class GRect

Rectangle class.

Public Fields

[more]int xmin
Minimal horizontal point coordinate of the rectangle.
[more]int ymin
Minimal vertical point coordinate of the rectangle.
[more]int xmax
Maximal horizontal point coordinate of the rectangle.
[more]int ymax
Maximal vertical point coordinate of the rectangle.

Public Methods

[more] GRect()
Constructs an empty rectangle
[more] GRect(int xmin, int ymin, unsigned int width=0, unsigned int height=0)
Constructs a rectangle given its minimal coordinates xmin and ymin, and its measurements width and height.
[more]int width() const
Returns the rectangle width.
[more]int height() const
Returns the rectangle height.
[more]int area() const
Returns the area of the rectangle.
[more]int isempty() const
Returns true if the rectangle is empty.
[more]int contains(int x, int y) const
Returns true if the rectangle contains pixel (x,y).
[more]int contains(const GRect & rect) const
Returns true if this rectangle contains the passed rectangle rect.
[more]friend int operator==(const GRect & r1, const GRect & r2)
Returns true if rectangles r1 and r2 are equal.
[more]friend int operator!=(const GRect & r1, const GRect & r2)
Returns true if rectangles r1 and r2 are not equal.
[more]void clear()
Resets the rectangle to the empty rectangle
[more]int inflate(int dx, int dy)
Fatten the rectangle.
[more]int translate(int dx, int dy)
Translate the rectangle.
[more]int intersect(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the intersection of rectangles rect1 and rect2.
[more]int recthull(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the smallest rectangle containing the points of both rectangles rect1 and rect2.
[more]void scale(float factor)
Multiplies xmin, ymin, xmax, ymax by factor and scales the rectangle
[more]void scale(float xfactor, float yfactor)
Multiplies xmin, xmax by xfactor and ymin, ymax by yfactor and scales the rectangle


Documentation

Rectangle class. Each instance of this class represents a rectangle whose sides are parallel to the axis. Such a rectangle represents all the points whose coordinates lies between well defined minimal and maximal values. Member functions can combine several rectangles by computing the intersection of rectangles (intersect) or the smallest rectangle enclosing two rectangles (recthull).
o GRect()
Constructs an empty rectangle

o GRect(int xmin, int ymin, unsigned int width=0, unsigned int height=0)
Constructs a rectangle given its minimal coordinates xmin and ymin, and its measurements width and height. Setting width or height to zero produces an empty rectangle.

oint width() const
Returns the rectangle width.

oint height() const
Returns the rectangle height.

oint area() const
Returns the area of the rectangle.

oint isempty() const
Returns true if the rectangle is empty.

oint contains(int x, int y) const
Returns true if the rectangle contains pixel (x,y). A rectangle contains all pixels with horizontal pixel coordinates in range xmin (inclusive) to xmax (exclusive) and vertical coordinates ymin (inclusive) to ymax (exclusive).

oint contains(const GRect & rect) const
Returns true if this rectangle contains the passed rectangle rect. The function basically checks, that the intersection of this rectangle with rect is rect.

ofriend int operator==(const GRect & r1, const GRect & r2)
Returns true if rectangles r1 and r2 are equal.

ofriend int operator!=(const GRect & r1, const GRect & r2)
Returns true if rectangles r1 and r2 are not equal.

ovoid clear()
Resets the rectangle to the empty rectangle

oint inflate(int dx, int dy)
Fatten the rectangle. Both vertical sides of the rectangle are pushed apart by dx units. Both horizontal sides of the rectangle are pushed apart by dy units. Setting arguments dx (resp. dy) to a negative value reduces the rectangle horizontal (resp. vertical) size.

oint translate(int dx, int dy)
Translate the rectangle. The new rectangle is composed of all the points of the old rectangle translated by dx units horizontally and dy units vertically.

oint intersect(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the intersection of rectangles rect1 and rect2. This function returns true if the intersection rectangle is not empty.

oint recthull(const GRect &rect1, const GRect &rect2)
Sets the rectangle to the smallest rectangle containing the points of both rectangles rect1 and rect2. This function returns true if the created rectangle is not empty.

ovoid scale(float factor)
Multiplies xmin, ymin, xmax, ymax by factor and scales the rectangle

ovoid scale(float xfactor, float yfactor)
Multiplies xmin, xmax by xfactor and ymin, ymax by yfactor and scales the rectangle

oint xmin
Minimal horizontal point coordinate of the rectangle.

oint ymin
Minimal vertical point coordinate of the rectangle.

oint xmax
Maximal horizontal point coordinate of the rectangle.

oint ymax
Maximal vertical point coordinate of the rectangle.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.