Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion core/src/border.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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<f32> for Radius {
fn from(radius: f32) -> Self {
Self {
Expand Down
Loading