xxxxxxxxxx
41
var rWidth, rSpacing;
function setup() {
createCanvas(400, 400);
background(100);
noStroke();
}
function draw() {
/*
What we are going to do now is set up a
nested for loop
to make the rows of checkers repeat vertically.
*/
for (var y = 0; y < 400; y = y + 60) {
fill(255);
rect(0,y, 400, 30);
fill(0);
rect(0,y+30, 400, 30);
rWidth = 30;
rSpacing = 60;
for (var x = 0; x < 9; x++) {
if (rWidth > 0) {
rWidth-=3;
rSpacing-=3;
}
fill(0);
rect(x*rSpacing, y, rWidth, 30);
fill(255);
rect(x*rSpacing, y+30, rWidth, 30);
}
}
}