euv_chart/animation/struct.rs
1use super::*;
2
3/// Animates the values of a chart's series.
4///
5/// The animator keeps the values the chart showed last and the values it
6/// should show now, and interpolates between them. The chart's layout
7/// is recomputed on every frame of the animation, so the shapes really
8/// move rather than jumping at the end.
9///
10/// The clock and the easing come from `euv-engine`: the chart's motion
11/// is the framework's motion, down to the delay and the pause. The
12/// engine's tween counts in seconds and the chart's API counts in
13/// milliseconds, and the conversion happens here and nowhere else.
14#[derive(Clone, Data, Debug)]
15pub struct Animator {
16 /// The values each series animates from.
17 #[get(pub(crate))]
18 #[get_mut(pub(crate))]
19 #[set(pub(crate))]
20 pub(crate) from: Vec<Vec<f64>>,
21 /// The values each series animates to.
22 #[get(pub(crate))]
23 #[get_mut(pub(crate))]
24 #[set(pub(crate))]
25 pub(crate) to: Vec<Vec<f64>>,
26 /// The values the chart shows right now.
27 #[get(pub(crate))]
28 #[get_mut(pub(crate))]
29 #[set(pub(crate))]
30 pub(crate) current: Vec<Vec<f64>>,
31 /// The tween that drives the progress of the animation.
32 ///
33 /// The tween carries the clock, the easing, and the delay. It runs
34 /// from zero to one, and the chart interpolates its own values with
35 /// the progress it reports.
36 #[get(pub(crate))]
37 #[get_mut(pub(crate))]
38 #[set(pub(crate))]
39 pub(crate) tween: Tween<f64>,
40 /// The duration of one animation, in milliseconds.
41 #[get(pub(crate), type(copy))]
42 #[get_mut(pub(crate))]
43 #[set(skip)]
44 pub(crate) duration: f64,
45 /// The delay before the animation starts, in milliseconds.
46 #[get(pub(crate), type(copy))]
47 #[get_mut(pub(crate))]
48 #[set(skip)]
49 pub(crate) delay: f64,
50 /// The option the chart was created with, for the restore action.
51 #[get(pub(crate))]
52 #[get_mut(pub(crate))]
53 #[set(pub(crate))]
54 pub(crate) initial: Option<ChartOption>,
55}