Start with simple scenes, text, LaTeX maths, shapes, and positioning.
These short examples introduce the basic pieces of Manim. After reading them here, try the code in the Manim Lab editor.
← Return to the main Manim Lab whenever you want to render an example.
Rendered in Manim Lab: all the animations on this page were rendered in the Manim Lab page using our renderer.
Module A • Your first scene
A Manim animation begins with a small scene class. Here is a minimal example.
🧩 A very first scene
from manim import *
class HelloInvariantMath(Scene):
def construct(self):
text = Tex(r"Hello, InvariantMath!")
self.play(Write(text))
self.wait(1)
Scenedefines an animation scene.construct()is where the animation is created.Tex()displays LaTeX text.Write()animates the text appearing.
HelloInvariantMath.
- Change the greeting text.
- Increase
self.wait(1)toself.wait(3).
Module B • Text and LaTeX maths
Use Text for regular writing and MathTex for mathematical formulas.
✏️ Title and formula
from manim import *
class TextAndMath(Scene):
def construct(self):
title = Text("Geometric series")
formula = MathTex(r"1 + x + x^2 + \cdots = \frac{1}{1-x}")
title.to_edge(UP)
formula.next_to(title,DOWN,buff=0.5)
self.play(Write(title))
self.play(Write(formula))
self.wait(2)
Textdisplays ordinary text.MathTexrenders LaTeX formulas.to_edge()andnext_to()position objects.
- Add your own title.
- Replace the formula with one from your course.
Module C • Shapes and positions
Manim can animate simple geometric objects like circles, squares, and triangles.
🔷 Simple shapes
from manim import *
class ShapesExample(Scene):
def construct(self):
circle = Circle(color=BLUE)
square = Square(color=GREEN).shift(RIGHT*2)
triangle = Triangle(color=RED).shift(LEFT*2)
self.play(Create(circle),Create(square),Create(triangle))
self.wait(2)
- Shapes appear with
Create(). shift()moves objects across the screen.
- Add another shape.
- Change the colours.
Module D • Styles and reusable helpers
When scenes grow larger, it helps to reuse colours and small helper functions.
🎨 Palette and helper example
from manim import *
# Define colours once
InvariantMath_BLUE = "#0ea5e9"
InvariantMath_GREEN = "#22c55e"
# Helper for consistent titles
def title(text):
return Text(text,color=InvariantMath_BLUE).to_edge(UP)
# Scene to render
class PaletteExample(Scene):
def construct(self):
heading = title("InvariantMath example")
bar = Rectangle(
width=4,
height=0.3,
color=InvariantMath_GREEN
).next_to(heading,DOWN,buff=0.5)
caption = Text(
"Reusable styles keep scenes consistent.",
font_size=28
).next_to(bar,DOWN,buff=0.5)
self.play(Write(heading))
self.play(GrowFromCenter(bar))
self.play(FadeIn(caption))
self.wait(2)
- Colours are defined once at the top.
- The
title()helper creates consistent headings. PaletteExampleis the scene you render.
PaletteExample.
- Change the palette colours.
- Add another shape using the same colours.
Once these ideas feel comfortable, return to the main Manim Lab and start combining them into your own scenes.