A canvas Graphic to provide an adapter between the 2D Canvas API and the ExcaliburGraphicsContext.

The Canvas works by re-rastering a draw handler to a HTMLCanvasElement for every draw which is then passed to the ExcaliburGraphicsContext implementation as a rendered image.

Low performance API

Hierarchy

Constructors

Properties

_bitmap: HTMLCanvasElement
_ctx: CanvasRenderingContext2D
filtering: ImageFiltering = null
id: number = ...
lineCap: "square" | "butt" | "round" = 'butt'
opacity: number = 1

Gets or sets the opacity of the graphic, 0 is transparent, 1 is solid (opaque).

quality: number = 1
showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

tint: Color = null
transform: AffineMatrix = ...

Accessors

  • get color(): Color
  • Gets or sets the fillStyle of the Raster graphic. Setting the fillStyle will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Returns Color

  • set color(value: Color): void
  • Parameters

    Returns void

  • get ctx(): CanvasRenderingContext2D
  • Return the 2D graphics context of this canvas

    Returns CanvasRenderingContext2D

  • get dirty(): boolean
  • Gets whether the graphic is dirty, this means there are changes that haven't been re-rasterized

    Returns boolean

  • get flipHorizontal(): boolean
  • Gets or sets the flipHorizontal, which will flip the graphic horizontally (across the y axis)

    Returns boolean

  • set flipHorizontal(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get flipVertical(): boolean
  • Gets or sets the flipVertical, which will flip the graphic vertically (across the x axis)

    Returns boolean

  • set flipVertical(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get height(): number
  • Gets or sets the current height of the Raster graphic. Setting the height will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Any padding or quality set will be factored into the height

    Returns number

  • set height(value: number): void
  • Parameters

    • value: number

    Returns void

  • get lineDash(): number[]
  • Returns number[]

  • set lineDash(value: number[]): void
  • Parameters

    • value: number[]

    Returns void

  • get lineWidth(): number
  • Gets or sets the line width of the Raster graphic. Setting the lineWidth will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Returns number

  • set lineWidth(value: number): void
  • Parameters

    • value: number

    Returns void

  • get padding(): number
  • Returns number

  • set padding(value: number): void
  • Parameters

    • value: number

    Returns void

  • get rotation(): number
  • Gets or sets the rotation of the graphic

    Returns number

  • set rotation(value: number): void
  • Parameters

    • value: number

    Returns void

  • get smoothing(): boolean
  • Gets or sets the smoothing (anti-aliasing of the graphic). Setting the height will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Returns boolean

  • set smoothing(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get strokeColor(): Color
  • Gets or sets the strokeStyle of the Raster graphic. Setting the strokeStyle will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Returns Color

  • set strokeColor(value: Color): void
  • Parameters

    Returns void

  • get width(): number
  • Gets or sets the current width of the Raster graphic. Setting the width will cause the raster to be flagged dirty causing a re-raster on the next draw.

    Any paddings or quality set will be factored into the width

    Returns number

  • set width(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Executes drawing implementation of the graphic, this is where the specific drawing code for the graphic should be implemented. Once rasterize() the graphic can be drawn to the ExcaliburGraphicsContext via draw(...)

    Parameters

    • ctx: CanvasRenderingContext2D

      Canvas to draw the graphic to

    Returns void

  • Flags the graphic as dirty, meaning it must be re-rasterized before draw. This should be called any time the graphics state changes such that it affects the outputted drawing

    Returns void