#include <base.h>
Inheritance diagram for fgl::FGRect:


A rectangle is internally represented as an upper-left corner and a bottom-right corner, but it is normally expressed as an upper-left corner and a size.
The coordinate type is FGCOORD (defined in qwindowdefs.h as int). The minimum value of FGCOORD is FGCOORD_MIN (-2147483648) and the maximum value is FGCOORD_MAX (2147483647).
Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.
Generally, @ e{width = right - left + 1} and {height = bottom - top + 1}. We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.
The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.
A FGRect can be constructed with a set of left, top, width and height integers, from two FGPoints or from a FGPoint and a FGSize. After creation the dimensions can be changed, e.g. with setLeft(), setRight(), setTop() and setBottom(), or by setting sizes, e.g. setWidth(), setHeight() and setSize(). The dimensions can also be changed with the move functions, e.g. moveBy(), moveCenter(), moveBottomRight(), etc. You can also add coordinates to a rectangle with addCoords().
You can test to see if a FGRect contains a specific point with contains(). You can also test to see if two FGRects intersect with intersects() (see also intersect()). To get the bounding rectangle of two FGRects use unite().
gradient.cpp, and regress.cpp.
Public Member Functions | |
| FGRect () | |
| FGRect (const FGRect &old) | |
| FGRect (int xpos, int ypos, int width, int height) | |
| FGRect (int width, int height) | |
| FGRect (const FGPoint r0, const FGPoint r1) | |
| FGRect (const FGSize &sz) | |
| FGRect (const FGCircle &c) | |
| FGRect (const FGDrawBuffer &sprite) | |
| bool | isValid (void) const |
| bool | isNull (void) const |
| bool | isEmpty (void) const |
| FGRect | normalize (void) const |
| FGCOORD | left (void) const |
| FGCOORD | right (void) const |
| FGCOORD | top (void) const |
| FGCOORD | bottom (void) const |
| FGPoint | topLeft (void) const |
| FGPoint | bottomRight (void) const |
| FGPoint | topRight (void) const |
| FGPoint | bottomLeft (void) const |
| FGPoint | center (void) const |
| FGRect | operator| (const FGRect &r) const |
| FGRect | operator & (const FGRect &r) const |
| FGRect & | operator|= (const FGRect &r) |
| FGRect & | operator &= (const FGRect &r) |
| bool | contains (const FGPoint &p, bool proper=false) const |
| bool | contains (int x, int y, bool proper=false) const |
| bool | contains (const FGRect &r, bool proper=false) const |
| FGRect | unite (const FGRect &r) const |
| FGRect | intersect (const FGRect &r) const |
| bool | intersects (const FGRect &r) const |
Public Attributes | |
| FGCOORD | w |
| FGCOORD | h |
Friends | |
| bool | operator== (const FGRect &, const FGRect &) |
| bool | operator!= (const FGRect &, const FGRect &) |
|
|
Constructs an invalid rectangle. |
|
|
copy
|
|
||||||||||||||||||||
|
Constructs a rectangle with the top, left corner and width and height. Example (creates two identical rectangles): |
|
||||||||||||
|
Constructs a rectangle with the top left corner at (0,0) and width and height. |
|
||||||||||||
|
Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner. |
|
|
Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner. |
|
|
Constructs a rectangle with topLeft as the top-left corner and bottomRight as the bottom-right corner. |
|
|
Returns the bottom coordinate of the rectangle.
|
|
|
Returns the bottom-left position of the rectangle.
|
|
|
Returns the bottom-right position of the rectangle.
|
|
|
Returns the center point of the rectangle.
|
|
||||||||||||
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns TRUE if the rectangle r is inside this rectangle; otherwise returns FALSE. If proper is TRUE, this function returns TRUE only if r is entirely inside (not on the edge).
|
|
||||||||||||||||
|
Returns TRUE if the point x, y is inside this rectangle; otherwise returns FALSE. If proper is TRUE, this function returns TRUE only if the point is entirely inside (not on the edge). |
|
||||||||||||
|
Returns TRUE if the point p is inside or on the edge of the rectangle; otherwise returns FALSE. If proper is TRUE, this function returns TRUE only if p is inside (not on the edge). |
|
|
Returns the intersection of this rectangle and rectangle r. |
|
|
Returns TRUE if this rectangle intersects with rectangle r (there is at least one pixel that is within both rectangles); otherwise returns FALSE.
|
|
|
Returns TRUE if the rectangle is empty; otherwise returns FALSE. An empty rectangle has a left() > right() or top() > bottom().
An empty rectangle is not valid.
|
|
|
Returns TRUE if the rectangle is a null rectangle; otherwise returns FALSE. A null rectangle has both the width and the height set to 0, that is right() == left() - 1 and bottom() == top() - 1. Note that if right() == left() and bottom() == top(), then the rectangle has width 1 and height 1. A null rectangle is also empty. A null rectangle is not valid.
Reimplemented from fgl::FGPoint. |
|
|
Returns TRUE if the rectangle is valid; otherwise returns FALSE. A valid rectangle has a left() <= right() and top() <= bottom(). Note that non-trivial operations like intersections are not defined for invalid rectangles.
|
|
|
Returns the left coordinate of the rectangle. Identical to x().
|
|
|
Returns a normalized rectangle, i.e. a rectangle that has a non-negative width and height. It swaps left and right if left() > right(), and swaps top and bottom if top() > bottom().
|
|
|
Returns the intersection of this rectangle and rectangle r. Returns an empty rectangle if there is no intersection.
|
|
|
Intersects this rectangle with rectangle r. |
|
|
Returns the bounding rectangle of this rectangle and rectangle r. The bounding rectangle of a nonempty rectangle and an empty or invalid rectangle is defined to be the nonempty rectangle.
|
|
|
Unites this rectangle with rectangle r. |
|
|
Returns the right coordinate of the rectangle.
|
|
|
Returns the top coordinate of the rectangle. Identical to y().
|
|
|
Returns the top-left position of the rectangle.
|
|
|
|
|
|
Returns the bounding rectangle of this rectangle and rectangle r. |
|
||||||||||||
|
|
|
||||||||||||
|
|
1.4.0