Struct representing a rectangle in a 2 dimensional coordinate space. More...
#include <UTGeometry.h>
Public Member Functions | |
Rect_t () | |
Rect_t (float left, float top, float right, float bottom) | |
Rect_t (const Rect_t ©) | |
const Rect_t & | operator= (const Rect_t ©) |
bool | operator== (const Rect_t &other) const |
bool | operator!= (const Rect_t &other) const |
Rect_t | operator+ (const Point_t &add) const |
Rect_t | operator- (const Point_t &subtract) const |
const Rect_t & | operator+= (const Point_t &add) |
const Rect_t & | operator-= (const Point_t &subtract) |
bool | Contains (const Point_t &point) const |
bool | Overlapping (const Rect_t &other) const |
Rect_t | operator& (const Rect_t &intersect) const |
const Rect_t & | operator&= (const Rect_t &intersect) |
Rect_t | operator| (const Rect_t &intersect) const |
const Rect_t & | operator|= (const Rect_t &intersect) |
float | Width () const |
float | Height () const |
void | OffsetTo (const Point_t &left_top) |
void | InsetBy (float value) |
void | InsetBy (float left, float top, float right, float bottom) |
void | ExpandBy (float value) |
void | ExpandBy (float left, float top, float right, float bottom) |
void | ExpandToInteger () |
Rect_t | OffsetToCopy (const Point_t &left_top) const |
Rect_t | InsetByCopy (float value) const |
Rect_t | InsetByCopy (float left, float top, float right, float bottom) const |
Rect_t | ExpandByCopy (float value) const |
Rect_t | ExpandByCopy (float left, float top, float right, float bottom) const |
Point_t | LeftTop () const |
Point_t | RightTop () const |
Point_t | LeftBottom () const |
Point_t | RightBottom () const |
Public Attributes | |
float | left |
float | top |
float | right |
float | bottom |
Struct representing a rectangle in a 2 dimensional coordinate space. Although it can be used in other ways, the value space which is typically used is that for a monitor, with increasing x values to the right and increasing y values to the bottom. Floating point numbers are used by the UTgfx and UTgui libraries to represent screen display because for scaling, use of floating point computation until final conversion to an integer coordinate is more efficient than use of integers when scaling. That way the same interface can be used to render to the display, printer, and so on. Floats are accurate to within c_dbl_abs_min_denominator out to about 4,000,000.
Definition at line 167 of file UTGeometry.h.
Rect_t::Rect_t | ( | ) | [inline] |
Constructor for an uninitialized rectangle, just to make the compiler happy.
Definition at line 1375 of file UTGeometry.h.
Rect_t::Rect_t | ( | float | left, | |
float | top, | |||
float | right, | |||
float | bottom | |||
) | [inline] |
Initializer for a new rectangle with a specific size.
Definition at line 1382 of file UTGeometry.h.
Rect_t::Rect_t | ( | const Rect_t & | copy | ) | [inline] |
Copy constructor.
Definition at line 1392 of file UTGeometry.h.
Assignment operator.
Definition at line 1402 of file UTGeometry.h.
bool Rect_t::operator== | ( | const Rect_t & | other | ) | const |
Comparison operator. Because of possible floating point error, if all sides' coordinates are within c_dbl_compare_equality_threshold of each other, returns true. This is adequate for pixels. For very large values, a custom comparison function should be used.
bool Rect_t::operator!= | ( | const Rect_t & | other | ) | const |
Comparison operator. Because of possible floating point error, if all sides' coordinates are within c_dbl_compare_equality_threshold of each other, returns false. This is adequate for pixels. For very large values, a custom comparison function should be used.
Adds the x value of the specified point to the left and right values of the rectangle on the left side of the expression, and the y value of the point to the top and bottom values, returning the result in a new rectangle.
Definition at line 1413 of file UTGeometry.h.
Subtracts the x value of the specified point from the left and right values of the rectangle on the left side of the expression, and the y value of the point from the top and bottom values, returning the result in a new rectangle.
Definition at line 1420 of file UTGeometry.h.
Adds the x value of the specified point to the left and right values of this, and the y value of the point to the top and bottom values.
Definition at line 1427 of file UTGeometry.h.
Subtracts the x value of the specified point from the left and right values of this, and the y value of the point from the top and bottom values.
Definition at line 1438 of file UTGeometry.h.
bool Rect_t::Contains | ( | const Point_t & | point | ) | const |
Returns true if this rectangle contains the specified point.
bool Rect_t::Overlapping | ( | const Rect_t & | other | ) | const |
Returns true if this rectangle at least partially overlaps the other.
Returns the overlapping portion of two rectangles in a new rectangle.
Trims this rectangle to the portion which overlaps another.
Returns a rectangle which encloses both rectangles.
Extends this rectangle to completely enclose the other rectangle.
float Rect_t::Width | ( | ) | const [inline] |
Returns the width of the rectangle (right minus left).
Definition at line 1449 of file UTGeometry.h.
float Rect_t::Height | ( | ) | const [inline] |
Returns the height of the rectangle (bottom minus top).
Definition at line 1456 of file UTGeometry.h.
void Rect_t::OffsetTo | ( | const Point_t & | left_top | ) |
Offsets this such that the left top corner will be positioned at the specified point.
void Rect_t::InsetBy | ( | float | value | ) | [inline] |
Insets the rectangle by the specified value on each side.
Definition at line 1463 of file UTGeometry.h.
void Rect_t::InsetBy | ( | float | left, | |
float | top, | |||
float | right, | |||
float | bottom | |||
) | [inline] |
Insets the rectangle by the specified values on each side.
Definition at line 1473 of file UTGeometry.h.
void Rect_t::ExpandBy | ( | float | value | ) | [inline] |
Expands the rectangle by the specified value on each side.
Definition at line 1483 of file UTGeometry.h.
void Rect_t::ExpandBy | ( | float | left, | |
float | top, | |||
float | right, | |||
float | bottom | |||
) | [inline] |
Expands the rectangle by the specified values on each side.
Definition at line 1493 of file UTGeometry.h.
void Rect_t::ExpandToInteger | ( | ) |
Expands the rectangle on each side to the next integer value, to an accuracy of c_dbl_abs_min_denominator.
Offsets this such that the left top corner will be positioned at the specified point, returning the result in a new rectangle. this remains unchanged.
Definition at line 1503 of file UTGeometry.h.
Rect_t Rect_t::InsetByCopy | ( | float | value | ) | const [inline] |
Insets the rectangle by the specified value on each side, returning the result in a new rectangle. this remains unchanged.
Definition at line 1512 of file UTGeometry.h.
Rect_t Rect_t::InsetByCopy | ( | float | left, | |
float | top, | |||
float | right, | |||
float | bottom | |||
) | const [inline] |
Insets the rectangle by the specified values on each side, returning the result in a new rectangle. this remains unchanged.
Definition at line 1519 of file UTGeometry.h.
Rect_t Rect_t::ExpandByCopy | ( | float | value | ) | const [inline] |
Expands the rectangle by the specified value on each side, returning the result in a new rectangle. this remains unchanged.
Definition at line 1526 of file UTGeometry.h.
Rect_t Rect_t::ExpandByCopy | ( | float | left, | |
float | top, | |||
float | right, | |||
float | bottom | |||
) | const [inline] |
Expands the rectangle by the specified values on each side, returning the result in a new rectangle. this remains unchanged.
Definition at line 1533 of file UTGeometry.h.
Point_t Rect_t::LeftTop | ( | ) | const [inline] |
Returns the point of the left, top corner.
Definition at line 1540 of file UTGeometry.h.
Point_t Rect_t::RightTop | ( | ) | const [inline] |
Returns the point of the right, top corner.
Definition at line 1547 of file UTGeometry.h.
Point_t Rect_t::LeftBottom | ( | ) | const [inline] |
Returns the point of the left, bottom corner.
Definition at line 1554 of file UTGeometry.h.
Point_t Rect_t::RightBottom | ( | ) | const [inline] |
Returns the point of the right, bottom corner.
Definition at line 1561 of file UTGeometry.h.
float Rect_t::left |
The coordinate value of the left side of the rectangle along the x axis.
Definition at line 182 of file UTGeometry.h.
float Rect_t::top |
The coordinate value of the top of the rectangle along the y axis.
Definition at line 186 of file UTGeometry.h.
float Rect_t::right |
The coordinate value of the right side of the rectangle along the x axis. For display purposes, the right value is where the right side will be rendered. For example, Rect_t(0,2,0,2) would be rendered as follows:
012 0 ### 1 # # 2 ###
Definition at line 190 of file UTGeometry.h.
float Rect_t::bottom |
The coordinate value of the bottom of the rectangle along the y axis. For display purposes, the bottom value is where the bottom side will be rendered. For example, Rect_t(0,2,0,2) would be rendered as follows:
012 0 ### 1 # # 2 ###
Definition at line 202 of file UTGeometry.h.