@@ -8,6 +8,8 @@
#pragma once
#include <algorithm>
+#include <cassert>
+#include <cstdlib>
#include <ostream>
#include <string>
@@ -262,6 +264,14 @@ public:
{
}
+ constexpr Rectangle(const Point &topLeft, const Point &bottomRight)
+ : x(topLeft.x), y(topLeft.y),
+ width(bottomRight.x - x),
+ height(bottomRight.y - y)
+ {
+ assert(bottomRight.x >= x && bottomRight.y >= y);
+ }
+
int x;
int y;
unsigned int width;
@@ -629,6 +629,13 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
* \param[in] size The desired Rectangle size
*/
+/**
+ * \fn Rectangle::Rectangle(const Point &topLeft, const Point &bottomRight)
+ * \brief Construct a Rectangle with the two given points.
+ * \param[in] topLeft The top-left corner
+ * \param[in] bottomRight The bottom-right corner
+ */
+
/**
* \var Rectangle::x
* \brief The horizontal coordinate of the rectangle's top-left corner