#FLcreativecoding Week 2, 04 - The Clocks
/*
* Creative Coding
* Week 2, 04 - The Clocks
completely rec0ded by Marius Ivaskevicius
special feature morphing clock faces and arrows
*/
int detail=48;
int eventCouter=0;
int eventDelay=100;
class Pin{
float pinX=0;
float pinY=0;
int desX=0;
int desY=0;
int speed=10;
Pin(float x,float y){
this.pinX=x;
this.pinY=y;
this.desX=int(this.pinX);
this.desY=int(this.pinY);
}
void go(int x,int y){
this.desX=x;
this.desY=y;
}
float getX(){
this.pinX-=(this.pinX-this.desX)/this.speed;
return this.pinX;
}
float getY(){return this.pinY-=(this.pinY-this.desY)/this.speed;}
}
class Face{
int x;
int y;
int size=50;
int form=0;
Pin[] pins;
float rotation=0;
Face(int x,int y,int shape){
this.x=x;
this.y=y;
this.pins= new Pin[detail];
for(int i=0;i
int(this.y+cos(i*TWO_PI/detail)*this.size));
}
}
void nclower(int n){
for(int i=0;i
this.y+int(cos(i*TWO_PI/detail+this.rotation)*(this.size + cos(i*TWO_PI/detail*n+this.rotation)*this.size/2)*0.6));
}
}
void turn(float ang){
this.rotation=ang;
transformUpdate();
}
void transform(int to){
this.form=to;
transformUpdate();
}
void transformUpdate(){
switch(this.form){
case 0://circle
for(int i=0;i
int(this.y+cos(i*TWO_PI/detail)*this.size));
}
break;
case 1://triangle
int ax=int(this.x+sin(TWO_PI/6.0)*this.size*1.2);
int ay=int(this.y+cos(TWO_PI/6.0)*this.size*1.2);
int bx=int(this.x+sin(TWO_PI/6.0*3.0)*this.size*1.2);
int by=int(this.y+cos(TWO_PI/6.0*3.0)*this.size*1.2);
int cx=int(this.x+sin(TWO_PI/6.0*5.0)*this.size*1.2);
int cy=int(this.y+cos(TWO_PI/6.0*5.0)*this.size*1.2);
for(int i=0;i
}
for(int i=detail/3;i
}
for(int i=detail/3*2;i
}
break;
case 2://square
int dx=int(this.x+sin(TWO_PI/8.0)*this.size*1.2);
int dy=int(this.y+cos(TWO_PI/8.0)*this.size*1.2);
int ex=int(this.x+sin(TWO_PI/8.0*3.0)*this.size*1.2);
int ey=int(this.y+cos(TWO_PI/8.0*3.0)*this.size*1.2);
int fx=int(this.x+sin(TWO_PI/8.0*5.0)*this.size*1.2);
int fy=int(this.y+cos(TWO_PI/8.0*5.0)*this.size*1.2);
int gx=int(this.x+sin(TWO_PI/8.0*7.0)*this.size*1.2);
int gy=int(this.y+cos(TWO_PI/8.0*7.0)*this.size*1.2);
for(int i=0;i
}
for(int i=detail/4;i
}
for(int i=detail/4*2;i
}
for(int i=detail/4*3;i
}
break;
case 3://nclower 2
nclower(2);
break;
case 4://nclower 3
nclower(3);
break;
case 5://nclower 4
nclower(4);
break;
}
}
void update(){
int j=1;
beginShape();
for(int i=0;i
}
}
Face[] faces;
Face[] arrows;
void setup() {
faces=new Face[25];
for(int i=0;i<5 br="" i=""> for(int j=0;j<5 br="" j=""> faces[i*5+j]=new Face(j*55+40,i*55+40,0);
faces[i*5+j].transform(0);
}
}
arrows=new Face[25];
for(int i=0;i<5 br="" i=""> for(int j=0;j<5 br="" j=""> arrows[i*5+j]=new Face(j*55+40,i*55+40,0);
arrows[i*5+j].transform(2);
}
}
size(600, 600);
background(180);
rectMode(CENTER);
}
int shapeA=2;
int shapeB=2;
void draw() {
eventCouter++;
if(eventCouter>eventDelay){
eventCouter=0;
shapeA=int(random(0,3));
shapeB=int(random(0,3));
for(int i=0;i<25 br="" i=""> if(i%2==0){faces[i].transform(shapeA);}
else{faces[i].transform(shapeB);}
}
shapeA=int(random(3,6));
for(int i=0;i<25 arrows="" br="" i="" shapea="" transform=""> }
background(206,67,0);
strokeWeight(2);
int num = 5;
for (int i=0; i
fill(255,128,64);
faces[i*5+j].update();
arrows[i*5+j].turn(((i+1)*5+j)* TWO_PI * millis() / 60000.0);
fill(255,155,64);
stroke(255,179,64);
arrows[i*5+j].update();
}
}
}//end of draw
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home