Chapter 41: Canvas Circles

Canvas Circles properly, slowly, and in great detail — exactly like a patient teacher sitting next to you explaining it for the first time.

We’re going to build every concept with tiny, complete, runnable examples. No skipping steps. No magic. Just clear English, visual thinking, common beginner traps, and repeated patterns until circles feel completely natural and easy to control.

Canvas Circles – From Zero to Confident

1. The single most important sentence about circles in Canvas

A circle in Canvas is not a permanent object you can later move or resize like in SVG. It is a curved path (specifically a full 360° arc) that you describe once, then tell the painter to:

  • fill() → paint the inside pixels
  • stroke() → paint the outline pixels
  • or both

After you call fill() or stroke(), those pixels are just pixels — there is no “circle object” anymore. If you want to move the circle, grow it, change its color, or make it pulse → you have to erase the old circle (usually with clearRect) and draw a new circle at the new position/size/color.

2. The only command you need for circles: arc()

Almost every circle uses this one method:

JavaScript

To draw a full circle — the most common case — you always use:

JavaScript

3. Radians quick-reference table (memorize these!)

Canvas uses radians, not degrees. Here are the ones you will use 95% of the time:

Angle (degrees) Radians value Position / Direction
0 right (3 o’clock)
90° Math.PI / 2 down (6 o’clock)
180° Math.PI left (9 o’clock)
270° Math.PI * 1.5 up (12 o’clock)
360° Math.PI * 2 full circle — back to start

4. Minimal complete circle example (copy → run immediately)

HTML

What you should see & remember forever:

  • Circle perfectly centered using canvas.width/2 and canvas.height/2
  • beginPath() → starts fresh (very important!)
  • arc(…, 0, Math.PI*2) → full 360° circle
  • fill() → paints inside pixels
  • stroke() → paints outline pixels (drawn on top of fill)

5. Example 2 – Different circle styles (copy-paste & play)

HTML

Key lessons from this example:

  • Fill only → just fill()
  • Outline only → just stroke()
  • Both → fill() first → stroke() second (stroke sits on top)
  • Thick ring → large lineWidth on stroke
  • Dashed/dotted → setLineDash([dash, gap]) + lineCap = ’round’ for nice dots

6. Your three tiny practice tasks (10–15 min each)

Task 1 – Smiley face Yellow filled circle (face) Two small black filled circles (eyes) One thick red arc (smiling mouth) — use partial arc with angles Math.PI/4 to Math.PI*3/4

Task 2 – Traffic light Three stacked circles (red top, yellow middle, green bottom) Each with thick black outline Use same center x, different y positions

Task 3 – Olympic rings style Draw five interlocking circles (try blue, yellow, black, green, red) Tip: draw them one by one, adjust positions so they overlap nicely

Paste any of them here when you finish — I’ll review it like we’re pair-programming together.

Which part still feels a little slippery?

  • Why beginPath() before every circle?
  • Difference between fill() and stroke() order?
  • How to make thick rings / outlines look nice?
  • Angles in radians (0 to Math.PI*2)?
  • Positioning multiple circles accurately?
  • Something else?

Tell me honestly — we’ll stay on circles until you feel super confident drawing and combining them with other shapes.

You’re doing really well — circles are the gateway to almost every beautiful and useful Canvas graphic!

You may also like...

Leave a Reply

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