Package Exports
- culori
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (culori) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 theh
,s
andv
value; - if the user inputs
#ffffff00
I might also want to apply thea: 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:
- Named colors
- Hex colors (with 3, 4, 6, or 8 digits)
- RGB and RGBA
- HSL and HSLA
- HWB
- LAB and LCH
- Grays
Additionally, it supports:
- HSV (also called HSB)
- HSI
- CubeHelix (soon)
Documentation
- Getting Started with Culori
- Culori Recipes
- Extending Culori
- API Reference
- Benchmarks
- Further Reading
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: d3-color and d3-interpolate by Mike Bostock, and chroma.js by Gregor Aisch.
You may also want to look at TinyColor by Brian Grinstead, color by Heather Arthur, and color.js by Andrew Brehaut et al.