xxxxxxxxxx
function setup() {
createCanvas(500, 500)
noStroke()
}
function draw() {
// how draw 10 squares?
// what i stand for? (increment)
let numRow = 50
let numCol = 50
let spacingX = width / numRow
let spacingY = height / numCol
for (let i = 0; i < numRow; i++) {
for (let j = 0; j < numCol; j++) {
push()
let r = i / numCol * 255
let g = j / numRow * 255
fill('white')
if (j % 2 == 0) {
// this is a trick for even number
if (i % 2 == 0) {
// fill('black')
fill(r, 0, g)
}
}
if (j % 2 != 0) {
// this is a trick for even number
if (i % 2 != 0) {
translate(second(),second()*2)
fill(r, g, 0)
}
}
if (j % 7 == 0) {
// this is a trick for even number
if (i % 7 == 0) {
translate(-second(),-second())
fill('pink')
}
}
let xPos = i * spacingX // 0, 50, 100,
let yPos = j * spacingY
rect(xPos, yPos, spacingX, spacingY)
pop()
}
}
}