2.4 Draw: idraw.*
Add
import idraw.* |
at the top of your Definitions Window to import this library.
This package provides stateful classes and imperative methods for a visual world. Here is its class diagram of public fields and methods:
import colors.*; |
import geometry.*; |
|
+---------------------------------+ |
| abstract World | |
+---------------------------------+ |
| Canvas theCanvas |---+ |
+---------------------------------+ | |
| void bigBang(int,int,double) | | |
| World endOfTime(String) | | |
| World endOfWorld(String) | | |
| abstract void onTick() | | |
| abstract void onKeyEvent(String)| | |
| abstract void draw() | | |
+---------------------------------+ | |
| |
v |
+------------------------------------+ |
| Canvas | |
+------------------------------------+ |
+------------------------------------+ |
| void show() | |
| void close() | |
| void drawCircle(Posn,int,IColor) | |
| void drawDisk(Posn,int,IColor) | |
| void drawRect(Posn,int,int,IColor) | |
| void drawLine(Posn,Posn,IColor) | |
| void drawString(Posn,String) | |
+------------------------------------+ |
The abstract World class in idraw provides the same methods as the World class in World (draw package). Their return values are usually void, however, except for endOfTime and endOfWorld, which continue to return the last world.
In an analogous manner, the methods in the Canvas class export the same methods as the Canvas class in Canvas (draw package). Again their return values are void.