Skip to main content

A Python library to create whiteboard-style, hand-drawn animations for educational videos, tutorials or data storytelling.

Project description

✍️ handanim

Build and Deploy Docs

A Python library to create whiteboard-style, hand-drawn animations for educational videos, tutorials or data storytelling.

handanim lets you programmatically animate hand-drawn diagrams, geometric shapes, handwritten text, and visual explanations — ideal for online teaching, explainer videos, and mathematical illustrations.

⭐️ If you like this project, please consider starring it on GitHub! Your support helps the project grow.

✨ Features

  • Draw and animate shapes (lines, ellipses, polygons) with a hand-drawn feel
  • Fill objects with sketch-style strokes (hatching, scribbles)
  • Animate handwritten text using custom fonts
  • Export vector images (SVG) or videos (MP4).
  • Intuitive Python API for creating scenes and timelines

📷 Example Output

Example 1: Pythagoras Theorem

(Example animation of a Pythagoras Theorem — see examples/pythagoras.py)

Example 2: Square formula

(Example animation of proof of a plus b whole square — see examples/a_plus_b_square.py)

🚀 Quickstart

📦 Installation using Poetry

The easiest way to install all the dependencies is to use Poetry.

# Install dependencies (requires Python 3.11+)
poetry install

# Run example animation
poetry run python examples/pythagoras.py

✏️ Basic Usage

from handanim.core import Scene
from handanim.animations import SketchAnimation
from handanim.primitives import NGon

scene = Scene(width = 800, height = 608)
triangle = NGon(
    center = (400, 304),
    radius = 100,
    n = 3
)
scene.add(SketchAnimation(start_time = 0, end_time = 5), drawable = triangle)
scene.render("triangle_anim.mp4", fps = 30)

📦 Installation using pip

If you prefer using pip instead of Poetry, you can install the main dependencies directly from the requirements.txt file. This method works well for lightweight setups or deployment environments.

# Create and activate a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install core dependencies
pip install -r requirements.txt

# (Optional) Install development dependencies
pip install -r dev-requirements.txt

# Run example animation
python examples/pythagoras.py

Make sure you're using Python 3.11+ (as specified in the project).

📦 Installation using conda

If you prefer conda for environment management:

# Create a new environment
conda create -n handanim python=3.11
conda activate handanim

# Install system dependencies via conda-forge
conda install -c conda-forge cairo pycairo ffmpeg

# Install handanim and remaining Python dependencies
pip install -r requirements.txt

# Run example animation
python examples/pythagoras.py

Note: The requirements.txt may need updating for your platform. If you encounter issues, the Poetry-based installation is the most tested path.

Installing Cairo

Your system must have the Cairo graphics library installed for pycairo or cairocffi to work correctly. This is a native C library and needs to be installed separately depending on your OS.

✅ On Ubuntu/Debian

sudo apt update
sudo apt install libcairo2 libcairo2-dev

✅ On macOS (using Homebrew)

brew install cairo

✅ On Windows

Use the precompiled binaries:

  1. Download the GTK 3 Runtime (which includes Cairo).
  2. Install it and add its bin/ folder to your system PATH.
  3. Then install Python packages as usual:
pip install -r requirements.txt

Or use the cairocffi + pycairo + pip combo with wheels from Gohlke's unofficial site if needed.

🎬 Installing FFmpeg (Required for Video Rendering)

moviepy uses FFmpeg to write video files (e.g., .mp4). You must have FFmpeg installed and accessible in your system PATH.

✅ On Ubuntu/Debian

sudo apt update
sudo apt install ffmpeg

✅ On macOS (using Homebrew)

brew install ffmpeg

✅ On Windows

  1. Download FFmpeg from the official site or a reliable Windows build like gyan.dev.
  2. Extract the archive, and add the bin/ folder to your system PATH.
  3. Verify installation:
ffmpeg -version

📄 License

This project is licensed under the MIT License.

🤝 Contributing

We welcome contributions!

You can help by:

  • Adding new animation primitives (e.g., Bezier curves, arrows)
  • Improving rendering quality and styles, caching and optimization.
  • Writing example scripts or tutorials.
  • Reporting bugs and suggesting features

Please see CONTRIBUTING.md (coming soon) for guidelines.

❤️ Inspiration

Inspired by:

⭐️ Support handanim!

If you find this project useful, please give it a star on GitHub.

It motivates me to keep improving it and helps others discover it!

✨ Made with love by Subhrajyoty Roy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

handanim-0.1.0.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

handanim-0.1.0-py3-none-any.whl (81.4 kB view details)

Uploaded Python 3

File details

Details for the file handanim-0.1.0.tar.gz.

File metadata

  • Download URL: handanim-0.1.0.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.9 Darwin/25.5.0

File hashes

Hashes for handanim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2c5ed710bb2611dec5e72ede0c8299064a3f4d9a1732793657f6f4d16394b77b
MD5 01e8e8aa0e28e784a57f1fe961f3c0fe
BLAKE2b-256 a8e833b7e96908b751139cf113d66d8d307b0dd09fd0076b953dc40e53e0b89f

See more details on using hashes here.

File details

Details for the file handanim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: handanim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 81.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.9 Darwin/25.5.0

File hashes

Hashes for handanim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33746bc2c5ea33c0f2c087ccc9268f1e60f685cbaa6b7ec1b74435e3ca33413e
MD5 838c605d8a15c1fc4104fe1c2d235dec
BLAKE2b-256 37d83712af1e789b8ad120fafea355c59338e4656944dcbc0f6bbdd5961758f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page