Graphics Objects

The module provides the following classes of drawable objects: Point, Line, Circle, Oval, Rectangle, Polygon, and Text. All objects are initially created unfilled with a black outline. All graphics objects support the following generic set of methods:
setFill(color)
Sets the interior of the object to the given color.


Example: someObject.setFill("red")

setOutline(color)
Sets the outline of the object to the given color.


Example: someObject.setOutline("yellow")

setWidth(pixels)
Sets the width of the outline of the object to the desired number of pixels. (Does not work for Point.)


Example: someObject.setWidth(3)

draw(aGraphWin)
Draws the object into the given GraphWin and returns the drawn object.


Example: someObject.draw(someGraphWin)

undraw()
Undraws the object from a graphics window. If the object is not currently drawn, no action is taken.


Example: someObject.undraw()

move(dx,dy)
Moves the object dx units in the $x$ direction and dy units in the $y$ direction. If the object is currently drawn, the image is adjusted to the new position.


Example: someObject.move(10, 15.5)

clone()
Returns a duplicate of the object. Clones are always created in an undrawn state. Other than that, they are identical to the cloned object.


Example: objectCopy = someObject.clone()



Subsections