Skip to main content
The CanvasRenderer draws shapes onto an HTML canvas using the Canvas 2D API.

ICanvasRenderer interface

CanvasRenderer

The default implementation. Renders strokes using perfect-freehand for the draw dash style, and Canvas 2D setLineDash for other styles.

Rendering pipeline

  1. Apply viewport transform (translate + scale)
  2. For each visible shape, decode segment paths and render strokes
  3. For closed shapes with fill, render the fill first, then the stroke

TsdrawRenderTheme

Maps palette keys (e.g. 'blue') to hex colors, adapting for the current light/dark theme.

resolveThemeColor

Background renderer

Draws a background pattern behind shapes. The pattern scales with the viewport zoom for consistent visual density.