CSC151.02 2010S Functional Problem Solving : Reference

RGB Colors


Basic RGB Procedures

(rgb-new r g b)
MediaScheme Color Procedure. Build an RGB color whose red, green, and blue components are the specified values, each of which is an integer between 0 and 255 (inclusive).
(rgb-red color)
MediaScheme Color Procedure. Get the red component of an RGB color.
(rgb-green color)
MediaScheme Color Procedure. Get the green component of an RGB color.
(rgb-blue color)
MediaScheme Color Procedure. Get the blue component of an RGB color.
(rgb? value)
MediaScheme Color Predicate. Determine if value can be interpreted as an RGB color.

Converting To and From RGB Colors

(rgb->color-name rgb-color)
MediaScheme Color Procedure. Convert the given color to a string that names a similar color. Note that this conversion approximates the RGB color as there are many fewer names than colors.
(rgb->rgb-list rgb-color)
MediaScheme Color Procedure. Convert the given color to a list of its three components.
(rgb->string rgb-color)
MediaScheme Color Procedure. Convert the given RGB color to an easy-to-read string. (The string is not so easy to convert back to an RGB color.)
(color-name->rgb string)
MediaScheme Color Procedure. Build an RGB color that corresponds to the given color name.
(color->rgb string)
MediaScheme Color Procedure. Convert any of the myriad representations of colors to a corresponding RGB color.
(rgb-list->rgb rgb-lst)
MediaScheme Color Procedure. Converts a list representation of a color of the form (r g b) into an RGB color.

Transforming RGB Colors

(rgb-lighter rgb-color)
MediaScheme Color Procedure. Build a lighter version of the given color.
(rgb-darker rgb-color)
MediaScheme Color Procedure. Build a darker version of the given color.
(rgb-redder rgb-color)
MediaScheme Color Procedure Build a redder version of the given color.
(rgb-greener rgb-color)
MediaScheme Color Procedure. Build a greener version of the given color.
(rgb-bluer rgb-color)
MediaScheme Color Procedure. Build a bluer version of the given color.
(rgb-rotate rgb-color)
MediaScheme Color Procedure. Rotate the three components of the given color, setting the red component to the value of green, green to the value of blue, and blue to the value of red.
(rgb-phaseshift rgb-color)
MediaScheme Color Procedure.Phase shift” the color by adding 128 to components less than 128 and subtracting 128 from components greater than 128.
(rgb-complement rgb-color)
MediaScheme Color Procedure. Compute the psuedo-complement of the given color.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (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.