Skip to content

Sprite sheets and clips

Read as Markdown

Import from @pibbl/core/sprites. loadSpriteSheet(url, { grid }) loads a regular image grid; loadSpriteSheet(url, { format }) loads metadata through a supplied adapter. It returns a promise for a sheet with readonly frames and animations maps, and idempotent dispose(). Failures release partially loaded image resources. Unmount consumers before disposal. Loading uses browser image decoding.

defineSpriteAnimation({ frames, fps }) or defineSpriteAnimation({ frames: [{ frame, duration }, ...] }) creates an ordinary seekable animation definition. FPS and millisecond durations must be finite and positive. The frame list must be nonempty. Loop with repeat; control playback with the existing animation API.

Import aseprite from @pibbl/core/sprites/formats/aseprite and pass { format: aseprite() }. Supports JSON hash/array frames and frame tags, including forward, reverse, and ping-pong ordering. Images resolve relative to metadata.

Import texturePacker from @pibbl/core/sprites/formats/texture-packer and pass { format: texturePacker() }. Supports JSON hash/array rectangles, trim offsets, and clockwise packed rotation. Linked multipacks and scales other than 1 are explicitly rejected. Author clips with defineSpriteAnimation.

Adapters are separate imports; importing a grid loader does not import either parser. See the sprite guide and sprite types.

Related types: SpriteSheet, SpriteGrid, SpriteSheetFormat, SpriteFrame.

Load a grid image or metadata through an explicitly supplied import adapter. See SpriteFrame.

loadSpriteSheet: (url: string, options: { readonly grid: SpriteGrid; } | { readonly format: SpriteSheetFormat; }) => Promise<SpriteSheet>

Related API: loadSpriteSheet, SpriteGrid, SpriteSheetFormat, SpriteSheet.

  • url — Grid image URL or atlas metadata URL.

  • options — Grid dimensions or an explicit metadata format adapter.

A decoded sprite sheet with explicit disposal ownership.

View source — packages/core/src/features/sprites/loader.ts:16

Author a finite discrete animation using FPS or explicit positive millisecond durations. See SpriteFrame.

defineSpriteAnimation: (options: { readonly frames: readonly SpriteFrame[]; readonly fps: number; } | { readonly frames: readonly Readonly<{ frame: SpriteFrame; duration: number; }>[]; }) => PibblAnimationDefinition<SpriteFrame>

Related API: defineSpriteAnimation, SpriteFrame, PibblAnimationDefinition.

  • options — Frames with a shared FPS or individual millisecond durations.

A seekable discrete animation definition.

View source — packages/core/src/features/sprites/model.ts:60

Import Aseprite JSON hash or array exports, including frame tags and millisecond timing. See SpriteSheetFormat.

aseprite: () => SpriteSheetFormat

Related API: aseprite, SpriteSheetFormat.

An explicit atlas metadata adapter.

View source — packages/core/src/features/sprites/formats/aseprite.ts:5

Import TexturePacker JSON hash/array rectangles with clockwise packed rotation and trim offsets. See SpriteSheetFormat.

texturePacker: () => SpriteSheetFormat

Related API: texturePacker, SpriteSheetFormat.

An explicit atlas metadata adapter.

View source — packages/core/src/features/sprites/formats/texture-packer.ts:5

Read the Authoring, signals, and lifecycle companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.