Top off your modules in order. If you haven't topped an earlier module, do that first
Module G topping off exercise topperG1, a zoom operator
Write the unary painter operator (zoom p n). It takes a painter p and positive number n and it returns a painter which is a copy of p but zoomed in or out by the factor n. Let us agree that the normal zoom factor is 1. This is what you get from p itself. With an enormous zoom factor, approaching infinity, the output painter would just render the image of p in the single pixel in the center of the frame. More realistically, with a zoom factor of 3, the image would be in the middle third of the frame both horizontally and vertically. With a tiny zoom factor, approaching zero, the output painter would just render the single central pixel of p, copied throughout the image. More realistically, with a zoom factor of 1/2, the image would be twice as big, so that only the middle half would appear within the given frame.
We will not deal with cropping the image at the edge of the frame, so that if the given frame is a subframe of the overall viewport, a zoomed-in image may be partly written outside the specified frame. This is ok. For example (beside p (zoom p 1/3)) would be a painter that paints p in the left half and then paints two thirds (horizontally) of the middle third (vertically) of a 3 times bigger p. Of the 3 times bigger p, The middle third appears on the right and the left third overwrites the p on the left side. So note that images are not cropped at the edges of frames. However all painting is cropped at the edges of the viewport, so don't worry about writing all over the display screen!
Zoom is not as hard to write as it may seem at first. Realize that Transform-painter will accept coordinates that are not in the range from 0.0 to 1.0. For example, to zoom with n = 1/5, the origin coordinates would be 1/2 - 5/2, 1/2 - 5/2. Note that the zooming is from the center, (1/2 1/2), and that the inverse of n is the side length of the frame of the transformed painter (relative to the given frame).
Submission: Make a couple of printouts of zoomed painters. Write your name and the command that generated the image (including the call to zoom) on each page and hand them to Ray. Also exclaim topperG1 including your zoom code. You will get an acknowledgement only on this one, no bug reports.
Design a painter operator, a UPO
(cookie-cutter p:painter n:non-neg-int sx:small-shift-value sy:small-shift-value).It takes a painter p, a number n, and small shift amounts sx and sy. It returns a painter which paints p n times, each time shifted sx in the x (horizontal) direction and sy in the y (vertical) direction.
If you use the standard 400 by 400 pixel viewport and you paint p each time with the origin increased by .0025 in both x and y coordinates, you will get the lines thickened in a 3-D effect. Use an n near 10 and you'll get a cookie-cutter effect. If you use .005 or even .01 for the increment, the copies will appear distinct but the 3-d effect will still occur. Try the effect of different amounts of shift in the x and y directions. See how several painters, which have lines of various slopes, appear when shifted in various directions.
Show Ray your code and an image or two such as ((cookie-cutter wave 8 0.01 0.02) wf). r Try combinations in which you plug cookie-cutters into various painter operators and apply cookie-cutters to compound painters. For instance what is the difference between
(lambda (p) (flip-vert (cookie-cutter p 10 .0025 .01)))and
(lambda (p) (cookie-cutter (flip-vert p) 10 .01 .0025))