frame-msg
    Preparing search index...

    Class TxSprite

    A sprite message containing image data with a custom palette.

    Index

    Constructors

    Properties

    compress: boolean

    Whether the pixel data is compressed using LZ4.

    height: number

    The height of the sprite in pixels.

    numColors: number

    The number of colors in the sprite's palette.

    paletteData: Uint8Array

    The palette data as a flat Uint8Array of RGB values.

    pixelData: Uint8Array

    The pixel data as a Uint8Array of palette indices.

    width: number

    The width of the sprite in pixels.

    Accessors

    • get bpp(): number

      The number of bits per pixel, derived from the number of colors.

      Returns number

    Methods

    • Packs the sprite data into a compact binary format. The format includes a header, palette data, and packed pixel data. Pixel data can be optionally compressed using LZ4.

      Returns Uint8Array

      A Uint8Array containing the packed sprite data.

    • Converts the TxSprite to a PNG image as an ArrayBuffer. Intended for debugging and visualization purposes.

      Returns ArrayBuffer

      The PNG image data as an ArrayBuffer.

    • Creates a TxSprite from an image file, resizing and quantizing it to a maximum of 16 colors.

      Parameters

      • imageBytes: ArrayBuffer

        The ArrayBuffer containing the image data.

      • maxPixels: number = 48000

        The maximum number of pixels allowed in the sprite.

      • compress: boolean = false

        Whether to compress the pixel data using LZ4.

      Returns Promise<TxSprite>

      A TxSprite instance.

    • Creates a TxSprite from an indexed PNG image.

      Parameters

      • imageBytes: ArrayBuffer

        The ArrayBuffer containing the PNG image data.

      • compress: boolean = false

        Whether to compress the pixel data using LZ4.

      Returns Promise<TxSprite>

      A TxSprite instance.