xxxxxxxxxx
29
let n = 10;
let w;
function setup() {
createCanvas(600, 600);
w = width / n;
}
function draw() {
background(20);
noStroke();
for (i = 1; i <= n / 2; i++) {
if (mouseX > (i - 1) * w && mouseX < i * w) {
fill(50, 0, 255);
} else {
noFill();
}
rect((i - 1) * w, 0, w, height);
}
for (i = n / 2 + 1; i <= n; i++) {
if (mouseX > (i - 1) * w && mouseX < i * w) {
fill(255, 0, 50);
} else {
noFill();
}
rect((i - 1) * w, 0, w, height);
}
}