Skip to content

Instantly share code, notes, and snippets.

@slambert
Last active September 20, 2016 21:56
Show Gist options
  • Select an option

  • Save slambert/fd2a02ddc31738160406499204de5a34 to your computer and use it in GitHub Desktop.

Select an option

Save slambert/fd2a02ddc31738160406499204de5a34 to your computer and use it in GitHub Desktop.
Track amount of times mouse has clicked and change sketch. More than a switch....
// declare int variable
int clickcount = 0;
void setup(){
size(500,500);
background(0);
}
void draw(){
// Conditional colors
if(clickcount == 0){
background(255,0,0); // red
} if (clickcount == 1){
background(255); // white
} if (clickcount == 2){
background(255,0,255); // magenta
} if (clickcount >=3){
background(random(255));
}
// Draw the circle
//background(0); //make it black!
// make a circle that wont go away
noStroke();
// fill(255);
ellipse(mouseX,mouseY,30,30);
println("Click count is: " + clickcount);
} //draw
void mouseReleased(){
clickcount = clickcount + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment