* Added a `teachpack' function to do teachpack titles

* Made it add "foo teachpack" as an index entry

svn: r10687
This commit is contained in:
Eli Barzilay 2008-07-09 02:28:20 +00:00
parent 4df95e9da7
commit afad5af486
16 changed files with 130 additions and 111 deletions

View File

@ -1,17 +1,17 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/arrow-gui))
teachpack/htdp/arrow-gui))
@title[#:tag "arrow-gui"]{An Arrow GUI: arrow-gui.ss}
@teachpack["arrow-gui"]{An Arrow GUI}
@declare-exporting[teachpack/htdp/arrow-gui]
The teachpack provides operations for creating and manipulating an arrow
GUI. We recommend using the @seclink["world"]{world teachpack} instead.
@deftech{modelT} @scheme[(-> button% event% true)]
@deftech{modelT} @scheme[(-> button% event% true)]
A @tech{modelT} is a function that accepts and ignores two arguments.

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/arrow))
teachpack/htdp/arrow))
@title[#:tag "arrow"]{Managing Control Arrows: arrow.ss}
@teachpack["arrow"]{Managing Control Arrows}
@declare-exporting[teachpack/htdp/arrow]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/convert))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/convert))
@title[#:tag "convert"]{Converting Temperatures: convert.ss}
@teachpack["convert"]{Converting Temperatures}
@declare-exporting[teachpack/htdp/convert]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label (except-in scheme/base file-size)
teachpack/htdp/dir))
teachpack/htdp/dir))
@title[#:tag "dir"]{Working with Files and Directories: dir.ss}
@teachpack["dir"]{Working with Files and Directories}
@declare-exporting[teachpack/htdp/dir]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/docs))
teachpack/htdp/docs))
@title[#:tag "docs"]{Manipulating Simple HTML Documents: docs.ss}
@teachpack["docs"]{Manipulating Simple HTML Documents}
@declare-exporting[teachpack/htdp/docs]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/draw))
teachpack/htdp/draw))
@title[#:tag "draw"]{Simple Drawing: draw.ss}
@teachpack["draw"]{Simple Drawing}
@declare-exporting[teachpack/htdp/draw]
@ -26,29 +26,36 @@ a color, it raises an error.
@scheme[width] x @scheme[height] canvas.}
@defproc[(start/cartesian-plane [width number?][height number?])
true]{Opens a @scheme[width] x @scheme[height] canvas and draws a Cartesian
plane.}
true]{
Opens a @scheme[width] x @scheme[height] canvas and draws a Cartesian
plane.}
@defproc[(stop) true]{Closes the canvas.}
@defproc[(draw-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) true]{Draws a
@scheme[c] circle at @scheme[p] with radius @scheme[r].}
@defproc[(draw-circle [p posn?] [r number?] [c (unsyntax @tech{DrawColor})])
true]{
Draws a @scheme[c] circle at @scheme[p] with radius @scheme[r].}
@defproc[(draw-solid-disk [p posn?] [r number?] [c (unsyntax @tech{DrawColor})]) true]{Draws a
@scheme[c] disk at @scheme[p] with radius @scheme[r].}
@defproc[(draw-solid-disk [p posn?] [r number?] [c (unsyntax @tech{DrawColor})])
true]{
Draws a @scheme[c] disk at @scheme[p] with radius @scheme[r].}
@defproc[(draw-solid-rect [ul posn?] [width number?] [height number?] [c
(unsyntax @tech{DrawColor})]) true]{Draws a @scheme[width] x @scheme[height], @scheme[c]
rectangle with the upper-left corner at @scheme[ul].}
@defproc[(draw-solid-rect [ul posn?] [width number?] [height number?]
[c (unsyntax @tech{DrawColor})])
true]{
Draws a @scheme[width] x @scheme[height], @scheme[c] rectangle with the
upper-left corner at @scheme[ul].}
@defproc[(draw-solid-line [strt posn?] [end posn?] [c (unsyntax @tech{DrawColor})]) true]{Draws
a @scheme[c] line from @scheme[strt] to @scheme[end].}
@defproc[(draw-solid-line [strt posn?] [end posn?]
[c (unsyntax @tech{DrawColor})])
true]{
Draws a @scheme[c] line from @scheme[strt] to @scheme[end].}
@defproc[(draw-solid-string [p posn?][s string?]) true]{Draws @scheme[s] at
@scheme[p].}
@defproc[(draw-solid-string [p posn?] [s string?]) true]{
Draws @scheme[s] at @scheme[p].}
@defproc[(sleep-for-a-while [s number?]) true]{Suspends evaluation for
@scheme[s] seconds.}
@defproc[(sleep-for-a-while [s number?]) true]{
Suspends evaluation for @scheme[s] seconds.}
The teachpack also provides @scheme[clear-] operations for each
@scheme[draw-] operation. The arguments are the same. Note: use
@ -58,8 +65,8 @@ The color argument for all @scheme[clear-] functions are optional.
@;-----------------------------------------------------------------------------
@section[#:tag "interaction"]{Interactions with Canvas}
@defproc[(wait-for-mouse-click) posn?]{Waits for the user to click on the
mouse, within the canvas.}
@defproc[(wait-for-mouse-click) posn?]{
Waits for the user to click on the mouse, within the canvas.}
@deftech{DrawKeyEvent}: @scheme[(or/c char? symbol?)] A
@tech{DrawKeyEvent} represents keyboard events:

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/elevator))
teachpack/htdp/elevator))
@title[#:tag "elevator"]{Controlling an Elevator: elevator.ss}
@teachpack["elevator"]{Controlling an Elevator}
@declare-exporting[teachpack/htdp/elevator]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/graphing))
teachpack/htdp/graphing))
@title[#:tag "graphing"]{Graphing Functions: graphing.ss}
@teachpack["graphing"]{Graphing Functions}
@declare-exporting[teachpack/htdp/graphing]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/guess))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/guess))
@title[#:tag "guess"]{Guessing Numbers: guess.ss}
@teachpack["guess"]{Guessing Numbers}
@declare-exporting[teachpack/htdp/guess]
@ -19,7 +19,7 @@ is the user's guess, and @scheme[target], which is the randomly
chosen number-to-be-guessed. The result is a symbol that reflects the
relationship of the player's guess to the target.}
@defproc[(guess-with-gui-3 [check-guess (-> digit? digit? digit? number? symbol?)]) true]{
@defproc[(guess-with-gui-3 [check-guess (-> digit? digit? digit? number? symbol?)]) true]{
The @scheme[check-guess] function consumes three digits (@scheme[digit0],
@scheme[digit1], @scheme[digit2]) and one number (@scheme[target]). The
latter is the randomly chosen number-to-be-guessed; the three digits are

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/gui))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/gui))
@title[#:tag "gui"]{Simple Graphical User Interfaces: gui.ss}
@teachpack["gui"]{Simple Graphical User Interfaces}
@declare-exporting[teachpack/htdp/gui]

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/hangman))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/hangman))
@title[#:tag "hangman"]{Hangman : hangman.ss}
@teachpack["hangman"]{Hangman}
@declare-exporting[teachpack/htdp/hangman]

View File

@ -1,11 +1,11 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/image
lang/private/imageeq))
teachpack/htdp/image
lang/private/imageeq))
@title[#:tag "image"]{Manipulating Images: image.ss}
@teachpack["image"]{Manipulating Images}
@declare-exporting[teachpack/htdp/image]
@ -30,8 +30,8 @@ A @tech{Mode} is used to specify whether painting a shape fills or
outlines the form.
@defstruct[color [(red (and/c natural-number/c (<=/c 255)))
(green (and/c natural-number/c (<=/c 255)))
(blue (and/c natural-number/c (<=/c 255)))]]
(green (and/c natural-number/c (<=/c 255)))
(blue (and/c natural-number/c (<=/c 255)))]]
@deftech{RGB} @scheme[color?]
@ -71,10 +71,10 @@ shapes with the following functions.
@scheme[m] and painted in color @scheme[c]}
@defproc[(star [n (and/c number? (>=/c 2))]
[outer (and/c number? (>=/c 1))]
[inner (and/c number? (>=/c 1))]
[m (unsyntax @tech{Mode})]
[c (unsyntax @tech{Color})]) image?]{
[outer (and/c number? (>=/c 1))]
[inner (and/c number? (>=/c 1))]
[m (unsyntax @tech{Mode})]
[c (unsyntax @tech{Color})]) image?]{
Creates a multi-pointed star with @scheme[n] points, an @scheme[outer]
radius for the max distance of the points to the center, and
an @scheme[inner] radius for the min distance to the center. }
@ -137,11 +137,11 @@ find out where the pinhole is and place it where convenient.
Images can be composed, and images can be found within compositions.
@defproc[(add-line [i image?]
[x number?]
[y number?]
[z number?]
[u number?]
[c (unsyntax @tech{Color})]) image?]{
[x number?]
[y number?]
[z number?]
[u number?]
[c (unsyntax @tech{Color})]) image?]{
Creates an image by adding a line (colored @scheme[c]) from @scheme[(x,y)]
to @scheme[(z,u)] to image @scheme[i].}
@ -238,10 +238,10 @@ and converts a list of colors into an image.
Converts an image to a list of colors.}
@defproc[(color-list->image [l List-of-color]
[width natural-number/c]
[height natural-number/c]
[x natural-number/c]
[y natural-number/c]) image?]{
[width natural-number/c]
[height natural-number/c]
[x natural-number/c]
[y natural-number/c]) image?]{
Converts a list of colors @scheme[l] to an image with the given
@scheme[width] and @scheme[height] and pinhole (@scheme[x],@scheme[y])
coordinates, specified with respect to the top-left of the image.}
@ -252,20 +252,20 @@ indicates fully transparent.
@defstruct[alpha-color [(alpha (and/c natural-number/c (<=/c 255)))
(red (and/c natural-number/c (<=/c 255)))
(green (and/c natural-number/c (<=/c 255)))
(blue (and/c natural-number/c (<=/c 255)))]]{
(red (and/c natural-number/c (<=/c 255)))
(green (and/c natural-number/c (<=/c 255)))
(blue (and/c natural-number/c (<=/c 255)))]]{
A structure representing an alpha color.}
@defproc[(image->alpha-color-list [img image?]) (list-of alpha-color?)]{
to convert an image to a list of alpha colors}
@defproc[(alpha-color-list->image
[l (list-of alpha-color?)]
[width integer?]
[height integer?]
[x integer?]
[y integer?]) image? ]{
[l (list-of alpha-color?)]
[width integer?]
[height integer?]
[x integer?]
[y integer?]) image?]{
Converts a list of @scheme[alpha-color]s @scheme[l] to an image with the given
@scheme[width] and @scheme[height] and pinhole (@scheme[x],@scheme[y])
coordinates, specified with respect to the top-left of the image.}

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/master))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/master))
@title[#:tag "master"]{MasterMinding : master.ss}
@teachpack["master"]{MasterMinding}
@declare-exporting[teachpack/htdp/master]

View File

@ -0,0 +1,10 @@
#lang scheme/base
(require scribble/manual)
(provide teachpack)
(define (teachpack tp . name)
(apply title #:tag tp
`(,@name ": " ,(filepath (format "~a.ss" tp))
,(index (format "~a teachpack" tp)))))

