Created
January 28, 2016 18:21
-
-
Save ohmygodwin/d6f8296181860964e094 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
void setup() { | |
size(480, 270); | |
background(255); | |
} | |
void draw() { | |
//change the stroke weight to have a thicker line | |
strokeWeight(25); | |
//use the random function to get a random color for the stroke | |
stroke(random(0,255),random(0,255),random(0,255)); | |
//draw a line from previous mouse location to current mouse location | |
line(pmouseX, pmouseY, mouseX, mouseY); | |
} | |
void mousePressed() { | |
//reset the background when the mouse is pressed | |
background(255); | |
} | |
void keyPressed() { | |
//reset the background when certain keys are pressed | |
if (key == 'a') { | |
background(0); | |
} | |
else if (key == 's') { | |
background(255,0,0); | |
} | |
else if (key == 'd') { | |
background(0,255,0); | |
} | |
else if (key == 'f') { | |
background(0,0,255); | |
} | |
else if (key == 'r') { | |
background(random(0,255),random(0,255),random(0,255)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment