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 <yerlandinata@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
This commit is contained in:
committed by
Jacopo Mondi
parent
2f621920ea
commit
724bbf7d25
@@ -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<unsigned int>(std::max(point1.x, point2.x)) -
|
||||
static_cast<unsigned int>(std::min(point1.x, point2.x)),
|
||||
static_cast<unsigned int>(std::max(point1.y, point2.y)) -
|
||||
static_cast<unsigned int>(std::min(point1.y, point2.y)))
|
||||
{
|
||||
}
|
||||
|
||||
int x;
|
||||
int y;
|
||||
unsigned int width;
|
||||
|
||||
Reference in New Issue
Block a user