Simple Drawing Exercises


draw.ss

The teachpack draw.ss provides a miniscule collection of graphics functions:
  • start : number number -> void;
    opens a canvas
  • stop : -> void (no arguments);
    closes the canvas
  • draw-circle : posn number color -> true;
    draws a circle at posn with given radius and color
  • draw-solid-disk : posn number color -> true;
    draws a disk at posn with given radius and color
  • draw-solid-rect : posn number number color -> true;
    draws a rectangle at posn with given width, height, and color
  • draw-solid-line : posn posn color -> true;
    draws a line from one posn to other
  • sleep-for-a-while : number -> true;
    suspends evaluation for the given number of seconds
  • predefined colors: WHITE YELLOW RED BLUE GREEN BLACK



  • The teachpack also provides clear- operations for each draw- operation. The arguments are the same.


    The color argument for all functions are optional.

    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.