Due: 4:00 p.m.,
This homework is also available in PDF.
Summary: In this assignment, you will extend the ideas from the lab on iterating over positions in an image to build an interesting composite image.
Purposes: To give you further experience with
region.compute-pixels! procedure. To help you think about
applications of recent techniques to making images.
Expected Time: 1-2 hours
Collaboration: I encourage you to work in groups of size three. You may, however, work alone or work in a group of size two or size four. You may discuss this assignment with anyone, provided you credit such discussions when you submit the assignment.
Submitting: Email me your answer. More details below.
Warning: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.
In a recent lab, you learned
how to use the
region.compute-pixels! procedure to create
rectangles in which the color at any position is computed by a formula
based on the position. We call such computed swatches of color
gradients. For example, the following puts a 41x41
box with a simple gradient somewhere in the middle of the image called
(define square (lambda (x) (* x x))) (region.compute-pixels! canvas 80 80 120 120 (lambda (pos) (rgb.new (* 0.5 (+ (square (- (position.row pos) 100)) (square (- (position.col pos) 100)))) (* 150 (abs (sin (* .2 (position.row pos))))) 0)))
We've also seen how to put borders on those gradients. One simple technique is to draw a larger, single-colored, box before we draw the gradient. For example, we might precede the preceding code with
(region.compute-pixels! canvas 76 76 124 124 (lambda (pos) (rgb.new 0 0 0)))
Create an interesting image with three bordered rectangles. Each rectangle should have a different gradient, although you should use a similar formula to compute each gradient. (You might vary gradients by changing scale factors in your computation, for example.) At least two of the gradients should overlap. You may choose the size of the image, the size of the rectangles, the colors in your gradients, and the formula for the gradients.
Write a short paragraph that explains your choice of gradients and placement.
I will primarily judge your work on your success on the structure of the code for your gradients.
You are likely to receive a higher grade if you give a more careful analysis of how you arrived at your code and how the code relates to your goals for the gradient.
You are also likely to receive a higher grade if you find a way to generalize your code.
Please submit this work via email. The email should be titled CSC151.02 Assignment 07 and should contain your code for creating the image.
Please send your work as the body of an email message. I don't like attachments, and prefer not to receive them when they can be avoided.
You need not attach the image you've created - I can run the code to create the image. (Note, also, that the code is likely to be much smaller than the image.)
Monday, 17 September 2007 [Samuel A. Rebelsky]
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Mon Dec 3 09:55:58 2007.
The source to the document was last modified on Mon Sep 17 20:59:03 2007.
This document may be found at
You may wish to validate this document's HTML ; ;Samuel A. Rebelsky, email@example.com
http://creativecommons.org/licenses/by-nc/2.5/or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.