Create a vector named palette, of length 16, in which the element at
position x is a color with red intensity 16x and
green intensity 16(15 - x).
Develop a procedure that takes two arguments, a device context and a vector
of colors. When invoked, the procedure should first determine and save the
current background color stored in the device context (by sending it a
get-background message). Then it should run through the colors in
the vector, repainting with each color in turn. Finally, it should repaint
with the original background color.
Graphics operations on MathLAN workstations are so fast that a test run of
your procedure will probably appear as nothing more than a quick flicker.
You can slow your procedure down by inserting, in the body of your kernel,
a call to the DrScheme procedure sleep. This procedure takes a
positive real number as argument and causes DrScheme to suspend its
processing for the specified number of seconds.
Define a pen that draws solid lines, two pixels wide, in dark blue. Use it
to draw a circle in the middle of drawing-canvas. (To draw a
circle, send the draw-ellipse message to the device context, giving
it the same value for the width and height of the ellipse.)
What happens if you draw an arc with a transparent-style pen and a solid-style brush?
Write a DrScheme program that displays a graphic of an archery target: on a gray background, concentric rings of white (the outermost), black, blue, and red, with a gold disk in the middle. The outer diameters of the rings are, respectively, five, four, three, and two times the diameter of the gold disk. If you like, print the point value of each color at the top of the ring or disk (1 for white, 2 for black, 3 for blue, 4 for red, and 5 for gold).
The file /home/stone/courses/scheme/examples/kaleidoscope.ss
contains a Scheme program that creates a canvas that
responds to keyboard input by drawing a randomly selected shape and then
reflecting it to produce a pattern with eightfold symmetry. (All the
letter, number, and punctuation keys have the same effect except the c key, which clears the canvas.) Feel free to experiment with the program
and to add new features to it -- for instance: