xxxxxxxxxx
35
/*
This program draws a checkerboard
in black and white
by Daniel Weiner
3/1/21
*/
function setup() {
createCanvas(400, 400);
background(220);
fill(220);
let numRows = 8;
let numCols = 8;
let sqW = width / numRows;
let sqH = sqW;
for (let i = 0; i < numRows; i++) {
for (let j = 0; j < numCols; j++) {
rect(sqW*j, sqH*i, sqW, sqH);
// only draw ellipse if i+j is even
let drawCirc = (i+j)%2 == 0;
if (drawCirc) {
ellipse(sqW*j+sqW/2, sqH*i+sqH/2, sqW, sqH);
}
}
}
}
function draw() {
}