Skip to content

Instantly share code, notes, and snippets.

@todocono
Created March 10, 2020 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todocono/cb1cd5ff003587ecf8de3baa3b812e61 to your computer and use it in GitHub Desktop.
Save todocono/cb1cd5ff003587ecf8de3baa3b812e61 to your computer and use it in GitHub Desktop.
/* 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