casher-IterationExercise

 

var boolDoRefresh;
 
function setup() {
  createCanvas(400, 400);
	background('white');
  boolDoRefresh = true;
}
 
function draw() {
  if (boolDoRefresh) {
		background('white');
		for (var x = 0; x <= width; x += 50) {
			for (var y = 0; y <= width; y+= 50) {
 
				var maybeACircle = int(random(0,10));
				strokeWeight(1.5);
				if (maybeACircle == 0) {
					fill('blue');
					ellipse(x+23, y+23, 45, 45);
				}
				else {
					fill('white');
					rect(x, y, 45, 45);
				}
			}
		}
    boolDoRefresh = false;
	}
}
 
function mousePressed() {
  boolDoRefresh = true;
}