Chapter 59: Canvas Clock Start

Lesson: Canvas Clock – Starting from Absolute Zero

Step 1 – The absolute bare-minimum canvas clock face (just a circle)

Create this file and open it in the browser:

HTML

What we have right now:

  • A dark round clock face with a thick metallic-looking border
  • Nothing else yet — no ticks, no numbers, no hands
  • This is the foundation — everything else will be drawn on top of this circle

Why we do it this way:

  • Square canvas + border-radius: 50% → looks perfectly circular
  • Dark background + light border → modern premium watch style
  • radius = width/2 – 40 → leaves space for the thick border so it doesn’t get cut off

Step 2 – Add hour & minute ticks (the skeleton)

Add this function right after the previous code and call it:

JavaScript

Why this works:

  • Math.PI / 6 = 30° per hour
  • Math.PI / 30 = 6° per minute
  • – Math.PI / 2 shifts 0° from right → top (12 o’clock position)
  • lineCap = ’round’ makes ticks look smooth and professional

Step 4 – Add numbers (only 12, 3, 6, 9 – modern & clean)

Add this right after addTicks():

JavaScript

Why only 12, 3, 6, 9? Modern watches and minimalist designs often do this — it looks cleaner and less crowded.

Step 5 – Center dot (preparation for hands)

JavaScript

This will become the center bolt that holds the hands.

Full code so far – just the face (no hands yet)

HTML

Homework / next-step challenge

  1. Make the numbers bigger for 12, 3, 6, 9 (try 64px font)
  2. Add small dots instead of minute lines (use arc with tiny radius)
  3. Change the face to a lighter silver/gray theme
  4. (Bonus) Try Roman numerals (XII, III, VI, IX) instead of Arabic numbers

Paste your version here when you’re done — I’ll give feedback like we’re sitting together improving it.

Any part confusing?

  • Why subtract Math.PI / 2 from the angle?
  • Why radius – 70 for number position?
  • Why textBaseline = ‘middle’ for numbers?
  • Something else?

Tell me — we’ll zoom in until the clock face feels 100% clear to you.

Next lesson we’ll add the moving hands — it’s going to look amazing! 🚀

You may also like...

Leave a Reply

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