# 💡 SDK Concepts

**SpriteStudio-SDK** is a high-performance, **engine-agnostic** animation player SDK for SpriteStudio. It computes everything needed to play a raster-based 2D animation and hands your engine a ready-to-render plan - so a player only needs to draw, not to re-implement SpriteStudio's animation math.

## 🔄 The workflow

1. **Convert** - turn a SpriteStudio project (`.sspj`) into an optimized binary (`.ssab`) with `libssconverter` (via `ssconverter-cli`, [SSConverter GUI](<https://cri-middleware.github.io/SpriteStudio-Docs/players/converter/index.md>), `ssconverter-web`, or automatic conversion in the player). See [Converting Assets](<https://cri-middleware.github.io/SpriteStudio-Docs/overview/conversion/index.md>).
2. **Play anywhere** - pass the `.ssab` to `libssruntime`. It plays *any* `.ssab`; what it covers is listed below, and what it does not cover yet is in [Shared Limitations](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/limitations/index.md>).

```
graph LR
    SS[" .sspj (+ .ssae/.ssce/.ssee/.ssse/.fnt/.ssqe)<br/>+ Images "]
    CLI[[" ssconverter-cli / GUI / web "]]
    CONV(" libssconverter ")
    BIN[" .ssab / .ssqb "]
    RT(" libssruntime ")
    STATE[" Part States / Mesh<br/>+ DrawBatch plan "]
    REND[[" Your renderer "]]

    SS --> CLI --> CONV -. generate .-> BIN
    BIN --> RT
    RT --> STATE --> REND

    classDef generated stroke-dasharray: 5 5;
    class BIN generated;
```

## 🧠 Brain vs. Body

`libssruntime` is the **Brain**: it evaluates keyframes for the current frame and computes bone matrices, mesh deformation, and hierarchical color/opacity, then emits a cross-engine **`DrawBatch` plan**. Your player is the **Body**: it reads the generated vertices and draws the primitives. Because every renderer consumes the *same* `DrawBatch` plan, engine-specific visual drift is structurally eliminated. (See [Porting a Player](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/porting/index.md>).)

## ✅ What the core provides

Because every official player evaluates animations with `libssruntime`, this feature set is **shared** rather than reimplemented per engine:

- Bone hierarchies and transforms, with full keyframe interpolation (Bezier / Hermite / Linear / ...)
- Mesh & deform
- Effect parts (particles)
- Instance parts
- Masks
- 9-slice parts - the runtime builds the whole grid (margins, stretch / tile fill, repeats), so a player only draws the geometry it is handed
- Shape parts - triangles, rectangles, stars and other figures with no texture; the runtime generates their vertices, so a player only draws them
- Text parts - the runtime passes the authored text and, for a bitmap font, its glyph table, and keeps the part's slot in the draw plan; laying out and drawing the glyphs is the player's job
- Parts color (per-part color blending)
- Authored texture change - a per-part texture swap set on the timeline; the runtime resolves it into the draw batch, so a player that binds textures per batch needs no special handling
- Frame-accurate events - user data, signal, audio
- Sub-frame interpolation (smooth playback above the base frame rate - 144 Hz+, slow motion)
- Whole-animation mixing / crossfade (animations stacked on tracks) - what it gives and where each player documents it is on [Motion Blending](<https://cri-middleware.github.io/SpriteStudio-Docs/overview/motion-blending/index.md>)
- The **Override Layer API** - override a part's color, cell reference, or visibility at runtime; what a player lets you change at runtime is on [Changing a Character at Runtime](<https://cri-middleware.github.io/SpriteStudio-Docs/overview/runtime-changes/index.md>)

> [!TIP]
>
> **Source of truth**
>
> This list follows the SDK's **Player Porting Guide**, whose table of contents ([`README.md`](<https://github.com/cri-middleware/SpriteStudio-SDK/blob/HEAD/libs/ssruntime/docs/README.md>)) links to the page that covers each item. The guide's *Introduction → Limitations* ([`20_limitations.md`](<https://github.com/cri-middleware/SpriteStudio-SDK/blob/HEAD/libs/ssruntime/docs/10_introduction/20_limitations.md>)) draws the boundary: two of these - text parts and audio events - are computed as **state only** and still need the player to draw or play them, and several carry constraints - both are summarized in [Shared Limitations](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/limitations/index.md>), along with what the core does *not* do. What differs between the players themselves is on [Player Differences](<https://cri-middleware.github.io/SpriteStudio-Docs/overview/player-differences/index.md>).

## 📚 Libraries & tools

| Component | Role |
| --- | --- |
| [`libsspj`](<https://github.com/cri-middleware/SpriteStudio-SDK/tree/HEAD/libs/sspj>) | Parses `.sspj` projects (`ssae` / `ssce` / `ssee` / `ssse` / `fnt` / `ssqe`). |
| [`libssab`](<https://github.com/cri-middleware/SpriteStudio-SDK/tree/HEAD/libs/ssab>) | Reads/writes the `.ssab` / `.ssqb` binary (FlatBuffers). |
| [`libssconverter`](<https://github.com/cri-middleware/SpriteStudio-SDK/tree/HEAD/libs/ssconverter>) | Converts `.sspj` projects into `.ssab` / `.ssqb`. |
| [`libssruntime`](<https://github.com/cri-middleware/SpriteStudio-SDK/tree/HEAD/libs/ssruntime>) | The playback Brain; emits the `DrawBatch` plan. |
| [`ssconverter-cli`](<https://github.com/cri-middleware/SpriteStudio-SDK/tree/HEAD/cli>) | Command-line converter (Windows / macOS / Linux). |

## ✨ Why this design

- **Zero-math integration & visual consistency** - the SDK does the state computation; your engine just renders the shared `DrawBatch`.
- **Ultra-compact payload & SIMD** - the `.ssab` format uses a columnar layout and hash-based lookups for near-zero parsing overhead; the runtime leverages SIMD (`f32x4`), with a WebAssembly build without it for runtimes that have none.
- **Extreme portability** - the core is strict `#![no_std]` Rust with no OS/stdlib dependency; integrates via C-API or WASM, from embedded devices to browsers.

## ➡️ Next

- [Glossary](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/glossary/index.md>) - the vocabulary used here and in every player's docs.
- [Shared Limitations](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/limitations/index.md>) - the constraints that apply to every player.
- [Format Specification](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/format-spec/index.md>) - the `.ssab / .ssqb` binary and the runtime `FrameData` interface.
- [Porting a Player](<https://cri-middleware.github.io/SpriteStudio-Docs/sdk/porting/index.md>) - build a player for a new engine.
- Source of truth: [SpriteStudio-SDK](<https://github.com/cri-middleware/SpriteStudio-SDK>).
