✍️ handanim Documentation

handanim is a Python library and agentic studio for creating whiteboard-style, hand-drawn animations, mathematical proofs, and narrated short-form explainers.

PyPI Version GitHub Stars Docs Status

The Unified Whiteboard Ecosystem

handanim ships three tightly integrated packages in a single installation:

🎨 handanim — Core Visual Engine

Hand-sketched geometric primitives, LaTeX & Hershey math, flowcharts, tables, hierarchical 2D character rigs with 2-joint IK, multi-page scene transitions (PageTurnTransition & PaperCrumpleTransition), camera pan/zoom, camera-invariant overlays, and export to MP4, GIF, SVG, PDF, Beamer, and native TikZ.

🎙️ voiceanim — Voice, Music & SFX

Word-aligned speech synthesis (Kokoro-82M local TTS, Qwen3-TTS, AWS Polly), word-by-word Captions highlighting, repeating background theme music with speech ducking, and automatic chalk, eraser, page-turn, and paper-crumple sound effects.

🤖 aianim — Agentic Studio & MCP

Structured ScenePlan compiler, self-healing execution loop, static AST guardrails (check_code), headless layout/timing introspection (Scene.introspect), and a ready-to-use Model Context Protocol server (handanim-ai mcp).

Visual Showcase

30-Second Quick Example

Create a hand-drawn scene with narration, word-by-word highlighted captions, repeating background theme music, and automatic chalk drawing and eraser sound effects:

from handanim import (
    Captions, Circle, Eraser, Math, Scene, SketchAnimation, StrokeStyle, Text,
)
from handanim.stylings.color import BLACK, BLUE, RED, TEAL
from voiceanim import VoiceEngine

# 1. Synthesize word-timed narration (uses local Kokoro-82M or MockVoiceProvider)
clip = VoiceEngine.synthesize(
    "Let us sketch a circle and Euler's identity on the whiteboard.",
    provider="kokoro",
    voice="af_heart",
)

# 2. Build a 9:16 portrait or 16:9 landscape whiteboard scene
scene = Scene(width=1080, height=1920, fps=30, background_color=(0.99, 0.98, 0.95))
scene.set_viewport_to_identity()

title = Text("Whiteboard Demo", position=(540, 220), font_size=64, align="center")
circle = Circle(center=(540, 780), radius=220, stroke_style=StrokeStyle(color=BLUE, width=4))
formula = Math(r"$e^{i\pi} + 1 = 0$", position=(340, 1150), font_size=72, stroke_style=StrokeStyle(color=TEAL, width=3.5))
eraser = Eraser(objects_to_erase=[circle])

scene.add(SketchAnimation(start_time=0.0, duration=1.0), title)
scene.add(SketchAnimation(start_time=0.8, duration=1.5), circle)
scene.add(SketchAnimation(start_time=2.2, duration=1.4), formula)
scene.add(SketchAnimation(start_time=4.0, duration=0.8), eraser)

# 3. Pin word-timed captions on the camera-independent overlay layer
scene.overlay.add(Captions(clip, words_per_chunk=3, highlight=RED, color=BLACK, y=1590))

# 4. Render with narration, looping marimba theme music, and auto chalk/eraser SFX
scene.render(
    "demo.mp4",
    narration=clip,
    background_music="marimba",
    sketch_sound=True,
    eraser_sound=True,
)

API Reference