overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | Public Attributes
gameplay::Rectangle Class Reference

#include <Rectangle.h>

List of all members.

Public Member Functions

 Rectangle ()
 Rectangle (float width, float height)
 Rectangle (float x, float y, float width, float height)
 Rectangle (const Rectangle &copy)
 ~Rectangle ()
bool isEmpty () const
void set (float x, float y, float width, float height)
void set (const Rectangle &r)
void setPosition (float x, float y)
float left () const
float top () const
float right () const
float bottom () const
bool contains (float x, float y) const
bool contains (float x, float y, float width, float height) const
bool contains (const Rectangle &r) const
bool intersects (float x, float y, float width, float height) const
bool intersects (const Rectangle &r) const
void inflate (float horizontalAmount, float verticalAmount)
Rectangleoperator= (const Rectangle &r)
bool operator== (const Rectangle &r) const
bool operator!= (const Rectangle &r) const

Static Public Member Functions

static const Rectangleempty ()
static bool intersect (const Rectangle &r1, const Rectangle &r2, Rectangle *dst)
static void combine (const Rectangle &r1, const Rectangle &r2, Rectangle *dst)

Public Attributes

float x
float y
float width
float height

Detailed Description

Defines a rectangle.


Constructor & Destructor Documentation

Constructs a new rectangle initialized to all zeros.

gameplay::Rectangle::Rectangle ( float  width,
float  height 
)

Constructs a new rectangle with the x = 0, y = 0 and the specified width and height.

Parameters:
widthThe width of the rectangle.
heightThe height of the rectangle.
gameplay::Rectangle::Rectangle ( float  x,
float  y,
float  width,
float  height 
)

Constructs a new rectangle with the specified x, y, width and height.

Parameters:
xThe x-coordinate of the rectangle.
yThe y-coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.

Constructs a new rectangle that is a copy of the specified rectangle.

Parameters:
copyThe rectangle to copy.

Destructor.


Member Function Documentation

float gameplay::Rectangle::bottom ( ) const

Returns the y-coordinate of the bottom of the rectangle.

Returns:
The y-coordinate of the bottom of the rectangle.
static void gameplay::Rectangle::combine ( const Rectangle r1,
const Rectangle r2,
Rectangle dst 
) [static]

Returns a new rectangle that exactly contains two other rectangles.

Parameters:
r1The first rectangle to contain.
r2The second rectangle to contain.
dstA rectangle to store the union of the two rectangle parameters.
bool gameplay::Rectangle::contains ( float  x,
float  y 
) const

Determines whether this rectangle contains a specified point.

Parameters:
xThe x-coordinate of the point.
yThe y-coordinate of the point.
Returns:
true if the rectangle contains the point, false otherwise.
bool gameplay::Rectangle::contains ( float  x,
float  y,
float  width,
float  height 
) const

Determines whether this rectangle contains a specified rectangle.

Parameters:
xThe x-coordinate of the rectangle.
yThe y-coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
Returns:
true if the rectangle contains the specified rectangle, false otherwise.
bool gameplay::Rectangle::contains ( const Rectangle r) const

Determines whether this rectangle contains a specified rectangle.

Parameters:
rThe rectangle.
Returns:
true if the rectangle contains the specified rectangle, false otherwise.
static const Rectangle& gameplay::Rectangle::empty ( ) [static]

Returns a rectangle with all of its values set to zero.

Returns:
The empty rectangle with all of its values set to zero.
void gameplay::Rectangle::inflate ( float  horizontalAmount,
float  verticalAmount 
)

Pushes the edges of the Rectangle out by the horizontal and vertical values specified.

Each corner of the Rectangle is pushed away from the center of the rectangle by the specified amounts. This results in the width and height of the Rectangle increasing by twice the values provided.

Parameters:
horizontalAmountThe value to push the sides out by.
verticalAmountThe value to push the top and bottom out by.
static bool gameplay::Rectangle::intersect ( const Rectangle r1,
const Rectangle r2,
Rectangle dst 
) [static]

Computes the intersection of two rectangles and returns the result.

Parameters:
r1The first rectangle.
r2The second rectangle.
dstPopulated with the resulting intersection, or Rectangle.empty if they do not intersect.
Returns:
True if the two rectangles intersect, false otherwise.
bool gameplay::Rectangle::intersects ( float  x,
float  y,
float  width,
float  height 
) const

Determines whether a specified rectangle intersects with this rectangle. Rectangles intersect if there is a common point that is contained in both rectangles.

Parameters:
xThe x-coordinate of the rectangle.
yThe y-coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
Returns:
true if the specified Rectangle intersects with this one, false otherwise.
bool gameplay::Rectangle::intersects ( const Rectangle r) const

Determines whether a specified rectangle intersects with this rectangle.

Parameters:
rThe rectangle.
Returns:
true if the specified rectangle intersects with this one, false otherwise.

Gets a value that indicates whether the rectangle is empty.

Returns:
true if the rectangle is empty, false otherwise.
float gameplay::Rectangle::left ( ) const

Returns the x-coordinate of the left side of the rectangle.

Returns:
The x-coordinate of the left side of the rectangle.
bool gameplay::Rectangle::operator!= ( const Rectangle r) const

operator !=

Rectangle& gameplay::Rectangle::operator= ( const Rectangle r)

operator =

bool gameplay::Rectangle::operator== ( const Rectangle r) const

operator ==

float gameplay::Rectangle::right ( ) const

Returns the x-coordinate of the right side of the rectangle.

Returns:
The x-coordinate of the right side of the rectangle.
void gameplay::Rectangle::set ( float  x,
float  y,
float  width,
float  height 
)

Sets the values of this rectangle to the specified values.

Parameters:
xThe x-coordinate of the rectangle.
yThe y-coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
void gameplay::Rectangle::set ( const Rectangle r)

Sets the values of this rectangle to those in the specified rectangle.

Parameters:
rThe rectangle to copy.
void gameplay::Rectangle::setPosition ( float  x,
float  y 
)

Sets the x-coordinate and y-coordinate values of this rectangle to the specified values.

Parameters:
xThe x-coordinate of the rectangle.
yThe y-coordinate of the rectangle.
float gameplay::Rectangle::top ( ) const

Returns the y-coordinate of the top of the rectangle.

Returns:
The y-coordinate of the top of the rectangle.

Member Data Documentation

Specifies the height of the rectangle.

Specifies the width of the rectangle.

Specifies the x-coordinate of the rectangle.

Specifies the y-coordinate of the rectangle.

 All Classes Functions Variables Typedefs Enumerations Enumerator