RevGrid - v0.9.3
    Preparing search index...

    A wrapper around CanvasRenderingContext2D which accesses values from CanvasRenderingContext2D from a cache.

    Supports saving and restoring by pushing and popping cached values onto/from a stack. Cache also stores the width and height of strings so that these widths and heights can be re-used without needing to be constantly recalculated

    Index

    Properties

    Cache of CanvasRenderingContext2D values

    Methods

    • Parameters

      • cssColorSpec: undefined | string

      Returns number

    • Parameters

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

      Returns void

    • Returns void

    • Parameters

      • x: number
      • y: number
      • width: number
      • height: number
      • color: string

      Returns void

    • Parameters

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

      Returns void

    • Returns void

    • Unwind a previous clipSave and pop cache stack if necessary

      Returns void

    • Conditionally clip a region

      Parameters

      • conditional: boolean

        if true, save cache to stack and clip region

      • x: number

        left of region

      • y: number

        top of region

      • width: number

        width of region

      • height: number

        height of region

      Returns void

      The conditional paramater indicates whether a region is to be clipped. If so, then the cache is saved to the stack. Always call a matching clipRestore to unwind this clipSave even if conditional was false

    • Returns void

    • Parameters

      • x0: number
      • y0: number
      • x1: number
      • y1: number

      Returns CanvasGradient

    • Parameters

      • image: CanvasImageSource
      • dx: number
      • dy: number
      • dw: number
      • dh: number

      Returns void

    • Returns void

    • Parameters

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

      Returns void

    • Parameters

      • text: string
      • x: number
      • y: number
      • OptionalmaxWidth: number

      Returns void

    • Gets the width in pixels of a character using the current font.

      Parameters

      • char: string

        Character whose width is wanted.

      Returns number

      Width of character in pixels.

    • Gets the width in pixels of the character m using the current font.

      Returns number

      Width of m in pixels.

    • Gets the height, ascent and descent in pixels of the current font.

      Returns TextHeight

      A TextHeight interface with height, ascent and descent encompassing the main characters in the font.

    • Parameters

      • sx: number
      • sy: number
      • sw: number
      • sh: number

      Returns ImageData

    • Gets the height, ascent and descent in pixels of a text string using the current font.

      Parameters

      • text: string

        string whose height is to be obtained.

      Returns TextHeight

      A TextHeight interface with height, ascent and descent of string.

    • Gets the width of a string using the current font.

      Parameters

      • text: string

        Text to measure.

      Returns number

      Width of string in pixels.

      Calculates the width of a string in pixels by adding the widths of each character in the string. The widths of each character is either obtained from a map or (if not in map) calculated using measureText() and stored in map.

      NOTE: There is a minor measuring error when taking the sum of the pixel widths of individual characters that make up a string vs. the pixel width of the string taken as a whole. This is possibly due to kerning or rounding. The error is typically about 0.1%.

    • Gets a map of the width (value) of characters (key) for a particular font

      Parameters

      • font: string

        the name of the font

      Returns TextWidthMap

    • Parameters

      • x: number
      • y: number

      Returns void

    • Parameters

      • value: string

      Returns TextMetrics

    • Parameters

      • x: number
      • y: number

      Returns void

    • Parameters

      • imageData: ImageData
      • sx: number
      • sy: number

      Returns void

    • Parameters

      • cpx: number
      • cpy: number
      • x: number
      • y: number

      Returns void

    • Parameters

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

      Returns void

    • Parameters

      • x: number
      • y: number

      Returns void

    • Returns void

    • Parameters

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

      Returns void