Class GraphicsContext

A thin caching wrapper around a 2D canvas rendering context.

Notes

This class is mostly a transparent wrapper around a canvas rendering context which improves performance when writing context state.

For best performance, avoid reading state from the gc. Writes are cached based on the previously written value.

Unless otherwise specified, the API and semantics of this class are identical to the builtin 2D canvas rendering context: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D

The wrapped canvas context should not be manipulated externally until the wrapping GraphicsContext object is disposed.

Implements

Constructors

Properties

_disposed: boolean = false
_state: State

Accessors

Methods

  • Parameters

    • x: number
    • y: number
    • radius: number
    • startAngle: number
    • endAngle: number
    • Optional anticlockwise: boolean

    Returns void

  • Parameters

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

    Returns void

  • Dispose of the resources held by the object.

    Notes

    If the object's dispose method is called more than once, all calls made after the first will be a no-op.

    Undefined Behavior

    It is undefined behavior to use any functionality of the object after it has been disposed unless otherwise explicitly noted.

    Returns void

  • Parameters

    • x: number
    • y: number
    • radiusX: number
    • radiusY: number
    • rotation: number
    • startAngle: number
    • endAngle: number
    • Optional anticlockwise: boolean

    Returns void

  • Parameters

    • m11: number
    • m12: number
    • m21: number
    • m22: number
    • dx: number
    • dy: number

    Returns void

  • Parameters

    • m11: number
    • m12: number
    • m21: number
    • m22: number
    • dx: number
    • dy: number

    Returns void