[librsvg: 8/10] rect: add translate method



commit e6b5442fbcaa0a82a6f24782075bb34acf4af560
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Nov 24 20:34:44 2019 +0100

    rect: add translate method

 rsvg_internals/src/rect.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/rsvg_internals/src/rect.rs b/rsvg_internals/src/rect.rs
index d2856a1d..31e187a8 100644
--- a/rsvg_internals/src/rect.rs
+++ b/rsvg_internals/src/rect.rs
@@ -10,6 +10,7 @@ pub trait RectangleExt {
     fn intersection(&self, rect: &cairo::Rectangle) -> Option<cairo::Rectangle>;
     fn union(&self, rect: &cairo::Rectangle) -> cairo::Rectangle;
     fn transform(&self, affine: &cairo::Matrix) -> cairo::Rectangle;
+    fn translate(&self, by: (f64, f64)) -> cairo::Rectangle;
     fn outer(&self) -> cairo::Rectangle;
 }
 
@@ -112,6 +113,15 @@ impl RectangleExt for cairo::Rectangle {
         }
     }
 
+    fn translate(&self, by: (f64, f64)) -> cairo::Rectangle {
+        cairo::Rectangle {
+            x: self.x + by.0,
+            y: self.y + by.1,
+            width: self.width,
+            height: self.height,
+        }
+    }
+
     fn outer(&self) -> cairo::Rectangle {
         let (x, y) = (self.x.floor(), self.y.floor());
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]