3#include <Foundation/Basics.h>
4#include <Foundation/Math/Vec2.h>
8template <
typename Type>
13 PL_DECLARE_POD_TYPE();
55 Type
Left()
const {
return x; }
58 Type
Right()
const {
return x + width; }
61 Type
Top()
const {
return y; }
64 Type
Bottom()
const {
return y + height; }
67 Type
GetX1()
const {
return x; }
70 Type
GetX2()
const {
return x + width; }
73 Type
GetY1()
const {
return y; }
76 Type
GetY2()
const {
return y + height; }
114 [[nodiscard]]
bool IsValid()
const;
158 void Scale(Type sX, Type sY);
161#include <Foundation/Math/Implementation/Rect_inl.h>
A simple rectangle class templated on the type for x, y and width, height.
Definition Rect.h:10
void Clip(const plRectTemplate< Type > &clipRect)
Clips this rect so that it is fully inside the provided rectangle.
Definition Rect_inl.h:190
plVec2Template< Type > GetMaxCorner() const
Returns the maximum corner position. Same as GetBottomRight().
Definition Rect.h:82
bool HasNonZeroArea() const
Returns true if the area of the rectangle is non zero.
Definition Rect_inl.h:102
plVec2Template< Type > GetMinCorner() const
Returns the minimum corner position. Same as GetTopLeft().
Definition Rect.h:79
void Grow(Type xy)
Increases the size of the rect in all directions.
Definition Rect_inl.h:181
Type GetY1() const
The smaller value along y. Same as Top().
Definition Rect.h:73
plVec2Template< Type > GetExtents() const
Returns the width and height as a vec2.
Definition Rect.h:100
Type Right() const
The larger value along x.
Definition Rect.h:58
Type GetY2() const
The larger value along y. Same as Bottom().
Definition Rect.h:76
plVec2Template< Type > GetTopLeft() const
Returns the top left corner. Same as GetMinCorner().
Definition Rect.h:85
bool IsValid() const
Checks whether the position and size contain valid values.
Definition Rect_inl.h:205
void Scale(Type sX, Type sY)
Scales width and height, and moves the position as well.
Definition Rect_inl.h:239
void SetCenter(Type tX, Type tY)
Sets the center of the rectangle.
Definition Rect_inl.h:221
Type GetX2() const
The larger value along x. Same as Right().
Definition Rect.h:70
const plVec2Template< Type > GetClampedPoint(const plVec2Template< Type > &vPoint) const
The given point is clamped to the area of the rect, i.e. it will be either inside the rect or on its ...
Definition Rect_inl.h:213
Type Left() const
The smaller value along x.
Definition Rect.h:55
plVec2Template< Type > GetBottomRight() const
Returns the bottom right corner. Same as GetMaxCorner().
Definition Rect.h:94
bool Contains(const plVec2Template< Type > &vPoint) const
Returns true if the rectangle contains the provided point.
Definition Rect_inl.h:108
Type GetX1() const
The smaller value along x. Same as Left().
Definition Rect.h:67
plVec2Template< Type > GetBottomLeft() const
Returns the bottom left corner.
Definition Rect.h:91
plRectTemplate()
Default constructor does not initialize the data.
static plRectTemplate< Type > MakeUnion(const plRectTemplate< Type > &r0, const plRectTemplate< Type > &r1)
Creates a rect that is the union of the two provided rects.
Definition Rect_inl.h:70
plVec2Template< Type > GetTopRight() const
Returns the top right corner.
Definition Rect.h:88
bool Overlaps(const plRectTemplate< Type > &other) const
Returns true if the rectangle overlaps the provided rectangle. Also returns true if the rectangles ar...
Definition Rect_inl.h:126
void Translate(Type tX, Type tY)
Moves the rectangle.
Definition Rect_inl.h:230
static plRectTemplate< Type > MakeInvalid()
Creates an 'invalid' rect.
Definition Rect_inl.h:34
static plRectTemplate< Type > MakeIntersection(const plRectTemplate< Type > &r0, const plRectTemplate< Type > &r1)
Creates a rect that is the intersection of the two provided rects.
Definition Rect_inl.h:50
plVec2Template< Type > GetHalfExtents() const
Returns the half width and half height as a vec2.
Definition Rect.h:103
plVec2Template< Type > GetCenter() const
Returns the center point of the rectangle.
Definition Rect.h:97
Type Top() const
The smaller value along y.
Definition Rect.h:61
Type Bottom() const
The larger value along y.
Definition Rect.h:64
void ExpandToInclude(const plRectTemplate< Type > &other)
Extends this rectangle so that the provided rectangle is completely contained within it.
Definition Rect_inl.h:135
const plRectTemplate< Type > GetClampedRect(const plRectTemplate< Type > &r) const
Clamps the given rect to the area of this rect and returns it.
Definition Rect.h:144
A 2-component vector class.
Definition Vec2.h:14