xxxxxxxxxx
40
var r;
var x, y;
var b, s;
function setup() {
createCanvas(400, 400);
background(220);
x = 0;
y = 0;
// frameRate(10);
b = 20;
s = b*2;
}
function draw() {
// background(220);
noStroke();
r = random(0, 1);
if (r < 0.5) {
fill(255);
rect(x, y, width/b, height/b);
// fill(0);
// rect(x, y, width/s, height/s);
fill(0)
rect(x + width/s, y + height/s, width/s, height/s);
} else {
fill(255);
rect(x, y, width/b, height/b);
// fill(0);
// rect(x + width/s, y, width/s, height/s);
fill(0);
rect(x, y + height/s, width/s, height/s);
}
x = x + width/s;
if(x>width){
x = 0;
y = y + height/b;
}
}