we (web engine): Experimental web browser project to understand the limits of Claude

Canvas line styles & dashing #170

open opened by pierrelf.com

Phase 18: Canvas 2D API — Issue 5/10#

Implement line style properties and dashed line support for canvas stroke operations.

Dependencies#

  • Canvas path API & rasterization (issue 4)

Requirements#

Line cap styles (lineCap property):

  • 'butt' (default) — flat edge at endpoint
  • 'round' — semicircle at endpoint
  • 'square' — half-square projection at endpoint

Line join styles (lineJoin property):

  • 'miter' (default) — sharp corner, clipped by miterLimit
  • 'round' — circular arc at corner
  • 'bevel' — flat diagonal at corner

Miter limit:

  • miterLimit property (default 10.0)
  • When miter length / lineWidth exceeds miterLimit, fall back to bevel join

Dash patterns:

  • setLineDash(segments) — set the dash pattern (alternating dash/gap lengths)
  • getLineDash() — return current dash pattern
  • lineDashOffset property — offset into the dash pattern
  • If segments array has odd length, double it per spec
  • Empty segments array = solid line

Stroke geometry:

  • Generate offset curves at ±lineWidth/2 from the path centerline
  • Apply line caps at sub-path endpoints
  • Apply line joins at path segment junctions
  • Apply dash pattern along the path length

Acceptance criteria#

  • Stroked paths respect lineCap, lineJoin, miterLimit settings
  • Dashed lines render correctly with various dash patterns
  • lineDashOffset shifts the dash pattern
  • Round caps and joins produce visually smooth curves
  • save/restore correctly preserves line style state
  • Unit tests for dash pattern application and join geometry
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3miigymq4bo25