xxxxxxxxxx
153
let h, w, y;
function setup() {
createCanvas(400, 400);
h = height;
w = width / 20;
y = 0;
}
function draw() {
background(220);
if (mouseX > 0 && mouseX <= w) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(0, y, w, h);
if (mouseX > w && mouseX <= w * 2) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w, y, w, h);
if (mouseX > w * 2 && mouseX <= w * 3) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 2, y, w, h);
if (mouseX > w * 3 && mouseX <= w * 4) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 3, y, w, h);
if (mouseX > w * 4 && mouseX <= w * 5) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 4, y, w, h);
if (mouseX > w * 5 && mouseX <= w * 6) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 5, y, w, h);
if (mouseX > w * 6 && mouseX <= w * 7) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 6, y, w, h);
if (mouseX > w * 7 && mouseX <= w * 8) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 7, y, w, h);
if (mouseX > w * 8 && mouseX <= w * 9) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 8, y, w, h);
if (mouseX > w * 9 && mouseX <= w * 10) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 9, y, w, h);
if (mouseX > w * 10 && mouseX <= w * 11) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 10, y, w, h);
if (mouseX > w * 11 && mouseX <= w * 12) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 11, y, w, h);
if (mouseX > w * 12 && mouseX <= w * 13) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 12, y, w, h);
if (mouseX > w * 13 && mouseX <= w * 14) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 13, y, w, h);
if (mouseX > w * 14 && mouseX <= w * 15) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 14, y, w, h);
if (mouseX > w * 15 && mouseX <= w * 16) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 15, y, w, h);
if (mouseX > w * 16 && mouseX <= w * 17) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 16, y, w, h);
if (mouseX > w * 17 && mouseX <= w * 18) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 17, y, w, h);
if (mouseX > w * 18 && mouseX <= w * 19) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 18, y, w, h);
if (mouseX > w * 19 && mouseX <= w * 20) {
fill(255, 0, 0);
} else {
fill(255);
}
rect(w * 19, y, w, h);
}