Skip to main content

ferroui_base/animation/animators/
vector_animator.rs

1use crate::Vector;
2use crate::animation::animators::{Animator, AnimatorBase};
3
4/// Animator that handles [`Vector`] properties.
5#[derive(Default)]
6pub struct VectorAnimator {
7    base: AnimatorBase,
8}
9
10impl VectorAnimator {
11    pub fn new() -> Self {
12        Self::default()
13    }
14
15    /// Interpolates between two values using the specified progress.
16    #[inline]
17    pub fn interpolate_core(progress: f64, old_value: &Vector, new_value: &Vector) -> Vector {
18        ((*new_value - *old_value) * progress) + *old_value
19    }
20}
21
22impl Animator for VectorAnimator {
23    type Value = Vector;
24
25    fn base(&self) -> &AnimatorBase {
26        &self.base
27    }
28
29    #[inline]
30    fn interpolate(&self, progress: f64, old_value: &Vector, new_value: &Vector) -> Vector {
31        Self::interpolate_core(progress, old_value, new_value)
32    }
33}