ReadonlycolorThe space the canvas composited in. Exports convert out of it when asked.
ReadonlycolorWhat the engine settled on, which is not always what Root asked for.
ReadonlyengineWhich backend took the render, and what it reports about itself.
ReadonlygpuSnapshots, not proxies: none of these can change once the canvas has been rendered.
ReadonlyheightHeight of the rendered canvas in device pixels.
ReadonlywidthWidth of the rendered canvas in device pixels — the root's width times its scale.
Encodes at the renderer's default frame rate. Pass fps to WorkerCanvas.toBuffer to choose one.
Shorthand for toBuffer('avif'). Smaller again than WebP, at a much higher encode cost.
Shorthand for toBuffer('bmp'). Uncompressed pixels in a container almost nothing needs.
Encodes at the renderer's default frame rate. Pass fps to WorkerCanvas.toBuffer to choose one.
Shorthand for toBuffer('ico'). An icon, one size per page.
Shorthand for toBuffer('jpg'). Lossy and opaque — no alpha channel.
Not available in worker mode — see newPage.
Shorthand for toBuffer('pdf'). A document, one page per rendered page.
Shorthand for toBuffer('png'). Lossless, and the format to reach for unless there is a reason not to.
Shorthand for toBuffer('raw'). Pixel data in the canvas's own colorType, with no container around it.
Shorthand for toBuffer('svg'). Vector output: the drawing as paths rather than pixels.
Shorthand for toBuffer('tiff'). A sheet per page, for print pipelines.
Shorthand for toBuffer('webp'). Smaller than PNG at the same quality, and takes every page as an animation.
getContext, newPage and pages all hand back a live CanvasRenderingContext2D bound to
native memory in the worker. Proxying one would mean a thread round trip per fillRect, so
these throw rather than return something that only looks like a context. Drawing is expressed
as a component tree here, which is what the worker replays on the other side.
Not available in worker mode: a page is added while drawing, and drawing happens in the worker.
Release the Canvas from worker memory. Call when done with this object.
Writes the canvas to disk from the worker thread.
Optionaloptions: SaveOptionsUse WorkerCanvas.toFile instead.
Writes the canvas to disk from the worker thread, blocking until it lands.
Optionaloptions: SaveOptionsUse WorkerCanvas.toFileSync instead.
Encodes the canvas on the worker and resolves with the bytes.
The asynchronous form to prefer: the encode runs on the worker's thread, so several canvases can be encoded at once without blocking the caller.
Optionaloptions: ExportOptions & AnimationExportOptionsEncodes the canvas on the worker and resolves with the bytes.
The asynchronous form to prefer: the encode runs on the worker's thread, so several canvases can be encoded at once without blocking the caller.
Optionaloptions: StillExportOptionsEncodes the canvas and hands back the bytes, blocking until the worker has done it.
An animated format takes every page as a frame; a still one takes the first. The result is cached, so asking twice for the same format and options costs a map lookup rather than a second encode.
Optionaloptions: ExportOptions & AnimationExportOptionsEncodes the canvas and hands back the bytes, blocking until the worker has done it.
An animated format takes every page as a frame; a still one takes the first. The result is cached, so asking twice for the same format and options costs a map lookup rather than a second encode.
Optionalformat: StillFormatOptionaloptions: StillExportOptionsThe HTMLCanvasElement spelling of toURLSync, taking a quality rather than an options
object. Synchronous despite the name, as it is on a real canvas.
Optionalquality: numberEncodes to a data URL, blocking on the worker.
Optionaloptions: ExportOptions & AnimationExportOptionsEncodes to a data URL, blocking on the worker.
Optionalformat: StillFormatOptionaloptions: StillExportOptionsWrites the canvas to disk, taking the format from the file's extension.
Optionaloptions: SaveOptionsWrites the canvas to disk, blocking on the worker.
Not split by format the way toBuffer is: the format comes from the filename extension here,
so there is no format argument for the animation options to be checked against.
Optionaloptions: SaveOptionsReturns a real Sharp, as skia-canvas does — not a Buffer, which is what this used to hand back.
A Sharp instance cannot cross a thread boundary, so the pixels are fetched and the wrapper is
built here. That mirrors what skia-canvas itself does internally with toBuffer('raw').
Optionaloptions: RenderOptionsHands the pixels to sharp for further processing, blocking on the worker.
Optionaloptions: RenderOptionstoBuffer, resolved as a data: URL instead of raw bytes.
Optionaloptions: ExportOptions & AnimationExportOptionstoBuffer, resolved as a data: URL instead of raw bytes.
Optionaloptions: StillExportOptionstoBufferSync, encoded as a data: URL instead of raw bytes.
Optionaloptions: ExportOptions & AnimationExportOptionstoBufferSync, encoded as a data: URL instead of raw bytes.
Optionalformat: StillFormatOptionaloptions: StillExportOptions
A Canvas that lives in a worker thread.
Every method behaves as its counterpart on a real Canvas does. Sync methods block the calling thread while the worker runs the real call (over the pool's synchronous channel); async methods go through Comlink. The two members that cannot be honoured —
getContext()andnewPage()— say so instead of returning something that only resembles the real thing.