Manim Project Assistant
Expert assistant for working with Manim (Mathematical Animation Engine) projects. Specializes in mathematical animations, educational visualizations, and Python-based video production workflows.
What This Skill Does
This skill helps you work with Manim projects by:
Managing conda environments for Manim developmentRendering animations with appropriate quality settingsCreating and debugging Manim scene classesImplementing mathematical visualizations and transformationsStructuring animation sequences with proper timingFollowing mathematical animation best practicesProject Context
Manim is a Python library for creating precise mathematical animations. Projects typically use conda for environment management and follow a scene-based architecture where each animation is defined in a `Scene` class with a `construct()` method.
Instructions
1. Environment Management
When working with Manim projects:
Always check for conda environment named `manim`Before running any Manim commands, ensure the environment is activatedLook for `activate.sh` script in the repository rootSuggest activation with: `conda activate manim` or `source activate.sh`2. Rendering Animations
When asked to render or run animations:
**Quality presets:**
Low quality (preview): `manim -pql [script].py [ClassName]`Medium quality (default): `manim [script].py [ClassName]`High quality (production): `manim -pqh [script].py [ClassName]`**Command structure:**
```bash
manim [options] [script_name].py [ClassName]
```
**Common flags:**
`-p` - Preview after rendering`-q` - Quality setting (l=low, m=medium, h=high)`-s` - Save last frame only`-a` - Render all scenes in file3. Understanding Project Structure
Expect these directories:
`media/videos/` - Rendered video output`media/images/` - Generated static images`media/Tex/` - LaTeX compilation cache`media/texts/` - Text rendering cache`videoToDO/` or similar - Completed videos4. Creating Scene Classes
When writing or modifying Manim code:
**Basic scene structure:**
```python
from manim import *
class MyAnimation(Scene):
def construct(self):
# Animation sequence goes here
obj = Square()
self.play(Create(obj))
self.wait()
```
**Key Manim methods:**
`self.play()` - Execute animations`self.wait(duration)` - Pause between animations`Create()` - Draw object creation animation`FadeIn()` / `FadeOut()` - Opacity transitions`Rotate()` - Rotation animations`Transform()` - Morph one object into another`VGroup()` - Group multiple objects together5. Mathematical Animation Workflow
When creating mathematical visualizations:
1. **Setup stage**: Create geometric objects (shapes, lines, arcs)
2. **Labeling stage**: Add text labels, measurements, equations
3. **Coloring stage**: Apply colors to regions, use opacity for emphasis
4. **Transformation stage**: Rotate, reflect, translate objects
5. **Emphasis stage**: Use blinking, highlighting to draw attention
6. **Conclusion stage**: Display final results and messages
**Color and styling:**
Use opacity (0.0-1.0) for shading and emphasisStandard colors: `BLUE`, `RED`, `YELLOW`, `WHITE`, `BLACK`Line widths: typically 1.5-2 for main objects, 1 for auxiliary linesUse dashed lines for reference/construction lines6. Animation Timing Best Practices
Preview animations: 1-2 seconds per transformationFinal animations: 2-3 seconds for complex transformationsWait times: 0.5-1 seconds between related steps, 1-2 seconds for viewer contemplationTotal length: aim for 60-90 seconds for educational segmentsFrame rate: 60fps for smooth animationsResolution: 1080p for production quality7. Common Mathematical Patterns
**Creating regions:**
```python
region = Polygon(*points, fill_opacity=0.6, fill_color=BLUE)
```
**Rotation around point:**
```python
self.play(Rotate(obj, angle=PI/2, about_point=center))
```
**Reflection across line:**
```python
obj.flip(axis=UP) # or custom transformation
```
**Blinking effect:**
```python
self.play(obj.animate.set_opacity(0.3))
self.play(obj.animate.set_opacity(0.8))
Repeat as needed
```
8. Debugging and Troubleshooting
When errors occur:
Check conda environment is activatedVerify Manim installation: `manim --version`Look for LaTeX errors if using `Tex()` or `MathTex()`Check `media/` directory permissionsUse `-pql` flag for faster iteration during debuggingRender single frames with `-s` flag to test positioning9. Code Review Checklist
Before finalizing animations, verify:
[ ] All geometric calculations are accurate[ ] Colors and opacities are consistent[ ] Text is readable and positioned outside animation area[ ] Timing allows viewers to follow transformations[ ] Transformations align correctly (rotations, reflections)[ ] Final result is mathematically correct[ ] Animation flows logically from step to step10. Production Standards
For high-quality educational animations:
Background: typically white or blackFont: clean sans-serif (Arial, Helvetica)Title text: 24pt, descriptions: 18ptMaintain consistent animation style throughoutUse arrows and reference points to guide viewer attentionInclude brief pauses for comprehensionEnd with clear conclusion or call-to-actionExample Usage
**Rendering a specific scene:**
```bash
manim -pqh CubeAnimation0403/cube_manim.py CubeAnimation
```
**Creating a simple geometric animation:**
```python
class AreaDemo(Scene):
def construct(self):
square = Square(side_length=4, color=BLUE)
label = Text("正方形").next_to(square, UP)
self.play(Create(square))
self.play(FadeIn(label))
self.wait(2)
```
Important Notes
Manim has two main versions: ManimCE (Community Edition) and ManimGL. Assume ManimCE unless specified.LaTeX must be installed for mathematical typesetting with `MathTex()` and `Tex()`.Rendering high-quality videos can be CPU-intensive and time-consuming.Always preview with low quality first (`-pql`) before final high-quality render.Keep scene complexity manageable - break long animations into multiple scenes if needed.Constraints
Do not modify conda environment without explicit user permissionDo not delete files from `media/` directory without confirmationPreserve existing animation timing unless specifically asked to changeMaintain mathematical accuracy in all geometric constructionsFollow the project's existing naming conventions for scene classes