Chapter 58: Clock Hands

Clock Hands in the most detailed, clear, and patient way possible.

Imagine we’re sitting together at a desk. I’m your favorite teacher who wants you to really understand how the moving hands of an analog clock are drawn and animated — not just copy-paste a finished clock, but know exactly why every line is positioned, rotated, and styled the way it is.

Today we focus only on the hands (hour, minute, second) — the moving parts that show the time. We assume the clock face (background circle, ticks, numbers) is already drawn once (we covered that in the previous lesson).

We will build this step by step:

  • Understand the math of angles
  • Calculate hand positions every second
  • Draw each hand with correct length, thickness, and style
  • Animate them smoothly
  • Add realistic details (tapered hands, center dot, shadows)

Clock Hands – Complete Explanation & Build-Along

1. The single most important mental model

Each hand is a straight line rotated around the center of the clock.

  • The clock is a circle → 360°
  • There are 12 hours → each hour mark is 30° apart (360 ÷ 12 = 30)
  • In Canvas (and most graphics systems):
    • 0° is at the right (3 o’clock)
    • Angles increase clockwise
    • But 12 o’clock is at the top → we subtract 90° (or Math.PI/2 radians) to make 0° point up

Key angle formulas (you will use these every time):

JavaScript

Why the numbers?

  • Seconds: 60 seconds → 6° per second → Math.PI / 30 (since 360° = 2π radians)
  • Minutes: 60 minutes → 6° per minute → same Math.PI / 30 + tiny second adjustment
  • Hours: 12 hours → 30° per hour → Math.PI / 6

2. Three different hands — different lengths & thicknesses

Hand Length (from center) Thickness (lineWidth) Color (typical) Speed / Update frequency
Second longest (~80–90% of radius) thinnest (4–6 px) bright red every second
Minute medium (~65–75%) medium (8–12 px) white/silver every second
Hour shortest (~50–60%) thickest (14–20 px) white/silver every second (smooth)

3. Step-by-step: How to draw one hand (the pattern)

JavaScript

Why this pattern?

  • translate(cx, cy) → makes (0,0) the center — rotation is now around center
  • rotate(angle) → rotates the whole paper
  • We draw the hand straight up (negative y) → rotation makes it point correctly
  • save() / restore() → protects the rest of the canvas from rotation

4. Full clock hands example (copy → run)

HTML

What you should see & remember forever:

  • Red second hand moves fastest
  • White minute & hour hands move slower
  • All hands rotate around the center (not around (0,0))
  • save() / restore() + translate + rotate pattern is the standard way
  • Hands are just thick lines drawn from near-center to near-edge

5. Your mini homework (try tonight – 15–20 minutes)

  1. Make the second hand thinner and add a small counter-weight (short line on opposite side)
  2. Make the hour hand shorter and thicker than the minute hand
  3. Add a small white circle at the end of each hand (like a tip)
  4. (Bonus) Make the second hand smoothly animated instead of jumping every second (use requestAnimationFrame + milliseconds)

Paste your modified code here if you want feedback — I’ll review it like we’re pair-programming together 😄

Any part confusing?

  • Why we subtract Math.PI / 2 from every angle?
  • How the translate → rotate → translate back pattern works?
  • Why different lengths & thicknesses for each hand?
  • How to make smooth second-hand animation?
  • Something else?

Tell me — we’ll zoom in until the clock hands feel perfect to you.

You just built the moving heart of a real analog clock — the face + hands together make a complete working clock! 🚀

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *