# Assignment 5: Colors in Context

Due: 4:00 p.m., Friday, 14 September 2007
No extensions!

This homework is also available in PDF.

Summary: In this assignment, you will use the transformations you learned in the reading and lab on transforming RGB colors to construct images that let one explore colors in context.

Purposes: To give you further practice using the color transformations. To explore ways to generalize and automate actions. To experiment with ideas from the lecture on color theory.

Expected Time: One hour

Collaboration: You must work in a group of size two or three. 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

### The Theory: Relationship Between Colors

In his guest lecture on Monday, Professor Kluber gave us some terminology for describing relationships between colors For example, a color scheme can be complementary, analogous, monochromatic, or discordant. As some of you suggested in the followup discussion, it should be possible to compute other colors in a color scheme from a starting color.

Kluber also encouraged us to think about how colors can look different depending on the context in which they appear. At the end of class, we explored one technique for building images that let us test that hypothesis.

### The Practice: Transforming Colors

Do we know how to compute complements, analogs, and other variants of a color? We know some ways. In particular, we can use the basic color transformations that were discussed in the reading on transforming RGB colors. For example, to compute the complement of a color, `subject`, we might use `(rgb.complement subject)`.

## Assignment

Write Scheme instructions that permit you to view a single color in different contexts. Begin by using define to associate the name `subject` to the color we will explore. For example, you might write something like

```(define subject (cname->rgb "violet"))
```

Next, write Scheme instructions to create nine different 3x3 images. The center pixel of each image will be `subject`. In one image, all of the remaining pixels will be the same color. However, that color will differ from image to image.

The colors you should use for the non-center pixels are as follows.

• 1. Complementary. The remaining pixels should be the complement of `subject`.
• 2. Monochromatic: Darker. The remaining pixels in the image should be a darker tint of `subject`.
• 3. Monochromatic: Lighter. The remaining pixels in the image should be a lighter tint of `subject`.
• 4. White. The remaining pixels in the image should be white.
• 5. Black. The remaining pixels in the image should be black.
• 6. Psuedo-Analogous: Redder. The remaining pixels should be slightly redder than `subject`. (It is up to you how much redder.)
• 7. Psuedo-Analogous: Bluer. The remaining pixels should be slightly bluer than `subject`
• 8. Psuedo-Analogous: Greener. The remaining pixels should be slightly bluer than `subject`
• 9. Discordant. The remaining pixels should be in a color that is not complementary to, nor analogous to, nor a monochromatic variant of `subject`. It's up to you to decide how to combine filters to produce such a color. (It may be that you can't create such a color in every case. Try to pick a strategy that works for many or most colors.)

Although you may want to experiment using DrScheme's interactions pane, you should write the final version of your instructions in DrScheme's definitions pane. This way, if you've written your instructions well, you should be able to change the definition of `subject`, click the button, and see the new subject color in all nine different contexts.

## Important Evaluation Criteria

I will primarily look at whether your instructions are correct, automatic (that is, you did not need to copy and paste any results), and general (that is, one set of instructions works for any color as fgcolor). I will also look at how you make use of the transformation procedures and how you find a discordant color scheme.

Please submit this work via email. The email should be titled CSC151.02 Assignment 05 and should contain your code from the definitions pane.

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 certainly need not attach the images you created as I should be able to recreate them by running your code.

## History

Monday, 10 September 2007 [Janet Davis]

• Created

Monday, 10 September 2007 [Samuel A. Rebelsky]

• Reformatted to match Sam's page structure.

Monday, 17 September 2007 [Samuel A. Rebelsky]

• Reformatted again after a file-copying mishap.

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:55 2007.
The source to the document was last modified on Mon Sep 17 09:33:17 2007.
This document may be found at `http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2007F/Assignments/assignment.05.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.