1pub fn bounce_in(t: f32) -> f32 {
3 1.0 - bounce_out(1.0 - t)
4}
5
6pub fn bounce_out(t: f32) -> f32 {
8 const N1: f32 = 7.5625;
9 const D1: f32 = 2.75;
10 if t < 1.0 / D1 {
11 return N1 * t * t;
12 } else if t < 2.0 / D1 {
13 return N1 * (t - 1.5 / D1).powi(2) + 0.75;
14 } else if t < 2.5 / D1 {
15 return N1 * (t - 2.25 / D1).powi(2) + 0.9375;
16 } else {
17 return N1 * (t - 2.625 / D1).powi(2) + 0.984375;
18 }
19}
20
21pub fn bounce_in_out(t: f32) -> f32 {
23 if t < 0.5 {
24 (1.0 - bounce_out(1.0 - 2.0 * t)) / 2.0
25 } else {
26 (1.0 + bounce_out(2.0 * t - 1.0)) / 2.0
27 }
28}