Skip to main content

NineSlice

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

Index

Constructors

constructor

Properties

readonlyinheritedid

id: number = ...

publicinheritedopacity

opacity: number = 1

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

publicinheritedshowDebug

showDebug: boolean = false

Gets or sets wether to show debug information about the graphic

publicoptionalinheritedtint

tint?: Color

publicinheritedtransform

transform: AffineMatrix = ...

Accessors

publicinheritedflipHorizontal

  • 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

  • Parameters

    • value: boolean

    Returns void

publicinheritedflipVertical

  • 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

  • Parameters

    • value: boolean

    Returns void

publicinheritedheight

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


    Returns number

  • Parameters

    • value: number

    Returns void

publicinheritedlocalBounds

  • Gets a copy of the bounds in pixels occupied by the graphic on the the screen. This includes scale.


    Returns BoundingBox

publicinheritedorigin

  • get origin(): Vector | undefined
  • set origin(value: Vector | undefined): void
  • Gets or sets the origin of the graphic, if not set the center of the graphic is the origin


    Returns Vector | undefined

  • Parameters

    Returns void

publicinheritedrotation

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


    Returns number

  • Parameters

    • value: number

    Returns void

publicinheritedscale

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


    Returns Vector

  • Parameters

    Returns void

publicinheritedwidth

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


    Returns number

  • Parameters

    • value: number

    Returns void

Methods

clone

  • Clones the 9 slice


    Returns NineSlice

publicinheritedcloneGraphicOptions

publicinheriteddraw

  • Draw the whole graphic to the context including transform


    Parameters

    Returns void

getConfig

publicinheritedisStale

  • isStale(): boolean
  • Returns boolean

setMargins

  • setMargins(left: number, top: number, right: number, bottom: number, auto?: boolean): void
  • Sets the 9 slice margins (pixels), and recalculates the 9 slice if desired (auto)


    Parameters

    • left: number
    • top: number
    • right: number
    • bottom: number
    • auto: boolean = false

    Returns void

setStretch

  • setStretch(type: horizontal | vertical | both, stretch: NineSliceStretch, auto?: boolean): void
  • Sets the stretching strategy for the 9 slice, and recalculates the 9 slice if desired (auto)


    Parameters

    • type: horizontal | vertical | both
    • stretch: NineSliceStretch
    • auto: boolean = false

    Returns void

setTargetHeight

  • setTargetHeight(newHeight: number, auto?: boolean): void
  • Sets the target height of the 9 slice (pixels), and recalculates the 9 slice if desired (auto)


    Parameters

    • newHeight: number
    • auto: boolean = false

    Returns void

setTargetWidth

  • setTargetWidth(newWidth: number, auto?: boolean): void
  • Sets the target width of the 9 slice (pixels), and recalculates the 9 slice if desired (auto)


    Parameters

    • newWidth: number
    • auto: boolean = false

    Returns void