easey/
easey.rs

1pub trait Easey {
2    fn inverse(self) -> Self;
3
4    fn minmaxp(self) -> Self;
5    fn minmax(self, min: Self, max: Self) -> Self;
6
7    fn pre_delay(self, point: Self) -> Self;
8    fn post_delay(self, point: Self) -> Self;
9
10    fn ease_in(self) -> Self;
11    fn ease_in_quad(self) -> Self;
12    fn ease_in_cubic(self) -> Self;
13    fn ease_in_quart(self) -> Self;
14    fn ease_in_quint(self) -> Self;
15    fn ease_in_sine(self) -> Self;
16    fn ease_in_expo(self) -> Self;
17    fn ease_in_circ(self) -> Self;
18    fn ease_in_back(self) -> Self;
19
20    fn ease_out(self) -> Self;
21    fn ease_out_quad(self) -> Self;
22    fn ease_out_cubic(self) -> Self;
23    fn ease_out_quart(self) -> Self;
24    fn ease_out_quint(self) -> Self;
25    fn ease_out_sine(self) -> Self;
26    fn ease_out_expo(self) -> Self;
27    fn ease_out_circ(self) -> Self;
28    fn ease_out_back(self) -> Self;
29
30    fn ease_in_out(self) -> Self;
31    fn ease_in_out_quad(self) -> Self;
32    fn ease_in_out_cubic(self) -> Self;
33    fn ease_in_out_quart(self) -> Self;
34    fn ease_in_out_quint(self) -> Self;
35    fn ease_in_out_sine(self) -> Self;
36    fn ease_in_out_expo(self) -> Self;
37    fn ease_in_out_circ(self) -> Self;
38    fn ease_in_out_back(self) -> Self;
39
40    fn square_wave(self, wave_duration: Self) -> Self;
41    fn square_wave_as_bool(self, wave_duration: Self) -> bool;
42
43    fn sin_wave(self) -> Self;
44    fn cos_wave(self) -> Self;
45    fn tan_wave(self) -> Self;
46}
47
48macro_rules! impl_timing_trait {
49    ( $fxx:ident ) => {
50        impl Easey for $fxx {
51            #[inline(always)]
52            fn inverse(self) -> Self {
53                crate::$fxx::inverse(self)
54            }
55
56            #[inline(always)]
57            fn minmaxp(self) -> Self {
58                crate::$fxx::minmaxp(self)
59            }
60
61            #[inline(always)]
62            fn minmax(self, min: Self, max: Self) -> Self {
63                crate::$fxx::minmax(self, min, max)
64            }
65
66            #[inline(always)]
67            fn pre_delay(self, delay_point: Self) -> Self {
68                crate::$fxx::pre_delay(self, delay_point)
69            }
70
71            #[inline(always)]
72            fn post_delay(self, delay_point: Self) -> Self {
73                crate::$fxx::post_delay(self, delay_point)
74            }
75
76            #[inline(always)]
77            fn ease_in(self) -> Self {
78                crate::$fxx::ease_in(self)
79            }
80
81            #[inline(always)]
82            fn ease_in_quad(self) -> Self {
83                crate::$fxx::ease_in_quad(self)
84            }
85
86            #[inline(always)]
87            fn ease_in_cubic(self) -> Self {
88                crate::$fxx::ease_in_cubic(self)
89            }
90
91            #[inline(always)]
92            fn ease_in_quart(self) -> Self {
93                crate::$fxx::ease_in_quart(self)
94            }
95
96            #[inline(always)]
97            fn ease_in_quint(self) -> Self {
98                crate::$fxx::ease_in_quint(self)
99            }
100
101            #[inline(always)]
102            fn ease_in_sine(self) -> Self {
103                crate::$fxx::ease_in_sine(self)
104            }
105
106            #[inline(always)]
107            fn ease_in_expo(self) -> Self {
108                crate::$fxx::ease_in_expo(self)
109            }
110
111            #[inline(always)]
112            fn ease_in_circ(self) -> Self {
113                crate::$fxx::ease_in_circ(self)
114            }
115
116            #[inline(always)]
117            fn ease_in_back(self) -> Self {
118                crate::$fxx::ease_in_back(self)
119            }
120
121            #[inline(always)]
122            fn ease_out(self) -> Self {
123                crate::$fxx::ease_out(self)
124            }
125
126            #[inline(always)]
127            fn ease_out_quad(self) -> Self {
128                crate::$fxx::ease_out_quad(self)
129            }
130
131            #[inline(always)]
132            fn ease_out_cubic(self) -> Self {
133                crate::$fxx::ease_out_cubic(self)
134            }
135
136            #[inline(always)]
137            fn ease_out_quart(self) -> Self {
138                crate::$fxx::ease_out_quart(self)
139            }
140
141            #[inline(always)]
142            fn ease_out_quint(self) -> Self {
143                crate::$fxx::ease_out_quint(self)
144            }
145
146            #[inline(always)]
147            fn ease_out_sine(self) -> Self {
148                crate::$fxx::ease_out_sine(self)
149            }
150
151            #[inline(always)]
152            fn ease_out_expo(self) -> Self {
153                crate::$fxx::ease_out_expo(self)
154            }
155
156            #[inline(always)]
157            fn ease_out_circ(self) -> Self {
158                crate::$fxx::ease_out_circ(self)
159            }
160
161            #[inline(always)]
162            fn ease_out_back(self) -> Self {
163                crate::$fxx::ease_out_back(self)
164            }
165
166            #[inline(always)]
167            fn ease_in_out(self) -> Self {
168                crate::$fxx::ease_in_out(self)
169            }
170
171            #[inline(always)]
172            fn ease_in_out_quad(self) -> Self {
173                crate::$fxx::ease_in_out_quad(self)
174            }
175
176            #[inline(always)]
177            fn ease_in_out_cubic(self) -> Self {
178                crate::$fxx::ease_in_out_cubic(self)
179            }
180
181            #[inline(always)]
182            fn ease_in_out_quart(self) -> Self {
183                crate::$fxx::ease_in_out_quart(self)
184            }
185
186            #[inline(always)]
187            fn ease_in_out_quint(self) -> Self {
188                crate::$fxx::ease_in_out_quint(self)
189            }
190
191            #[inline(always)]
192            fn ease_in_out_sine(self) -> Self {
193                crate::$fxx::ease_in_out_sine(self)
194            }
195
196            #[inline(always)]
197            fn ease_in_out_expo(self) -> Self {
198                crate::$fxx::ease_in_out_expo(self)
199            }
200
201            #[inline(always)]
202            fn ease_in_out_circ(self) -> Self {
203                crate::$fxx::ease_in_out_circ(self)
204            }
205
206            #[inline(always)]
207            fn ease_in_out_back(self) -> Self {
208                crate::$fxx::ease_in_out_back(self)
209            }
210
211            #[inline(always)]
212            fn square_wave(self, wave_duration: $fxx) -> Self {
213                crate::$fxx::square_wave(self, wave_duration)
214            }
215
216            #[inline(always)]
217            fn square_wave_as_bool(self, wave_duration: $fxx) -> bool {
218                crate::$fxx::square_wave_as_bool(self, wave_duration)
219            }
220
221            #[inline(always)]
222            fn sin_wave(self) -> Self {
223                crate::$fxx::sin_wave(self)
224            }
225
226            #[inline(always)]
227            fn cos_wave(self) -> Self {
228                crate::$fxx::cos_wave(self)
229            }
230
231            #[inline(always)]
232            fn tan_wave(self) -> Self {
233                crate::$fxx::tan_wave(self)
234            }
235        }
236    };
237}
238
239impl_timing_trait!(f32);
240impl_timing_trait!(f64);