CanvasBackend
Defined in: canvas/canvas-backend.ts:26
A renderer for a Scene, implemented per target (WebGL / Canvas / SVG).
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CanvasBackend(
canvas,width,height):CanvasBackend
Defined in: canvas/canvas-backend.ts:54
Parameters
Section titled “Parameters”canvas
Section titled “canvas”HTMLCanvasElement
number
height
Section titled “height”number
Returns
Section titled “Returns”CanvasBackend
Properties
Section titled “Properties”supportsPassThrough
Section titled “supportsPassThrough”
readonlysupportsPassThrough: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.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”appendToLayer()
Section titled “appendToLayer()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”destroy()
Section titled “destroy()”destroy():
void
Defined in: canvas/canvas-backend.ts:564
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”drawPassThrough()
Section titled “drawPassThrough()”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.)
Parameters
Section titled “Parameters”string
"replace-first" | "replace-rest" | "append"
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”removePassThroughLayer()
Section titled “removePassThroughLayer()”removePassThroughLayer(
name):void
Defined in: canvas/canvas-backend.ts:348
Remove a pass-through layer.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Backend.removePassThroughLayer
render()
Section titled “render()”render():
void
Defined in: canvas/canvas-backend.ts:172
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”renderOverlays()
Section titled “renderOverlays()”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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”resize()
Section titled “resize()”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.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setHoverText()
Section titled “setHoverText()”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.
Parameters
Section titled “Parameters”HoverText | null
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setLayers()
Section titled “setLayers()”setLayers(
layers):void
Defined in: canvas/canvas-backend.ts:90
Parameters
Section titled “Parameters”layers
Section titled “layers”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setOverlays()
Section titled “setOverlays()”setOverlays(
layers):void
Defined in: canvas/canvas-backend.ts:206
Replace the highlight overlays; renderOverlays (or the next render()) paints them.
Parameters
Section titled “Parameters”layers
Section titled “layers”readonly RenderLayer[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setPassThroughLayer()
Section titled “setPassThroughLayer()”setPassThroughLayer(
layer):void
Defined in: canvas/canvas-backend.ts:344
Register/replace a pass-through layer (no buffers). Backends opt in.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setTextLayer()
Section titled “setTextLayer()”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.
Parameters
Section titled “Parameters”readonly TextData[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setTransform()
Section titled “setTransform()”setTransform(
t):void
Defined in: canvas/canvas-backend.ts:127
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”snapshotPassThrough()
Section titled “snapshotPassThrough()”snapshotPassThrough():
void
Defined in: canvas/canvas-backend.ts:379
Capture the current canvas + transform so render() can snapshot-pan during a gesture.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”toPNG()
Section titled “toPNG()”toPNG():
string
Defined in: canvas/canvas-backend.ts:561
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”toSVG()
Section titled “toSVG()”toSVG():
string
Defined in: canvas/canvas-backend.ts:563
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”updateLayer()
Section titled “updateLayer()”updateLayer(
name,layer):void
Defined in: canvas/canvas-backend.ts:96
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”updateLayerFlags()
Section titled “updateLayerFlags()”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.
Parameters
Section titled “Parameters”string
Uint8Array
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”updateLayerStyles()
Section titled “updateLayerStyles()”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.
Parameters
Section titled “Parameters”string
_tables
Section titled “_tables”drawables?
Section titled “drawables?”Returns
Section titled “Returns”void