Skip to main content

simple_easing/
expo.rs

1/// <https://easings.net/#easeInExpo>
2#[inline]
3#[must_use]
4pub fn expo_in(t: f32) -> f32 {
5	if t <= 0.0 {
6		0.0
7	} else {
8		10.0f32.mul_add(t, -10.0).exp2()
9	}
10}
11
12/// <https://easings.net/#easeOutExpo>
13#[inline]
14#[must_use]
15pub fn expo_out(t: f32) -> f32 {
16	if 1.0 <= t {
17		1.0
18	} else {
19		1.0 - (-10.0 * t).exp2()
20	}
21}
22
23/// <https://easings.net/#easeInOutExpo>
24#[inline]
25#[must_use]
26pub fn expo_in_out(t: f32) -> f32 {
27	if t <= 0.0 {
28		0.0
29	} else if 1.0 <= t {
30		1.0
31	} else if t < 0.5 {
32		20.0f32.mul_add(t, -10.0).exp2() / 2.0
33	} else {
34		(2.0 - (-20.0f32).mul_add(t, 10.0).exp2()) / 2.0
35	}
36}