Skip to main content

Function: readClipboardShape()

readClipboardShape(clipboard?, deps?, fallback?): Promise<ShapeImage>

Defined in: src/lib/brushes/shapeImage/index.ts:89

Read a brush shape from a PNG image on the clipboard. Without one (or when the browser won't let it be read), the fallback PNG is used if there is one (e.g. image data copied on the canvas, canvas.copiedPng()). Throws a ShapeImageError if there is none or it can't be used.

Parameters​

clipboard?​

Pick<Clipboard, "read"> = navigator.clipboard

deps?​

ShapeImageDependencies = {}

fallback?​

() => Promise<Blob | undefined>

Returns​

Promise<ShapeImage>

Example​

const shape = await readClipboardShape(navigator.clipboard, {}, () => canvas.copiedPng());