cubicBezier
Builds the easing function of CSS cubic-bezier(x1, y1, x2, y2): given the progress of time
(0 to 1), it returns the progress of the animation.
y1 and y2 may leave [0, 1] to overshoot (the output then does too), but, as in CSS,
x1 and x2 may not. The input is clamped to [0, 1]. The curve is solved by bisection,
to within 1e-10.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x1 | number | x of the first control point, in `[0, 1]` |
y1 | number | y of the first control point |
x2 | number | x of the second control point, in `[0, 1]` |
y2 | number | y of the second control point |
Returns
Section titled “Returns”function — The easing function
Examples
Section titled “Examples”Play a CSS curve in JavaScript
Section titled “Play a CSS curve in JavaScript”Same result as cubic-bezier() in CSS, e.g. to drive a canvas animation.
Overshoot
Section titled “Overshoot”y control points outside [0, 1] make the animation go past its target and come back.
