pub trait UINum { fn to_f32(self) -> f32; } impl UINum for f32 { fn to_f32(self) -> f32 { self } } impl UINum for u32 { fn to_f32(self) -> f32 { self as f32 } } impl UINum for i32 { fn to_f32(self) -> f32 { self as f32 } } #[derive(Copy, Clone, Eq, PartialEq)] pub enum Axis { X, Y, } #[derive(Clone, Copy, Eq, PartialEq)] pub struct Dir { pub axis: Axis, pub sign: Sign, } impl Dir { pub const fn new(axis: Axis, dir: Sign) -> Self { Self { axis, sign: dir } } pub const LEFT: Self = Self::new(Axis::X, Sign::Neg); pub const RIGHT: Self = Self::new(Axis::X, Sign::Pos); pub const UP: Self = Self::new(Axis::Y, Sign::Neg); pub const DOWN: Self = Self::new(Axis::Y, Sign::Pos); } #[derive(Clone, Copy, Eq, PartialEq)] pub enum Sign { Neg, Pos, }