Culori
Culori is a general-purpose color library for JavaScript.
Why I built this
There are already several excellent libraries out there for manipulating colors in JavaScript.
This library aims to provide a simple API to:
Convert between a variety of color formats.
Build a color picker for a particular format. Let's take the ubiquitous HSV color picker; the library should allow me to:
- map the user interface for the
h
, s
, v
values to a color that I can then convert to any other format - for a color in any format the user can input (these will usually be the CSS Colors Level 4), obtain the representation in HSV space, so the interface can be updated accordingly
Of particular interest is deciding when to apply the alpha channel to the interface (i.e. to an opacity slider). If the interface contains color swatches, I should decide whether to use the alpha channel or not:
- if the user inputs
#ffffff
I might only use the h
, s
and v
value; - if the user inputs
#ffffff00
I might also want to apply the a: 0
value.
Create color schemes based on a base color.
Obtain color scales to use in data visualization.
Supported formats
The library supports all the color formats defined in the CSS Colors Level 4:
Additionally, it supports:
- HSV (also called HSB)
- HSI
- CubeHelix (soon)
Documentation
About the project
Culori is written by Dan Burzo and is released under the MIT License.
It builds upon the ideas of two thoroughly documented and time-tested projects: chroma.js by Gregor Aisch and d3-color by Mike Bostock.
You may also want to look at TinyColor by Brian Grinstead, color by Heather Arthur, and color.js by Andrew Brehaut et al.