colorizr 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -658,6 +658,26 @@ declare function extractAlphaFromHex(input: string): number;
658
658
  */
659
659
  declare function removeAlphaFromHex(input: string): HEX;
660
660
 
661
+ declare const CLMS_TO_OKLAB: number[][];
662
+ declare const DEG2RAD: number;
663
+ declare const LMS_TO_LRGB: number[][];
664
+ declare const LRGB_TO_LMS: number[][];
665
+ declare const OKLAB_TO_CLMS: number[][];
666
+ declare const P3_TO_SRGB: number[][];
667
+ declare const P3_TO_XYZ: number[][];
668
+ declare const SRGB_TO_P3: number[][];
669
+ declare const XYZ_TO_SRGB: number[][];
670
+ declare const GAMUT_EPSILON = 0.000001;
671
+ declare const PRECISION = 5;
672
+ declare const RAD2DEG: number;
673
+
674
+ declare function srgbGammaDecode(input: number): number;
675
+ declare function srgbGammaEncode(input: number): number;
676
+
677
+ declare function isInGamut(color: ColorTuple): boolean;
678
+ declare function oklabToLinearP3(L: number, a: number, b: number): ColorTuple;
679
+ declare function oklabToLinearSRGB(L: number, a: number, b: number): ColorTuple;
680
+
661
681
  /**
662
682
  * Get the step keys for a given step count.
663
683
  *
@@ -1058,4 +1078,4 @@ declare function toGamut(input: string, format?: ColorType): string;
1058
1078
  */
1059
1079
  declare function transparentize(input: string, alpha: number, format?: ColorType): string;
1060
1080
 
1061
- export { APCA_VERSION, type Analysis, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DELTA_E_JND, type FormatCSSOptions, type HEX, type HSL, type HueMode, type LAB, type LCH, type MixOptions, type PaletteOptions, type PlainObject, type RGB, type ReadableColorMethod, type ReadableColorOptions, type ScaleOptions, type ScaleVariant, type Scheme, type SchemeOptions, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, toGamut, transparentize };
1081
+ export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions, type PlainObject, RAD2DEG, type RGB, type ReadableColorMethod, type ReadableColorOptions, SRGB_TO_P3, type ScaleOptions, type ScaleVariant, type Scheme, type SchemeOptions, XYZ_TO_SRGB, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isInGamut, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklabToLinearP3, oklabToLinearSRGB, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, srgbGammaDecode, srgbGammaEncode, toGamut, transparentize };
package/dist/index.d.ts CHANGED
@@ -658,6 +658,26 @@ declare function extractAlphaFromHex(input: string): number;
658
658
  */
659
659
  declare function removeAlphaFromHex(input: string): HEX;
660
660
 
661
+ declare const CLMS_TO_OKLAB: number[][];
662
+ declare const DEG2RAD: number;
663
+ declare const LMS_TO_LRGB: number[][];
664
+ declare const LRGB_TO_LMS: number[][];
665
+ declare const OKLAB_TO_CLMS: number[][];
666
+ declare const P3_TO_SRGB: number[][];
667
+ declare const P3_TO_XYZ: number[][];
668
+ declare const SRGB_TO_P3: number[][];
669
+ declare const XYZ_TO_SRGB: number[][];
670
+ declare const GAMUT_EPSILON = 0.000001;
671
+ declare const PRECISION = 5;
672
+ declare const RAD2DEG: number;
673
+
674
+ declare function srgbGammaDecode(input: number): number;
675
+ declare function srgbGammaEncode(input: number): number;
676
+
677
+ declare function isInGamut(color: ColorTuple): boolean;
678
+ declare function oklabToLinearP3(L: number, a: number, b: number): ColorTuple;
679
+ declare function oklabToLinearSRGB(L: number, a: number, b: number): ColorTuple;
680
+
661
681
  /**
662
682
  * Get the step keys for a given step count.
663
683
  *
@@ -1058,4 +1078,4 @@ declare function toGamut(input: string, format?: ColorType): string;
1058
1078
  */
1059
1079
  declare function transparentize(input: string, alpha: number, format?: ColorType): string;
1060
1080
 
