summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/vector.rs62
1 files changed, 61 insertions, 1 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index e0aa262..1d2ea93 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -1,4 +1,4 @@
-use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign};
+use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub, SubAssign};
use crate::color::Color;
@@ -14,6 +14,66 @@ impl Vec2<u32>
pub const ZERO: Self = Self { x: 0, y: 0 };
}
+impl<Value> Add<Value> for Vec2<Value>
+where
+ Value: Add<Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn add(self, rhs: Value) -> Self::Output
+ {
+ Self {
+ x: self.x + rhs.clone(),
+ y: self.y + rhs,
+ }
+ }
+}
+
+impl<Value> Sub<Value> for Vec2<Value>
+where
+ Value: Sub<Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn sub(self, rhs: Value) -> Self::Output
+ {
+ Self {
+ x: self.x - rhs.clone(),
+ y: self.y - rhs,
+ }
+ }
+}
+
+impl<Value> Mul<Value> for Vec2<Value>
+where
+ Value: Mul<Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn mul(self, rhs: Value) -> Self::Output
+ {
+ Self {
+ x: self.x * rhs.clone(),
+ y: self.y * rhs,
+ }
+ }
+}
+
+impl<Value> Div<Value> for Vec2<Value>
+where
+ Value: Div<Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn div(self, rhs: Value) -> Self::Output
+ {
+ Self {
+ x: self.x / rhs.clone(),
+ y: self.y / rhs,
+ }
+ }
+}
+
#[derive(Debug, Default, Clone)]
#[repr(C)]
pub struct Vec3<Value>