Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

constructor

Properties

_bitmap

_bitmap: HTMLCanvasElement

Protected _ctx

_ctx: CanvasRenderingContext2D

filtering

filtering: ImageFiltering = null

Readonly id

id: number = ...

opacity

opacity: number = 1

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

showDebug

showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

transform

transform: Matrix = ...

Accessors

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

  • 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.

    Parameters

    Returns void

ctx

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

    Returns CanvasRenderingContext2D

dirty

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

    Returns boolean

flipHorizontal

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

    Returns boolean

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

    Parameters

    • value: boolean

    Returns void

flipVertical

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

    Returns boolean

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

    Parameters

    • value: boolean

    Returns void

height

  • get height(): number
  • set height(value: number): void
  • 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 set will be factored into the height

    Returns 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 set will be factored into the height

    Parameters

    • value: number

    Returns void

lineDash

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

lineWidth

  • get lineWidth(): number
  • set lineWidth(value: number): void
  • 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

  • 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.

    Parameters

    • value: number

    Returns void

localBounds

origin

  • Gets or sets the origin of the graphic, if not set the center of the graphic is the origin

    Returns Vector

  • Gets or sets the origin of the graphic, if not set the center of the graphic is the origin

    Parameters

    Returns void

padding

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

rotation

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

    Returns number

  • Gets or sets the rotation of the graphic

    Parameters

    • value: number

    Returns void

scale

  • Gets or sets the scale of the graphic, this affects the width and

    Returns Vector

  • Gets or sets the scale of the graphic, this affects the width and

    Parameters

    Returns void

smoothing

  • get smoothing(): boolean
  • set smoothing(value: boolean): void
  • 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

  • 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.

    Parameters

    • value: boolean

    Returns void

strokeColor

  • get strokeColor(): Color
  • set strokeColor(value: Color): void
  • 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

  • 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.

    Parameters

    Returns void

width

  • get width(): number
  • set width(value: number): void
  • 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 set will be factored into the width

    Returns 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 set will be factored into the width

    Parameters

    • value: number

    Returns void

Methods

Protected _applyRasterProperites

  • _applyRasterProperites(ctx: CanvasRenderingContext2D): void

Protected _drawImage

Protected _flip

Protected _postDraw

Protected _preDraw

Protected _rotate

clone

cloneGraphicOptions

cloneRasterOptions

draw

execute

  • execute(ctx: CanvasRenderingContext2D): void
  • Executes drawing implemenation 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

    Returns void

flagDirty

  • flagDirty(): 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 outputed drawing

    Returns void

isStale

  • isStale(): boolean

rasterize

  • rasterize(): void