Skip to content

Snapshoter

Snapshot helper

Takes a snapshot of the ResponsiveCanvas backing a CanvasRenderer. In general, ResponsiveCanvas is multi-layer therefore two capturing modes are available: capture all layers separately or merge them into one image. When you call snapshot() method Snapshoter waits for the next render update and makes a copy of all canvas layers. There’re several modes for the resolution of the snapshot: “video” - snapshot has the same size as the video stream, “max”/“min” - in maximum/minimum size among canvas layers.

Constructors

new Snapshoter()

new Snapshoter(renderer, mirror, sizeMode, sizeMax?): Snapshoter

Constructor

Parameters

renderer: CanvasRenderer<object>

Renderer to take snapshot of

mirror: boolean = false

Mirror captured images

sizeMode: "video" | "max" | "min" = "video"

Video size mode

sizeMax?: number

Maximum video size

Returns

Snapshoter

Properties

mirror

protected mirror: boolean = false

Mirror captured images


renderer

protected renderer: CanvasRenderer<object>

Renderer to take snapshot of


sizeMax?

protected optional sizeMax: number

Maximum video size


sizeMode

protected sizeMode: "video" | "max" | "min" = "video"

Video size mode

Methods

snapshot()

snapshot(): Promise<undefined | ImageData>

Take snapshot of the renderer

Enqueues capture after the next renderer update. All canvas layers are merged into one final image.

Returns

Promise<undefined | ImageData>

Promise resolved to the merged captured image


snapshotLayers()

snapshotLayers(): Promise<(undefined | ImageData)[]>

Take snapshot of the renderer

Enqueues capture after the next renderer update. All canvas layers are returned as separate images.

Returns

Promise<(undefined | ImageData)[]>

Promise resolved to the array of captured images