var boolDoRefresh; function setup() { createCanvas(400, 400); boolDoRefresh = true; } function draw() { if (boolDoRefresh) { background(255,255,255); stroke(51); strokeWeight(4); var gridSize=8; for(var i=0, x=10;i<=gridSize;i++, x+=50){ for(var k=0,y=10;k<=gridSize;k++,y+=50) { var r=random(3); if(r<0.3){ ellipse(x+10,y+10,20,20); } else{ rect(x,y,20,20); } } } boolDoRefresh = false; } } function mousePressed() { boolDoRefresh = true; } |