Animation engine for explanatory math videos with programmatic mathematical visualization capabilities
npx @tessl/cli install tessl/pypi-manimgl@1.7.00
# ManimGL
1
2
ManimGL is a sophisticated Python animation engine specifically designed for creating precise programmatic animations for explanatory mathematics videos. Originally developed by 3Blue1Brown, it provides a comprehensive framework for mathematical visualization with support for LaTeX rendering, OpenGL-based graphics, and real-time interactive animation development.
3
4
## Package Information
5
6
- **Package Name**: manimgl
7
- **Language**: Python
8
- **Installation**: `pip install manimgl`
9
- **System Requirements**: FFmpeg, OpenGL, LaTeX (optional), Pango (Linux)
10
11
## Core Imports
12
13
```python
14
import manimgl
15
```
16
17
Common imports for most animations:
18
19
```python
20
from manimgl import *
21
```
22
23
Import specific components:
24
25
```python
26
from manimgl import Scene, Mobject, Animation
27
from manimgl import Circle, Square, Text, Tex
28
from manimgl import ShowCreation, FadeIn, Transform
29
```
30
31
## Basic Usage
32
33
```python
34
from manimgl import *
35
36
class BasicExample(Scene):
37
def construct(self):
38
# Create mathematical objects
39
circle = Circle(radius=1, color=BLUE)
40
square = Square(side_length=2, color=RED)
41
text = Text("Hello ManimGL", font_size=48)
42
43
# Position objects
44
circle.shift(LEFT * 2)
45
square.shift(RIGHT * 2)
46
text.shift(UP * 2)
47
48
# Animate objects
49
self.play(ShowCreation(circle))
50
self.play(ShowCreation(square))
51
self.play(FadeIn(text))
52
self.play(Transform(circle, square))
53
self.wait()
54
55
# Run with: manimgl example.py BasicExample
56
```
57
58
## Architecture
59
60
ManimGL uses a hierarchical architecture built around mathematical objects (Mobjects) and their animations:
61
62
- **Scene**: Top-level container managing the animation timeline and camera
63
- **Mobject**: Base class for all mathematical objects that can be displayed and animated
64
- **Animation**: Base class for all animations that transform mobjects over time
65
- **Camera**: Manages the viewport, coordinate system, and rendering
66
- **Window**: Handles display, user interaction, and real-time preview
67
68
This design enables complex mathematical animations with precise control over timing, positioning, and visual effects, making it ideal for educational content creation and mathematical demonstrations.
69
70
## Capabilities
71
72
### Core Scene Framework
73
74
Essential scene management for creating animations, including base scene classes, interactive development, 3D scene support, and animation timeline control.
75
76
```python { .api }
77
class Scene:
78
def construct(self): ...
79
def play(*animations, **kwargs): ...
80
def add(*mobjects): ...
81
def remove(*mobjects): ...
82
def wait(duration=None): ...
83
84
class InteractiveScene(Scene): ...
85
class ThreeDScene(Scene): ...
86
```
87
88
[Scene Framework](./scene-framework.md)
89
90
### Mathematical Objects
91
92
Comprehensive collection of mathematical objects including basic geometry, 3D shapes, coordinate systems, text rendering, and complex mathematical constructs.
93
94
```python { .api }
95
class Mobject:
96
def shift(vector): ...
97
def scale(factor): ...
98
def rotate(angle): ...
99
100
class Circle(VMobject): ...
101
class Square(VMobject): ...
102
class Line(VMobject): ...
103
class Text(VMobject): ...
104
class Tex(VMobject): ...
105
```
106
107
[Mathematical Objects](./mathematical-objects.md)
108
109
### Animation System
110
111
Extensive animation framework with over 80 animation classes covering transforms, creation effects, movement, indication, fading, and specialized mathematical animations.
112
113
```python { .api }
114
class Animation:
115
def __init__(mobject, **kwargs): ...
116
117
class Transform(Animation): ...
118
class ShowCreation(Animation): ...
119
class FadeIn(Animation): ...
120
class Rotate(Animation): ...
121
class Indicate(Animation): ...
122
```
123
124
[Animation System](./animation-system.md)
125
126
### Text and LaTeX Rendering
127
128
Advanced text rendering capabilities including plain text, LaTeX mathematical expressions, code highlighting, and markup support with precise typographical control.
129
130
```python { .api }
131
class Text(VMobject):
132
def __init__(text, **kwargs): ...
133
134
class Tex(VMobject):
135
def __init__(*tex_strings, **kwargs): ...
136
137
class TexText(VMobject): ...
138
class Code(VMobject): ...
139
class BulletedList(VMobject): ...
140
```
141
142
[Text and LaTeX](./text-and-latex.md)
143
144
### Coordinate Systems and Graphs
145
146
Mathematical coordinate systems, number lines, function plotting, and graph visualization with support for 2D and 3D coordinate systems.
147
148
```python { .api }
149
class Axes(VMobject):
150
def __init__(x_range, y_range, **kwargs): ...
151
def plot(function, **kwargs): ...
152
153
class NumberPlane(VMobject): ...
154
class ComplexPlane(Axes): ...
155
class FunctionGraph(VMobject): ...
156
class ParametricCurve(VMobject): ...
157
```
158
159
[Coordinate Systems](./coordinate-systems.md)
160
161
### 3D Objects and Surfaces
162
163
Three-dimensional objects, surfaces, and specialized 3D mathematical constructs with camera controls and depth management.
164
165
```python { .api }
166
class Surface(VMobject):
167
def __init__(func, **kwargs): ...
168
169
class ParametricSurface(Surface): ...
170
class TexturedSurface(Surface): ...
171
class ThreeDAxes(Axes): ...
172
```
173
174
[3D Objects](./3d-objects.md)
175
176
### Utilities and Constants
177
178
Essential utilities including mathematical constants, color definitions, rate functions, vector operations, and development tools.
179
180
```python { .api }
181
# Constants
182
PI, TAU, DEGREES, RADIANS
183
UP, DOWN, LEFT, RIGHT, ORIGIN
184
BLUE, RED, GREEN, YELLOW, WHITE, BLACK
185
186
# Rate functions
187
def linear(t): ...
188
def smooth(t): ...
189
def there_and_back(t): ...
190
191
# Vector operations
192
def normalize(vector): ...
193
def rotate_vector(vector, angle): ...
194
```
195
196
[Utilities and Constants](./utilities-and-constants.md)
197
198
### Interactive Controls
199
200
Comprehensive interactive controls including UI widgets, buttons, sliders, color pickers, and text input for real-time parameter manipulation and user interaction.
201
202
```python { .api }
203
class MotionMobject(Mobject):
204
def __init__(mobject, **kwargs): ...
205
206
class Button(Mobject):
207
def __init__(mobject, on_click, **kwargs): ...
208
209
class LinearNumberSlider(ControlMobject):
210
def __init__(value, min_value, max_value, **kwargs): ...
211
212
class ColorSliders(ControlMobject): ...
213
class Textbox(ControlMobject): ...
214
class ControlPanel(Group): ...
215
```
216
217
[Interactive Controls](./interactive-controls.md)
218
219
### Boolean Operations
220
221
Precise geometric boolean operations for 2D shapes using Skia-Path Ops integration, enabling complex shape construction and geometric analysis.
222
223
```python { .api }
224
class Union(VMobject):
225
def __init__(*vmobjects, **kwargs): ...
226
227
class Difference(VMobject):
228
def __init__(subject, clip, **kwargs): ...
229
230
class Intersection(VMobject):
231
def __init__(*vmobjects, **kwargs): ...
232
233
class Exclusion(VMobject):
234
def __init__(*vmobjects, **kwargs): ...
235
```
236
237
[Boolean Operations](./boolean-operations.md)
238
239
### Value Tracking
240
241
Powerful numeric parameter tracking system for animation state management, enabling complex parameter-dependent animations and interactive controls.
242
243
```python { .api }
244
class ValueTracker(Mobject):
245
def __init__(value=0, **kwargs): ...
246
def get_value(): ...
247
def set_value(value): ...
248
249
class ExponentialValueTracker(ValueTracker): ...
250
class ComplexValueTracker(ValueTracker): ...
251
```
252
253
[Value Tracking](./value-tracking.md)
254
255
### Vector Fields
256
257
Comprehensive vector field visualization including static fields, time-dependent fields, streamlines, and animated flow visualization for physics simulations.
258
259
```python { .api }
260
class VectorField(VMobject):
261
def __init__(func, coordinate_system, **kwargs): ...
262
263
class TimeVaryingVectorField(VectorField): ...
264
class StreamLines(VGroup): ...
265
class AnimatedStreamLines(VGroup): ...
266
267
def move_along_vector_field(mobject, func): ...
268
```
269
270
[Vector Fields](./vector-fields.md)
271
272
### Probability and Statistics
273
274
Specialized tools for probability demonstrations and statistical visualizations including sample spaces, bar charts, and interactive probability tools.
275
276
```python { .api }
277
class SampleSpace(Rectangle):
278
def __init__(width=3, height=3, **kwargs): ...
279
def divide_horizontally(p_list, **kwargs): ...
280
def divide_vertically(p_list, **kwargs): ...
281
282
class BarChart(VGroup):
283
def __init__(values, **kwargs): ...
284
def change_bar_values(values): ...
285
```
286
287
[Probability and Statistics](./probability-stats.md)
288
289
### Matrix Visualization
290
291
Linear algebra visualization tools for displaying matrices, vectors, and matrix operations with proper mathematical formatting and interactive capabilities.
292
293
```python { .api }
294
class Matrix(VMobject):
295
def __init__(matrix, **kwargs): ...
296
def get_entries(): ...
297
def set_column_colors(*colors): ...
298
299
class Vector(Matrix): ...
300
class IntegerMatrix(Matrix): ...
301
class DecimalMatrix(Matrix): ...
302
303
def get_det_text(matrix, determinant=None): ...
304
```
305
306
[Matrix Visualization](./matrix-visualization.md)
307
308
### Advanced Animations
309
310
Sophisticated animation techniques including transform matching, homotopy deformations, complex animation composition, and specialized mathematical animations.
311
312
```python { .api }
313
class TransformMatchingParts(AnimationGroup):
314
def __init__(mobject, target_mobject, **kwargs): ...
315
316
class TransformMatchingTex(TransformMatchingParts): ...
317
class Homotopy(Animation): ...
318
class ComplexHomotopy(Homotopy): ...
319
320
class AnimationGroup(Animation): ...
321
class LaggedStart(AnimationGroup): ...
322
class UpdateFromFunc(Animation): ...
323
```
324
325
[Advanced Animations](./advanced-animations.md)
326
327
## Command Line Interface
328
329
ManimGL provides a command-line interface for rendering animations and interactive development:
330
331
```bash
332
# Interactive scene selection
333
manimgl
334
335
# Render specific scene
336
manimgl scene_file.py SceneName
337
338
# Preview with low quality
339
manimgl scene_file.py SceneName -l
340
341
# High quality render
342
manimgl scene_file.py SceneName -m
343
344
# Save to specific file
345
manimgl scene_file.py SceneName -o output.mp4
346
```