@zokugun/lang.color.cie

0.3.0 • Public • Published

@zokugun/lang.color.cie

kaoscript License NPM Version Dependency Status Build Status CircleCI Coverage Status

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(): Number
  • luma(Number): Color
  • x(): Number
  • x(Number): Color
  • z(): Number
  • z(Number): Color
  • illuminant(): String or Array
  • illuminant(String|Array, String:method): Color
  • observer(): Number
  • observer(Number, String:method): Color

CIEYxy

  • luma(): Number
  • luma(Number): Color
  • x(): Number
  • x(Number): Color
  • y(): Number
  • y(Number): Color

CIELab

  • luma(): Number
  • luma(Number): Color
  • astar(): Number
  • astar(Number): Color
  • bstar(): Number
  • bstar(Number): Color

CIELuv

  • luma(): Number
  • luma(Number): Color
  • ustar(): Number
  • ustar(Number): Color
  • vstar(): Number
  • vstar(Number): Color

CIELCH(ab)

  • luma(): Number
  • luma(Number): Color
  • chroma(): Number
  • chroma(Number): Color
  • hue(): Number
  • hue(Number): Color

CIELCH(uv)

  • luma(): Number
  • luma(Number): Color
  • chroma(): Number
  • chroma(Number): Color
  • hue(): Number
  • hue(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.

Name 2° Observer 10° Observer Note
X Y Z X Y Z
A 109.85 100 35.585 111.144 100 35.2 Incandescent / Tungsten
B 99.072 100 85.223 99.1778 100 35.2 Direct sunlight at noon (Deprecated)
C 98.074 100 118.232 97.285 100 116.145 Average / North sky Daylight (Deprecated)
D50 96.422 100 82.521 96.72 100 81.427 Horizon Light
D55 95.682 100 92.149 95.799 100 90.923 Mid-morning / Mid-afternoon Daylight
D65 95.047 100 108.883 94.811 100 107.304 Noon Daylight
D75 94.972 100 122.638 94.416 100 120.641 North sky Daylight
E 100 100 100 100 100 100 Equal energy
F1 94.8788 100 108.1515 94.7913 100 103.1914 Daylight Fluorescent
F2 99.186 100 67.393 103.279 100 69.027 Cool White Fluorescent
F3 103.7535 100 49.8605 108.9683 100 51.9648 White Fluorescent
F4 109.1473 100 38.8133 114.9614 100 40.9633 Warm White Fluorescent
F5 90.872 100 98.7229 93.3686 100 98.6363 Daylight Fluorescent
F6 97.3091 100 60.1905 102.1481 100 62.0736 Lite White Fluorescent
F7 95.041 100 108.747 95.792 100 107.686 D65 simulator, Daylight simulator
F8 96.4125 100 82.3331 97.1146 100 81.1347 D50 simulator, Sylvania F40 Design 50
F9 100.3648 100 67.8684 102.1163 100 67.8256 Cool White Deluxe Fluorescent
F10 96.1735 100 81.7123 99.0012 100 83.134 Philips TL85, Ultralume 50
F11 100.962 100 64.350 103.863 100 65.607 Philips TL84, Ultralume 40
F12 108.0463 100 39.2275 111.4284 100 40.353 Philips TL83, Ultralume 30

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

Package Sidebar

Install

npm i @zokugun/lang.color.cie

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

39.7 kB

Total Files

11

Last publish

Collaborators

  • daiyam