Rect Class Reference

Defines a 2D rectangle with top-left corner coordinates and width/height in pixels. More...

Functions

 Rect (size_t x_=0, size_t y_=0, size_t w_=0, size_t h_=0)
 
size_t area ()
 Returns the area of the rectangle. More...
 
bool operator== (const Rect &that) const
 Tests if the given Rect has the same properties. More...
 
bool operator!= (const Rect &that) const
 Tests if the given Rect has different properties. More...
 
bool isEmpty () const
 Tests if the given Rect is empty (width or/and height is null) More...
 
bool contains (const Rect &target, bool proper=false) const
 Tests if this Rect contains the <target> Rect. More...
 
bool isContained (const Rect &target, bool proper=false) const
 Tests if this Rect is contained inside the given <target> Rect. More...
 
bool isContained (const Resolution &resolution, bool proper=false) const
 Overloaded function. Tests if this Rect is contained inside a given Resolution. It tests if the current rect is contained inside a Rect defined by Rect(O,0,resolution.width,resolution.height). More...
 

Attributes

size_t x
 
size_t y
 
size_t width
 
size_t height
 

Detailed Description

Defines a 2D rectangle with top-left corner coordinates and width/height in pixels.

Constructor and Destructor

◆ Rect()

Rect ( size_t  x_ = 0,
size_t  y_ = 0,
size_t  w_ = 0,
size_t  h_ = 0 
)
inline

Functions

◆ area()

size_t area ( )
inline

Returns the area of the rectangle.

Returns
.

◆ operator==()

bool operator== ( const Rect that) const
inline

Tests if the given Rect has the same properties.

Returns
True if all the components matches.

◆ operator!=()

bool operator!= ( const Rect that) const
inline

Tests if the given Rect has different properties.

Returns
True if one of the components does not match.

◆ isEmpty()

bool isEmpty ( ) const
inline

Tests if the given Rect is empty (width or/and height is null)

Returns
True if rectangle is empty

◆ contains()

bool contains ( const Rect target,
bool  proper = false 
) const
inline

Tests if this Rect contains the <target> Rect.

Returns
Returns true if this rectangle contains the <target> rectangle. otherwise returns false. If proper is true, this function only returns true if the target rectangle is entirely inside this rectangle (not on the edge).

◆ isContained() [1/2]

bool isContained ( const Rect target,
bool  proper = false 
) const
inline

Tests if this Rect is contained inside the given <target> Rect.

Returns
Returns true if this rectangle is inside the current target Rect. otherwise returns false. If proper is true, this function only returns true if this rectangle is entirely inside the <target> rectangle (not on the edge).

◆ isContained() [2/2]

bool isContained ( const Resolution resolution,
bool  proper = false 
) const
inline

Overloaded function. Tests if this Rect is contained inside a given Resolution. It tests if the current rect is contained inside a Rect defined by Rect(O,0,resolution.width,resolution.height).

Returns
Returns true if this rectangle is inside the rectangle defined by Rect(O,0,resolution.width,resolution.height). otherwise returns false. If proper is true, this function only returns true if this rectangle is entirely inside the rectangle defined by the resolution (not on the edge).

Variables

◆ x

size_t x

x coordinates of top-left corner.

Referenced by Rect::contains(), Rect::isContained(), Rect::operator!=(), and Rect::operator==().

◆ y

size_t y

y coordinates of top-left corner.

Referenced by Rect::contains(), Rect::isContained(), Rect::operator!=(), and Rect::operator==().

◆ width

size_t width

width of the rectangle in pixels.

Referenced by Rect::contains(), Rect::isContained(), Rect::operator!=(), and Rect::operator==().

◆ height

size_t height

height of the rectangle in pixels.

Referenced by Rect::contains(), Rect::isContained(), Rect::operator!=(), and Rect::operator==().