Rect
Class representing a Rectangle with a few convenient methods.
Public Functions
| int32_t | area() const |
| Calculate the area of the rectangle. | |
| FORCE_INLINE_FUNCTION int16_t | bottom() const |
| Gets the y coordinate of the bottom edge of the Rect, i.e. | |
| void | expandToFit(const Rect & other) |
| Increases the area covered by this rectangle to encompass the area covered by supplied rectangle. | |
| bool | includes(const Rect & other) const |
| Determines whether the specified rectangle is completely included in this rectangle. | |
| bool | intersect(const Rect & other) const |
| Determines whether specified rectangle intersects with this rectangle. | |
| bool | intersect(int16_t otherX, int16_t otherY) const |
| Determines whether specified point lies inside this rectangle. | |
| bool | isEmpty() const |
| Query if this object is empty. | |
| bool | operator!=(const Rect & other) const |
| Opposite of the == operator. | |
| Rect | operator&(const Rect & other) const |
| Gets a rectangle describing the intersecting area between this rectangle and the supplied rectangle. | |
| void | operator&=(const Rect & other) |
| Assigns this Rect to the intersection of the current Rect and the assigned Rect. | |
| bool | operator==(const Rect & other) const |
| Compares equality of two Rect by the dimensions and position of these. | |
| Rect() | |
| Default constructor. | |
| Rect(int16_t rectX, int16_t rectY, int16_t rectWidth, int16_t rectHeight) | |
| Initializes a new instance of the Rect class. | |
| void | restrictTo(int16_t max_width, int16_t max_height) |
| Restrict the area to not exceed the given max width and max height. | |
| FORCE_INLINE_FUNCTION int16_t | right() const |
| Gets the x coordinate of the right edge of the Rect, i.e. | |
Public Attributes
Public Functions Documentation
area
| int32_t area | ( | ) | const |
Calculate the area of the rectangle.
area of the rectangle.
bottom
| FORCE_INLINE_FUNCTION int16_t bottom | ( | ) | const |
expandToFit
| void expandToFit | ( | const Rect & | other | ) | |
Increases the area covered by this rectangle to encompass the area covered by supplied rectangle.
| other | The other rectangle. |
includes
Determines whether the specified rectangle is completely included in this rectangle.
| other | The other rectangle. |
true if the specified rectangle is completely included.
intersect
Determines whether specified rectangle intersects with this rectangle.
| other | The other rectangle. |
true if the two rectangles intersect.
intersect
| bool intersect | ( | int16_t | otherX , | const | |
| int16_t | otherY | const | |||
| ) | const |
Determines whether specified point lies inside this rectangle.
| otherX | The x coordinate of the point. |
| otherY | The y coordinate of the point. |
true if point lies inside rectangle.
isEmpty
| bool isEmpty | ( | ) | const |
Query if this object is empty.
true if any of the dimensions are 0.
operator!=
| bool operator!= | ( | const Rect & | other | ) | |
operator&
Gets a rectangle describing the intersecting area between this rectangle and the supplied rectangle.
| other | The other rectangle. |
Intersecting rectangle or empty Rect in case of no intersection.
operator&=
| void operator&= | ( | const Rect & | other | ) | |
operator==
| bool operator== | ( | const Rect & | other | ) | |
Rect
Rect
| Rect | ( | int16_t | rectX , | ||
| int16_t | rectY , | ||||
| int16_t | rectWidth , | ||||
| int16_t | rectHeight | ||||
| ) |
Initializes a new instance of the Rect class.
| rectX | The x coordinate. |
| rectY | The y coordinate. |
| rectWidth | The width. |
| rectHeight | The height. |
restrictTo
| void restrictTo | ( | int16_t | max_width , | ||
| int16_t | max_height | ||||
| ) |
Restrict the area to not exceed the given max width and max height.
As a result, width or height can be negative if the rect is completely outside Rect(0, 0, max_width, max_height), but this is nicely handled by the isEmpty() function.
| max_width | The maximum width. |
| max_height | The maximum height. |
right
| FORCE_INLINE_FUNCTION int16_t right | ( | ) | const |
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.