/* Animation Assignment: Moving objects, changing colors, mouse click/placement interaction Liz Rutledge August 9, 2010 */ float ax=1;// 5 points that will make up bezier shape float ay=1; float bx=30; float by=39; float cx=80; float cy=68; float dx=85; float dy=40; float ex=ax; float ey=ay; float n=0.1; //increment variables float m=0.1; float rx=800; //rectangle x,y,width and height float ry=0; float rw=100; float rh=200; float sx=10; //ellipse parameters float sy=50; float sw=30; float sh=20; float sz=-1*.001; //third shape increment float s2x=1; int r1=mouseX/3; int g1=255-mouseY/3; int b1=mouseY/3; int r2; int g2; int b2; int r3; int g3; int b3; color c1=color(r1,g1,b1); //colors for 3 different shapes color c2=color(r2,g2,b2); color c3=color(r3,g3,b3); void setup() { size(800,800); frameRate(30); smooth(); } void draw() { background((mouseX+mouseY)/6); r1=0; g1=255-mouseY/3; b1=mouseX/3; color c3=color(r3,g3,b3); /*BEGIN SHAPE 1*/ color c1=color(r1,g1,b1); //colors for 3 different shapes ex=ax; ey=ay; fill(c1); beginShape(); //bezier shape with 5 points vertex(ax,ay); bezierVertex(bx-20, by+20,bx+20,by-20,bx,by); bezierVertex(cx-60, cy+40,cx+60,cy+40,cx,cy); bezierVertex(dx-35,dy+15,dx+10,dy+5,dx,dy); bezierVertex(ex-25, ey-10,ex+30, ey-10, ex,ey); endShape(); ax=ax+2*n; //incrementation for shape 1 ay=ay+3*m; bx=1.01*bx; by=1.06*by; cx=1.01*cx; cy=1.01*cy; dx=dx+3*n; dy=dy+2*n; n=n+.05; m=m+.05; /*BEGIN SHAPE 2*/ color c2=color(r2,g2,b2); r2=255-mouseX/3; g2=mouseY/3; b2=0; // b2=255-mouseX/3; fill(c2); rectMode(CENTER); rect(rx,ry,rw,rh); rx=rx-5; ry=ry+5; rw=-1.0000000001*n+rw; // rh=1.0000000001*m+rh; rh=20*(pow(sz,2)+3*(sz)+3); /*BEGIN SHAPE 3*/ c3=color(r3,g3,b3); r3=mouseY/3; g3=100; b3=255-mouseX/3; fill(c3); ellipse(sx,sy,sw,sh); sy=50*(pow(sz,2)+3*(sz)+3); //quadratic equation to generate parabolic motion sw=sw*1.03; // ellipse incrementing sh=sh*1.03; sz=sz-.08; sx=sx+8; /*BEGIN SHAPE 4*/ c3=color(b3,g3,r3); //swapped r3 and b3 to be opposite color of shape 3 r3=mouseY/3; g3=0; b3=255-mouseX/3; fill(c3); ellipse(s2x,sy,sw,sh); sy=10*(pow(sz,2)-3*(sz)+3); //quadratic equation to generate parabolic motion sw=sw*1.02; // ellipse incrementing sh=sh*1.02; sz=sz-.05; s2x=s2x+20; println(frameCount); } void mousePressed() { sw=60; sz=-.0005; }