/**
 * Функции easing: t=0..1 -> 0..1. Используются в Tween и переходах сцен.
 */

export type EaseFn = (t: number) => number;

export const linear: EaseFn = (t) => t;

export const quadIn: EaseFn = (t) => t * t;

export const quadOut: EaseFn = (t) => 1 - (1 - t) * (1 - t);

export const cubicIn: EaseFn = (t) => t * t * t;

export const cubicOut: EaseFn = (t) => 1 - Math.pow(1 - t, 3);

export const sineInOut: EaseFn = (t) => -(Math.cos(Math.PI * t) - 1) / 2;

/** Затухающий овершут: 0 → ~1.1 → 1 («появление с пружинкой», pop-эффекты). */
export const backOut: EaseFn = (t) => {
    const s = 1.70158;
    const u = t - 1;
    return 1 + (s + 1) * u * u * u + s * u * u;
};