Skip to main content

Rect

Class representing a Rectangle with a few convenient methods.

Public Functions

uint32_tarea() const
Calculate the area of the rectangle.
FORCE_INLINE_FUNCTION int16_tbottom() const
Gets the y coordinate of the bottom edge of the Rect, i.e.
voidexpandToFit(const Rect & other)
Increases the area covered by this rectangle to encompass the area covered by supplied rectangle.
boolincludes(const Rect & other) const
Determines whether the specified rectangle is completely included in this rectangle.
boolintersect(const Rect & other) const
Determines whether specified rectangle intersects with this rectangle.
boolintersect(int16_t otherX, int16_t otherY) const
Determines whether specified point lies inside this rectangle.
boolisEmpty() const
Query if this object is empty.
booloperator!=(const Rect & other) const
Opposite of the == operator.
Rectoperator&(const Rect & other) const
Gets a rectangle describing the intersecting area between this rectangle and the supplied rectangle.
voidoperator&=(const Rect & other)
Assigns this Rect to the intersection of the current Rect and the assigned Rect.
booloperator==(const Rect & other) const
Compares equality of two Rect by the dimensions and position of these.
Rect()
Default constructor.
Rect(int16_t x, int16_t y, int16_t width, int16_t height)
Initializes a new instance of the Rect class.
FORCE_INLINE_FUNCTION int16_tright() const
Gets the x coordinate of the right edge of the Rect, i.e.

Public Attributes

int16_theight
The height.
int16_twidth
The width.
int16_tx
The x coordinate.
int16_ty
The y coordinate.

Public Functions Documentation

area

uint32_t area()const

Calculate the area of the rectangle.

Returns:

area of the rectangle.

bottom

FORCE_INLINE_FUNCTION int16_t bottom()const

Gets the y coordinate of the bottom edge of the Rect, i.e.

the number of the first row just below the Rect.

Returns:

y coordinate of the bottom edge (calculated as "y + height").

expandToFit

void expandToFit(const Rect &other)

Increases the area covered by this rectangle to encompass the area covered by supplied rectangle.

Parameters:
otherThe other rectangle.

includes

bool includes(const Rect &other)

Determines whether the specified rectangle is completely included in this rectangle.

Parameters:
otherThe other rectangle.
Returns:

true if the specified rectangle is completely included.

intersect

bool intersect(const Rect &other)

Determines whether specified rectangle intersects with this rectangle.

Parameters:
otherThe other rectangle.
Returns:

true if the two rectangles intersect.

intersect

bool intersect(int16_totherX ,const
int16_totherYconst
)const

Determines whether specified point lies inside this rectangle.

Parameters:
otherXThe x coordinate of the point.
otherYThe y coordinate of the point.
Returns:

true if point lies inside rectangle.

isEmpty

bool isEmpty()const

Query if this object is empty.

Returns:

true if any of the dimensions are 0.

operator!=

bool operator!=(const Rect &other)

Opposite of the == operator.

Parameters:
otherThe Rect to compare with.
Returns:

true if the compared Rect differ in dimensions or coordinates.

operator&

Rect operator&(const Rect &other)

Gets a rectangle describing the intersecting area between this rectangle and the supplied rectangle.

Parameters:
otherThe other rectangle.
Returns:

Intersecting rectangle or Rect(0, 0, 0, 0) in case of no intersection.

operator&=

void operator&=(const Rect &other)

Assigns this Rect to the intersection of the current Rect and the assigned Rect.

The assignment will result in a Rect(0, 0, 0, 0) if they do not intersect.

Parameters:
otherThe rect to intersect with.

operator==

bool operator==(const Rect &other)

Compares equality of two Rect by the dimensions and position of these.

Parameters:
otherThe Rect to compare with.
Returns:

true if the compared Rect have the same dimensions and coordinates.

Rect

Default constructor.

Resulting in an empty Rect with coordinates 0,0.

Rect

Rect(int16_tx ,
int16_ty ,
int16_twidth ,
int16_theight
)

Initializes a new instance of the Rect class.

Parameters:
xThe x coordinate.
yThe y coordinate.
widthThe width.
heightThe height.
FORCE_INLINE_FUNCTION int16_t right()const

Gets the x coordinate of the right edge of the Rect, i.e.

the number of the first column just to the right of the Rect.

Returns:

x coordinate of the right edge (calculated as "x + width").

Public Attributes Documentation

height

int16_t height

The height.

width

int16_t width

The width.

x

int16_t x

The x coordinate.

y

int16_t y

The y coordinate.