diff --git a/CHANGELOG.md b/CHANGELOG.md index 034d7ce..3f52a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines. +# [2.2.0](https://github.com/pex-gl/pex-color/compare/v2.1.1...v2.2.0) (2024-10-08) + + +### Bug Fixes + +* handle okhsl/okhsv lightness and saturation epsilon (ie. achromatic and close to white edge cases) ([5c39853](https://github.com/pex-gl/pex-color/commit/5c39853e3a3ee5654f544668b34b0a187f97ff84)) + + +### Features + +* add lch/oklch ([0e0e437](https://github.com/pex-gl/pex-color/commit/0e0e437ca5fb9961a87f1d0a38ca0fbbf73d2150)) +* add P3 ([386302a](https://github.com/pex-gl/pex-color/commit/386302a828704bcad8ec79b4f7364f6d4ddf1f1a)) +* add XYZ D50 and split with D65 + split lab50/65 ([0cdc911](https://github.com/pex-gl/pex-color/commit/0cdc911fb397e65bb5eb1648f36aa365d116f83e)) +* update css ([8aec1bf](https://github.com/pex-gl/pex-color/commit/8aec1bf2f845cc36b5b5f7aaed2970c647ea508a)) + + +### Performance Improvements + +* GC enhancement ([e9a79e3](https://github.com/pex-gl/pex-color/commit/e9a79e3320f577e1d3b5578ba26dc15b859705eb)) +* optimise ok methods ([5985cd9](https://github.com/pex-gl/pex-color/commit/5985cd9e4a19de3b0da200ca5907c5cea221e208)) + + + ## [2.1.1](https://github.com/pex-gl/pex-color/compare/v2.1.0...v2.1.1) (2024-07-09) diff --git a/README.md b/README.md index 40f75af..9062e8f 100755 --- a/README.md +++ b/README.md @@ -118,10 +118,14 @@ API naming follows the following rules:
All components in the range 0 <= x <= 1
Array.<number>
CIELAB with D65 standard illuminant as default.
+CIELAB perceptual Lightness, a* red/green, b* blue/yellow.
Components range (D65): 0 <= l <= 1; -0.86183 <= a <= 0.98234; -1.0786 <= b <= 0.94478;
Components range (D50): 0 <= l <= 1; -0.79287 <= a <= 0.9355; -1.12029 <= b <= 0.93388;
Array.<number>
CIELCh Luminance Chroma Hue. Cylindrical form of Lab.
+All components in the range 0 <= x <= 1
+Array.<number>
CIELChuv Luminance Chroma Hue.
All components in the range 0 <= x <= 1
@@ -140,8 +144,16 @@ API naming follows the following rules:Cartesian form using D65 standard illuminant.
Components range: 0 <= l <= 1; -0.233 <= a <= 0.276; -0.311 <= b <= 0.198;
Array.<number>
Cylindrical form using D65 standard illuminant.
+All components in the range 0 <= x <= 1
+Array.<number>
r, g, b values (DCI-P3 color gamut, D65 whitepoint, sRGB gamma curve).
+All components in the range 0 <= x <= 1
+Array.<number>
CIE XYZ using D65 standard illuminant.
+CIE XYZ.
Components range: 0 <= x <= 0.95; 0 <= y <= 1; 0 <= z <= 1.08;
color
](#color)
- [.fromValues(color, r, g, b, [a])](#module_pex-color.fromValues) ⇒ [color
](#color)
- [.toCSSRGB(color, [precision])](#module_pex-color.toCSSRGB) ⇒ [css
](#css)
+ - [.toCSSRGBLinear(color, [precision])](#module_pex-color.toCSSRGBLinear) ⇒ [css
](#css)
+ - [.toCSSRGBLinear(color, [precision])](#module_pex-color.toCSSRGBLinear) ⇒ [css
](#css)
- [.toCSSHSL(color, [precision])](#module_pex-color.toCSSHSL) ⇒ [css
](#css)
+ - [.toCSSHWB(color, [precision])](#module_pex-color.toCSSHWB) ⇒ [css
](#css)
+ - [.toCSSLab(color, [precision])](#module_pex-color.toCSSLab) ⇒ [css
](#css)
- [.toCSSLab(color, [precision])](#module_pex-color.toCSSLab) ⇒ [css
](#css)
- [.toCSSLCH(color, [precision])](#module_pex-color.toCSSLCH) ⇒ [css
](#css)
- - [.toCSSHWB(color, [precision])](#module_pex-color.toCSSHWB) ⇒ [css
](#css)
+ - [.toCSSOkLab(color, [precision])](#module_pex-color.toCSSOkLab) ⇒ [css
](#css)
+ - [.toCSSOklch(color, [precision])](#module_pex-color.toCSSOklch) ⇒ [css
](#css)
+ - [.toCSSXYZD50(color, [precision])](#module_pex-color.toCSSXYZD50) ⇒ [css
](#css)
+ - [.toCSSXYZ(color, [precision])](#module_pex-color.toCSSXYZ) ⇒ [css
](#css)
- [.fromHex(color, hex)](#module_pex-color.fromHex) ⇒ [color
](#color)
- [.toHex(color, alpha)](#module_pex-color.toHex) ⇒ [hex
](#hex)
- [.fromHPLuv(color, h, s, l, [a])](#module_pex-color.fromHPLuv) ⇒ [color
](#color)
@@ -174,8 +193,12 @@ API naming follows the following rules:
- [.toHSV(color, out)](#module_pex-color.toHSV) ⇒ [hsv
](#hsv)
- [.fromHWB(color, h, w, b, [a])](#module_pex-color.fromHWB) ⇒ [color
](#color)
- [.toHWB(color, out)](#module_pex-color.toHWB) ⇒ [hwb
](#hwb)
- - [.fromLab(color, l, a, b, α, illuminant)](#module_pex-color.fromLab) ⇒ [color
](#color)
- - [.toLab(color, out, illuminant)](#module_pex-color.toLab) ⇒ [lab
](#lab)
+ - [.fromLabD50(color, l, a, b, α)](#module_pex-color.fromLabD50) ⇒ [color
](#color)
+ - [.toLabD50(color, out)](#module_pex-color.toLabD50) ⇒ [lab
](#lab)
+ - [.fromLabD65(color, l, a, b, α)](#module_pex-color.fromLabD65) ⇒ [color
](#color)
+ - [.toLabD65(color, out)](#module_pex-color.toLabD65) ⇒ [lab
](#lab)
+ - [.fromLCH(color, l, c, h, [a])](#module_pex-color.fromLCH) ⇒ [color
](#color)
+ - [.toLCH(color, out)](#module_pex-color.toLCH) ⇒ [lch
](#lch)
- [.fromLCHuv(color, l, c, h, [a])](#module_pex-color.fromLCHuv) ⇒ [color
](#color)
- [.toLCHuv(color, out)](#module_pex-color.toLCHuv) ⇒ [lchuv
](#lchuv)
- [.fromLinear(color, r, g, b, [a])](#module_pex-color.fromLinear) ⇒ [color
](#color)
@@ -186,8 +209,14 @@ API naming follows the following rules:
- [.toOkhsv(color, out)](#module_pex-color.toOkhsv) ⇒ [okhsv
](#okhsv)
- [.fromOklab(color, L, a, b, [α])](#module_pex-color.fromOklab) ⇒ [color
](#color)
- [.toOklab(color, out)](#module_pex-color.toOklab) ⇒ [oklab
](#oklab)
- - [.fromXYZ(color, x, y, z, a)](#module_pex-color.fromXYZ) ⇒ [color
](#color)
- - [.toXYZ(color, out)](#module_pex-color.toXYZ) ⇒ [xyz
](#xyz)
+ - [.fromOklch(color, l, c, h, [a])](#module_pex-color.fromOklch) ⇒ [color
](#color)
+ - [.toOklch(color, out)](#module_pex-color.toOklch) ⇒ [oklch
](#oklch)
+ - [.fromP3(color, r, g, b, a)](#module_pex-color.fromP3) ⇒ [color
](#color)
+ - [.toP3(color, out)](#module_pex-color.toP3) ⇒ [p3
](#p3)
+ - [.fromXYZD50(color, x, y, z, a)](#module_pex-color.fromXYZD50) ⇒ [color
](#color)
+ - [.toXYZD50(color, out)](#module_pex-color.toXYZD50) ⇒ [xyz
](#xyz)
+ - [.fromXYZD65(color, x, y, z, a)](#module_pex-color.fromXYZD65) ⇒ [color
](#color)
+ - [.toXYZD65(color, out)](#module_pex-color.toXYZD65) ⇒ [xyz
](#xyz)
@@ -278,6 +307,35 @@ Updates a color based on r, g, b, [a] values.
Returns a rgb CSS string representation of a given color.
**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSRGBLinear(color, [precision]) ⇒ [css
](#css)
+
+Returns a linear rgb CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSRGBLinear(color, [precision]) ⇒ [css
](#css)
+
+Returns a P3 rgb CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color)
| Param | Type | Default |
| ----------- | ---------------------------- | -------------- |
@@ -291,6 +349,35 @@ Returns a rgb CSS string representation of a given color.
Returns a hsl CSS string representation of a given color.
**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSHWB(color, [precision]) ⇒ [css
](#css)
+
+Returns a hwb CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hwb)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSLab(color, [precision]) ⇒ [css
](#css)
+
+Returns a lab CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lab)
| Param | Type | Default |
| ----------- | ---------------------------- | -------------- |
@@ -317,17 +404,57 @@ Returns a lab CSS string representation of a given color.
Returns a lch CSS string representation of a given color.
**Kind**: static method of [pex-color
](#module_pex-color)
+**See**: [https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/lch)
| Param | Type | Default |
| ----------- | ---------------------------- | -------------- |
| color | [color
](#color) | |
| [precision] | number
| 5
|
-
+
-### pex-color.toCSSHWB(color, [precision]) ⇒ [css
](#css)
+### pex-color.toCSSOkLab(color, [precision]) ⇒ [css
](#css)
-Returns a hwb CSS string representation of a given color.
+Returns a lab CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSOklch(color, [precision]) ⇒ [css
](#css)
+
+Returns a lch CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSXYZD50(color, [precision]) ⇒ [css
](#css)
+
+Returns a xyz-d50 CSS string representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type | Default |
+| ----------- | ---------------------------- | -------------- |
+| color | [color
](#color) | |
+| [precision] | number
| 5
|
+
+
+
+### pex-color.toCSSXYZ(color, [precision]) ⇒ [css
](#css)
+
+Returns a xyz (xyz-d65) CSS string representation of a given color.
**Kind**: static method of [pex-color
](#module_pex-color)
@@ -507,36 +634,92 @@ Returns a HWB representation of a given color.
| color | [color
](#color) |
| out | Array
|
-
+
+
+### pex-color.fromLabD50(color, l, a, b, α) ⇒ [color
](#color)
+
+Updates a color based on Lab values and alpha using D50 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| l | number
|
+| a | number
|
+| b | number
|
+| α | number
|
+
+
+
+### pex-color.toLabD50(color, out) ⇒ [lab
](#lab)
+
+Returns a Lab representation of a given color using D50 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
+
+
+
+### pex-color.fromLabD65(color, l, a, b, α) ⇒ [color
](#color)
+
+Updates a color based on Lab values and alpha using D65 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| l | number
|
+| a | number
|
+| b | number
|
+| α | number
|
+
+
+
+### pex-color.toLabD65(color, out) ⇒ [lab
](#lab)
+
+Returns a Lab representation of a given color using D65 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
+
+
-### pex-color.fromLab(color, l, a, b, α, illuminant) ⇒ [color
](#color)
+### pex-color.fromLCH(color, l, c, h, [a]) ⇒ [color
](#color)
-Updates a color based on Lab values and alpha.
+Updates a color based on LCH values and alpha.
**Kind**: static method of [pex-color
](#module_pex-color)
-| Param | Type |
-| ---------- | ---------------------------- |
-| color | [color
](#color) |
-| l | number
|
-| a | number
|
-| b | number
|
-| α | number
|
-| illuminant | Array
|
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| l | number
|
+| c | number
|
+| h | number
|
+| [a] | number
|
-
+
-### pex-color.toLab(color, out, illuminant) ⇒ [lab
](#lab)
+### pex-color.toLCH(color, out) ⇒ [lch
](#lch)
-Returns a Lab representation of a given color.
+Returns a LCH representation of a given color.
**Kind**: static method of [pex-color
](#module_pex-color)
-| Param | Type |
-| ---------- | ---------------------------- |
-| color | [color
](#color) |
-| out | Array
|
-| illuminant | Array
|
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
@@ -683,11 +866,98 @@ Returns an Oklab representation of a given color.
| color | [color
](#color) |
| out | Array
|
-
+
+
+### pex-color.fromOklch(color, l, c, h, [a]) ⇒ [color
](#color)
+
+Updates a color based on Oklch values and alpha.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| l | number
|
+| c | number
|
+| h | number
|
+| [a] | number
|
+
+
+
+### pex-color.toOklch(color, out) ⇒ [oklch
](#oklch)
+
+Returns an Oklch representation of a given color.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
+
+
-### pex-color.fromXYZ(color, x, y, z, a) ⇒ [color
](#color)
+### pex-color.fromP3(color, r, g, b, a) ⇒ [color
](#color)
-Updates a color based on XYZ values and alpha.
+Updates a color based on P3 values and alpha using D65 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| r | number
|
+| g | number
|
+| b | number
|
+| a | number
|
+
+
+
+### pex-color.toP3(color, out) ⇒ [p3
](#p3)
+
+Returns a P3 representation of a given color using D65 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
+
+
+
+### pex-color.fromXYZD50(color, x, y, z, a) ⇒ [color
](#color)
+
+Updates a color based on XYZ values and alpha using D50 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| x | number
|
+| y | number
|
+| z | number
|
+| a | number
|
+
+
+
+### pex-color.toXYZD50(color, out) ⇒ [xyz
](#xyz)
+
+Returns a XYZ representation of a given color using D50 standard illuminant.
+
+**Kind**: static method of [pex-color
](#module_pex-color)
+
+| Param | Type |
+| ----- | ---------------------------- |
+| color | [color
](#color) |
+| out | Array
|
+
+
+
+### pex-color.fromXYZD65(color, x, y, z, a) ⇒ [color
](#color)
+
+Updates a color based on XYZ values and alpha using D65 standard illuminant.
**Kind**: static method of [pex-color
](#module_pex-color)
@@ -699,11 +969,11 @@ Updates a color based on XYZ values and alpha.
| z | number
|
| a | number
|
-
+
-### pex-color.toXYZ(color, out) ⇒ [xyz
](#xyz)
+### pex-color.toXYZD65(color, out) ⇒ [xyz
](#xyz)
-Returns a XYZ representation of a given color.
+Returns a XYZ representation of a given color using D65 standard illuminant.
**Kind**: static method of [pex-color
](#module_pex-color)
@@ -717,16 +987,47 @@ Returns a XYZ representation of a given color.
## utils
- [utils](#module_utils)
- - [.linearToSrgb](#module_utils.linearToSrgb) ⇒ number
- - [.srgbToLinear](#module_utils.srgbToLinear) ⇒ number
+ - [.D65](#module_utils.D65)
+ - [.D50](#module_utils.D50)
+ - [.linearToSrgb(c)](#module_utils.linearToSrgb) ⇒ number
+ - [.srgbToLinear(c)](#module_utils.srgbToLinear) ⇒ number
+ - [.linearToRgb(lr, lg, lb, out)](#module_utils.linearToRgb) ⇒ [color
](#color)
+ - [.rgbToLinear(r, g, b, out)](#module_utils.rgbToLinear) ⇒ [linear
](#linear)
+ - [.xyzD65ToLinear(x, y, z, out)](#module_utils.xyzD65ToLinear) ⇒ [linear
](#linear)
+ - [.linearToXyzD65(lr, lg, lb, out)](#module_utils.linearToXyzD65) ⇒ [xyz
](#xyz)
+ - [.xyzD50ToLinear(x, y, z, out)](#module_utils.xyzD50ToLinear) ⇒ [linear
](#linear)
+ - [.linearToXyzD50(lr, lg, lb, out)](#module_utils.linearToXyzD50) ⇒ [xyz
](#xyz)
+ - [.linearP3ToXyzD65(lr, lg, lb, out)](#module_utils.linearP3ToXyzD65) ⇒ [xyz
](#xyz)
+ - [.xyzD65ToLinearP3(x, y, z, out)](#module_utils.xyzD65ToLinearP3) ⇒ Array
+ - [.lchToLab(l, c, h, out)](#module_utils.lchToLab) ⇒ [lab
](#lab)
+ - [.labToLch(l, a, b, out)](#module_utils.labToLch) ⇒ [lch
](#lch)
+ - [.labToXyz(l, a, b, out, illuminant)](#module_utils.labToXyz) ⇒ [xyz
](#xyz)
+ - [.xyzToLab(x, y, z, out, illuminant)](#module_utils.xyzToLab) ⇒ [lab
](#lab)
+ - [.oklabToLinear(L, a, b, out)](#module_utils.oklabToLinear) ⇒ [linear
](#linear)
+ - [.linearToOklab(lr, lg, lb, out)](#module_utils.linearToOklab) ⇒ [oklab
](#oklab)
+
+
+
+### utils.D65
+
+Illuminant D65: x,y,z tristimulus values
+
+**Kind**: static constant of [utils
](#module_utils)
+**See**: [https://en.wikipedia.org/wiki/Standard_illuminant#White_points_of_standard_illuminants](https://en.wikipedia.org/wiki/Standard_illuminant#White_points_of_standard_illuminants)
+
+### utils.D50
+
+Illuminant D50: x,y,z tristimulus values
+
+**Kind**: static constant of [utils
](#module_utils)
-### utils.linearToSrgb ⇒ number
+### utils.linearToSrgb(c) ⇒ number
Convert component from linear value
-**Kind**: static constant of [utils
](#module_utils)
+**Kind**: static method of [utils
](#module_utils)
| Param | Type |
| ----- | ------------------- |
@@ -734,16 +1035,229 @@ Convert component from linear value
-### utils.srgbToLinear ⇒ number
+### utils.srgbToLinear(c) ⇒ number
Convert component to linear value
-**Kind**: static constant of [utils
](#module_utils)
+**Kind**: static method of [utils
](#module_utils)
| Param | Type |
| ----- | ------------------- |
| c | number
|
+
+
+### utils.linearToRgb(lr, lg, lb, out) ⇒ [color
](#color)
+
+Return a RGB representation from Linear values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| lr | number
|
+| lg | number
|
+| lb | number
|
+| out | Array
|
+
+
+
+### utils.rgbToLinear(r, g, b, out) ⇒ [linear
](#linear)
+
+Return a Linear representation from RGB values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| r | number
|
+| g | number
|
+| b | number
|
+| out | Array
|
+
+
+
+### utils.xyzD65ToLinear(x, y, z, out) ⇒ [linear
](#linear)
+
+Return a Linear representation from XYZ values with D65 illuminant.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| x | number
|
+| y | number
|
+| z | number
|
+| out | Array
|
+
+
+
+### utils.linearToXyzD65(lr, lg, lb, out) ⇒ [xyz
](#xyz)
+
+Return a XYZ representation with D65 illuminant from Linear values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| lr | number
|
+| lg | number
|
+| lb | number
|
+| out | Array
|
+
+
+
+### utils.xyzD50ToLinear(x, y, z, out) ⇒ [linear
](#linear)
+
+Return a Linear representation from XYZ values with D50 illuminant.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| x | number
|
+| y | number
|
+| z | number
|
+| out | Array
|
+
+
+
+### utils.linearToXyzD50(lr, lg, lb, out) ⇒ [xyz
](#xyz)
+
+Return a XYZ representation with D50 illuminant from Linear values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| lr | number
|
+| lg | number
|
+| lb | number
|
+| out | Array
|
+
+
+
+### utils.linearP3ToXyzD65(lr, lg, lb, out) ⇒ [xyz
](#xyz)
+
+Return a XYZ representation with D65 illuminant from Linear P3 values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| lr | number
|
+| lg | number
|
+| lb | number
|
+| out | Array
|
+
+
+
+### utils.xyzD65ToLinearP3(x, y, z, out) ⇒ Array
+
+Return a Linear P3 representation from XYZ values with D65 illuminant.
+
+**Kind**: static method of [utils
](#module_utils)
+**Returns**: Array
- P3 Linear
+
+| Param | Type |
+| ----- | ------------------- |
+| x | number
|
+| y | number
|
+| z | number
|
+| out | Array
|
+
+
+
+### utils.lchToLab(l, c, h, out) ⇒ [lab
](#lab)
+
+Return a Lab representation from LCH values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| l | number
|
+| c | number
|
+| h | number
|
+| out | Array
|
+
+
+
+### utils.labToLch(l, a, b, out) ⇒ [lch
](#lch)
+
+Return a Lch representation from Lab values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| l | number
|
+| a | number
|
+| b | number
|
+| out | Array
|
+
+
+
+### utils.labToXyz(l, a, b, out, illuminant) ⇒ [xyz
](#xyz)
+
+Return a XYZ representation from Lab values with provided illuminant.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ---------- | ------------------- |
+| l | number
|
+| a | number
|
+| b | number
|
+| out | Array
|
+| illuminant | Array
|
+
+
+
+### utils.xyzToLab(x, y, z, out, illuminant) ⇒ [lab
](#lab)
+
+Return a lab representation from XYZ values with provided illuminant.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ---------- | ------------------- |
+| x | number
|
+| y | number
|
+| z | number
|
+| out | Array
|
+| illuminant | Array
|
+
+
+
+### utils.oklabToLinear(L, a, b, out) ⇒ [linear
](#linear)
+
+Return a Linear representation from Oklab values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| L | number
|
+| a | number
|
+| b | number
|
+| out | Array
|
+
+
+
+### utils.linearToOklab(lr, lg, lb, out) ⇒ [oklab
](#oklab)
+
+Return a Oklab representation from Linear values.
+
+**Kind**: static method of [utils
](#module_utils)
+
+| Param | Type |
+| ----- | ------------------- |
+| lr | number
|
+| lg | number
|
+| lb | number
|
+| out | Array
|
+
## bytes : Array.<number>
@@ -830,7 +1344,7 @@ All components in the range 0 <= x <= 1
## lab : Array.<number>
-CIELAB with D65 standard illuminant as default.
+CIELAB perceptual Lightness, a* red/green, b* blue/yellow.
Components range (D65): 0 <= l <= 1; -0.86183 <= a <= 0.98234; -1.0786 <= b <= 0.94478;
@@ -838,6 +1352,16 @@ Components range (D50): 0 <= l <= 1; -0.79287 <= a <= 0.9355; -1.12029 <= b <= 0
**Kind**: global typedef
**See**: [https://en.wikipedia.org/wiki/CIELAB_color_space](https://en.wikipedia.org/wiki/CIELAB_color_space)
+
+
+## lch : Array.<number>
+
+CIELCh Luminance Chroma Hue. Cylindrical form of Lab.
+
+All components in the range 0 <= x <= 1
+
+**Kind**: global typedef
+**See**: [https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model](https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model)
## lchuv : Array.<number>
@@ -865,7 +1389,7 @@ All components in the range 0 <= x <= 1
All components in the range 0 <= x <= 1
**Kind**: global typedef
-**See**: [https://bottosson.github.io/posts/colorpicker/#hsv-2](https://bottosson.github.io/posts/colorpicker/#hsv-2)
+**See**: [https://bottosson.github.io/posts/colorpicker/#hsl-2](https://bottosson.github.io/posts/colorpicker/#hsl-2)
## okhsv : Array.<number>
@@ -884,11 +1408,31 @@ Components range: 0 <= l <= 1; -0.233 <= a <= 0.276; -0.311 <= b <= 0.198;
**Kind**: global typedef
**See**: [https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab](https://bottosson.github.io/posts/oklab/#converting-from-linear-srgb-to-oklab)
+
+
+## oklch : Array.<number>
+
+Cylindrical form using D65 standard illuminant.
+
+All components in the range 0 <= x <= 1
+
+**Kind**: global typedef
+**See**: [https://drafts.csswg.org/css-color/#color-conversion-code](https://drafts.csswg.org/css-color/#color-conversion-code)
+
+
+## p3 : Array.<number>
+
+r, g, b values (DCI-P3 color gamut, D65 whitepoint, sRGB gamma curve).
+
+All components in the range 0 <= x <= 1
+
+**Kind**: global typedef
+**See**: [https://drafts.csswg.org/css-color/#color-conversion-code](https://drafts.csswg.org/css-color/#color-conversion-code)
## xyz : Array.<number>
-CIE XYZ using D65 standard illuminant.
+CIE XYZ.
Components range: 0 <= x <= 0.95; 0 <= y <= 1; 0 <= z <= 1.08;
diff --git a/package-lock.json b/package-lock.json
index 4111d73..6f4b347 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "pex-color",
- "version": "2.1.1",
+ "version": "2.2.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "pex-color",
- "version": "2.1.1",
+ "version": "2.2.0",
"license": "MIT",
"devDependencies": {
"colorjs.io": "github:color-js/color.js"
diff --git a/package.json b/package.json
index 57bca9e..48ff54f 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pex-color",
- "version": "2.1.1",
+ "version": "2.2.0",
"description": "Color utilities (css, p3, hex, hsl, hsv, hwb, lab, lch, xyz, okhsl, okhsv, oklab, oklch, hpluv, hsluv, lchuv, bytes) for PEX.",
"keywords": [
"pex",
@@ -58,14 +58,14 @@
"test": "node --test --experimental-test-coverage test",
"test:watch": "node --test --watch test"
},
+ "devDependencies": {
+ "colorjs.io": "github:color-js/color.js"
+ },
"engines": {
"node": ">=22.0.0",
"npm": ">=10.5.1",
"snowdev": ">=2.2.x"
},
- "devDependencies": {
- "colorjs.io": "github:color-js/color.js"
- },
"snowdev": {
"dependencies": []
}