// Pendulum Paint // Daniel Shiffman // Nov 19, 2005 // Messed with my original pendulum example from http://www.shiffman.net/itp/classes/nature/ ArrayList a; float xoff = 0.0; float yoff = 100.0; void setup() { size(200,200); framerate(30); smooth(); colorMode(RGB,255,255,255,255); a = new ArrayList(); float y = 0; for (int i = 0; i < 8; i++) { // Make a new Pendulum with an origin location and armlength Pendulum p = new Pendulum(new Vector3D(width/2,y),50.0f); p.theta=radians(random(-180,180)); a.add(p); y+=50; } background(0); } void draw() { //background(0); fill(50,5); rect(0,0,width,height); for (int i = 0; i < a.size(); i++) { Pendulum p = (Pendulum) a.get(i); if (i > 0) { Pendulum prev = (Pendulum) a.get(i-1); p.origin = prev.loc.copy(); } p.go(); } //xoff += 0.01; //yoff += 0.01; //saveFrame(); } void mousePressed() { for (int i = 0; i < a.size(); i++) { Pendulum p = (Pendulum) a.get(i); p.clicked(mouseX,mouseY); } } void mouseReleased() { for (int i = 0; i < a.size(); i++) { Pendulum p = (Pendulum) a.get(i); p.stopDragging(); } }