interpolate
Blends two values of the same shape: every number goes from its value in from (t = 0) to
its value in to (t = 1), with lerp, through arrays and plain objects.
t is not clamped, so an easing that overshoots (a spring, a back curve) carries the value
past to and back. Keys and lengths come from from; the result is a new value.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
from | T | The value at `t = 0` |
to | T | The value at `t = 1`, with the same shape |
t | number | The progress, usually the output of an easing |
Returns
Section titled “Returns”Interpolated<T> — The blended value
Examples
Section titled “Examples”Blend a set of properties
Section titled “Blend a set of properties”Every number in the structure moves from its start to its end value.
With an easing
Section titled “With an easing”Pass the eased progress as t; overshooting easings carry the value past the end.
Related Types
Section titled “Related Types”Interpolatable
Section titled “Interpolatable”A value interpolate can blend: a number, or arrays and plain objects of them, nested at will (a point, a color, a whole set of style properties).
Interpolated
Section titled “Interpolated”The type of an interpolated value: the shape of the input, with literal numbers widened to
number (interpolate(0, 10, t) is a number, not 0 | 10).
