Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

color-space

colorjs1.2mMIT2.1.0TypeScript support: included

Collection of color space conversions

color, colour, rgb, hsl, hsv, lab, lch, luv, lch, cie, hsluv, husl, color-convert, gamut, color-conversions, color-space, color-translation, color-data, coloroid, cubehelix, munsell, hcg, hsp

readme

Color-space test stable npm size

Collection of color spaces conversions & data.

Demo.

Usage

import space from 'color-space';

//convert lab to lch
var result = space.lab.lch([80,50,60]);

Spaces can be imported separately:

import rgb from 'color-space/rgb.js';
import hsl from 'color-space/hsl.js';

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

API

<fromSpace>.<toSpace>(array);
<space>.name //space name
<space>.min //channel minimums
<space>.max //channel maximums
<space>.channel //channel names
<space>.alias //alias space names

Spaces

  • <input checked="" disabled="" type="checkbox"> RGB — additive color model based on red, green and blue primary colors.
  • <input checked="" disabled="" type="checkbox"> HSL — cylindrical-coordinates representation of RGB.
  • <input checked="" disabled="" type="checkbox"> HSV, HSB
  • <input checked="" disabled="" type="checkbox"> HWB
  • <input checked="" disabled="" type="checkbox"> HSI — used for computer vision due to better separation of shapes in an image, comparing to HSL/HSB.
  • <input checked="" disabled="" type="checkbox"> CMYK
  • <input checked="" disabled="" type="checkbox"> CMY
  • <input checked="" disabled="" type="checkbox"> XYZ
  • <input checked="" disabled="" type="checkbox"> XYY (YXY)
  • <input checked="" disabled="" type="checkbox"> LAB
  • <input checked="" disabled="" type="checkbox"> LCHab
  • <input checked="" disabled="" type="checkbox"> LUV
  • <input checked="" disabled="" type="checkbox"> LCHuv
  • <input checked="" disabled="" type="checkbox"> HSLuv
  • <input checked="" disabled="" type="checkbox"> HPLuv
  • <input checked="" disabled="" type="checkbox"> LABHunter
  • <input checked="" disabled="" type="checkbox"> YUV
  • <input checked="" disabled="" type="checkbox"> YIQ
  • <input checked="" disabled="" type="checkbox"> YCgCo
  • <input checked="" disabled="" type="checkbox"> YDbDr
  • <input checked="" disabled="" type="checkbox"> YPbPr
  • <input checked="" disabled="" type="checkbox"> YCbCr
  • <input checked="" disabled="" type="checkbox"> YcCbcCrc
  • <input checked="" disabled="" type="checkbox"> JPEG
  • <input checked="" disabled="" type="checkbox"> XvYCC
  • <input checked="" disabled="" type="checkbox"> UCS
  • <input checked="" disabled="" type="checkbox"> UVW
  • <input disabled="" type="checkbox"> Munsell
  • <input disabled="" type="checkbox"> NCS
  • <input disabled="" type="checkbox"> PMS
  • <input disabled="" type="checkbox"> RAL
  • <input checked="" disabled="" type="checkbox"> TSL – color space designed for face detection purpose.
  • <input disabled="" type="checkbox"> RG
  • <input disabled="" type="checkbox"> RGK
  • <input checked="" disabled="" type="checkbox"> Coloroid — color space for architects and visual constructors, Hungarian Standard MSZ 7300 since 2000.
  • <input disabled="" type="checkbox"> OSA-UCS — accurately reprsenting uniform color differences, developed by the Optical Society of America’s Committee on Uniform Color Scales.
  • <input disabled="" type="checkbox"> HKS
  • <input checked="" disabled="" type="checkbox"> LMS — represents sensitivity of the human eye to Long, Medium and Short wavelengths.
  • <input checked="" disabled="" type="checkbox"> Cubehelix — colormaps for data visualization.
  • <input disabled="" type="checkbox"> Gray
  • <input disabled="" type="checkbox"> CIECAM02
  • <input disabled="" type="checkbox"> US Federal Standard 595
  • <input disabled="" type="checkbox"> Toyo
  • <input disabled="" type="checkbox"> PhotoYCC
  • <input checked="" disabled="" type="checkbox"> HCG
  • <input disabled="" type="checkbox"> HCL
  • <input checked="" disabled="" type="checkbox"> HSP
  • <input disabled="" type="checkbox"> HCY
  • <input checked="" disabled="" type="checkbox"> YES — computationally effective color space for face recognition.
  • <input disabled="" type="checkbox"> British Standard Colour
  • <input disabled="" type="checkbox"> RG chromacity
  • <input disabled="" type="checkbox"> CIE DSH
  • <input disabled="" type="checkbox"> HSM

Contribute

Please fork, add color space with basic conversions to/from XYZ or RGB and tests. The goal of the project is the most complete set of color spaces with minimal uniform API.

Credits

Thanks to all scientists, who devoted their time to color research and conveyed their knowledge, for now we can use their formulas and code.

Alternatives

See also

  • color-api - color API proposal by Lea Verou