racket/collects/teachpack/htdc/Docs/idraw.thtml
Matthias Felleisen 8c3845a768 some first scribblings for teachpacks
svn: r7575
2007-10-26 21:58:57 +00:00

50 lines
2.1 KiB
Plaintext

{ (define LIBNAME "An Imperative Drawing Library (HtDC)")
(include "head.tinc") }
<p>Add
<pre><code>
import idraw.*
</code></pre>
at the top of your Definitions Window to import this library.
</p>
<p>This <code>idraw</code> package provides stateful classes and imperative methods
for a visual world. Here is its class diagram of public fields and methods:
<pre>
<code>
import colors.*;
import geometry.*;
+---------------------------------+
| abstract World |
+---------------------------------+ +------------------------------------+
| Canvas theCanvas |------>| Canvas |
+---------------------------------+ +------------------------------------+
| void bigBang(int,int,double) | +------------------------------------+
| World endOfTime(String) | | void show() |
| World endOfWorld(String) | | void close() |
| abstract void onTick() | | void drawCircle(Posn,int,IColor) |
| abstract void onKeyEvent(String)| | void drawDisk(Posn,int,IColor) |
| abstract void draw() | | void drawRect(Posn,int,int,IColor) |
+---------------------------------+ | void drawLine(Posn,Posn,IColor) |
| void drawString(Posn,String) |
+------------------------------------+
</code>
</pre>
</p>
<p>The abstract <code>World</code> class in <code>idraw</code> provides the same
methods as the <code>World</code> class in <a href="./draw.html#world">the
<code>draw</code> library</a>. Their return values are usually <code>void</code>,
however, except for <code>endOfTime</code> and <code>endOfWorld</code>, which
continue to return the last world.</p>
<p>In an analogous manner, the methods in the <code>Canvas</code> class export
the same methods as the <code>Canvas</code> class in <a
href="./draw.html#canvas">the <code>draw</code> package</a>. Their return values,
however, are <code>void</code>. </p>
{(include "foot.tinc")}