{ (define LIBNAME "A Functional Drawing Library (HtDC)") (include "head.tinc") } This draw package provides classes and methods for a visual world. Here is its class diagram of public fields and methods:

import colors.*;
import geometry.*;

 +-----------------------------------+
 | abstract World                    |
 +-----------------------------------+       +---------------------------------------+
 | Canvas theCanvas                  |------>| Canvas                                |
 +-----------------------------------+       +---------------------------------------+
 | boolean bigBang(int,int,double)   |       +---------------------------------------+
 | boolean endOfTime(String)         |       | boolean show()                        |
 | World endOfWorld(String)          |       | boolean close()                       |
 |                                   |       | boolean drawCircle(Posn,int,Color)    |
 |                                   |       | boolean drawDisk(Posn,int,Color)      |
 | abstract World onTick()           |       | boolean drawRect(Posn,int,int,Color)  |
 | abstract World onKeyEvent(String) |       | boolean drawLine(Posn,Posn,Color)     |
 | abstract boolean draw()           |       | boolean drawString(Posn,String)       |
 | abstract boolean erase()          |       | boolean clearCircle(Posn,int,Color)   |
 +-----------------------------------+       | boolean clearDisk(Posn,int,Color)     |
                                             | boolean clearRect(Posn,int,int,Color) |
                                             | boolean clearLine(Posn,Posn,Color)    |
                                             +---------------------------------------+

The abstract World class exports the following methods:

The methods may fail due to the unavailability of the physical devices, inappropriate uses, etc. In those cases, they fail with an exception.

A derived concrete class must supply definitions for the following methods:

A program may, in principle, start several instances of (subclasses of) World. If it does, the event handlers are called in a unpredictable order.

To create an instance of the Canvas class, a program must supply two int values: one for the width of the canvas and one for its height. The canvas is a rectangle, whose borders are parallel to the computer screen's borders. A program can use the following methods on instances of Canvas:

The methods may fail due to the unavailability of the physical devices, inappropriate uses, etc. In those cases, they fail with an exception.

{(include "foot.tinc")}