@rickosborne/hue 2025.2.16
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 +774 -0
- package/color-comparator.cjs +90 -0
- package/color-comparator.cjs.map +6 -0
- package/color-comparator.d.ts +26 -0
- package/color-comparator.d.ts.map +1 -0
- package/color-comparator.mjs +71 -0
- package/color-comparator.mjs.map +6 -0
- package/color-conversion-error.cjs +36 -0
- package/color-conversion-error.cjs.map +6 -0
- package/color-conversion-error.d.ts +10 -0
- package/color-conversion-error.d.ts.map +1 -0
- package/color-conversion-error.mjs +17 -0
- package/color-conversion-error.mjs.map +6 -0
- package/color-conversion.cjs +222 -0
- package/color-conversion.cjs.map +6 -0
- package/color-conversion.d.ts +25 -0
- package/color-conversion.d.ts.map +1 -0
- package/color-conversion.mjs +203 -0
- package/color-conversion.mjs.map +6 -0
- package/color-from-css.cjs +131 -0
- package/color-from-css.cjs.map +6 -0
- package/color-from-css.d.ts +8 -0
- package/color-from-css.d.ts.map +1 -0
- package/color-from-css.mjs +112 -0
- package/color-from-css.mjs.map +6 -0
- package/color.cjs +226 -0
- package/color.cjs.map +6 -0
- package/color.d.ts +66 -0
- package/color.d.ts.map +1 -0
- package/color.mjs +207 -0
- package/color.mjs.map +6 -0
- package/hsl.cjs +58 -0
- package/hsl.cjs.map +6 -0
- package/hsl.d.ts +24 -0
- package/hsl.d.ts.map +1 -0
- package/hsl.mjs +39 -0
- package/hsl.mjs.map +6 -0
- package/hsv.cjs +58 -0
- package/hsv.cjs.map +6 -0
- package/hsv.d.ts +24 -0
- package/hsv.d.ts.map +1 -0
- package/hsv.mjs +39 -0
- package/hsv.mjs.map +6 -0
- package/index.cjs +27 -0
- package/index.cjs.map +6 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.mjs +10 -0
- package/index.mjs.map +6 -0
- package/numbers.cjs +25 -0
- package/numbers.cjs.map +6 -0
- package/numbers.d.ts +2 -0
- package/numbers.d.ts.map +1 -0
- package/numbers.mjs +5 -0
- package/numbers.mjs.map +6 -0
- package/package.json +116 -0
- package/rgb.cjs +161 -0
- package/rgb.cjs.map +6 -0
- package/rgb.d.ts +83 -0
- package/rgb.d.ts.map +1 -0
- package/rgb.mjs +142 -0
- package/rgb.mjs.map +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
# @rickosborne/hue
|
|
2
|
+
|
|
3
|
+
Basic color manipulation utilities built on [@rickosborne/typical](https://www.npmjs.com/package/@rickosborne/typical) for types and [@rickosborne/guard](https://www.npmjs.com/package/@rickosborne/guard) for guards.
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
Install via your favorite package manager.
|
|
7
|
+
|
|
8
|
+
Each package supports CommonJS `require`, ESM `import`, and TypeScript usage.
|
|
9
|
+
|
|
10
|
+
You also have a choice: barrel imports or direct imports.
|
|
11
|
+
|
|
12
|
+
Barrel imports mean you're going to require/import everything from the same package-level namespace:
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// CommonJS
|
|
16
|
+
const { isPlainObject, isListOf } = require("@rickosborne/guard");
|
|
17
|
+
// ESM / TypeScript
|
|
18
|
+
import { isPlainObject, isListOf } from "@rickosborne/guard";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Implications:
|
|
22
|
+
|
|
23
|
+
- Nice and simple.
|
|
24
|
+
- Your build system needs to do tree-shaking well ... or you'll end up adding the entire package even if you only import two functions.
|
|
25
|
+
|
|
26
|
+
The other option is to use direct imports:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
// CommonJS
|
|
30
|
+
const { isPlainObject } = require("@rickosborne/guard/is-object");
|
|
31
|
+
const { isListOf } = require("@rickosborne/guard/is-list-of");
|
|
32
|
+
// ESM / TypeScript
|
|
33
|
+
import { isPlainObject } from "@rickosborne/guard/is-object.js";
|
|
34
|
+
import { isListOf } from "@rickosborne/guard/is-list-of.js";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Implications:
|
|
38
|
+
|
|
39
|
+
- You (probably) don't have to worry about tree-shaking as your build (likely) ends up with only the functions you need.
|
|
40
|
+
|
|
41
|
+
If you're using a modern build system, there aren't any strong reasons to prefer one way over the other.
|
|
42
|
+
It's really just down to your personal preference.
|
|
43
|
+
|
|
44
|
+
### A quick note about file extensions
|
|
45
|
+
|
|
46
|
+
Do you need to use file extensions?
|
|
47
|
+
And if so, which extensions?
|
|
48
|
+
|
|
49
|
+
Honestly ... this is a dumpster fire question.
|
|
50
|
+
It really comes down to your own setup and configuration.
|
|
51
|
+
|
|
52
|
+
Within each package itself:
|
|
53
|
+
|
|
54
|
+
- The CommonJS files all have `.cjs` extensions.
|
|
55
|
+
- The ESM files all have `.mjs` extensions.
|
|
56
|
+
- Node subpath exports have been set up to send `.js` imports to the `.cjs` (via `require`) or `.mjs` (via `import`) files, depending on your setup.
|
|
57
|
+
|
|
58
|
+
So, in theory, the only extension which _won't_ work would be `.ts` because the source isn't included.
|
|
59
|
+
|
|
60
|
+
If you run into a problem with a particular configuration, file a GitHub issue with:
|
|
61
|
+
|
|
62
|
+
- Your `tsconfig.json`'s `module`, `moduleResolution`, and `target` settings.
|
|
63
|
+
- Your `package.json`'s `type` and `imports` settings.
|
|
64
|
+
- An example of another package which imports correctly for you.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
This package is licensed as [CC-BY-NC-SA-4.0] unless otherwise noted.
|
|
69
|
+
That is, Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
|
|
70
|
+
|
|
71
|
+
[CC-BY-NC-SA-4.0]: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
***
|
|
75
|
+
|
|
76
|
+
## API
|
|
77
|
+
|
|
78
|
+
### Classes
|
|
79
|
+
|
|
80
|
+
#### Color
|
|
81
|
+
|
|
82
|
+
<a id="api-color"></a>
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
class Color implements ColorParts
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### ColorConversionError
|
|
89
|
+
|
|
90
|
+
<a id="api-colorconversionerror"></a>
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
class ColorConversionError extends Error
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Functions
|
|
97
|
+
|
|
98
|
+
#### chroma01FromHSL
|
|
99
|
+
|
|
100
|
+
<a id="api-chroma01fromhsl"></a>
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
function chroma01FromHSL(hsl: HSL | {
|
|
104
|
+
s: Real01;
|
|
105
|
+
l: Real01;
|
|
106
|
+
}): Real01;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### chroma01FromHSL
|
|
110
|
+
|
|
111
|
+
<a id="api-chroma01fromhsl"></a>
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
function chroma01FromHSL(hsl: HSL | {
|
|
115
|
+
s: Real01;
|
|
116
|
+
l: Real01;
|
|
117
|
+
} | undefined): Real01 | undefined;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### chroma01FromHSV
|
|
121
|
+
|
|
122
|
+
<a id="api-chroma01fromhsv"></a>
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
function chroma01FromHSV(hsv: HSV | {
|
|
126
|
+
s: Real01;
|
|
127
|
+
v: Real01;
|
|
128
|
+
}): Real01;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### chroma01FromHSV
|
|
132
|
+
|
|
133
|
+
<a id="api-chroma01fromhsv"></a>
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
function chroma01FromHSV(hsv: HSV | {
|
|
137
|
+
s: Real01;
|
|
138
|
+
v: Real01;
|
|
139
|
+
} | undefined): Real01 | undefined;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### chroma01FromRGB
|
|
143
|
+
|
|
144
|
+
<a id="api-chroma01fromrgb"></a>
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
function chroma01FromRGB(rgb: RGB255): Real01;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### chroma01FromRGB
|
|
151
|
+
|
|
152
|
+
<a id="api-chroma01fromrgb"></a>
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
function chroma01FromRGB(rgb: RGB255 | undefined): Real01 | undefined;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### chroma01FromRGB01
|
|
159
|
+
|
|
160
|
+
<a id="api-chroma01fromrgb01"></a>
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
function chroma01FromRGB01(rgb: RGB01): Real01;
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Calculate the chroma value for the given RGB, producing a real number in the range [0,1].
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
#### chroma01FromRGB01
|
|
170
|
+
|
|
171
|
+
<a id="api-chroma01fromrgb01"></a>
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
function chroma01FromRGB01(rgb: RGB01 | undefined): Real01 | undefined;
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### colorComparatorBuilder
|
|
178
|
+
|
|
179
|
+
<a id="api-colorcomparatorbuilder"></a>
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
colorComparatorBuilder: <C extends object>(fnName: string, ...keys: (keyof UnbrandedNumbers<C>)[]) => Comparator<C | undefined>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Generator for color comparators, since they all follow the same pattern of working through number values. This sorts null values after defined ones.
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
#### colorEqBuilder
|
|
189
|
+
|
|
190
|
+
<a id="api-coloreqbuilder"></a>
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
colorEqBuilder: <C extends object>(fnName: string, keys: (keyof UnbrandedNumbers<C>)[], defaultEpsilons: Record<keyof C, number>) => ColorCloseTo<C>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Generator for color equality functions, since they all follow the same pattern of iterating over keys and doing delta checks.
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
#### colorFromCSS
|
|
200
|
+
|
|
201
|
+
<a id="api-colorfromcss"></a>
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
colorFromCSS: (text: string) => Color | undefined
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Try to parse a CSS color expression. Does not support anything clever. Intended more for "I have colors in a config file" use-cases, and not "accept CSS typed in by Web users".
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
#### cssFormatHSL
|
|
211
|
+
|
|
212
|
+
<a id="api-cssformathsl"></a>
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
cssFormatHSL: (hsl: HSL) => string
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### cssFormatHSV
|
|
219
|
+
|
|
220
|
+
<a id="api-cssformathsv"></a>
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
cssFormatHSV: (hsv: HSV) => string
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
#### cssFormatRGB
|
|
227
|
+
|
|
228
|
+
<a id="api-cssformatrgb"></a>
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
cssFormatRGB: (rgb: RGB255) => string
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### hexFromRGB
|
|
235
|
+
|
|
236
|
+
<a id="api-hexfromrgb"></a>
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
hexFromRGB: (rgb: RGB255, format?: "short" | "long") => string
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### hslFromHSV
|
|
243
|
+
|
|
244
|
+
<a id="api-hslfromhsv"></a>
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
function hslFromHSV(hsv: HSV): HSL;
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### hslFromHSV
|
|
251
|
+
|
|
252
|
+
<a id="api-hslfromhsv"></a>
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
function hslFromHSV(hsv: HSV | undefined): HSL | undefined;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### hslFromRGB
|
|
259
|
+
|
|
260
|
+
<a id="api-hslfromrgb"></a>
|
|
261
|
+
|
|
262
|
+
```typescript
|
|
263
|
+
function hslFromRGB(rgb: RGB255): HSL;
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### hslFromRGB
|
|
267
|
+
|
|
268
|
+
<a id="api-hslfromrgb"></a>
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
function hslFromRGB(rgb: RGB255 | undefined): HSL | undefined;
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### hslFromRGB01
|
|
275
|
+
|
|
276
|
+
<a id="api-hslfromrgb01"></a>
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
function hslFromRGB01(rgba01: RGBA01): HSLA;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### hslFromRGB01
|
|
283
|
+
|
|
284
|
+
<a id="api-hslfromrgb01"></a>
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
function hslFromRGB01(rgb01: RGB01): HSL;
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### hslFromRGB01
|
|
291
|
+
|
|
292
|
+
<a id="api-hslfromrgb01"></a>
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
function hslFromRGB01(rgb01: RGB01 | undefined): HSL | undefined;
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### hsvFromHSL
|
|
299
|
+
|
|
300
|
+
<a id="api-hsvfromhsl"></a>
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
function hsvFromHSL(hsl: HSL): HSV;
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### hsvFromHSL
|
|
307
|
+
|
|
308
|
+
<a id="api-hsvfromhsl"></a>
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
function hsvFromHSL(hsl: HSL | undefined): HSV | undefined;
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
#### hsvFromRGB
|
|
315
|
+
|
|
316
|
+
<a id="api-hsvfromrgb"></a>
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
function hsvFromRGB(rgb: RGB255): HSV;
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### hsvFromRGB
|
|
323
|
+
|
|
324
|
+
<a id="api-hsvfromrgb"></a>
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
function hsvFromRGB(rgb: RGB255 | undefined): HSV | undefined;
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
#### hue360FromRGB
|
|
331
|
+
|
|
332
|
+
<a id="api-hue360fromrgb"></a>
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
function hue360FromRGB(rgb: RGB255, chroma01?: Real01 | undefined, max255?: Int255 | Real255 | undefined): Int360;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### hue360FromRGB
|
|
339
|
+
|
|
340
|
+
<a id="api-hue360fromrgb"></a>
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
function hue360FromRGB(rgb: RGB255 | undefined, chroma01?: Real01 | undefined, max255?: Int255 | Real255 | undefined): Int360 | undefined;
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### hue360FromRGB01
|
|
347
|
+
|
|
348
|
+
<a id="api-hue360fromrgb01"></a>
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
function hue360FromRGB01(rgb01: RGB01, chroma01?: Real01 | undefined, max01?: Real01 | undefined): Int360;
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
#### hue360FromRGB01
|
|
355
|
+
|
|
356
|
+
<a id="api-hue360fromrgb01"></a>
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
function hue360FromRGB01(rgb01: RGB01 | undefined, chroma01?: Real01 | undefined, max01?: Real01 | undefined): Int360 | undefined;
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
#### rgb01From255
|
|
363
|
+
|
|
364
|
+
<a id="api-rgb01from255"></a>
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
function rgb01From255(rgb: RGB255): RGB01;
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### rgb01From255
|
|
371
|
+
|
|
372
|
+
<a id="api-rgb01from255"></a>
|
|
373
|
+
|
|
374
|
+
```typescript
|
|
375
|
+
function rgb01From255(rgb: RGB255 | undefined): RGB01 | undefined;
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
#### rgb01FromHueChromaMin
|
|
379
|
+
|
|
380
|
+
<a id="api-rgb01fromhuechromamin"></a>
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
rgb01FromHueChromaMin: (hue360: Int360, chroma01: Real01, min: Real01, alpha01: Real01 | undefined) => RGB01
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### rgb255From01
|
|
387
|
+
|
|
388
|
+
<a id="api-rgb255from01"></a>
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
function rgb255From01(rgb: RGB01): RealRGB;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### rgb255From01
|
|
395
|
+
|
|
396
|
+
<a id="api-rgb255from01"></a>
|
|
397
|
+
|
|
398
|
+
```typescript
|
|
399
|
+
function rgb255From01(rgb: RGB01 | undefined): RealRGB | undefined;
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
#### rgbFromHex
|
|
403
|
+
|
|
404
|
+
<a id="api-rgbfromhex"></a>
|
|
405
|
+
|
|
406
|
+
```typescript
|
|
407
|
+
function rgbFromHex(text: string, options?: ThrowOnError | undefined): IntRGB;
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
#### rgbFromHex
|
|
411
|
+
|
|
412
|
+
<a id="api-rgbfromhex"></a>
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
function rgbFromHex(text: string | undefined, options: typeof NO_THROW): IntRGB | undefined;
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
#### rgbFromHSL
|
|
419
|
+
|
|
420
|
+
<a id="api-rgbfromhsl"></a>
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
function rgbFromHSL(hsl: HSL): RGB01;
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
#### rgbFromHSL
|
|
427
|
+
|
|
428
|
+
<a id="api-rgbfromhsl"></a>
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
function rgbFromHSL(hsl: HSL | undefined): RGB01 | undefined;
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
#### rgbFromHSV
|
|
435
|
+
|
|
436
|
+
<a id="api-rgbfromhsv"></a>
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
function rgbFromHSV(hsv: HSV): RGB01;
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
#### rgbFromHSV
|
|
443
|
+
|
|
444
|
+
<a id="api-rgbfromhsv"></a>
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
function rgbFromHSV(hsv: HSV | undefined): RGB01 | undefined;
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### rgbFromReal
|
|
451
|
+
|
|
452
|
+
<a id="api-rgbfromreal"></a>
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
function rgbFromReal(real: RealRGBA): IntRGBA;
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
#### rgbFromReal
|
|
459
|
+
|
|
460
|
+
<a id="api-rgbfromreal"></a>
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
function rgbFromReal(real: RealRGB): IntRGB;
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
#### rgbFromReal
|
|
467
|
+
|
|
468
|
+
<a id="api-rgbfromreal"></a>
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
function rgbFromReal(real: RealRGB | undefined): IntRGB | undefined;
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
#### rgbIntFrom01
|
|
475
|
+
|
|
476
|
+
<a id="api-rgbintfrom01"></a>
|
|
477
|
+
|
|
478
|
+
```typescript
|
|
479
|
+
function rgbIntFrom01(rgba01: RGBA01): IntRGBA;
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
#### rgbIntFrom01
|
|
483
|
+
|
|
484
|
+
<a id="api-rgbintfrom01"></a>
|
|
485
|
+
|
|
486
|
+
```typescript
|
|
487
|
+
function rgbIntFrom01(rgb01: RGB01): IntRGB;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
#### rgbIntFrom01
|
|
491
|
+
|
|
492
|
+
<a id="api-rgbintfrom01"></a>
|
|
493
|
+
|
|
494
|
+
```typescript
|
|
495
|
+
function rgbIntFrom01(rgb01: RGB01 | undefined): IntRGB | undefined;
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### toHSL
|
|
499
|
+
|
|
500
|
+
<a id="api-tohsl"></a>
|
|
501
|
+
|
|
502
|
+
```typescript
|
|
503
|
+
function toHSL(h360: number, s01: number, l01: number, a01: number): HSLA;
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
#### toHSL
|
|
507
|
+
|
|
508
|
+
<a id="api-tohsl"></a>
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
function toHSL(h360: number, s01: number, l01: number, a01?: number | undefined): HSL;
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
#### toHSV
|
|
515
|
+
|
|
516
|
+
<a id="api-tohsv"></a>
|
|
517
|
+
|
|
518
|
+
```typescript
|
|
519
|
+
function toHSV(h360: number, s01: number, v01: number, a01: number): HSVA;
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
#### toHSV
|
|
523
|
+
|
|
524
|
+
<a id="api-tohsv"></a>
|
|
525
|
+
|
|
526
|
+
```typescript
|
|
527
|
+
function toHSV(h360: number, s01: number, v01: number, a01?: number | undefined): HSV;
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
#### toRGB
|
|
531
|
+
|
|
532
|
+
<a id="api-torgb"></a>
|
|
533
|
+
|
|
534
|
+
```typescript
|
|
535
|
+
function toRGB(r255: number, g255: number, b255: number, a255: number): RGBA255;
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### toRGB
|
|
539
|
+
|
|
540
|
+
<a id="api-torgb"></a>
|
|
541
|
+
|
|
542
|
+
```typescript
|
|
543
|
+
function toRGB(r255: number, g255: number, b255: number, a255?: number | undefined): RGB255;
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### Interfaces
|
|
547
|
+
|
|
548
|
+
#### ColorConversionErrorOptions
|
|
549
|
+
|
|
550
|
+
<a id="api-colorconversionerroroptions"></a>
|
|
551
|
+
|
|
552
|
+
```typescript
|
|
553
|
+
export interface ColorConversionErrorOptions extends ErrorOptions
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
#### ColorParts
|
|
557
|
+
|
|
558
|
+
<a id="api-colorparts"></a>
|
|
559
|
+
|
|
560
|
+
```typescript
|
|
561
|
+
export interface ColorParts
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
#### HSL
|
|
565
|
+
|
|
566
|
+
<a id="api-hsl"></a>
|
|
567
|
+
|
|
568
|
+
```typescript
|
|
569
|
+
export interface HSL
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
#### HSLA
|
|
573
|
+
|
|
574
|
+
<a id="api-hsla"></a>
|
|
575
|
+
|
|
576
|
+
```typescript
|
|
577
|
+
export interface HSLA extends HSL
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
#### HSV
|
|
581
|
+
|
|
582
|
+
<a id="api-hsv"></a>
|
|
583
|
+
|
|
584
|
+
```typescript
|
|
585
|
+
export interface HSV
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
#### HSVA
|
|
589
|
+
|
|
590
|
+
<a id="api-hsva"></a>
|
|
591
|
+
|
|
592
|
+
```typescript
|
|
593
|
+
export interface HSVA extends HSV
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
#### IntRGB
|
|
597
|
+
|
|
598
|
+
<a id="api-intrgb"></a>
|
|
599
|
+
|
|
600
|
+
```typescript
|
|
601
|
+
export interface IntRGB
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
A color with RGB values, and possibly an alpha. All values are integers in the range [0..255].
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
#### IntRGBA
|
|
608
|
+
|
|
609
|
+
<a id="api-intrgba"></a>
|
|
610
|
+
|
|
611
|
+
```typescript
|
|
612
|
+
export interface IntRGBA extends IntRGB
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
A color with RGBA values. All values are integers in the range [0,255].
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
#### RealRGB
|
|
619
|
+
|
|
620
|
+
<a id="api-realrgb"></a>
|
|
621
|
+
|
|
622
|
+
```typescript
|
|
623
|
+
export interface RealRGB
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
A color with RGB values, and possibly an alpha. All values are real numbers in the range [0,255].
|
|
627
|
+
|
|
628
|
+
|
|
629
|
+
#### RealRGBA
|
|
630
|
+
|
|
631
|
+
<a id="api-realrgba"></a>
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
export interface RealRGBA extends RealRGB
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
A color with RGBA values. All values are real numbers in the range [0,255].
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
#### RGB01
|
|
641
|
+
|
|
642
|
+
<a id="api-rgb01"></a>
|
|
643
|
+
|
|
644
|
+
```typescript
|
|
645
|
+
export interface RGB01
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
A color with RGB values, and possibly an alpha. All values are real numbers in the range [0,1].
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
#### RGBA01
|
|
652
|
+
|
|
653
|
+
<a id="api-rgba01"></a>
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
export interface RGBA01 extends RGB01
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### TypeAliases
|
|
660
|
+
|
|
661
|
+
#### ColorCloseTo
|
|
662
|
+
|
|
663
|
+
<a id="api-colorcloseto"></a>
|
|
664
|
+
|
|
665
|
+
```typescript
|
|
666
|
+
type ColorCloseTo<C extends object> = (a: C | undefined, b: C | undefined, epsilons?: Partial<Record<keyof C, number>> | undefined) => boolean;
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
A function which checks two colors for equivalence, within some tolerable margin of error.
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
#### RGB255
|
|
673
|
+
|
|
674
|
+
<a id="api-rgb255"></a>
|
|
675
|
+
|
|
676
|
+
```typescript
|
|
677
|
+
type RGB255 = IntRGB | RealRGB;
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
A color with RGB values, and possibly an alpha. All values are numbers in the range [0,255].
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
#### RGBA255
|
|
684
|
+
|
|
685
|
+
<a id="api-rgba255"></a>
|
|
686
|
+
|
|
687
|
+
```typescript
|
|
688
|
+
type RGBA255 = IntRGBA | RealRGBA;
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
#### UnbrandedNumbers
|
|
692
|
+
|
|
693
|
+
<a id="api-unbrandednumbers"></a>
|
|
694
|
+
|
|
695
|
+
```typescript
|
|
696
|
+
type UnbrandedNumbers<C extends object> = {
|
|
697
|
+
[K in keyof C]: C[K] extends number ? Unbound<C[K]> : C[K];
|
|
698
|
+
};
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
Remove the branding from number values, to make type operations less onerous for generics.
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
#### UncheckedColorParts
|
|
705
|
+
|
|
706
|
+
<a id="api-uncheckedcolorparts"></a>
|
|
707
|
+
|
|
708
|
+
```typescript
|
|
709
|
+
type UncheckedColorParts = {
|
|
710
|
+
[K in keyof ColorParts]?: number | undefined;
|
|
711
|
+
};
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
Color parts which do not use branded numbers. Useful for tests or when you've already verified the values.
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
### Variables
|
|
718
|
+
|
|
719
|
+
#### COLOR_EPSILON
|
|
720
|
+
|
|
721
|
+
<a id="api-color-epsilon"></a>
|
|
722
|
+
|
|
723
|
+
```typescript
|
|
724
|
+
COLOR_EPSILON = 0.0001
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
#### hslComparator
|
|
728
|
+
|
|
729
|
+
<a id="api-hslcomparator"></a>
|
|
730
|
+
|
|
731
|
+
```typescript
|
|
732
|
+
hslComparator: import("../typical/comparator.js").Comparator<HSL | undefined>
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
#### hslEq
|
|
736
|
+
|
|
737
|
+
<a id="api-hsleq"></a>
|
|
738
|
+
|
|
739
|
+
```typescript
|
|
740
|
+
hslEq: import("./color-comparator.js").ColorCloseTo<HSL>
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
#### hsvComparator
|
|
744
|
+
|
|
745
|
+
<a id="api-hsvcomparator"></a>
|
|
746
|
+
|
|
747
|
+
```typescript
|
|
748
|
+
hsvComparator: import("../typical/comparator.js").Comparator<HSV | undefined>
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
#### hsvEq
|
|
752
|
+
|
|
753
|
+
<a id="api-hsveq"></a>
|
|
754
|
+
|
|
755
|
+
```typescript
|
|
756
|
+
hsvEq: import("./color-comparator.js").ColorCloseTo<HSV>
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
#### rgbComparator
|
|
760
|
+
|
|
761
|
+
<a id="api-rgbcomparator"></a>
|
|
762
|
+
|
|
763
|
+
```typescript
|
|
764
|
+
rgbComparator: import("../typical/comparator.js").Comparator<IntRGB | undefined>
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
#### rgbEq
|
|
768
|
+
|
|
769
|
+
<a id="api-rgbeq"></a>
|
|
770
|
+
|
|
771
|
+
```typescript
|
|
772
|
+
rgbEq: import("./color-comparator.js").ColorCloseTo<RGB255 | RGB01>
|
|
773
|
+
```
|
|
774
|
+
|