The GObject
The GObject is the base object (i.e. the common superclass) for all other graphics objects. Any abstract method seen here can be called on any other (more specific) graphics object, but not on a generic GObject.
GObject is an abstract class -- if you try to make one directly, you'll have to fill in the abstract methods.
Factory Functions
- function GObject()
- Creates an empty
GObject
. You probably shouldn't be using this.
Methods
- abstract function GObject::getBounds()
- Returns a GRectangle representing the smallest box that covers everything this GObject covers.
- function GObject::setLocation([x[, y]])
- Sets this GObject's location in the window to (x, y). If
undefined
is passed in instead of a number for either x and/or y, it defaults to the object's current location. - function GObject::getLocation()
- Returns: A GPoint representing the origin of this object.
- function GObject::getX()
- Returns: The x coordinate of this object's origin.
- function GObject::getY()
- Returns: The y coordinate of this object's origin.
- function GObject::move(dx, dy)
- Moves this object by the displacements dx and dy
- function GObject::movePolar(r, theta)
- Moves this object r units in the direction theta. theta is measured in degrees clockwise from the +x axis.
- abstract function GObject::getSize()
- Returns: The size of this object as a GDimension.
- abstract function GObject::getWidth()
- Returns: The width of this object as a number.
- abstract function GObject::getHeight()
- Returns: The height of this object as a number.
- abstract function GObject::contains(x, y)
- Returns:
true
if this object contains the given x and y coordinates, andfalse
otherwise. - function GObject::sendToFront()
- Puts this object on top of all other objects in its attached container. Fails if this object isn't in a container.
- See Also: GWindow, GCompound
- function GObject::sendToBack()
- Puts this object behind all other objects in its attached container. Fails if this object isn't in a container.
- See Also: GWindow, GCompound
- function GObject::sendForward()
- Moves this object one "step" towards the front of its container. Fails if this object isn't in a container.
- See Also: GWindow, GCompound
- function GObject::sendBackward()
- Moves this object one "step" towards the back of its container. Fails if this object isn't in a container.
- See Also: GWindow, GCompound
- function GObject::setColor(color)
- Sets the border color of this object. If the object is filled and hasn't been specifically assigned a fill color, also sets the fill color.
- color may be a predefined Javascript color (e.g.
"Red"
), or it may be a string in the form"#RRGGBB
, where RR, GG, and BB are the hexadecimal values of the red, green, and blue intensities. - function GObject::getColor()
- Returns: The color of the object as previously set.
- function GObject::setFillColor(color)
- Sets the fill color of this object specifically. color's format matches that of GObject::setColor.
- See Also: GObject::setColor
- function GObject::setFilled(flag)
- Sets this object to be filled if
flag
is true, or not filled ifflag
is false. - function GObject::isFilled()
- Returns:
true
if this object is filled,false
otherwise. - function GObject::setLineWidth(width)
- Sets this object's lines to be width units wide.
- function GObject::getLineWidth()
- Returns: The width of this object's lines as a number.
- function GObject::rotate(theta)
- Rotates this object by theta degrees around its origin.
- Marks the object as transformed.
- function GObject::scale(multiplier)
- function GObject::scale(xMultiplier, yMultiplier)
- Scales this object. If an individual xMultiplier and yMultiplier are specified, scales the x and y axes differently as specified. If a single multiplier is specified, scales both x and y by that multiplier.
- Marks the object as transformed.
- function GObject::shear(xShear, yShear)
- Applies an affine shear transformation to this object, using scale factors xShear and yShear.
- Marks the object as transformed.
- function GObject::translate(xTransform, yTransform)
- Translates the display of the object by xTransform and yTransform before it is displayed, without changing the object's origin.
- Marks the object as transformed.
- function GObject::setVisible(flag)
- Makes the object visible if flag is
true
, and invisible if flag isfalse
. - function GObject::isVisible()
- Returns:
true
if the object is visible,false
otherwise.