dev
    Preparing search index...

    Class CanvasContext

    A rendering context for the Canvas backend. This class serves as a proxy for the underlying CanvasRenderingContext2D object, part of the browser's API.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    canvas: HTMLCanvasElement | OffscreenCanvas | { height: number; width: number }

    The HTMLCanvasElement or OffscreenCanvas that is associated with the above context. If there was no associated <canvas> element, just store the default WIDTH / HEIGHT.

    context2D: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D

    The 2D rendering context from the Canvas API. Forward method calls to this object.

    curTransfrom: DOMMatrix
    textHeight: number = 0

    Height of one line of text (in pixels).

    Accessors

    • get fillStyle(): string | CanvasGradient | CanvasPattern

      Returns string | CanvasGradient | CanvasPattern

    • set fillStyle(style: string | CanvasGradient | CanvasPattern): void

      Parameters

      • style: string | CanvasGradient | CanvasPattern

      Returns void

    • get strokeStyle(): string | CanvasGradient | CanvasPattern

      Returns string | CanvasGradient | CanvasPattern

    • set strokeStyle(style: string | CanvasGradient | CanvasPattern): void

      Parameters

      • style: string | CanvasGradient | CanvasPattern

      Returns void

    Methods

    • Parameters

      • x: number
      • y: number
      • radius: number
      • startAngle: number
      • endAngle: number
      • counterclockwise: boolean

      Returns this

    • Parameters

      • cp1x: number
      • cp1y: number
      • cp2x: number
      • cp2y: number
      • x: number
      • y: number

      Returns this

    • Set the pixels in a rectangular area to transparent black rgba(0,0,0,0).

      Parameters

      • x: number
      • y: number
      • width: number
      • height: number

      Returns this

    • Parameters

      • Optionalf: string | FontInfo

        is 1) a FontInfo object or 2) a string formatted as CSS font shorthand (e.g., 'bold 10pt Arial') or 3) a string representing the font family (one of size, weight, or style must also be provided).

      • Optionalsize: string | number

        a string specifying the font size and unit (e.g., '16pt'), or a number (the unit is assumed to be 'pt').

      • Optionalweight: string | number

        is a string (e.g., 'bold', 'normal') or a number (100, 200, ... 900).

      • Optionalstyle: string

        is a string (e.g., 'italic', 'normal').

      Returns this

    • Ensure that width and height do not exceed the browser limit.

      Parameters

      • width: number
      • height: number

      Returns [number, number]

      array of [width, height] clamped to the browser limit.