Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Génicus

macrumors member
Original poster
Feb 18, 2009
67
0
Belgium
Hello, I am looking for a javascript that can put hours, minutes and seconds in a analog clock form. I have a javascript that produces this numbers, but I don't have a clue how to put them into a clock...
Can somebody help me please?
Thanks in advance
 

mason.kramer

macrumors 6502
Apr 16, 2007
270
18
Watertown, MA
Do you know how to program? Let's assume you do. (Because if you don't, what the heck are you doing here? :))

There's nothing to "know" about doing this, really. You have a fixed background which is the clock face. You have hands that move according to what time is. The angle (call it theta) of the minute hand is related to the minutes of the hour by the formula theta = x*6, where is the x number of minutes. The hour hand theta is more complicated but let's just think through it right now. 12 hours in the unit circle = 360/12 degrees per hour, or 30°. theta = 30*h + 30*(minutes/60).

Now decide how you are going to display the hands as they tick around. You can use Flash (or possibly HTML) to display the image of a clock hand which is rotated theta degrees. 3D css transforms are only supported in the most recent browsers, but can also be used. I don't think timing the display of many many copies of the same rotated image is at all advisable.
 

Génicus

macrumors member
Original poster
Feb 18, 2009
67
0
Belgium
I can program in Pascal, I know a little bit of php, css, html, but javascript is new for me; although I want to learn it as soon as possible for this project.
 

mason.kramer

macrumors 6502
Apr 16, 2007
270
18
Watertown, MA
I can program in Pascal, I know a little bit of php, css, html, but javascript is new for me; although I want to learn it as soon as possible for this project.

Alright, well what I've just posted should get you started. At this point it's a web graphics problem: you need to pick a method for display rotated images. There might be a javascript framework such as scriptaculous that can do rotations, in which case that is the preferred method.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.