Skip to main content

Class: Snapshoter

@geenee/armature.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

constructor

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

Constructor

Parameters

NameTypeDefault valueDescription
rendererCanvasRenderer<>undefinedRenderer to take snapshot of
mirrorbooleanfalseMirror captured images
sizeMode"video" | "max" | "min""video"Video size mode
sizeMax?numberundefinedMaximum video size

Properties

mirror

Protected mirror: boolean = false

Mirror captured images


renderer

Protected renderer: CanvasRenderer<>

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