API

Interface SpriteAtlasFrameSource

One source frame for createSpriteAtlasFromFrames / appendSpriteAtlasFrames. The packed region is width × height texels. By default the source is read as a tightly-packed RGBA8 buffer of exactly that size starting at byte 0; the optional srcX / srcY / srcStrideBytes fields let the source describe a sub-rectangle of a larger buffer without forcing the caller to copy out the sub-rect first.

interface SpriteAtlasFrameSource {
    height: number;
    name?: string;
    pivot?: readonly [number, number];
    pixels: Uint8Array;
    srcStrideBytes?: number;
    srcX?: number;
    srcY?: number;
    width: number;
}
Index
height: number

Height of the frame to pack (texels written to the atlas).

name?: string

Recorded on the emitted SpriteFrame.name.

pivot?: readonly [number, number]

Pivot in [0,1] of the frame. Default [0.5, 0.5].

pixels: Uint8Array

RGBA8 bytes, row-major, top-to-bottom, straight alpha. When srcX / srcY / srcStrideBytes are all defaulted, this must be exactly width * height * 4 bytes; when sub-rect fields are supplied, it must be large enough to cover the rect (see those fields' docs).

srcStrideBytes?: number

Bytes between consecutive rows of pixels. Default width * 4 (tightly packed). Must satisfy (srcX + width) * 4 <= srcStrideBytes — i.e. each row's sub-rect window must fit within one stride, so reads do not spill into the next row.

srcX?: number

Top-left x of the sub-rect to pack, in texels into pixels. Default 0.

srcY?: number

Top-left y of the sub-rect to pack, in texels into pixels. Default 0.

width: number

Width of the frame to pack (texels written to the atlas).