From 3a859ec55111c666f95067c506238ea9287f10f9 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 23 Dec 2014 08:11:27 -0800 Subject: [PATCH] Add a new method, `translate_by_size`, to rectangles --- src/rect.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rect.rs b/src/rect.rs index 776f0e0..1922d38 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -115,6 +115,11 @@ impl + Sub> Rect { size: Size2D(self.size.width + width + width, self.size.height + height + height), } } + + #[inline] + pub fn translate_by_size(&self, size: &Size2D) -> Rect { + Rect(Point2D(self.origin.x + size.width, self.origin.y + size.height), self.size.clone()) + } } impl> Rect {