View File

@ -1,10 +1,10 @@
#lang scribble/doc
@(require scribble/manual
(for-label scheme
teachpack/htdp/show-queen))
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/show-queen))
@title[#:tag "show-queen"]{8 Queens: show-queen.ss}
@teachpack["show-queen"]{Queens}
@declare-exporting[teachpack/htdp/show-queen]

View File

@ -1,12 +1,12 @@
#lang scribble/doc
@(require scribble/manual
@(require scribble/manual "shared.ss"
(for-label scheme
teachpack/htdp/image
teachpack/htdp/world
lang/private/imageeq))
teachpack/htdp/image
teachpack/htdp/world
lang/private/imageeq))
@title[#:tag "world"]{Simulations and Animations: world.ss}
@teachpack["world"]{Simulations and Animations}
The teachpack provides two sets of tools. The first allows students to
@ -20,20 +20,22 @@ second one generalizes the first by adding interactive GUI features.
The teachpack assumes working knowledge of the basic image manipulation
primitives and introduces a special kind of image: a scene.
@deftech{Scene}@schemeblock[(and/c image?
(lambda (i)
(and (= (pinhole-x i) 0) (= (pinhole-y i) 0))))]
@deftech{Scene}@;
@schemeblock[(and/c image?
(lambda (i)
(and (= (pinhole-x i) 0) (= (pinhole-y i) 0))))]
The teachpack can display only @tech{Scene}s, which are images whose
pinholes are at position @scheme[(0,0)].
@defproc[(empty-scene [width natural-number/c]
[height natural-number/c])
(unsyntax @tech{Scene})]
{Creates a @scheme[width] x @scheme[height] @tech{Scene}.}
[height natural-number/c])
(unsyntax @tech{Scene})]
{Creates a @scheme[width] x @scheme[height] @tech{Scene}.}
@defproc[(place-image [img image?] [x number?][y number?]
[s (unsyntax @tech{Scene})]) (unsyntax @tech{Scene})]
@defproc[(place-image [img image?] [x number?] [y number?]
[s (unsyntax @tech{Scene})])
(unsyntax @tech{Scene})]
{Creates a scene by placing @scheme[img] at @scheme[(x,y)] into @scheme[s];
@scheme[(x,y)] are comp. graph. coordinates, i.e., they count right and
down from the upper-left corner.}
@ -41,12 +43,12 @@ pinholes are at position @scheme[(0,0)].
@section[#:tag "simulations"]{Simple Simulations}
@defproc[(run-simulation
[w natural-number/c]
[h natural-number/c]
[r number?]
[create-image (-> natural-number/c scene)]
[gifs? boolean? #f])
true]{
[w natural-number/c]
[h natural-number/c]
[r number?]
[create-image (-> natural-number/c scene)]
[gifs? boolean? #f])
true]{
creates and shows a canvas of width @scheme[w] and height @scheme[h] ,
starts a clock, making it tick every @scheme[r] (usually fractional)
seconds. Every time the clock ticks, drscheme applies @scheme[create-image] to
@ -61,7 +63,7 @@ pinholes are at position @scheme[(0,0)].
for describing students work.
}
In addition,
In addition,
@schemeblock[
(define (create-UFO-scene height)
(place-image UFO 50 height (empty-scene 100 100)))