1pub mod emergence;
2pub mod highlight;
3pub mod delete;
4pub mod transform;
5pub mod funcs;
6
7#[macro_export]
8macro_rules! define_animation
9{
10 ($name:ident, $anim_name:ident $(,)?
11 $($field:ident: $ftype:ty = $fdef:expr),* $(,)?) =>
12 {
13 use $crate::core::
14 {
15 ProgressFunc,
16 Vertex,
17 Indices,
18 Color,
19 AnimationKind,
20 PackedAnimation,
21 DEFAULT_PROGRESS_FUNC
22 };
23 use $crate::draw::Tessellation;
24 use std::sync::{Arc, Mutex};
25
26 #[derive(Clone, Debug)]
27 pub struct $name
28 {
29 pub progress: f32,
30 pub func: ProgressFunc,
31 $(
32 pub $field: $ftype,
33 )*
34 }
35
36 impl Default for $name
37 {
38 fn default() -> Self
39 {
40 Self
41 {
42 progress: 0.0,
43 func: DEFAULT_PROGRESS_FUNC,
44 $(
45 $field: $fdef,
46 )*
47 }
48 }
49 }
50
51 impl AnimationKind for $name
52 {
53 fn generate
54 (
55 self,
56 tessellation: Tessellation
57 ) -> PackedAnimation
58 {
59 Arc::new(
60 Mutex::new(
61 $anim_name
62 {
63 tessellation, data: self
64 }
65 ))
66 }
67 }
68
69 #[derive(Debug, Clone, Default)]
70 pub(crate) struct $anim_name
71 {
72 tessellation: Tessellation,
73 data: $name,
74 }
75
76 };
77}
78
79pub mod dummy
80{
81 use crate::core::Animation;
82
83 define_animation!(Dummy, DummyAnimation);
84
85 impl Animation for DummyAnimation
86 {
87 #[inline]
88 fn set_progress(&mut self, progress: f32) { self.data.progress = progress }
89
90 #[inline]
91 fn get_progress(&self) -> f32 { self.data.progress }
92
93 #[inline]
94 fn get_vertices(&self) -> Vec<Vertex> { self.tessellation.vertices.clone() }
95
96 #[inline]
97 fn get_indices(&self) -> Indices { self.tessellation.indices.clone() }
98
99 #[inline]
100 fn get_colors(&self) -> Vec<Color> { self.tessellation.colors.clone() }
101 }
102}