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;
}
Leave a Reply