ranim_core/components/
width.rs

1use derive_more::From;
2
3use crate::prelude::Interpolatable;
4
5/// Width
6#[repr(C)]
7#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable, From)]
8pub struct Width(pub f32);
9
10impl Width {
11    /// Max
12    pub fn max(self, other: Self) -> Self {
13        Self(self.0.max(other.0))
14    }
15    /// Min
16    pub fn min(self, other: Self) -> Self {
17        Self(self.0.min(other.0))
18    }
19}
20
21impl Default for Width {
22    fn default() -> Self {
23        1.0.into()
24    }
25}
26
27impl Interpolatable for Width {
28    fn lerp(&self, target: &Self, t: f64) -> Self {
29        Self(self.0.lerp(&target.0, t))
30    }
31}