Pixel Dust Game Engine  v0.9.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Public Member Functions | Public Attributes | List of all members
RectT Class Reference
Collaboration diagram for RectT:
Collaboration graph
[legend]

Public Member Functions

bool empty () const
 return true if this rectangle is empty (no width or no height)
 
bool contains (const PointT< T > &p) const
 return true if the point is inside this rectangle
 
bool contains (const RectT< T > &r) const
 return true if the rectangle passed in is entirely inside this rectangle
 
bool overlaps (const RectT< T > &r) const
 return true if this rectangle overlaps the other rectangle at all (sharing an edge is not overlapping)
 
PointT< T > leftTop () const
 get the top left corner point of the rectangle
 
PointT< T > rightTop () const
 get the top right corner point of the rectangle
 
PointT< T > leftBottom () const
 get the bottom left corner point of the rectangle
 
PointT< T > rightBottom () const
 get the bottom right corner point of the rectangle
 
PointT< T > centerPoint () const
 get the center point of the rectangle, rounds down if fractional
 
x1 () const
 get the 1st x coordinate (leftmost)
 
y1 () const
 get the 1st y coordinate (topmost)
 
x2 () const
 get the 2nd x coordinate (rightmost)
 
y2 () const
 get the 2nd y coordinate (bottom-most)
 
width () const
 get the width of the rectangle
 
height () const
 get the height of the rectangle
 
RectT< T > intersection (const RectT< T > &r) const
 get a new rectangle that is the overlapping area of the the rectangles
 
RectT< T > unionWith (const RectT< T > &r) const
 get the smallest possible new rectangle that contains both rectangles
 
RectT< T > & moveLeft (T delta)
 move the rectangle to the left by some amount
 
RectT< T > & moveRight (T delta)
 move the rectangle to the right by some amount
 
RectT< T > & moveUp (T delta)
 move the rectangle up by some amount
 
RectT< T > & moveDown (T delta)
 move the rectangle down by some amount
 
RectT< T > & moveXTo (T x)
 move the rectangle to a particular x location, leaving y unchanged
 
RectT< T > & moveYTo (T y)
 move the rectangle to a particular y location, leaving x unchanged
 
RectT< T > & moveTo (T x, T y)
 move the rectangle to a particular (x, y) location
 
RectT< T > & moveTo (PointT< T > p)
 move the rectangle to a particular point
 
RectT< T > & center (PointT< T > p)
 move the rectangle to be centered over a particular point
 
RectT< T > & center (RectT< T > r)
 move the rectangle to be centered within/relative to another rectangle
 
RectT< T > & setSize (T n)
 set the size (width & height) of the rectangle
 
RectT< T > & setWidth (T w)
 set the width of the rectangle
 
RectT< T > & setHeight (T h)
 set the height of the rectangle
 
RectT< T > & horzShrink (T delta)
 reduce the width of the rectangle while leaving the center point unchanged
 
RectT< T > & vertShrink (T delta)
 reduce the height of the rectangle while leaving the center point unchanged
 
RectT< T > & horzGrow (T delta)
 increase the width of the rectangle while leaving the center point unchanged
 
RectT< T > & vertGrow (T delta)
 increase the height of the rectangle while leaving the center point unchanged
 
RectT< T > & shrink (T delta)
 reduce the height and width of the rectangle while leaving the center point unchanged
 
RectT< T > & grow (T delta)
 increase the height and width of the rectangle while leaving the center point unchanged
 
RectT< T > & horzScale (float f)
 change the x coordinates of the rectangle by a multiplier
 
RectT< T > & vertScale (float f)
 change the y coordinates of the rectangle by a multiplier
 
RectT< T > & scale (float f)
 change the coordinates of the rectangle by a multiplier
 
RectT< T > & round ()
 round the coordinates to closest whole number
 
 operator QuadT< T > ()
 
bool operator== (const RectT< T > &r2)
 return true if this rectangle is equal to the other
 
bool operator!= (const RectT< T > &r2)
 return true if this rectangle is not equal to the other
 
