/* Matt Martell IAT 800 - Dr. Christopher Shaw Due Oct. 6, 2008 A2-08 - Create a dynamic animation using the cos() and sin() function as a generator for motion. */ void setup() { background (3444); size(400,400); smooth(); stroke(230,230,250); frameRate(3); } //Variables float rotation = 0; float xPos; float yPos; float i = PI; float a = 0.0; float inc = PI*1/8; void draw () { background(3444); rotation =inc; inc++; // To set postion of the line xPos =200 + sin(rotation)*10; yPos =250 + sin(rotation)*10; //To build the line pushMatrix(); strokeWeight (4); stroke(random(255),random(255),145); translate (xPos, yPos); rotate (rotation); line (50,50,80,80); popMatrix(); //To build the cosine graph (code courtesy of processing reference library) stroke (255,22,189); for(int i=0; i<150; i++) { line(i*4, 50, i*4, 50+cos(a)*30.0); a = a + inc; } }