xxxxxxxxxx
//A template you can use for Chris Ried's Coding Challenge week 1
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
}
function draw() {
drawCheckerBox(0, 0, width, height,50,'#ffffff','#000000');
}
const drawCheckerBox = (x, y, w, h, n, clr1, clr2) => {
let w_diff = w / n;
let h_diff = h / n;
let cnt = 0;
noStroke();
push();
translate(x, y);
for (let j = 0; j < n; j++) {
for (let k = 0; k < n; k++) {
let clr = cnt % 2 == 0 ? clr1 : clr2;
fill(clr);
rect(j * w_diff, k * h_diff, w_diff, h_diff);
cnt++;}}
pop();
};