{ (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:

 +-----------------------------------+
 | abstract World                    |
 +-----------------------------------+       +---------------------------------------+
 | Canvas theCanvas                  |------>| Canvas                                |
 +-----------------------------------+       +---------------------------------------+
 | boolean bigBang(int,int,double)   |       +---------------------------------------+
 | boolean endOfTime()               |       | boolean show()                        |
 | World endOfWorld()                |       | 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)    |
                                             +---------------------------------------+

                      +----------+
                      | Posn     |
                      +----------+
                      | int x    |
                      | int y    |
                      +----------+

                              +-------+
                              | Color |
                              +-------+
                                  |
                                 / \
                                 ---
                                  |
             ------------------------------------------
             |          |         |         |         |     
         +-------+  +-------+ +-------+ +-------+ +-------+  
         | Blue  |  | Green | | Red   | | White | | Yellow| 
         +-------+  +-------+ +-------+ +-------+ +-------+ 

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.

To create an instance of the Posn class, a program must supply two int values: one for its x coordinate of the canvas and the second for its y coordinate.

The Color class is abstract. Its variants (subclasses) are created with no arguments.

{(include "foot.tinc")}