/* built with Studio Sketchpad: * https://sketchpad.cc * * observe the evolution of this sketch: * https://studio.sketchpad.cc/sp/pad/view/ro.VvOZn5eUiyZ/rev.8 * * authors: * GoToLoop * license (unless otherwise specified): * creative commons attribution-share alike 3.0 license. * https://creativecommons.org/licenses/by-sa/3.0/ */ /** * Follow My Lead Closely! (v3.03) * by jordanorelli (2014/Feb) * mod GoToLoop * * forum.processing.org/two/discussion/2846/my-first-code * * studio.processingtogether.com/sp/pad/export/ro.90vdKMfkiO$zf/latest */ static final color LEADER_C = #B22222, CHASER_C = #1874CD; static final int DIM = 050, GAP = 10; final PVector[] hist = new PVector[GAP]; int idx; void setup() { size(600, 600, JAVA2D); frameRate(60); smooth(4); noStroke(); noCursor(); ellipseMode(CENTER); mouseX = mouseY = width<<1; for (int i = GAP; i-- != 0; hist[i] = new PVector(mouseX, mouseY)); } void draw() { background(-1); hist[idx].set(mouseX, mouseY); final PVector old = hist[idx = (idx + 1) % GAP]; fill(CHASER_C); ellipse(old.x, old.y, DIM, DIM); fill(LEADER_C); ellipse(mouseX, mouseY, DIM, DIM); }