xxxxxxxxxx
let r = 255
let g = 255
let b = 255
function setup() {
createCanvas(500, 500)
noStroke()
let numRow = 50
let numCol = 50
let boxW = width/numRow
let boxH = height/numCol
let rStep = 255/numRow
let bStep = 255/numCol
for (var i = 0; i < numRow; i++){
r -= rStep
for (var j = 0; j < numCol; j++){
b -=bStep
let xPos = i/numRow*width
let yPos = j/numCol*height
let col = 255
if (j%2 == 0){
if ( i%2 == 0){
col = [r,g,b]
}
}
if (i%2 != 0){
if ( j%2 != 0){
col = [r,g,b]
}
}
if (i%3 == 0){
if ( j%3 == 0){
col = [b,r,g]
}
}
fill(col)
rect(xPos,yPos,boxW,boxH)
}
b = 255
}
}