CSC151 2007S, Class 06: Transforming Colors Admin: * No reading for Monday! * Reminder: EC: Cross-Country meet this weekend. (Oakland Acres; Buses depart from PEC) * EC: Math video at noon on Monday. Free pizza! (3821) * Please don't ask for extensions at 2:00 a.m. * From now on, I am making the due time for assignments 4:00 p.m. * HW4 assigned. * Note: Poor proofreading in the lab "pixel-map" should be "image.map" "pixel-map!" should be "image.map!" Overview: * Preliminary lessons from HW3. * Key points from the reading. * Questions and answers. * Lab! /Preliminary Lessons from HW3/ * Let Scheme figure out the values; you don't have to. * Problem: Copy the color in (0,0) from src to (0,0) in destination > (define tmp (image.get-pixel src 0 0)) > (rgb->string tmp) "127/32/90" > (image.set-pixel! destination 0 0 (rgb.new 127 32 90) * Alternate: > (define tmp (image.get-pixel src 0 0)) > (image.set-pixel! destination 0 0 tmp) * Alternate > (image.set-pixel! destination 0 0 (image.get-pixel src 0 0)) * Not a new issue: "Set pixel 1 1 to purple" > (cname->rgb "purple") -1442775041 > (image.set-pixel canvas 1 1 -1442775041) VS > (define purple (cname->rgb "purple")) > (image.set-pixel canvas 1 1 purple) VS > (image.set-pixel canvas 1 1 (cname->rgb "purple")) * Definitions window vs. Interactions window. * When you hit "run", everything in the interactions window disappera * WHen you hit "run", any call to image.new or image.load creates a new image, WHICH IS DIFFERENT THAN THE ONE YOU CURRENTLY SEE ON THE SCREEN * Some problems not even Emily can fix. * Computers are Sentient and Malicious. * More on Tuesday. /Key Points from the Reading/ * Topic: Thinking about transforming colors * Scaling: Once you know how to transform a color, you can transform a pixel or even a whole image * Controlling operations: * In Scheme, "map" means "compute with every component" * IN Math and Scheme, "compose" means "do two things in sequence" /Questions and Answers/ /Lab + Reflection/ * Don't work with huge images, at least not now * REMEMBER! Every lab is online. WHen there's a lot of code to type, copy/paste! * How far did you get in the lab? * No further than Problem 3 * Beyond Problem 3 but no further than Problem 6 * Beyond Problem 6 but no further than Problem 9