#include "gtypes.h"

class GRectangle

This type contains real-valued x, y, width, and height fields. It is used to represent the bounding box of a graphical object.
Constructor
GRectangle()
GRectangle(xywidthheight) 
Creates a GRectangle object with the specified components.
Methods
contains(pt)
contains(xy) 
Returns true if the rectangle contains the given point, which may be specified either as a point or as distinct coordinates.
getHeight() Returns the height component of the rectangle.
getWidth() Returns the width component of the rectangle.
getX() Returns the x component of the rectangle.
getY() Returns the y component of the rectangle.
isEmpty() Returns true if the rectangle is empty.
toString() Converts the GRectangle to a string in the form "(x, y, width, height)".

Constructor detail


GRectangle();
GRectangle(double x, double y, double width, double height);
Creates a GRectangle object with the specified components. If these parameters are not supplied, the default constructor sets these fields to 0.

Usage:

GRectangle empty;
GRectangle r(x, y, width, height);

Method detail


double getX() const;
Returns the x component of the rectangle.

Usage:

double x = r.getX();

double getY() const;
Returns the y component of the rectangle.

Usage:

double y = pt.getY();

double getWidth() const;
Returns the width component of the rectangle.

Usage:

double width = r.getWidth();

double getHeight() const;
Returns the height component of the rectangle.

Usage:

double height = pt.getHeight();

bool isEmpty() const;
Returns true if the rectangle is empty.

Usage:

if (r.isEmpty()) ...

bool contains(GPoint pt) const;
bool contains(double x, double y) const;
Returns true if the rectangle contains the given point, which may be specified either as a point or as distinct coordinates.

Usage:

if (r.contains(pt)) ...
if (r.contains(x, y)) ...

string toString() const;
Converts the GRectangle to a string in the form "(x, y, width, height)".

Usage:

string str = r.toString();