precise-colors 0.9.7 → 0.9.8
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/README.md +89 -2
- package/dist/index.cjs +39 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +319 -29
- package/dist/index.d.ts +319 -29
- package/dist/index.js +39 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,133 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CMYK color model (Cyan, Magenta, Yellow, Key/Black).
|
|
3
|
+
* @property {number} c - Cyan `[0..100]`
|
|
4
|
+
* @property {number} m - Magenta `[0..100]`
|
|
5
|
+
* @property {number} y - Yellow `[0..100]`
|
|
6
|
+
* @property {number} k - Key/Black `[0..100]`
|
|
7
|
+
* @see {@link https://en.wikipedia.org/wiki/CMYK_color_model|Wikipedia}
|
|
8
|
+
*/
|
|
1
9
|
interface Cmyk {
|
|
2
|
-
/** [0..100] */
|
|
10
|
+
/** Cyan `[0..100]` */
|
|
3
11
|
readonly c: number;
|
|
4
|
-
/** [0..100] */
|
|
12
|
+
/** Magenta `[0..100]` */
|
|
5
13
|
readonly m: number;
|
|
6
|
-
/** [0..100] */
|
|
14
|
+
/** Yellow `[0..100]` */
|
|
7
15
|
readonly y: number;
|
|
8
|
-
/** [0..100] */
|
|
16
|
+
/** Key/Black `[0..100]` */
|
|
9
17
|
readonly k: number;
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Apple 16-bit RGB color.
|
|
21
|
+
* @property {number} r16 - Red `[0..65535]`
|
|
22
|
+
* @property {number} g16 - Green `[0..65535]`
|
|
23
|
+
* @property {number} b16 - Blue `[0..65535]`
|
|
24
|
+
* @see {@link https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ConvertRGBtoHTMLColor.html|Apple RGB}
|
|
25
|
+
*/
|
|
11
26
|
interface Apple {
|
|
27
|
+
/** Red `[0..65535]` */
|
|
12
28
|
readonly r16: number;
|
|
29
|
+
/** Green `[0..65535]` */
|
|
13
30
|
readonly g16: number;
|
|
31
|
+
/** Blue `[0..65535]` */
|
|
14
32
|
readonly b16: number;
|
|
15
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* sRGB color model (8-bit per channel).
|
|
36
|
+
* @property {number} r - Red `[0..255]`
|
|
37
|
+
* @property {number} g - Green `[0..255]`
|
|
38
|
+
* @property {number} b - Blue `[0..255]`
|
|
39
|
+
* @see {@link https://www.color.org/srgb.pdf|ICC sRGB Specification}
|
|
40
|
+
*/
|
|
16
41
|
interface Rgb {
|
|
17
|
-
/** [0..255] */
|
|
42
|
+
/** Red `[0..255]` */
|
|
18
43
|
readonly r: number;
|
|
19
|
-
/** [0..255] */
|
|
44
|
+
/** Green `[0..255]` */
|
|
20
45
|
readonly g: number;
|
|
21
|
-
/** [0..255] */
|
|
46
|
+
/** Blue `[0..255]` */
|
|
22
47
|
readonly b: number;
|
|
23
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* HSL cylindrical color model (Hue, Saturation, Lightness).
|
|
51
|
+
* @property {number} h - Hue `[0..360]`
|
|
52
|
+
* @property {number} s - Saturation `[0..100]`
|
|
53
|
+
* @property {number} l - Lightness `[0..100]`
|
|
54
|
+
* @see {@link https://www.w3.org/TR/css-color-4/#the-hsl-notation|W3C CSS Color 4}
|
|
55
|
+
*/
|
|
24
56
|
interface Hsl {
|
|
57
|
+
/** Hue angle `[0..360]` */
|
|
25
58
|
readonly h: number;
|
|
59
|
+
/** Saturation `[0..100]` */
|
|
26
60
|
readonly s: number;
|
|
61
|
+
/** Lightness `[0..100]` */
|
|
27
62
|
readonly l: number;
|
|
28
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* HSV/HSB cylindrical color model (Hue, Saturation, Value/Brightness).
|
|
66
|
+
* @property {number} h - Hue `[0..360]`
|
|
67
|
+
* @property {number} s - Saturation `[0..100]`
|
|
68
|
+
* @property {number} v - Value `[0..100]`
|
|
69
|
+
* @see {@link https://en.wikipedia.org/wiki/HSL_and_HSV|Wikipedia}
|
|
70
|
+
*/
|
|
29
71
|
interface Hsv {
|
|
72
|
+
/** Hue angle `[0..360]` */
|
|
30
73
|
readonly h: number;
|
|
74
|
+
/** Saturation `[0..100]` */
|
|
31
75
|
readonly s: number;
|
|
76
|
+
/** Value/Brightness `[0..100]` */
|
|
32
77
|
readonly v: number;
|
|
33
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* HCG color model (Hue, Chroma, Grayness).
|
|
81
|
+
* Derived from the Munsell color system.
|
|
82
|
+
* @property {number} h - Hue `[0..360]`
|
|
83
|
+
* @property {number} c - Chroma `[0..100]`
|
|
84
|
+
* @property {number} g - Grayness `[0..100]`
|
|
85
|
+
* @see {@link https://github.com/d3/d3-hcg|d3-hcg}
|
|
86
|
+
*/
|
|
34
87
|
interface Hcg {
|
|
88
|
+
/** Hue angle `[0..360]` */
|
|
35
89
|
readonly h: number;
|
|
90
|
+
/** Chroma `[0..100]` */
|
|
36
91
|
readonly c: number;
|
|
92
|
+
/** Grayness `[0..100]` */
|
|
37
93
|
readonly g: number;
|
|
38
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* HWB color model (Hue, Whiteness, Blackness).
|
|
97
|
+
* @property {number} h - Hue `[0..360]`
|
|
98
|
+
* @property {number} w - Whiteness `[0..100]`
|
|
99
|
+
* @property {number} b - Blackness `[0..100]`
|
|
100
|
+
* @see {@link https://www.w3.org/TR/css-color-4/#the-hwb-notation|W3C CSS Color 4}
|
|
101
|
+
*/
|
|
39
102
|
interface Hwb {
|
|
40
|
-
/** Hue [0..360] */
|
|
103
|
+
/** Hue angle `[0..360]` */
|
|
41
104
|
readonly h: number;
|
|
42
|
-
/** Whiteness [0..100] */
|
|
105
|
+
/** Whiteness `[0..100]` */
|
|
43
106
|
readonly w: number;
|
|
44
|
-
/** Blackness [0..100] */
|
|
107
|
+
/** Blackness `[0..100]` */
|
|
45
108
|
readonly b: number;
|
|
46
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* CIE L*a*b* perceptual color space (1976).
|
|
112
|
+
* a* and b* are theoretically unbounded but clamped to `[-128..127]` for 8-bit storage.
|
|
113
|
+
* @property {number} l - Lightness `[0..100]`
|
|
114
|
+
* @property {number} a - Green-Red axis `[-128..127]`
|
|
115
|
+
* @property {number} b - Blue-Yellow axis `[-128..127]`
|
|
116
|
+
* @see {@link https://en.wikipedia.org/wiki/CIELAB_color_space|Wikipedia}
|
|
117
|
+
* @see {@link https://www.w3.org/TR/css-color-4/#lab-colors|W3C CSS Color 4}
|
|
118
|
+
*/
|
|
47
119
|
interface Lab {
|
|
120
|
+
/** Lightness `[0..100]` */
|
|
48
121
|
readonly l: number;
|
|
122
|
+
/** Green (-) to Red (+) axis. Clamped `[-128..127]`, theoretical `~[-430..+172]` */
|
|
49
123
|
readonly a: number;
|
|
124
|
+
/** Blue (-) to Yellow (+) axis. Clamped `[-128..127]`, theoretically unbounded */
|
|
50
125
|
readonly b: number;
|
|
51
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* CIE XYZ tristimulus color space with D65 illuminant.
|
|
129
|
+
* @property {number} x - X tristimulus `[0..95.047]`
|
|
130
|
+
* @property {number} y - Y luminance `[0..100]`
|
|
131
|
+
* @property {number} z - Z tristimulus `[0..108.883]`
|
|
132
|
+
* @see {@link https://en.wikipedia.org/wiki/CIE_1931_color_space|Wikipedia CIE 1931}
|
|
133
|
+
* @see {@link https://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D|D65 Illuminant}
|
|
134
|
+
*/
|
|
52
135
|
interface Xyz {
|
|
136
|
+
/** X tristimulus `[0..95.047]` for D65 white */
|
|
53
137
|
readonly x: number;
|
|
138
|
+
/** Y tristimulus (luminance) `[0..100]` */
|
|
54
139
|
readonly y: number;
|
|
140
|
+
/** Z tristimulus `[0..108.883]` for D65 white */
|
|
55
141
|
readonly z: number;
|
|
56
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* XYZ values from Lab conversion (named Lyz to avoid confusion).
|
|
145
|
+
* Uses D65 illuminant reference white.
|
|
146
|
+
* @property {number} l - X tristimulus `[0..95.047]`
|
|
147
|
+
* @property {number} y - Y luminance `[0..100]`
|
|
148
|
+
* @property {number} z - Z tristimulus `[0..108.883]`
|
|
149
|
+
* @see {@link https://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D|D65 Illuminant}
|
|
150
|
+
*/
|
|
57
151
|
interface Lyz {
|
|
152
|
+
/** X tristimulus `[0..95.047]` for D65 */
|
|
58
153
|
readonly l: number;
|
|
154
|
+
/** Y tristimulus `[0..100]` */
|
|
59
155
|
readonly y: number;
|
|
156
|
+
/** Z tristimulus `[0..108.883]` for D65 */
|
|
60
157
|
readonly z: number;
|
|
61
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* CIE LCH cylindrical color space (Lightness, Chroma, Hue).
|
|
161
|
+
* Polar representation of L*a*b*.
|
|
162
|
+
* @property {number} l - Lightness `[0..100]`
|
|
163
|
+
* @property {number} c - Chroma `[0..~230]`
|
|
164
|
+
* @property {number} h - Hue `[0..360]`
|
|
165
|
+
* @see {@link https://en.wikipedia.org/wiki/CIELAB_color_space#Cylindrical_model|Wikipedia}
|
|
166
|
+
* @see {@link https://www.w3.org/TR/css-color-4/#lch-colors|W3C CSS Color 4}
|
|
167
|
+
*/
|
|
62
168
|
interface Lch {
|
|
169
|
+
/** Lightness `[0..100]` */
|
|
63
170
|
readonly l: number;
|
|
171
|
+
/** Chroma `[0..~230]`. Theoretically unbounded, sRGB max ~131 */
|
|
64
172
|
readonly c: number;
|
|
173
|
+
/** Hue angle `[0..360]` */
|
|
65
174
|
readonly h: number;
|
|
66
175
|
}
|
|
67
|
-
/**
|
|
176
|
+
/**
|
|
177
|
+
* Rounds a number to specified decimal places.
|
|
178
|
+
* Uses exponential notation to avoid floating-point errors
|
|
179
|
+
* (e.g., `1.005 * 100 = 100.49999...` but `roundTo(1.005, 2) = 1.01`).
|
|
180
|
+
* @param num - Number to round
|
|
181
|
+
* @param places - Decimal places `[0..]`
|
|
182
|
+
* @returns Rounded number
|
|
183
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed|Number.toFixed} for string output
|
|
184
|
+
*/
|
|
68
185
|
declare function roundTo(num: number, places: number): number;
|
|
186
|
+
/**
|
|
187
|
+
* Modulo operation that always returns positive result.
|
|
188
|
+
* @param x - Dividend
|
|
189
|
+
* @param n - Divisor
|
|
190
|
+
* @returns `x mod n`, always positive
|
|
191
|
+
*/
|
|
69
192
|
declare function modulo(x: number, n: number): number;
|
|
70
193
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @returns {string} `"rgb(r,g,b)"` representation of passed {@link Rgb} instance.
|
|
194
|
+
* Converts {@link Rgb} to CSS rgb() string.
|
|
195
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
196
|
+
* @returns CSS string `"rgb(r,g,b)"` (rounded)
|
|
75
197
|
*/
|
|
76
198
|
declare function rgb2css(rgb: Rgb): string;
|
|
77
199
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param {Rgb}
|
|
80
|
-
* @returns
|
|
200
|
+
* Converts {@link Rgb} to comma-separated string.
|
|
201
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
202
|
+
* @returns String `"r,g,b"` (rounded)
|
|
81
203
|
*/
|
|
82
204
|
declare function rgb2str(rgb: Rgb): string;
|
|
83
205
|
/**
|
|
84
|
-
* Converts {@link Rgb} and
|
|
85
|
-
*
|
|
86
|
-
* @param
|
|
87
|
-
* @
|
|
88
|
-
* @returns {string} `"rgb(r,g,b,a)"` representation of passed {@link Rgb} instance and `alpha`.
|
|
206
|
+
* Converts {@link Rgb} and alpha to CSS rgba() string.
|
|
207
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
208
|
+
* @param alpha - Alpha `[0..1]`
|
|
209
|
+
* @returns CSS string `"rgba(r,g,b,a)"` (rounded)
|
|
89
210
|
*/
|
|
90
211
|
declare function rgba2css(rgb: Rgb, alpha: number): string;
|
|
91
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* Converts {@link Hsl} to CSS hsl() string.
|
|
214
|
+
* @param hsl - {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
215
|
+
* @returns CSS string `"hsl(hdeg,s%,l%)"` (rounded to 2 decimals)
|
|
216
|
+
*/
|
|
92
217
|
declare function hsl2css(hsl: Hsl): string;
|
|
93
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* Converts {@link Hwb} to CSS hwb() string.
|
|
220
|
+
* @param hwb - {@link Hwb} color, h `[0..360]`, w/b `[0..100]`
|
|
221
|
+
* @returns CSS string `"hwb(hdeg,w%,b%)"` (rounded to 2 decimals)
|
|
222
|
+
*/
|
|
94
223
|
declare function hwb2css(hwb: Hwb): string;
|
|
95
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Converts {@link Rgb} to 6-digit hex string (without #).
|
|
226
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
227
|
+
* @returns Hex string `"rrggbb"` (rounded)
|
|
228
|
+
*/
|
|
96
229
|
declare function rgb2hex(rgb: Rgb): string;
|
|
97
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Converts gray value to 6-digit hex string.
|
|
232
|
+
* @param gray - Gray level `[0..100]`
|
|
233
|
+
* @returns Hex string `"gggggg"` (rounded)
|
|
234
|
+
*/
|
|
98
235
|
declare function gray2hex(gray: number): string;
|
|
236
|
+
/**
|
|
237
|
+
* Parses hex string to {@link Rgb}.
|
|
238
|
+
* @param input - Hex string (6 digits, without #)
|
|
239
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]`
|
|
240
|
+
*/
|
|
99
241
|
declare function hex2rgb(input: string): Rgb;
|
|
100
|
-
/**
|
|
242
|
+
/**
|
|
243
|
+
* Converts {@link Hsl} to {@link Rgb}.
|
|
244
|
+
* @param hsl - {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
245
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]` (not rounded)
|
|
246
|
+
*/
|
|
101
247
|
declare function hsl2rgb(hsl: Hsl): Rgb;
|
|
102
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* Converts {@link Hsl} to {@link Hsv}.
|
|
250
|
+
* @param hsl - {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
251
|
+
* @returns {@link Hsv} color, h `[0..360]`, s/v `[0..100]`
|
|
252
|
+
*/
|
|
103
253
|
declare function hsl2hsv(hsl: Hsl): Hsv;
|
|
254
|
+
/**
|
|
255
|
+
* Converts {@link Hsl} to {@link Hcg}.
|
|
256
|
+
* @param hsl - {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
257
|
+
* @returns {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
258
|
+
*/
|
|
104
259
|
declare function hsl2hcg(hsl: Hsl): Hcg;
|
|
260
|
+
/**
|
|
261
|
+
* Converts {@link Hsv} to {@link Rgb}.
|
|
262
|
+
* @param hsv - {@link Hsv} color, h `[0..360]`, s/v `[0..100]`
|
|
263
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]` (not rounded)
|
|
264
|
+
*/
|
|
105
265
|
declare function hsv2rgb(hsv: Hsv): Rgb;
|
|
266
|
+
/**
|
|
267
|
+
* Converts {@link Hsv} to {@link Hsl}.
|
|
268
|
+
* @param hsv - {@link Hsv} color, h `[0..360]`, s/v `[0..100]`
|
|
269
|
+
* @returns {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
270
|
+
*/
|
|
106
271
|
declare function hsv2hsl(hsv: Hsv): Hsl;
|
|
272
|
+
/**
|
|
273
|
+
* Converts {@link Hsv} to {@link Hcg}.
|
|
274
|
+
* @param hsv - {@link Hsv} color, h `[0..360]`, s/v `[0..100]`
|
|
275
|
+
* @returns {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
276
|
+
*/
|
|
107
277
|
declare function hsv2hcg(hsv: Hsv): Hcg;
|
|
278
|
+
/**
|
|
279
|
+
* Converts {@link Apple} 16-bit RGB to 8-bit {@link Rgb}.
|
|
280
|
+
* @param rgb16 - {@link Apple} color, r16/g16/b16 `[0..65535]`
|
|
281
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]`
|
|
282
|
+
*/
|
|
108
283
|
declare function apple2rgb(rgb16: Apple): Rgb;
|
|
284
|
+
/**
|
|
285
|
+
* Converts {@link Cmyk} to {@link Rgb}.
|
|
286
|
+
* @param cmyk - {@link Cmyk} color, c/m/y/k `[0..100]`
|
|
287
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]`
|
|
288
|
+
*/
|
|
109
289
|
declare function cmyk2rgb(cmyk: Cmyk): Rgb;
|
|
290
|
+
/**
|
|
291
|
+
* Converts {@link Rgb} to {@link Cmyk}.
|
|
292
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
293
|
+
* @returns {@link Cmyk} color, c/m/y/k `[0..100]`
|
|
294
|
+
*/
|
|
110
295
|
declare function rgb2cmyk(rgb: Rgb): Cmyk;
|
|
296
|
+
/**
|
|
297
|
+
* Converts {@link Rgb} to {@link Hsl}.
|
|
298
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
299
|
+
* @returns {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
300
|
+
*/
|
|
111
301
|
declare function rgb2hsl(rgb: Rgb): Hsl;
|
|
302
|
+
/**
|
|
303
|
+
* Converts {@link Rgb} to {@link Hwb}.
|
|
304
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
305
|
+
* @returns {@link Hwb} color, h `[0..360]`, w/b `[0..100]`
|
|
306
|
+
*/
|
|
112
307
|
declare function rgb2hwb(rgb: Rgb): Hwb;
|
|
308
|
+
/**
|
|
309
|
+
* Converts {@link Hwb} to {@link Rgb}.
|
|
310
|
+
* @param hwb - {@link Hwb} color, h `[0..360]`, w/b `[0..100]`
|
|
311
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]` (not rounded)
|
|
312
|
+
*/
|
|
113
313
|
declare function hwb2rgb(hwb: Hwb): Rgb;
|
|
314
|
+
/**
|
|
315
|
+
* Converts {@link Hwb} to {@link Hcg}.
|
|
316
|
+
* @param hwb - {@link Hwb} color, h `[0..360]`, w/b `[0..100]`
|
|
317
|
+
* @returns {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
318
|
+
*/
|
|
114
319
|
declare function hwb2hcg(hwb: Hwb): Hcg;
|
|
320
|
+
/**
|
|
321
|
+
* Converts {@link Hcg} to {@link Rgb}.
|
|
322
|
+
* @param hcg - {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
323
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]` (not rounded)
|
|
324
|
+
*/
|
|
115
325
|
declare function hcg2rgb(hcg: Hcg): Rgb;
|
|
326
|
+
/**
|
|
327
|
+
* Converts {@link Hcg} to {@link Hsv}.
|
|
328
|
+
* @param hcg - {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
329
|
+
* @returns {@link Hsv} color, h `[0..360]`, s/v `[0..100]`
|
|
330
|
+
*/
|
|
116
331
|
declare function hcg2hsv(hcg: Hcg): Hsv;
|
|
332
|
+
/**
|
|
333
|
+
* Converts {@link Hcg} to {@link Hsl}.
|
|
334
|
+
* @param hcg - {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
335
|
+
* @returns {@link Hsl} color, h `[0..360]`, s/l `[0..100]`
|
|
336
|
+
*/
|
|
117
337
|
declare function hcg2hsl(hcg: Hcg): Hsl;
|
|
338
|
+
/**
|
|
339
|
+
* Converts {@link Hcg} to {@link Hwb}.
|
|
340
|
+
* @param hcg - {@link Hcg} color, h `[0..360]`, c/g `[0..100]`
|
|
341
|
+
* @returns {@link Hwb} color, h `[0..360]`, w/b `[0..100]`
|
|
342
|
+
*/
|
|
118
343
|
declare function hcg2hwb(hcg: Hcg): Hwb;
|
|
344
|
+
/**
|
|
345
|
+
* Converts gray to {@link Rgb}.
|
|
346
|
+
* @param gray - Gray level `[0..100]`
|
|
347
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]`
|
|
348
|
+
*/
|
|
119
349
|
declare function gray2rgb(gray: number): Rgb;
|
|
350
|
+
/**
|
|
351
|
+
* Converts gray to {@link Hsl}.
|
|
352
|
+
* @param gray - Gray level `[0..100]`
|
|
353
|
+
* @returns {@link Hsl} color, h=0, s=0, l=gray
|
|
354
|
+
*/
|
|
120
355
|
declare function gray2hsl(gray: number): Hsl;
|
|
356
|
+
/**
|
|
357
|
+
* Converts gray to {@link Hsv}.
|
|
358
|
+
* @param gray - Gray level `[0..100]`
|
|
359
|
+
* @returns {@link Hsv} color, h=0, s=0, v=gray
|
|
360
|
+
*/
|
|
121
361
|
declare function gray2hsv(gray: number): Hsv;
|
|
362
|
+
/**
|
|
363
|
+
* Converts gray to {@link Hwb}.
|
|
364
|
+
* @param gray - Gray level `[0..100]`
|
|
365
|
+
* @returns {@link Hwb} color, h=0, w=gray, b=100-gray
|
|
366
|
+
*/
|
|
122
367
|
declare function gray2hwb(gray: number): Hwb;
|
|
368
|
+
/**
|
|
369
|
+
* Converts gray to {@link Cmyk}.
|
|
370
|
+
* @param gray - Gray level `[0..100]`
|
|
371
|
+
* @returns {@link Cmyk} color, c=0, m=0, y=0, k=gray
|
|
372
|
+
*/
|
|
123
373
|
declare function gray2cmyk(gray: number): Cmyk;
|
|
374
|
+
/**
|
|
375
|
+
* Converts gray to {@link Lab}.
|
|
376
|
+
* @param gray - Gray level `[0..100]`
|
|
377
|
+
* @returns {@link Lab} color, l=gray, a=0, b=0
|
|
378
|
+
*/
|
|
124
379
|
declare function gray2lab(gray: number): Lab;
|
|
380
|
+
/**
|
|
381
|
+
* Converts {@link Rgb} to {@link Lab}.
|
|
382
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
383
|
+
* @returns {@link Lab} color, l `[0..100]`, a/b `[-128..127]`
|
|
384
|
+
*/
|
|
125
385
|
declare function rgb2lab(rgb: Rgb): Lab;
|
|
386
|
+
/**
|
|
387
|
+
* Converts {@link Lab} to {@link Lyz} (XYZ values).
|
|
388
|
+
* @param lab - {@link Lab} color, l `[0..100]`, a/b `[-128..127]`
|
|
389
|
+
* @returns {@link Lyz} color, l `[0..95.047]`, y `[0..100]`, z `[0..108.883]`
|
|
390
|
+
*/
|
|
126
391
|
declare function lab2lyz(lab: Lab): Lyz;
|
|
392
|
+
/**
|
|
393
|
+
* Converts {@link Lab} to {@link Lch}.
|
|
394
|
+
* @param lab - {@link Lab} color, l `[0..100]`, a/b `[-128..127]`
|
|
395
|
+
* @returns {@link Lch} color, l `[0..100]`, c `[0..~230]`, h `[0..360]`
|
|
396
|
+
*/
|
|
127
397
|
declare function lab2lch(lab: Lab): Lch;
|
|
398
|
+
/**
|
|
399
|
+
* Converts {@link Lch} to {@link Lab}.
|
|
400
|
+
* @param lch - {@link Lch} color, l `[0..100]`, c `[0..~230]`, h `[0..360]`
|
|
401
|
+
* @returns {@link Lab} color, l `[0..100]`, a/b `[-128..127]`
|
|
402
|
+
*/
|
|
128
403
|
declare function lch2lab(lch: Lch): Lab;
|
|
404
|
+
/**
|
|
405
|
+
* Converts {@link Xyz} to {@link Rgb}.
|
|
406
|
+
* @param xyz - {@link Xyz} color, x `[0..95.047]`, y `[0..100]`, z `[0..108.883]`
|
|
407
|
+
* @returns {@link Rgb} color, r/g/b `[0..255]`
|
|
408
|
+
*/
|
|
129
409
|
declare function xyz2rgb(xyz: Xyz): Rgb;
|
|
410
|
+
/**
|
|
411
|
+
* Converts {@link Xyz} to {@link Lab}.
|
|
412
|
+
* @param xyz - {@link Xyz} color, x `[0..95.047]`, y `[0..100]`, z `[0..108.883]`
|
|
413
|
+
* @returns {@link Lab} color, l `[0..100]`, a/b `[-128..127]`
|
|
414
|
+
*/
|
|
130
415
|
declare function xyz2lab(xyz: Xyz): Lab;
|
|
416
|
+
/**
|
|
417
|
+
* Converts {@link Rgb} to {@link Xyz}.
|
|
418
|
+
* @param rgb - {@link Rgb} color, r/g/b `[0..255]`
|
|
419
|
+
* @returns {@link Xyz} color, x `[0..95.047]`, y `[0..100]`, z `[0..108.883]`
|
|
420
|
+
*/
|
|
131
421
|
declare function rgb2xyz(rgb: Rgb): Xyz;
|
|
132
422
|
|
|
133
423
|
export { type Apple, type Cmyk, type Hcg, type Hsl, type Hsv, type Hwb, type Lab, type Lch, type Lyz, type Rgb, type Xyz, apple2rgb, cmyk2rgb, gray2cmyk, gray2hex, gray2hsl, gray2hsv, gray2hwb, gray2lab, gray2rgb, hcg2hsl, hcg2hsv, hcg2hwb, hcg2rgb, hex2rgb, hsl2css, hsl2hcg, hsl2hsv, hsl2rgb, hsv2hcg, hsv2hsl, hsv2rgb, hwb2css, hwb2hcg, hwb2rgb, lab2lch, lab2lyz, lch2lab, modulo, rgb2cmyk, rgb2css, rgb2hex, rgb2hsl, rgb2hwb, rgb2lab, rgb2str, rgb2xyz, rgba2css, roundTo, xyz2lab, xyz2rgb };
|