xxxxxxxxxx
32
let x;
let w;
function setup() {
createCanvas(400, 400);
w = width / 20;
}
function draw() {
background(220);
for (let i = 0; i < 10; i++) {
x = i * 20;
if (mouseX > x && mouseX < x + w) {
fill("red");
} else {
fill(255);
}
rect(x, 0, w, 400);
}
for (let i = 10; i < 20; i++) {
x = i * 20;
if (mouseX > x && mouseX < x + w) {
fill("blue");
} else {
fill(255);
}
rect(x, 0, w, 400);
}
}