Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Image

Hierarchy

  • Image

Index

Constructors

constructor

  • new Image(canvas: HTMLCanvasElement, x?: number, y?: number, w?: number, h?: number): Image
  • A wrapper around images. Handles browser-specific quirks and other things a game shouldn't have to know about.

    constructor

    Parameters

    • canvas: HTMLCanvasElement
    • Optional x: number
    • Optional y: number
    • Optional w: number
    • Optional h: number

    Returns Image

Properties

Private _canvas

_canvas: any

Private _height

_height: any

Private _width

_width: any

height

height: number

width

width: number

x

x: number

y

y: number

Methods

_ensure256Square

  • _ensure256Square(): void
  • Chrome has trouble copying from a canvas in RAM to a canvas in GPU memory and vice versa, unless all canvases are >= 256x256.

    Returns void

draw

  • draw(ctx: CanvasRenderingContext2D, x: number, y: number): void
  • Draws this image.

    Parameters

    • ctx: CanvasRenderingContext2D

      A canvas' graphics context.

    • x: number

      The x-coordinate at which to draw.

    • y: number

      The y-coordinate at which to draw.

    Returns void

drawScaled

  • drawScaled(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number): void
  • Draws this image.

    Parameters

    • ctx: CanvasRenderingContext2D

      A canvas' graphics context.

    • x: number

      The x-coordinate at which to draw.

    • y: number

      The y-coordinate at which to draw.

    • w: number

      The width to (possibly) stretch the image to when drawing.

    • h: number

      The height to (possibly) stretch the image to when drawing.

    Returns void

drawScaled2

  • drawScaled2(ctx: CanvasRenderingContext2D, srcX: number, srcY: number, srcW: number, srcH: number, destX: number, destY: number, destW: number, destH: number): void
  • Draws this image.

    Parameters

    • ctx: CanvasRenderingContext2D

      A canvas' graphics context.

    • srcX: number

      The x-coordinate at which to draw.

    • srcY: number

      The y-coordinate at which to draw.

    • srcW: number

      The width of the (possibly) sub-image to draw.

    • srcH: number

      The height of the (possibly) sub-image to draw.

    • destX: number

      The x-coordinate at which to draw.

    • destY: number

      The y-coordinate at which to draw.

    • destW: number

      The width to (possibly) stretch the image to when drawing.

    • destH: number

      The height to (possibly) stretch the image to when drawing.

    Returns void

makeColorTranslucent

  • makeColorTranslucent(x?: number, y?: number): void
  • Converts a color of a particular type to completely transparent in this image.

    method

    Parameters

    • Optional x: number

      The x-coordinate of the pixel whose color to change. 0 will be used if this parameter is undefined.

    • Optional y: number

      The y-coordinate of the pixel whose color to change. 0 will be used if this parameter is undefined.

    Returns void

    This image, which has been modified.

Generated using TypeDoc