diff --git a/src/components/util/geometry.rs b/src/components/util/geometry.rs index e02bb8a6bb9..248ce1ba01e 100644 --- a/src/components/util/geometry.rs +++ b/src/components/util/geometry.rs @@ -300,3 +300,11 @@ pub fn to_pt(au: Au) -> f64 { (a as f64) / 60f64 * 72f64 / 96f64 } +/// Returns true if the rect contains the given point. Points on the top or left sides of the rect +/// are considered inside the rectangle, while points on the right or bottom sides of the rect are +/// not considered inside the rectangle. +pub fn rect_contains_point>(rect: Rect, point: Point2D) -> bool { + point.x >= rect.origin.x && point.x < rect.origin.x + rect.size.width && + point.y >= rect.origin.y && point.y < rect.origin.y + rect.size.height +} +