xxxxxxxxxx
function setup() {
createCanvas(500, 500);
}
function draw() {
background(0);
stroke(255);
// X Lines to illustrate
line(200,0,200,height);
line(300,0,300,height);
// Y Lines to illustrate
line(0,200,width,200);
line(0,300,width,300);
if (mouseX > 200 && mouseX < 300 && mouseY > 200 && mouseY < 300)
// IF our mouse is at the same time :
// Between 200 and 300 on the X axis
// Between 200 and 300 on the Y axis
{
fill(0,255,0); // Our ellipse will be filled with GREEN
}
else
{
fill(255,0,0); // ELSE, our ellipse will be filled with RED
}
noStroke();
ellipse(mouseX, mouseY, 50, 50);
}