diff options
Diffstat (limited to 'evc/src/helpers/vector.rs')
-rw-r--r-- | evc/src/helpers/vector.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/evc/src/helpers/vector.rs b/evc/src/helpers/vector.rs index 4daa849..12243e4 100644 --- a/evc/src/helpers/vector.rs +++ b/evc/src/helpers/vector.rs @@ -24,6 +24,32 @@ impl<T: std::ops::Div<Output = T> + Copy> Vec2<T> { } } +impl Vec2<isize> { + pub fn x_only(&self) -> Self { + Self { x: self.x, y: 0 } + } + pub fn y_only(&self) -> Self { + Self { x: self.x, y: 0 } + } +} + +impl Into<Vec2<f32>> for Vec2<isize> { + fn into(self) -> Vec2<f32> { + Vec2 { + x: self.x as f32, + y: self.y as f32, + } + } +} +impl From<(isize, isize)> for Vec2<f32> { + fn from((x, y): (isize, isize)) -> Self { + Vec2 { + x: x as f32, + y: y as f32, + } + } +} + impl<T: std::ops::Add> std::ops::Add for Vec2<T> { type Output = Vec2<T::Output>; #[inline] |