CanvasBackend
Defined in: canvas/canvas-backend.ts:16
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:44
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: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.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”appendToLayer()
Section titled “appendToLayer()”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.
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:404
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: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.)
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:201
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:158
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: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.
Parameters
Section titled “Parameters”number
height
Section titled “height”number
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setLayers()
Section titled “setLayers()”setLayers(
layers):void
Defined in: canvas/canvas-backend.ts:80
Parameters
Section titled “Parameters”layers
Section titled “layers”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setPassThroughLayer()
Section titled “setPassThroughLayer()”setPassThroughLayer(
layer):void
Defined in: canvas/canvas-backend.ts:197
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:181
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:117
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:223
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:402
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”toSVG()
Section titled “toSVG()”toSVG():
string
Defined in: canvas/canvas-backend.ts:403
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:86
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: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.
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: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.
Parameters
Section titled “Parameters”string
_tables
Section titled “_tables”drawables?
Section titled “drawables?”Returns
Section titled “Returns”void