Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "canvas"

Index

Functions

Const canvas2d

  • canvas2d(width: number, height?: number, parent?: HTMLElement): CanvasContext
  • Creates a canvas element of given size, obtains its 2D drawing context and returns object of both. If parent is given, the canvas is appended to it as child.

    Parameters

    • width: number

      -

    • Default value height: number = width

      -

    • Optional parent: HTMLElement

      -

    Returns CanvasContext

canvasPixels

  • Accepts either an existing canvas or creates a new one of given size. Returns object of canvas, 2d context, img data and wrapped img data as u32 ABGR pixel array.

    Parameters

    • canvas: HTMLCanvasElement

    Returns RawPixelBuffer

  • Parameters

    • width: number
    • Optional height: undefined | number

    Returns RawPixelBuffer

Const imageCanvas

  • imageCanvas(img: HTMLImageElement, width?: undefined | number, height?: undefined | number, parent?: HTMLElement): CanvasContext
  • Creates canvas for given image and draws image, optionally with given new size. If no width/height is given, the canvas will be of same size as image. If parent is given, the canvas is appended to it as child.

    Parameters

    • img: HTMLImageElement

      -

    • Optional width: undefined | number

      -

    • Default value height: undefined | number = width

      -

    • Optional parent: HTMLElement

      -

    Returns CanvasContext

Const imagePromise

  • imagePromise(src: string): Promise<HTMLImageElement>
  • Async function. Loads image from given src URL.

    Parameters

    • src: string

      -

    Returns Promise<HTMLImageElement>

Generated using TypeDoc