Animation engine for explanatory math videos with programmatic mathematical visualization capabilities
npx @tessl/cli install tessl/pypi-manimgl@1.7.0ManimGL 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.
pip install manimglimport manimglCommon imports for most animations:
from manimgl import *Import specific components:
from manimgl import Scene, Mobject, Animation
from manimgl import Circle, Square, Text, Tex
from manimgl import ShowCreation, FadeIn, Transformfrom manimgl import *
class BasicExample(Scene):
def construct(self):
# Create mathematical objects
circle = Circle(radius=1, color=BLUE)
square = Square(side_length=2, color=RED)
text = Text("Hello ManimGL", font_size=48)
# Position objects
circle.shift(LEFT * 2)
square.shift(RIGHT * 2)
text.shift(UP * 2)
# Animate objects
self.play(ShowCreation(circle))
self.play(ShowCreation(square))
self.play(FadeIn(text))
self.play(Transform(circle, square))
self.wait()
# Run with: manimgl example.py BasicExampleManimGL uses a hierarchical architecture built around mathematical objects (Mobjects) and their animations:
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.
Essential scene management for creating animations, including base scene classes, interactive development, 3D scene support, and animation timeline control.
class Scene:
def construct(self): ...
def play(*animations, **kwargs): ...
def add(*mobjects): ...
def remove(*mobjects): ...
def wait(duration=None): ...
class InteractiveScene(Scene): ...
class ThreeDScene(Scene): ...Comprehensive collection of mathematical objects including basic geometry, 3D shapes, coordinate systems, text rendering, and complex mathematical constructs.
class Mobject:
def shift(vector): ...
def scale(factor): ...
def rotate(angle): ...
class Circle(VMobject): ...
class Square(VMobject): ...
class Line(VMobject): ...
class Text(VMobject): ...
class Tex(VMobject): ...Extensive animation framework with over 80 animation classes covering transforms, creation effects, movement, indication, fading, and specialized mathematical animations.
class Animation:
def __init__(mobject, **kwargs): ...
class Transform(Animation): ...
class ShowCreation(Animation): ...
class FadeIn(Animation): ...
class Rotate(Animation): ...
class Indicate(Animation): ...Advanced text rendering capabilities including plain text, LaTeX mathematical expressions, code highlighting, and markup support with precise typographical control.
class Text(VMobject):
def __init__(text, **kwargs): ...
class Tex(VMobject):
def __init__(*tex_strings, **kwargs): ...
class TexText(VMobject): ...
class Code(VMobject): ...
class BulletedList(VMobject): ...Mathematical coordinate systems, number lines, function plotting, and graph visualization with support for 2D and 3D coordinate systems.
class Axes(VMobject):
def __init__(x_range, y_range, **kwargs): ...
def plot(function, **kwargs): ...
class NumberPlane(VMobject): ...
class ComplexPlane(Axes): ...
class FunctionGraph(VMobject): ...
class ParametricCurve(VMobject): ...Three-dimensional objects, surfaces, and specialized 3D mathematical constructs with camera controls and depth management.
class Surface(VMobject):
def __init__(func, **kwargs): ...
class ParametricSurface(Surface): ...
class TexturedSurface(Surface): ...
class ThreeDAxes(Axes): ...Essential utilities including mathematical constants, color definitions, rate functions, vector operations, and development tools.
# Constants
PI, TAU, DEGREES, RADIANS
UP, DOWN, LEFT, RIGHT, ORIGIN
BLUE, RED, GREEN, YELLOW, WHITE, BLACK
# Rate functions
def linear(t): ...
def smooth(t): ...
def there_and_back(t): ...
# Vector operations
def normalize(vector): ...
def rotate_vector(vector, angle): ...Comprehensive interactive controls including UI widgets, buttons, sliders, color pickers, and text input for real-time parameter manipulation and user interaction.
class MotionMobject(Mobject):
def __init__(mobject, **kwargs): ...
class Button(Mobject):
def __init__(mobject, on_click, **kwargs): ...
class LinearNumberSlider(ControlMobject):
def __init__(value, min_value, max_value, **kwargs): ...
class ColorSliders(ControlMobject): ...
class Textbox(ControlMobject): ...
class ControlPanel(Group): ...Precise geometric boolean operations for 2D shapes using Skia-Path Ops integration, enabling complex shape construction and geometric analysis.
class Union(VMobject):
def __init__(*vmobjects, **kwargs): ...
class Difference(VMobject):
def __init__(subject, clip, **kwargs): ...
class Intersection(VMobject):
def __init__(*vmobjects, **kwargs): ...
class Exclusion(VMobject):
def __init__(*vmobjects, **kwargs): ...Powerful numeric parameter tracking system for animation state management, enabling complex parameter-dependent animations and interactive controls.
class ValueTracker(Mobject):
def __init__(value=0, **kwargs): ...
def get_value(): ...
def set_value(value): ...
class ExponentialValueTracker(ValueTracker): ...
class ComplexValueTracker(ValueTracker): ...Comprehensive vector field visualization including static fields, time-dependent fields, streamlines, and animated flow visualization for physics simulations.
class VectorField(VMobject):
def __init__(func, coordinate_system, **kwargs): ...
class TimeVaryingVectorField(VectorField): ...
class StreamLines(VGroup): ...
class AnimatedStreamLines(VGroup): ...
def move_along_vector_field(mobject, func): ...Specialized tools for probability demonstrations and statistical visualizations including sample spaces, bar charts, and interactive probability tools.
class SampleSpace(Rectangle):
def __init__(width=3, height=3, **kwargs): ...
def divide_horizontally(p_list, **kwargs): ...
def divide_vertically(p_list, **kwargs): ...
class BarChart(VGroup):
def __init__(values, **kwargs): ...
def change_bar_values(values): ...Linear algebra visualization tools for displaying matrices, vectors, and matrix operations with proper mathematical formatting and interactive capabilities.
class Matrix(VMobject):
def __init__(matrix, **kwargs): ...
def get_entries(): ...
def set_column_colors(*colors): ...
class Vector(Matrix): ...
class IntegerMatrix(Matrix): ...
class DecimalMatrix(Matrix): ...
def get_det_text(matrix, determinant=None): ...Sophisticated animation techniques including transform matching, homotopy deformations, complex animation composition, and specialized mathematical animations.
class TransformMatchingParts(AnimationGroup):
def __init__(mobject, target_mobject, **kwargs): ...
class TransformMatchingTex(TransformMatchingParts): ...
class Homotopy(Animation): ...
class ComplexHomotopy(Homotopy): ...
class AnimationGroup(Animation): ...
class LaggedStart(AnimationGroup): ...
class UpdateFromFunc(Animation): ...ManimGL provides a command-line interface for rendering animations and interactive development:
# Interactive scene selection
manimgl
# Render specific scene
manimgl scene_file.py SceneName
# Preview with low quality
manimgl scene_file.py SceneName -l
# High quality render
manimgl scene_file.py SceneName -m
# Save to specific file
manimgl scene_file.py SceneName -o output.mp4