Skip to content

Canvas class

Implementation of ImageAdapter interface for OffscreenCanvas and HTMLCanvasElement.

INFO

This page describes only static helper methods and constructor. Other public methods and props description can be found on ImageAdapter page.

TIP

You can pass OffscreenCanvas and HTMLCanvasElement directly to distort() and distortUnwrap() functions -- they will be wrapped in Canvas adapter internally.

Constructor

  • Param: canvas: OffscreenCanvas | HTMLCanvasElement
  • Example:
ts
import { Canvas } from "@alxcube/lens";
const canvas = new OffscreenCanvas(1, 1);
const adapter = new Canvas(canvas);

Static methods

createFromImage()

  • Param: image: Exclude<CanvasImageSource, SVGImageElement | VideoFrame>| OffscreenCanvas
  • Returns: Canvas

Creates canvas instance from wide variety of canvas image sources.


createFromUrl()

  • Param: url :string
  • Returns: Promise<Canvas>

Asynchronously creates Canvas instance from image url.


createFromBlob()

  • Param: blob: Blob
  • Returns: Promise<Canvas>

Asynchronously creates Canvas instance from given image Blob or File.