@texel/color 1.1.8 → 1.1.10
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/package.json +4 -2
- package/src/core.js +5 -0
- package/src/gamut.js +2 -2
- package/src/util.js +2 -2
- package/types.d.ts +4 -1
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@texel/color",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "a minimal and modern color library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
|
+
"types": "./types.d.ts",
|
|
7
8
|
"exports": {
|
|
8
|
-
"import": "./src/index.js"
|
|
9
|
+
"import": "./src/index.js",
|
|
10
|
+
"types": "./types.d.ts"
|
|
9
11
|
},
|
|
10
12
|
"license": "MIT",
|
|
11
13
|
"author": {
|
package/src/core.js
CHANGED
|
@@ -20,6 +20,10 @@ import { listColorSpaces, sRGB, XYZ } from "./spaces.js";
|
|
|
20
20
|
* const vec = [ x, y, z ];
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {number[][][]} ColorGamutCoefficients
|
|
25
|
+
*/
|
|
26
|
+
|
|
23
27
|
/**
|
|
24
28
|
* @typedef {Object} ChromaticAdaptation
|
|
25
29
|
* @property {Matrix3x3} from the matrix to convert from the source whitepoint to the destination whitepoint
|
|
@@ -42,6 +46,7 @@ import { listColorSpaces, sRGB, XYZ } from "./spaces.js";
|
|
|
42
46
|
/**
|
|
43
47
|
* @typedef {Object} ColorGamut
|
|
44
48
|
* @property {ColorSpace} space the color space associated with this color gamut
|
|
49
|
+
* @property {ColorGamutCoefficients} [coefficients] the coefficients used during gamut mapping from OKLab
|
|
45
50
|
*/
|
|
46
51
|
|
|
47
52
|
const tmp3 = vec3();
|
package/src/gamut.js
CHANGED
|
@@ -92,8 +92,8 @@ const setYZ = (v, a, b) => {
|
|
|
92
92
|
* the RGB gamut, using the given coefficients.
|
|
93
93
|
* @param {number} a The normalized a component of the hue.
|
|
94
94
|
* @param {number} b The normalized b component of the hue.
|
|
95
|
-
* @param {
|
|
96
|
-
* @param {
|
|
95
|
+
* @param {Matrix3x3} lmsToRgb The LMS to RGB conversion matrix.
|
|
96
|
+
* @param {ColorGamutCoefficients} okCoeff The OKLab coefficients.
|
|
97
97
|
* @returns {number} The maximum saturation.
|
|
98
98
|
* @method
|
|
99
99
|
* @category mapping
|
package/src/util.js
CHANGED
|
@@ -92,11 +92,11 @@ export const RGBtoHex = RGBToHex;
|
|
|
92
92
|
* Checks if an RGB color is within the gamut.
|
|
93
93
|
* @method
|
|
94
94
|
* @param {Vector} lrgb The linear RGB array.
|
|
95
|
-
* @param {number} [ep=
|
|
95
|
+
* @param {number} [ep=0] The epsilon value for comparison.
|
|
96
96
|
* @returns {boolean} True if the color is within the gamut, false otherwise.
|
|
97
97
|
* @category rgb
|
|
98
98
|
*/
|
|
99
|
-
export const isRGBInGamut = (lrgb, ep =
|
|
99
|
+
export const isRGBInGamut = (lrgb, ep = 0) => {
|
|
100
100
|
const r = lrgb[0];
|
|
101
101
|
const g = lrgb[1];
|
|
102
102
|
const b = lrgb[2];
|
package/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare module "@texel/color" {
|
|
|
15
15
|
* const vec = [ x, y, z ];
|
|
16
16
|
*/
|
|
17
17
|
type Vector = number[];
|
|
18
|
+
type ColorGamutCoefficients = number[][][];
|
|
18
19
|
/**
|
|
19
20
|
* @property from - the matrix to convert from the source whitepoint to the destination whitepoint
|
|
20
21
|
* @property to - the matrix to convert from the destination whitepoint to the source whitepoint
|
|
@@ -47,9 +48,11 @@ declare module "@texel/color" {
|
|
|
47
48
|
};
|
|
48
49
|
/**
|
|
49
50
|
* @property space - the color space associated with this color gamut
|
|
51
|
+
* @property [coefficients] - the coefficients used during gamut mapping from OKLab
|
|
50
52
|
*/
|
|
51
53
|
type ColorGamut = {
|
|
52
54
|
space: ColorSpace;
|
|
55
|
+
coefficients?: ColorGamutCoefficients;
|
|
53
56
|
};
|
|
54
57
|
/**
|
|
55
58
|
* Converts OKLab color to another color space.
|
|
@@ -156,7 +159,7 @@ declare module "@texel/color" {
|
|
|
156
159
|
* @param okCoeff - The OKLab coefficients.
|
|
157
160
|
* @returns The maximum saturation.
|
|
158
161
|
*/
|
|
159
|
-
function computeMaxSaturationOKLC(a: number, b: number, lmsToRgb:
|
|
162
|
+
function computeMaxSaturationOKLC(a: number, b: number, lmsToRgb: Matrix3x3, okCoeff: ColorGamutCoefficients): number;
|
|
160
163
|
/**
|
|
161
164
|
* Retrieves the LMS to RGB conversion matrix from the given gamut.
|
|
162
165
|
* @param gamut - The gamut object.
|