// Sketch for animation for mobile phone company "3". // Time-based computational animation. // // See http://www.unlekker.net/proj/DREIx3x2x2D/ int numObj,numEvent,cnt; float scaleIt,colors[][],zMax,zMin; float tri[][],penta[][],dodo[][]; int dodoNum=30; Event event[]; void setup() { // size(240,320); size(576,768); size(300,400); // framerate(25); smooth(); background(255); ellipseMode(CENTER_DIAMETER); rectMode(CENTER_DIAMETER); scaleIt=(float)width/576.0f; initShapes(); colors=new float[5][3]; addColor(0, 100,0,0); addColor(0, 40,0,60); addColor(0, 20,80,40); addColor(0, 80,30,10); addColor(1, 255,60,0); addColor(2, 0,100,255); addColor(3, 255,255,255); cnt=0; zMax=400; zMin=0; numEvent=200; event=new Event[numEvent]; for(int i=0; i=event[i].start && event[i].stateCnt!=-1) event[i].draw(); pop(); if(cnt%10==0) println("cnt "+cnt); cnt++; // Run only to 675 frames == 3*3*3 seconds / 25 fps // then reset if(cnt>675) { cnt=0; for(int i=0; i100 && start>120) col=3; type=0; if(start<200) type=0; else if(start<300 && random(100)>99) type=(int)random(100)%4+1; else if(start<400 && random(100)>90) type=(int)random(100)%4+1; else if(start<500 && random(100)>70) type=(int)random(100)%4+1; else if(random(100)>50) type=(int)random(100)%4+1; type=0; rad=(int)(random(4)+1)*3; if(random(100)>98) rad+=10; vD=new Vec3D(rad*0.7,0,0); vD.rotateZ(random(PI*2)); newMove(); rotD=1+random(2);//+(random(2)-1)*0.2; if(random(100)>50) rotD=-rotD; } void newMove() { // vD.set(random(2)-1,random(2)-1,random(2)-1); // vD.rotateX(random(PI/6.0f)-PI/12.0f); // vD.rotateY(random(PI/6.0f)-PI/12.0f); if(random(100)>50) vD.rotateZ(PI/2); else vD.rotateZ(-PI/2); moveCnt=(int)random(6)+6; } public void draw() { T=1-D*(float)stateCnt; // if(T<0.2) fract=1-T*5.0f; if(T>=0.8) fract=1-(1-T)*5.0f; else fract=0; fill(colors[col][0],colors[col][1],colors[col][2], 225-225*fract); // 200-abs(200*cos(PI+PI*D*(float)stateCnt))); fract=abs(sin(PI*0.5+PI*0.5*D*(float)stateCnt));// fract=T; fract*=fract; if(drawCnt200) rotate(PI*2*(float)(start-200)/475); // if(start>100) rotateY(PI*0.4*(float)(start-100)/575); scale(1+T*T*3,1+T*T*3); translate(v[i].x,v[i].y,v[i].z); if(type==0) ellipse(0,0,currRad,currRad); else if(type==1) pentagon(0,0,currRad,currRad*0.6); else if(type==2) dodogon(0,0,currRad,currRad*0.4,2); else if(type==3) trigon(0,0,currRad,currRad*0.75); else if(type==4) cross(0,0,currRad/2,currRad/6); pop(); } stateCnt--; } } void initShapes() { tri=new float[3][2]; penta=new float[5][2]; dodo=new float[dodoNum][2]; for(int i=0; i