rust/integral-geometry/src/lib.rs
branchtransitional_engine
changeset 16056 d4675c190fa5
parent 16051 2003b466b279
child 16061 31cc1e450273
--- a/rust/integral-geometry/src/lib.rs	Thu Aug 29 17:09:39 2024 +0200
+++ b/rust/integral-geometry/src/lib.rs	Tue Sep 03 11:16:16 2024 +0200
@@ -496,7 +496,7 @@
 
     #[inline]
     pub fn with_margin(&self, margin: i32) -> Self {
-        let offset = Point::diag(margin);
+        let offset = Point::new(min(margin, self.width() as i32 / 2), min(margin, self.height() as i32 / 2));
         Self::new(self.top_left() + offset, self.bottom_right() - offset)
     }