Animate Arts I Winter 2004
Exercise 5: Stained glass patterns
Out: Thursday, March 4
Due: Tuesday, March 9, 11:59pm
In this exercise, you will build on the higher-level operators we designed in
class to make a language for constructing simple stained glass patterns.
Part 0: Install new version of meta
This version has a number of bug fixes as well as the ability to save your
editor configuration. More importantly, it has the accessor procedures
discussed in class today.
Part 1: Building new operators
Write code to implement the following procedures:
- [mirror-horizontally picture]
Should return a new picture consisting of two copies of picture next
to one another. The one of the left should be identical to picture,
but the one on the right should be the flipped horizontally. You can
flip the picture by scaling it with a scale factor of [point -1 1].
- [mirror-vertically picture]
Same, but should flip the picture vertically and stack them vertically.
- [horizontal-array picture count]
Should return a new picture consisting of count copies of picture,
arranged side-to-side in a row.
- [vertical-array picture count]
Same, but should arrange the pictures vertically
You will probably want to make liberal use of the stacking procedures defined
in class. You must provide test cases to demonstrate that each of these
procedures work. That is, you should include in your code calls that show
that the procedure works as advertised.
Part 2: A harder operator
Now write a procedure [surround center fringe] that returns a new
picture consisting of the picture center with copies of fringe
arranged around the perimeter of its bounding box. For example, the call
[surround [box 50 50] [box 10 10]] should return an image that looks like:
- You may assume that the width of the center is always a multiple of the
width of the fringe picture, and the height of the center is always a
multiple of the height of the fringe picture. That way you know you
won't have to use half of a fringe picture somewhere.
- You will probably find yourself wanting to make liberal use of the
recenter procedure defined in class.
Again, include test cases to show that it works.
Part 3: Have fun
Together with the operations discussed in class, you've now made a little
picture language for creating ersatz stained-glass windows. Play with it
and have fun. Experiment with making different kinds of images and choose
the 5 you like best.
Turning it in
Due to time limitations, this assignment will not be critiqued.
However, you are still responsible for making your code intelligible and
- Make a .meta file with the code and test cases for parts 1 and 2.
- Do not put your images into the file. This will make the
files too large.
- Do not just save your interaction window. When you do that,
we have to execute each expression in the file manually rather than running
them all at once (because meta tries to execute the command prompts as
- For part 3, end the file with an expression of the form:
This will let us execute one command to see all your images at once.
It will make it much easier to grade.