AsepriteParser
ceramic.AsepriteParser (Class)
Parser for Aseprite (.ase/.aseprite) animation files.
This class provides utilities to parse Aseprite files and convert them into
formats usable by the Ceramic engine. It handles layer compositing, frame
extraction, texture atlas packing, and sprite sheet generation.
Key features:
- Parses all Aseprite data including frames, layers, tags, slices, and palettes
- Composites layers with proper blend modes and opacity
- Detects and deduplicates identical frames to save memory
- Packs frames into texture atlases for efficient rendering
- Generates sprite sheets for animation playback (when sprite plugin is enabled)
- Supports indexed color mode with palette lookups
- Handles premultiplied alpha for correct blending
The parser supports all standard Aseprite blend modes including:
Normal, Multiply, Screen, Overlay, Darken, Lighten, Color Dodge,
Color Burn, Hard Light, Soft Light, Difference, Exclusion,
Hue, Saturation, Color, Luminosity, Addition, Subtract, and Divide.
See: AsepriteData for the parsed data structure, AsepriteBlendFuncs for blend mode implementations
Static Members
Parses an Aseprite file and returns structured data for use in Ceramic.
This method processes all frames, composites layers, detects duplicates,
and optionally packs frames into a texture atlas.
Name |
Type |
Default |
Description |
ase |
ase.Ase |
|
The raw Aseprite file data to parse |
prefix |
String |
|
Prefix for naming texture regions in the atlas (e.g., "player") |
atlasPacker |
TextureAtlasPacker |
(optional) |
Optional texture atlas packer to add frames to |
singleFrame |
Int |
-1 |
If >= 0, only parse up to this frame number (for partial loading) |
premultiplyAlpha |
Bool |
true |
Whether to premultiply alpha for correct GPU blending (default: true) |
options |
AnonStruct |
(optional) |
Optional parsing options: - layers: Array of layer names to include (null = all visible layers) |
Returns |
Description |
AsepriteData |
Parsed AsepriteData containing frames, tags, layers, and atlas references |
ase
parseTextureFromAsepriteData(asepriteData: AsepriteData, frame: Int, ?density: Float = 1): Texture
Creates a texture from a specific frame in parsed Aseprite data.
This method is useful when you need a standalone texture from a single frame
rather than using the texture atlas. It handles frame deduplication and
proper positioning of trimmed frames.
Name |
Type |
Default |
Description |
asepriteData |
AsepriteData |
|
The parsed Aseprite data |
frame |
Int |
|
Frame index to extract (0-based) |
density |
Float |
1 |
Texture density for high-DPI displays (default: 1) |
Returns |
Description |
Texture |
A new Texture containing the frame's pixels, or null if frame not found |
ase
parseGridTextureFromAsepriteData(asepriteData: AsepriteData, frameStart: Int, frameEnd: Int, texWidth: Int, texHeight: Int, ?spacing: Int = 0, ?padding: Int = 0, ?density: Float = 1): Texture
Creates a grid texture containing multiple frames from Aseprite data.
This method arranges frames in a grid layout within a single texture,
useful for sprite sheets or tile sets that need a specific layout.
Frames are arranged left-to-right, top-to-bottom with configurable spacing.
Name |
Type |
Default |
Description |
asepriteData |
AsepriteData |
|
The parsed Aseprite data |
frameStart |
Int |
|
First frame index to include (0-based) |
frameEnd |
Int |
|
Last frame index to include (inclusive) |
texWidth |
Int |
|
Width of the output texture |
texHeight |
Int |
|
Height of the output texture |
spacing |
Int |
0 |
Pixels between frames (default: 0) |
padding |
Int |
0 |
Pixels of padding around the entire grid (default: 0) |
density |
Float |
1 |
Texture density for high-DPI displays (default: 1) |
Returns |
Description |
Texture |
A new Texture containing the frame grid |
Creates a sprite sheet from parsed Aseprite data.
This method generates a SpriteSheet with animations based on the tags
defined in the Aseprite file. Each tag becomes an animation with proper
frame sequencing, durations, and loop settings.
The sprite sheet uses the texture atlas from the AsepriteData for
efficient rendering of animations.
Only available when the sprite plugin is enabled.
Name |
Type |
Description |
asepriteData |
AsepriteData |
The parsed Aseprite data containing frames and tags |
Returns |
Description |
SpriteSheet |
A new SpriteSheet ready for animation playback |
Private Members
Parses and composites pixel data for a single frame.
This internal method handles the complex task of:
- Extracting cel data from each layer
- Handling linked cels that reference other frames
- Computing the packed bounds by trimming transparent pixels
- Compositing layers with blend modes and opacity
ase
blendAseFrameLayerPixels(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, blendMode: ase.chunks.LayerBlendMode, opacity: Int): Void
ase
blendAseFrameLayerPixelsNormal(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsMultiply(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsScreen(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsOverlay(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsDarken(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsLighten(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsColorDodge(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsColorBurn(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsHardLight(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsSoftLight(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsDifference(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsExclusion(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsHue(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsSaturation(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsColor(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsLuminosity(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsAddition(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsSubtract(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
ase
blendAseFrameLayerPixelsDivide(srcBuffer: UInt8Array, srcBufferWidth: Int, dstBuffer: UInt8Array, dstBufferWidth: Int, srcX: Int, srcY: Int, srcWidth: Int, srcHeight: Int, dstX: Int, dstY: Int, opacity: Int): Void
Extracts pixel data from a cel chunk.
Handles different color depths:
- 32-bit RGBA: Direct pixel data
- 16-bit Grayscale+Alpha: Converted to RGBA
- 8-bit Indexed: Palette lookup to RGBA
Name |
Type |
Description |
ase |
ase.Ase |
The Aseprite file data for color depth info |
palette |
AsepritePalette |
Color palette for indexed color mode |
celChunk |
ase.chunks.CelChunk |
The cel containing compressed pixel data |
Returns |
Description |
UInt8Array |
RGBA pixel data as UInt8Array |