3template <
typename Type>
6template <
typename Type>
15template <
typename Type>
24template <
typename Type>
27 x = vTopLeftPosition.x;
28 y = vTopLeftPosition.y;
33template <
typename Type>
43 res.width = -fLargeValue;
44 res.height = -fLargeValue;
49template <
typename Type>
69template <
typename Type>
89template <
typename Type>
92 return x == rhs.x && y == rhs.y && width == rhs.width && height == rhs.height;
95template <
typename Type>
98 return !(*
this == rhs);
101template <
typename Type>
104 return (width > 0) && (height > 0);
107template <
typename Type>
110 if (vPoint.x >= x && vPoint.x <= Right())
112 if (vPoint.y >= y && vPoint.y <= Bottom())
119template <
typename Type>
122 return r.x >= x && r.y >= y && r.
Right() <= Right() && r.
Bottom() <= Bottom();
125template <
typename Type>
128 if (x < other.
Right() && Right() > other.x && y < other.
Bottom() && Bottom() > other.y)
134template <
typename Type>
137 Type thisRight = Right();
138 Type thisBottom = Bottom();
146 if (other.
Right() > thisRight)
147 width = other.
Right() - x;
149 width = thisRight - x;
151 if (other.
Bottom() > thisBottom)
154 height = thisBottom - y;
157template <
typename Type>
160 Type thisRight = Right();
161 Type thisBottom = Bottom();
169 if (other.x > thisRight)
172 width = thisRight - x;
174 if (other.y > thisBottom)
175 height = other.y - y;
177 height = thisBottom - y;
180template <
typename Type>
189template <
typename Type>
200 width = newRight - newLeft;
201 height = newBottom - newTop;
204template <
typename Type>
209 return width >= 0 && height >= 0;
212template <
typename Type>
220template <
typename Type>
229template <
typename Type>
238template <
typename Type>
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
bool HasNonZeroArea() const
Returns true if the area of the rectangle is non zero.
Definition Rect_inl.h:102
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
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
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
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
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
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
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
A 2-component vector class.
Definition Vec2.h:14
constexpr PL_ALWAYS_INLINE T Min(T f1, T f2)
Returns the smaller value, f1 or f2.
Definition Math_inl.h:27
constexpr PL_ALWAYS_INLINE T Clamp(T value, T min_val, T max_val)
Clamps "value" to the range [min; max]. Returns "value", if it is inside the range already.
Definition Math_inl.h:51
constexpr TYPE MaxValue()
Returns the largest possible positive value (that is not infinity).
constexpr PL_ALWAYS_INLINE T Max(T f1, T f2)
Returns the greater value, f1 or f2.
Definition Math_inl.h:39