Announcing: color.js
1.0
color.js
, my javascript color management library, has reached version 1.0. I'm surprised about this because I wrote it back in 2008 (hence the incredibly generic name) and have hardly touched it since. The magic of open source I guess. Rather than blathering about the features, here’s some snippets:
var Color = net.brehaut.Color; // or
// var Color = require('./color').Color;
var Green = Color("#00FF00");
var Red = Color({hue: 0, saturation: 1, value: 1});
var Blue = Color("rgba(0,0,255,1)");
var Cyan = Color({hue: 180, saturation: 1, lightness: 0.5});
var Magenta = Color("hsl(300, 100%, 50%)");
var Yellow = Color([255,255,0]);
Red.toCSS() //=> "#FF0000"
Red.shiftHue(45)
.darkenByRatio(0.5)
.desaturateByAmount(0.1)
.toCSS(); //=> "#80630D"
The library supports most CSS string formats, object and array literals, immutable values, three color models (RGB, HSV, and HSL) and has a grab bag of operations on each.
Thanks to Matt Wilson, Tim Baumann, Simon Heimler, Aidan Hobson Sayers, and Michel Vielmetter for their contributions.