aboutsummaryrefslogtreecommitdiff
path: root/src/core/bound.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-09 20:00:52 +0100
committerJulian T <julian@jtle.dk>2021-02-09 20:00:52 +0100
commit3a144c8c1fc83150fc06d792082db5cc4bce3cc5 (patch)
treee408c35a782c8595f2704c4d4dbff3424035ce82 /src/core/bound.rs
parentbb5d37b3685ae8da38865f837cf697dac0055b9d (diff)
Add tiling for rendering
Diffstat (limited to 'src/core/bound.rs')
-rw-r--r--src/core/bound.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/bound.rs b/src/core/bound.rs
index a1c1070..404424e 100644
--- a/src/core/bound.rs
+++ b/src/core/bound.rs
@@ -45,6 +45,15 @@ impl<T: Number> Bound2<T> {
)
}
+ /// Finds the intersected area between two bounds
+ pub fn intersect(&self, b: &Bound2<T>) -> Bound2<T> {
+ Bound2::new(
+ &Vector2::new_xy(max(self.min.x, b.min.x), max(self.min.y, b.min.y)),
+ &Vector2::new_xy(min(self.max.x, b.max.x), min(self.max.y, b.max.y)),
+ )
+ }
+
+
/// Calculates the diagonal vector
///
/// Can be used to calculate the size of the bound
@@ -96,14 +105,6 @@ impl From<&Bound2f> for Bound2i {
}
}
-/// Finds the intersected area between two bounds
-pub fn intersect<T: Number>(a: &Bound2<T>, b: &Bound2<T>) -> Bound2<T> {
- Bound2::new(
- &Vector2::new_xy(max(a.min.x, b.min.x), max(a.min.y, b.min.y)),
- &Vector2::new_xy(min(a.max.x, b.max.x), min(a.max.y, b.max.y)),
- )
-}
-
#[cfg(test)]
mod tests {
use super::*;