GraphWin Objects
A GraphWin object represents a window on the screen where
graphical images may be drawn. A program may define any number of
GraphWins. A GraphWin understands the following methods:
- GraphWin(title, width, height, autoflush)
- Constructs
a new graphics window for drawing on the screen. The parameters
are optional, the default title is ``Graphics Window,'' and the
default size is 200 x 200. The autoflush parameter, if True causes
the window to be immediately updated after every drawing operation.
The default value is False, allowing operations to ``batch up'' for
better efficiency.
- plot(x, y, color)
- Draws the pixel at
in the window. Color is optional, black is the default.
Note: pixel-level operations are very inefficient and this method
should be avoided.
- plotPixel(x, y, Color)
- Draws the
pixel at the ``raw'' position
ignoring any coordinate
transformations set up by setCoords. Note: pixel-level
operations are very inefficient and this method should be avoided.
- setBackground(color)
- Sets the window background to the given
color. The initial background is gray. See Section 5.8.5 for
information on specifying colors.
- close()
- Closes the on-screen window.
Once a window is closed, further operations on the window will raise a
GraphicsError exception.
- isClosed()
- Returns a Boolean indicating if the
window has been closed either by an explicit call to
close or a click on its close box.
- getMouse()
- Pauses for the user to
click in the window and returns where the mouse was clicked as a
Point object. Raises GraphicsError if the window is
closed while getMouse is in progress.
- setCoords(xll, yll, xur, yur)
- Sets
the coordinate system of the window. The lower left corner is
and the upper right corner is
. All
subsequent drawing will be done with respect to the altered
coordinate system (except for plotPixel).
- update()
- Causes any pending window operations to be
performed. Normally, this will happen automatically during idle
periods. Explicit update() calls may be useful for animations.
John Zelle
2005-06-04