RectT< T > & operator= (const RectT< T > &r2)
 set rectangle equal to another
 
RectT< T > & operator+= (const PointT< T > &p1)
 offset this rectangle's location by adding x & y coordinates of the point
 
RectT< T > & operator-= (const PointT< T > &p1)
 offset this rectangle's location by subtracting x & y coordinates of the point
 
RectT< T > & operator+= (const RectT< T > &r2)
 add another rectangle to this one by adding coordinates
 
RectT< T > & operator-= (const RectT< T > &r2)
 subtract another rectangle from this one by subtracting coordinates
 
RectT< T > operator+ (const PointT< T > &p1)
 get a rectangle offset by adding the x & y coordinates of a point
 
RectT< T > operator- (const PointT< T > &p1)
 get a rectangle offset by subtracting the x & y coordinates of a point
 
RectT< T > operator+ (const RectT< T > &r2)
 add two rectangles together by adding coordinates
 
RectT< T > operator- (const RectT< T > &r2)
 subtract one rectangle from another by subtracting coordinates
 
 RectT (T wid, T hgt)
 create a rectangle with origin at (0,0) and set its height and width values
 
 RectT (T lft, T tp, T rgt, T bot)
 create a rectangle with left, top, right, and bottom coordinates (x1, y1, x2, y2) specified
 
 RectT (const PointT< T > &lftTop, const PointT< T > &rgtBot)
 create a rectangle given its top left and bottom right corner points
 
 RectT (const PointT< T > &lftTop, T wid, T hgt)
 create a rectangle given its top teft corner point and a height and width
 
 RectT ()
 create an empty rectangle with origin at (0,0)
 

Public Attributes

left
 leftmost coordinate of a rectangle on a grid or screen
 
top
 topmost coordinate of a rectangle on a grid or screen
 
right
 rightmost coordinate of a rectangle on a grid or screen
 
bottom
 bottom-most coordinate of a rectangle on a grid or screen
 

Detailed Description

Rectangle for 2D coordinate system. Rect is a class that provides support for dealing with rectangles in 2 dimensional space.

Constructor & Destructor Documentation

RectT ( wid,
hgt 
)
inline

create a rectangle with origin at (0,0) and set its height and width values

RectT ( lft,
tp,
rgt,
bot 
)
inline

create a rectangle with left, top, right, and bottom coordinates (x1, y1, x2, y2) specified

RectT ( const PointT< T > &  lftTop,
const PointT< T > &  rgtBot 
)
inline

create a rectangle given its top left and bottom right corner points

RectT ( const PointT< T > &  lftTop,
wid,
hgt 
)
inline

create a rectangle given its top teft corner point and a height and width

RectT ( )
inline

create an empty rectangle with origin at (0,0)

Member Function Documentation

RectT<T>& center ( PointT< T >  p)
inline

move the rectangle to be centered over a particular point

RectT<T>& center ( RectT< T >  r)
inline

move the rectangle to be centered within/relative to another rectangle

PointT<T> centerPoint ( ) const
inline

get the center point of the rectangle, rounds down if fractional

bool contains ( const PointT< T > &  p) const
inline

return true if the point is inside this rectangle

bool contains ( const RectT< T > &  r) const
inline

return true if the rectangle passed in is entirely inside this rectangle

bool empty ( ) const
inline

return true if this rectangle is empty (no width or no height)

RectT<T>& grow ( delta)
inline

increase the height and width of the rectangle while leaving the center point unchanged

T height ( ) const
inline

get the height of the rectangle

RectT<T>& horzGrow ( delta)
inline

increase the width of the rectangle while leaving the center point unchanged

RectT<T>& horzScale ( float  f)
inline

change the x coordinates of the rectangle by a multiplier

RectT<T>& horzShrink ( delta)
inline

reduce the width of the rectangle while leaving the center point unchanged

RectT<T> intersection ( const RectT< T > &  r) const
inline

get a new rectangle that is the overlapping area of the the rectangles

PointT<T> leftBottom ( ) const
inline

get the bottom left corner point of the rectangle

PointT<T> leftTop ( ) const
inline

get the top left corner point of the rectangle

RectT<T>& moveDown ( delta)
inline

move the rectangle down by some amount

RectT<T>& moveLeft ( delta)
inline

move the rectangle to the left by some amount

RectT<T>& moveRight ( delta)
inline

move the rectangle to the right by some amount

RectT<T>& moveTo ( x,
y 
)
inline

move the rectangle to a particular (x, y) location

RectT<T>& moveTo ( PointT< T >  p)
inline

move the rectangle to a particular point

RectT<T>& moveUp ( delta)
inline

move the rectangle up by some amount

RectT<T>& moveXTo ( x)
inline

move the rectangle to a particular x location, leaving y unchanged

RectT<T>& moveYTo ( y)
inline

move the rectangle to a particular y location, leaving x unchanged

operator QuadT< T > ( )
inline
bool operator!= ( const RectT< T > &  r2)

return true if this rectangle is not equal to the other

RectT<T> operator+ ( const PointT< T > &  p1)

get a rectangle offset by adding the x & y coordinates of a point

RectT<T> operator+ ( const RectT< T > &  r2)

add two rectangles together by adding coordinates

RectT<T>& operator+= ( const PointT< T > &  p1)

offset this rectangle's location by adding x & y coordinates of the point

RectT<T>& operator+= ( const RectT< T > &  r2)

add another rectangle to this one by adding coordinates

RectT<T> operator- ( const PointT< T > &  p1)

get a rectangle offset by subtracting the x & y coordinates of a point

RectT<T> operator- ( const RectT< T > &  r2)

subtract one rectangle from another by subtracting coordinates

RectT<T>& operator-= ( const PointT< T > &  p1)

offset this rectangle's location by subtracting x & y coordinates of the point

RectT<T>& operator-= ( const RectT< T > &  r2)

subtract another rectangle from this one by subtracting coordinates

RectT<T>& operator= ( const RectT< T > &  r2)

set rectangle equal to another

bool operator== ( const RectT< T > &  r2)

return true if this rectangle is equal to the other

bool overlaps ( const RectT< T > &  r) const
inline

return true if this rectangle overlaps the other rectangle at all (sharing an edge is not overlapping)

PointT<T> rightBottom ( ) const
inline

get the bottom right corner point of the rectangle

PointT<T> rightTop ( ) const
inline

get the top right corner point of the rectangle

RectT<T>& round ( )
inline

round the coordinates to closest whole number

RectT<T>& scale ( float  f)
inline

change the coordinates of the rectangle by a multiplier

RectT<T>& setHeight ( h)
inline

set the height of the rectangle

RectT<T>& setSize ( n)
inline

set the size (width & height) of the rectangle

RectT<T>& setWidth ( w)
inline

set the width of the rectangle

RectT<T>& shrink ( delta)
inline

reduce the height and width of the rectangle while leaving the center point unchanged

RectT<T> unionWith ( const RectT< T > &  r) const
inline

get the smallest possible new rectangle that contains both rectangles

RectT<T>& vertGrow ( delta)
inline

increase the height of the rectangle while leaving the center point unchanged

RectT<T>& vertScale ( float  f)
inline

change the y coordinates of the rectangle by a multiplier

RectT<T>& vertShrink ( delta)
inline

reduce the height of the rectangle while leaving the center point unchanged

T width ( ) const
inline

get the width of the rectangle

T x1 ( ) const
inline

get the 1st x coordinate (leftmost)

T x2 ( ) const
inline

get the 2nd x coordinate (rightmost)

T y1 ( ) const
inline

get the 1st y coordinate (topmost)

T y2 ( ) const
inline

get the 2nd y coordinate (bottom-most)

Member Data Documentation

T bottom

bottom-most coordinate of a rectangle on a grid or screen

T left

leftmost coordinate of a rectangle on a grid or screen

T right

rightmost coordinate of a rectangle on a grid or screen

T top

topmost coordinate of a rectangle on a grid or screen