A Manim-based educational animation system that visualizes Python code execution step-by-step, designed to teach programming fundamentals through clear visual demonstrations.
- Step-by-step code execution with visual highlighting
- Curved arrow animations showing data flow
- Variable memory visualization with real-time updates
- Calculation overlays demonstrating expression evaluation
- VS Code Dark+ syntax highlighting
- Terminal-style output display
- Create and activate a virtual environment:
uv venv
# On Windows: .venv\Scripts\activate
# On macOS/Linux: source .venv/bin/activate
- Install dependencies:
uv pip install manim
Run the basic assignment animation:
./.venv/Scripts/python.exe -m manim -pql main.py BasicAssignment
- BasicAssignment - Demonstrates
x = 1
,x = x + 1
,print(x)
- MultipleVariables - Shows multiple variable operations
- StringOperations - String concatenation example
-pql
- Low quality (480p, fast preview)-pqm
- Medium quality (720p)-pqh
- High quality (1080p)-pqk
- 4K quality
# Preview with low quality
./.venv/Scripts/python.exe -m manim -pql main.py BasicAssignment
# Render high quality video
./.venv/Scripts/python.exe -m manim -pqh main.py BasicAssignment
# Test multiple animations
./.venv/Scripts/python.exe -m manim -pql main.py MultipleVariables
The system uses colored arrows to show data flow:
- Red arrows: Value assignment (e.g.,
1
βx
) - Yellow arrows: Variable substitution in expressions
- Cyan arrows: Output to terminal
For the code x = x + 1
:
- Highlight line: Shows current executing line
- Fetch value: Arrow from memory box to variable in expression
- Substitute: Shows
x
being replaced with1
- Calculate: Displays
1 + 1 = 2
- Assign: Arrow showing
2
going to variablex
- Update memory: Variable box updates to show new value
Uses VS Code Dark+ theme colors:
- Keywords (if, for, def): Blue
#569CD6
- Variables: Light blue
#9CDCFE
- Numbers: Green
#B5CEA8
- Strings: Orange
#CE9178
- Functions: Yellow
#DCDCAA
βββ main.py # Entry point with multiple scenes
βββ src/
β βββ python_animation.py # Main animation scene class
β βββ components/ # UI component modules
β βββ utils/ # Helper utilities
βββ media/ # Generated video files
βββ .venv/ # Virtual environment
- Add a new scene class in
main.py
:
class MyCustomAnimation(PythonAnimation):
def construct(self):
self.code_lines = [
"my_var = 42",
"result = my_var * 2",
"print(result)"
]
super().construct()
- Run the new animation:
./.venv/Scripts/python.exe -m manim -pql main.py MyCustomAnimation
Modify timing in python_animation.py
:
# Animation timing (in seconds)
self.wait(1.5) # Pause duration
run_time=0.8 # Animation speed
Colors are defined in the colors
dictionary in PythonAnimation
:
self.colors = {
'arrow_assignment': "#FF6B6B", # Red
'arrow_output': "#4ECDC4", # Cyan
'calculation': "#FFD93D" # Yellow
}
This system is designed for:
- Programming instructors teaching Python basics
- Students learning variable assignment and expressions
- Code visualization in educational videos
- Step-by-step debugging demonstrations
- Start with simple 3-line examples
- Use meaningful variable names
- Demonstrate one concept per animation
- Include print statements to show results
- Module not found error: Ensure virtual environment is activated
- FFmpeg warnings: Install FFmpeg for video processing (optional)
- Slow rendering: Use
-pql
for fast previews during development
- Use low quality (
-pql
) for development - Render high quality only for final output
- Keep animations under 30 seconds for optimal performance
- Follow the existing code structure
- Add new scenes to
main.py
- Test with low quality before committing
- Update documentation for new features
Educational use - see project documentation for details.