Detailed Description
The PRectanglei class represents an axis-aligned rectangle with 32-bit int coordinates; PRectanglei instances are immutable (thread-safe).
A rectangle is defined from one corner (minX, minY) and two lengths: width and height.
Definition at line 33 of file PRectanglei.h.
#include <PRectanglei.h>
Constructor & Destructor Documentation
◆ PRectanglei() [1/2]
|
explicit |
Constructs a rectangle from its (minX, minY) corner, its width and its height.
If width < 0, then width is set to 0. If height < 0, then height is set to 0. Rectangles are valid if and only if width>0 and height>0.
- See also
- IsValid()
◆ PRectanglei() [2/2]
PRectanglei::PRectanglei | ( | const PRectanglei & | other | ) |
Constructs a shared copy of other.
◆ ~PRectanglei()
|
virtual |
Destroys this object.
Member Function Documentation
◆ ClipBy()
PRectanglei PRectanglei::ClipBy | ( | const PRectanglei & | other | ) | const |
Clips this rectangle by another ones.
If no intersection between the two rectangles, then returns a rectangle with a width or height equal to 0.
◆ Contains() [1/2]
bool PRectanglei::Contains | ( | const PPoint2Di & | p | ) | const |
Returns true if the specified point belongs to this rectangle, false otherwise.
WARNING: to be consistent with GetArea(), rectangle(x,y,w,h) does not contain (x+w,y+h) point
◆ Contains() [2/2]
bool PRectanglei::Contains | ( | const PRectanglei & | r | ) | const |
Returns true if the specified rectangle fully inside this rectangle, false otherwise.
◆ Expand()
PRectanglei PRectanglei::Expand | ( | papillon::int32 | expandBy | ) | const |
DEPRECATED, use Expanded() instead.
Returns a new rectangle expanded on each side
◆ Expanded()
PRectanglei PRectanglei::Expanded | ( | papillon::int32 | expandBy | ) | const |
Returns a new rectangle expanded on each side.
◆ FromString()
|
static |
Parses the specified string to build a PRectanglei object.
Expected format is "x,y,w,h" or "x;y;w;h" or "x y w h". If failure, rectangle is set to (0, 0, 0, 0). Returns PResult::C_OK if success, another result otherwise.
◆ GetArea()
papillon::int32 PRectanglei::GetArea | ( | ) | const |
Returns area of rectangles.
◆ GetCentre()
PPoint2Df PRectanglei::GetCentre | ( | ) | const |
Returns the centre point of this rectangle.
◆ GetDiceCoefficient()
float PRectanglei::GetDiceCoefficient | ( | const PRectanglei & | rectangle | ) | const |
Gets the diceCoefficient with another rectangle.
The dice coefficient between 2 rectangles A and B is given by:
2*overlapArea(A,B)
Dice(A,B) = --------------------------— Area(A) + Area(B)
the returned value range is [0, 1].
◆ GetHeight()
papillon::int32 PRectanglei::GetHeight | ( | ) | const |
Returns the height of this rectangle.
Note: the result is always >= 0.
◆ GetOrigin()
PPoint2Di PRectanglei::GetOrigin | ( | ) | const |
Returns the origin point (x,y) of this rectangle.
◆ GetOriginf()
PPoint2Df PRectanglei::GetOriginf | ( | ) | const |
Returns the origin point (x,y) of this rectangle.
◆ GetOverlapArea()
float PRectanglei::GetOverlapArea | ( | const PRectanglei & | rectangle | ) | const |
Gets the overlap area with another rectangle.
◆ GetSize()
PSizei PRectanglei::GetSize | ( | ) | const |
Returns the size this rectangle.
◆ GetWidth()
papillon::int32 PRectanglei::GetWidth | ( | ) | const |
Returns the width of this rectangle.
Note: the result is always >= 0.
◆ GetX()
papillon::int32 PRectanglei::GetX | ( | ) | const |
Returns the x-coordinate (column) of the top left corner of this rectangle.
◆ GetY()
papillon::int32 PRectanglei::GetY | ( | ) | const |
Returns the y-coordinate (row) of the top left corner of this rectangle.
◆ Intersected()
PRectanglei PRectanglei::Intersected | ( | const PRectanglei & | other | ) | const |
Returns the rectangle corresponding to the intersection of this rectangle and other.
◆ IsValid()
bool PRectanglei::IsValid | ( | ) | const |
Returns true if this either width and height of this rectangle are > 0.
◆ operator!=()
bool PRectanglei::operator!= | ( | const PRectanglei & | other | ) | const |
Returns true if this rectangle is different of other, false otherwise.
◆ operator=()
PRectanglei& PRectanglei::operator= | ( | const PRectanglei & | other | ) |
Performs a shared copy of other to this object.
◆ operator==()
bool PRectanglei::operator== | ( | const PRectanglei & | other | ) | const |
Returns true if this rectangle is the same than other, false otherwise.
◆ ToPRectanglef()
PRectanglef PRectanglei::ToPRectanglef | ( | ) | const |
Returns a PRectanglef from this rectangle.