Created
April 7, 2020 02:58
-
-
Save moziauddin/f1f0ea22e9fb19c69b529ee719fc262a to your computer and use it in GitHub Desktop.
Processing Mouse Envents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int rectSize = 100; | |
float rectX ; | |
float rectY; | |
void setup() { | |
size(400,400); | |
background(250); | |
rectX = width* 0.4; | |
rectY = height * 0.4; | |
} | |
void draw() { | |
fill(99); | |
rect(rectX, rectY, rectSize, rectSize); | |
} | |
void mousePressed() { | |
if((mouseX > rectX && mouseX < (rectX + rectSize)) && | |
(mouseY > rectY && mouseY < (rectY + rectSize))){ | |
println("Clicked within the square. MouseX: " + mouseX + " - MouseY: " + mouseY); | |
} else { | |
println("You've crossed your boundaries, how dare you?"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment