Skip to main content

simple_easing/
cubic.rs

1/// <https://easings.net/#easeInCubic>
2#[inline]
3#[must_use]
4pub fn cubic_in(t: f32) -> f32 {
5	t * t * t
6}
7
8/// <https://easings.net/#easeOutCubic>
9#[inline]
10#[must_use]
11pub fn cubic_out(t: f32) -> f32 {
12	1.0 - (1.0 - t).powi(3)
13}
14
15/// <https://easings.net/#easeInOutCubic>
16#[inline]
17#[must_use]
18pub fn cubic_in_out(t: f32) -> f32 {
19	if t < 0.5 {
20		4.0 * t * t * t
21	} else {
22		1.0 - (-2.0f32).mul_add(t, 2.0).powi(3) / 2.0
23	}
24}