Pymations
Maths animations in Python

Write a few lines of Python and watch shapes, equations and graphs move: drawn, transformed, coloured and labelled. Build your scenes, run them, mix them with Pyctures drawing, and save the result as a video.

Runs Manim Community scripts: paste one in and press Run.

$pip install pymations

Free and open source, MIT licence. Python 3.9 or newer.

Try Pymations in your browser

shape_morph.py
Loading the preview…

One shape flowing into the next: square, circle, triangle, star, hexagon.

Open in Circuitry

Change the code and press Run (or Cmd/Ctrl+Enter). Move the pointer over the picture for the timeline: drag it to scrub. Python runs in your browser; the first run loads it, which takes a few seconds.

Where it comes from

Manim was created by Grant Sanderson to make the animations in his 3Blue1Brown maths videos. Manim Community is the community-maintained version that most people use today.

Pymations is a fresh rewrite, not a fork. It runs Manim Community scripts, but it is built to play in real time and to use Circuitry as its code editor and preview: build your scenes, run them, mix them with Pyctures animations, and export a video.

Pymations is an independent project and is not affiliated with Manim, Manim Community or 3Blue1Brown.

Made with Pymations

Showreel

Highlights from the demos below.

Explainer toolkit

Diagrams, charts, networks, matrices, proofs and equations: the building blocks of an explainer video, in under a minute.

Pythagoras

Four triangles rearranged inside a square prove a² + b² = c².

The derivative

Secant lines close in on the tangent as h shrinks.

Euler’s identity

e^(iπ) + 1 = 0, from the cos and sin parts on the unit circle.

Odd numbers

1 + 3 + 5 + … adds up to a square, n².

Sine wave

A point goes round the unit circle and draws the sine wave.

Gaussian integral

Maths on top of a moving Pyctures background.

Solving an equation

Each step of the algebra moves into the next.

Point on a curve

A point rides a curve, with its coordinates following.

Staggered grid

A grid of squares coming in one after another.

A short script, or scenes

A script can just say what to play, line by line. Longer pieces use the scene form: a class with a construct() method. Every scene in a file plays, in order, each as a section of one timeline.

A script
from pymations import *

circle = Circle(color=ORANGE)
play(Create(circle))
play(circle.animate.shift(RIGHT * 2).scale(0.5))
wait()
A scene, as Manim Community writes it
from manim import *

class Intro(Scene):
    def construct(self):
        eq = MathTex(r"e^{i\pi} + 1 = 0", font_size=96)
        self.play(Write(eq))
        self.wait()

from manim import * works too, so tutorials and scripts written for Manim Community run as they are. What matches and what differs: running Manim scripts.

Save it as a video

In Circuitry, the video button in the editor's footer records the animation to an MP4: 720p, 1080p, 4K, a 9:16 Short or a square, at 30 or 60 frames a second. The video is made frame by frame, so no frame is ever dropped, and it stops by itself at the end.

Run it with your own Python

Pymations is also a free Python package for Python 3.9 or newer, with nothing else to install. The same .py files run on your computer and become web pages.

Your browser opens on the animation
pymations run scene.py
A web page that plays it in any browser
pymations build scene.py -o scene.html

Or put animations in your own page: a <div> for each, which starts when it scrolls into view.

index.html
<div data-pymations-src="scene.py"></div>
<div data-pymations-src="intro.py" data-pymations-loop></div>
<script type="module" src="pymations/pymations.js"></script>

Full instructions: Pymations outside Circuitry.

Built into Circuitry

Open a Python file in Circuitry's code editor, write from pymations import * and press Run. The animation plays in a preview beside the code. It mixes with Pyctures drawing, so a scene can have a moving picture behind it.

Open Circuitry