blip  0.1
Rectangle Class Reference

A rectangle in cartesian space. More...

#include <Rectangle.hpp>

Public Member Functions

 Rectangle () throw ()
 Construct a new Rectangle of zero size and upper-left corner located at the origin. More...
 
 Rectangle (int x, int y, int width, int height) throw ()
 Construct a new Rectangle with the given coordinates and size. More...
 
 ~Rectangle () throw ()
 Destructor. More...
 
void reshape (int x, int y, int width, int height) throw ()
 Change the shape of the rectangle. More...
 
void merge (const Rectangle &other) throw ()
 Reshape this rectangle such that it contains both its original shape and the shape of another rectangle. More...
 
bool intersects (const Rectangle &other) const throw ()
 Test if this rectangle intersects another rectangle. More...
 
void clip (const Rectangle &other) throw ()
 If this rectangle intersects another, reshape it such that it consists only of the intersection of the two rectangles. More...
 
bool contains (const Rectangle &other) const throw ()
 Test if this rectangle completely contains another rectangle. More...
 
bool isEmpty () const throw ()
 Test if the rectangle is empty, i.e., has zero width and/or height. More...
 
int getX () const throw ()
 Get the X-coordinate of the rectangle's upper-left corner. More...
 
int getY () const throw ()
 Get the Y-coordinate of the rectangle's upper-left corner. More...
 
int getWidth () const throw ()
 Get the rectangle's width. More...
 
int getHeight () const throw ()
 Get the rectangle's height. More...
 

Detailed Description

A rectangle in cartesian space.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

Rectangle ( )
throw (
)

Construct a new Rectangle of zero size and upper-left corner located at the origin.

◆ Rectangle() [2/2]

Rectangle ( int  x,
int  y,
int  width,
int  height 
)
throw (
)

Construct a new Rectangle with the given coordinates and size.

Parameters
xThe X-coordinate of the rectangle's upper-left corner.
yThe Y-coordinate of the rectangle's upper-left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.

◆ ~Rectangle()

~Rectangle ( )
throw (
)

Destructor.

Member Function Documentation

◆ clip()

void clip ( const Rectangle other)
throw (
)

If this rectangle intersects another, reshape it such that it consists only of the intersection of the two rectangles.

If the rectangles do not intersect, leaves the rectangle unmodified.

◆ contains()

bool contains ( const Rectangle other) const
throw (
)

Test if this rectangle completely contains another rectangle.

◆ getHeight()

int getHeight ( ) const
throw (
)
inline

Get the rectangle's height.

◆ getWidth()

int getWidth ( ) const
throw (
)
inline

Get the rectangle's width.

◆ getX()

int getX ( ) const
throw (
)
inline

Get the X-coordinate of the rectangle's upper-left corner.

◆ getY()

int getY ( ) const
throw (
)
inline

Get the Y-coordinate of the rectangle's upper-left corner.

◆ intersects()

bool intersects ( const Rectangle other) const
throw (
)

Test if this rectangle intersects another rectangle.

◆ isEmpty()

bool isEmpty ( ) const
throw (
)
inline

Test if the rectangle is empty, i.e., has zero width and/or height.

◆ merge()

void merge ( const Rectangle other)
throw (
)

Reshape this rectangle such that it contains both its original shape and the shape of another rectangle.

◆ reshape()

void reshape ( int  x,
int  y,
int  width,
int  height 
)
throw (
)

Change the shape of the rectangle.

Parameters
xThe new X-coordinate of the rectangle's upper-left corner.
yThe new Y-coordinate of the rectangle's upper-left corner.
widthThe new width of the rectangle.
heightThe new height of the rectangle.

The documentation for this class was generated from the following files: