diff --git a/core/src/border.rs b/core/src/border.rs index 232211db73..c0afc80667 100644 --- a/core/src/border.rs +++ b/core/src/border.rs @@ -1,5 +1,5 @@ //! Draw lines around containers. -use crate::{Color, Pixels}; +use crate::{Color, Pixels, animation::Interpolable}; /// A border. #[derive(Debug, Clone, Copy, PartialEq, Default)] @@ -75,6 +75,16 @@ impl Border { } } +impl Interpolable for Border { + fn interpolated(&self, other: Self, ratio: f32) -> Self { + Self { + color: self.color.interpolated(other.color, ratio), + width: self.width.interpolated(other.width, ratio), + radius: self.radius.interpolated(other.radius, ratio), + } + } +} + /// The border radii for the corners of a graphics primitive in the order: /// top-left, top-right, bottom-right, bottom-left. #[derive(Debug, Clone, Copy, PartialEq, Default)] @@ -224,6 +234,17 @@ impl Radius { } } +impl Interpolable for Radius { + fn interpolated(&self, other: Self, ratio: f32) -> Self { + Self { + top_left: self.top_left.interpolated(other.top_left, ratio), + top_right: self.top_right.interpolated(other.top_right, ratio), + bottom_left: self.bottom_left.interpolated(other.bottom_left, ratio), + bottom_right: self.bottom_right.interpolated(other.bottom_right, ratio), + } + } +} + impl From for Radius { fn from(radius: f32) -> Self { Self {