This struct contains real-valued x, y, width, and height fields. More...
#include "gtypes.h"
Public Member Functions | |
GRectangle(double x=0, double y=0, double width=0, double height=0) | |
Creates a GRectangle object with the specified position and size. More... | |
GRectangle(double x, double y, const GDimension &size) | |
Creates a GRectangle object with the specified position and size. More... | |
GRectangle(const GPoint &p, double width=0, double height=0) | |
Creates a GRectangle object with the specified position and size. More... | |
GRectangle(const GPoint &p, const GDimension &size) | |
Creates a GRectangle object with the specified position and size. More... | |
bool | contains(double x, double y) const |
Returns true if the rectangle contains the given point. More... | |
bool | contains(const GPoint &pt) const |
Returns true if the rectangle contains the given point. More... | |
bool | contains(const GRectangle &rect) const |
Returns true if this rectangle contains the given rectangle entirely. More... | |
GRectangle | enlargedBy(double amount) |
Returns a new rectangle with its boundaries shifted outward by the given amount on all 4 sides. More... | |
bool | intersects(const GRectangle &other) const |
Returns true if this rectangle and the given other rectangle overlap. More... | |
bool | isEmpty() const |
Returns true if the rectangle is empty, meaning that it has a width and height that are both 0 or negative. More... | |
string | toString() const |
Converts the GRectangle to a string in the form "(</code><i>x</i><code>,</code> <i>y</i><code>,</code>
<i>width</i><code>,</code> <i>height</i><code>)" . More... | |
Public Attributes | |
double | height |
double | width |
double | x |
double | y |
This struct contains real-valued x, y, width, and height fields.
It is used to represent the bounding box of a graphical object.
GRectangle | ( | double | x = 0 , |
double | y = 0 , |
||
double | width = 0 , |
||
double | height = 0 |
||
) |
Creates a GRectangle
object with the specified position and size.
If these parameters are not supplied, the constructor sets these fields to 0.
GRectangle | ( | double | x, |
double | y, | ||
const GDimension & | size | ||
) |
Creates a GRectangle
object with the specified position and size.
If these parameters are not supplied, the constructor sets these fields to 0.
GRectangle | ( | const GPoint & | p, |
double | width = 0 , |
||
double | height = 0 |
||
) |
Creates a GRectangle
object with the specified position and size.
If these parameters are not supplied, the constructor sets these fields to 0.
GRectangle | ( | const GPoint & | p, |
const GDimension & | size | ||
) |
Creates a GRectangle
object with the specified position and size.
If these parameters are not supplied, the constructor sets these fields to 0.
bool contains | ( | double | x, |
double | y | ||
) | const |
Returns true
if the rectangle contains the given point.
bool contains | ( | const GPoint & | pt | ) | const |
Returns true
if the rectangle contains the given point.
bool contains | ( | const GRectangle & | rect | ) | const |
Returns true
if this rectangle contains the given rectangle entirely.
GRectangle enlargedBy | ( | double | amount | ) |
Returns a new rectangle with its boundaries shifted outward by the given amount on all 4 sides.
e.g. a 10x10 rectangle at position (55, 42) enlarged by 1 will become a 12x12 rectangle at position (54, 41).
bool intersects | ( | const GRectangle & | other | ) | const |
Returns true if this rectangle and the given other rectangle overlap.
bool isEmpty | ( | ) | const |
Returns true
if the rectangle is empty, meaning that it has a width and height that are both 0 or negative.
string toString | ( | ) | const |
Converts the GRectangle
to a string in the form "(</code><i>x</i><code>,</code> <i>y</i><code>,</code>
<i>width</i><code>,</code> <i>height</i><code>)"
.
|
friend |
Compares two rectangles for inequality.
|
friend |
Relational operators that compare rectangles by x, y, then width, then height.
|
friend |
Writes the given rectangle to the given output stream.
|
friend |
Relational operators that compare rectangles by x, y, then width, then height.
|
friend |
Compares two rectangles for equality.
|
friend |
Relational operators that compare rectangles by x, y, then width, then height.
|
friend |
Relational operators that compare rectangles by x, y, then width, then height.
double height |
double width |
double x |
double y |