Math

Math Modifier icon

The Math Numeric Modifier applies a simple operation to a numeric value: it adds, subtracts, multiplies, divides, wraps or replaces it. Because it is a Modifier, it works on top of whatever defines the value, keyframes, a Generator or a link, without changing it.

The same Math Modifier exists for every type of numeric parameter: single values (1D) such as a Rotation or an Opacity, and values with 2, 3 or 4 dimensions, such as a Position, a 3D Position or a color. This page covers all of them.

Use it for:


Quick Navigation



Adding the Math Modifier

As described in Generators and Modifiers, click the Modifier slot (the flask icon) of a numeric parameter and choose Math in the list. The list only shows the Modifiers that match the type of the parameter, so the right version of Math (1D, 2D, 3D or 4D) is picked automatically.

The Math Modifier is applied after what defines the value: keyframes, a Generator or a link. Several Modifiers on the same parameter are applied one after another, from top to bottom, so their order matters: adding 10 then multiplying by 2 does not give the same result as multiplying first.

Note:

Most numeric Modifiers are reversible: you can still move the Motion Path control points of an animation that goes through a Math Modifier, and Autograph takes the offset into account. See Generators and Modifiers.

The Operations

The Operation menu sets what the Math Modifier does with the incoming value and its own Value. The table below shows the result of each operation for an incoming value of 10 and a Value of 3:

Operation Result 10 and 3 Typical use
Add Input + Value 13 Offset an animation, oscillate around a value
Subtract Input - Value 7 Offset in the other direction, recenter a value
Multiply Input × Value 30 Amplify or reduce an animation, invert it with -1
Divide Input ÷ Value 3.33 Reduce an animation. Dividing by 0 leaves the value unchanged
Modulo Remainder of Input ÷ Value 1 Wrap a value that keeps growing, to repeat a motion endlessly
Replace Value 3 Override the value, usually with an animated Influence
Note:

Modulo keeps the sign of the incoming value: -10 modulo 3 gives -1, not 2. It also works with decimal numbers: 7.5 modulo 2 gives 1.5.

Influence

The Influence blends between the incoming value and the result of the operation:

In the following example, the three dots bob with the same Oscillate, with an Amplitude of 150, followed by the same Math Modifier in Multiply mode with a Value of 2. Only the Influence changes: at 0, the dot keeps its original motion; at 1, its motion is doubled; at 0.5, it moves exactly halfway between the two.

The same Multiply 2 with an Influence of 0, 0.5 and 1. The blue lines mark the original motion, the orange lines the full result.
Then paste in the Project panel. Learn more

The Influence is not limited to the 0 to 1 range: at 2, Add 3 adds 6, and at -1 it subtracts 3. Animate it to fade the effect of the Modifier in or out, as shown in Bringing an Animation to Rest with Replace.

Parameters with Several Dimensions

On a parameter with 2, 3 or 4 dimensions, the Value and the Influence have the same number of dimensions, and each dimension is computed separately. On a Position of 100, 200, Add with a Value of 50, -20 gives 150, 180, and an Influence of 1, 0 applies the change to X only.

On a color, the four dimensions are the red, green, blue and alpha channels: Multiply with a Value of 1, 0.5, 0.2, 1 turns white into orange, without touching the alpha.

Which version of Math a parameter accepts depends on its dimension mode (see Managing Dimensions):

Example: Offsetting an Animation

To move an animation without touching its keyframes, add a Math Modifier in Add mode. In the following example, both dots have exactly the same keyframes on their Position. The orange one has a Math Modifier that adds -300 to Y, so it follows the same motion 300 pixels lower.

Same keyframes on both dots. The orange one has a Math Modifier in Add mode on Y.
Then paste in the Project panel. Learn more
Tip:

Use Multiply the same way to make an animation larger or smaller, or -1 to mirror it, while keeping its timing. To oscillate around a value other than 0, see Oscillating Around Another Value on the Oscillate page.

Example: an Endless Loop with Modulo

A value driven by the Current Time Generator grows forever, so a layer moved by it leaves the frame and never comes back. A Math Modifier in Modulo mode wraps that value: it goes back to 0 each time it reaches the Value, and the motion repeats endlessly, without any keyframe.

In the following example, the Position of the text is in Separated mode, and its X uses three steps:

  1. A Current Time Generator with a Multiplier of 700: X grows by 700 pixels per second.
  2. A Math Modifier in Modulo mode, with a Value of 2800: X now goes from 0 to 2800, then starts over.
  3. A second Math Modifier in Subtract mode, with a Value of 1400: X goes from -1400 to 1400, from beyond the left edge of the frame to beyond the right edge.
Current Time × 700, Modulo 2800, then Subtract 1400 on Position X. The text crosses the frame every 4 seconds.
Then paste in the Project panel. Learn more
Tip:

Choose a Modulo value large enough for the layer to be completely outside the frame when it jumps back, so that the jump is never visible.

Example: Bringing an Animation to Rest with Replace

Replace overrides the incoming value with the Value. On its own, it simply locks the parameter, but combined with an animated Influence, it blends smoothly from the animation to a fixed value.

In the following example, an Oscillate makes the dot bob up and down. A Math Modifier in Replace mode, with a Value of 0, has its Influence animated from 0 at one second to 1 at three seconds: the bobbing fades out, and the dot comes to rest on the line.

Oscillate on Position Y, then Math in Replace mode with a Value of 0 and an animated Influence.
Then paste in the Project panel. Learn more

Controls

The 1D, 2D, 3D and 4D versions of the Math Modifier have the same controls. Only the number of dimensions of Value and Influence changes.

Parameter / Script Name Type Default Function
Enabled / enabled Boolean On Turns the Modifier on or off. When off, the value passes through unchanged.
Operation / op Choice Add The operation applied to the incoming value. See The Operations.
- Add: Adds the Value.
- Subtract: Subtracts the Value.
- Multiply: Multiplies by the Value.
- Divide: Divides by the Value. Dividing by 0 leaves the value unchanged.
- Modulo: Keeps the remainder of the division by the Value, with the sign of the incoming value.
- Replace: Replaces the incoming value with the Value.
Value / other Float, Float 2D, 3D or 4D 1 on each dimension The number used by the operation. It has as many dimensions as the parameter, so each dimension can use a different value.
Influence / influence Float, Float 2D, 3D or 4D 1 on each dimension Blends between the incoming value at 0 and the result of the operation at 1, on each dimension. Values above 1 or below 0 push the result further. See Influence.