RectI Class Reference

#include <Pt/Gfx/Rect.h>

Integer rectangle. More...

Public Member Functions

bool isEmpty () const
 Returns true if width or height is zero.
RectI toIntersected (const RectI &rect) const
 Returns the intersection of this rect and another, or an empty rect if they do not overlap.
bool contains (const PointI &p) const
 Returns true if the given point is inside or on the edge of this rect.
bool contains (const RectI &r) const
 Returns true if the given rect is entirely inside this rect.
bool intersects (const RectI &r) const
 Returns true if this rect overlaps with the given rect.
PointI center () const
 Returns the center point of this rect.
void normalize ()
 Normalizes this rect so that width and height are non-negative.
RectI toNormalized () const
 Returns a normalized copy of this rect.

Static Public Member Functions

static RectI fromLTRB (Int left, Int top, Int right, Int bottom)
 Creates a rect from left, top, right, and bottom edges.
static RectI fromXYWH (Int x, Int y, Int w, Int h)
 Creates a rect from x, y, width, and height.

Detailed Description

RectI is the integer counterpart of Rect: a PointI origin and a SizeI. Image regions and rounded drawing rectangles use this type. Widen it to Rect when a painter needs a floating-point rectangle.

Geometry matches Rect, including exclusive right and bottom edges in contains(). There is no rounding API on this type: rounding is how a Rect becomes a RectI.