xxxxxxxxxx
25
let col = 10;
let row = 10;
let gridWidth = 400;
let gridHeight = 400;
function setup() {
createCanvas(gridWidth, gridHeight);
noLoop();
}
function draw() {
background(255);
let cellWidth = gridWidth / col;
let cellHeight = gridHeight / row;
for (let i = 0; i < col; i++) {
for (let j = 0; j < row; j++) {
if ((i + j) % 2 == 0) {
fill("black");
} else {
fill("white");
}
rect(i * cellWidth, j * cellHeight, cellWidth, cellHeight);
}
}
}