#include <Pt/Gfx/Rect.h>
Floating-point rectangle. More...
Public Member Functions | |
| bool | isEmpty () const |
| Returns true if width or height is zero. | |
| Rect | toIntersected (const Rect &rect) const |
| Returns the intersection of this rect and another, or an empty rect if they do not overlap. | |
| bool | contains (const Point &p) const |
| Returns true if the given point is inside or on the edge of this rect. | |
| bool | contains (const Rect &r) const |
| Returns true if the given rect is entirely inside this rect. | |
| bool | intersects (const Rect &r) const |
| Returns true if this rect overlaps with the given rect. | |
| Point | center () const |
| Returns the center point of this rect. | |
| void | normalize () |
| Normalizes this rect so that width and height are non-negative. | |
| Rect | toNormalized () const |
| Returns a normalized copy of this rect. | |
| Rect (const RectI &r) | |
| Constructs from a RectI by widening the coordinates. | |
| Rect & | operator= (const RectI &r) |
| Assigns from a RectI by widening the coordinates. | |
| RectI | round () const |
| Rounds each component to the nearest integer and returns a RectI. | |
| RectI | floor () const |
| Floors each component and returns a RectI. | |
| RectI | ceil () const |
| Ceils each component and returns a RectI. | |
| RectI | roundOut () const |
| Returns the smallest enclosing integer rect. | |
| RectI | roundIn () const |
| Returns the largest integer rect contained within this rect. | |
Rect is an origin Point and a Size. Drawing clips, fill rectangles, and path bounds use this type. Image regions use integer rectangles; convert with round(), floor(), ceil(), roundOut(), or roundIn() when a pixel rect is required. RectF is a typedef of this type.
The origin is the top-left. right() and bottom() are origin plus size, and contains(const Point&) treats the right and bottom edges as exclusive. isEmpty() is true when width or height is zero. Negative width or height is allowed until normalize() moves the origin so both are non-negative.
Construct from a point and a size, from a size at the origin, from two corner points, or with fromLTRB() and fromXYWH(). Widen a RectI with the explicit constructor.
unify() grows this rect to include another. toIntersected() returns the overlap, or an empty rect. intersects() is true when the interiors overlap.
The example constructs a clip rectangle and tests a point.