SimpleCxxLib packageclass GRectangle| Constructor | |
GRectangle(x, y, width, height) | Creates a GRectangle object with the specified components. |
| Methods | |
contains(x, y) | Returns true if the rectangle contains the given point, which may be specified either as a point or as distinct coordinates. |
| Returns the height component of the rectangle. | |
| Returns the width component of the rectangle. | |
| Returns the x component of the rectangle. | |
| Returns the y component of the rectangle. | |
Returns true if the rectangle is empty. | |
Converts the GRectangle to a string in the form "(x, y, width, height)". | |
GRectangle(); GRectangle(double x, double y, double width, double height);
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);
double getX() const;
Usage:
double x = r.getX();
double getY() const;
Usage:
double y = pt.getY();
double getWidth() const;
Usage:
double width = r.getWidth();
double getHeight() const;
Usage:
double height = pt.getHeight();
bool isEmpty() const;
true if the rectangle is empty.
Usage:
if (r.isEmpty()) ...
bool contains(GPoint pt) const; bool contains(double x, double y) const;
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;
GRectangle to a string in the form
"(x, y,
width, height)".
Usage:
string str = r.toString();