simple-rgb

2019-05-21

simple manipulation of {X|HT}ML RGB values

Upstream URL

github.com/wmannis/simple-rgb

Author

William S. Annis <wm.annis@gmail.com>

Maintainer

William S. Annis <wm.annis@gmail.com>

License

MIT
README

SIMPLE-RGB

This library was designed to be used by another library which generates SVG files. It is currently focused on the small set of basic color manipulations (lightening, compliments, etc) you might use to generate a color palette for a GUI or web page.

(March 2019) The current all-singing, all-dancing color manipulation library is Dufy, which you should consider if you have serious color manipulation needs.

Package

The package name is :simple-rgb, with a single nickname, :rgb.

It depends on no other libraries, but you will need LIFT to run the unit tests.

Conditions and Restarts

[condition]
hsv-type-error
This condition is raised by hsv if any of the three values passed to it falls outside the range 0.0 through 1.0.

There are no restarts.

Functions

[function]
rgb r g b => rgb-vector
This is the only way to create a literal RGB value the rest of the library will accept. Each color element is an integer between 0 and 255. Anything outside this range, or of a non-integer type, will raise a type-error condition.

[function]
rgb= a b => boolean
Tests RGB equality.

[function]
hsv h s v => hsv-vector
This is the only way to create a literal HSV value the rest of the library will accept. Each of the values has to be a float between 0.0 and 1.0. A range or type problem will result in a hsv-type-error condition being raised.

Note that some HSV libraries represent the h element in degrees. This one does not.

[function]
mix-rgb a b &key (alpha 0.5) => rgb-vector
Blends two RGB colors. By default the mix is even, but by setting the :alpha keyword you can weight the mix, with 0.0 simply returning the first argument, 1.0 the second.

[function]
lighten-rgb a => rgb-vector
Lightens a color by mixing it with white with an alpha of 0.5. For different shading use mix-rgb directly.

[function]
darken-rgb a => rgb-vector
Darkens a color by mixing it with black with an alpha of 0.5. For different shading use mix-rgb directly.

[function]
greyscale-rgb a => rgb-vector
Converts a color to greyscale by setting each color element to the value 0.3r + 0.59g + 0.11b. See: Grayscale.

[function]
invert-rgb a => rgb-vector
Inverts a color.

[function]
complement-rgb a => rgb-vector
Creates the complement of the color using the forumla described at Adobe.

[function]
rgb->hsv a => hsv-vector
Converts an RGB value to HSV.

[function]
hsv->rgb a => rgb-vector
Converts and HSV value to RGB.

[function]
rotate-hsv a rotation => hsv-vector
Rotates the hue of a HSV color. The rotation is expressed in degrees, rather than the 0.0-1.0 range used by the rest of the library. Creating palettes of complimentary and contrasting colors is often thought of in terms of rotating a color wheel, and I've used degrees here since that's more natural for me, at least, to think about.

[function] rotate-rgb a rotation => rgb-vector
This convenience function is equivalent to:

(hsv->rgb (rotate-hsv (rgb->hsv a) rotation))

[function]
xmlify-rgb a &optional (stream nil) => x/html-color-string
Turns an RGB value into a string of the form #FFAADD. Optionally you can specify a stream designator of the sort format expects. By default it returns the string.

[function]
parse s => rgb-vector This converts an HTML color string into an RGB value.

Dependencies (0)

    Dependents (0)

      • GitHub
      • Quicklisp