The teachpack provides two sets of functions: one for drawing into a canvas and one for reacting to canvas events.
Warning: This teachpack is deprecated. Unless you’re solving exercises taken from How To Design Programs, we strongly encourage you to use the world teachpack instead; see Simulations and Animations: "world.ss".
DrawColor: (and/c symbol? (one-of/c 'white 'yellow 'red 'blue 'green 'black)) These six colors are definitely provided. If you want other colors, guess! For example, 'orange works, but 'mauve doesn’t. If you apply the function to a symbol that it doesn’t recognize as a color, it raises an error.
|(draw-solid-rect ul width height c) → true|
|ul : posn?|
|width : number?|
|height : number?|
|c : DrawColor|
The teachpack also provides clear- operations for each draw- operation. The arguments are the same. Note: use clear-rectangle instead of clear-string for now. The color argument for all clear- functions are optional.
|(wait-for-mouse-click) → posn?|
DrawWorld: For proper interactions, using the teachpack requires that you provide a data definition for DrawWorld . In principle, there are no constraints on this data definition. You can even keep it implicit, even if this violates the Design Recipe.
The following functions allow programs to react to events from the canvas.