use crate::easing::Curve;
#[derive(Debug)]
pub struct InCubic;
impl Curve for InCubic {
#[inline]
fn y(&self, p: f32) -> f32 {
p * p * p
}
}
#[test]
fn test_in_cubic() {
let p = InCubic.y(1.0);
assert_eq!(p, 1.0);
}
#[derive(Debug)]
pub struct OutCubic;
impl Curve for OutCubic {
#[inline]
fn y(&self, p: f32) -> f32 {
let m = p - 1.0;
1.0 + m * m * m
}
}
#[test]
fn test_out_cubic() {
let p = OutCubic.y(1.0);
assert_eq!(p, 1.0);
}
#[derive(Debug)]
pub struct InOutCubic;
impl Curve for InOutCubic {
#[inline]
fn y(&self, p: f32) -> f32 {
let m = p - 1.0;
let t = p * 2.0;
if t < 1.0 {
return p * t * t;
}
1.0 + m * m * m * 4.0
}
}
#[test]
fn test_in_out_cubic() {
let p = InOutCubic.y(1.0);
assert_eq!(p, 1.0);
}