diff --git a/crates/emath/src/rect.rs b/crates/emath/src/rect.rs index f01387c1..215aed53 100644 --- a/crates/emath/src/rect.rs +++ b/crates/emath/src/rect.rs @@ -287,6 +287,33 @@ impl Rect { p.clamp(self.min, self.max) } + /// Floor the rect coordinates + #[inline(always)] + pub fn floor(self) -> Self { + Self { + min: self.min.floor(), + max: self.max.floor(), + } + } + + /// Round the rect coordinates + #[inline(always)] + pub fn round(self) -> Self { + Self { + min: self.min.round(), + max: self.max.round(), + } + } + + /// Ceil the rect coordinates + #[inline(always)] + pub fn ceil(self) -> Self { + Self { + min: self.min.ceil(), + max: self.max.ceil(), + } + } + #[inline(always)] pub fn extend_with(&mut self, p: Pos2) { self.min = self.min.min(p);