34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
112 : left{0}, top{0}, width{0}, height{0}
128 constexpr Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight)
noexcept
129 : left{rectLeft}, top{rectTop}, width{rectWidth}, height{rectHeight}
144 : position(rectPosition), size(rectSize)
169 return width == 0 || height == 0;
178 return { left + width / 2, top + height / 2 };
187 return { left, top };
196 return { left + width, top };
205 return { left, top + height };
214 return { left + width, top + height };
226 return left <= point.x && point.x < left + width && top <= point.y && point.y < top + height;
237 return left <= other.left && other.left + other.width <= left + width
238 && top <= other.top && other.top + other.height <= top + height;
249 return left + width > other.left && left < other.left + other.width
250 && top + height > other.top && top < other.top + other.height;
265 if (!intersects(other)) {
270 T resultLeft = std::max(left, other.left);
271 T resultTop = std::max(top, other.top);
272 T resultRight = std::min(left + width, other.left + other.width);
273 T resultBottom = std::min(top + height, other.top + other.height);
275 result =
Rect<T>(resultLeft, resultTop, resultRight - resultLeft, resultBottom - resultTop);
287 return Rect<T>(left - value, top - value, width + 2 * value, height + 2 * value);
298 return Rect<T>(left + value, top + value, width - 2 * value, height - 2 * value);
328 extern template struct Rect<
float>;
329 extern template struct Rect<
int>;
330 extern template struct Rect<
unsigned>;
331 extern template struct Rect<std::size_t>;
345 return lhs.position == rhs.position && lhs.size == rhs.size;
359 return lhs.position != rhs.position || lhs.size != rhs.size;
362 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Rect(const Vector< T, 2 > &rectPosition, const Vector< T, 2 > &rectSize) noexcept
Construct the rectangle from position and size.
Definition: Rect.h:143
constexpr Vector< T, 2 > getBottomLeft() const noexcept
Get the bottom left corner.
Definition: Rect.h:204
Rect< unsigned > RectU
A unsigned rectangle.
Definition: Rect.h:318
bool operator!=(const Rect< T > &lhs, const Rect< T > &rhs)
Inequality operator.
Definition: Rect.h:358
constexpr bool isEmpty() const noexcept
Check if the rectangle is empty.
Definition: Rect.h:168
bool intersects(const Rect< T > &other, Rect< T > &result) const noexcept
Check the intersection between two rectangles.
Definition: Rect.h:264
Rect< int > RectI
A int rectangle.
Definition: Rect.h:312
constexpr Rect< T > extend(T value) const noexcept
Extend the rectangle.
Definition: Rect.h:286
constexpr bool intersects(const Rect< T > &other) const noexcept
Check the intersection between two rectangles.
Definition: Rect.h:248
constexpr bool contains(const Rect< T > &other) const noexcept
Check if a rectangle is inside the rectangle's area.
Definition: Rect.h:236
Rect< float > RectF
A float rectangle.
Definition: Rect.h:306
constexpr Vector< T, 2 > getTopRight() const noexcept
Get the top right corner.
Definition: Rect.h:195
Utility class for manipulating 2D axis aligned rectangles.
Definition: Rect.h:88
constexpr Rect< T > shrink(T value) const noexcept
Shrink the rectangle.
Definition: Rect.h:297
constexpr Vector< T, 2 > getCenter() const noexcept
Get the center of the rectangle.
Definition: Rect.h:177
constexpr Rect() noexcept
Default constructor.
Definition: Rect.h:111
constexpr Vector< T, 2 > getTopLeft() const noexcept
Get the top left corner.
Definition: Rect.h:186
constexpr Vector< T, 2 > getBottomRight() const noexcept
Get the bottom right corner.
Definition: Rect.h:213
constexpr bool contains(const Vector< T, 2 > &point) const noexcept
Check if a point is inside the rectangle's area.
Definition: Rect.h:225
constexpr Vector< T, 2 > getSize() const noexcept
Get the size of the rectangle.
Definition: Rect.h:156
constexpr Rect(T rectLeft, T rectTop, T rectWidth, T rectHeight) noexcept
Construct the rectangle from its coordinates.
Definition: Rect.h:128
General purpose math vector.
Definition: Vector.h:61
bool operator==(const Rect< T > &lhs, const Rect< T > &rhs)
Equality operator.
Definition: Rect.h:344
Rect< std::size_t > RectZ
A std::size_t rectangle.
Definition: Rect.h:324