{ (define LIBNAME "Simple Drawing Exercises") (include "head.tinc") } The teachpack provides two kinds of functions. The first four allow students to simulate a small world of animated drawings and games:
The world consists of a canvas and whatever the tick and keyevent handlers draw on it. For the use of these functions, see the HtDP+ material. With the reminder, the students can write functions that draw into this world:clear-
operations for each
draw-
operation. The arguments are the same. Note: use
clear-rectangle
instead of clear-string
for now.
Sample session: Set teachpack to draw.ss
and execute:
> (start 500 500)
> (draw-solid-disk (make-posn 100 100) 3 'red)
true
> (clear-solid-disk (make-posn 100 100) 3 'red)
true
> (sleep-for-a-while 1)
> (draw-solid-disk (make-posn 100 100) 3 'red)
true
> (clear-solid-disk (make-posn 100 100) 3)
true
> (stop)
>
This session opens a window, draws a red disk, clears it, sleeps for a second,
and then repeats. The last expression closes the canvas.
See http://www.ccs.neu.edu/home/matthias/HtDP/Extended/
for an example on how to use get-key-event
. The program is
the basis for an extended exercise under development.
{(include "foot.tinc")}