Haig Armen Educational Archive


Exercise 27

by Haig. Average Reading Time: less than a minute.

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  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;
}

No comments on ‘Exercise 27’

Leave a Reply