xxxxxxxxxx
38
/*******************************************************************
NAME: Zenek Chapman
DATE: 10 October 2024
CLASS: Computer Science 30
PROGRAM DESCRIPTION: This program creates a ellipse that follows the mouse and changes colour depending on the quadrant it is in
*******************************************************************/
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
mouseClicked()
}
function mouseClicked(){
ellipse(mouseX, mouseY, 40, 40)
if (mouseX < width/2 && mouseX > 0 && mouseY< height/2 && mouseY > 0 && keyIsPressed === true){ //check is it in qudrant 2
fill(33,56,223)
}
else if (mouseX > width/2 && mouseX < width && mouseY< height/2 && mouseY > 0 && keyIsPressed === true){ //check if it is in qudrant 1
fill (20, 200, 80)
}
else if (mouseX > width/2 && mouseX < width && mouseY< 400 && mouseY > 200 && keyIsPressed === true){ //check if it is in qudrant 4
fill (230, 10, 80)
}
else if (mouseX > 0 && mouseX < width/2 && mouseY < height && mouseY > height/2 && keyIsPressed === true){ //check if it is in qudrant 3
fill (240, 190, 40)
}
if (keyIsPressed === false){
fill (255)
}
}