use bevy_reflect::Reflect;
#[derive(Default, Copy, Clone, PartialEq, Debug, Reflect)]
pub struct BorderRect {
pub left: f32,
pub right: f32,
pub top: f32,
pub bottom: f32,
}
impl BorderRect {
pub const ZERO: Self = Self::square(0.);
#[must_use]
#[inline]
pub const fn square(value: f32) -> Self {
Self {
left: value,
right: value,
top: value,
bottom: value,
}
}
#[must_use]
#[inline]
pub const fn rectangle(horizontal: f32, vertical: f32) -> Self {
Self {
left: horizontal,
right: horizontal,
top: vertical,
bottom: vertical,
}
}
}
impl From<f32> for BorderRect {
fn from(v: f32) -> Self {
Self::square(v)
}
}
impl From<[f32; 4]> for BorderRect {
fn from([left, right, top, bottom]: [f32; 4]) -> Self {
Self {
left,
right,
top,
bottom,
}
}
}