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.

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

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

draw(aGraphWin)
Draws the object into the given GraphWin.

undraw()
Undraws the object from a graphics window. This produces an error if the object is not currently drawn.

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.

getFill()
Returns a list with 3 integers representing the RGB components of the object's current fill color, or an empty list if there is no fill.

getOutline()
Similar to getFill(), but for the outline color of the object.

isDrawn()
Returns True if the object is currently in a drawn state, False otherwise.

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.
Objects can also be printed. Printing an object produces a string that shows the dimensions and location of the object, e.g.:

>>> r = graphics.Rectangle(graphics.Point(20, 20), graphics.Point(200, 200))
>>> print r
Rectangle(Point(20.00, 20.00), Point(200.00, 200.00))



Subsections
John Zelle 2010-08-29