eazy_data/easing/logarithmic/
log10.rs1use crate::easing::Curve;
4
5use libm::log10f;
6
7#[derive(Debug)]
18pub struct InLog10;
19
20impl Curve for InLog10 {
21 #[inline(always)]
22 fn y(&self, p: f32) -> f32 {
23 1.0 - OutLog10.y(1.0 - p)
24 }
25}
26
27#[test]
28fn test_in_log10() {
29 let p = InLog10.y(1.0);
30
31 assert_eq!(p, 1.0);
32}
33
34#[derive(Debug)]
45pub struct OutLog10;
46
47impl Curve for OutLog10 {
48 #[inline(always)]
49 fn y(&self, p: f32) -> f32 {
50 log10f((p * 9.0) + 1.0)
51 }
52}
53
54#[test]
55fn test_out_log10() {
56 let p = OutLog10.y(1.0);
57
58 assert_eq!(p, 1.0);
59}
60
61#[derive(Debug)]
72pub struct InOutLog10;
73
74impl Curve for InOutLog10 {
75 #[inline(always)]
76 fn y(&self, p: f32) -> f32 {
77 let t = p * 2.0;
78
79 if t < 1.0 {
80 return 0.5 - 0.5 * OutLog10.y(1.0 - t);
81 }
82
83 0.5 + 0.5 * OutLog10.y(t - 1.0)
84 }
85}
86
87#[test]
88fn test_in_out_log10() {
89 let p = InOutLog10.y(1.0);
90
91 assert_eq!(p, 1.0);
92}