The Pythagorean theorem, in colour

Animate a² + b² = c² so that each term keeps its colour while it turns into a number and then into a square. On the way you write three formulas, colour their glyphs, put them on the timeline, link them and export the scene.

What you will make

Three lines of one derivation: the theorem, the 3-4-5 triangle that makes it concrete, and the sum of two squares that equals a third. The term a² is blue, b² gold and c² green, and each keeps its colour as it becomes 3² and then 9.

You will end with a project file, the Python that Manim runs, and a video like the one at the end of this page. Everything is in your browser. Manim itself is only needed for the very last step.

Before you start

Step by step

1. Write the theorem

In the Creator press + New. The editor of a new formula opens.

  1. Click the Raw LaTeX field and type a^2 + b^2 = c^2.
  2. Press Apply (or Ctrl+Enter). The glyph view on the right draws the formula and counts eight glyphs.
  3. Type theorem in the Name field and press Enter. The name becomes a variable in the Python and the label of the clip on the timeline.
  4. Type 2 in the first box of Size, the scale, and press Enter. The box at its right then reads 96, Manim's font_size: twice its default of 48, which reads better in a video.
The editor of the formula theorem: its name (1), its size 2 times 48 equals 96 (2), the Raw LaTeX field with a^2 + b^2 = c^2 (3) and the Apply button (4); at the right, the glyph view draws the formula.
The editor after step 1: the name (1), the size (2), the LaTeX (3) and Apply (4).

2. Colour its three terms

Each glyph has a number, its place in the formula: a is 0 and its exponent 1, the + is 2, b and its exponent are 3 and 4, and so on up to the exponent of c, 7. You colour glyphs by selecting them in the glyph view.

  1. Drag a box over the a and its exponent. The box selects every glyph it touches.
  2. Click the blue swatch under the drawing.
  3. Do the same for b and its exponent with the gold swatch, and for c and its exponent with the green one.
A box over a and its exponent, then the blue swatch; the same for b with the gold one.

Press Close. Colouring glyphs and objects shows the other ways to select glyphs and to give them colours.

3. Write and colour the other two

Press + New twice more, and give each formula its LaTeX, its name, a size of 2 and its colours the same way:

NameLaTeXColours
numbers3^2 + 4^2 = 5^23 and its exponent blue, 4 and its exponent gold, 5 and its exponent green
squares9 + 16 = 259 blue, 16 gold, 25 green
The Creator with three formula cards: theorem, numbers and squares, each with its terms in blue, gold and green.
The Creator after step 3.

4. Put the formulas on the timeline

Drag each card of the Creator onto a track of the timeline. A track holds clips that do not overlap, so use both:

A dropped clip is three seconds long, and its start snaps to the ticks of the ruler. The clips overlap on purpose: a transformation starts when the second clip does, while the first is still on screen. The timeline at the end of step 7 shows how it should look.

5. Let the first formula write itself

Right-click the clip of theorem and choose Intro ▸ Write. The formula now draws itself during the first second, as Manim's Write does.

The right-click menu of the clip theorem, with its Intro submenu open.
The Intro submenu of a clip.

A relation says which glyphs of one clip become which glyphs of the next. Select the clip of theorem. In the Animations panel, under Relations:

  1. Choose numbers in Relate with, and press Create relation…. The relation editor opens: the source above, the target below.
  2. Press Suggest links by label. The glyphs that have the same label, the exponents, the + and the =, are proposed as dashed links. Press Accept all.
  3. Click the a of the source, then the 3 of the target: a click on a glyph of one side followed by a click on the other links them at once. Do the same for b and 4, and for c and 5.
  4. Press Save relation.
The relation editor from theorem to numbers after Suggest links by label (ringed, 1): dashed links join the exponents, the plus and the equals sign, and the bar with Accept all (2) offers them.
After Suggest links by label (1): five dashed links, and Accept all (2).
The relation editor with all eight glyphs of theorem linked to the eight glyphs of numbers; the list of pairs at the right.
All eight glyphs linked, ready for Save relation.

Select the clip of numbers, relate it with squares and open the relation editor again. This time several glyphs become one or two, so you select them first: Shift+click glyphs of a side to select more than one, then click a glyph of the other side, or press Link when both sides hold several.

In numbersIn squaresHow
3 and its exponent9Shift+click both, then click the 9
++click, click
4 and its exponent1 and 6Shift+click both, Shift+click the 1 and the 6, press Link
==click, click
5 and its exponent2 and 5as for the 4

Press Save relation. The relation editor explains every control.

The relation editor from numbers to squares with its five pairs linked and listed at the right.
The second relation, as the finished project has it.
The timeline with three clips, theorem and squares on the upper track and numbers on the lower one, and a band between each pair of clips that are related.
The timeline after step 7: a band joins the clips of each relation.

8. Play it

Press the Play button under the Preview, or Space. Each term keeps its colour as it turns into the next one.

The Preview in the middle of the first transformation: the letters a, b and c are turning into 3, 4 and 5, each in its own colour.
The Preview at 2.5 seconds, half way through the first transformation, from theorem to numbers.

9. Export it

Choose Export ▸ Python — ManimCE… and press Download ThePythagoreanTheoremInColour.py (1). The button names the file after the scene, and the scene is named after the project, as you set up in Before you start. The first lines of the file say how to render it at the project's size, 1920×1080 at 60 frames a second:

manim -r 1920,1080 --fps 60 ThePythagoreanTheoremInColour.py ThePythagoreanTheoremInColour

That takes a while. For a quick draft, take -r 1920,1080 --fps 60 out and put -ql in its place, a low-quality 854×480 at 15 frames a second, and add -p to play the video when it is done:

manim -pql ThePythagoreanTheoremInColour.py ThePythagoreanTheoremInColour

Adding -ql to the first command would change nothing: Manim applies -r and --fps after the quality flag.

The Export Python dialog for ManimCE with the scene name, the options and a preview of the code; the Download button, which carries the scene's file name, is ringed and numbered 1.
The Python export dialog, with Download ThePythagoreanTheoremInColour.py (1).

The warnings in the dialog say that, without the companion, the scene finds the glyphs of each formula by their position when it runs. The Python page explains why, and the generated file works as it is. The generated Python goes through it, and Exporting covers ManimGL, video and audio.

The result

This is the Python the editor exports for the project you made, for each Manim:

And this is the scene as ManimCE renders it from the ManimCE file:

Ideas to go further