Created
May 12, 2015 00:31
-
-
Save clavis-magna/71c4b056502687899a5a to your computer and use it in GitHub Desktop.
change color of screen based on mouse click
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
//tests if mouse button is pressed and where the mouse is on the screen | |
//changes background color accordingly | |
void setup(){ | |
size(500,500); | |
background(255,0,0); | |
} | |
void draw(){ | |
//top left quater of screen && mouse pressed | |
if(mousePressed && mouseX > 0 && mouseY > 0 && mouseX < 250 && mouseY < 250){ | |
background(0,255,0); | |
} | |
//top right quarter of screen && mouse pressed | |
else if(mousePressed && mouseX > 250 && mouseY > 0 && mouseX < 500 && mouseY < 250){ | |
background(0,0,255); | |
} | |
//anything else | |
else{ | |
background(255,0,0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment