xxxxxxxxxx
22
let squares = [];
function setup() {
createCanvas(400, 400);
noStroke();
for (let x = 0; x < width; x += 100) {
for (let y = 0; y < height; y += 100) {
let col = color(random(255), random(255), random(255));
squares.push({ x, y, col });
}
}
}
function draw() {
background(0);
for (let i = 0; i < squares.length; i++) {
fill(squares[i].col);
rect(squares[i].x, squares[i].y, 100, 100);
}
}