1
1
Fork 0
mirror of https://github.com/griffi-gh/hUI.git synced 2025-04-10 17:57:20 -05:00

add glam-specific functions to Sides

This commit is contained in:
griffi-gh 2025-03-31 13:45:46 +02:00
parent 6afcd8ee29
commit 7f6f5a2ba1

View file

@ -44,6 +44,49 @@ impl<T: Add + Clone> Sides<T> {
}
}
macro_rules! impl_sides_glam_fns {
(
$($numeric_type:ty => $glam_type:ty),*
$(,)?
) => {
$(
impl Sides<$numeric_type> {
pub fn top_left(&self) -> $glam_type {
<$glam_type>::new(self.left, self.top)
}
pub fn top_right(&self) -> $glam_type {
<$glam_type>::new(self.right, self.top)
}
pub fn bottom_left(&self) -> $glam_type {
<$glam_type>::new(self.left, self.bottom)
}
pub fn bottom_right(&self) -> $glam_type {
<$glam_type>::new(self.right, self.bottom)
}
}
)*
};
}
impl_sides_glam_fns!(
f32 => glam::Vec2,
f64 => glam::DVec2,
u8 => glam::U8Vec2,
u16 => glam::U16Vec2,
u32 => glam::UVec2,
u64 => glam::U64Vec2,
i8 => glam::I8Vec2,
i16 => glam::I16Vec2,
i32 => glam::IVec2,
i64 => glam::I64Vec2,
);
impl<T: Clone> From<T> for Sides<T> {
fn from(value: T) -> Self {
Self::all(value)