//********************************************************************// //CAAD D_ARCH UnCover PSZ Project: Pillars_Pavilion Class Pillar // //WS06/07 12. FEB. 2007 by Huang, Yung-Chieh | BaTeam MaeTaB // //********************************************************************// class Pillar { float Radius; //pillar radius float PosX; //pillar position x float PosY; //pillar position y Pillar(float r, float px, float py) { Radius=r; PosX=px; PosY=py; } /**********Set Movement Rules**********/ void move(float dm, int b) { ellipseMode(CENTER); float mx1=mouseX; float my1=mouseY; float mx2=width-mouseX; float my2=height-mouseY; float d1 = dist(PosX, PosY, mx1, my1); float d2 = dist(PosX, PosY, mx2, my2); color c = color(d1/2, (255-(d1/2)), (255-d1)); stroke(c); fill(c); float mbx1=((PosX-mx1)*dm*dm)/(d1*d1*b*40); float mby1=((PosY-my1)*dm*dm)/(d1*d1*b*40); float mbx2=((PosX-mx2)*dm*dm)/(d2*d2*b*40); float mby2=((PosY-my2)*dm*dm)/(d2*d2*b*40); if((d2 <= 1.6*b) && (d1 > 1.6*b)){ PosX += ((PosX-mx2)*dm*dm)/(102.4*b*b*b); PosY += ((PosY-my2)*dm*dm)/(102.4*b*b*b); } else if((d2 <= dm) && (d2 > 1.6*b) && (d1 > 1.6*b)){ PosX += mbx2; PosY += mby2; } if(d1 <= 1.6*b){ PosX += ((PosX-mx1)*dm*dm)/(102.4*b*b*b); PosY += ((PosY-my1)*dm*dm)/(102.4*b*b*b); } else if((d1 <= dm) && (d1 > 1.6*b)){ PosX += mbx1; PosY += mby1; } /**********Pillar Field Limitation**********/ if(PosX < b){ PosX=b; } if(PosX > (width-b)){ PosX = (width-b); } if(PosY < b){ PosY=b; } if(PosY > (height-b)){ PosY = (height-b); } /*********Draw Pillar*********/ strokeWeight(100); ellipse(PosX, PosY, Radius*2, Radius*2); line(PosX, PosY, 0, PosX, PosY, 5*b); } }