simple_easing2/
back.rs

1const C1: f32 = 1.70158;
2const C2: f32 = C1 * 1.525;
3const C3: f32 = C1 + 1.0;
4
5/// <https://easings.net/#easeInBack>
6#[must_use]
7#[inline(always)]
8pub fn back_in(t: f32) -> f32 {
9    (C3 * t * t).mul_add(t, -C1 * t * t)
10}
11
12/// <https://easings.net/#easeOutBack>
13#[must_use]
14#[inline(always)]
15pub fn back_out(t: f32) -> f32 {
16    C1.mul_add((t - 1.0).powi(2), C3.mul_add((t - 1.0).powi(3), 1.0))
17}
18
19/// <https://easings.net/#easeInOutBack>
20#[must_use]
21#[inline(always)]
22pub fn back_in_out(t: f32) -> f32 {
23    if t < 0.5 {
24        ((2.0 * t).powi(2) * ((C2 + 1.0) * 2.0).mul_add(t, -C2)) / 2.0
25    } else {
26        2.0f32
27            .mul_add(t, -2.0)
28            .powi(2)
29            .mul_add((C2 + 1.0).mul_add(t.mul_add(2.0, -2.0), C2), 2.0)
30            / 2.0
31    }
32}