PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIRect< Type > Class Template Reference

The PIRect class provides a two-dimensional rectangle class for 2D geometry. More...

#include <pirect.h>

Public Member Functions

 PIRect ()
 Constructs empty rectangle.
 
 PIRect (Type left_, Type bottom_, Type width_, Type height_)
 Constructs rectangle from bottom-left corner, width and height.
 
 PIRect (const PIPoint< Type > &bottom_left, const PIPoint< Type > &top_right)
 Constructs rectangle from opposite corners.
 
PIRect< Type > & set (Type left_, Type bottom_, Type width_, Type height_)
 Sets rectangle from bottom-left corner, width and height.
 
PIRect< Type > & set (const PIPoint< Type > &top_left, const PIPoint< Type > &bottom_right)
 Sets rectangle from two opposite corners.
 
bool pointIn (Type x, Type y) const
 Checks point against current rectangle bounds.
 
bool pointIn (const PIPoint< Type > &p) const
 Checks point against current rectangle bounds.
 
bool isEmpty () const
 Returns true if width and height are zero.
 
PIRect< Type > & translate (Type x, Type y)
 Shifts the rectangle by x and y.
 
PIRect< Type > & translate (const PIPoint< Type > &p)
 Shifts the rectangle by a point offset.
 
PIRect< Type > translated (Type x, Type y) const
 Returns translated copy of the rectangle.
 
PIRect< Type > translated (const PIPoint< Type > &p) const
 Returns copy shifted by a point offset.
 
PIRect< Type > & move (Type x, Type y)
 Same as translate().
 
PIRect< Type > & move (const PIPoint< Type > &p)
 Same as translate().
 
PIRect< Type > moved (Type x, Type y) const
 Same as translated().
 
PIRect< Type > moved (const PIPoint< Type > &p) const
 Same as translated().
 
PIRect< Type > & scale (Type x, Type y)
 Scales rectangle extents by x and y.
 
PIRect< Type > & scale (Type s)
 Scales both extents by s.
 
PIRect< Type > & scale (const PIPoint< Type > &p)
 Scales extents by point components.
 
PIRect< Type > scaled (Type x, Type y) const
 Returns scaled copy of the rectangle.
 
PIRect< Type > scaled (Type s) const
 Returns copy scaled uniformly.
 
PIRect< Type > scaled (const PIPoint< Type > &p) const
 Returns copy scaled by point components.
 
PIRect< Type > & normalize ()
 Normalizes corner order.
 
PIRect< Type > normalized () const
 Returns normalized copy of the rectangle.
 
PIRect< Type > & unite (const PIRect< Type > &r)
 Updates bounds using rectangle r and normalizes the result.
 
PIRect< Type > united (const PIRect< Type > &rect) const
 Returns copy after unite().
 
PIRect< Type > & intersect (const PIRect< Type > &r)
 Replaces rectangle with intersection with r.
 
PIRect< Type > intersected (const PIRect< Type > &rect) const
 Returns copy after intersect().
 
Type top () const
 Returns top edge coordinate.
 
Type left () const
 Returns left edge coordinate.
 
Type right () const
 Returns right edge coordinate.
 
Type bottom () const
 Returns bottom edge coordinate.
 
Type width () const
 Returns rectangle width.
 
Type height () const
 Returns rectangle height.
 
PIPoint< Type > topLeft () const
 Returns top-left corner.
 
PIPoint< Type > topRigth () const
 Returns top-right corner.
 
PIPoint< Type > bottomLeft () const
 Returns bottom-left corner.
 
PIPoint< Type > bottomRight () const
 Returns bottom-right corner.
 
PIPoint< Type > center () const
 Returns rectangle center.
 
void setTop (Type v)
 Sets top edge coordinate.
 
void setLeft (Type v)
 Sets left edge coordinate.
 
void setRigth (Type v)
 Sets right edge coordinate.
 
void setBottom (Type v)
 Sets bottom edge coordinate.
 
void setWidth (Type v)
 Updates stored width-related extent.
 
void setHeight (Type v)
 Updates stored height-related extent.
 
void setTopLeft (const PIPoint< Type > &p)
 Sets top-left corner.
 
void setBottomRight (const PIPoint< Type > &p)
 Sets bottom-right corner.
 
void setBottomLeft (const PIPoint< Type > &p)
 Sets bottom-left corner.
 
void setTopRigth (const PIPoint< Type > &p)
 Sets top-right corner.
 
void setCenter (const PIPoint< Type > &p)
 Repositions rectangle around center point p.
 
void setSize (Type w, Type h)
 Sets rectangle size from current bottom-left corner.
 
void operator+= (Type x)
 Shifts both coordinates by x.
 
void operator+= (const PIPoint< Type > &p)
 Shifts rectangle by a point offset.
 
void operator-= (Type x)
 Shifts both coordinates by -x.
 
void operator-= (const PIPoint< Type > &p)
 Shifts rectangle by the negated point offset.
 
void operator|= (const PIRect< Type > &r)
 Same as unite().
 
void operator&= (const PIRect< Type > &r)
 Same as intersect().
 
PIRect< Type > operator+ (const PIPoint< Type > &p)
 Returns translated copy of the rectangle.
 
PIRect< Type > operator- (const PIPoint< Type > &p)
 Returns copy shifted by the negated point offset.
 
PIRect< Type > operator| (const PIRect< Type > &r)
 Returns copy after unite().
 
PIRect< Type > operator& (const PIRect< Type > &r)
 Returns copy after intersect().
 
bool operator== (const PIRect< Type > &r) const
 Checks whether rectangle corners are equal.
 
bool operator!= (const PIRect< Type > &r) const
 Checks whether rectangle corners differ.
 

Detailed Description

template<typename Type>
class PIRect< Type >

The PIRect class provides a two-dimensional rectangle class for 2D geometry.