i have done the program but i need the hour hand to move in proportion to the minutes or seconds..like if it is 3:30 then my hour hand should be between 3&4..but my hour hand only moves when the minute hand completes 60 minutes.. can someone help me out..my program is given below
int centerX = 300;
int centerY =300;
int secHand = 250;
int minHand = 200;
int hourHand = 150;
float x;
float y;
float angle;
void setup() {
int width = 600;
int height = 600;
size(width, height);
}
void draw () {
stroke(255);
background(0);
float quarterCircle = PI/2;
// for the ellipse
for (int i=1; i<=60; i++) {
angle = i * PI / 30.0;
float x = (centerX + cos(angle)* secHand);
float y =(centerY + sin(angle)* secHand);
if(i % 5 != 0) {
point(x,y);
}
else {
ellipse(x, y, 5, 5);
}
}
// for second hand
angle = ((2 * PI/60) * second()) - quarterCircle;
x = centerX + secHand * cos(angle);
y = centerY + secHand * sin(angle);
stroke(255);
line(centerX, centerY , x, y);
// for minute hand
angle = ((2 * PI/60) * minute()) - quarterCircle;
x = centerX + minHand * cos(angle);
y = centerY + minHand * sin(angle);
stroke(255);
line(centerX, centerY , x, y);
// for hour hand
hourHand = hourHand + second()/60;
angle = ((2 * PI/12) * hour()) - quarterCircle;
x = centerX + hourHand * cos(angle);
y = centerY + hourHand * sin(angle);
stroke(255);
line(centerX, centerY, x, y);
}