xxxxxxxxxx
78
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
let x = width / 20
for (n = 0; n <= 20; n++) {
fill("white");
rect(n * x, 0, x, height);
}
if (mouseX < x) {
fill("red")
rect(0, 0, x, height);
} else if (mouseX < 2 * x) {
fill("red")
rect(x, 0, x, height);
} else if (mouseX < 3 * x) {
fill("red")
rect(x * 2, 0, x, height);
} else if (mouseX < 4 * x) {
fill("red")
rect(x * 3, 0, x, height);
} else if (mouseX < 5 * x) {
fill("red")
rect(x * 4, 0, x, height);
} else if (mouseX < 6 * x) {
fill("red")
rect(x * 5, 0, x, height);
} else if (mouseX < 7 * x) {
fill("red")
rect(x * 6, 0, x, height);
} else if (mouseX < 8 * x) {
fill("red")
rect(x * 7, 0, x, height);
} else if (mouseX < 9 * x) {
fill("red")
rect(x * 8, 0, x, height);
} else if (mouseX < 10 * x) {
fill("red")
rect(x * 9, 0, x, height);
} else if (mouseX < 11 * x) {
fill("red")
rect(x * 10, 0, x, height);
} else if (mouseX < 12 * x) {
fill("red")
rect(x * 11, 0, x, height);
} else if (mouseX < 13 * x) {
fill("red")
rect(x * 12, 0, x, height);
} else if (mouseX < 14 * x) {
fill("red")
rect(x * 13, 0, x, height);
} else if (mouseX < 15 * x) {
fill("red")
rect(x * 14, 0, x, height);
} else if (mouseX < 16 * x) {
fill("red")
rect(x * 15, 0, x, height);
} else if (mouseX < 17 * x) {
fill("red")
rect(x * 16, 0, x, height);
} else if (mouseX < 18 * x) {
fill("red")
rect(x * 17, 0, x, height);
} else if (mouseX < 19 * x) {
fill("red")
rect(x * 18, 0, x, height);
} else if (mouseX < 20 * x) {
fill("red")
rect(x * 19, 0, x, height);
}
}