@texel/color 1.1.3 → 1.1.5
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/.jsdoc.json +10 -0
- package/DOC.md +17 -0
- package/README.md +7 -1
- package/package.json +8 -2
- package/src/core.js +131 -8
- package/src/gamut.js +74 -4
- package/src/okhsl.js +40 -0
- package/src/spaces/a98-rgb.js +15 -0
- package/src/spaces/display-p3.js +15 -0
- package/src/spaces/oklab.js +24 -0
- package/src/spaces/prophoto-rgb.js +10 -0
- package/src/spaces/rec2020.js +15 -0
- package/src/spaces/srgb.js +15 -0
- package/src/spaces/util.js +14 -0
- package/src/spaces/xyz.js +26 -2
- package/src/spaces.js +14 -0
- package/src/util.js +121 -19
- package/types/types.d.ts +556 -0
- package/test/almost-equal.js +0 -15
- package/test/banner.png +0 -0
- package/test/bench-colorjs.js +0 -227
- package/test/bench-culori.js +0 -148
- package/test/bench-node.js +0 -51
- package/test/bench-size.js +0 -12
- package/test/canvas-graph.js +0 -212
- package/test/check-gamut-epsilon.js +0 -136
- package/test/colorjs-fn.js +0 -34
- package/test/example-interpolation.js +0 -107
- package/test/logo.js +0 -112
- package/test/logo.png +0 -0
- package/test/profiles/DisplayP3.icc +0 -0
- package/test/spaces/hsl.js +0 -87
- package/test/spaces/lab.js +0 -60
- package/test/test-colorjs.js +0 -86
- package/test/test-other-spaces.js +0 -115
- package/test/test.js +0 -481
- package/tools/__pycache__/calc_oklab_matrices.cpython-311.pyc +0 -0
- package/tools/calc_oklab_matrices.py +0 -233
- package/tools/print_matrices.py +0 -509
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A 3x3 matrix represented as an array of arrays.
|
|
3
|
+
* @example
|
|
4
|
+
* const matrix = [
|
|
5
|
+
* [a, b, c],
|
|
6
|
+
* [d, e, f],
|
|
7
|
+
* [g, h, i]
|
|
8
|
+
* ];
|
|
9
|
+
*/
|
|
10
|
+
declare type Matrix3x3 = number[][];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A n-dimensional vector represented as an array of numbers, typically in 3D (X, Y, Z).
|
|
14
|
+
* @example
|
|
15
|
+
* const vec = [ x, y, z ];
|
|
16
|
+
*/
|
|
17
|
+
declare type Vector = number[];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @property id - the unique identifier for this color space in lowercase
|
|
21
|
+
* @property [toXYZ_M] - optional matrix to convert this color directly to XYZ D65
|
|
22
|
+
* @property [fromXYZ_M] - optional matrix to convert XYZ D65 to this color space
|
|
23
|
+
* @property [toLMS_M] - optional matrix to convert this color space to OKLab's LMS intermediary form
|
|
24
|
+
* @property [fromLMS_M] - optional matrix to convert OKLab's LMS intermediary form to this color space
|
|
25
|
+
* @property [adapt] - optional chromatic adaptation matrices
|
|
26
|
+
* @property [base] - an optional base color space that this space is derived from
|
|
27
|
+
* @property [toBase] - if a base color space exists, this maps the color to the base space form (e.g. gamma to the linear base space)
|
|
28
|
+
* @property [fromBase] - if a base color space exists, this maps the color from the base space form (e.g. the linear base space to the gamma space)
|
|
29
|
+
*/
|
|
30
|
+
declare type ColorSpace = {
|
|
31
|
+
id: string;
|
|
32
|
+
toXYZ_M?: Matrix3x3;
|
|
33
|
+
fromXYZ_M?: Matrix3x3;
|
|
34
|
+
toLMS_M?: Matrix3x3;
|
|
35
|
+
fromLMS_M?: Matrix3x3;
|
|
36
|
+
adapt?: any;
|
|
37
|
+
base?: ColorSpace;
|
|
38
|
+
toBase?: (...params: any[]) => any;
|
|
39
|
+
fromBase?: (...params: any[]) => any;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @property space - the color space associated with this color gamut
|
|
44
|
+
*/
|
|
45
|
+
declare type ColorGamut = {
|
|
46
|
+
space: ColorSpace;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Converts OKLab color to another color space.
|
|
51
|
+
* @param OKLab - The OKLab color.
|
|
52
|
+
* @param LMS_to_output - The transformation matrix from LMS to the output color space.
|
|
53
|
+
* @param [out = vec3()] - The output vector.
|
|
54
|
+
* @returns The transformed color.
|
|
55
|
+
*/
|
|
56
|
+
declare function OKLab_to(
|
|
57
|
+
OKLab: Vector,
|
|
58
|
+
LMS_to_output: Matrix3x3,
|
|
59
|
+
out?: Vector
|
|
60
|
+
): Vector;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Converts a color from another color space to OKLab.
|
|
64
|
+
* @param input - The input color.
|
|
65
|
+
* @param input_to_LMS - The transformation matrix from the input color space to LMS.
|
|
66
|
+
* @param [out = vec3()] - The output vector.
|
|
67
|
+
* @returns The transformed color.
|
|
68
|
+
*/
|
|
69
|
+
declare function OKLab_from(
|
|
70
|
+
input: Vector,
|
|
71
|
+
input_to_LMS: Matrix3x3,
|
|
72
|
+
out?: Vector
|
|
73
|
+
): Vector;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Transforms a color vector by the specified 3x3 transformation matrix.
|
|
77
|
+
* @param input - The input color.
|
|
78
|
+
* @param matrix - The transformation matrix.
|
|
79
|
+
* @param [out = vec3()] - The output vector.
|
|
80
|
+
* @returns The transformed color.
|
|
81
|
+
*/
|
|
82
|
+
declare function transform(
|
|
83
|
+
input: Vector,
|
|
84
|
+
matrix: Matrix3x3,
|
|
85
|
+
out?: Vector
|
|
86
|
+
): Vector;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Serializes a color to a CSS color string.
|
|
90
|
+
* @param input - The input color.
|
|
91
|
+
* @param inputSpace - The input color space.
|
|
92
|
+
* @param [outputSpace = inputSpace] - The output color space.
|
|
93
|
+
* @returns The serialized color string.
|
|
94
|
+
*/
|
|
95
|
+
declare function serialize(
|
|
96
|
+
input: Vector,
|
|
97
|
+
inputSpace: ColorSpace,
|
|
98
|
+
outputSpace?: ColorSpace
|
|
99
|
+
): string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Deserializes a color string to an object with <code>id</code> (color space string) and <code>coords</code> (the vector, in 3 or 4 dimensions).
|
|
103
|
+
* Note this does not return a <code>ColorSpace</code> object; you may want to use the example code below to map the string ID to a <code>ColorSpace</code>, but this will increase the size of your final bundle as it references all spaces.
|
|
104
|
+
* @example
|
|
105
|
+
* import { listColorSpaces, deserialize } from "@texel/color";
|
|
106
|
+
*
|
|
107
|
+
* const { id, coords } = deserialize(str);
|
|
108
|
+
* // now find the actual color space object
|
|
109
|
+
* const space = listColorSpaces().find((f) => id === f.id);
|
|
110
|
+
* console.log(space, coords);
|
|
111
|
+
* @param input - The color string to deserialize.
|
|
112
|
+
* @returns The deserialized color object.
|
|
113
|
+
*/
|
|
114
|
+
declare function deserialize(input: string): any;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Parses a color string and converts it to the target color space.
|
|
118
|
+
* @param input - The color string to parse.
|
|
119
|
+
* @param targetSpace - The target color space.
|
|
120
|
+
* @param [out = vec3()] - The output vector.
|
|
121
|
+
* @returns The parsed and converted color.
|
|
122
|
+
*/
|
|
123
|
+
declare function parse(
|
|
124
|
+
input: string,
|
|
125
|
+
targetSpace: ColorSpace,
|
|
126
|
+
out?: Vector
|
|
127
|
+
): Vector;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Converts a color from one color space to another.
|
|
131
|
+
* @param input - The input color.
|
|
132
|
+
* @param fromSpace - The source color space.
|
|
133
|
+
* @param toSpace - The target color space.
|
|
134
|
+
* @param [out = vec3()] - The output vector.
|
|
135
|
+
* @returns The converted color.
|
|
136
|
+
*/
|
|
137
|
+
declare function convert(
|
|
138
|
+
input: Vector,
|
|
139
|
+
fromSpace: ColorSpace,
|
|
140
|
+
toSpace: ColorSpace,
|
|
141
|
+
out?: Vector
|
|
142
|
+
): Vector;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Calculates the DeltaEOK (color difference) between two OKLab colors.
|
|
146
|
+
* @param oklab1 - The first OKLab color.
|
|
147
|
+
* @param oklab2 - The second OKLab color.
|
|
148
|
+
* @returns The delta E value.
|
|
149
|
+
*/
|
|
150
|
+
declare function deltaEOK(oklab1: Vector, oklab2: Vector): number;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A function that maps an OKLCH color to a lightness value.
|
|
154
|
+
* @param oklch - The input OKLCH color
|
|
155
|
+
* @param cusp - A 2D cusp point in the form [L, C]
|
|
156
|
+
*/
|
|
157
|
+
declare type GamutMapMethod = (oklch: Vector, cusp: number[]) => void;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A {@link GamutMapMethod} that maintains the color's lightness.
|
|
161
|
+
*/
|
|
162
|
+
declare const MapToL: GamutMapMethod;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A {@link GamutMapMethod} that maps towards middle gray (L = 0.5).
|
|
166
|
+
*/
|
|
167
|
+
declare const MapToGray: GamutMapMethod;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A {@link GamutMapMethod} that maps towards the lightness of the current hue's cusp.
|
|
171
|
+
*/
|
|
172
|
+
declare const MapToCuspL: GamutMapMethod;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* A {@link GamutMapMethod} that adaptively maps towards gray.
|
|
176
|
+
*/
|
|
177
|
+
declare const MapToAdaptiveGray: GamutMapMethod;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* A {@link GamutMapMethod} that adaptively maps towards the cusp's lightness.
|
|
181
|
+
*/
|
|
182
|
+
declare const MapToAdaptiveCuspL: GamutMapMethod;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Computes the maximum saturation (S = C/L) possible for a given hue that fits within
|
|
186
|
+
* the RGB gamut, using the given coefficients.
|
|
187
|
+
* @param a - The normalized a component of the hue.
|
|
188
|
+
* @param b - The normalized b component of the hue.
|
|
189
|
+
* @param lmsToRgb - The LMS to RGB conversion matrix.
|
|
190
|
+
* @param okCoeff - The OKLab coefficients.
|
|
191
|
+
* @returns The maximum saturation.
|
|
192
|
+
*/
|
|
193
|
+
declare function computeMaxSaturationOKLC(
|
|
194
|
+
a: number,
|
|
195
|
+
b: number,
|
|
196
|
+
lmsToRgb: number[][],
|
|
197
|
+
okCoeff: number[][][]
|
|
198
|
+
): number;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Retrieves the LMS to RGB conversion matrix from the given gamut.
|
|
202
|
+
* @param gamut - The gamut object.
|
|
203
|
+
* @returns The LMS to RGB conversion matrix.
|
|
204
|
+
*/
|
|
205
|
+
declare function getGamutLMStoRGB(gamut: ColorGamut): Matrix3x3;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Finds the cusp of the OKLCH color space for a given hue.
|
|
209
|
+
* @param a - The normalized a component of the hue.
|
|
210
|
+
* @param b - The normalized b component of the hue.
|
|
211
|
+
* @param gamut - The gamut object.
|
|
212
|
+
* @param [out = [0, 0]] - The output array to store the cusp values.
|
|
213
|
+
* @returns The cusp values [L, C].
|
|
214
|
+
*/
|
|
215
|
+
declare function findCuspOKLCH(
|
|
216
|
+
a: number,
|
|
217
|
+
b: number,
|
|
218
|
+
gamut: ColorGamut,
|
|
219
|
+
out?: number[]
|
|
220
|
+
): number[];
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Applies fast approximate gamut mapping in OKLab space on the given OKLCH input color,
|
|
224
|
+
* using the specified gamut and converting to the target color space.
|
|
225
|
+
* @param oklch - The input OKLCH color that you wish to gamut map.
|
|
226
|
+
* @param [gamut = sRGBGamut] - The gamut object.
|
|
227
|
+
* @param [targetSpace = gamut.space] - The target color space.
|
|
228
|
+
* @param [out = vec3()] - The output array to store the mapped color.
|
|
229
|
+
* @param [mapping = MapToCuspL] - The gamut mapping function.
|
|
230
|
+
* @param [cusp] - Optional, you can provide the cusp values [L, C] to avoid re-computing them.
|
|
231
|
+
* @returns The mapped color in the target color space.
|
|
232
|
+
*/
|
|
233
|
+
declare function gamutMapOKLCH(
|
|
234
|
+
oklch: Vector,
|
|
235
|
+
gamut?: ColorGamut,
|
|
236
|
+
targetSpace?: ColorSpace,
|
|
237
|
+
out?: Vector,
|
|
238
|
+
mapping?: GamutMapMethod,
|
|
239
|
+
cusp?: Vector
|
|
240
|
+
): Vector;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Converts OKHSL color to OKLab color.
|
|
244
|
+
* @param hsl - The OKHSL color as an array [h, s, l].
|
|
245
|
+
* @param [gamut = sRGBGamut] - The color gamut.
|
|
246
|
+
* @param [out = vec3()] - The output array to store the OKLab color.
|
|
247
|
+
* @returns The OKLab color as an array [L, a, b].
|
|
248
|
+
*/
|
|
249
|
+
declare function OKHSLToOKLab(
|
|
250
|
+
hsl: Vector,
|
|
251
|
+
gamut?: ColorGamut,
|
|
252
|
+
out?: Vector
|
|
253
|
+
): Vector;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Converts OKLab color to OKHSL color.
|
|
257
|
+
* @param lab - The OKLab color as an array [L, a, b].
|
|
258
|
+
* @param [gamut = sRGBGamut] - The color gamut.
|
|
259
|
+
* @param [out = vec3()] - The output array to store the OKHSL color.
|
|
260
|
+
* @returns The OKHSL color as an array [h, s, l].
|
|
261
|
+
*/
|
|
262
|
+
declare function OKLabToOKHSL(
|
|
263
|
+
lab: Vector,
|
|
264
|
+
gamut?: ColorGamut,
|
|
265
|
+
out?: Vector
|
|
266
|
+
): Vector;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Converts OKHSV color to OKLab color.
|
|
270
|
+
* @param hsv - The OKHSV color as an array [h, s, v].
|
|
271
|
+
* @param [gamut = sRGBGamut] - The color gamut.
|
|
272
|
+
* @param [out = vec3()] - The output array to store the OKLab color.
|
|
273
|
+
* @returns The OKLab color as an array [L, a, b].
|
|
274
|
+
*/
|
|
275
|
+
declare function OKHSVToOKLab(
|
|
276
|
+
hsv: Vector,
|
|
277
|
+
gamut?: ColorGamut,
|
|
278
|
+
out?: Vector
|
|
279
|
+
): Vector;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Converts OKLab color to OKHSV color.
|
|
283
|
+
* @param lab - The OKLab color as an array [L, a, b].
|
|
284
|
+
* @param [gamut = sRGBGamut] - The color gamut.
|
|
285
|
+
* @param [out = vec3()] - The output array to store the OKHSV color.
|
|
286
|
+
* @returns The OKHSV color as an array [h, s, v].
|
|
287
|
+
*/
|
|
288
|
+
declare function OKLabToOKHSV(
|
|
289
|
+
lab: Vector,
|
|
290
|
+
gamut?: ColorGamut,
|
|
291
|
+
out?: Vector
|
|
292
|
+
): Vector;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Returns a list of color spaces.
|
|
296
|
+
* @returns An array of color space objects.
|
|
297
|
+
*/
|
|
298
|
+
declare function listColorSpaces(): ColorSpace[];
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Returns a list of color gamuts.
|
|
302
|
+
* @returns An array of color gamut objects.
|
|
303
|
+
*/
|
|
304
|
+
declare function listColorGamuts(): ColorGamut[];
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Clamps a value between a minimum and maximum value.
|
|
308
|
+
* @param value - The value to clamp.
|
|
309
|
+
* @param min - The minimum value.
|
|
310
|
+
* @param max - The maximum value.
|
|
311
|
+
* @returns The clamped value.
|
|
312
|
+
*/
|
|
313
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Linearly interpolates between two values.
|
|
317
|
+
* @param min - The start value.
|
|
318
|
+
* @param max - The end value.
|
|
319
|
+
* @param t - The interpolation factor between 0 and 1.
|
|
320
|
+
* @returns The interpolated value.
|
|
321
|
+
*/
|
|
322
|
+
declare function lerp(min: number, max: number, t: number): number;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Converts degrees to radians.
|
|
326
|
+
* @param n - The angle in degrees.
|
|
327
|
+
* @returns The angle in radians.
|
|
328
|
+
*/
|
|
329
|
+
declare function degToRad(n: number): number;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Converts radians to degrees.
|
|
333
|
+
* @param n - The angle in radians.
|
|
334
|
+
* @returns The angle in degrees.
|
|
335
|
+
*/
|
|
336
|
+
declare function radToDeg(n: number): number;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Constrains an angle to the range [0, 360).
|
|
340
|
+
* @param angle - The angle in degrees.
|
|
341
|
+
* @returns The constrained angle.
|
|
342
|
+
*/
|
|
343
|
+
declare function constrainAngle(angle: number): number;
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Converts a hex color string to an RGB array.
|
|
347
|
+
* @param str - The hex color string.
|
|
348
|
+
* @param [out = vec3()] - The output array.
|
|
349
|
+
* @returns The RGB array.
|
|
350
|
+
*/
|
|
351
|
+
declare function hexToRGB(str: string, out?: Vector): Vector;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Converts an RGB array to a hex color string.
|
|
355
|
+
* @param rgb - The RGB array.
|
|
356
|
+
* @returns The hex color string.
|
|
357
|
+
*/
|
|
358
|
+
declare function RGBToHex(rgb: Vector): string;
|
|
359
|
+
|
|
360
|
+
declare function RGBtoHex(): void;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Checks if an RGB color is within the gamut.
|
|
364
|
+
* @param lrgb - The linear RGB array.
|
|
365
|
+
* @param [ep = GAMUT_EPSILON] - The epsilon value for comparison.
|
|
366
|
+
* @returns True if the color is within the gamut, false otherwise.
|
|
367
|
+
*/
|
|
368
|
+
declare function isRGBInGamut(lrgb: Vector, ep?: number): boolean;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Clamps an RGB array to the range [0, 1].
|
|
372
|
+
* @param rgb - The RGB array.
|
|
373
|
+
* @param [out = vec3()] - The output array.
|
|
374
|
+
* @returns The clamped RGB array.
|
|
375
|
+
*/
|
|
376
|
+
declare function clampedRGB(rgb: Vector, out?: Vector): Vector;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Converts xyY color space to XYZ color space.
|
|
380
|
+
* @param arg - The xyY array.
|
|
381
|
+
* @param [out = vec3()] - The output array.
|
|
382
|
+
* @returns The XYZ array.
|
|
383
|
+
*/
|
|
384
|
+
declare function xyY_to_XYZ(arg: Vector, out?: Vector): Vector;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Converts XYZ color space to xyY color space.
|
|
388
|
+
* @param arg - The XYZ array.
|
|
389
|
+
* @param [out = vec3()] - The output array.
|
|
390
|
+
* @returns The xyY array.
|
|
391
|
+
*/
|
|
392
|
+
declare function XYZ_to_xyY(arg: Vector, out?: Vector): Vector;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Converts a float value to a byte value.
|
|
396
|
+
* @param n - The float value.
|
|
397
|
+
* @returns The byte value.
|
|
398
|
+
*/
|
|
399
|
+
declare function floatToByte(n: number): number;
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Creates a new vec3 array.
|
|
403
|
+
* @returns The vec3 array.
|
|
404
|
+
*/
|
|
405
|
+
declare function vec3(): Vector;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Calculates the delta angle between two angles.
|
|
409
|
+
* @param a0 - The first angle in degrees.
|
|
410
|
+
* @param a1 - The second angle in degrees.
|
|
411
|
+
* @returns The delta angle in degrees.
|
|
412
|
+
*/
|
|
413
|
+
declare function deltaAngle(a0: number, a1: number): number;
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Linearly interpolates between two angles.
|
|
417
|
+
* @param a0 - The start angle in degrees.
|
|
418
|
+
* @param a1 - The end angle in degrees.
|
|
419
|
+
* @param t - The interpolation factor between 0 and 1.
|
|
420
|
+
* @returns The interpolated angle in degrees.
|
|
421
|
+
*/
|
|
422
|
+
declare function lerpAngle(a0: number, a1: number, t: number): number;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The Adobe RGB (1998) color space in linear form, without a transfer function, aliased as <code>"a98-rgb-linear"</code>.
|
|
426
|
+
*/
|
|
427
|
+
declare const A98RGBLinear: ColorSpace;
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* The Adobe RGB (1998) color space, with a transfer function, aliased as <code>"a98-rgb"</code>. Inherits from the {@link A98RGBLinear} color space.
|
|
431
|
+
*/
|
|
432
|
+
declare const A98RGB: ColorSpace;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* A color gamut for the {@link A98RGB}, or Adobe RGB (1998), color space.
|
|
436
|
+
*/
|
|
437
|
+
declare const A98RGBGamut: ColorGamut;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* The Display-P3 color space in linear form, without a transfer function, aliased as <code>"display-p3-linear"</code>.
|
|
441
|
+
*/
|
|
442
|
+
declare const DisplayP3Linear: ColorSpace;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* The Display-P3 color space, with a transfer function, aliased as <code>"display-p3"</code>. Inherits from the {@link DisplayP3Linear} color space.
|
|
446
|
+
*/
|
|
447
|
+
declare const DisplayP3: ColorSpace;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* A color gamut for the {@link DisplayP3} color space.
|
|
451
|
+
*/
|
|
452
|
+
declare const DisplayP3Gamut: ColorGamut;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The OKLab color space.
|
|
456
|
+
*/
|
|
457
|
+
declare const OKLab: ColorSpace;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The OKLCH color space, with Lightness, Chroma, and Hue components. This is the cylindrical form of the {@link OKLab} color space.
|
|
461
|
+
*/
|
|
462
|
+
declare const OKLCH: ColorSpace;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* An implementation of the OKHSL color space, fixed to the {@link sRGBGamut}. This is useful for color pickers and other applications where
|
|
466
|
+
* you wish to work with components in a well-defined and enclosed cylindrical form. If you wish to use OKHSL with a different gamut, you'll
|
|
467
|
+
* need to use the {@link OKHSLToOKLab} and {@link OKLabToOKHSL} methods directly, passing your desired gamut.
|
|
468
|
+
*/
|
|
469
|
+
declare const OKHSL: ColorSpace;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* An implementation of the OKHSV color space, fixed to the {@link sRGBGamut}. This is useful for color pickers and other applications where
|
|
473
|
+
* you wish to work with components in a well-defined and enclosed cylindrical form. If you wish to use OKHSL with a different gamut, you'll
|
|
474
|
+
* need to use the {@link OKHSLToOKLab} and {@link OKLabToOKHSL} methods directly, passing your desired gamut.
|
|
475
|
+
*/
|
|
476
|
+
declare const OKHSV: ColorSpace;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The ProPhotoRGB color space in linear form, without a transfer function, aliased as <code>"prophoto-rgb-linear"</code>.
|
|
480
|
+
*/
|
|
481
|
+
declare const ProPhotoRGBLinear: ColorSpace;
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* The ProPhotoRGB color space, with a transfer function, aliased as <code>"prophoto-rgb"</code>. Inherits from the {@link ProPhotoRGBLinear} color space.
|
|
485
|
+
*/
|
|
486
|
+
declare const ProPhotoRGB: ColorSpace;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The Rec2020 color space in linear form, without a transfer function, aliased as <code>"rec2020-linear"</code>.
|
|
490
|
+
*/
|
|
491
|
+
declare const Rec2020Linear: ColorSpace;
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* The Rec2020 color space, with a transfer function, aliased as <code>"rec2020"</code>. Inherits from the {@link Rec2020Linear} color space.
|
|
495
|
+
*/
|
|
496
|
+
declare const Rec2020: ColorSpace;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* A color gamut for the {@link Rec2020} color space.
|
|
500
|
+
*/
|
|
501
|
+
declare const Rec2020Gamut: ColorGamut;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* The sRGB color space in linear form, without a transfer function, aliased as <code>"srgb-linear"</code>.
|
|
505
|
+
*/
|
|
506
|
+
declare const sRGBLinear: ColorSpace;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* The sRGB color space, with a transfer function, aliased as <code>"srgb"</code>. Inherits from the {@link sRGBLinear} color space.
|
|
510
|
+
*/
|
|
511
|
+
declare const sRGB: ColorSpace;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* A color gamut for the {@link sRGB} color space.
|
|
515
|
+
*/
|
|
516
|
+
declare const sRGBGamut: ColorGamut;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Converts a single sRGB gamma-corrected channel value to linear light (un-companded) form.
|
|
520
|
+
* @param val - The sRGB gamma-corrected channel value in the range [0, 1].
|
|
521
|
+
* @returns The linear light channel value.
|
|
522
|
+
*/
|
|
523
|
+
declare function sRGBGammaToLinear(val: number): number;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Converts a single linear-light channel value to sRGB gamma-corrected form.
|
|
527
|
+
* @param val - The linear-light channel value in the range [0, 1].
|
|
528
|
+
* @returns The sRGB gamma-corrected channel value.
|
|
529
|
+
*/
|
|
530
|
+
declare function sRGBLinearToGamma(val: number): number;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Converts a color from XYZ with D65 whitepoint to XYZ with D50 whitepoint.
|
|
534
|
+
* @param XYZ - The input color in XYZ with D65 whitepoint.
|
|
535
|
+
* @param [out = vec3()] - The output color in XYZ with D50 whitepoint.
|
|
536
|
+
* @returns The converted color in XYZ with D50 whitepoint.
|
|
537
|
+
*/
|
|
538
|
+
declare function XYZD65ToD50(XYZ: Vector, out?: Vector): Vector;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Converts a color from XYZ with D50 whitepoint to XYZ with D65 whitepoint.
|
|
542
|
+
* @param XYZ - The input color in XYZ with D50 whitepoint.
|
|
543
|
+
* @param [out = vec3()] - The output color in XYZ with D65 whitepoint.
|
|
544
|
+
* @returns The converted color in XYZ with D65 whitepoint.
|
|
545
|
+
*/
|
|
546
|
+
declare function XYZD50ToD65(XYZ: Vector, out?: Vector): Vector;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* XYZ color space with D65 whitepoint, aliased as <code>"xyz"</code>.
|
|
550
|
+
*/
|
|
551
|
+
declare const XYZ: ColorSpace;
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* XYZ color space with D50 whitepoint, aliased as <code>"xyz-d50"</code>.
|
|
555
|
+
*/
|
|
556
|
+
declare const XYZD50: ColorSpace;
|
package/test/almost-equal.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const EPSILON = Math.pow(2, -33); // ~= 0.0000000001
|
|
2
|
-
|
|
3
|
-
export default function arrayAlmostEqual(a, b, tolerance = EPSILON) {
|
|
4
|
-
if (!a || !b) return false;
|
|
5
|
-
if (a.length !== b.length) return false;
|
|
6
|
-
for (let i = 0; i < a.length; i++) {
|
|
7
|
-
const p0 = a[i];
|
|
8
|
-
const p1 = b[i];
|
|
9
|
-
if (p0 !== p1) {
|
|
10
|
-
const diff = Math.abs(p1 - p0);
|
|
11
|
-
if (diff > tolerance) return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
package/test/banner.png
DELETED
|
Binary file
|