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