use kurbo::Vec2;
use std::ops::{Mul, MulAssign};
#[derive(Clone, Copy, Default, Debug, PartialEq)]
pub struct NonUniformRoundedRectRadii {
pub top_left: Vec2,
pub top_right: Vec2,
pub bottom_right: Vec2,
pub bottom_left: Vec2,
}
impl NonUniformRoundedRectRadii {
pub fn average(&self) -> f64 {
(self.top_left.x
+ self.top_left.y
+ self.top_right.x
+ self.top_right.y
+ self.bottom_left.x
+ self.bottom_left.y
+ self.bottom_right.x
+ self.bottom_right.y)
/ 8.0
}
}
impl Mul<f64> for NonUniformRoundedRectRadii {
type Output = Self;
fn mul(self, rhs: f64) -> Self::Output {
Self {
top_left: self.top_left * rhs,
top_right: self.top_right * rhs,
bottom_right: self.bottom_right * rhs,
bottom_left: self.bottom_left * rhs,
}
}
}
impl MulAssign<f64> for NonUniformRoundedRectRadii {
fn mul_assign(&mut self, rhs: f64) {
self.top_left *= rhs;
self.top_right *= rhs;
self.bottom_left *= rhs;
self.bottom_right *= rhs;
}
}