Skip to content

CanvasBackend

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

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

new CanvasBackend(canvas, width, height): CanvasBackend

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

HTMLCanvasElement

number

number

CanvasBackend

readonly supportsPassThrough: true = true

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

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:139

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:564

void

Backend.destroy


drawPassThrough(name, batch, mode): void

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

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:348

Remove a pass-through layer.

string

void

Backend.removePassThroughLayer


render(): void

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

void

Backend.render


renderOverlays(): void

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

Repaint only the overlays (#519): put back the pixels kept under the hover label and the old overlays, then keep the rectangle under each new overlay and paint it. Costs O(overlay drawables) plus a copy out and back of each overlay’s bounding box, whatever the scene.

void

Backend.renderOverlays


resize(width, height): void

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

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


setHoverText(hover): void

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

The one-label hover slot (#496): paint a chip and the full text over the live canvas, keeping the small rectangle underneath so a clear puts it back. Costs one drawImage out and one back of a label-sized rectangle (a copy, not getImageData, which un-premultiplies and would not restore exactly) plus one text paint, whatever the scene or the placed labels, and repaints nothing else. A later render() repaints everything and paints the hover again from hoverText.

HoverText | null

void

Backend.setHoverText


setLayers(layers): void

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

RenderLayer[]

void

Backend.setLayers


setOverlays(layers): void

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

Replace the highlight overlays; renderOverlays (or the next render()) paints them.

readonly RenderLayer[]

void

Backend.setOverlays


setPassThroughLayer(layer): void

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

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

PassThroughLayer

void

Backend.setPassThroughLayer


setTextLayer(texts): void

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

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:127

ViewTransform

void

Backend.setTransform


snapshotPassThrough(): void

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

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

void

Backend.snapshotPassThrough


toPNG(): string

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

string

Backend.toPNG


toSVG(): string

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

string

Backend.toSVG


updateLayer(name, layer): void

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

string

RenderLayer

void

Backend.updateLayer


updateLayerFlags(name, flags): void

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

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:107

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