Glade Reference


Rect class

A Rect class is used to represent a rectangle comprising two coordinate pairs. Note that this is NOT the same as a rectangle object which is a database object instead.

 

r = Rect

Creates a Rect object r. The rectangle coordinates are set to invalid i.e. llx = +infinity, urx = -infinity etc.

 

r = Rect(Point ll, Point ur)

Creates a Rect object r and initialises it with Point types ll, ur.

 

r = Rect(int llx, int lly, int urx, int ury)

Creates a Rect object and initialises its coordinates.

 

int x = r.left()

int y = r.bottom()

int x = r.right()

int y = r.top()

Get the specified Rect coordinate.

 

r.setLeft(int x)

r.setBottom(int y)

r.setRight(int x)

r.setTop(int y)

Set the specified Rect coordinate.

 

Point ll = r.getLL()

Point ur = r.getUR()

Get the lower left or upper right Rect coordinates as Points.

 

r.invalidate()

Set the Rect to invalid, i.e. llx = +infinity, urx = -infinity etc.

 

r.scale(double s)

r.scale(int s)

Scale a Rect coordinates by dividing them by s.

 

Rect s = r.offset(int x, int y)

Offset (transpose) a Rect by the specified x and y coordinates. The Rect r is modified.

 

r.width(int w)

Set a Rect's width. The lower left remains the same.

 

int w = r.width()

Get the width of a Rect.

 

r.height(int h)

Set the height of a Rect. The lower left remains the same.

 

int h = r.height()

Get the height of a Rect.

 

Point p = r.centre()

Get the centre point of a Rect.

 

bool b = r.isSquare()

Returns True is the rectangle is square, False if it is not.

 

transform(orient_t orient, const Point &p)

Transforms a Rect using Point p and orientation orient.

 

r.swapxy()

Swaps the X and Y coordinates of a Rect.

 

r.unionWith(const Rect &p)

Rect r is set to the union of the Rects r and p, i.e. the bounding box of both.

 

r.unionWith(const Point &p)

Rect r is set to the union of itself and Point p, i.e. the bounding box of both.

 

bool b = r.touchOrOverlaps(int x, int y)

Returns True if the Rect touches or overlaps the point x, y; returns False otherwise.

 

bool b = r.touchOrOverlaps(int xlo, int ylo, int xhi, int yhi)

Returns True if the Rect touches or overlaps the rectangle formed by xlo, ylo, xhi, yhi; returns False otherwise.

 

bool b = r.touchOrOverlaps(const Rect &p)

Returns True if the Rect touches or overlaps the Rect p; returns False otherwise.

 

bool b = r.touch(int x, int y)

Returns True if the Rect touches the point x, y; returns False otherwise.

 

bool b = r.touch(int xlo, int ylo, int xhi, int yhi)

Returns True if the Rect touches the rectangle formed by xlo, ylo, xhi, yhi; returns False otherwise.

 

bool b = r.touch(const Rect &p)

Returns True if the Rect touches the Rect p; returns False otherwise.

 

bool b = r.overlaps(int x, int y)

Returns True if the Rect overlaps the point x, y; returns False otherwise.

 

bool b = r.overlaps(int xlo, int ylo, int xhi, int yhi)

Returns True if the Rect overlaps the rectangle formed by xlo, ylo, xhi, yhi; returns False otherwise.

 

bool b = r.overlaps(const Rect &p)

Returns True if the Rect overlaps the Rect p; returns False otherwise.

 

bool b = r.contains(int x, int y)

Returns True if the Rect contains the point x, y; returns False otherwise.

 

bool b = r.contains(int xlo, int ylo, int xhi, int yhi)

Returns True if the Rect contains the rectangle formed by xlo, ylo, xhi, yhi; returns False otherwise.

 

bool b = r.contains(const Rect &p)

Returns True if the Rect contains the Rect p; returns False otherwise.

 

r.intersectsWith(const Rect &p)

Modifies Rect r to the intersection of itself and Rect p.

 

Rect s = r.intersectsWith(const Rect &p)

Returns a rectangle which is the intersection of r and p.

 

Contents|Index

Copyright © Peardrop Design 2020.