Morph blocks

A Morph block turns glyphs of a formula into other glyphs of the same formula, the way a derivation is written: each row grows out of the one above it, and the rows stay.

What a Morph block does

You write the whole derivation as one formula, one row per line, and put it on the timeline. Only its first row appears with the clip. A Morph block placed later in the clip names pairs of glyphs: a source, which is on screen when the block starts, and a target, a glyph of a later row. During the block the targets arrive, moving out of their sources. By default the sources stay where they are, so the rows pile up like a derivation on a blackboard.

A Morph block is a relation inside one clip. Its pairs, their styles, the arc of their paths and their timing work as they do between two clips: see How relations work and the relation editor. What is new is where the glyphs live.

A Morph block works on an object that has glyphs, such as a formula or a text. A brace, a shape or a line is one piece and has no Morph.

Morph, or a relation between clips?

Both solve the same equation in the same three steps. Here is the equation of the first transform twice: on the left three formulas linked by two relations, each replacing the one before it; on the right one formula with two Morph blocks, whose rows stay.

Relation between clipsMorph block
FormulasTwo, each with its own clip on its own track.One, in one clip.
LayoutEach clip is placed, scaled and coloured on its own.LaTeX lays the rows out: an & lines the equals signs up.
The sourceConsumed by Transform and Fade transform; stays with Copy (source stays) and Fade copy (source stays).Stays: Copy is the default style.
TimingA window inside the target clip.A block anywhere in the clip, with the same easing and duration.
The glyphs come fromAnother formula, which may be anywhere in the scene.Other glyphs of the same formula.

Choose Morph for a derivation that stays on screen, aligned on an equals sign, where each line comes from the one above. Choose a relation when one formula becomes another in place, when the second one must be placed, scaled or coloured on its own, or when the first one leaves. The two mix: a glyph of a row can also arrive from another formula through a relation.

Write the derivation

Type the rows in the Raw LaTeX field of the formula editor, one per line. Manim sets every formula in an aligned environment, so & marks the column the rows line up on and \\ ends a row:

x + 3 &= 5 \\
x &= 5 - 3 \\
x &= 2

Place the formula on the timeline as it is: nothing needs hiding. A glyph that a Morph block brings in skips the clip's intro and arrives through the block. A dropped clip lasts three seconds; drag its right edge, or set its End in the Timing tab, so that there is room for the blocks.

Add a Morph block

Put the playhead at the time the block should start, right-click the clip and choose Morph within the formula: the block starts at the playhead. (The Add animation button of the Timing tab offers the same entry, at the playhead too.) The block is one second long and has no pairs yet: the timeline writes it Morph · 0, the number being its pairs.

The menu that opens over a clip of the timeline when it is right-clicked: Add animation, with its groups and the entry Morph within the formula under the pointer.
With the playhead at 2 s, a right-click on the clip opens the Add animation menu; Morph within the formula starts a block there.
The timeline of the derivation: a clip with two Morph blocks, labelled Morph · 5 and Morph · 2, and a Write block.
The clip with its three blocks. The first Morph block has five pairs, the second two.

Choose the pairs

Open the pair editor with Edit pairs…: in the Animations panel when the block is selected, or in the block's right-click menu. The editor draws the formula twice: the glyphs that are on screen when the block starts, the sources, and the glyphs the block can bring in, the targets. It lays the two copies out the way that draws the glyphs that can take part larger. For these three rows that is one over the other: the sources above, the targets below. In a taller derivation a block may open side by side, the sources at the left, each line beside its own and the links as arcs over them, as the second block of the derivative tutorial does. The first key over the corner of the drawing changes the layout, and the drawing takes glyphs with a circle, zooms and moves as the relation editor's does.

Linking glyphs

Suggest pairs by label

Suggest pairs by label draws dashed links for you: each glyph that can arrive takes the nearest glyph before it, in reading order, that has the same label and can be a source. Accept all turns them into pairs; Dismiss throws them away. It is a quick start for the glyphs that stay the same from one row to the next. It cannot know that a + becomes a −: link those by hand, as the clip shows.

