JSPM

  • Created
  • Published
  • Downloads 419001
  • Score
    100M100P100Q219967F

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/lchab
  • 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

NPM

Math and data behind color spaces and color conversions. Color-space provides a uniform interface to the following color spaces: RGB, HSl, HSV (HSB), HWB, CMYK, CMY, XYZ, XYY (YXY), LAB, LCHab, LUV, LCHuv, HuSL, HuSLp, LABHunter, LMS.

Converter & tests

Use

In browser:

Attach color-space.js and use global colorSpace object:

<script src="js/color-space.js"></script>
var rgb = colorSpace.rgb;

//convert rgb to hsl
rgb.hsl([255,0,0]);

Also you can use browserify to get your own build.

In node:

$ npm install color-space

Include all spaces:

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

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

Include only needed spaces (to get a subset or to shrink final size):

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

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

API

Convert one space to another:

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

colorSpace[fromSpace][toSpace](array);

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
xyz.whitepoint //list of whitepoint references
lms.transform //list of transform matrices

For other details see source code or console.log(space).

Contribute

Please fork, add color space with basic conversions (to/from XYZ or RGB), tests. Color-space is supposed to be a basic library to work with color conversions, an enhanced replacement for color-convert.