xxxxxxxxxx
44
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// counting pixel
// for (let x=0; x<width; x +=40){
// rect(x,0,40,height);
// }
//counting columns
// for (let c = 0 ; c<10; c++){
// if (c! == 6){//skip column 7
// let x = c*40;
// rect(x,0,40,height);
// }
// }
// NO! possible way to make grid but not really
// for (let a = 0; a<10; a++){
// let x = a * 40;
// rect(x,0,40,height);
// }
//CHECKERBOARD
for (let c = 0; c <10; c++){
let x = c *40;
for (let r = 0; r<10; r++){
let y = r*40;
//if ((c % 2 == 0 && r % 2 == 0)|| (c % 2 == 1 && r % 2 ==1 ){ %% is modular. it is combination of divide and plus.
if ((c + r) % 2 == 0)
{
fill("red");
}else {
fill('white');
}
rect (x,y,40,40)
}
}
}