// Spiral Feedback by Jim Bumgardner // int currentFrame = 0; int max_frames = 24; PImage[] frames = new PImage[max_frames]; float r = 0; float a = 0; float maxRad = 240; float cx,cy; float phi = (sqrt(5)+1)/2 - 1; // golden ratio float golden_angle = phi * TWO_PI; // golden angle float angleIncrement = golden_angle / (24*PI); void setup() { size(500, 500); cx = width/2; cy = height/2; smooth(); background(255); frameRate(24); noStroke(); fill(0); colorMode(HSB,1); } void draw() { frames[currentFrame] = get(); // Get the display window currentFrame = (currentFrame + 1) % max_frames; if (frames[currentFrame] != null) { image(frames[currentFrame], 0, 0); } if (frameCount <= max_frames) background(#FFFFFF); a += angleIncrement; if (a > TWO_PI) a -= TWO_PI; r = sin(frameCount/24.0)*maxRad; float x = cx + sin(a)*r; float y = cy + cos(a)*r; fill(sin(millis()*.001)*.5+.5,1,.8, .5); ellipse(x, y, 10, 10); }