Skip to content

CanvasBackend

Defined in: canvas/canvas-backend.ts:16

A renderer for a Scene, implemented per target (WebGL / Canvas / SVG).

new CanvasBackend(canvas, width, height): CanvasBackend

Defined in: canvas/canvas-backend.ts:44

HTMLCanvasElement

number

number

CanvasBackend

readonly supportsPassThrough: true = true

Defined in: canvas/canvas-backend.ts:27

Canvas-2D persists drawn pixels between calls, so the canvas IS the pass-through accumulation buffer: points draw on top of the retained base map and stay there.

Backend.supportsPassThrough

appendToLayer(delta): void

Defined in: canvas/canvas-backend.ts:129

Incremental append (O(new)): accumulate the new drawables into the stored layer (so a later full render() still draws everything), then draw ONLY those new drawables on top — no clear. The clip (if any) is established ONCE and kept across appends at a given transform, so each batch is just the new shapes — the canvas analog of a GPU sub-buffer upload. Full redraws happen on transform/recolor/resize.

RenderDelta

void

Backend.appendToLayer


destroy(): void

Defined in: canvas/canvas-backend.ts:404

void

Backend.destroy


drawPassThrough(name, batch, mode): void

Defined in: canvas/canvas-backend.ts:213

Draw a batch of pass-through points onto the main canvas at the current transform.

  • "replace-first" starts a fresh full repaint of the overlay: drop any snapshot, redraw the retained base via the normal render(), then draw this batch on top.
  • "replace-rest" / "append" draw this batch on top of what’s already there (no clear) — continuing a chunked repaint, or an incremental add. (Single-batch draw; Task 7 time-slices large batches. No color grouping — YAGNI.)

string

DrawBatch

"replace-first" | "replace-rest" | "append"

void

Backend.drawPassThrough


removePassThroughLayer(name): void

Defined in: canvas/canvas-backend.ts:201

Remove a pass-through layer.

string

void

Backend.removePassThroughLayer


render(): void

Defined in: canvas/canvas-backend.ts:158

void

Backend.render


resize(width, height): void

Defined in: canvas/canvas-backend.ts:68

Resize the CSS size + device-px backing store and re-read the dpr. Clears the canvas (setting canvas.width/height resets the bitmap and context state); the engine re-renders right after, which reapplies the view transform via setView.

number

number

void

Backend.resize


setLayers(layers): void

Defined in: canvas/canvas-backend.ts:80

RenderLayer[]

void

Backend.setLayers


setPassThroughLayer(layer): void

Defined in: canvas/canvas-backend.ts:197

Register/replace a pass-through layer (no buffers). Backends opt in.

PassThroughLayer

void

Backend.setPassThroughLayer


setTextLayer(texts): void

Defined in: canvas/canvas-backend.ts:181

Set the screen-space text labels (#105 N7b-2); drawn on the next render(). Replaces the set.

readonly TextData[]

void

Backend.setTextLayer


setTransform(t): void

Defined in: canvas/canvas-backend.ts:117

ViewTransform

void

Backend.setTransform


snapshotPassThrough(): void

Defined in: canvas/canvas-backend.ts:223

Capture the current canvas + transform so render() can snapshot-pan during a gesture.

void

Backend.snapshotPassThrough


toPNG(): string

Defined in: canvas/canvas-backend.ts:402

string

Backend.toPNG


toSVG(): string

Defined in: canvas/canvas-backend.ts:403

string

Backend.toSVG


updateLayer(name, layer): void

Defined in: canvas/canvas-backend.ts:86

string

RenderLayer

void

Backend.updateLayer


updateLayerFlags(name, flags): void

Defined in: canvas/canvas-backend.ts:109

Flags-only update (#208): patch the retained vector view’s flag bytes IN PLACE — no new objects or arrays (vs updateLayerStyles, which swaps in a freshly materialized view) — and the next render() repaints with the new visibility, exactly as before. Flags feed the clip silhouette, so drop the cached clip. The length guard is defensive: any drawable-set change reaches this backend as updateLayer/appendToLayer/setLayers first.

string

Uint8Array

void

Backend.updateLayerFlags


updateLayerStyles(name, _tables, drawables?): void

Defined in: canvas/canvas-backend.ts:97

Styles-only update: swap the stored vector view (the next render() repaints from it), so Canvas always needs drawables (it renders from them — see stylesNeedDrawables, left at its default). Visibility flags feed the clip silhouette, so drop the cached clip.

string

StyleTables

DrawableVector[]

void

Backend.updateLayerStyles