docs fixed for 4.0

svn: r9455
This commit is contained in:
Matthias Felleisen 2008-04-24 13:22:46 +00:00
parent e4563319db
commit 7be28dfc6d
5 changed files with 79 additions and 55 deletions

View File

@ -1,9 +1,11 @@
#lang scribble/doc #lang scribble/doc
@(require scribble/manual) @(require scribble/manual (for-label teachpack/htdc/draw))
@title[#:tag "Jdraw"]{Draw: draw.*} @title[#:tag "Jdraw"]{Draw: draw.*}
@declare-exporting[teachpack/htdc/draw]
Add Add
@verbatim[#:indent 3]{ @verbatim[#:indent 3]{
import draw.* import draw.*
@ -54,10 +56,10 @@ exception.
The abstract @tt{World} class exports the following methods. The abstract @tt{World} class exports the following methods.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
bigBang(int width,int height,double speed) @defthing[bigBang (int width,int height,double speed)]
Initializes the world, associates it with a @tt{width} x Initializes the world, associates it with a @tt{width} x
@tt{height} <a href="#canvas">@tt{Canvas}</a>, displays @tt{height} @seclink["canvas"]{@tt{Canvas}}, displays
this canvas, enables keyevents, and finally starts the clock at a rate of this canvas, enables keyevents, and finally starts the clock at a rate of
one tick per @tt{speed} seconds. If it succeeds with all of its one tick per @tt{speed} seconds. If it succeeds with all of its
actions, the method produces @tt{true}. actions, the method produces @tt{true}.
@ -70,18 +72,18 @@ The canvas in @tt{World} is called
@tt{theCanvas}. @tt{theCanvas}.
References to a "canvas" in conjunction with the @tt{World} class References to a "canvas" in conjunction with the @tt{World} class
denote this default canvas. denote this default canvas.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
endOfTime() @defthing[endOfTime ()]
Displays the given message, stops the clock and, if it succeeds, produces Displays the given message, stops the clock and, if it succeeds, produces
@tt{true}. After the end of time, events no longer trigger calls @tt{true}. After the end of time, events no longer trigger calls
to @tt{onTick} or @tt{onKeyEvent}. The canvas remains visible. to @tt{onTick} or @tt{onKeyEvent}. The canvas remains visible.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
endOfWorld(String msg) @defthing[endOfWorld (String msg)]
Displays the given message, stops the clock and, if it succeeds, produces the Displays the given message, stops the clock and, if it succeeds, produces the
last @tt{World}. After the end of the world, events no longer trigger calls last @tt{World}. After the end of the world, events no longer trigger calls
@ -92,14 +94,14 @@ remains visible.
A derived concrete class must supply definitions for the following methods: A derived concrete class must supply definitions for the following methods:
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
onTick() @defthing[onTick ()]
Invoked for every tick of the clock. Its purpose is to create a Invoked for every tick of the clock. Its purpose is to create a
@tt{World} whose differences with @tt{this} one represent @tt{World} whose differences with @tt{this} one represent
what happened during the amount of time it takes the clock to tick. what happened during the amount of time it takes the clock to tick.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
onKeyEvent(String key) @defthing[onKeyEvent (String key)]
Invoked for every keyboard event associated with the canvas. Its purposes Invoked for every keyboard event associated with the canvas. Its purposes
is to create a @tt{World} whose differences with is to create a @tt{World} whose differences with
@ -108,9 +110,9 @@ Invoked for every keyboard event associated with the canvas. Its purposes
@tt{key}. @tt{key}.
@; ----------------------------------------------------------------------------- @; -----------------------------------------------------------------------------
draw() @defthing[draw ()]
Invoked <em>after</em> one of the two event handlers has been called. Its Invoked @emph{after} one of the two event handlers has been called. Its
purpose is to present @tt{this World} graphically on its purpose is to present @tt{this World} graphically on its
canvas. If it succeeds, its result is @tt{true}. canvas. If it succeeds, its result is @tt{true}.
@ -118,6 +120,7 @@ A program may, in principle, start several instances of (subclasses of)
@tt{World}. If it does, the event handlers are called in a unpredictable @tt{World}. If it does, the event handlers are called in a unpredictable
order. order.
@; -----------------------------------------------------------------------------
@section[#:tag "canvas"]{Canvas} @section[#:tag "canvas"]{Canvas}
To create an instance of the @tt{Canvas} class, a program must supply To create an instance of the @tt{Canvas} class, a program must supply
@ -126,14 +129,14 @@ 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 screen's borders. A program can use the following methods on instances of
@tt{Canvas}] @tt{Canvas}]
show() @defthing[show ()]
Initializes the canvas to a white area, enables the drawing methods, and Initializes the canvas to a white area, enables the drawing methods, and
finally displays the canvas. If it succeeds, it produces finally displays the canvas. If it succeeds, it produces
@tt{true}. Invoking the method a second time without calling @tt{true}. Invoking the method a second time without calling
@tt{close} before has no effect. @tt{close} before has no effect.
close() @defthing[close ()]
Hides the canvas and erases the current content. If it succeeds, it Hides the canvas and erases the current content. If it succeeds, it
produces @tt{true}. produces @tt{true}.
@ -142,31 +145,31 @@ Closing the Canvas using the display controls does not fully hide the
canvas; it is still necessary to invoke @tt{close} before canvas; it is still necessary to invoke @tt{close} before
@tt{show} is re-enabled. @tt{show} is re-enabled.
drawCircle(Posn p,int r,IColor c)> @defthing[drawCircle (Posn p,int r,IColor c)]
Draws a circle on @tt{this}Canvas] at @tt{p} with radius Draws a circle on @tt{this}Canvas] at @tt{p} with radius
@tt{r} and color @tt{c}. If it succeeds, it produces @tt{r} and color @tt{c}. If it succeeds, it produces
@tt{true}. @tt{true}.
drawDisk(Posn p,int r,IColor c) @defthing[drawDisk (Posn p,int r,IColor c)]
Draws a disk on @tt{this}Canvas] at @tt{p} with radius Draws a disk on @tt{this}Canvas] at @tt{p} with radius
@tt{r} and color @tt{c}. If it succeeds, it produces @tt{r} and color @tt{c}. If it succeeds, it produces
@tt{true}. @tt{true}.
drawRect(Posn p,int w,int h,IColor c) @defthing[drawRect (Posn p,int w,int h,IColor c)]
Draws a solid rectangle on @tt{this}Canvas] at @tt{p} with Draws a solid rectangle on @tt{this}Canvas] at @tt{p} with
width @tt{w}, height @tt{h}, and color @tt{c}. The width @tt{w}, height @tt{h}, and color @tt{c}. The
rectangle's lines are parallel to the canvas's borders. If it succeeds, it rectangle's lines are parallel to the canvas's borders. If it succeeds, it
produces @tt{true}. produces @tt{true}.
drawLine(Posn p0,Posn p1,IColor c) @defthing[drawLine (Posn p0,Posn p1,IColor c)]
Draws a line on @tt{this}Canvas] from @tt{p0} to Draws a line on @tt{this}Canvas] from @tt{p0} to
@tt{p1} using color @tt{c}. If it succeeds, it produces @tt{p1} using color @tt{c}. If it succeeds, it produces
@tt{true}. @tt{true}.
drawString(Posn p,String s) @defthing[drawString (Posn p,String s)]
Draws the string @tt{s} at @tt{p} on @tt{this}Canvas]. If it succeeds, it produces @tt{true}. Draws the string @tt{s} at @tt{p} on @tt{this}Canvas]. If it succeeds, it produces @tt{true}.

