Group damage regions by area increase
This commit is contained in:
parent
6270c33ed9
commit
f8cd1faa28
4 changed files with 199 additions and 108 deletions
|
|
@ -66,6 +66,11 @@ impl Rectangle<f32> {
|
|||
Size::new(self.width, self.height)
|
||||
}
|
||||
|
||||
/// Returns the area of the [`Rectangle`].
|
||||
pub fn area(&self) -> f32 {
|
||||
self.width * self.height
|
||||
}
|
||||
|
||||
/// Returns true if the given [`Point`] is contained in the [`Rectangle`].
|
||||
pub fn contains(&self, point: Point) -> bool {
|
||||
self.x <= point.x
|
||||
|
|
@ -74,6 +79,15 @@ impl Rectangle<f32> {
|
|||
&& point.y <= self.y + self.height
|
||||
}
|
||||
|
||||
/// Returns true if the current [`Rectangle`] is completely within the given
|
||||
/// `container`.
|
||||
pub fn is_within(&self, container: &Rectangle) -> bool {
|
||||
container.contains(self.position())
|
||||
&& container.contains(
|
||||
self.position() + Vector::new(self.width, self.height),
|
||||
)
|
||||
}
|
||||
|
||||
/// Computes the intersection with the given [`Rectangle`].
|
||||
pub fn intersection(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue