From 724bbf7d2506d65e060c9475010738983f5b85bd Mon Sep 17 00:00:00 2001 From: Yudhistira Erlandinata Date: Wed, 25 Sep 2024 08:12:24 +0000 Subject: libcamera: geometry: Add two-point Rectangle constructor Add a constructor to the Rectangle class that accepts two points. The constructed Rectangle spans all the space between the two given points. Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang Reviewed-by: Jacopo Mondi Signed-off-by: Jacopo Mondi Reviewed-by: Harvey Yang --- include/libcamera/geometry.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 3e6f0f5d..9ca5865a 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -262,6 +262,15 @@ public: { } + constexpr Rectangle(const Point &point1, const Point &point2) + : Rectangle(std::min(point1.x, point2.x), std::min(point1.y, point2.y), + static_cast(std::max(point1.x, point2.x)) - + static_cast(std::min(point1.x, point2.x)), + static_cast(std::max(point1.y, point2.y)) - + static_cast(std::min(point1.y, point2.y))) + { + } + int x; int y; unsigned int width; -- cgit v1.2.1