CSC151 2007S, Class 05: RGB Colors Admin: * My laptop died, so I am even further behind on everything. I apologize. * Fruit * Remember: Everything I hand out in class (more or less) is available online through the course Web site. * Make sure that it's clear when you're asking a question and when you're submitting a solution. "HW3" can mean either. * HELP NEEDED on HW3 * QUESTION on HW3 * We'll spend a few minutes discussing what I intend for assignment 3. Overview: * Problem: representing colors. * The RGB representation. * Complementary colors. Some quick notes:* * Problems in CS: Algorithms and Data For algs, need: Basic operations (learning() Naming Choices (coming late next week) Repeat operations (coming tomorrow and beyond) Name collections of operations * How about data * In the end, it's all 0's and 1's * And we know how to translate those to numbers (and vice versa) * We will therefore often think aqbout representing data as numbers, even when the data seems non-numeric * Also care about * Is it easy to compute with * Is it easy to use * RGB is the simplest technique for representing colors * By combining red, green, and blue we can get almost any color * Matches physical device * How do we phrase the amount of red, green, and blue? * Some do percentages * We'll use 0..255 Updates/Clarifications * You can AND SHOULD write defintions in the interactions * When you call rgb->cname, YOU HAVE TO CREATE THE RGB FIRST E.g., (rbg->cname (rbg.new 255 0 0)) NOT (rbg->cname 255 0 0) * (rgb->cname redcomp greencomp bluecomp) Notices * Lab hours * Should be TC present 6-midnight Mo-Th; also 5-midnight on Sunday * TAs will be available Sun-Thu 9-10ish Lessons * Nesting is natural and appropriate * Some of this stuff is "learning the vocabulary" * You need to know what operations are available to you and what they do * There is some confusion about naming * Names we define ourself don't have quotes and are defined with define (define pretty (rgb->new 123 32 97)) * Color names do have quotes and are built-in "magenta" * Things we define ourselves we can use when the appropriate type is expected * Since pretty is an rgb, we can write (image.set-pixel! canvas 10 10 pretty) * Since "magenta" is an rgb, we cannot write (image.set-pixel! canvas 10 10 "magenta") * Since canvas is NOT an rgb, we should not be able to write (image.set-pixel! canvas 10 10 canvs) * Since we haven't defined magenta, we cannot write (image.set-pixel! canvas 10 10 magenta) * But we could define magenta (define magenta (cname->rgb "magenta"))