8.3

## Colors

 (require colors) package: colors

### 1Colors

the colors library provides alternatives to rgb color representations. it current supports hsl (hue, saturation, luminosity), hsi (hue, saturation, intensity), and hsv (hue, saturation, value).

For a full introduction to hsl and hsv color systems see Wikipedia.

### 2structures and contracts

 value
Contract that accepts hsl?, hsv?, or hsi? values.

 procedure(hsl? it) → boolean? it : any/c
is it an hsl color type?

 procedure(hsi? it) → boolean? it : any/c
is it an hsi color type?

 procedure(hsv? it) → boolean? it : any/c
is it an hsv color type?

 value
Contract which accepts any color like type: color%’s, strings, or h**/c values.

 value
Contract for value percentages. Equivalent to (real-in 0 1).

 value
Contract for value hues. Equivalent to (or/c (real-in 0 1) +nan.0). This contract is similar to %/c except +nan.0 is use for colors which do not have a defined hue.

### 3Color Construction

 procedure(color->hsl color) → hsl? color : color/c
Convert to an HSL color.

 procedure(hsl->color hsl) → (is-a/c color%) hsl : hsl?
Convert back to an RGB Color.

 procedure(color->hsv color) → hsv? color : color/c
Convert to an HSV color.

 procedure(hsv->color hsv) → (is-a/c color%) hsv : hsv?
Convert back to an RGB Color.

 procedure(color->hsi color) → hsi? color : color/c
Convert to an HSI color.

 procedure(hsi->color hsi) → (is-a/c color%) hsi : hsi?
Convert back to an RGB Color.

 procedure(hsl hue saturation lightness [alpha]) → hsl? hue : hue/c saturation : %/c lightness : %/c alpha : %/c = 1.0
Directly construct an HSL color.

 procedure(hsv hue saturation value [alpha]) → hsv? hue : hue/c saturation : %/c value : %/c alpha : %/c = 1.0
Directly construct an HSV color.

 procedure(hsi hue saturation intensity [alpha]) → hsi? hue : hue/c saturation : %/c intensity : %/c alpha : %/c = 1.0
Directly construct an HSI color.

### 4Color manipulation

 procedure(complement color) → h**/c color : h**/c
Get the complement of a color. The resulting color has the same type as color.

 procedure(set-hue color hue) → h**/c color : h**/c hue : hue/c
Construct a color like color but with the given hue. The resulting color has the same type as color.

 procedure(set-saturation color saturation) → h**/c color : h**/c saturation : %/c
Construct a color like color but with the given saturation. The resulting color has the same type as color.

 procedure(set-brightness color brightness) → h**/c color : h**/c brightness : %/c
Construct a color like color but with the given brightness. The resulting color has the same type as color.