From 902b4d960d424046e24ff0ed4532f8728638769d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 19 Jun 2024 11:27:33 +0200 Subject: [PATCH] Add `Rect::from_pos` --- crates/emath/src/rect.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/emath/src/rect.rs b/crates/emath/src/rect.rs index ec220395bd7..42a67cfb4fb 100644 --- a/crates/emath/src/rect.rs +++ b/crates/emath/src/rect.rs @@ -110,6 +110,15 @@ impl Rect { } } + /// A zero-sized rect at a specific point. + #[inline] + pub fn from_pos(point: Pos2) -> Self { + Self { + min: point, + max: point, + } + } + /// Bounding-box around the points. pub fn from_points(points: &[Pos2]) -> Self { let mut rect = Self::NOTHING;