xxxxxxxxxx
float r = 150;
float x, y;
float a;
float aVel = 0.1;
float mx=200; //x coordinate minute hand
float my=200; //y cooridinate minute hand
float mn=0; // minute angle
float hx=200; //x coordinate of hour
float hy=200; //y cooridinate of hour
float hn=0; // hour
float sa = 2*PI/60; //increasing by 1 second
int currentS;
int currentM;
int currentH;
void setup() {
size(400, 400);
a = map(second(), 0, 59, -PI/2, (3*PI/2)); //<- this remaps it to the range
currentS=second();
}
void draw() {
background(40,30,90,20);
fill(250,60,60,150);
stroke(240);
strokeWeight(10);
ellipse(200, 200, 305, 305);
//decorations
//thinking bubbles
fill(250);
ellipse(20,375,5,5);
fill(250);
ellipse(35,352,15,15);
fill(250);
ellipse(58,320,25,25);
//center point
ellipse(200,200,12,12);
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(190, 80);
vertex(200, 70);
vertex(210, 80);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(190, 320);
vertex(200, 330);
vertex(210, 320);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(320, 190);
vertex(330, 200);
vertex(320, 210);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(80, 190);
vertex(70, 200);
vertex(80, 210);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(107, 125);
vertex(110, 110);
vertex(125, 108);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(293, 275);
vertex(290, 290);
vertex(275, 292);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(293, 125);
vertex(290, 110);
vertex(275, 108);
endShape();
fill(250);
stroke(250);
strokeWeight(4);
strokeJoin(ROUND);
beginShape();
vertex(107, 275);
vertex(110, 290);
vertex(125, 292);
endShape();
//seconds
//translate the origin to the center of the screen
translate (width/2, height/2);
//translating between polar and cartesian coordinates
x = r * cos(a);
y = r * sin(a);
fill(0);
stroke(250);
strokeWeight(8);
line(0, 0, x, y);
//conditional to check if s has changed
if (second()!=currentS){
//increase angle
//a=a+aVel; <-- this increases it just by aVel
a = a+sa;
//of -PI/2 through to 3/2*PI depending on seconds
println(second());
currentS=second();
}
if (second()>10 && second()<15){
a=a+2*sa;
}
else if (second()>20 && second()<25){
a=a+3*sa;
}
else if (second()>35 && second()<40){
a=a+3*sa;
}
else if (second()>55 && second()<50){
a=a+3*sa;
}
else if (second()>2 && second()<6){
a=a+3*sa;
}
//MINUTES
mx=cos(mn)*r;
my=sin(mn)*r;
mn = map(minute(), 0, 59, -PI/2, (3*PI/2)); //<- this remaps it to the range
strokeWeight(10);
line(0, 0, mx, my);
if (minute()!=currentM) {
//increase angle
//a=a+aVel; <-- this increases it just by aVel
a = a+sa;
//of -PI/2 through to 3/2*PI depending on seconds
println(minute());
currentM=minute();
if (minute()>30 && minute()<40){
a=a+2*sa;
}
hx=cos(hn)*width/2+width/2;
hy=sin(hn)*height/2+height/2;
hn=map(hour(), 0, 59, -PI/2, (3*PI/2));
line(width/2,height/2,hx,hy);
if (hour()!=currentH) {
hn=hn+(PI/60)/hour();
}
}
}