use crate::easing::Curve;
use libm::log10f;
#[derive(Debug)]
pub struct InLog10;
impl Curve for InLog10 {
#[inline]
fn y(&self, p: f32) -> f32 {
1.0 - OutLog10.y(1.0 - p)
}
}
#[test]
fn test_in_log10() {
let p = InLog10.y(1.0);
assert_eq!(p, 1.0);
}
#[derive(Debug)]
pub struct OutLog10;
impl Curve for OutLog10 {
#[inline]
fn y(&self, p: f32) -> f32 {
log10f((p * 9.0) + 1.0)
}
}
#[test]
fn test_out_log10() {
let p = OutLog10.y(1.0);
assert_eq!(p, 1.0);
}
#[derive(Debug)]
pub struct InOutLog10;
impl Curve for InOutLog10 {
#[inline]
fn y(&self, p: f32) -> f32 {
let t = p * 2.0;
if t < 1.0 {
return 0.5 - 0.5 * OutLog10.y(1.0 - t);
}
0.5 + 0.5 * OutLog10.y(t - 1.0)
}
}
#[test]
fn test_in_out_log10() {
let p = InOutLog10.y(1.0);
assert_eq!(p, 1.0);
}