@4bitlabs/color-space
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@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);

Package Sidebar

Install

npm i @4bitlabs/color-space

Weekly Downloads

1

Version

2.0.0

License

ISC

Unpacked Size

102 kB

Total Files

107

Last publish

Collaborators

  • 32bitkid