JSPM

  • Created
  • Published
  • Downloads 410684
  • Score
    100M100P100Q214382F

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

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

Use browserify to use in browser.

To include all spaces at once:

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

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

To include one target space:

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

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

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:

  • rgb
  • hsl
  • hsv (hsb)
  • hwb
  • cmyk
  • xyz (ciexyz)
  • lab (cielab)
  • luv (cieluv)
  • lch (cielch)

To see details console.log(space).

Contribute

Please fork, add conversions, figure out color profile stuff for XYZ, LAB, etc. This is meant to be a basic library that can be used by other libraries to wrap color calculations in some cool way.