xxxxxxxxxx
clock s;
clock m;
clock h;
spinning[]spinnings=new spinning[200];
fafafish a;
void setup() {
size(500, 500);
//clock
s = new clock (4, 0.9);
m = new clock (6, 0.7);
h = new clock (9, 0.6);
//spin
for (int i=0; i<150; i+=2) {
spinnings[i]=new spinning(random(130, 150), random(2*PI));
//fafafish
a= new fafafish (0, 0);
}
}
void draw() {
background(0);
smooth();
//cross
stroke(255, 0, 0);
strokeCap(SQUARE);
strokeWeight(6);
line(width/2, height/2-15, width/2, height/2+15);
line(width/2-15, height/2, width/2+15, height/2);
//clock
pushMatrix();
translate(mouseX, mouseY);
s.pin();
s.time(second()*(2*PI/60));
s.clockdisplay();
m.time(minute()*(2*PI/60));
m.clockdisplay();
h.time(hour()*(2*PI/12));
h.clockdisplay();
popMatrix();
//spin
for (int i=0; i<150; i+=2) {
if ((mouseX < (width/2)+40)&&(mouseX>(width/2)-40)&&(mouseY< (height/2)+40)&&(mouseY>(height/2)-40)){
if (i==0){
//fafafish
pushMatrix();
translate(mouseX, mouseY);
a.ffdisplay(1.5, 4.3, 4);
popMatrix();
}
}else{
//fafafish
pushMatrix();
translate(mouseX, mouseY);
a.ffdisplay(1.5, 4.3, 4);
popMatrix();
}
pushMatrix();
spinnings[i].rotating();
spinnings[i].spindisplay();
popMatrix();
}
}
///clock /////////////////////////////////////////////////////////////////////////////////////////////
class clock {
float cx, cy, n;
float sw, lena, timesmh; //stroke weight, length, time
float len=0.8; //start length
float px, py; //pin xy
boolean spintf=false;
boolean clocktf=false;
clock( float tempsw, float templ) {
sw=tempsw;
lena=templ;
}
void time(float temptime) {
timesmh=temptime;
if (clocktf==false) {
spintf=true;
stroke(0);
} else {
stroke (random(255), 0, random(255));
strokeWeight(sw);
cx=len*cos(n)*width/2+0;
cy=len*sin(n)*height/2+0;
if ((mouseX < (width/2)+4)&&(mouseX>(width/2)-4)) {
n=map(mouseX, width/2, 0, ((timesmh)- HALF_PI), random(2*PI));
stroke(#FA7777);
len=lena;
if ((mouseY< (height/2)+20)&&(mouseY>(height/2)-20)) {
n=map(mouseY, height/2, 0, ((timesmh)- HALF_PI), random(2*PI));
stroke(#FA7777);
len=lena;
} else {
n=random(2*PI);
len=0.8;
}
} else {
n=random(2*PI);
len=0.8;
}
}
if ((mouseX < (width/2)+40)&&(mouseX>(width/2)-40)&&(mouseY< (height/2)+40)&&(mouseY>(height/2)-40)) {
clocktf=true ;
spintf=false;
} else {
clocktf=false;
spintf=true;
}
}
void pin() {
strokeWeight(6);
strokeCap(ROUND);
beginShape(POINTS);
for (int a = 0; a < 360; a+=6) {
float angle = radians(a);
float px = 0.95*cos(angle)*width/2+0;
float py =0.95*sin(angle) * height/2+0;
vertex(px, py);
}
endShape();
strokeWeight(9);
strokeCap(SQUARE);
line(0, -height/2+5, 0, -height/2+35);
line(0, height/2-5, 0, height/2-35);
line(width/2-5, 0, width/2-35, 0);
line(-width/2+5, 0, -width/2+35, 0);
}
void clockdisplay() {
strokeCap(ROUND);
line(0, 0, cx, cy);
}
}
///fafafish /////////////////////////////////////////////////////////////////////////////////////////////
class fafafish {
float x;
float y;
float a = x-164;
float b = y-270;
float angle;
float swf,swp,swc;
boolean fafafishtf=false;
fafafish(float tempx, float tempy) {
x=tempx;
y=tempy;
}
void ffdisplay(float tempswc,float tempswf,float tempswp) {
swc=tempswc;
swf=tempswf;
swp=tempswp;
if (fafafishtf==false) {
//background(0);
rotate(radians(random(angle)));
angle+=0.01;
scale(0.2, 0.2);
} else {
scale(0.5, 0.5);
}
noFill();
strokeWeight(swc);
stroke(#FFDE6F);
ellipse(a+164, b+270, 55, 55);
ellipse(a+166, b+274, 56, 55);
ellipse(a+168, b+270, 57, 56);
ellipse(a+162, b+272, 55, 57);
ellipse(a+162, b+268, 57, 55);
//fish
strokeWeight(swf);
point(a+207, b+257);
strokeWeight(1.8);
strokeCap(ROUND);
stroke(#FF6464);
bezier(a+216, b+259, a+209, b+273, a+198, b+261, a+198, b+261);
//petal
strokeWeight(swp);
stroke(255);
bezier(a+159, b+250, a+256, b+14, a+299, b+324, a+185, b+262);
bezier(a+139, b+252, a+26, b+98, a+199, b+173, a+162, b+245);
bezier(a+139, b+252, a+28, b+162, a+29, b+306, a+141, b+270);
bezier(a+156, b+283, a+98, b+454, a+39, b+306, a+141, b+270);
bezier(a+156, b+283, a+78, b+436, a+202, b+377, a+173, b+294);
bezier(a+191, b+281, a+328, b+403, a+184, b+393, a+173, b+294);
bezier(a+191, b+281, a+390, b+354, a+266, b+193, a+185, b+262);
if ((mouseX < (width/2)+40)&&(mouseX>(width/2)-40)&&(mouseY< (height/2)+40)&&(mouseY>(height/2)-40)) {
fafafishtf=true ;
} else {
fafafishtf=false;
}
}
}
///spinning /////////////////////////////////////////////////////////////////////////////////////////////
class spinning {
float x;
float angle;
boolean spintf=false;
boolean clocktf=false;
float r=93;
float g=140;
float b=255;
spinning (float tempX, float tempA) {
x=tempX;
angle = tempA;
}
void rotating() {
translate(mouseX, mouseY);
if (spintf==false) {
clocktf=true;
} else {
clocktf=false;
rotate(radians(random(angle)));
angle+=random(2*PI)+180;
stroke(r, g, b);
strokeWeight(3);
line(0, 0, x, x);
}
if ((mouseX < (width/2)+40)&&(mouseX>(width/2)-40)&&(mouseY< (height/2)+40)&&(mouseY>(height/2)-40)) {
spintf=false ;
clocktf=true;
} else {
spintf=true;
clocktf=false;
}
}
void spindisplay() {
r=random(82, 130);
g=random(82, 245);
b=random(235, 255);
}
}