A Rectangle is a position with a size. More...
#include <Dimensions.hh>


Public Member Functions | |
| Rectangle () | |
| Constructs an empty Rectangle. | |
| Rectangle (const Coordinate_Type x, const Coordinate_Type y, const Dimensions_Type width=0, const Dimensions_Type height=0) | |
| Constructs a Rectangle from an x,y position and width,height size. | |
| Rectangle (const Point_2D &position, const Size_2D &size) | |
| Constructs a Rectangle from a position and a size. | |
| Rectangle (const Size_2D &size) | |
| Constructs a Rectangle from a size at position 0,0. | |
| Rectangle (const Rectangle &rectangle) | |
| Constructs a Rectangle as a copy of another Rectangle. | |
| Rectangle & | position (const Coordinate_Type &x, const Coordinate_Type &y) |
| Set the position of this Rectangle. | |
| Rectangle & | position (const Point_2D &point) |
| Set the position of this Rectangle. | |
| Rectangle & | operator= (const Point_2D &point) |
| Assign the position of the Rectangle from a Point_2D. | |
| Point_2D | position () const |
| Get the Rectangle position. | |
| operator Point_2D () const | |
| Convert the Rectangle to its corresponding Point_2D. | |
| Rectangle & | size (const Dimensions_Type &width, const Dimensions_Type &height) |
| Set the size of this Rectangle. | |
| Rectangle & | size (const Size_2D &size) |
| Set the size of this Rectangle. | |
| Rectangle & | operator= (const Size_2D &size) |
| Assign the size of the Rectangle from a Size_2D. | |
| Size_2D | size () const |
| Get the Rectangle size. | |
| operator Size_2D () const | |
| Convert the Rectangle to its corresponding Size_2D. | |
| Rectangle & | operator= (const Rectangle &rectangle) |
| Assign the position and size of another Rectangle to this Rectangle. | |
| bool | operator== (const Rectangle &rectangle) const |
| Test if this Rectangle is equal to another Rectangle. | |
| bool | operator!= (const Rectangle &rectangle) const |
| Test if this Rectangle is not equal to another Rectangle. | |
| operator bool () | |
| Test for all zero dimension values. | |
| Rectangle & | operator+= (const Point_2D &offset) |
| Add an offset. | |
| Rectangle & | operator+= (const Size_2D &size) |
| Add a size amount. | |
| Rectangle & | operator+= (const Rectangle &rectangle) |
| Add another Rectangle's point coordinate offset and size amount. | |
| Rectangle & | operator-= (const Point_2D &offset) |
| Subtract an offset. | |
| Rectangle & | operator-= (const Size_2D &size) |
| Subtract a size amount. | |
| Rectangle & | operator-= (const Rectangle &rectangle) |
| Subtract another Rectangle's point coordinate offset and size amount. | |
| Rectangle & | operator*= (double factor) |
| Multiply by a factor. | |
| Rectangle & | operator/= (double factor) |
| Divide by a factor. | |
| Rectangle & | operator&= (const Rectangle &rectangle) |
| Take the intersection with another Rectangle. | |
| Rectangle & | operator|= (const Rectangle &rectangle) |
| Take the union with another Rectangle. | |
A Rectangle is a position with a size.
The Rectangle's position is based in a Point_2D being at the upper left corner of the Rectangle, and its size is based in a Size_2D with the X-axis Width increasing to the right and the Y-axis Height increasing downward (raster order).
| PIRL::Rectangle::Rectangle | ( | ) |
Constructs an empty Rectangle.
The position is 0,0 and the size is 0,0.
| PIRL::Rectangle::Rectangle | ( | const Coordinate_Type | x, |
| const Coordinate_Type | y, | ||
| const Dimensions_Type | width = 0, |
||
| const Dimensions_Type | height = 0 |
||
| ) |
| PIRL::Rectangle::Rectangle | ( | const Size_2D & | size ) |
| PIRL::Rectangle::Rectangle | ( | const Rectangle & | rectangle ) |
| Rectangle& PIRL::Rectangle::position | ( | const Coordinate_Type & | x, |
| const Coordinate_Type & | y | ||
| ) | [inline] |
Set the position of this Rectangle.
| x | The horizontal (x-axis) position of the Rectangle. |
| y | The vertical (y-axis) position of the Rectangle. |
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
References position().
Set the position of this Rectangle.
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
References position().
Assign the position of the Rectangle from a Point_2D.
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
Referenced by operator=().
| Point_2D PIRL::Rectangle::position | ( | ) | const [inline] |
Get the Rectangle position.
References PIRL::Point_2D::Point_2D(), PIRL::Point_2D::X, and PIRL::Point_2D::Y.
Referenced by operator Point_2D(), PIRL::Cube::position(), and position().
| PIRL::Rectangle::operator Point_2D | ( | ) | const [inline] |
Convert the Rectangle to its corresponding Point_2D.
References position().
| Rectangle& PIRL::Rectangle::size | ( | const Dimensions_Type & | width, |
| const Dimensions_Type & | height | ||
| ) | [inline] |
Set the size of this Rectangle.
Reimplemented from PIRL::Size_2D.
Reimplemented in PIRL::Cube.
References size().
Set the size of this Rectangle.
Reimplemented from PIRL::Size_2D.
Reimplemented in PIRL::Cube.
References size().
Assign the size of the Rectangle from a Size_2D.
Reimplemented from PIRL::Size_2D.
Reimplemented in PIRL::Cube.
References operator=().
| Size_2D PIRL::Rectangle::size | ( | ) | const [inline] |
Get the Rectangle size.
References PIRL::Size_2D::Height, PIRL::Size_2D::Size_2D(), and PIRL::Size_2D::Width.
Referenced by operator Size_2D(), PIRL::Cube::size(), and size().
| PIRL::Rectangle::operator Size_2D | ( | ) | const [inline] |
Assign the position and size of another Rectangle to this Rectangle.
Reimplemented in PIRL::Cube.
References PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.
| bool PIRL::Rectangle::operator== | ( | const Rectangle & | rectangle ) | const [inline] |
| bool PIRL::Rectangle::operator!= | ( | const Rectangle & | rectangle ) | const [inline] |
| PIRL::Rectangle::operator bool | ( | ) | [inline] |
Test for all zero dimension values.
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
Add an offset.
| offset | A Point_2D that provides the offset values. |
Reimplemented from PIRL::Point_2D.
Referenced by operator+=().
Add a size amount.
| size | A Size_2D that provides the amount values. |
Reimplemented from PIRL::Size_2D.
References operator+=().
Add another Rectangle's point coordinate offset and size amount.
| rectangle | A Rectangle. |
References operator+=().
Subtract an offset.
| offset | A Point_2D that provides the offset values. |
Reimplemented from PIRL::Point_2D.
Referenced by operator-=().
Subtract a size amount.
N.B.: If the size Dimensions_Type values are an unsigned type (as they are by default) and a size amount to be subtracted is greater than the corresponding dimension value, the result will be zero.
| size | A Size_2D that provides the amount values. |
Reimplemented from PIRL::Size_2D.
References operator-=().
Subtract another Rectangle's point coordinate offset and size amount.
| rectangle | A Rectangle. |
References operator-=().
| Rectangle& PIRL::Rectangle::operator*= | ( | double | factor ) | [inline] |
Multiply by a factor.
The new size values will be rounded to the nearest Dimensions_Types.
| factor | A factor by which to multiply the Size_2D dimensions. |
| invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
| Rectangle& PIRL::Rectangle::operator/= | ( | double | factor ) | [inline] |
Divide by a factor.
The new size dimensions will be rounded to the nearest Dimensions_Type values.
N.B.: Divide by zero is handled as a special case. If the coordinate value was zero it will remain zero. If the Dimensions_Type has an infinity value (determined by numeric_types) that is used, or its negative if the coordinate value is negative. Otherwise, if the Dimensions_Type is signed the type's max value is used, or the min value if the coordinate value is negative; for an unsigned value the max value is used.
| factor | A factor by which to divide the Size_2D dimensions. |
| invalid_argument | If the factor is negative and the size values Dimensions_Type are an unsigned type (as they are by default). |
Reimplemented from PIRL::Point_2D.
Reimplemented in PIRL::Cube.
Referenced by PIRL::Cube::operator/=().
Take the intersection with another Rectangle.
The intersection of two Rectangles is the overlapping area of both.
References PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.
Referenced by PIRL::Cube::operator&=().
Take the union with another Rectangle.
The union of two Rectangles is the bounding area of both.
References PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.
Referenced by PIRL::Cube::operator|=().
1.7.2