xxxxxxxxxx
29
//press switch to turn the light on and off
var on = false
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
if (on) {
background(255);
} else {
background(0);
}
rectMode(CENTER);
stroke(0);
fill(255);
rect(200, 200, 100, 100);
}
function mousePressed() {
if (mouseX > 150 && mouseX < 250 && mouseY > 150 && mouseY < 250) {
on = !on
}
}