typedef object drawing; typedef void (*drawfn)(drawing d, rect r);
drawing newdrawing(rect r, drawfn fn); /* create drawing area */
A drawing is a area on a window which can be used to draw a picture or some graphics. The newdrawing function creates a drawing area, and takes as an argument a rectangle, which specifies where on the current window the drawing should be placed. The rectangle is measured in pixels, relative to the top-left point of the window which is the point (0,0). Drawings are usually placed on the last window that was created.
A redraw call-back is also supplied by the programmer when creating a drawing. This call-back function is called automatically by the graphics library whenever the drawing needs to be redrawn, and is passed two parameters: the drawing which needs to be redrawn, and that drawing's rectangle (in local co-ordinates).