use bevy::reflect::Reflect;
use super::units::Units;
#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq)]
pub struct Corner {
pub top_left: Units,
pub top_right: Units,
pub bottom_left: Units,
pub bottom_right: Units,
}
impl Corner {
pub fn new(top_left: Units, top_right: Units, bottom_left: Units, bottom_right: Units) -> Self {
Self {
top_left,
top_right,
bottom_left,
bottom_right,
}
}
pub fn vertical(top: Units, bottom: Units) -> Self {
Self {
top_left: top,
top_right: top,
bottom_left: bottom,
bottom_right: bottom,
}
}
pub fn horizontal(left: Units, right: Units) -> Self {
Self {
top_left: left,
top_right: right,
bottom_left: left,
bottom_right: right,
}
}
pub fn all(value: impl Into<Units> + Copy) -> Self {
Self {
top_left: value.into(),
top_right: value.into(),
bottom_left: value.into(),
bottom_right: value.into(),
}
}
pub fn into_tuple(self) -> (Units, Units, Units, Units) {
(
self.top_left,
self.top_right,
self.bottom_left,
self.bottom_right,
)
}
pub fn top_left(mut self, value: impl Into<Units> + Copy) -> Self {
self.top_left = value.into();
self
}
pub fn top_right(mut self, value: impl Into<Units> + Copy) -> Self {
self.top_right = value.into();
self
}
pub fn bottom_left(mut self, value: impl Into<Units> + Copy) -> Self {
self.bottom_left = value.into();
self
}
pub fn bottom_right(mut self, value: impl Into<Units> + Copy) -> Self {
self.bottom_right = value.into();
self
}
}
impl From<Corner> for (Units, Units, Units, Units) {
fn from(edge: Corner) -> Self {
edge.into_tuple()
}
}
impl From<(Units, Units, Units, Units)> for Corner {
fn from(value: (Units, Units, Units, Units)) -> Self {
Corner::new(value.0, value.1, value.2, value.3)
}
}