/** * Modulo cycling * * Math for artists who now need to program * ITP DriveBy, 10/2/2008 * Elie Zananiri - ez@silentlycrashing.net */ //---------------------------- // variables float currY; int currTime; //---------------------------- void setup() { // set up the applet size(300, 300); smooth(); frameRate(30); // reset the animation independent variable (time) currTime = 0; // set the ball color noStroke(); fill(#FF6F00); } //---------------------------- void draw() { // clear the screen background(0); // move the ball currY = move(currTime); // draw the ball ellipse(width/2, currY, 20, 20); currTime = (currTime+1)%55; } //---------------------------- void mousePressed() { // reset the animation independent variable (time) currTime = 0; } //---------------------------- float move(float x) { return (0.1 * pow(x, 2) + 10); }