On this page:

3 Color Operations

A color can be represented in three ways: as a color index (an integer in 0 to 299, inclusive), as a color name string, or as a rgb value. All drawing functions which take a color argument accept colors in any form. An rgb value is assigned to an index with change-color.


(struct rgb (red green blue)
    #:extra-constructor-name make-rgb)
  red : (real-in 0 1)
  green : (real-in 0 1)
  blue : (real-in 0 1)
Takes three values in the range 0 (dark) to 1 (bright) and returns an rgb (a color).


(change-color index rgb)  void?

  index : (integer-in 0 299)
  rgb : rgb?
Changes the color at index in the color table to the color specified in rgb. Only the first twenty-one indices are initialized; a color index should not be used until it has been initialized.

Returns #t if the default display screen for viewports is in color or #f otherwise.