Documentation / @ripl/dom / createCanvasExport
Function: createCanvasExport() ​
createCanvasExport(
canvas):ContextExport
Defined in: dom/src/export.ts:20
Builds a ContextExport from an HTMLCanvasElement, shared by every canvas-backed context (Canvas 2D, 3D, WebGPU). The canvas is snapshotted immediately by copying its current pixels onto a detached 2D canvas, so the returned exporters are unaffected by subsequent rendering. This works for any canvas regardless of the API used to draw it, because the source canvas is a valid drawImage source even when backed by WebGL/WebGPU, so callers should ensure a frame has been rendered before exporting (WebGPU present textures are transient).
Every object URL handed out by toURL() is tracked and revoked by release(); without that call each one pins its blob for the document's lifetime.
Parameters ​
| Parameter | Type |
|---|---|
canvas | HTMLCanvasElement |