/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.tqRcNgsNE-z/rev.4 * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /** * Frame-Independant Animation (v2.1) * by Quarks (2013/Jul) * * http://forum.processing.org/topic/scale-jumps-back-to-100 * http://studio.processingtogether.com/sp/pad/export/ro.9jAqLpHlv-8K3/latest */ float x; int y, lTime; static final short VEL_X = 0200; // pixels per second static final short DIM = 040, FPS = 60; static final color BG = #C0F0C0, FG = #800000; void setup() { size(400, 200); frameRate(FPS); fill(FG); noStroke(); y = height >> 1; lTime = millis(); } void draw() { // Get current time in milliseconds: final int cTime = millis(); // Calculate elapsed time in seconds: final float eTime = 1e-3 * (cTime - lTime); // Reset last time ready for next draw: lTime = cTime; // Move x by velocity * elapsed time: x = (x + VEL_X*eTime) % width; background(BG); ellipse(x, y, DIM, DIM); }