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)
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.

plot(x, y, color)
Draws the pixel at $(x,y)$ in the window. Color is optional, black is the default.

plotPixel(x, y, Color)
Draws the pixel at the ``raw'' position $(x,y)$ ignoring any coordinate transformations set up by setCoords.

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.

getMouse()
Pauses for the user to click a mouse in the window and returns where the mouse was clicked as a Point object.

checkMouse()
Similar to getMouse, but does not pause for a user click. Returns the latest point where the mouse was clicked or None if the window as not been clicked since the previous call to checkMouse or getMouse. This is particularly useful for controlling simple animation loops.

checkKey()
Similar to checkMouse, but for keypresses. It does not pause for a keypress. Returns a string with the key that was pressed, or the empty string if nothing was pressed since the previous call to checkKey.

setCoords(xll, yll, xur, yur)
Sets the coordinate system of the window. The lower-left corner is $(xll, yll)$ and the upper-right corner is $(xur, yur)$. All subsequent drawing will be done with respect to the altered coordinate system (except for plotPixel).

John Zelle 2010-08-29