A *Rectangle* is a position with a size.
More...

`#include <Dimensions.hh>`

Inheritance diagram for PIRL::Rectangle:

Collaboration diagram for PIRL::Rectangle:

## 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).

**Version:**

**Revision:**- 1.27

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.

**Parameters:**-
x The horizontal (x-axis) position of the Rectangle. y The vertical (y-axis) position of the Rectangle.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Point_2D.

Reimplemented in PIRL::Cube.

References position().

Set the position of this Rectangle.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Point_2D.

Reimplemented in PIRL::Cube.

References position().

Assign the position of the Rectangle from a Point_2D.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Point_2D.

Reimplemented in PIRL::Cube.

Referenced by operator=().

Point_2D PIRL::Rectangle::position | ( | ) | const` [inline]` |

Get the Rectangle position.

**Returns:**- A Point_2D with the Rectangle position.
**N.B.**: Changing this Point_2D will not change the position of the Rectangle.

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.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Size_2D.

Reimplemented in PIRL::Cube.

References size().

Set the size of this Rectangle.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Size_2D.

Reimplemented in PIRL::Cube.

References size().

Assign the size of the Rectangle from a Size_2D.

**Returns:**- This Rectangle.

Reimplemented from PIRL::Size_2D.

Reimplemented in PIRL::Cube.

References operator=().

Size_2D PIRL::Rectangle::size | ( | ) | const` [inline]` |

Get the Rectangle size.

**Returns:**- A Size_2D with the Rectangle size.
**N.B.**: Changing this size will not change the size of the Rectangle.

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.

**Returns:**- 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.

**Returns:**- true if any dimension value is non-zero; false otherwise.

Reimplemented from PIRL::Point_2D.

Reimplemented in PIRL::Cube.

Add an offset.

**Parameters:**-
offset A Point_2D that provides the offset values.

**Returns:**- This Rectangle with its values offset.

Reimplemented from PIRL::Point_2D.

Referenced by operator+=().

Add a size amount.

**Parameters:**-
size A Size_2D that provides the amount values.

**Returns:**- This Rectangle with the amount added to its size values.

Reimplemented from PIRL::Size_2D.

References operator+=().

Add another Rectangle's point coordinate offset and size amount.

**Parameters:**-
rectangle A Rectangle.

**Returns:**- This Rectangle with its point coordinate offset by the other Rectangle's point coordinate values, and the other Rectangle's size amount added to its size dimensions.

References operator+=().

Subtract an offset.

**Parameters:**-
offset A Point_2D that provides the offset values.

**Returns:**- This Rectangle with its values offset.

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.

**Parameters:**-
size A Size_2D that provides the amount values.

**Returns:**- This Rectangle with the amount subtracted to its values.

Reimplemented from PIRL::Size_2D.

References operator-=().

Subtract another Rectangle's point coordinate offset and size amount.

**Parameters:**-
rectangle A Rectangle.

**Returns:**- This Rectangle with its point coordinate offset by the other Rectangle's point coordinate values, and the other Rectangle's size amount subtracted from its size dimensions.

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.

**Parameters:**-
factor A factor by which to multiply the Size_2D dimensions.

**Returns:**- This Rectangle with its values changed.

**Exceptions:**-
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.

**Parameters:**-
factor A factor by which to divide the Size_2D dimensions.

**Returns:**- This Rectangle with its values changed.

**Exceptions:**-
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.

**Returns:**- This Rectangle with its position and size set to the intersection with the other Rectangle. If the Rectangles do not intersect this will result in a Rectangle with no area (Width and Height both zero) but the position will be unchanged.

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.

**Returns:**- This Rectangle with its position and size set to the union - i.e. the bounding box - with the other Rectangle.

References PIRL::Size_2D::Height, PIRL::Size_2D::Width, PIRL::Point_2D::X, and PIRL::Point_2D::Y.

Referenced by PIRL::Cube::operator|=().

The documentation for this struct was generated from the following files:

Generated on Thu Jan 19 2017 14:47:09 for PIRL++ by 1.7.2