Manim basics

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.

Rendered in Manim Lab: all the animations on this page were rendered in the Manim Lab page using our renderer.

On this page

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)
  • Scene defines an animation scene.
  • construct() is where the animation is created.
  • Tex() displays LaTeX text.
  • Write() animates the text appearing.
Paste this code into the Manim Lab editor and render the scene named HelloInvariantMath.
Preview First scene
Try this
  • Change the greeting text.
  • Increase self.wait(1) to self.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)
  • Text displays ordinary text.
  • MathTex renders LaTeX formulas.
  • to_edge() and next_to() position objects.
Try this
  • Add your own title.
  • Replace the formula with one from your course.
Preview Text and maths

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.
Try this
  • Add another shape.
  • Change the colours.
Preview Shapes example

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.
  • PaletteExample is the scene you render.
Paste the entire code block into the Manim Lab editor and render the scene named PaletteExample.
Try this
  • Change the palette colours.
  • Add another shape using the same colours.
Preview Palette example

Once these ideas feel comfortable, return to the main Manim Lab and start combining them into your own scenes.