Suggest pairs by label, Accept all, and the plus linked to the minus by two clicks. The five pairs are then ready to be saved with Save pairs.

Which glyphs can take part

Glyphs that cannot take part as they are drawn dimmed; point at one and its tooltip says why. A source must be fully on screen when the block starts. A target must not be on screen yet, or be there only because the intro brought it, and nothing else may bring it in. Neither may be busy with another animation while the block runs.

The Morph pairs dialog of the second block: the glyphs of the first two rows are dimmed on the lower copy, and the 2 of the third row is dimmed on the upper copy.
The second block. Below, where the targets are, rows 1 and 2 are dimmed: they are on screen before the block starts, so nothing can bring them in. Above, where the sources are, the 2 of row 3 is dimmed: it is not on screen yet.
The tooltip saysIt means
not on screen yet · still arriving · off screen by thenAs a source: it is not fully on screen when the block starts.
consumed earlierAn earlier pair of the clip took the glyph out with Transform or Fade transform: it is gone, as a source and as a target.
a source of an earlier transferAs a target: an earlier pair copies from it, so it must be on screen already.
brought in by a relation · brought in by another Morph blockAs a target: something else brings it in. A glyph has one owner.
on screen already · on screen earlierAs a target: it is there before the block.
busy during the block (…)Another animation, the intro or the outro runs on it.

A pair is never made of one glyph on both sides of the block. When the pairs would break a rule, the side column of the editor lists the problems, each line starting with error or warning, and Save pairs waits until no error is left. The whole session is one step of the undo history; Cancel asks before it throws changes away.

Glyphs that no pair brings

The 2 of the last row comes from nothing: no glyph turns into it. Give it its own block. Add an Appear animation, such as Write, at the time it should be drawn, and pick the glyph in the panel of the block. A glyph that is the target of a pair, or the glyph of an Appear block, waits off screen by itself.

The panel of the Write block: its animation, its timing and the glyph picker with the 2 of the last row chosen.
The Write block of the 2. Its glyph picker shows the formula; the glyphs it names are marked.

The block's settings

Select the block to see its panel. Its Default style is the style of every pair that has none of its own (a pair can choose in the editor):

A default style that would give the project an error, a source that another pair consumes already for instance, is not set, and the notice Default style not changed says why: give the pairs that clash a style of their own, or keep the default.

Below the style come the Path arc, in degrees (a full turn at most, either way), that bends the glyphs' paths (Custom paths explains it), the pairs, read-only, each with what its glyphs follow and its own Edit path…, and the usual timing: start, duration and easing.

The panel of a Morph block: a hint, Default style and Path arc, the list of its five pairs with Edit path… buttons, and the Timing section.
The panel of the first block: its default style, its arc, its pairs and its timing.

Moving, copying and deleting

Drag a block on the timeline to move it and pull its edges to resize it, like any block. A Morph block stops before it would run into another animation of one of its glyphs. A block's right-click menu has Edit pairs…, Duplicate without pairs (a glyph arrives through one pair only, so a copy starts empty) and Delete….

The right-click menu of a Morph block: Edit pairs…, Duplicate without pairs and Delete….
The menu of a Morph block.
The Edit menu with the entry Suggest morph pairs highlighted.
Edit ▸ Suggest morph pairs.

With Edit ▸ Suggest morph pairs on (it is off by default), a new Morph block starts with the pairs Suggest finds, as one undo step.

How it exports

A Morph block is a self.play(…) over its window, with one animation for each pair; when another animation starts or ends inside the window, the export cuts the play into slices (the blocks page shows how). A copy is ReplacementTransform of a copy of the source in ManimCE and TransformFromCopy in ManimGL; the block's duration becomes run_time, and an easing other than the default smooth becomes rate_func. The first block of the project below, in ManimCE and in ManimGL:

        self.play(
            ReplacementTransform(rows_g[0].copy(), rows_g[5]),
            ReplacementTransform(rows_g[3].copy(), rows_g[6]),
            …
            run_time=1,
        )
        self.play(
            TransformFromCopy(rows_g[0], rows_g[5]),
            TransformFromCopy(rows_g[3], rows_g[6]),
            …
            run_time=1,
        )

Where to go next