Advertisement
xeromino

grids

Mar 19th, 2016
335
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var edge, step, rows;
  2.  
  3. function setup() {
  4.   createCanvas(600, 800);
  5.   colorMode(HSB, 360, 100, 100);
  6.   edge = 50;
  7.   rows = 14;
  8.   step = (height - 2 * edge) / rows;
  9.  
  10.   drawGrid();
  11. }
  12.  
  13. function drawGrid() {
  14.   background('#202020');
  15.   for (var x = edge + step / 2; x < width - edge; x += step) {
  16.     for (var y = edge + step / 2; y < height - edge; y += step) {
  17.       drawElement(x, y);
  18.     }
  19.   }
  20. }
  21.  
  22. function drawElement(x, y) {
  23.   var sz = step * .9;
  24.   noFill();
  25.  
  26.   //stroke("#ffffff");
  27.   strokeCap(SQUARE);
  28.   if (random(1) > 0.2) {
  29.     while (sz > step * .1) {
  30.       strokeWeight(random(1, 2));
  31.       stroke(random(0, 360), 100, 100);
  32.       push();
  33.       translate(x, y);
  34.       rotate(random(TWO_PI));
  35.       var end = random(PI / 2, TWO_PI);
  36.       arc(0, 0, sz, sz, 0, end);
  37.       pop();
  38.       sz += -step * .1;
  39.     }
  40.   }
  41. }
  42.  
  43. function mouseReleased() {
  44.   drawGrid();
  45. }
  46.  
  47. function keyTyped() {
  48.   if (key === 's') save("image-" + int(random(12345)) + ".png");
  49. }
  50.  
  51. function draw() {
  52.  
  53. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement