|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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)
Rectangle & | operator= (const Rectangle &r)
bool | operator== (const Rectangle &r) const
bool | operator!= (const Rectangle &r) const

## Static Public Member Functions

static const Rectangle & | empty ()
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

gameplay::Rectangle::Rectangle | ( |  | ) |

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:

  width | The width of the rectangle.
  height | The 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:

  x | The x-coordinate of the rectangle.
  y | The y-coordinate of the rectangle.
  width | The width of the rectangle.
  height | The height of the rectangle.

gameplay::Rectangle::Rectangle | ( | const Rectangle & | copy | ) |

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

Parameters:

  copy | The rectangle to copy.

gameplay::Rectangle::~Rectangle | ( |  | ) |

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:

  r1 | The first rectangle to contain.
  r2 | The second rectangle to contain.
  dst | A 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:

  x | The x-coordinate of the point.
  y | The 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:

  x | The x-coordinate of the rectangle.
  y | The y-coordinate of the rectangle.
  width | The width of the rectangle.
  height | The 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:

  r | The 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:

  horizontalAmount | The value to push the sides out by.
  verticalAmount | The 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:

  r1 | The first rectangle.
  r2 | The second rectangle.
  dst | Populated 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:

  x | The x-coordinate of the rectangle.
  y | The y-coordinate of the rectangle.
  width | The width of the rectangle.
  height | The 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:

  r | The rectangle.

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

bool gameplay::Rectangle::isEmpty | ( |  | ) | const

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:

  x | The x-coordinate of the rectangle.
  y | The y-coordinate of the rectangle.
  width | The width of the rectangle.
  height | The height of the rectangle.

void gameplay::Rectangle::set | ( | const Rectangle & | r | ) |

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

Parameters:

  r | The 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:

  x | The x-coordinate of the rectangle.
  y | The 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

float gameplay::Rectangle::height

Specifies the height of the rectangle.

float gameplay::Rectangle::width

Specifies the width of the rectangle.

float gameplay::Rectangle::x

Specifies the x-coordinate of the rectangle.

float gameplay::Rectangle::y

Specifies the y-coordinate of the rectangle.

All Classes Functions Variables Typedefs Enumerations Enumerator