Exercise 27

Adding a small probability of a red square to our grid


size(400, 400);
noStroke();
background(255);

float x = 0;
while (x < width) {
  float y = 0;
  while (y < height) {
        if (random(100) > 98) {
      fill(255, 0, 0);
    } 
    else {
      // but usually pick a random gray color
      fill(random(100, 200));
    }

    rect(x, y, 38, 38);
    y = y + 40;
  }
  x = x + 40;
}

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *