Skip to content

GRectangle

The GRectangle is a utility class representing a bounding box.

Note

Don't confuse GRect with GRectangle. The former is a GObject that you can add to a GWindow; the latter is a utility type that stores a GObject's bounding box, and cannot be added to a GWindow.

Factory Functions

function GRectangle(rect)
Creates a copy of the given rect.
function GRectangle(x, y, width, height)
Creates a GRectangle at (x, y) with the given width and height.

Methods

function GRectangle::getX()
Returns: The x component of this GRectangle's origin.
function GRectangle::getY()
Returns: The y component of this GRectangle's origin.
function GRectangle::getWidth()
Returns: The width of this GRectangle.
function GRectangle::getHeight()
Returns: The height of this GRectangle.
function GRectangle::setLocation(point)
Sets this GRectangle to be located at the given point.
point can also be another GRectangle, or a GObject!
function GRectangle::setLocation(x, y)
Sets this GRectangle to be located at (x, y)
function GRectangle::getLocation()
Returns the origin of this rectangle as a GPoint
function GRectangle::setSize(dimension)
Sets this GRectangle to be the size of the given dimension.
dimension can also be another GRectangle, or a GObject!
function GRectangle::setSize(width, height)
Sets this GRectangle's size to be a given width and height.
function GRectangle::setBounds(object)
Sets this GRectangle's x/y/width/height to match that of the passed-in object of type GRectangle or GObject.
function GRectangle::setBounds(positionObject, sizeObject)
Sets this GRectangle's x/y to match that of the passed-in positionObject, and its width/height to match that of the passed-in sizeObject.
These objects should be of type GRectangle or GObject. Additionally, positionObject can be a GPoint, and positionObject can be a GDimension.
function GRectangle::setBounds(x, y, width, height)
Sets this GRectangle's x, y, width, and height as specified.
function GRectangle::contains(x, y)
Returns: true if this GRectangle contains the point (x, y). false otherwise.
function GRectangle::add(point)
Expands this GRectangle to contain the given point.
function GRectangle::add(x, y)
Expands this GRectangle to contain the point (x, y).
function GRectangle::translate(dx, dy)
Adjusts the origin of this GRectangle by the displacements dx, dy.