rust/integral-geometry/src/lib.rs
branchtransitional_engine
changeset 16056 d4675c190fa5
parent 16051 2003b466b279
child 16061 31cc1e450273
equal deleted inserted replaced
16055:ce4b50823a95 16056:d4675c190fa5
   494         (self.top_left() + self.bottom_right()) / 2
   494         (self.top_left() + self.bottom_right()) / 2
   495     }
   495     }
   496 
   496 
   497     #[inline]
   497     #[inline]
   498     pub fn with_margin(&self, margin: i32) -> Self {
   498     pub fn with_margin(&self, margin: i32) -> Self {
   499         let offset = Point::diag(margin);
   499         let offset = Point::new(min(margin, self.width() as i32 / 2), min(margin, self.height() as i32 / 2));
   500         Self::new(self.top_left() + offset, self.bottom_right() - offset)
   500         Self::new(self.top_left() + offset, self.bottom_right() - offset)
   501     }
   501     }
   502 
   502 
   503     #[inline]
   503     #[inline]
   504     pub const fn x_range(&self) -> RangeInclusive<i32> {
   504     pub const fn x_range(&self) -> RangeInclusive<i32> {