1061
- export { APCA_VERSION, type Analysis, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DELTA_E_JND, type FormatCSSOptions, type HEX, type HSL, type HueMode, type LAB, type LCH, type MixOptions, type PaletteOptions, type PlainObject, type RGB, type ReadableColorMethod, type ReadableColorOptions, type ScaleOptions, type ScaleVariant, type Scheme, type SchemeOptions, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, toGamut, transparentize };
1081
+ export { APCA_VERSION, type Analysis, CLMS_TO_OKLAB, type ColorKeysTuple, type ColorModel, type ColorModelKey, type ColorModelKeys, type ColorReturn, type ColorTuple, type ColorType, type ColorTypeInput, type ColorValue, type ColorizrOptions, type ConverterParameters, DEG2RAD, DELTA_E_JND, type FormatCSSOptions, GAMUT_EPSILON, type HEX, type HSL, type HueMode, type LAB, type LCH, LMS_TO_LRGB, LRGB_TO_LMS, type MixOptions, OKLAB_TO_CLMS, P3_TO_SRGB, P3_TO_XYZ, PRECISION, type PaletteOptions, type PlainObject, RAD2DEG, type RGB, type ReadableColorMethod, type ReadableColorOptions, SRGB_TO_P3, type ScaleOptions, type ScaleVariant, type Scheme, type SchemeOptions, XYZ_TO_SRGB, addAlphaToHex, apcaContrast, brightnessDifference, chroma, colorDifference, compare, contrast, convertAlphaToHex, convertCSS, darken, Colorizr as default, deltaE, desaturate, extractAlphaFromHex, extractColorParts, formatCSS, formatHex, getColorType, getP3MaxChroma, getP3MaxColor, getScaleStepKeys, grayscale, hex2hsl, hex2oklab, hex2oklch, hex2rgb, hsl2hex, hsl2oklab, hsl2oklch, hsl2rgb, invert, isHSL, isHex, isInGamut, isLAB, isLCH, isRGB, isValidColor, lighten, luminance, mix, name, oklab2hex, oklab2hsl, oklab2oklch, oklab2rgb, oklabToLinearP3, oklabToLinearSRGB, oklch2hex, oklch2hsl, oklch2oklab, oklch2rgb, opacify, opacity, palette, parseCSS, random, readableColor, removeAlphaFromHex, rgb2hex, rgb2hsl, rgb2oklab, rgb2oklch, rotate, saturate, scale, scheme, srgbGammaDecode, srgbGammaEncode, toGamut, transparentize };
package/dist/index.js CHANGED
@@ -23,7 +23,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
23
23
  var index_exports = {};
