Skip to main content
Built by Best ROI MediaMITWave 1 · LiveBestRoiMedia/anim-toolkit

keylib

Stroke-list key-drawing library for zero-cost 2D posing, arc inbetweens, and sequences.

Vector key-drawing library and stroke-list editor that segments vectorized character keys by skeleton joints, then generates posed frames, arc-preserving inbetweens, part swaps, and full sequences with zero AI image calls.

View on GitHub ↗
Quick clonegit clone https://github.com/BestRoiMedia/anim-toolkit.git
GitHub repositoryBestRoiMedia/anim-toolkit
Module path_tools/anim/keylib/
LicenseMIT
Release waveWave 1
LanguagesPython · SVG · JSON

Why we built it

Re-generating every frame of a 2D character with an image model is slow, expensive, and prone to on-model drift. By vectorizing a small set of clean key drawings once and segmenting their strokes and paint regions by joint hierarchy, keylib lets us pose, mirror, swap hands, and inbetween unlimited animations deterministically for free.

Architecture & how it works

keylib ingests centre-line strokes (*.strokes.json) and paint regions from toonz_engine or toonz-vector alongside joint coordinates, cutting strokes and naming them per anatomical part. Keys are registered against the rest key's topology in a library.json. From there, pose, inbetween, mirror, swap, boil, and sequence commands transform and interpolate strokes with optional joint stagger, reversal snap, and automated art/motion gates (POSE_BEYOND_ART, LIMB_TORN, ORPHAN_FRAGMENT, CONTOUR_STRETCH, INK_PAINT_SEPARATION, SIMULTANEOUS_JOINTS, CHART_MISMATCH).

Key capabilities

  • Automatic stroke segmentation and bible-color paint tracing per skeletal part
  • Zero-cost posing, arc-preserving key-to-key inbetweening, x-mirroring, and part swapping
  • Exposure-sheet sequence builder with per-joint stagger offsets and reversal snapping
  • Strict joint-fitting check (fit) that rejects drawings where limbs moved beyond max-shift
  • Automated art quality gates (LIMB_TORN, ORPHAN_FRAGMENT, CONTOUR_STRETCH, INK_PAINT_SEPARATION)
  • Studio v2 hook integration (gates_hook.py) and deterministic self-test suite

Usage example

Build a key, add it to a library, and render an inbetween sequencePython
python3 anim/keylib/cli.py key build --config ./char.json --name idle --strokes ./000.strokes.json --paint ./000_paint.png --joints ./000_joints.json --out ./idle.json
python3 anim/keylib/cli.py library add --lib ./lib/library.json --name idle --drawing ./idle.json --config ./char.json
python3 anim/keylib/cli.py inbetween --lib ./lib/library.json --a idle --b crouch --t 0.5 --out ./mid.json --svg ./mid.svg
python3 anim/keylib/cli.py sequence --lib ./lib/library.json --sheet ./walk.xsheet.json --out ./seq --check
All commands emit a single JSON object with command, result, problems, and next_actions. Zero network or paid API calls.