Add `Rect::from_pos`

This commit is contained in:
Emil Ernerfeldt 2024-06-19 11:27:33 +02:00
parent 159f8360fa
commit 902b4d960d
1 changed files with 9 additions and 0 deletions

View File

@ -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;