@zokugun/lang.color.cie
v0.3.0
Published
Add CIELAB, CIELUV, CIELCh, CIEXYZ, CIEYxy spaces to Color class
Downloads
7
Maintainers
Readme
@zokugun/lang.color.cie
Provides CIELAB, CIELUV, CIELCh, CIEXYZ, CIEYxy spaces.
Getting Started
With node previously installed:
npm install @zokugun/lang.color.cie
Use it with JavaScript
:
require('kaoscript/register');
const { Color, Space } = require('@zokugun/lang.color.cie')();
const c = new Color('ciexyz(11.2933, 11.0002, 12.8373)');
Use it with kaoscript
:
import '@zokugun/lang.color.cie'
const c = new Color('ciexyz(11.2933, 11.0002, 12.8373)')
Properties
A color is defined in a color space. If you try to access it into another space, the color will be automatically converted into the new space.
CIEXYZ
luma()
: Numberluma(Number)
: Colorx()
: Numberx(Number)
: Colorz()
: Numberz(Number)
: Colorilluminant()
: String or Arrayilluminant(String|Array, String:method)
: Colorobserver()
: Numberobserver(Number, String:method)
: Color
CIEYxy
luma()
: Numberluma(Number)
: Colorx()
: Numberx(Number)
: Colory()
: Numbery(Number)
: Color
CIELab
luma()
: Numberluma(Number)
: Colorastar()
: Numberastar(Number)
: Colorbstar()
: Numberbstar(Number)
: Color
CIELuv
luma()
: Numberluma(Number)
: Colorustar()
: Numberustar(Number)
: Colorvstar()
: Numbervstar(Number)
: Color
CIELCH(ab)
luma()
: Numberluma(Number)
: Colorchroma()
: Numberchroma(Number)
: Colorhue()
: Numberhue(Number)
: Color
CIELCH(uv)
luma()
: Numberluma(Number)
: Colorchroma()
: Numberchroma(Number)
: Colorhue()
: Numberhue(Number)
: Color
Illuminants & Observers
The CIE 1931 2° Standard Observer and the CIE 1964 10° Standard Observer are supported for the standard illuminants.
On a color with non-standard illuminant, changing the observer won't change the coordinates of the color. But changing the illuminant, will always change the coordinates of the color.
SRGB is converted from/to CIEXYZ with the Standard Illuminant D65 and the 2° Standard Observer.
Syntax
const c = new Color('ciexyz(11.2933, 11.0002, 12.8373, D65)')
expect(c.format('cielch(uv)')).to.equal('cielch(uv)(39.5808, 7.4685, 329.1097, D65, 2)')
CIEXYZ
ciexyz(x, luma|Y, z, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
x: from 0 to 127, up to 4 decimal places
z: from 0 to 127, up to 4 decimal places
ciexyz(11.2933, 11.0002, 12.8373)
ciexyz(11.2933, 11.0002, 12.8373, D65, 2)
ciexyza(x, luma|Y, z, alpha, illuminant?, observer?)
ciexyza(11.2933, 11.0002, 12.8373, 0.7)
ciexyza(11.2933, 11.0002, 12.8373, 0.7, D65, 2)
CIEYxy
cieyxy(luma|Y, x, y, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
x: from 0 to 100, up to 4 decimal places
y: from 0 to 100, up to 4 decimal places
cieyxy(11.0002, 32.1464, 31.3121)
cieyxy(11.0002, 32.1464, 31.3121, D65, 2)
cieyxya(luma|Y, x, y, alpha, illuminant?, observer?)
cieyxya(11.0002, 32.1464, 31.3121, 0.7)
cieyxya(11.0002, 32.1464, 31.3121, 0.7, D65, 2)
CIELab
cielab(luma, a, b, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
a: from -128 to 127, up to 4 decimal places
y: from -128 to 127, up to 4 decimal places
cielab(39.5808, 6.2364, -2.2407)
cielab(39.5808, 6.2364, -2.2407, D65, 2)
cielaba(luma, a, b, alpah, illuminant?, observer?)
cielaba(39.5808, 6.2364, -2.2407, 0.7)
cielaba(39.5808, 6.2364, -2.2407, 0.7, D65, 2)
CIELuv
cieluv(luma, u, v, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
u: from -128 to 127, up to 4 decimal places
v: from -128 to 127, up to 4 decimal places
cieluv(39.5808, 6.4091, -3.8343)
cieluv(39.5808, 6.4091, -3.8343, D65, 2)
cieluva(luma, u, v, alpha, illuminant?, observer?)
cieluv(39.5808, 6.4091, -3.8343, 0.7)
cieluv(39.5808, 6.4091, -3.8343, 0.7, D65, 2)
CIELCH(ab)
cielch(ab)(luma, chroma, hue, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
chroma: from 0 to 100, up to 4 decimal places
hue: from 0 to 359.9999, up to 4 decimal places
cielch(ab)(39.5808, 6.6267, 340.237)
cielch(ab)(39.5808, 6.6267, 340.237, D65, 2)
cielcha(ab)(luma, chroma, hue, alpha, illuminant?, observer?)
cielcha(ab)(39.5808, 6.6267, 340.237, 0.7)
cielcha(ab)(39.5808, 6.6267, 340.237, 0.7, D65, 2)
CIELCH(uv)
cielch(uv)(luma, chroma, hue, illuminant?, observer?)
luma: from 0 to 100, up to 4 decimal places
chroma: from 0 to 100, up to 4 decimal places
hue: from 0 to 359.9999, up to 4 decimal places
cielch(uv)(39.5808, 7.4685, 329.1097)
cielch(uv)(39.5808, 7.4685, 329.1097, D65, 2)
cielcha(uv)(luma, chroma, hue, alpha, illuminant?, observer?)
cielcha(uv)(39.5808, 7.4685, 329.1097, 0.7)
cielcha(uv)(39.5808, 7.4685, 329.1097, 0.7, D65, 2)
License
MIT © Baptiste Augrain