Communitygithub.com

manim-math

Video and animation skill. Mathematical and algorithmic animation with Manim Community Edition — scene structure, transforms, axes, camera work, LaTeX, render flags, and compositing into the main studio.

¿Qué es manim-math?

manim-math is a Claude Code agent skill that video and animation skill. Mathematical and algorithmic animation with Manim Community Edition — scene structure, transforms, axes, camera work, LaTeX, render flags, and compositing into the main studio.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/adityaakunjir/Bakko/tree/HEAD/skills/manim-math

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

Manim (Mathematical Animation)

Manim is the right tool when the explanation is the mathematics: a proof, an algorithm stepping through state, a function transforming, a geometric construction. Its LaTeX typesetting is the reason to use it; its layout system is not.


1. Setup

pip install manim
manim --version

Requirements:

  • FFmpeg on PATH (already installed in this workspace).
  • LaTeX (TeX Live / MiKTeX) only if you use MathTex/Tex. Without it, Text and MarkupText still work but you lose real math typesetting.
  • On Windows, MiKTeX's on-the-fly package install must be enabled or the first MathTex compile stalls.

Pin the version in a project (manim==0.19.*) — Manim's API has shifted across minor releases.


2. Scene skeleton

from manim import *

class Pipeline(Scene):
    def construct(self):
        self.camera.background_color = "#0a0b10"
        title = Text("Vector search", font="Inter", weight=BOLD, font_size=56)
        title.to_edge(UP, buff=0.6)

        q = MathTex(r"q \in \mathbb{R}^{768}").scale(1.1)
        dots = VGroup(*[Dot(radius=0.06) for _ in range(6)]).arrange(RIGHT, buff=0.5)

        self.play(Write(title), run_time=1.0)
        self.play(FadeIn(q, shift=UP * 0.3), run_time=0.8)
        self.play(LaggedStart(*[GrowFromCenter(d) for d in dots], lag_ratio=0.12))
        self.wait(1.2)
  • construct is the whole film; there is no timeline object.
  • self.play(...) advances time; self.wait(seconds) holds.
  • Every animation has run_time; default is 1s. Be explicit.
  • LaggedStart/AnimationGroup/Succession replace hand-tuned offsets.

3. The core vocabulary

NeedMobject / animation
ShapesCircle, Square, RoundedRectangle, Polygon, Line, Arrow, Dot
TextText (no LaTeX), MathTex (LaTeX), Tex, MarkupText
GroupingVGroup, Group, .arrange(RIGHT, buff=0.4), .next_to(x, UP)
EnterCreate, Write, FadeIn, GrowFromCenter, DrawBorderThenFill
ExitFadeOut, Uncreate, ShrinkToCenter
ChangeTransform, ReplacementTransform, TransformMatchingTex, ApplyMethod
EmphasisIndicate, Circumscribe, Flash, Wiggle
AnnotationBrace, SurroundingRectangle, Arrow, DashedLine

ReplacementTransform when the target is a new object that should keep existing; Transform when mutating in place. TransformMatchingTex is the only clean way to morph equations term by term.


4. Axes, plots, numbers

ax = Axes(
    x_range=[0, 6, 1], y_range=[0, 8, 2],
    x_length=9, y_length=5,
    axis_config={"color": GREY_B, "stroke_width": 2},
    tips=True,
).to_edge(DOWN, buff=0.9)
labels = ax.get_axis_labels(x_label="t", y_label="cost")

graph = ax.plot(lambda x: 0.5 * x ** 2, color="#00f0ff", stroke_width=5)
dot = Dot(ax.c2p(0, 0), color="#fcee0a")
tracker = ValueTracker(0)
dot.add_updater(lambda m: m.move_to(ax.c2p(tracker.get_value(),
                                           0.5 * tracker.get_value() ** 2)))

self.play(Create(ax), FadeIn(labels))
self.play(Create(graph), FadeIn(dot), run_time=2)
self.play(tracker.animate.set_value(4), run_time=3, rate_func=smooth)
  • ax.c2p(x, y) converts data coordinates to scene coordinates. Always use it.
  • ValueTracker + add_updater is how you animate a dependent value.
  • always_redraw(lambda: ...) for labels that must follow a moving object.
  • Ternary plots, matrices, and tables exist, but they are easier to build as SVG in the main studio unless the math is the point.

5. Camera

class Zoom( MovingCameraScene ):
    def construct(self):
        circle = Circle(radius=1, color="#9d4edd")
        self.play(Create(circle))
        self.camera.frame.save_state()
        self.play(self.camera.frame.animate.set(width=4).move_to(circle))
        self.wait(1)
        self.play(Restore(self.camera.frame))
  • MovingCameraScene for 2D zoom/pan; animate self.camera.frame.
  • ThreeDScene + set_camera_orientation(phi=..., theta=...) for 3D; begin_ambient_camera_rotation(rate=0.1) for drift.
  • Keep zooms ≥1.5s and ease with smooth; a snap zoom reads as a mistake.
  • Camera moves and object transforms compete for attention — do one at a time.

6. Rendering

manim -qh scene.py Pipeline          # 1080p60
manim -qm scene.py Pipeline          # 720p30 (fast review)
manim -ql scene.py Pipeline          # 480p15 (blocking)
manim -qh -p scene.py Pipeline       # render then play
manim -qh -s scene.py Pipeline       # last frame only (thumbnail)
manim -qh -t --format webm scene.py Pipeline   # transparent alpha

Output lands in media/videos/<file>/<quality>/<Scene>.mp4. Use -o name to rename, --disable_caching when iterating on a scene that caches badly.

Render discipline:

  • Blocking at -ql, review at -qm, final at -qh only.
  • One scene per beat, so a re-render is cheap.
  • Keep media/ out of version control except the final MP4s.

7. Compositing into the studio

Manim's strength is the insert, not the whole film. Two patterns:

  1. Full-frame insert — render 1920×1080 MP4, place it in a Remotion Series.Sequence with <OffthreadVideo>, then add titles/captions from the studio on top.
  2. Alpha overlay — render transparent WebM (-t --format webm), composite over the studio's background. Verify alpha in VLC/Chrome before trusting it; yuva420p support varies by player.

Match Manim's background to the studio canvas (#0a0b10) and its accent colors to the palette in explainer-graphics, or the cut will look like two videos.

Audio, captions, and sound design come from the studio pipeline — Manim has no narration or ducking system worth using here.


8. Design rules

  • Manim defaults are academic: black background, thin white strokes, LaTeX blue. Restyle: thicker strokes (stroke_width=4–6), accent color for the active element, muted grey for context.
  • One equation per frame. Build it term by term with TransformMatchingTex.
  • Annotate in the viewer's language; put the formal notation underneath.
  • Minimum on-screen text height ~26px at 1080p (Manim's default font_size=48 is ~0.48 units; check it in the still).
  • Hold the final state ≥1s. Manim scenes end too fast by default.
  • Avoid self.play chains under 0.4s each; they read as flicker.

9. QC

  • -ql pass reviewed for timing before any -qh render.
  • Every MathTex compiled (no missing-package fallback boxes).
  • Text legible at 50% scale; stroke colors survive H.264.
  • Final frame held; no abrupt cut to black.
  • Insert duration matches the Remotion sequence exactly.
  • Alpha overlay verified in a player, not just assumed.

Skills relacionados