From 981066f78705fa2081391e5d1b37a142e0c62761 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Thu, 21 Dec 2006 19:03:54 +0000 Subject: [PATCH] world docs fixed svn: r5156 --- collects/teachpack/htdp/Docs/world.thtml | 45 ++++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/collects/teachpack/htdp/Docs/world.thtml b/collects/teachpack/htdp/Docs/world.thtml index c03db5167e..88dde9457d 100644 --- a/collects/teachpack/htdp/Docs/world.thtml +++ b/collects/teachpack/htdp/Docs/world.thtml @@ -1,12 +1,43 @@ -{ (define LIBNAME "Animated Images") +{ (define LIBNAME "Animated Images, Simulating Worlds") (include "head.tinc") } -

The teachpack provides two kinds of functions. The first four allow +

The teachpack provides two kinds of functions. The first five allow students to simulate a small world of animated drawings and games:

-
  • {(idx big-bang)} : Number Number Number World -> true
    +
  • {(idx run-simulation)} : Nat Nat Number [Nat -> Image] -> true
    + (run-simulation width height r create-image) + creates and shows a width x height canvas, + starts a clock, ticking every r (usually fractional) seconds, + and, every time the clock ticks, it applies create-image to + the number of ticks passed since this function call. + +

    In addition, the function pops up a frame and displays the pictures that + create-image generates. The result is a simple animation. +

    + +

    Example: +

    +
    +(define (create-UFO-scene height)
    +  (place-image UFO 50 height (empty-scene 100 100)))
    +
    +(define UFO (overlay (circle 10 'solid 'green) (rectangle 40 4 'solid 'green)))
    +
    +(run-simulation 100 100 (/ 1 28) create-UFO-scene)
    +
    +
    +

    + +

    + The Stop button on the frame allows users to stop the clock + and thus the simulation. It also enables the Images button, + which then allows users to create images of all the steps taken since the + beginning of time. +

    + +
  • {(idx big-bang)} : Nat Nat Number World -> true
    (big-bang width height n w) - creates and shows a width x height canvas, + creates and shows a width x height canvas, starts the clock, makes it tick every n seconds, and makes w the first world @@ -33,7 +64,7 @@ students to simulate a small world of animated drawings and games: or the events of releasing a key on the keypad. -
  • {(idx on-mouse-event)} : (World Number Number MouseEvent -> +
  • {(idx on-mouse-event)} : (World Nat Nat MouseEvent -> World) -> true
    (on-mouse-event clack) means that DrScheme must call clack on the current world, the current x and y coordinates of the mouse, and and a @@ -69,12 +100,12 @@ students to simulate a small world of animated drawings and games:

    The rest are functions for creating scenes:

    -
  • {(idx nw:rectangle)} : Number Number Mode Color -> Image
    +
  • {(idx nw:rectangle)} : Nat Nat Mode Color -> Image
    (nw:rectangle width height mode color) creates a width x height rectangle, solid or outlined, with its anchor in the NW corner -
  • {(idx empty-scene)} : Number Number -> Scene
    +
  • {(idx empty-scene)} : Nat Nat -> Scene
    (empty-scene width height) creates a width x height "scene" (frame with origin in NW)