aboutsummaryrefslogtreecommitdiff
path: root/evc/src/helpers/vector.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-12-07 20:38:00 +0100
committermetamuffin <metamuffin@disroot.org>2022-12-07 20:38:00 +0100
commit9d7986bbfd44b69a623fa29528b5d13000b91c77 (patch)
tree8da95f328243a96acec6c3ea6ebddc71bb63f05c /evc/src/helpers/vector.rs
parent7be0d5039db7e8660bced13698178bf1d6758109 (diff)
downloadvideo-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar
video-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar.bz2
video-codec-experiments-9d7986bbfd44b69a623fa29528b5d13000b91c77.tar.zst
advanced translate
Diffstat (limited to 'evc/src/helpers/vector.rs')
-rw-r--r--evc/src/helpers/vector.rs26
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]