xxxxxxxxxx
54
let on = false;
let stay = false;
let lx;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(20);
for (lx = width / 3; lx <= width; lx += width / 3) {
stroke(255);
line(lx, 0, lx, height);
}
if (on) {
noStroke();
fill(200, 50, 150);
rect(width * 2 / 3, 0, width / 3, height);
} else {
noStroke();
noFill();
rect(width * 2 / 3, 0, width / 3, height);
}
if (stay) {
noStroke();
fill(200, 50, 150);
rect(width * 2 / 3, 0, width / 3, height);
} else {
noStroke();
noFill();
rect(width * 2 / 3, 0, width / 3, height);
}
if (mouseX > 2 * width / 3 && mouseX < width) {
if (on) {
stay = true;
} else {
stay = false;
}
}
if (mouseX < width * 2 / 3) {
on = false;
}
}
function mousePressed() {
if (mouseX > 2 * width / 3 && mouseX < width) {
on = true;
}
}