Understanding the Linear Expression in After Effects
The linear() function in Adobe After Effects is an
interpolation expression used to remap a range of input values to a
completely new range of output values at a constant rate. By translating
numbers between two different scales, it allows motion designers to
create dynamic, procedural animations where one property drives another
without relying on manual keyframes.
How the linear()
Function Works
At its core, the linear() method calculates a value
between a specified minimum and maximum based on an input value. It
moves from the starting output to the ending output in a straight,
mechanical progression (constant velocity), avoiding easing unless
paired with other functions.
Basic Syntax
The function is typically written with five parameters:
linear(input, inputMin, inputMax, outputMin, outputMax)- input: The driver property or variable being
evaluated (such as
time, a Slider Control, or another layer's property). - inputMin: The starting threshold of the input range.
- inputMax: The ending threshold of the input range.
- outputMin: The value returned when the input equals
inputMin. - outputMax: The value returned when the input equals
inputMax.
There is also a simplified three-parameter version:
linear(progress, outputMin, outputMax)In this version, progress is expected to range between
0 and 1.
Key Use Cases
Mapping Control Sliders to Layer Properties A Slider Control might range from 0 to 100, but an opacity or rotation property might need to scale between 20% and 80%, or 0° and 360°. The
linear()function maps these numbers smoothly:s = effect("Slider Control")("Slider"); linear(s, 0, 100, 20, 80);Time-Based Transitions Instead of setting keyframes to trigger an event, you can tie a property directly to the composition timeline. For example, fading a layer in from 0% to 100% opacity between seconds 2 and 4:
linear(time, 2, 4, 0, 100);Audio-Driven Animation When converting audio to keyframes, peak values are often erratic. The
linear()expression can clamp and scale those peaks to control a layer's scale, position, or blur cleanly.Proximity-Based Effects By calculating the distance between two layers with
length(),linear()can automatically scale or fade an object as it approaches another layer.
Clamping Behavior
The linear() function automatically clamps its output.
If the input falls below inputMin, the output stays fixed
at outputMin. If the input exceeds inputMax,
the output stays fixed at outputMax. This prevents values
from overshooting or breaking properties outside of the designated
range.