xxxxxxxxxx
18
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
let numRects = 5;
let rectWidth = width / numRects;
for (let i = 0; i < numRects; i++) {
fill("white")
if (mouseX > i * rectWidth && mouseX < i * rectWidth + rectWidth) {
fill("red");
}
rect(i * rectWidth, 0, rectWidth, height);
}
}