From 9d7986bbfd44b69a623fa29528b5d13000b91c77 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 7 Dec 2022 20:38:00 +0100 Subject: advanced translate --- evc/src/helpers/vector.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'evc/src/helpers/vector.rs') 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 + Copy> Vec2 { } } +impl Vec2 { + 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> for Vec2 { + fn into(self) -> Vec2 { + Vec2 { + x: self.x as f32, + y: self.y as f32, + } + } +} +impl From<(isize, isize)> for Vec2 { + fn from((x, y): (isize, isize)) -> Self { + Vec2 { + x: x as f32, + y: y as f32, + } + } +} + impl std::ops::Add for Vec2 { type Output = Vec2; #[inline] -- cgit v1.2.3-70-g09d2