JSPM

  • Created
  • Published
  • Downloads 434514
  • Score
    100M100P100Q220639F

Math & data behind color spaces and color conversions.

Package Exports

  • color-space
  • color-space/cmyk
  • color-space/hsl
  • color-space/hsv
  • color-space/lab
  • color-space/rgb
  • color-space/xyz
  • color-space/yuv

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 (color-space) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

color-space Build Status

Math and data behind color spaces and color conversions. Converter & tests.

NPM

Use

$ npm install color-space

To include all spaces:

var spaces = require('color-space');

//convert lab to lch
spaces.lab.lch([80,50,60]);

If you aware of size, you can include only needed spaces:

var rgb = require('color-space/rgb');
var hsl = require('color-space/hsl');

//convert rgb to hsl
rgb.hsl([200,230,100]);

Use browserify to use in a browser.

API

Convert from one space to another:

var fromSpace = 'rgb', toSpace = 'hsl';

spaces[fromSpace][toSpace](array);

Get space data:

space.name //space name
space.min //channel minimums
space.max //channel maximums
space.channel //channel names
space.alias //alias space names, if any
space.illuminant //space-specific properties

Available spaces:

To see details console.log(space).

Contribute

Please fork, add color spaces/convertions. If you add a new space, make sure you have implemented at least to/from XYZ or to/from RGB conversion functions. Don’t forget to add a test-case.

This is meant to be a basic library that can be used by other libraries to wrap color calculations in some cool way.