simple_easing/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>
6pub fn back_in(t: f32) -> f32 {
7 C3 * t * t * t - C1 * t * t
8}
9
10/// <https://easings.net/#easeOutBack>
11pub fn back_out(t: f32) -> f32 {
12 1.0 + C3 * (t - 1.0).powi(3) + C1 * (t - 1.0).powi(2)
13}
14
15/// <https://easings.net/#easeInOutBack>
16pub fn back_in_out(t: f32) -> f32 {
17 if t < 0.5 {
18 ((2.0 * t).powi(2) * ((C2 + 1.0) * 2.0 * t - C2)) / 2.0
19 } else {
20 ((2.0 * t - 2.0).powi(2) * ((C2 + 1.0) * (t * 2.0 - 2.0) + C2) + 2.0) / 2.0
21 }
22}