Options
All
  • Public
  • Public/Protected
  • All
Menu

Class VirtualContext

A Canvas' 2D rendering context that is not rendered.
Useful to work with ImageData objects, TextMetrics, to create bitmap data and anything else you can do with a 2D context.

Hierarchy

  • VirtualContext

Index

Methods

Static _init

  • _init(): void

Static getImageData

  • getImageData(image: HTMLImageElement, width?: undefined | number, height?: undefined | number): ImageData
  • Get the image data from an image object.

    Parameters

    • image: HTMLImageElement

      The image to get the data from.

    • Optional width: undefined | number

      The width of the image (defaults to the actual image's width).

    • Optional height: undefined | number

      The height of the image (defaults to the actual image's height).

    Returns ImageData

Static measureText

  • measureText(text: string, font: string): number
  • Get the width of a text with a specified font.

    Parameters

    • text: string

      The text to measure.

    • font: string

      The font to use.

    Returns number

Static requestBuffer

  • requestBuffer(width: number, height: number): CanvasRenderingContext2D
  • Request the virtual context.

    Parameters

    • width: number

      The width to request from the context.

    • height: number

      The height to request from the context.

    Returns CanvasRenderingContext2D

    The context object.

Generated using TypeDoc