Created
September 18, 2012 16:43
-
-
Save liamartinez/3744207 to your computer and use it in GitHub Desktop.
simple state switch
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
color redColor; | |
color blueColor; | |
boolean colorIsRed; | |
void setup () { | |
redColor = color (255, 0, 0); | |
blueColor = color (0, 0, 255); | |
colorIsRed = false; //default to a blue color | |
} | |
void draw () { | |
//conditional changes the fill color based on the colorIsRed boolean | |
if (colorIsRed == true) { | |
fill (redColor); | |
} | |
else { | |
fill (blueColor); | |
} | |
//draw the ellipse | |
ellipseMode (CENTER); | |
ellipse (width/2, height/2, 50, 50); | |
} | |
void mousePressed () { | |
colorIsRed = !colorIsRed; //make colorIsRed equal to whatever colorIsRed is NOT | |
println ("colorIsRed is: " + colorIsRed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment