Custom paths

A glyph travels from where it is to where it is going in a straight line, unless you say otherwise. Bend every line of a relation with one number, or draw the route of a single pair in the Preview, as you would a curve in a vector editor.

How a glyph travels

A relation moves the glyphs of its pairs during its window. Each glyph starts where its source formula has it when the window opens and ends where its target formula has it when the window closes. Between the two it follows a path. There are three kinds:

A pair with a custom path ignores the Path arc. The same two tools exist on Morph blocks, which move glyphs inside one formula.

You wantUse
A direct move, the least to look atStraight: leave the Path arc at 0°.
Glyphs that pass each other, or a gentle swing for everything that movesThe relation's Path arc.
One glyph to hop, loop or weave, or two glyphs to take different routesA custom path for each of those pairs.

The path arc

Select a relation: click its band on the timeline, or its row in the Relations list of one of its clips. In the Animations panel, the section Timing and style has the field Path arc, in degrees (the Animation tab of the relation editor has it too). 0° keeps the glyphs on straight lines; any value from −360° to 360° bends them.

The Timing and style section of a relation: Offset, Duration, Easing, Default style and Path arc, with a ring round the Path arc field.
The Path arc (1) sits with the relation's timing and its default style.

The sign says which way the glyph swings. A positive arc swings to the right of the glyph's own direction, a negative one to the left. A glyph that travels to the right has its right-hand side below it, so it passes under the straight line; one that travels to the left passes over it. Because every glyph bends to the same side of its own way, glyphs that go different ways swing past each other instead of through each other: the swap of the two sides of an equation is the classic case.

Paths edited by hand

When one glyph must hop over another, or weave round a third, a single angle is not enough. Give that pair a path of its own. Here two letters trade places. Along straight paths they run through each other; with a path for each, the a hops over and the b slides under.

Opening the mode

The curve is edited in the Preview, on the real positions, in a mode of its own called Edit path. There are several ways in; all of them open it on one pair.

WhereWhat Edit path… does there
A clip's Relations list, on the row of the relation Opens the mode on its only pair, or the path picker when the relation has several.
The panel of a selected relation, in the list of Pairs Opens the mode on that pair.
A right-click on the relation's band on the timeline Lists the pairs under Edit path, or offers Choose a pair….
The relation editor: the list of pairs, or the menu of a pair Saves the relation, closes the editor and opens the mode on that pair.
A Morph block: its panel, its dialog, its pair editor Opens the mode on that pair (the dialog and the editor close first).
The row of a relation in the Relations list: its name, 4 paths edited, its window, and the buttons Edit…, Edit path… and the delete key.
The row of a relation in a clip's Relations list: the dot and “4 paths edited” count the pairs with a path of their own, and Edit path… sits between Edit… and the delete key.

In the mode

The playhead jumps to the middle of the pair's window, so the glyph is on screen halfway along its way. The curve is drawn over the Preview from where the glyph starts to where it ends; those two places are marked by a faint copy of the glyph, and a dashed line joins them (the straight chord). A pair that has no path of its own starts from the arc it follows, turned into anchors and handles: the plain chord at 0°.

The Preview in the Edit path mode: a curve with a smooth anchor at its top, handles on both sides of it, faint copies of the glyph at both ends, the hint line along the top and the Done button.
The mode: an anchor (1) with its handles (2), the hint line (3) and Done (4). The glyph is drawn at the middle of the way, where the curve puts it.

Four words are enough to read the curve:

Chord
the straight line from where the glyph starts to where it ends (dashed);
Anchor
a point the curve passes through; the first and the last sit on the chord's ends;
Handle
the control point that sets how the curve leaves or reaches an anchor: the farther it is, the longer the curve keeps its direction;
Smooth or corner
on a smooth anchor the two handles stay in a line, so the curve has no kink there; on a corner they point anywhere.

Every gesture is one step of the undo history, and the glyph follows the curve as you change it.

Do thisWhat happens
Press on the curve and dragAdds an anchor there and moves it with the pointer.
Drag an anchorMoves it with its handles. The first and the last anchor sit on the glyph's two places and stay put.
Drag a handleReshapes the curve beside its anchor. On a smooth anchor the other handle mirrors it: it turns to stay opposite and takes the same length.
Drag a handle with Shift heldOn a smooth anchor the other handle turns to stay opposite, but keeps its own length.
Drag a handle with Ctrl heldMoves only that handle: the anchor becomes a corner.
Double-click an anchorMakes a corner smooth, or a smooth anchor a corner.
DeleteRemoves the selected anchor, or takes the selected handle back onto its anchor.
← → ↑ ↓Nudge the selected anchor or handle by one pixel of the Preview; with Shift, by ten. A nudged handle mirrors the other one, as a drag does.
Enter, Esc or DoneLeaves the mode. Esc first cancels a drag in progress. An entry chosen in the Preview's right-click menu leaves the mode too, keeping the path; closing that menu with Esc does not. On a button of the mode's bar (Path per glyph, the arrows of the routes…), Enter presses that button instead.
Shaping a path with the mode open: press on the curve and drag up, double-click the new anchor to make it smooth, draw one of its handles out (the other mirrors it), and press Enter to leave.

What is kept

A path for one glyph of a pair

A pair of several glyphs has several routes: each is one source glyph on its way to one target glyph. Two glyphs that become one have two routes, one glyph that becomes two has two, and two glyphs that become three have three, as Manim pairs them up. The path of the pair is common to all its routes, each on its own chord. A route can also have a path of its own.

In the mode, such a pair is edited as one path to begin with. The curve is drawn once, along the first route, and a bar at the top left says that it is the path of all the glyphs: each glyph takes the same shape on its own way.

The Preview in the Edit-path mode on a pair of two x that become one: a bar with the button Path per glyph, off, and the words One path for all the glyphs. One curve, drawn out to the left with an anchor and its handles, runs from the first x to the target; the second x, halfway, bends the same way.
A pair of two x that become one, as the mode opens on it: Path per glyph is off (1), and the curve is the path of all the glyphs (2). It is drawn along the first x; the second x, halfway along its own way, bends the same way.

To shape one route alone, press Path per glyph. Every route is drawn now, dimmed: dashed while it follows the common path, solid with a dot once it has its own. The bar says what you are editing, and starts on All together, the common path. Click a route's curve, or the faint glyph at its start or at its end, or step through the routes with the arrows of the bar: the curve with the anchors is then that route's, on its own chord, and the first change gives the route a path of its own. When a route of the pair has a path of its own already, the mode opens with Path per glyph on.

The same pair with Path per glyph on: a bar with Path per glyph, a padlock, Route 1 of 2, x to x, and the buttons All together and Remove own path. The first x travels a curve drawn out to the left, with an anchor and its handles; the other route is a dashed straight line.
The first of the two routes of a pair, with a path of its own. The padlock (1) locks the other routes, the bar names the route (2), and Remove own path (3) gives it back to the common path, which the other route, dashed, still follows.

The path picker

With several pairs, Edit path… on a relation's row opens the picker instead of choosing for you. It shows the relation as a diagram, with one row for each pair: a small picture of the curve that pair follows, what it goes from and to, its style, and whether it follows a custom path, the arc or a straight line. Point at a row and its link lights up in the diagram, and the other way round; a click on either opens the mode on that pair.

The Edit path dialog of a relation of seven pairs: its diagram on the left and a row for each pair, each with a small picture of its curve.
The picker of a relation of seven pairs. Four rows wear the dot of an edited path; the others follow the relation's arc of 30°.

The relation's band on the timeline has a menu of its own (right-click it). With up to five pairs it lists them under Edit path; with more it offers Choose a pair…, which opens the picker.

The menu of a relation's band: Edit pairs…, then Edit path with one entry for each pair, then Delete relation.
Up to five pairs are in the menu.
The same menu for a relation of seven pairs: Edit path offers Choose a pair… (7).
With more, Choose a pair….

The marks of an edited path

A pair whose path you drew wears a small dot wherever pairs are listed beside an Edit path…; point at it and it says Edited path. A relation's row in the Relations list counts them (“4 paths edited”). The lists of pairs in the panel of a relation and of a Morph block also say what each pair follows: custom path, arc 30° or straight. A pair whose only edited paths are those of its routes wears the dot too, and reads custom path on a route.

The list of pairs of a relation of seven pairs: each row names its glyphs, its style and what it follows, with an Edit path… button; four rows wear the dot.
The pairs of a relation: a dot on the four with a path of their own, and what each one follows.

Taking a path away

To give a pair the relation's arc back, open the relation editor, right-click one of its glyphs (or select it and click the badge of its link), and choose Straight path, which takes the paths of its routes away as well. With several edited links selected the entry says how many (Straight paths (3)). Ctrl+Z undoes any change of a path, one gesture at a time.

The relation editor with the menu of a pair open: the styles Inherit, Transform, Copy, Fade transform and Fade copy, then Edit path… and Straight path, then Delete link….
The menu of a pair in the relation editor: the style of the pair, Edit path… and Straight path.

How paths export

The Path arc becomes Manim's own path_arc, in degrees, on each transform of the relation. A custom path is played through a small helper, _spline_path, which the export writes at the top of the file. It takes the curve as a list of anchors and handles, in the frame of the chord, and moves each glyph along it at a steady pace. The helper is the same in ManimCE and in ManimGL, and it does the same arithmetic as the Preview, so the video shows what you drew. When the glyphs of one transform follow different paths (a pair whose routes have paths of their own), a second helper, _route_paths, wraps that transform and gives each glyph the path of its route, also when two glyphs are drawn on the same spot.

In the project of the three rows at the top of this page, the transform of the second row carries the arc and the transform of the third row carries its own path:

ReplacementTransform(arc_g[0], arc_end_g[0], path_arc=-45 * DEGREES),
ReplacementTransform(edited_g[0], edited_end_g[0], path_func=_spline_path([…])),

The swap of the two letters exports the same way, one path_func=_spline_path([…]) for each of its two pairs:

Good to know

Where to go next