{ (define LIBNAME "A Functional Drawing Library (HtDC)") (include "head.tinc") }

Add


  import draw.*
at the top of your Definitions Window to import this library.

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,IColor)   |
 |                                   |       | boolean drawDisk(Posn,int,IColor)     |
 | abstract World onTick()           |       | boolean drawRect(Posn,int,int,IColor) |
 | abstract World onKeyEvent(String) |       | boolean drawLine(Posn,Posn,IColor)    |
 | abstract boolean draw()           |       | boolean drawString(Posn,String)       |
 +-----------------------------------+       +---------------------------------------+

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")}