curve.ts

 1import bezier from "bezier-easing"
 2import { Curve } from "../ref/curves"
 3
 4/**
 5 * Formats our Curve data structure into a bezier easing function.
 6 * @param {Curve} curve - The curve to format.
 7 * @param {Boolean} inverted - Whether or not to invert the curve.
 8 * @returns {EasingFunction} The formatted easing function.
 9 */
10export function curve(curve: Curve, inverted?: Boolean) {
11    if (inverted) {
12        return bezier(
13            curve.value[3],
14            curve.value[2],
15            curve.value[1],
16            curve.value[0]
17        )
18    }
19
20    return bezier(
21        curve.value[0],
22        curve.value[1],
23        curve.value[2],
24        curve.value[3]
25    )
26}