# Assignment 4: Blending Colors

Due: 10:00 a.m., Tuesday, 11 September 2007
No extensions!

Summary: In this assignment, you will use the color manipulation operations you learned in the lab on RGB colors to blend colors together.

Purposes: To get you comfortable working with the basic color operations in the GIMP. To help you think about colors.

Collaboration: I would prefer that you work in groups of size three. However, you may work alone, in a group of size two, or a group of size four. You may discuss this assignment and possible solutions with anyone you wish. If you discuss this assignment with people other than group members, make sure to include a citation (e.g., I consulted this person, who helped me do this).

Warning: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.

Contents:

## Background

A common effect in digital graphics is a color blend, in which colors range more or less smoothly from one color to another. For example, this image shows a blend from blue to red: . Isn't it beautiful?

What tools does one need to construct blends like the above? You must know how to manipulate the red, green, and blue components of colors used in digital images. ANd you know that. In particular, you can extract the red, green, and blue components of a color using rgb.red, rgb.green, and rgb.blue, and you can construct an RGB color using rgb.new. Along with basic mathematical operations and the `image.set-pixel!` operation, this is enough to let you construct blends images.

## Assignment

(a) For your first blend, create definitions to assign the names `color0` and `color1` to two of your favorite colors from the lab on raster graphics. Then write Scheme instructions to create an image 11 pixels wide and 1 pixel high that is a blend from `color0` to `color1`.

How should you blend the colors? That's up to you. As a hint, you might want the middle pixel to be the average of `color0` and `color1`. You might also note that there are ten transitions we make in going from `color0` to `color1`.

(b) For your second blend, assign the names `color0` and `color1` to one of your favorite colors and a pseudo-complement of that color. Use the Scheme instructions you wrote in (a) to generate a blend from `color0` to `color1`. What do you notice about the colors in the middle? Why does this happen?

## Extra Credit

Create a 5 x 5 image with a different color in each of the four corners. Then, fill in the edges with a blend of the two corner colors. Finally, fill in the middle with a blend as well. How should you blend the colors in the middle? Again, it's up to you.

## Important Evaluation Criteria

I intend to evaluate your assignment on the correctness and elegance of your solution. That is, is what you've done something that could be reasonably considered a blend, and have you chosen a technique that is clear and easy to understand.

Please submit this work via email. The email should be titled CSC151.02 Assignment 04 and should contain your answers to all parts of this assignment.

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.

## History

Thursday, 6 September 2007 [Janet Davis]

• Created for section 1.

Thursday, 6 September 2007 [Samuel A. Rebelsky]

• Reformatted for section 2.

Friday, 7 September 2007 [Samuel A. Rebelsky]

• Minor cleanup.

Disclaimer: 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:53 2007.
The source to the document was last modified on Mon Sep 10 20:50:18 2007.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007F/Assignments/assignment.04.html`.

You may wish to validate this document's HTML ; ;

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2007 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.) This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `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.