Skip to main content

cocobrown

Compiler-Inspired Mathematical & Algorithmic Animation Engine

Zero LaTeX · Zero FFmpeg Required · Pure-Rust Timeline IR & Media Pipeline · CPU + Vello GPU · Live Hot-Reload

Version Python Rust Typst Zero-FFmpeg License

English | 简体中文

Showcase · 3-Min Benchmark vs. Manim · Quick Start · Usage Guide (USAGE.md) · Architecture (DESIGN.md) · Roadmap (ROADMAP.md)


Showcase

All four acts and the animated preview below are compiled directly from the single-file demo.py — zero LaTeX, zero FFmpeg required (showcase.gif itself is baked in 1.0s by cocobrown's built-in pure-Rust GIF encoder):

cocobrown v0.4.0 Animated Showcase

Act 1: Glowing SymPy Calculus, Gradients & Camera2D Act 2: Graph, BinaryTree, Array & Syntax-Highlighted CodeBlock
Act 1: Glowing SymPy Calculus Act 2: Graph, BinaryTree, Array & CodeBlock
Act 3: 2D Linear Algebra Shear, Vector Field & Matrix Act 4: Native Vector SVG & Animated ClipPath Spotlight
Act 3: Linear Algebra & Matrix Act 4: SVG & ClipPath Spotlight

Run the full showcase locally to generate demo.mp4 (auto-prefers system FFmpeg when available, seamlessly falling back to built-in pure-Rust H.264/MP4) or inspect it interactively:

python demo.py
# Or launch the persistent GPU live-preview window (editing demo.py hot-reloads in place)
cocobrown preview demo.py

3-Minute Benchmark: cocobrown vs. Manim

To measure real-world long-form production performance (not a toy 3-second clip), we built an apples-to-apples 180.0-second (3-minute, 5,400-frame @ 1920×1080, 30fps) complex 2D mathematical animation across 6 dense acts (80.6% continuous active motion, 19.4% teaching pauses, 580 timeline segments, peak 103 simultaneously animated entities):

  1. Act 1 (0–30s): Cubic calculus (Axes, Riemann sum, integral area, sliding tangent + live numeric readout)
  2. Act 2 (30–60s): Reactive sin(kx) wave sweep + Fourier square-wave S₁ → S₃ → S₅ → S₉ morphs + Brace
  3. Act 3 (60–90s): NumberPlane, 25-arrow vector field, shear & rotation grid/basis transformations
  4. Act 4 (90–120s): 8-node Graph shortest-path animation + 7-node BinaryTree inorder traversal
  5. Act 5 (120–150s): 6-cell sorting Array + pointer swaps, 3×3 Matrix highlights & TransformMatchingTex
  6. Act 6 (150–180s): 12-shape geometry grid, 2D camera pan/zoom choreography, hero morphs & finale equation

Measured Wall-Clock Results (1920×1080 @ 30fps, 180.0s / 5,400 frames)

Mode / Configuration Total Wall Time Effective Throughput Video Size Speedup vs. Manim
Manim CE 0.22.1 — Cold render (fresh media dir, MiKTeX + Cairo + FFmpeg) 145.47 s (2m 25s) 37.1 fps 7.24 MB 1.00× (cold baseline)
cocobrown — CPU + Built-in Pure-Rust MP4 (zero FFmpeg, cold) 56.47 s 95.6 fps 26.62 MB 2.58×
cocobrown — CPU (tiny-skia + rayon) + FFmpeg libx264 (cold) 21.40 s (build: 0.21 s) 252.4 fps 8.47 MB 6.80×
cocobrown — GPU (vello + wgpu) + FFmpeg libx264 (cold) 15.24 s (build: 0.13 s) 354.4 fps 8.12 MB 9.55×
Manim CE 0.22.1 — Incremental 1-edit (change final 2s formula, Manim cache ON) 51.86 s 104.1 fps 7.26 MB 1.00× (inc. baseline)
cocobrown — Incremental 1-edit (SHA-256 pure-Rust cache, 446/483 segs reused, 61 frames rendered) 3.00 s 1,797.3 fps 45.69 MB 17.3× (48.5× vs. Manim cold)

Hardware & Transparency Notes: Measured on Windows 11 ARM64 · Qualcomm Snapdragon X Plus X1P64100 (10-core Oryon CPU) + Qualcomm Adreno X1-85 GPU. cocobrown ran as a native --release win_arm64 extension (Python 3.13 ARM64); Manim CE 0.22.1 ran on Python 3.12 win_amd64 (Windows Prism emulation, as manimpango does not publish Windows ARM64 wheels) with MiKTeX (latex + dvisvgm) and ffmpeg. Both produced verified 180.00s H.264 .mp4 videos. Reproduce locally:

python benchmarks/run_benchmark.py --size 1920x1080 --fps 30

Full scripts & raw JSON: benchmarks/bench_scene_cocobrown.py, benchmarks/bench_scene_manim.py, benchmarks/run_benchmark.py, benchmarks/results_3min.json.


Highlights

  • Zero External Dependencies Out of the Box (v0.4.0):
    • Zero LaTeX / Zero TeX Live: Embeds typst 0.15 + compact New Computer Modern Math fonts, walking FrameItem trees and extracting skrifa outlines directly into kurbo::BezPath with full Glyph.span preservation (Write, sub-expression coloring, TransformMatchingTex).
    • Smart FFmpeg-First + Zero-FFmpeg Pure-Rust Fallback: Default encoder="auto" automatically discovers a usable system ffmpeg (checking PATH and standard WinGet/Scoop/Homebrew/Linux install paths) for peak libx264/HW encoding throughput & compact MP4s — and seamlessly falls back to built-in pure-Rust H.264/AAC MP4 (rusty_h264-encoder + muxide + rusty_aac) when ffmpeg is not installed. Animated GIF (gif), multi-format audio decoding/mixing (symphonia for WAV/MP3/OGG/FLAC/AAC), and SHA-256 incremental caching all work out of the box with zero external dependencies, while encoder="builtin" forces pure-Rust and encoder="ffmpeg" unlocks transparent VP9 .webm & 10-bit alpha ProRes 4444 .mov.
  • Pure-Data Compile-Time Timeline IR: Python scripts declare entities, layouts, and choreography during build time (~0.2s even for a 3-minute scene). After finish(), cocobrown releases the Python GIL and renders with zero per-frame Python callbacks.
  • Audio & Voiceover Timeline Synchronization: Schedule SFX/BGM via s.add_sound(...) (gain, fade-in/out, trim) or align animations automatically to narration clips via with s.voiceover("narration.wav") as dur:. Audio tracks are hashed independently from video segments — re-recording voiceover re-renders 0 video frames.
  • Rich CS, Math & Presentation Widgets:
    • Graphs & Data Structures: Graph, DiGraph, BinaryTree (deterministic spring/circular/grid/tree layouts, shortest-path & traversal animations), Array + ArrayPointer, Stack, Queue.
    • Presentation Widgets: Matrix (auto-fitted brackets, row/col/entry highlights, elementary row/col swaps), Table, and CodeBlock (pure-Python multi-language syntax highlighting + highlight_line / focus_lines).
    • Cartesian & SymPy Bridge (cocobrown[sympy]): NumberLine, Axes, NumberPlane, automatic asymptote splitting, exact analytic derivatives/Taylor series, 2D vector fields, 2×2 matrix transforms, and automatic Tracker reactivity.
  • Cinema, Assets & Compositing:
    • Raster Images & Vector SVG: s.image(...) (PNG/JPEG/RGBA deduplicated in .timeline v4) and s.svg(...) (native vector paths via usvg with Y-up flip, gradients, strokes, and Draw/Write support).
    • ClipPath Masking: entity.clip_to(mask) with parent-inherited hierarchical masks, animated mask invalidation, and exact CPU (tiny-skia::Mask) / GPU (vello::push_clip_layer) parity.
    • 2D Camera & Follow: Camera2D pan/zoom/roll, CameraFocus, CameraReset, and s.camera_follow / s.start_camera_follow tracking moving entities.
    • Gradients, Dual-Lobe HDR Bloom & Persistent GPU Live Preview: LinearGradient, RadialGradient, optional s.bloom(...), and cocobrown preview zero-readback winit + wgpu + vello window with millisecond IPC hot-reload preserving the playhead.

Architecture

Python Modular API (colors · anim · camera · entity · scene · coords · graph · structures · widgets · audio · assets · symbolic)
  │  build time (~0.2s): cursor choreography, auto-layout, lambdify & Tracker/CameraFollow baking
  ▼
Pure-Data Timeline IR (Camera2D + Bloom + AudioClips + SoA SceneArena + ResourceTable[Geom/Morph/Image] + Tracks)
  │  static validation: overlap conflict detection, parent/clip acyclicity
  ▼
Compile-Time Optimizer (RenderPlan)
  │  O(n log n) sweep-line → static-segment 1-frame reuse + static bg/fg layer cache + SHA-256 segment hashes
  ├───────────────────────────────┬───────────────────────────────┐
  ▼                               ▼                               ▼
CPU Backend (tiny-skia)     GPU Backend (vello + wgpu)     Live Preview (winit + wgpu)
rayon frame parallelism     3-slot async readback ring     zero-readback swapchain + IPC hot-reload
  └───────────────┬───────────────┘
                  ▼  (optional dual-lobe HDR Glow / Bloom + symphonia/rusty_aac audio mix)
Modular Media Subsystem (crates/cocobrown-core/src/media/)
  ├─ System FFmpeg (Auto-Preferred for MP4 when found): libx264 · NVENC/VideoToolbox/QSV/AMF · WebM Alpha · ProRes 4444 MOV
  └─ Built-in Pure-Rust (Auto-Fallback for MP4, Default for GIF/Audio/PNG): rusty_h264 + muxide + rusty_aac · gif · PNG Sequence

Installation

From PyPI

pip install cocobrown
# Optional: enable the SymPy symbolic math bridge
pip install "cocobrown[sympy]"

Requirements

  • Python ≥ 3.9 (abi3 stable ABI wheel)
  • Zero external binaries required for default MP4, GIF, AAC audio muxing, PNG sequences, or GPU live preview
  • FFmpeg (optional) on PATH only if you want libx264/hardware encoders, transparent .webm, or ProRes 4444 .mov
  • Rust stable toolchain + maturin when building from source

Build from Source

# 1. Create a virtual environment and install build/test tools
uv venv
uv pip install maturin pytest

# 2. Build and install the Rust core + Python extension (--release for full throughput)
maturin develop --release

# 3. Optional: enable the SymPy symbolic math bridge
uv pip install sympy

Verify installation:

cocobrown --version
python -c "import cocobrown as cb; print(cb.__version__, 'gpu:', cb.gpu_available())"

Quick Start

Create a glowing, camera-directed SymPy calculus animation with native Typst math, gradient typography, voiceover sync, and zero-FFmpeg MP4 export in ~25 lines:

import sympy as sp
import cocobrown as cb

x = sp.Symbol("x")
f = sp.Rational(1, 4) * x**3 - x

s = cb.Scene(size=(1280, 720), fps=60.0, background="#0B0F17")
s.bloom(intensity=0.45, threshold=0.50, radius=10)

ax = s.axes(x_range=(-3, 3, 1), y_range=(-2, 2, 1), x_label="$x$", y_label="$y$")
curve = ax.plot(f, color=cb.BLUE, width=0.055)
formula = (
    s.tex(f"$ f(x) = {cb.sympy_to_typst(f, wrap=False)} $", size=0.75)
    .fill(cb.LinearGradient([cb.BLUE, cb.YELLOW]))
    .to_corner(cb.UL, buff=0.45)
)

x0 = s.tracker(-2.0)
tangent = ax.tangent_line(f, x0, color=cb.YELLOW)  # exact analytic derivative + reactive baking

s.play(cb.par([cb.FadeIn(ax), cb.Write(formula), cb.Draw(curve)]), dur=1.0)
s.play(cb.ShowPassingFlash(curve, color=cb.YELLOW), dur=0.7)
s.play(cb.FadeIn(tangent), dur=0.35)
s.play(cb.par([x0.to(2.0), cb.CameraZoomTo(1.15)]), dur=2.0, ease=cb.Ease.IN_OUT)
s.play(cb.CameraReset(), dur=0.6)
s.wait(0.6)

# Default encoder="auto" uses system FFmpeg when available, else built-in pure-Rust MP4!
stats = s.bake("hello_cocobrown.mp4", quality="fast")
print(stats)

CLI Tools

# 1. Launch persistent GPU preview window with live hot-reload (preserves playhead)
cocobrown preview demo.py

# 2. Bake MP4 / GIF (auto-prefers system FFmpeg when installed, pure-Rust fallback otherwise) or pick encoder explicitly
cocobrown bake demo.py -o demo.mp4 --quality fast --cache-dir .cocobrown_cache
cocobrown bake demo.py -o demo_x264.mp4 --encoder ffmpeg --codec auto --backend auto
cocobrown bake demo.py -o demo.gif --encoder builtin
cocobrown bake demo.py -o overlay.mov --encoder ffmpeg
cocobrown bake demo.py -o frames_out --format png

# 3. Run pre-render static IR diagnostics (static reuse ratio, peak complexity, bandwidth)
cocobrown diagnose demo.py

Preview controls: Space Play/Pause · ← / → Step 1 frame · Home / End Jump to start/end · R Restart · Click/Drag scrub bar for 60fps seeking · Q / Esc Quit.


Documentation

  • README.zh-CN.md — 简体中文版项目说明。
  • USAGE.md | USAGE.zh-CN.md — Complete v0.4.0 API & feature guide (English / 简体中文).
  • DESIGN.md — Architecture whitepaper (Timeline IR, BlendMode, static layer caching, GPU async readback ring, and engineering trade-offs).
  • ROADMAP.md — Milestone progression (v0.0.1 → v0.4.0 and upcoming v0.5.0 optional 3D).
  • third_party/filament/README.md — Prebuilt & custom Google Filament SDK setup (including the fast Ninja trimmed static build script build-ninja.bat for Windows ARM64 / x64).

Upcoming Optional 3D (v0.5.0) & Acknowledgements

The upcoming optional 3D extension (cocobrown-3d, powered by Google Filament) keeps the core 2D wheel lightweight while enabling PBR 3D mathematical surfaces, vector fields, and 2D Typst HUD compositing.

For Windows ARM64 source builds (not yet merged into upstream Filament), copy third_party/filament/scripts/build-ninja.bat into the community-patched Windows ARM64 fork nithin-aashik-mcw/filament and run build\windows\build-ninja.bat release arm64 md core (see third_party/filament/README.md for full steps and the Qualcomm Adreno VK_LOADER_DRIVERS_DISABLE=*dzn* note).

Acknowledgements: Many thanks to nithin-aashik-mcw for providing and maintaining the Windows ARM64 port of Google Filament!


License

Licensed under the Apache License, Version 2.0 — Copyright 2026 choroship357.

Metadata

Release files for cocobrown 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cocobrown 0.4.0
File Size Uploaded Provenance Actions
cocobrown-0.4.0.tar.gz 271.0 kB Without provenance Details for cocobrown-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cocobrown 0.4.0
File Actions
cocobrown-0.4.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for cocobrown-0.4.0-cp39-abi3-win_arm64.whl
cocobrown-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for cocobrown-0.4.0-cp39-abi3-win_amd64.whl
cocobrown-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for cocobrown-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
cocobrown-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for cocobrown-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
cocobrown-0.4.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for cocobrown-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
cocobrown-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for cocobrown-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 150.6 MB

Release files / cocobrown-0.4.0.tar.gz

Download URL cocobrown-0.4.0.tar.gz
Size 271.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1f2ea2a1a723a46e50e4b3adb8d0fba88ed9704b8745bcd4bd78738702684b5c
BLAKE2b-256 checksum
How to use checksums
11b4c323a0f1a972550ff46ed942ece7114d8f9dee6bc9222a8f44b88898ed14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-win_arm64.whl

Download URL cocobrown-0.4.0-cp39-abi3-win_arm64.whl
Size 24.4 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
2f6342b98253a166835c682b3ff63fc01f4dca34014445de1febeebcde9ce53f
BLAKE2b-256 checksum
How to use checksums
33516f64d23d6790115aa378dcad8411c907731e6188da809835e74bd13108ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-win_amd64.whl

Download URL cocobrown-0.4.0-cp39-abi3-win_amd64.whl
Size 25.7 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e4b70c3f8344aa3763b3519220808d8807856e5d1885441eac7ebe1af00e414f
BLAKE2b-256 checksum
How to use checksums
0ee48ff6a0c6c77f77d20ffab9d2e960a8276bbde054dc62b6ebc3e626d83144
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL cocobrown-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 26.5 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b17e1aaedefa8c15351b38c69d6e83e701f11a8908d187ade3a9de96d8caa883
BLAKE2b-256 checksum
How to use checksums
0e43f9ff2f1eb83ff958918c2f57ea57f6d690bc4999d08fa3409117d832c220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL cocobrown-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 25.4 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a54fdd2f241b003c442bab4d47a5b95d21cf89006e37b8cd0bf70cc6f1a2c56a
BLAKE2b-256 checksum
How to use checksums
9dd063f7acf830fefce6dfc12d78295e55c64a215dfe10b1b2be1b973ec0f0d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL cocobrown-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Size 23.8 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8f677f3ef3b124f22f0fca83a5b0fb8d59dd134b5c8b98684eb7073a467bd439
BLAKE2b-256 checksum
How to use checksums
b830f081cb5b990284858482a6516e81c65807356f888c166bd1a9d2b791c008
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cocobrown-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL cocobrown-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 24.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6772fb230d6033ba0c7b7834ac2f5fa79a6da6c2c5187004d2ebdbc66c2f72c1
BLAKE2b-256 checksum
How to use checksums
715553a49e735a7b6c549a080c032325cd92e00a9beeffbb05fa9d63c7e25f19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for cocobrown 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

7 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page