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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user