• fullscreen
  • sketch41676.pde
  • int p = 5; //this is for the push (negative space) between the areas
    int num = 4; // number of cells in a row
    float cell;
    
    void setup () {
      size(400, 400);
      cell =  width/num; // cell size
    }
    
    
    void draw() {
    } 
    
    void mousePressed() {
      background(255);
      for (int i = 0; i < cell/p; i++) { // this loop determines the number of cells to draw (e.g. 4 x 4 = 16)
        int count = 0;
        stroke(random(1, 255)); // same stroke for all lines
        for (int y = 0; y < height; y+=cell) {
          if (num % 2 == 0) {
            count++; // if the number of modules in a column is even, add one to count to maintain checker effect
          }
          for (int x = 0; x < width; x+=cell) {
            strokeWeight(random(1, 5)); // random strokeweight for each line
            if (count % 2 == 0) { 
              line(x, y + i*p, x + cell-p, y + i*p); // even numbered cells
            }
            else { 
              line(x + i*p, y, x + i*p, y + cell-p); // odd numbered cells
            }
            count++;
          }
        }
      }
    }                                               

    code

    tweaks (0)

    about this sketch

    This sketch is running in HTML5 using Processingjs.

    license

    advertisement

    Nick Senske

    Mikale P1 notes

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    You need to login/register to comment.