JSPM

@4bitlabs/color-space

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q40581F
  • License ISC

Utility functions for parsing, converting and mixing colors in sRGB, CIE-XYZ, CIE-L*a*b*, and okLab color spaces

Package Exports

  • @4bitlabs/color-space
  • @4bitlabs/color-space/lab
  • @4bitlabs/color-space/linear-rgb
  • @4bitlabs/color-space/oklab
  • @4bitlabs/color-space/srgb
  • @4bitlabs/color-space/xyz

Readme

@4bitlabs/color-space License NPM Version NPM Downloads

Utility functions for parsing, converting and mixing colors in sRGB, CIE-XYZ, CIE-L*a*b*, and okLab color spaces

Installing

$ npm install --save @4bitlabs/color-space

Documentation

Full documentation for the library can be found here.

Quick-start

import { sRGB, XYZ, Lab, okLab, linearRGB } from '@4bitlabs/color-space';

const srgbColor = sRGB.create(255, 128, 0);
const xyzColor = XYZ.create(50.39, 57.009, 86.941);
const labColor = Lab.create(50.593, -49.586, 45.015);
const oklabColor = okLab.create(0.8, 0.144, 0.083);
const linearRGBColor = linearRGB.create(0.5, 0.5, 0.5);

You can also import only the specific color-spaces you intend to work by using package exports:

import * as sRGB from '@4bitlabs/color-spaces/srgb';
import * as XYZ from '@4bitlabs/color-spaces/xyz';

const tomato = sRGB.fromHex('#ff6347');
const xyzTomato = sRGB.toXYZ(tomato);
const xyzString = XYZ.toString(xyzTomato);