summaryrefslogtreecommitdiffstats
path: root/core/src/rectangle.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/rectangle.rs')
-rw-r--r--core/src/rectangle.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/src/rectangle.rs b/core/src/rectangle.rs
index 7ff324cb..c1c2eeac 100644
--- a/core/src/rectangle.rs
+++ b/core/src/rectangle.rs
@@ -74,9 +74,9 @@ impl Rectangle<f32> {
/// Returns true if the given [`Point`] is contained in the [`Rectangle`].
pub fn contains(&self, point: Point) -> bool {
self.x <= point.x
- && point.x <= self.x + self.width
+ && point.x < self.x + self.width
&& self.y <= point.y
- && point.y <= self.y + self.height
+ && point.y < self.y + self.height
}
/// Returns true if the current [`Rectangle`] is completely within the given
@@ -197,3 +197,18 @@ where
}
}
}
+
+impl<T> std::ops::Sub<Vector<T>> for Rectangle<T>
+where
+ T: std::ops::Sub<Output = T>,
+{
+ type Output = Rectangle<T>;
+
+ fn sub(self, translation: Vector<T>) -> Self {
+ Rectangle {
+ x: self.x - translation.x,
+ y: self.y - translation.y,
+ ..self
+ }
+ }
+}