View File

@ -7,7 +7,8 @@
@local-table-of-contents[] @local-table-of-contents[]
@include-section["draw.scrbl"] @;"A Functional Drawing Library (HtDC)"
@;include-section["idraw.scrbl"] @;"An Imperative Drawing Library (HtDC)"
@include-section["geometry.scrbl"] @;"A Geometry Library (HtDC)" @include-section["geometry.scrbl"] @;"A Geometry Library (HtDC)"
@include-section["colors.scrbl"] @;"A Colors Library (HtDC)" @include-section["colors.scrbl"] @;"A Colors Library (HtDC)"
@include-section["draw.scrbl"] @;"A Functional Drawing Library (HtDC)"
@include-section["idraw.scrbl"] @;"An Imperative Drawing Library (HtDC)"

View File

@ -1,49 +1,56 @@
{ (define LIBNAME "An Imperative Drawing Library (HtDC)") #lang scribble/doc
(include "head.tinc") }
@(require scribble/manual (for-label teachpack/htdc/draw))
<p>Add @title[#:tag "iJdraw"]{Draw: idraw.*}
<pre><code>
Add
@verbatim[#:indent 3]{
import idraw.* import idraw.*
</code></pre> }
at the top of your Definitions Window to import this library. 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> This package provides stateful classes and imperative methods for a visual
<code> world. Here is its class diagram of public fields and methods:
@verbatim[#:indent 3]{
import colors.*; import colors.*;
import geometry.*; import geometry.*;
+---------------------------------+ +---------------------------------+
| abstract World | | abstract World |
+---------------------------------+ +------------------------------------+ +---------------------------------+
| Canvas theCanvas |------>| Canvas | | Canvas theCanvas |---+
+---------------------------------+ +------------------------------------+ +---------------------------------+ |
| void bigBang(int,int,double) | +------------------------------------+ | void bigBang(int,int,double) | |
| World endOfTime(String) | | void show() | | World endOfTime(String) | |
| World endOfWorld(String) | | void close() | | World endOfWorld(String) | |
| abstract void onTick() | | void drawCircle(Posn,int,IColor) | | abstract void onTick() | |
| abstract void onKeyEvent(String)| | void drawDisk(Posn,int,IColor) | | abstract void onKeyEvent(String)| |
| abstract void draw() | | void drawRect(Posn,int,int,IColor) | | abstract void draw() | |
+---------------------------------+ | void drawLine(Posn,Posn,IColor) | +---------------------------------+ |
|
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) | | void drawString(Posn,String) |
+------------------------------------+ +------------------------------------+
</code> }
</pre>
</p>
<p>The abstract <code>World</code> class in <code>idraw</code> provides the same The abstract @tt{World} class in @tt{idraw} provides the same methods as
methods as the <code>World</code> class in <a href="./draw.html#world">the the @tt{World} class in @secref["Jworld"] (@tt{draw} package). Their return
<code>draw</code> library</a>. Their return values are usually <code>void</code>, values are usually @tt{void}, however, except for @tt{endOfTime} and
however, except for <code>endOfTime</code> and <code>endOfWorld</code>, which @tt{endOfWorld}, which continue to return the last world.
continue to return the last world.</p>
<p>In an analogous manner, the methods in the <code>Canvas</code> class export In an analogous manner, the methods in the @tt{Canvas} class export
the same methods as the <code>Canvas</code> class in <a the same methods as the @tt{Canvas} class in @secref["canvas"]
href="./draw.html#canvas">the <code>draw</code> package</a>. Their return values, (@tt{draw} package). Again their return values are @tt{void}.
however, are <code>void</code>. </p>
{(include "foot.tinc")}

View File

@ -1 +1,14 @@
#lang scheme
(define (err n)
(lambda x
(error n "is a stub; see docs for draw.*")))
(define-syntax prov
(syntax-rules ()
[(prov name ...) (begin (provide name ...) (define name (err name)) ...)]))
(prov bigBang endOfTime endOfWorld onTick onKeyEvent draw show close
drawCircle drawDisk drawRect drawLine drawString)
(printf "this is just a stand-in for the plt/collects/htdch/draw/ library\n") (printf "this is just a stand-in for the plt/collects/htdch/draw/ library\n")

View File

@ -8,7 +8,7 @@
@title[#:tag "world"]{Simulations and Animations: world.ss} @title[#:tag "world"]{Simulations and Animations: world.ss}
@declare-exporting[teachpack/htdp/world] @declare-exporting[teachpack/htdp/world #:use-sources (teachpack/htdp/image)]
The teachpack provides two sets of tools. The first allows students to The teachpack provides two sets of tools. The first allows students to
create and display a series of animated scenes, i.e., a simulation. The create and display a series of animated scenes, i.e., a simulation. The