Skip to content
hhh edited this page Jan 8, 2022 · 1 revision

Timing

/**
 * Type of timing functions.
 */
type TimingFunction = (x: number) => number;

/**
 * Timing functions and factories.
 */
namespace Timing {

    /**
     * Linear timing function.
     */
    const linear: TimingFunction;

    /**
     * Accuracy parameter used in {@link cubic}.
     * @default 0.002
     */
    let cubicAccuracy: number;

    /**
     * Factory of cubic bezier timing function.
     */
    const cubic: (x1: number, y1: number, x2: number, y2: number) => TimingFunction;

    /**
     * `cubic(0.25, 0.2, 0.25, 1)`
     */
    const ease: TimingFunction;

    /**
     * `cubic(0.42, 0, 1, 1)`
     */
    const easeIn: TimingFunction;

    /**
     * `cubic(0, 0, 0.58, 1)`
     */
    const easeOut: TimingFunction;

    /**
     * `cubic(0.42, 0, 0.25, 1)`
     */
    const easeInOut: TimingFunction;

    /**
     * Step timing function.
     * @param start Whether to jump at start. (default: `false`)
     */
    const steps: (stepCount: number, start?: boolean) => TimingFunction;
}

Documentation of canvasom

Clone this wiki locally