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

toonz-vector

Pure-Python centre-line ink vectorizer, palette-locked region tracer, and stroke inbetweener.

Pure-Python centre-line vectorization and stroke-matching toolkit implementing OpenToonz-inspired ink/paint separation, variable-width Catmull-Rom stroke fitting, and arc-preserving stroke inbetweening.

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

Why we built it

Standard edge-tracing vectorizers turn ink lines into hollow outline polygons that cannot be easily thinned, edited, or inbetweened. Inspired by OpenToonz's centre-line vectorization concepts (BSD-3-Clause), we built a clean Python implementation that extracts variable-width centre-line strokes, locks paint regions to a shared sequence palette, and computes arc-preserving stroke inbetweens.

Architecture & how it works

toonz/cli.py extracts dark ink pixels by tone threshold, separates wide dark fills (like hair masses) from lines using morphological opening, despeckles the line layer, thins to a 1-pixel skeleton, measures per-point half-widths, and fits weighted Catmull-Rom curves into *.strokes.json. Paint regions are flood-filled under the ink, quantized to a single palette shared across the whole directory to prevent color flicker, and traced. Separate match and inbetween commands pair strokes across frames and interpolate them using arc-preserving TInbetween-style transforms.

Key capabilities

  • Centre-line skeletonization with per-control-point variable stroke thickness
  • Automatic separation of thin ink lines from wide dark paint masses (--fill-px)
  • Shared-palette quantization across frame directories to eliminate color flicker
  • Dual SVG output: combined paint+ink (<name>.svg) and ink-only (<name>_lines.svg)
  • Stroke-to-stroke matching and arc-preserving ink-only inbetween generation

Usage example

Vectorize a frame directory and generate an arc-preserving inbetweenPython
python3 anim/toonz/cli.py vectorize ./frames --out ./vec --palette 14 --fill-px 8
python3 anim/toonz/cli.py match ./vec/000.strokes.json ./vec/001.strokes.json
python3 anim/toonz/cli.py inbetween ./vec/000.strokes.json ./vec/001.strokes.json --n 2 --ease inout --out ./vec/ib
Outputs *.strokes.json in the exact format consumed by keylib and compatible with toonz_engine.