Options
All
  • Public
  • Public/Protected
  • All
Menu

A Sprite is one of the main drawing primitives. It is responsible for drawing images or parts of images from a Texture resource to the screen.

Hierarchy

  • SpriteImpl
    • Sprite

Implements

Index

Constructors

constructor

Properties

anchor

anchor: Vector = new Vector(0.0, 0.0)

effects

effects: SpriteEffect[] = []

flipHorizontal

flipHorizontal: boolean = false

Draws the sprite flipped horizontally

flipVertical

flipVertical: boolean = false

Draws the sprite flipped vertically

height

height: number = 0

logger

logger: Logger = Logger.getInstance()

offset

offset: Vector = Vector.Zero

rotation

rotation: number = 0

scale

scale: Vector = Vector.One

width

width: number = 0

x

x: number = 0

y

y: number = 0

Accessors

drawHeight

  • get drawHeight(): number

drawWidth

  • get drawWidth(): number

Methods

addEffect

clearEffects

  • clearEffects(): void

clone

  • clone(): SpriteImpl

colorize

  • colorize(color: Color): void
  • Applies the Colorize effect to a sprite, changing the color channels of all pixels to be the average of the original color and the provided color.

    Parameters

    Returns void

darken

  • darken(factor?: number): void
  • Applies the Darken effect to a sprite, changes the darkness of the color according to HSL

    Parameters

    • Default value factor: number = 0.1

    Returns void

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D, x: number, y: number): void

desaturate

  • desaturate(factor?: number): void
  • Applies the Desaturate effect to a sprite, desaturates the color according to HSL

    Parameters

    • Default value factor: number = 0.1

    Returns void

draw

  • draw(ctx: CanvasRenderingContext2D, x: number, y: number): void
  • draw(options: DrawOptions): void
  • Draws the sprite appropriately to the 2D rendering context, at an x and y coordinate.

    Parameters

    • ctx: CanvasRenderingContext2D

      The 2D rendering context

    • x: number

      The x coordinate of where to draw

    • y: number

      The y coordinate of where to draw

    Returns void

  • Draws the sprite with custom options to override internals without mutating them.

    Parameters

    Returns void

fill

  • fill(color: Color): void
  • Applies the Fill effect to a sprite, changing the color channels of all non-transparent pixels to match a given color

    Parameters

    Returns void

grayscale

  • grayscale(): void

invert

  • invert(): void

lighten

  • lighten(factor?: number): void
  • Applies the Lighten effect to a sprite, changes the lightness of the color according to HSL

    Parameters

    • Default value factor: number = 0.1

    Returns void

opacity

  • opacity(value: number): void
  • Applies the Opacity effect to a sprite, setting the alpha of all pixels to a given value

    Parameters

    • value: number

    Returns void

removeEffect

  • removeEffect(effect: SpriteEffect): void
  • removeEffect(index: number): void

reset

  • reset(): void

saturate

  • saturate(factor?: number): void
  • Applies the Saturate effect to a sprite, saturates the color according to HSL

    Parameters

    • Default value factor: number = 0.1

    Returns void