A Graphic is the base Excalibur primitive for something that can be drawn to the [[ExcaliburGraphicsContext]]. [[Sprite]], [[Animation]], [[GraphicsGroup]], [[Canvas]], [[Rectangle]], [[Circle]], and [[Polygon]] all derive from the [[Graphic]] abstract class.

Implementors of a Graphic must override the abstract [[Graphic._drawImage]] method to render an image to the graphics context. Graphic handles all the position, rotation, and scale transformations in [[Graphic._preDraw]] and [[Graphic._postDraw]]

Hierarchy

Constructors

Properties

color: Color = Color.Black
end: Vector
id: number = ...
opacity: number = 1

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

showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

start: Vector
thickness: number = 1
tint: Color = null
transform: AffineMatrix = ...

Accessors

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

    Returns boolean

  • set flipHorizontal(value): 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): void
  • Parameters

    • value: boolean

    Returns void

  • get height(): number
  • Gets or sets the height of the graphic (always positive)

    Returns number

  • set height(value): void
  • Parameters

    • value: number

    Returns void

  • get localBounds(): BoundingBox
  • Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.

    Returns BoundingBox

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

    Returns number

  • set rotation(value): void
  • Parameters

    • value: number

    Returns void

  • get width(): number
  • Gets or sets the width of the graphic (always positive)

    Returns number

  • set width(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Meant to be overridden by the graphic implementation to draw the underlying image (HTMLCanvasElement or HTMLImageElement) to the graphics context without transform. Transformations like position, rotation, and scale are handled by [[Graphic._preDraw]] and [[Graphic._postDraw]]

    Parameters

    Returns void