![]() |
ezEngine
Release 25.03
|
A simple rectangle class templated on the type for x, y and width, height. More...
#include <Rect.h>
Public Member Functions | |
EZ_DECLARE_POD_TYPE () | |
ezRectTemplate () | |
Default constructor does not initialize the data. | |
ezRectTemplate (Type x, Type y, Type width, Type height) | |
Constructor to set all values. | |
ezRectTemplate (Type width, Type height) | |
Initializes x and y with zero, width and height with the given values. | |
ezRectTemplate (const ezVec2Template< Type > &vTopLeftPosition, const ezVec2Template< Type > &vSize) | |
Initializes x and y from pos, width and height from vSize. | |
Type | Left () const |
The smaller value along x. | |
Type | Right () const |
The larger value along x. | |
Type | Top () const |
The smaller value along y. | |
Type | Bottom () const |
The larger value along y. | |
Type | GetX1 () const |
The smaller value along x. Same as Left(). | |
Type | GetX2 () const |
The larger value along x. Same as Right(). | |
Type | GetY1 () const |
The smaller value along y. Same as Top(). | |
Type | GetY2 () const |
The larger value along y. Same as Bottom(). | |
ezVec2Template< Type > | GetMinCorner () const |
Returns the minimum corner position. Same as GetTopLeft(). | |
ezVec2Template< Type > | GetMaxCorner () const |
Returns the maximum corner position. Same as GetBottomRight(). | |
ezVec2Template< Type > | GetTopLeft () const |
Returns the top left corner. Same as GetMinCorner(). | |
ezVec2Template< Type > | GetTopRight () const |
Returns the top right corner. | |
ezVec2Template< Type > | GetBottomLeft () const |
Returns the bottom left corner. | |
ezVec2Template< Type > | GetBottomRight () const |
Returns the bottom right corner. Same as GetMaxCorner(). | |
ezVec2Template< Type > | GetCenter () const |
Returns the center point of the rectangle. | |
ezVec2Template< Type > | GetExtents () const |
Returns the width and height as a vec2. | |
ezVec2Template< Type > | GetHalfExtents () const |
Returns the half width and half height as a vec2. | |
void | Grow (Type xy) |
Increases the size of the rect in all directions. | |
bool | operator== (const ezRectTemplate< Type > &rhs) const |
bool | operator!= (const ezRectTemplate< Type > &rhs) const |
bool | IsValid () const |
Checks whether the position and size contain valid values. More... | |
bool | HasNonZeroArea () const |
Returns true if the area of the rectangle is non zero. | |
bool | Contains (const ezVec2Template< Type > &vPoint) const |
Returns true if the rectangle contains the provided point. | |
bool | Contains (const ezRectTemplate< Type > &r) const |
bool | Overlaps (const ezRectTemplate< Type > &other) const |
Returns true if the rectangle overlaps the provided rectangle. Also returns true if the rectangles are contained within each other completely(no intersecting edges). | |
void | ExpandToInclude (const ezRectTemplate< Type > &other) |
Extends this rectangle so that the provided rectangle is completely contained within it. | |
void | ExpandToInclude (const ezVec2Template< Type > &other) |
Extends this rectangle so that the provided point is contained within it. | |
void | Clip (const ezRectTemplate< Type > &clipRect) |
Clips this rect so that it is fully inside the provided rectangle. | |
const ezVec2Template< Type > | GetClampedPoint (const ezVec2Template< 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 edge and it will have the closest possible distance to the original point. More... | |
const ezRectTemplate< Type > | GetClampedRect (const ezRectTemplate< Type > &r) const |
Clamps the given rect to the area of this rect and returns it. More... | |
void | SetCenter (Type tX, Type tY) |
Sets the center of the rectangle. More... | |
void | Translate (Type tX, Type tY) |
Moves the rectangle. More... | |
void | Scale (Type sX, Type sY) |
Scales width and height, and moves the position as well. More... | |
Static Public Member Functions | |
static ezRectTemplate< Type > | MakeInvalid () |
Creates an 'invalid' rect. More... | |
static ezRectTemplate< Type > | MakeZero () |
Creates a rect that is located at the origin and has zero size. This is a 'valid' rect. | |
static ezRectTemplate< Type > | MakeIntersection (const ezRectTemplate< Type > &r0, const ezRectTemplate< Type > &r1) |
Creates a rect that is the intersection of the two provided rects. More... | |
static ezRectTemplate< Type > | MakeUnion (const ezRectTemplate< Type > &r0, const ezRectTemplate< Type > &r1) |
Creates a rect that is the union of the two provided rects. More... | |
Public Attributes | |
Type | x |
Type | y |
Type | width |
Type | height |
A simple rectangle class templated on the type for x, y and width, height.
const EZ_ALWAYS_INLINE ezVec2Template< Type > ezRectTemplate< Type >::GetClampedPoint | ( | const ezVec2Template< 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 edge and it will have the closest possible distance to the original point.
|
inline |
Clamps the given rect to the area of this rect and returns it.
If the input rect is entirely outside this rect, the result will be reduced to a point or a line closest to the input rect.
EZ_ALWAYS_INLINE bool ezRectTemplate< Type >::IsValid |
Checks whether the position and size contain valid values.
|
static |
Creates a rect that is the intersection of the two provided rects.
If the two rects don't overlap, the result will be a valid rect, but have zero area. See IsValid() and HasNonZeroArea().
|
static |
Creates an 'invalid' rect.
IsValid() will return false. It is possible to make an invalid rect valid using ExpandToInclude().
|
static |
Creates a rect that is the union of the two provided rects.
This is the same as constructing a bounding box around the two rects.
void ezRectTemplate< Type >::Scale | ( | Type | sX, |
Type | sY | ||
) |
Scales width and height, and moves the position as well.
void ezRectTemplate< Type >::SetCenter | ( | Type | tX, |
Type | tY | ||
) |
Sets the center of the rectangle.
void ezRectTemplate< Type >::Translate | ( | Type | tX, |
Type | tY | ||
) |
Moves the rectangle.