This module is a two week unit and constitutes the first of two programming projects. It counts for 9% of the grade (one module and one half of the project credit). Only exercise 1 is due in lab on Monday, March 25. The rest is due on April 8. There will be no Module G topping exercise in lab on March 25. Thus March 25 is a good opportunity to make up topping off exercises for previous modules, if not yet completed. In fact, it is crucial to get completely caught up with modules A-F at this time. See the lab modules note at the course web site for details. This is also a good lab to get design and debugging help on the painter graphics. This means you must work on the painter project this week so that you discover what parts of it you don't fully understand and can come to lab with your questions about it.
Goals:
Reading: SICP (Structure and Interpretation of Computer Programs), Section 2.2.4
Code on composers:
~saunders/280/Painters.scm.
The command: drscheme ~saunders/280/graphics/painters.scm
will start scheme with the painter code loaded. Otherwise you can open
it from the file menu. The summary lists most
of the procedures defined in the painter system.
Homework exercise:
Hand in printouts of your scheme code and of your graphics windows. Be sure each image is clearly labeled.
UUUUU UCUUU UUUUU
(stack fg:painter bg:painter n:odd-positive-int) -> q:painter
We will use the notation "x:t" to indicate that the argument x is supposed to be of type t. The output of stack is a painter q, where (q f:frame) will draw a diamond of fg's on a background of bg's in frame f. More precisely, on the i-th strip (of width (1/n)th of the frame width), q will paint j bg's followed by k fg's followed by k more bg's, each occupying (1/n)th of the strip. For the i-th strip, k would be 2*min(i, n+1-i) - 1 and j would be (n - k)/2. Something like this (for the case when fg paints a "p", bg paints a "." and n is 5).
. . p . . . p p p . p p p p p . p p p . . . p . .Illustrate on
123 456 789,The output UPO takes a painter p and paints (top-left p) spread over positions 1&2, paints (top-right p) in 3&6, paints (bottom-right p) in 8&9, paints (bottom-left p) in 4&7, and paints center in 5.
Use your imagination and cook up something you'll enjoy.
Here is a way to print a graphics window in unix (for submitting the result):
Module G Flourishes (optional problems):