From 068363a87c009091adfde699865a596ad4ecf972 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Wed, 27 Mar 2024 15:22:17 +0100 Subject: [PATCH] swf: Add Rectangle::grow method --- swf/src/types/rectangle.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/swf/src/types/rectangle.rs b/swf/src/types/rectangle.rs index edd5b11db..2479290ff 100644 --- a/swf/src/types/rectangle.rs +++ b/swf/src/types/rectangle.rs @@ -130,6 +130,17 @@ impl Rectangle { && self.y_min <= other.y_max && 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 Default for Rectangle {