From e8f6854cabeb2d71e22b9a2b28dcdfd20dc1b787 Mon Sep 17 00:00:00 2001 From: Leo Torres Date: Tue, 7 Apr 2026 11:36:13 +0200 Subject: [PATCH] docs: expand Manim CE reference docs with additional API coverage Add geometry mobjects, movement/creation animations, and LaTeX environments to the skill's reference docs. All verified against Manim CE v0.20.1. Co-Authored-By: Claude Opus 4.6 (1M context) --- skills/creative/manim-video/SKILL.md | 2 +- .../manim-video/references/animations.md | 25 +++++++ .../manim-video/references/equations.md | 51 ++++++++++++++ .../manim-video/references/mobjects.md | 69 +++++++++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-) diff --git a/skills/creative/manim-video/SKILL.md b/skills/creative/manim-video/SKILL.md index 5c82526fc..35c09bc7b 100644 --- a/skills/creative/manim-video/SKILL.md +++ b/skills/creative/manim-video/SKILL.md @@ -24,7 +24,7 @@ This is educational cinema. Every frame teaches. Every animation reveals structu ## Prerequisites -Run `scripts/setup.sh` to verify all dependencies. Requires: Python 3.10+, Manim Community Edition (`pip install manim`), LaTeX (`texlive-full` on Linux, `mactex` on macOS), and ffmpeg. +Run `scripts/setup.sh` to verify all dependencies. Requires: Python 3.10+, Manim Community Edition v0.20+ (`pip install manim`), LaTeX (`texlive-full` on Linux, `mactex` on macOS), and ffmpeg. Reference docs tested against Manim CE v0.20.1. ## Modes diff --git a/skills/creative/manim-video/references/animations.md b/skills/creative/manim-video/references/animations.md index 84b2cb016..1bbbc0341 100644 --- a/skills/creative/manim-video/references/animations.md +++ b/skills/creative/manim-video/references/animations.md @@ -50,6 +50,31 @@ self.play(circle.animate.set_color(RED)) self.play(circle.animate.shift(RIGHT * 2).scale(0.5)) # chain multiple ``` +## Additional Creation Animations + +```python +self.play(GrowFromPoint(circle, LEFT * 3)) # scale 0 -> 1 from a specific point +self.play(GrowFromEdge(rect, DOWN)) # grow from one edge +self.play(SpinInFromNothing(square)) # scale up while rotating (default PI/2) +self.play(GrowArrow(arrow)) # grows arrow from start to tip +``` + +## Movement Animations + +```python +# Move a mobject along an arbitrary path +path = Arc(radius=2, angle=PI) +self.play(MoveAlongPath(dot, path), run_time=2) + +# Rotate (as a Transform, not .animate — supports about_point) +self.play(Rotate(square, angle=PI / 2, about_point=ORIGIN), run_time=1.5) + +# Rotating (continuous rotation, updater-style — good for spinning objects) +self.play(Rotating(gear, angle=TAU, run_time=4, rate_func=linear)) +``` + +`MoveAlongPath` takes any `VMobject` as the path — use `Arc`, `CubicBezier`, `Line`, or a custom `VMobject`. Position is computed via `path.point_from_proportion()`. + ## Emphasis Animations ```python diff --git a/skills/creative/manim-video/references/equations.md b/skills/creative/manim-video/references/equations.md index 78d63f2b9..0a08a5ddd 100644 --- a/skills/creative/manim-video/references/equations.md +++ b/skills/creative/manim-video/references/equations.md @@ -65,6 +65,57 @@ MathTex(r"\vec{v}") # vector MathTex(r"\lim_{x \to \infty} f(x)") # limit ``` +## Matrices + +`MathTex` supports standard LaTeX matrix environments via `amsmath` (loaded by default): + +```python +# Bracketed matrix +MathTex(r"\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}") + +# Parenthesized matrix +MathTex(r"\begin{pmatrix} a & b \\ c & d \end{pmatrix}") + +# Determinant (vertical bars) +MathTex(r"\begin{vmatrix} a & b \\ c & d \end{vmatrix}") + +# Plain (no delimiters) +MathTex(r"\begin{matrix} x_1 \\ x_2 \\ x_3 \end{matrix}") +``` + +For matrices you need to animate element-by-element or color individual entries, use the `IntegerMatrix`, `DecimalMatrix`, or `MobjectMatrix` mobjects instead — see `mobjects.md`. + +## Cases and Piecewise Functions + +```python +MathTex(r""" + f(x) = \begin{cases} + x^2 & \text{if } x \geq 0 \\ + -x^2 & \text{if } x < 0 + \end{cases} +""") +``` + +## Aligned Environments + +For multi-line derivations with alignment, use `aligned` inside `MathTex`: + +```python +MathTex(r""" + \begin{aligned} + \nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_0} \\ + \nabla \cdot \mathbf{B} &= 0 \\ + \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\ + \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} + \end{aligned} +""") +``` + +Note: `MathTex` wraps content in `align*` by default. Override with `tex_environment` if needed: +```python +MathTex(r"...", tex_environment="gather*") +``` + ## Derivation Pattern ```python diff --git a/skills/creative/manim-video/references/mobjects.md b/skills/creative/manim-video/references/mobjects.md index d9c7b50b2..ec68b3750 100644 --- a/skills/creative/manim-video/references/mobjects.md +++ b/skills/creative/manim-video/references/mobjects.md @@ -35,6 +35,52 @@ rrect = RoundedRectangle(corner_radius=0.3, width=4, height=2) brace = Brace(rect, DOWN, color=YELLOW) ``` +## Polygons and Arcs + +```python +# Arbitrary polygon from vertices +poly = Polygon(LEFT, UP * 2, RIGHT, color=GREEN, fill_opacity=0.3) + +# Regular n-sided polygon +hexagon = RegularPolygon(n=6, color=TEAL, fill_opacity=0.4) + +# Triangle (shorthand for RegularPolygon(n=3)) +tri = Triangle(color=YELLOW, fill_opacity=0.5) + +# Arc (portion of a circle) +arc = Arc(radius=2, start_angle=0, angle=PI / 2, color=BLUE) + +# Arc between two points +arc_between = ArcBetweenPoints(LEFT * 2, RIGHT * 2, angle=TAU / 4, color=RED) + +# Curved arrow (arc with tip) +curved_arrow = CurvedArrow(LEFT * 2, RIGHT * 2, color=ORANGE) +``` + +## Sectors and Annuli + +```python +# Sector (pie slice) +sector = Sector(outer_radius=2, start_angle=0, angle=PI / 3, fill_opacity=0.7, color=BLUE) + +# Annulus (ring) +ring = Annulus(inner_radius=1, outer_radius=2, fill_opacity=0.5, color=GREEN) + +# Annular sector (partial ring) +partial_ring = AnnularSector( + inner_radius=1, outer_radius=2, + angle=PI / 2, start_angle=0, + fill_opacity=0.7, color=TEAL +) + +# Cutout (punch holes in a shape) +background = Square(side_length=4, fill_opacity=1, color=BLUE) +hole = Circle(radius=0.5) +cutout = Cutout(background, hole, fill_opacity=1, color=BLUE) +``` + +Use cases: pie charts, ring progress indicators, Venn diagrams with arcs, geometric proofs. + ## Positioning ```python @@ -99,6 +145,29 @@ class NetworkNode(Group): self.add(self.circle, self.label) ``` +## Matrix Mobjects + +Display matrices as grids of numbers or mobjects: + +```python +# Integer matrix +m = IntegerMatrix([[1, 2], [3, 4]]) + +# Decimal matrix (control decimal places) +m = DecimalMatrix([[1.5, 2.7], [3.1, 4.9]], element_to_mobject_config={"num_decimal_places": 2}) + +# Mobject matrix (any mobject in each cell) +m = MobjectMatrix([ + [MathTex(r"\pi"), MathTex(r"e")], + [MathTex(r"\phi"), MathTex(r"\tau")] +]) + +# Bracket types: "(" "[" "|" or "\\{" +m = IntegerMatrix([[1, 0], [0, 1]], left_bracket="[", right_bracket="]") +``` + +Use cases: linear algebra, transformation matrices, system-of-equations coefficient display. + ## Constants Directions: `UP, DOWN, LEFT, RIGHT, ORIGIN, UL, UR, DL, DR`