24
24
  __export(index_exports, {
25
25
  APCA_VERSION: () => APCA_VERSION,
26
+ CLMS_TO_OKLAB: () => CLMS_TO_OKLAB,
27
+ DEG2RAD: () => DEG2RAD,
26
28
  DELTA_E_JND: () => DELTA_E_JND,
29
+ GAMUT_EPSILON: () => GAMUT_EPSILON,
30
+ LMS_TO_LRGB: () => LMS_TO_LRGB,
31
+ LRGB_TO_LMS: () => LRGB_TO_LMS,
32
+ OKLAB_TO_CLMS: () => OKLAB_TO_CLMS,
33
+ P3_TO_SRGB: () => P3_TO_SRGB,
34
+ P3_TO_XYZ: () => P3_TO_XYZ,
35
+ PRECISION: () => PRECISION,
36
+ RAD2DEG: () => RAD2DEG,
37
+ SRGB_TO_P3: () => SRGB_TO_P3,
38
+ XYZ_TO_SRGB: () => XYZ_TO_SRGB,
27
39
  addAlphaToHex: () => addAlphaToHex,
28
40
  apcaContrast: () => apcaContrast,
29
41
  brightnessDifference: () => brightnessDifference,
@@ -57,6 +69,7 @@ __export(index_exports, {
57
69
  invert: () => invert,
58
70
  isHSL: () => isHSL,
59
71
  isHex: () => isHex,
72
+ isInGamut: () => isInGamut,
60
73
  isLAB: () => isLAB,
61
74
  isLCH: () => isLCH,
62
75
  isRGB: () => isRGB,
@@ -69,6 +82,8 @@ __export(index_exports, {
69
82
  oklab2hsl: () => oklab2hsl,
70
83
  oklab2oklch: () => oklab2oklch,
71
84
  oklab2rgb: () => oklab2rgb,
85
+ oklabToLinearP3: () => oklabToLinearP3,
86
+ oklabToLinearSRGB: () => oklabToLinearSRGB,
72
87
  oklch2hex: () => oklch2hex,
73
88
  oklch2hsl: () => oklch2hsl,
74
89
  oklch2oklab: () => oklch2oklab,
@@ -88,6 +103,8 @@ __export(index_exports, {
88
103
  saturate: () => saturate,
89
104
  scale: () => scale,
90
105
  scheme: () => scheme,
106
+ srgbGammaDecode: () => srgbGammaDecode,
107
+ srgbGammaEncode: () => srgbGammaEncode,
91
108
  toGamut: () => toGamut,
92
109
  transparentize: () => transparentize
93
110
  });
@@ -125,32 +142,47 @@ var COLOR_KEYS = {
125
142
  oklch: ["l", "c", "h"],
126
143
  rgb: ["r", "g", "b"]
127
144
  };
145
+ var CLMS_TO_OKLAB = [
146
+ [0.210454268309314, 0.7936177747023054, -0.0040720430116193],
147
+ [1.9779985324311684, -2.42859224204858, 0.450593709617411],
148
+ [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
149
+ ];
128
150
  var DEG2RAD = Math.PI / 180;
129
- var LAB_TO_LMS = {
130
- l: [0.3963377773761749, 0.2158037573099136],
131
- m: [-0.1055613458156586, -0.0638541728258133],
132
- s: [-0.0894841775298119, -1.2914855480194092]
133
- };
134
- var LRGB_TO_LMS = {
135
- l: [0.4122214708, 0.5363325363, 0.0514459929],
136
- m: [0.2119034982, 0.6806995451, 0.1073969566],
137
- s: [0.0883024619, 0.2817188376, 0.6299787005]
138
- };
139
- var LSM_TO_LAB = {
140
- l: [0.210454268309314, 0.7936177747023054, -0.0040720430116193],
141
- a: [1.9779985324311684, -2.42859224204858, 0.450593709617411],
142
- b: [0.0259040424655478, 0.7827717124575296, -0.8086757549230774]
143
- };
144
- var LSM_TO_RGB = {
145
- r: [4.076741636075958, -3.307711539258063, 0.2309699031821043],
146
- g: [-1.2684379732850315, 2.609757349287688, -0.341319376002657],
147
- b: [-0.0041960761386756, -0.7034186179359362, 1.7076146940746117]
148
- };
151
+ var LMS_TO_LRGB = [
152
+ [4.0767416621, -3.3077115913, 0.2309699292],
153
+ [-1.2684380046, 2.6097574011, -0.3413193965],
154
+ [-0.0041960863, -0.7034186147, 1.707614701]
155
+ ];
156
+ var LRGB_TO_LMS = [
157
+ [0.4122214708, 0.5363325363, 0.0514459929],
158
+ [0.2119034982, 0.6806995451, 0.1073969566],
159
+ [0.0883024619, 0.2817188376, 0.6299787005]
160
+ ];
161
+ var OKLAB_TO_CLMS = [
162
+ [1, 0.3963377773761749, 0.2158037573099136],
163
+ [1, -0.1055613458156586, -0.0638541728258133],
164
+ [1, -0.0894841775298119, -1.2914855480194092]
165
+ ];
166
+ var P3_TO_SRGB = [
167
+ [1.22494017628056, -0.22494017628055996, 0],
168
+ [-0.04205695470968812, 1.0420569547096883, 0],
169
+ [-0.019637554590334422, -0.07863604555063179, 1.0982736001409665]
170
+ ];
171
+ var P3_TO_XYZ = [
172
+ [0.4865709486482162, 0.26566769316909306, 0.1982172852343625],
173
+ [0.22897456406974884, 0.6917385218365064, 0.079286914093745],
174
+ [0, 0.04511338185890264, 1.043944368900976]
175
+ ];
149
176
  var SRGB_TO_P3 = [
150
177
  [0.8224270476, 0.1775729524, 0],
151
178
  [0.0331008087, 0.9668991913, 0],
152
179
  [0.0170720188, 0.0723477973, 0.9105801839]
153
180
  ];
181
+ var XYZ_TO_SRGB = [
182
+ [3.2409699419045226, -1.537383177570094, -0.4986107602930034],
183
+ [-0.9692436362808796, 1.8759675015077202, 0.0415550574071756],
184
+ [0.0556300796969936, -0.2039769588889765, 1.0569715142428786]
185
+ ];
154
186
  var GAMUT_EPSILON = 1e-6;
155
187
  var PRECISION = 5;
156
188
  var RAD2DEG = 180 / Math.PI;
@@ -708,27 +740,41 @@ function hex2hsl(input) {
708
740
  return addAlpha(rgb2hsl(hex2rgb(input)), alpha);
709
741
  }
710
742
 
711
- // src/converters/rgb2oklab.ts
712
- var { cbrt, sign } = Math;
713
- function rgb2lrgb(input) {
714
- const abs2 = Math.abs(input);
715
- if (abs2 < 0.04045) {
743
+ // src/modules/gamma.ts
744
+ function srgbGammaDecode(input) {
745
+ const abs = Math.abs(input);
746
+ if (abs < 0.04045) {
716
747
  return input / 12.92;
717
748
  }
718
- return (sign(input) || 1) * ((abs2 + 0.055) / 1.055) ** 2.4;
749
+ return (Math.sign(input) || 1) * ((abs + 0.055) / 1.055) ** 2.4;
719
750
  }
751
+ function srgbGammaEncode(input) {
752
+ const abs = Math.abs(input);
753
+ const sign = input < 0 ? -1 : 1;
754
+ if (abs > 31308e-7) {
755
+ return sign * (abs ** (1 / 2.4) * 1.055 - 0.055);
756
+ }
757
+ return input * 12.92;
758
+ }
759
+
760
+ // src/converters/rgb2oklab.ts
761
+ var { cbrt } = Math;
720
762
  function rgb2oklab(input, precision) {
721
763
  const value = parseInput(input, "rgb");
722
764
  const alpha = extractAlpha(input);
723
- const [lr, lg, lb] = [rgb2lrgb(value.r / 255), rgb2lrgb(value.g / 255), rgb2lrgb(value.b / 255)];
724
- const l = cbrt(LRGB_TO_LMS.l[0] * lr + LRGB_TO_LMS.l[1] * lg + LRGB_TO_LMS.l[2] * lb);
725
- const m = cbrt(LRGB_TO_LMS.m[0] * lr + LRGB_TO_LMS.m[1] * lg + LRGB_TO_LMS.m[2] * lb);
726
- const s = cbrt(LRGB_TO_LMS.s[0] * lr + LRGB_TO_LMS.s[1] * lg + LRGB_TO_LMS.s[2] * lb);
765
+ const [lr, lg, lb] = [
766
+ srgbGammaDecode(value.r / 255),
767
+ srgbGammaDecode(value.g / 255),
768
+ srgbGammaDecode(value.b / 255)
769
+ ];
770
+ const l = cbrt(LRGB_TO_LMS[0][0] * lr + LRGB_TO_LMS[0][1] * lg + LRGB_TO_LMS[0][2] * lb);
771
+ const m = cbrt(LRGB_TO_LMS[1][0] * lr + LRGB_TO_LMS[1][1] * lg + LRGB_TO_LMS[1][2] * lb);
772
+ const s = cbrt(LRGB_TO_LMS[2][0] * lr + LRGB_TO_LMS[2][1] * lg + LRGB_TO_LMS[2][2] * lb);
727
773
  const lab = restrictValues(
728
774
  {
729
- l: LSM_TO_LAB.l[0] * l + LSM_TO_LAB.l[1] * m + LSM_TO_LAB.l[2] * s,
730
- a: LSM_TO_LAB.a[0] * l + LSM_TO_LAB.a[1] * m + LSM_TO_LAB.a[2] * s,
731
- b: LSM_TO_LAB.b[0] * l + LSM_TO_LAB.b[1] * m + LSM_TO_LAB.b[2] * s
775
+ l: CLMS_TO_OKLAB[0][0] * l + CLMS_TO_OKLAB[0][1] * m + CLMS_TO_OKLAB[0][2] * s,
776
+ a: CLMS_TO_OKLAB[1][0] * l + CLMS_TO_OKLAB[1][1] * m + CLMS_TO_OKLAB[1][2] * s,
777
+ b: CLMS_TO_OKLAB[2][0] * l + CLMS_TO_OKLAB[2][1] * m + CLMS_TO_OKLAB[2][2] * s
732
778
  },
733
779
  precision
734
780
  );
@@ -855,24 +901,15 @@ function hsl2oklch(input, precision) {
855
901
  }
856
902
 
857
903
  // src/converters/oklab2rgb.ts
858
- var { abs } = Math;
859
- function lrgb2rgb(input) {
860
- const absoluteNumber = abs(input);
861
- const sign2 = input < 0 ? -1 : 1;
862
- if (absoluteNumber > 31308e-7) {
863
- return sign2 * (absoluteNumber ** (1 / 2.4) * 1.055 - 0.055);
864
- }
865
- return input * 12.92;
866
- }
867
904
  function oklab2rgb(input, precision = 0) {
868
905
  const { l: L, a: A, b: B } = parseInput(input, "oklab");
869
906
  const alpha = extractAlpha(input);
870
- const l = (L + LAB_TO_LMS.l[0] * A + LAB_TO_LMS.l[1] * B) ** 3;
871
- const m = (L + LAB_TO_LMS.m[0] * A + LAB_TO_LMS.m[1] * B) ** 3;
872
- const s = (L + LAB_TO_LMS.s[0] * A + LAB_TO_LMS.s[1] * B) ** 3;
873
- const r = 255 * lrgb2rgb(LSM_TO_RGB.r[0] * l + LSM_TO_RGB.r[1] * m + LSM_TO_RGB.r[2] * s);
874
- const g = 255 * lrgb2rgb(LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s);
875
- const b = 255 * lrgb2rgb(LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s);
907
+ const l = (OKLAB_TO_CLMS[0][0] * L + OKLAB_TO_CLMS[0][1] * A + OKLAB_TO_CLMS[0][2] * B) ** 3;
908
+ const m = (OKLAB_TO_CLMS[1][0] * L + OKLAB_TO_CLMS[1][1] * A + OKLAB_TO_CLMS[1][2] * B) ** 3;
909
+ const s = (OKLAB_TO_CLMS[2][0] * L + OKLAB_TO_CLMS[2][1] * A + OKLAB_TO_CLMS[2][2] * B) ** 3;
910
+ const r = 255 * srgbGammaEncode(LMS_TO_LRGB[0][0] * l + LMS_TO_LRGB[0][1] * m + LMS_TO_LRGB[0][2] * s);
911
+ const g = 255 * srgbGammaEncode(LMS_TO_LRGB[1][0] * l + LMS_TO_LRGB[1][1] * m + LMS_TO_LRGB[1][2] * s);
912
+ const b = 255 * srgbGammaEncode(LMS_TO_LRGB[2][0] * l + LMS_TO_LRGB[2][1] * m + LMS_TO_LRGB[2][2] * s);
876
913
  return addAlpha(
877
914
  {
878
915
  r: clamp(round(r, precision), 0, 255),
@@ -1321,15 +1358,10 @@ function colorDifference(left, right) {
1321
1358
  function luminance(input) {
1322
1359
  invariant(isString(input), MESSAGES.inputString);
1323
1360
  const { r, g, b } = resolveColor(input).rgb;
1324
- const rgb = [r / 255, g / 255, b / 255];
1325
- for (let index = 0; index < rgb.length; index++) {
1326
- if (rgb[index] <= 0.04045) {
1327
- rgb[index] /= 12.92;
1328
- } else {
1329
- rgb[index] = ((rgb[index] + 0.055) / 1.055) ** 2.4;
1330
- }
1331
- }
1332
- return round(0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2], 4);
1361
+ const lr = srgbGammaDecode(r / 255);
1362
+ const lg = srgbGammaDecode(g / 255);
1363
+ const lb = srgbGammaDecode(b / 255);
1364
+ return round(0.2126 * lr + 0.7152 * lg + 0.0722 * lb, 4);
1333
1365
  }
1334
1366
 
1335
1367
  // src/contrast.ts
@@ -1646,13 +1678,13 @@ function oklabToLinearP3(L, a, b) {
1646
1678
  return multiplyMatrix(SRGB_TO_P3, oklabToLinearSRGB(L, a, b));
1647
1679
  }
1648
1680
  function oklabToLinearSRGB(L, a, b) {
1649
- const l = (L + LAB_TO_LMS.l[0] * a + LAB_TO_LMS.l[1] * b) ** 3;
1650
- const m = (L + LAB_TO_LMS.m[0] * a + LAB_TO_LMS.m[1] * b) ** 3;
1651
- const s = (L + LAB_TO_LMS.s[0] * a + LAB_TO_LMS.s[1] * b) ** 3;
1681
+ const l = (OKLAB_TO_CLMS[0][0] * L + OKLAB_TO_CLMS[0][1] * a + OKLAB_TO_CLMS[0][2] * b) ** 3;
1682
+ const m = (OKLAB_TO_CLMS[1][0] * L + OKLAB_TO_CLMS[1][1] * a + OKLAB_TO_CLMS[1][2] * b) ** 3;
1683
+ const s = (OKLAB_TO_CLMS[2][0] * L + OKLAB_TO_CLMS[2][1] * a + OKLAB_TO_CLMS[2][2] * b) ** 3;
1652
1684
  return [
1653
- LSM_TO_RGB.r[0] * l + LSM_TO_RGB.r[1] * m + LSM_TO_RGB.r[2] * s,
1654
- LSM_TO_RGB.g[0] * l + LSM_TO_RGB.g[1] * m + LSM_TO_RGB.g[2] * s,
1655
- LSM_TO_RGB.b[0] * l + LSM_TO_RGB.b[1] * m + LSM_TO_RGB.b[2] * s
1685
+ LMS_TO_LRGB[0][0] * l + LMS_TO_LRGB[0][1] * m + LMS_TO_LRGB[0][2] * s,
1686
+ LMS_TO_LRGB[1][0] * l + LMS_TO_LRGB[1][1] * m + LMS_TO_LRGB[1][2] * s,
1687
+ LMS_TO_LRGB[2][0] * l + LMS_TO_LRGB[2][1] * m + LMS_TO_LRGB[2][2] * s
1656
1688
  ];
1657
1689
  }
1658
1690
 
@@ -2296,7 +2328,19 @@ function scheme(input, schemeOrOptions) {
2296
2328
  // Annotate the CommonJS export names for ESM import in node:
2297
2329
  0 && (module.exports = {
2298
2330
  APCA_VERSION,
2331
+ CLMS_TO_OKLAB,
2332
+ DEG2RAD,
2299
2333
  DELTA_E_JND,
2334
+ GAMUT_EPSILON,
2335
+ LMS_TO_LRGB,
2336
+ LRGB_TO_LMS,
2337
+ OKLAB_TO_CLMS,
2338
+ P3_TO_SRGB,
2339
+ P3_TO_XYZ,
2340
+ PRECISION,
2341
+ RAD2DEG,
2342
+ SRGB_TO_P3,
2343
+ XYZ_TO_SRGB,
2300
2344
  addAlphaToHex,
2301
2345
  apcaContrast,
2302
2346
  brightnessDifference,
@@ -2329,6 +2373,7 @@ function scheme(input, schemeOrOptions) {
2329
2373
  invert,
2330
2374
  isHSL,
2331
2375
  isHex,
2376
+ isInGamut,
2332
2377
  isLAB,
2333
2378
  isLCH,
2334
2379
  isRGB,
@@ -2341,6 +2386,8 @@ function scheme(input, schemeOrOptions) {
2341
2386
  oklab2hsl,
2342
2387
  oklab2oklch,
2343
2388
  oklab2rgb,
2389
+ oklabToLinearP3,
2390
+ oklabToLinearSRGB,
2344
2391
  oklch2hex,
2345
2392
  oklch2hsl,
2346
2393
  oklch2oklab,
@@ -2360,6 +2407,8 @@ function scheme(input, schemeOrOptions) {
2360
2407
  saturate,
2361
2408
  scale,
2362
2409
  scheme,
2410
+ srgbGammaDecode,
2411
+ srgbGammaEncode,
2363
2412
  toGamut,
2364
2413
  transparentize
2365
2414
  });