Created
March 10, 2020 03:01
-
-
Save todocono/cb1cd5ff003587ecf8de3baa3b812e61 to your computer and use it in GitHub Desktop.
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
/* IxLab 2020S - NYU Shanghai | |
* Example to review how to use millis(), map() and if else | |
* Ideas for exercises to practice: | |
* change the map values | |
* add other animations with the background that include colors | |
* add a bouncing ball | |
*/ | |
void setup() { | |
size(500, 500); | |
} | |
void draw() { | |
int m = millis(); | |
if ((m > 00) && (m<3000)) { | |
float b = map(m, 0, 3000, 255, 0); | |
background(b); | |
} else if ((m >= 3000) && (m <= 6000)) { | |
float c = map(m % 1000, 0, 1000, 0, 255); | |
println(c); | |
background(c); | |
} else { | |
background(125); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment