swf: Add Rectangle::grow method

This commit is contained in:
Kamil Jarosz 2024-03-27 15:22:17 +01:00 committed by TÖRÖK Attila
parent 1a250f0144
commit 068363a87c
1 changed files with 11 additions and 0 deletions

View File

@ -130,6 +130,17 @@ impl<T: Coordinate> Rectangle<T> {
&& self.y_min <= other.y_max && self.y_min <= other.y_max
&& self.y_max >= other.y_min && self.y_max >= other.y_min
} }
#[must_use]
pub fn grow(mut self, amount: T) -> Self {
if self.is_valid() {
self.x_min -= amount;
self.x_max += amount;
self.y_min -= amount;
self.y_max += amount;
}
self
}
} }
impl<T: Coordinate> Default for Rectangle<T> { impl<T: Coordinate> Default for Rectangle<T> {