Skip to content
The missing color library
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
Makefile
README.md

README.md

Color.js: the missing color library

Color.js is a very thin abstraction around a color, with a few bells on.

Normal colors:

// normal colors
Color.white // => Color('ffffff')
Color.black // => Color('000000')
Color.red   // => Color('ff0000')

custom colors, with nifty query methods!

Color('00FF10').toString() // => "#00FF10"
Color('00FF10').red()      // => 0
Color('00FF10').green()    // => 255
Color('00FF10').blue()     // => 16
Color('00FF10').rgb()      // => [0, 255, 16]
Color.rgb(0, 255, 16)      // => Color('00FF10')

hsl conversion!

Color('112233').hue()  // => 149
Color('112233').sat()  // => 128
Color('112233').lum()  // => 34
Color('112233').hsl()  // => [149, 128, 34]
// NB: This conversion is pretty buggy, and the algo needs
// a look from someone who knows a thing or two about the hsl space.
Color.hsl(149, 128, 34) // => Color('112233')

TODO

  • fix the hsl->rgb algo
  • color transforms (e.g. myColor.lum(-20) returns a darker color)
You can’t perform that action at this time.