xxxxxxxxxx
37
let lightOn
function setup() {
createCanvas(600, 400);
}
function draw() {
background(255);
setLineDash([5, 5]); //create the dashed line pattern here
line(400,0,400,height)
if(lightOn){
fill("red")
rect(400,0,200,400)
}
//if the mouse came from <400 to >400
if(mouseX>=400 && pmouseX<400){
// lightOn mode will chande oppositely
lightOn = !lightOn
}
console.log(mouseX)
//text
fill(0)
textSize(15)
textAlign(CENTER)
text('move mouse to the rightside!->',400/2,height/2)
}
function setLineDash(list) {
drawingContext.setLineDash(list);
}