Skip to main content

glissade/
lib.rs

1#![doc = include_str!("../README.md")]
2
3mod animation;
4mod easing;
5mod inertial;
6mod mix;
7mod stationary;
8mod time;
9
10mod animated;
11mod distance;
12mod impls;
13mod poly;
14mod smooth_array;
15
16pub use animated::Animated;
17pub use animation::Animation;
18pub use animation::{keyframes, Keyframes};
19pub use distance::Distance;
20pub use easing::Easing;
21pub use inertial::Inertial;
22pub use mix::Mix;
23pub use stationary::Stationary;
24pub use time::Time;
25
26#[cfg(feature = "derive")]
27pub use glissade_macro::Mix;
28
29#[cfg(test)]
30#[cfg(feature = "derive")]
31mod tests {
32    use crate as glissade;
33    use crate::Mix;
34
35    #[derive(Mix, PartialEq, Debug)]
36    struct Point {
37        x: f32,
38        y: f32,
39    }
40
41    #[test]
42    fn test_struct_derive() {
43        let p1 = Point { x: 0.0, y: 0.0 };
44        let p2 = Point { x: 1.0, y: 1.0 };
45        let p3 = p1.mix(p2, 0.5);
46        assert_eq!(p3, Point { x: 0.5, y: 0.5 });
47    }
48
49    #[derive(Mix, PartialEq, Debug)]
50    struct Color(f32, f32, f32);
51
52    #[test]
53    fn test_tuple_derive() {
54        let c1 = Color(0.0, 0.0, 0.0);
55        let c2 = Color(1.0, 1.0, 1.0);
56        let c3 = c1.mix(c2, 0.5);
57        assert_eq!(c3, Color(0.5, 0.5, 0.5));
58    }
59
60    #[derive(Mix, PartialEq, Debug)]
61    struct Size<T: Mix>
62    where
63        T: Clone + Copy,
64    {
65        width: T,
66        height: T,
67    }
68
69    #[test]
70    fn test_generics_derive() {
71        let s1 = Size {
72            width: 0.0,
73            height: 0.0,
74        };
75        let s2 = Size {
76            width: 1.0,
77            height: 1.0,
78        };
79        let s3 = s1.mix(s2, 0.5);
80        assert_eq!(
81            s3,
82            Size {
83                width: 0.5,
84                height: 0.5,
85            }
86        );
87    }
88}