Colors
1 Colors
2 structures and contracts
h**/  c
hsl?
hsi?
hsv?
color/  c
%/  c
hue/  c
3 Color Construction
color->hsl
hsl->color
color->hsv
hsv->color
color->hsi
hsi->color
hsl
hsv
hsi
4 Color manipulation
complement
set-hue
set-saturation
set-brightness
8.12

Colors🔗ℹ

Spencer Florence <spencer@florence.io>

 (require colors) package: colors

1 Colors🔗ℹ

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.

2 structures and contracts🔗ℹ

value

h**/c : contract?

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?

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

value

%/c : contract?

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

value

hue/c : contract?

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.

3 Color 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.

4 Color 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.