✍️ handanim Documentation¶
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¶
Pythagoras Theorem — Hand-sketched geometry with hachure fills
Algebraic Proof of (a + b)² — Step-by-step visual derivation
Flowcharts & Tables — ML pipeline & row-by-row model table
Page Turn & Paper Crumple — Multi-page sketchbook transitions with SFX
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,
)
User Guide (handanim)
Voice, Captions & Sound (voiceanim)
- voiceanim Overview
- Voice Providers (Kokoro, Qwen3-TTS, Polly, Mock)
- 1. Local Open-Weight Default:
KokoroProvider(provider="kokoro") - 2. Instruction-Controllable Local TTS:
QwenTTSProvider(provider="qwen") - 3. Cloud Neural & Generative TTS:
PollyProvider(provider="polly") - 4. Offline Deterministic CI / Testing:
MockVoiceProvider(provider="mock") - Multi-Beat Narration Stitching
- 1. Local Open-Weight Default:
- Word-Level Sync & Built-In Captions
- Background Music & Automatic Chalk / Eraser SFX
- 1. Repeating Background Theme Music
- 2. Automatic Chalk Sketch Sound During
SketchAnimation(On / Off & Volume Control) - 3. Automatic Board-Wiping Sound During
Eraser - 4. Automatic Page-Turn & Paper-Crumple Sounds (
transition_sound=True) - 5. Additional Procedural SFX (
pop,whoosh,ding,page_turn,crumple)
AI Studio & MCP (aianim)
API Reference
- handanim Package
- handanim.core Package
- handanim.primitives Package
- handanim.primitives.lines
- handanim.primitives.arrow
- handanim.primitives.polygons
- handanim.primitives.ellipse
- handanim.primitives.curves
- handanim.primitives.text
- handanim.primitives.math
- handanim.primitives.captions
- handanim.primitives.character
- handanim.primitives.flowchart
- handanim.primitives.table
- handanim.primitives.vector_svg
- handanim.primitives.raster_image
- handanim.primitives.eraser
- handanim.animations Package
- handanim.animations.sketch
- handanim.animations.fade
- handanim.animations.visibility
- handanim.animations.easing
- handanim.animations.translate
- handanim.animations.rotate
- handanim.animations.zoom
- handanim.animations.color_transition
- handanim.animations.camera
- handanim.animations.pose
- handanim.animations.transitions
- handanim.stylings & utils Package
- voiceanim Package
- aianim Package