Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Bitmap

Allows you to map pixels to the screen or draw rectangles.

Hierarchy

  • Bitmap

Index

Constructors

constructor

  • new Bitmap(width?: number, height?: number): Bitmap

Properties

baseTexture

baseTexture: BaseTexture

[read-only] The base texture that holds the image.

property

baseTexture

cacheEntry

cacheEntry: CacheEntry

Cache entry, for images. In all cases _url is the same as cacheEntry.key

canvas

[read-only] The bitmap canvas.

property

canvas

context

[read-only] The 2d context of the bitmap canvas.

property

context

fontFace

fontFace: string

The face name of the font.

property

fontFace

fontItalic

fontItalic: number

Whether the font is italic.

property

fontItalic

fontSize

fontSize: number

The size of the font in pixels.

property

fontSize

height

height: number

[read-only] The height of the bitmap.

property

height

outlineColor

outlineColor: string

The color of the outline of the text in CSS format.

property

outlineColor

outlineWidth

outlineWidth: number

The width of the outline of the text.

property

outlineWidth

paintOpacity

paintOpacity: number

The opacity of the drawing object in the range (0, 255).

property

paintOpacity

rect

rect: Rectangle

[read-only] The rectangle of the bitmap.

property

rect

smooth

smooth: boolean

Whether the smooth scaling is applied.

property

smooth

textColor

textColor: string

The color of the text in CSS format.

property

textColor

url

url: string

[read-only] The url of the image file.

property

url

width

width: number

[read-only] The width of the bitmap.

property

width

Methods

addLoadListener

  • addLoadListener(listner: (bitmap: Bitmap) => void): void
  • Add a callback function that will be called when the bitmap is loaded.

    method

    addLoadListener

    Parameters

    • listner: (bitmap: Bitmap) => void

      The callback function

        • Parameters

          Returns void

    Returns void

adjustTone

  • adjustTone(r: number, g: number, b: number): void
  • Changes the color tone of the entire bitmap.

    method

    adjustTone

    Parameters

    • r: number

      The red strength in the range (-255, 255)

    • g: number

      The green strength in the range (-255, 255)

    • b: number

      The blue strength in the range (-255, 255)

    Returns void

blt

  • blt(source: Bitmap, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw?: number, dh?: number): void
  • Performs a block transfer.

    method

    blt

    Parameters

    • source: Bitmap

      The bitmap to draw

    • sx: number

      The x coordinate in the source

    • sy: number

      The y coordinate in the source

    • sw: number

      The width of the source image

    • sh: number

      The height of the source image

    • dx: number

      The x coordinate in the destination

    • dy: number

      The y coordinate in the destination

    • Optional dw: number
    • Optional dh: number

    Returns void

bltImage

  • bltImage(source: Bitmap, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw?: number, dh?: number): void
  • Performs a block transfer, using assumption that original image was not modified (no hue)

    method

    blt

    Parameters

    • source: Bitmap

      The bitmap to draw

    • sx: number

      The x coordinate in the source

    • sy: number

      The y coordinate in the source

    • sw: number

      The width of the source image

    • sh: number

      The height of the source image

    • dx: number

      The x coordinate in the destination

    • dy: number

      The y coordinate in the destination

    • Optional dw: number
    • Optional dh: number

    Returns void

blur

  • blur(): void

clear

  • clear(): void

clearRect

  • clearRect(x: number, y: number, width: number, height: number): void
  • Clears the specified rectangle.

    method

    clearRect

    Parameters

    • x: number

      The x coordinate for the upper-left corner

    • y: number

      The y coordinate for the upper-left corner

    • width: number

      The width of the rectangle to clear

    • height: number

      The height of the rectangle to clear

    Returns void

drawCircle

  • drawCircle(x: number, y: number, radius: number, color: string): void
  • Draw the filled circle.

    method

    drawCircle

    Parameters

    • x: number

      The x coordinate of the center of the circle

    • y: number

      The y coordinate of the center of the circle

    • radius: number

      The radius of the circle

    • color: string

      The color of the circle in CSS format

    Returns void

drawText

  • drawText(text: string, x: number, y: number, maxWidth: number, lineHeight: number, align?: string): void
  • Draws the outline text to the bitmap.

    method

    drawText

    Parameters

    • text: string

      The text that will be drawn

    • x: number

      The x coordinate for the left of the text

    • y: number

      The y coordinate for the top of the text

    • maxWidth: number

      The maximum allowed width of the text

    • lineHeight: number

      The height of the text line

    • Optional align: string

      The alignment of the text

    Returns void

fillAll

  • fillAll(color: string): void

fillRect

  • fillRect(x: number, y: number, width: number, height: number, color: string): void
  • Fills the specified rectangle.

    method

    fillRect

    Parameters

    • x: number

      The x coordinate for the upper-left corner

    • y: number

      The y coordinate for the upper-left corner

    • width: number

      The width of the rectangle to clear

    • height: number

      The height of the rectangle to clear

    • color: string

      The color of the rectangle in CSS format

    Returns void

getAlphaPixel

  • getAlphaPixel(x: number, y: number): string
  • Returns alpha pixel value at the specified point.

    method

    getAlphaPixel

    Parameters

    • x: number

      The x coordinate of the pixel in the bitmap

    • y: number

      The y coordinate of the pixel in the bitmap

    Returns string

    The alpha value

getPixel

  • getPixel(x: number, y: number): string
  • Returns pixel color at the specified point.

    method

    getPixel

    Parameters

    • x: number

      The x coordinate of the pixel in the bitmap

    • y: number

      The y coordinate of the pixel in the bitmap

    Returns string

    The pixel color (hex format)

gradientFillRect

  • gradientFillRect(x: number, y: number, width: number, height: number, color1: string, color2: string, vertical?: boolean): void
  • Draws the rectangle with a gradation.

    method

    gradientFillRect

    Parameters

    • x: number

      The x coordinate for the upper-left corner

    • y: number

      The y coordinate for the upper-left corner

    • width: number

      The width of the rectangle to clear

    • height: number

      The height of the rectangle to clear

    • color1: string

      The start color of the gradation

    • color2: string

      The end color of the gradation

    • Optional vertical: boolean

      Whether it draws a vertical gradient

    Returns void

isError

  • isError(): boolean

isReady

  • isReady(): boolean

measureTextWidth

  • measureTextWidth(text: string): number
  • Returns the width of the specified text.

    method

    measureTextWidth

    Parameters

    • text: string

      The text to be measured

    Returns number

    The width of the text in pixels

resize

  • resize(width: number, height: number): void
  • Resizes the bitmap.

    method

    resize

    Parameters

    • width: number

      The new width of the bitmap

    • height: number

      The new height of the bitmap

    Returns void

rotateHue

  • rotateHue(offset: number): void

touch

  • touch(): void

Static load

Static snap

Generated using TypeDoc