@thi.ng/color 3.2.6 → 4.0.3
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/CHANGELOG.md +162 -230
- package/README.md +31 -15
- package/{ops/alpha.d.ts → alpha.d.ts} +1 -1
- package/{ops/alpha.js → alpha.js} +1 -1
- package/{ops/analog.d.ts → analog.d.ts} +3 -3
- package/{ops/analog.js → analog.js} +10 -10
- package/api/constants.js +18 -73
- package/api/gradients.d.ts +1 -1
- package/api/ranges.d.ts +2 -2
- package/api.d.ts +7 -2
- package/{ops/clamp.d.ts → clamp.d.ts} +1 -1
- package/{ops/clamp.js → clamp.js} +6 -5
- package/{ops/closest-hue.d.ts → closest-hue.d.ts} +1 -1
- package/{ops/closest-hue.js → closest-hue.js} +1 -1
- package/{ops/color-range.d.ts → color-range.d.ts} +2 -2
- package/{ops/color-range.js → color-range.js} +25 -18
- package/color.d.ts +1 -1
- package/color.js +16 -16
- package/convert.d.ts +1 -1
- package/convert.js +4 -4
- package/{ops/cosine-gradients.d.ts → cosine-gradients.d.ts} +2 -2
- package/{ops/cosine-gradients.js → cosine-gradients.js} +13 -5
- package/css/css.d.ts +1 -1
- package/css/css.js +12 -11
- package/css/parse-css.d.ts +1 -1
- package/css/parse-css.js +12 -9
- package/defcolor.d.ts +1 -1
- package/defcolor.js +24 -11
- package/{ops/distance.d.ts → distance.d.ts} +2 -2
- package/{ops/distance.js → distance.js} +7 -5
- package/{ops/gradients.d.ts → gradients.d.ts} +2 -2
- package/{ops/gradients.js → gradients.js} +3 -3
- package/hcy/hcy-rgb.d.ts +1 -1
- package/hcy/hcy-rgb.js +6 -6
- package/hcy/hcy.d.ts +1 -1
- package/hcy/hcy.js +4 -2
- package/hsi/hsi-rgb.d.ts +1 -1
- package/hsi/hsi-rgb.js +2 -2
- package/hsi/hsi.d.ts +1 -1
- package/hsi/hsi.js +4 -2
- package/hsl/hsl-css.d.ts +1 -1
- package/hsl/hsl-css.js +5 -4
- package/hsl/hsl-hsv.d.ts +1 -1
- package/hsl/hsl-hsv.js +1 -1
- package/hsl/hsl-rgb.d.ts +1 -1
- package/hsl/hsl-rgb.js +5 -5
- package/hsl/hsl.d.ts +1 -1
- package/hsl/hsl.js +5 -3
- package/hsv/hsv-css.d.ts +1 -1
- package/hsv/hsv-css.js +2 -2
- package/hsv/hsv-hsl.d.ts +1 -1
- package/hsv/hsv-hsl.js +1 -1
- package/hsv/hsv-rgb.d.ts +1 -1
- package/hsv/hsv-rgb.js +3 -3
- package/hsv/hsv.d.ts +1 -1
- package/hsv/hsv.js +5 -3
- package/index.d.ts +87 -87
- package/index.js +87 -87
- package/int/int-css.js +2 -2
- package/int/int-int.js +1 -1
- package/int/int-rgb.d.ts +1 -1
- package/int/int-rgb.js +2 -2
- package/int/int-srgb.d.ts +1 -1
- package/int/int-srgb.js +2 -2
- package/int/int.d.ts +24 -11
- package/int/int.js +59 -19
- package/internal/ensure.d.ts +5 -0
- package/internal/{ensure-args.js → ensure.js} +4 -1
- package/internal/matrix-ops.d.ts +8 -5
- package/internal/matrix-ops.js +12 -8
- package/internal/scale.d.ts +3 -0
- package/internal/scale.js +2 -0
- package/{ops/invert.d.ts → invert.d.ts} +1 -1
- package/{ops/invert.js → invert.js} +3 -2
- package/is-black.d.ts +3 -0
- package/{ops/is-black.js → is-black.js} +5 -6
- package/is-gray.d.ts +3 -0
- package/{ops/is-gray.js → is-gray.js} +6 -7
- package/is-white.d.ts +3 -0
- package/{ops/is-white.js → is-white.js} +5 -6
- package/lab/lab-css.d.ts +1 -1
- package/lab/lab-css.js +4 -4
- package/lab/lab-lab.d.ts +1 -1
- package/lab/lab-lab.js +3 -3
- package/lab/lab-lch.d.ts +1 -1
- package/lab/lab-lch.js +6 -5
- package/lab/lab-rgb.d.ts +1 -1
- package/lab/lab-rgb.js +2 -2
- package/lab/lab-xyz.d.ts +1 -1
- package/lab/lab-xyz.js +4 -4
- package/lab/lab50.d.ts +1 -1
- package/lab/lab50.js +8 -6
- package/lab/lab65.d.ts +1 -1
- package/lab/lab65.js +8 -6
- package/lch/lch-css.d.ts +1 -1
- package/lch/lch-css.js +5 -4
- package/lch/lch.d.ts +1 -1
- package/lch/lch.js +8 -6
- package/{ops/linear.d.ts → linear.d.ts} +0 -0
- package/{ops/linear.js → linear.js} +0 -0
- package/{ops/luminance-rgb.d.ts → luminance-rgb.d.ts} +1 -1
- package/{ops/luminance-rgb.js → luminance-rgb.js} +2 -2
- package/{ops/luminance.d.ts → luminance.d.ts} +2 -3
- package/{ops/luminance.js → luminance.js} +5 -10
- package/{ops/mix.d.ts → mix.d.ts} +2 -2
- package/{ops/mix.js → mix.js} +7 -6
- package/oklab/oklab-rgb.d.ts +1 -1
- package/oklab/oklab-rgb.js +4 -11
- package/oklab/oklab-xyz.d.ts +1 -1
- package/oklab/oklab-xyz.js +9 -21
- package/oklab/oklab.d.ts +1 -1
- package/oklab/oklab.js +8 -6
- package/package.json +323 -52
- package/rgb/hue-rgb.d.ts +1 -1
- package/rgb/hue-rgb.js +3 -2
- package/rgb/kelvin-rgba.d.ts +1 -1
- package/rgb/kelvin-rgba.js +3 -3
- package/rgb/rgb-css.d.ts +1 -1
- package/rgb/rgb-css.js +2 -2
- package/rgb/rgb-hcv.d.ts +1 -1
- package/rgb/rgb-hcv.js +4 -3
- package/rgb/rgb-hcy.d.ts +1 -1
- package/rgb/rgb-hcy.js +4 -4
- package/rgb/rgb-hsi.d.ts +1 -1
- package/rgb/rgb-hsi.js +4 -3
- package/rgb/rgb-hsl.d.ts +1 -1
- package/rgb/rgb-hsl.js +2 -2
- package/rgb/rgb-hsv.d.ts +1 -1
- package/rgb/rgb-hsv.js +2 -2
- package/rgb/rgb-lab.d.ts +1 -1
- package/rgb/rgb-lab.js +2 -2
- package/rgb/rgb-oklab.d.ts +1 -1
- package/rgb/rgb-oklab.js +6 -13
- package/rgb/rgb-srgb.d.ts +1 -1
- package/rgb/rgb-srgb.js +5 -5
- package/rgb/rgb-xyz.d.ts +1 -1
- package/rgb/rgb-xyz.js +4 -4
- package/rgb/rgb-ycc.d.ts +1 -1
- package/rgb/rgb-ycc.js +5 -4
- package/rgb/rgb.d.ts +1 -1
- package/rgb/rgb.js +15 -14
- package/{ops/sort.d.ts → sort.d.ts} +16 -5
- package/{ops/sort.js → sort.js} +21 -7
- package/srgb/srgb-css.d.ts +1 -1
- package/srgb/srgb-css.js +8 -8
- package/srgb/srgb-int.d.ts +1 -1
- package/srgb/srgb-int.js +4 -4
- package/srgb/srgb-rgb.d.ts +1 -1
- package/srgb/srgb-rgb.js +5 -5
- package/srgb/srgb.d.ts +1 -1
- package/srgb/srgb.js +9 -7
- package/{ops/swatches.d.ts → swatches.d.ts} +1 -1
- package/{ops/swatches.js → swatches.js} +0 -0
- package/{ops/transform.d.ts → transform.d.ts} +1 -1
- package/{ops/transform.js → transform.js} +5 -5
- package/xyy/xyy-xyz.d.ts +1 -1
- package/xyy/xyy-xyz.js +4 -4
- package/xyy/xyy.d.ts +1 -1
- package/xyy/xyy.js +6 -3
- package/xyz/wavelength-xyz.d.ts +1 -1
- package/xyz/wavelength-xyz.js +2 -2
- package/xyz/xyz-lab.d.ts +1 -1
- package/xyz/xyz-lab.js +5 -4
- package/xyz/xyz-oklab.d.ts +1 -1
- package/xyz/xyz-oklab.js +4 -4
- package/xyz/xyz-rgb.d.ts +1 -1
- package/xyz/xyz-rgb.js +3 -3
- package/xyz/xyz-xyy.d.ts +1 -1
- package/xyz/xyz-xyy.js +4 -4
- package/xyz/xyz-xyz.d.ts +1 -1
- package/xyz/xyz-xyz.js +4 -4
- package/xyz/xyz50.d.ts +1 -1
- package/xyz/xyz50.js +10 -8
- package/xyz/xyz65.d.ts +1 -1
- package/xyz/xyz65.js +10 -8
- package/ycc/ycc-rgb.d.ts +1 -1
- package/ycc/ycc-rgb.js +4 -4
- package/ycc/ycc.d.ts +1 -1
- package/ycc/ycc.js +4 -2
- package/internal/ensure-alpha.d.ts +0 -2
- package/internal/ensure-alpha.js +0 -2
- package/internal/ensure-args.d.ts +0 -3
- package/lib/index.js +0 -2236
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
- package/ops/is-black.d.ts +0 -3
- package/ops/is-gray.d.ts +0 -3
- package/ops/is-white.d.ts +0 -3
package/lib/index.js
DELETED
|
@@ -1,2236 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var strings = require('@thi.ng/strings');
|
|
6
|
-
var checks = require('@thi.ng/checks');
|
|
7
|
-
var errors = require('@thi.ng/errors');
|
|
8
|
-
var math = require('@thi.ng/math');
|
|
9
|
-
var vectors = require('@thi.ng/vectors');
|
|
10
|
-
var api = require('@thi.ng/api');
|
|
11
|
-
var binary = require('@thi.ng/binary');
|
|
12
|
-
var random = require('@thi.ng/random');
|
|
13
|
-
var defmulti = require('@thi.ng/defmulti');
|
|
14
|
-
var arrays = require('@thi.ng/arrays');
|
|
15
|
-
var compose = require('@thi.ng/compose');
|
|
16
|
-
var transducers = require('@thi.ng/transducers');
|
|
17
|
-
var compare = require('@thi.ng/compare');
|
|
18
|
-
|
|
19
|
-
exports.Hue = void 0;
|
|
20
|
-
(function (Hue) {
|
|
21
|
-
Hue[Hue["RED"] = 0] = "RED";
|
|
22
|
-
Hue[Hue["ORANGE"] = 1] = "ORANGE";
|
|
23
|
-
Hue[Hue["YELLOW"] = 2] = "YELLOW";
|
|
24
|
-
Hue[Hue["CHARTREUSE"] = 3] = "CHARTREUSE";
|
|
25
|
-
Hue[Hue["GREEN"] = 4] = "GREEN";
|
|
26
|
-
Hue[Hue["SPRING_GREEN"] = 5] = "SPRING_GREEN";
|
|
27
|
-
Hue[Hue["CYAN"] = 6] = "CYAN";
|
|
28
|
-
Hue[Hue["AZURE"] = 7] = "AZURE";
|
|
29
|
-
Hue[Hue["BLUE"] = 8] = "BLUE";
|
|
30
|
-
Hue[Hue["VIOLET"] = 9] = "VIOLET";
|
|
31
|
-
Hue[Hue["MAGENTA"] = 10] = "MAGENTA";
|
|
32
|
-
Hue[Hue["ROSE"] = 11] = "ROSE";
|
|
33
|
-
})(exports.Hue || (exports.Hue = {}));
|
|
34
|
-
class ParsedColor {
|
|
35
|
-
constructor(mode, value) {
|
|
36
|
-
this.mode = mode;
|
|
37
|
-
this.value = value;
|
|
38
|
-
}
|
|
39
|
-
deref() {
|
|
40
|
-
return this.value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const BLACK = Object.freeze([0, 0, 0, 1]);
|
|
45
|
-
const WHITE = Object.freeze([1, 1, 1, 1]);
|
|
46
|
-
const RED = Object.freeze([1, 0, 0, 1]);
|
|
47
|
-
const GREEN = Object.freeze([0, 1, 0, 1]);
|
|
48
|
-
const BLUE = Object.freeze([0, 0, 1, 1]);
|
|
49
|
-
const CYAN = Object.freeze([0, 1, 1, 1]);
|
|
50
|
-
const MAGENTA = Object.freeze([1, 0, 1, 1]);
|
|
51
|
-
const YELLOW = Object.freeze([1, 1, 0, 1]);
|
|
52
|
-
const RGB_LUMINANCE_REC601 = [0.299, 0.587, 0.114];
|
|
53
|
-
const RGB_LUMINANCE_REC709 = [0.2126, 0.7152, 0.0722];
|
|
54
|
-
const RGB_LUMINANCE_REC2020 = [0.2627, 0.678, 0.0593];
|
|
55
|
-
const RGB_XYZ_D50 = [
|
|
56
|
-
0.4360747,
|
|
57
|
-
0.2225045,
|
|
58
|
-
0.0139322,
|
|
59
|
-
0.3850649,
|
|
60
|
-
0.7168786,
|
|
61
|
-
0.0971045,
|
|
62
|
-
0.1430804,
|
|
63
|
-
0.0606169,
|
|
64
|
-
0.7141733,
|
|
65
|
-
];
|
|
66
|
-
const XYZ_RGB_D50 = [
|
|
67
|
-
3.1338561,
|
|
68
|
-
-0.9787684,
|
|
69
|
-
0.0719453,
|
|
70
|
-
-1.6168667,
|
|
71
|
-
1.9161415,
|
|
72
|
-
-0.2289914,
|
|
73
|
-
-0.4906146,
|
|
74
|
-
0.033454,
|
|
75
|
-
1.4052427,
|
|
76
|
-
];
|
|
77
|
-
const RGB_XYZ_D65 = [
|
|
78
|
-
0.4124564,
|
|
79
|
-
0.2126729,
|
|
80
|
-
0.0193339,
|
|
81
|
-
0.3575761,
|
|
82
|
-
0.7151522,
|
|
83
|
-
0.119192,
|
|
84
|
-
0.1804375,
|
|
85
|
-
0.072175,
|
|
86
|
-
0.9503041,
|
|
87
|
-
];
|
|
88
|
-
const XYZ_RGB_D65 = [
|
|
89
|
-
3.2404542,
|
|
90
|
-
-0.969266,
|
|
91
|
-
0.0556434,
|
|
92
|
-
-1.5371385,
|
|
93
|
-
1.8760108,
|
|
94
|
-
-0.2040259,
|
|
95
|
-
-0.4985314,
|
|
96
|
-
0.041556,
|
|
97
|
-
1.0572252,
|
|
98
|
-
];
|
|
99
|
-
const BRADFORD_D50_D65 = [
|
|
100
|
-
0.9555766,
|
|
101
|
-
-0.0282895,
|
|
102
|
-
0.0122982,
|
|
103
|
-
-0.0230393,
|
|
104
|
-
1.0099416,
|
|
105
|
-
-0.020483,
|
|
106
|
-
0.0631636,
|
|
107
|
-
0.0210077,
|
|
108
|
-
1.3299098,
|
|
109
|
-
];
|
|
110
|
-
const BRADFORD_D65_D50 = [
|
|
111
|
-
1.0478112,
|
|
112
|
-
0.0295424,
|
|
113
|
-
-0.0092345,
|
|
114
|
-
0.0228866,
|
|
115
|
-
0.9904844,
|
|
116
|
-
0.0150436,
|
|
117
|
-
-0.050127,
|
|
118
|
-
-0.0170491,
|
|
119
|
-
0.7521316,
|
|
120
|
-
];
|
|
121
|
-
const D50 = [0.96422, 1, 0.82521];
|
|
122
|
-
const D65 = [0.95047, 1, 1.08883];
|
|
123
|
-
const OKLAB_M1 = [
|
|
124
|
-
0.8189330101,
|
|
125
|
-
0.0329845436,
|
|
126
|
-
0.0482003018,
|
|
127
|
-
0.3618667424,
|
|
128
|
-
0.9293118715,
|
|
129
|
-
0.2643662691,
|
|
130
|
-
-0.1288597137,
|
|
131
|
-
0.0361456387,
|
|
132
|
-
0.633851707,
|
|
133
|
-
];
|
|
134
|
-
const OKLAB_M2 = [
|
|
135
|
-
0.2104542553,
|
|
136
|
-
1.9779984951,
|
|
137
|
-
0.0259040371,
|
|
138
|
-
0.793617785,
|
|
139
|
-
-2.428592205,
|
|
140
|
-
0.7827717662,
|
|
141
|
-
-0.0040720468,
|
|
142
|
-
0.4505937099,
|
|
143
|
-
-0.808675766,
|
|
144
|
-
];
|
|
145
|
-
exports.FF = strings.float(3);
|
|
146
|
-
exports.PC = strings.percent(3);
|
|
147
|
-
const setPrecision = (x) => {
|
|
148
|
-
exports.FF = strings.float(x);
|
|
149
|
-
exports.PC = strings.percent(x);
|
|
150
|
-
};
|
|
151
|
-
const INV8BIT = 1 / 0xff;
|
|
152
|
-
const EPS = 1 / 256;
|
|
153
|
-
|
|
154
|
-
const CSS_NAMES = {
|
|
155
|
-
aliceblue: "f0f8ff",
|
|
156
|
-
antiquewhite: "faebd7",
|
|
157
|
-
aqua: "0ff",
|
|
158
|
-
aquamarine: "7fffd4",
|
|
159
|
-
azure: "f0ffff",
|
|
160
|
-
beige: "f5f5dc",
|
|
161
|
-
bisque: "ffe4c4",
|
|
162
|
-
black: "000",
|
|
163
|
-
blanchedalmond: "ffebcd",
|
|
164
|
-
blue: "00f",
|
|
165
|
-
blueviolet: "8a2be2",
|
|
166
|
-
brown: "a52a2a",
|
|
167
|
-
burlywood: "deb887",
|
|
168
|
-
cadetblue: "5f9ea0",
|
|
169
|
-
chartreuse: "7fff00",
|
|
170
|
-
chocolate: "d2691e",
|
|
171
|
-
coral: "ff7f50",
|
|
172
|
-
cornflowerblue: "6495ed",
|
|
173
|
-
cornsilk: "fff8dc",
|
|
174
|
-
crimson: "dc143c",
|
|
175
|
-
cyan: "0ff",
|
|
176
|
-
darkblue: "00008b",
|
|
177
|
-
darkcyan: "008b8b",
|
|
178
|
-
darkgoldenrod: "b8860b",
|
|
179
|
-
darkgray: "a9a9a9",
|
|
180
|
-
darkgreen: "006400",
|
|
181
|
-
darkgrey: "a9a9a9",
|
|
182
|
-
darkkhaki: "bdb76b",
|
|
183
|
-
darkmagenta: "8b008b",
|
|
184
|
-
darkolivegreen: "556b2f",
|
|
185
|
-
darkorange: "ff8c00",
|
|
186
|
-
darkorchid: "9932cc",
|
|
187
|
-
darkred: "8b0000",
|
|
188
|
-
darksalmon: "e9967a",
|
|
189
|
-
darkseagreen: "8fbc8f",
|
|
190
|
-
darkslateblue: "483d8b",
|
|
191
|
-
darkslategray: "2f4f4f",
|
|
192
|
-
darkslategrey: "2f4f4f",
|
|
193
|
-
darkturquoise: "00ced1",
|
|
194
|
-
darkviolet: "9400d3",
|
|
195
|
-
deeppink: "ff1493",
|
|
196
|
-
deepskyblue: "00bfff",
|
|
197
|
-
dimgray: "696969",
|
|
198
|
-
dimgrey: "696969",
|
|
199
|
-
dodgerblue: "1e90ff",
|
|
200
|
-
firebrick: "b22222",
|
|
201
|
-
floralwhite: "fffaf0",
|
|
202
|
-
forestgreen: "228b22",
|
|
203
|
-
fuchsia: "f0f",
|
|
204
|
-
gainsboro: "dcdcdc",
|
|
205
|
-
ghostwhite: "f8f8ff",
|
|
206
|
-
gold: "ffd700",
|
|
207
|
-
goldenrod: "daa520",
|
|
208
|
-
gray: "808080",
|
|
209
|
-
grey: "808080",
|
|
210
|
-
green: "008000",
|
|
211
|
-
greenyellow: "adff2f",
|
|
212
|
-
honeydew: "f0fff0",
|
|
213
|
-
hotpink: "ff69b4",
|
|
214
|
-
indianred: "cd5c5c",
|
|
215
|
-
indigo: "4b0082",
|
|
216
|
-
ivory: "fffff0",
|
|
217
|
-
khaki: "f0e68c",
|
|
218
|
-
lavender: "e6e6fa",
|
|
219
|
-
lavenderblush: "fff0f5",
|
|
220
|
-
lawngreen: "7cfc00",
|
|
221
|
-
lemonchiffon: "fffacd",
|
|
222
|
-
lightblue: "add8e6",
|
|
223
|
-
lightcoral: "f08080",
|
|
224
|
-
lightcyan: "e0ffff",
|
|
225
|
-
lightgoldenrodyellow: "fafad2",
|
|
226
|
-
lightgray: "d3d3d3",
|
|
227
|
-
lightgreen: "90ee90",
|
|
228
|
-
lightgrey: "d3d3d3",
|
|
229
|
-
lightpink: "ffb6c1",
|
|
230
|
-
lightsalmon: "ffa07a",
|
|
231
|
-
lightseagreen: "20b2aa",
|
|
232
|
-
lightskyblue: "87cefa",
|
|
233
|
-
lightslategray: "789",
|
|
234
|
-
lightslategrey: "789",
|
|
235
|
-
lightsteelblue: "b0c4de",
|
|
236
|
-
lightyellow: "ffffe0",
|
|
237
|
-
lime: "0f0",
|
|
238
|
-
limegreen: "32cd32",
|
|
239
|
-
linen: "faf0e6",
|
|
240
|
-
magenta: "f0f",
|
|
241
|
-
maroon: "800000",
|
|
242
|
-
mediumaquamarine: "66cdaa",
|
|
243
|
-
mediumblue: "0000cd",
|
|
244
|
-
mediumorchid: "ba55d3",
|
|
245
|
-
mediumpurple: "9370db",
|
|
246
|
-
mediumseagreen: "3cb371",
|
|
247
|
-
mediumslateblue: "7b68ee",
|
|
248
|
-
mediumspringgreen: "00fa9a",
|
|
249
|
-
mediumturquoise: "48d1cc",
|
|
250
|
-
mediumvioletred: "c71585",
|
|
251
|
-
midnightblue: "191970",
|
|
252
|
-
mintcream: "f5fffa",
|
|
253
|
-
mistyrose: "ffe4e1",
|
|
254
|
-
moccasin: "ffe4b5",
|
|
255
|
-
navajowhite: "ffdead",
|
|
256
|
-
navy: "000080",
|
|
257
|
-
oldlace: "fdf5e6",
|
|
258
|
-
olive: "808000",
|
|
259
|
-
olivedrab: "6b8e23",
|
|
260
|
-
orange: "ffa500",
|
|
261
|
-
orangered: "ff4500",
|
|
262
|
-
orchid: "da70d6",
|
|
263
|
-
palegoldenrod: "eee8aa",
|
|
264
|
-
palegreen: "98fb98",
|
|
265
|
-
paleturquoise: "afeeee",
|
|
266
|
-
palevioletred: "db7093",
|
|
267
|
-
papayawhip: "ffefd5",
|
|
268
|
-
peachpuff: "ffdab9",
|
|
269
|
-
peru: "cd853f",
|
|
270
|
-
pink: "ffc0cb",
|
|
271
|
-
plum: "dda0dd",
|
|
272
|
-
powderblue: "b0e0e6",
|
|
273
|
-
purple: "800080",
|
|
274
|
-
red: "f00",
|
|
275
|
-
rosybrown: "bc8f8f",
|
|
276
|
-
royalblue: "4169e1",
|
|
277
|
-
saddlebrown: "8b4513",
|
|
278
|
-
salmon: "fa8072",
|
|
279
|
-
sandybrown: "f4a460",
|
|
280
|
-
seagreen: "2e8b57",
|
|
281
|
-
seashell: "fff5ee",
|
|
282
|
-
sienna: "a0522d",
|
|
283
|
-
silver: "c0c0c0",
|
|
284
|
-
skyblue: "87ceeb",
|
|
285
|
-
slateblue: "6a5acd",
|
|
286
|
-
slategray: "708090",
|
|
287
|
-
slategrey: "708090",
|
|
288
|
-
snow: "fffafa",
|
|
289
|
-
springgreen: "00ff7f",
|
|
290
|
-
steelblue: "4682b4",
|
|
291
|
-
tan: "d2b48c",
|
|
292
|
-
teal: "008080",
|
|
293
|
-
thistle: "d8bfd8",
|
|
294
|
-
tomato: "ff6347",
|
|
295
|
-
turquoise: "40e0d0",
|
|
296
|
-
violet: "ee82ee",
|
|
297
|
-
wheat: "f5deb3",
|
|
298
|
-
white: "fff",
|
|
299
|
-
whitesmoke: "f5f5f5",
|
|
300
|
-
yellow: "ff0",
|
|
301
|
-
yellowgreen: "9acd32",
|
|
302
|
-
transparent: "0000",
|
|
303
|
-
rebeccapurple: "639",
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
let CSS_SYSTEM_COLORS = {
|
|
307
|
-
canvas: "fff",
|
|
308
|
-
canvastext: "000",
|
|
309
|
-
linktext: "001ee4",
|
|
310
|
-
visitedtext: "4e2386",
|
|
311
|
-
activetext: "eb3323",
|
|
312
|
-
buttonface: "ddd",
|
|
313
|
-
buttontext: "000",
|
|
314
|
-
buttonborder: "000",
|
|
315
|
-
field: "fff",
|
|
316
|
-
fieldtext: "000",
|
|
317
|
-
highlight: "bbd5fb",
|
|
318
|
-
highlighttext: "000",
|
|
319
|
-
mark: "000",
|
|
320
|
-
marktext: "fff",
|
|
321
|
-
graytext: "808080",
|
|
322
|
-
};
|
|
323
|
-
const setSystemColors = (cols) => Object.assign(CSS_SYSTEM_COLORS, cols);
|
|
324
|
-
|
|
325
|
-
const CONVERSIONS = {};
|
|
326
|
-
const defConversions = (mode, spec) => {
|
|
327
|
-
for (let id in spec) {
|
|
328
|
-
const val = spec[id];
|
|
329
|
-
if (checks.isArray(val)) {
|
|
330
|
-
const [a, b, c, d] = val;
|
|
331
|
-
spec[id] =
|
|
332
|
-
val.length === 2
|
|
333
|
-
? (out, src) => b(out, a(out, src))
|
|
334
|
-
: val.length === 3
|
|
335
|
-
? (out, src) => c(out, b(out, a(out, src)))
|
|
336
|
-
: (out, src) => d(out, c(out, b(out, a(out, src))));
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
CONVERSIONS[mode] = spec;
|
|
340
|
-
};
|
|
341
|
-
const convert = (res, src, destMode, srcMode) => {
|
|
342
|
-
const spec = CONVERSIONS[destMode];
|
|
343
|
-
api.assert(!!spec, `no conversions available for ${destMode}`);
|
|
344
|
-
let $convert = spec[srcMode];
|
|
345
|
-
return $convert
|
|
346
|
-
? $convert(res, src)
|
|
347
|
-
: CONVERSIONS.rgb[srcMode]
|
|
348
|
-
? spec.rgb(res, CONVERSIONS.rgb[srcMode]([], src))
|
|
349
|
-
: errors.unsupported(`can't convert: ${srcMode} -> ${destMode}`);
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const intArgb32Srgb = (out, src) => vectors.setC4(out || [], ((src >>> 16) & 0xff) * INV8BIT, ((src >>> 8) & 0xff) * INV8BIT, (src & 0xff) * INV8BIT, (src >>> 24) * INV8BIT);
|
|
353
|
-
const intAbgr32Srgb = (out, src) => vectors.setC4(out || [], (src & 0xff) * INV8BIT, ((src >>> 8) & 0xff) * INV8BIT, ((src >>> 16) & 0xff) * INV8BIT, (src >>> 24) * INV8BIT);
|
|
354
|
-
const intRgb24Srgb = (out, src) => intArgb32Srgb(out, src | 0xff000000);
|
|
355
|
-
const intBgr24Srgb = (out, src) => intAbgr32Srgb(out, src | 0xff000000);
|
|
356
|
-
|
|
357
|
-
const parseCss = (src) => {
|
|
358
|
-
src = (checks.isString(src) ? src : src.deref()).toLowerCase();
|
|
359
|
-
const named = CSS_NAMES[src] || CSS_SYSTEM_COLORS[src];
|
|
360
|
-
if (named || src[0] === "#")
|
|
361
|
-
return new ParsedColor("srgb", intArgb32Srgb([], parseHex(named || src)));
|
|
362
|
-
const parts = src.split(/[(),/ ]+/);
|
|
363
|
-
const [mode, a, b, c, d] = parts;
|
|
364
|
-
api.assert(parts.length === 5 || parts.length === 6, `invalid ${mode} color: ${src}`);
|
|
365
|
-
switch (mode) {
|
|
366
|
-
case "rgb":
|
|
367
|
-
case "rgba":
|
|
368
|
-
return new ParsedColor("srgb", [
|
|
369
|
-
parseNumOrPercent(a),
|
|
370
|
-
parseNumOrPercent(b),
|
|
371
|
-
parseNumOrPercent(c),
|
|
372
|
-
parseAlpha(d),
|
|
373
|
-
]);
|
|
374
|
-
case "hsl":
|
|
375
|
-
case "hsla":
|
|
376
|
-
return new ParsedColor("hsl", [
|
|
377
|
-
parseHue(a),
|
|
378
|
-
parsePercent(b),
|
|
379
|
-
parsePercent(c),
|
|
380
|
-
parseAlpha(d),
|
|
381
|
-
]);
|
|
382
|
-
case "lab":
|
|
383
|
-
return new ParsedColor("lab50", [
|
|
384
|
-
parsePercent(a, false),
|
|
385
|
-
parseNumber(b) * 0.01,
|
|
386
|
-
parseNumber(c) * 0.01,
|
|
387
|
-
parseAlpha(d),
|
|
388
|
-
]);
|
|
389
|
-
case "lch":
|
|
390
|
-
return new ParsedColor("lch", [
|
|
391
|
-
parsePercent(a, false),
|
|
392
|
-
parseNumber(b) * 0.01,
|
|
393
|
-
parseHue(c),
|
|
394
|
-
parseAlpha(d),
|
|
395
|
-
]);
|
|
396
|
-
default:
|
|
397
|
-
errors.unsupported(`color mode: ${mode}`);
|
|
398
|
-
}
|
|
399
|
-
};
|
|
400
|
-
const HUE_NORMS = {
|
|
401
|
-
rad: math.TAU,
|
|
402
|
-
grad: 400,
|
|
403
|
-
turn: 1,
|
|
404
|
-
deg: 360,
|
|
405
|
-
undefined: 360,
|
|
406
|
-
};
|
|
407
|
-
const parseHue = (x) => {
|
|
408
|
-
const match = /^(-?[0-9.]+)(deg|rad|grad|turn)?$/.exec(x);
|
|
409
|
-
api.assert(!!match, `expected hue, got: ${x}`);
|
|
410
|
-
return math.fract(parseFloat(match[1]) / HUE_NORMS[match[2]]);
|
|
411
|
-
};
|
|
412
|
-
const parseAlpha = (x) => (x ? parseNumOrPercent(x, 1) : 1);
|
|
413
|
-
const parsePercent = (x, clamp = true) => {
|
|
414
|
-
api.assert(/^([0-9.]+)%$/.test(x), `expected percentage, got: ${x}`);
|
|
415
|
-
const res = parseFloat(x) / 100;
|
|
416
|
-
return clamp ? math.clamp01(res) : res;
|
|
417
|
-
};
|
|
418
|
-
const parseNumber = (x) => {
|
|
419
|
-
api.assert(/^-?[0-9.]+$/.test(x), `expected number, got: ${x}`);
|
|
420
|
-
return parseFloat(x);
|
|
421
|
-
};
|
|
422
|
-
const parseNumOrPercent = (x, norm = 255, clamp = true) => {
|
|
423
|
-
api.assert(/^-?[0-9.]+%?$/.test(x), `expected number or percentage, got: ${x}`);
|
|
424
|
-
const res = parseFloat(x) / (x.endsWith("%") ? 100 : norm);
|
|
425
|
-
return clamp ? math.clamp01(res) : res;
|
|
426
|
-
};
|
|
427
|
-
const parseHex = (src) => {
|
|
428
|
-
const match = /^#?([0-9a-f]{3,8})$/i.exec(src);
|
|
429
|
-
if (match) {
|
|
430
|
-
const hex = match[1];
|
|
431
|
-
switch (hex.length) {
|
|
432
|
-
case 3:
|
|
433
|
-
return ((binary.interleave4_12_24(parseInt(hex, 16)) | 0xff000000) >>> 0);
|
|
434
|
-
case 4:
|
|
435
|
-
return binary.interleave4_16_32(parseInt(hex, 16)) >>> 0;
|
|
436
|
-
case 6:
|
|
437
|
-
return (parseInt(hex, 16) | 0xff000000) >>> 0;
|
|
438
|
-
case 8:
|
|
439
|
-
return parseInt(hex, 16) >>> 0;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
return errors.illegalArgs(`invalid hex color: "${src}"`);
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
const ensureAlpha = (x, def = 1) => x != undefined ? math.clamp01(x) : def;
|
|
446
|
-
|
|
447
|
-
const linearSrgb = (x) => x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;
|
|
448
|
-
const srgbLinear = (x) => x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
|
|
449
|
-
|
|
450
|
-
const srgbRgb = (out, src) => vectors.setC4(out || src, srgbLinear(src[0]), srgbLinear(src[1]), srgbLinear(src[2]), ensureAlpha(src[3]));
|
|
451
|
-
const GAMMA$1 = 2.2;
|
|
452
|
-
const srgbRgbApprox = (out, src) => vectors.setC4(out || src, src[0] ** GAMMA$1, src[1] ** GAMMA$1, src[2] ** GAMMA$1, ensureAlpha(src[3]));
|
|
453
|
-
|
|
454
|
-
const intArgb32Rgb = (out, src) => srgbRgb(null, intArgb32Srgb(out, src));
|
|
455
|
-
const intRgb24Rgb = (out, src) => srgbRgb(null, intRgb24Srgb(out, src));
|
|
456
|
-
const intAbgr32Rgb = (out, src) => srgbRgb(null, intAbgr32Srgb(out, src));
|
|
457
|
-
const intBgr24Rgb = (out, src) => srgbRgb(null, intBgr24Srgb(out, src));
|
|
458
|
-
|
|
459
|
-
const ensureArgs = (args) => {
|
|
460
|
-
if (typeof args[0] === "number") {
|
|
461
|
-
switch (args.length) {
|
|
462
|
-
case 1:
|
|
463
|
-
return args.push(0, 0, 1), [args];
|
|
464
|
-
case 2:
|
|
465
|
-
return args.push(0, 1), [args];
|
|
466
|
-
case 3:
|
|
467
|
-
return args.push(1), [args];
|
|
468
|
-
default:
|
|
469
|
-
return [args];
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return args;
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
const defColor = (spec) => {
|
|
476
|
-
const channels = spec.channels || {};
|
|
477
|
-
const order = spec.order;
|
|
478
|
-
const numChannels = order.length;
|
|
479
|
-
order.reduce((acc, id) => {
|
|
480
|
-
acc[id] = Object.assign({ range: [0, 1] }, channels[id]);
|
|
481
|
-
return acc;
|
|
482
|
-
}, channels);
|
|
483
|
-
const min = order.map((id) => channels[id].range[0]);
|
|
484
|
-
const max = order.map((id) => channels[id].range[1]);
|
|
485
|
-
const minR = vectors.set4([], min);
|
|
486
|
-
const maxR = vectors.set4([], max);
|
|
487
|
-
minR[numChannels - 1] = 1;
|
|
488
|
-
const $Color = class {
|
|
489
|
-
constructor(buf, offset = 0, stride = 1) {
|
|
490
|
-
this.offset = offset;
|
|
491
|
-
this.stride = stride;
|
|
492
|
-
this.buf = buf || [0, 0, 0, 0];
|
|
493
|
-
this.offset = offset;
|
|
494
|
-
this.stride = stride;
|
|
495
|
-
}
|
|
496
|
-
get mode() {
|
|
497
|
-
return spec.mode;
|
|
498
|
-
}
|
|
499
|
-
get length() {
|
|
500
|
-
return numChannels;
|
|
501
|
-
}
|
|
502
|
-
get range() {
|
|
503
|
-
return [min, max];
|
|
504
|
-
}
|
|
505
|
-
get [Symbol.toStringTag]() {
|
|
506
|
-
return spec.mode;
|
|
507
|
-
}
|
|
508
|
-
[Symbol.iterator]() {
|
|
509
|
-
return vectors.stridedValues(this.buf, this.length, this.offset, this.stride);
|
|
510
|
-
}
|
|
511
|
-
copy() {
|
|
512
|
-
return new $Color(this.deref());
|
|
513
|
-
}
|
|
514
|
-
copyView() {
|
|
515
|
-
return new $Color(this.buf, this.offset, this.stride);
|
|
516
|
-
}
|
|
517
|
-
empty() {
|
|
518
|
-
return new $Color();
|
|
519
|
-
}
|
|
520
|
-
deref() {
|
|
521
|
-
return [this[0], this[1], this[2], this[3]];
|
|
522
|
-
}
|
|
523
|
-
set(src) {
|
|
524
|
-
return vectors.set4(this, src);
|
|
525
|
-
}
|
|
526
|
-
clamp() {
|
|
527
|
-
return vectors.clamp4(null, this, min, max);
|
|
528
|
-
}
|
|
529
|
-
eqDelta(o, eps = math.EPS) {
|
|
530
|
-
return vectors.eqDelta4(this, o, eps);
|
|
531
|
-
}
|
|
532
|
-
randomize(rnd) {
|
|
533
|
-
return vectors.randMinMax(this, minR, maxR, rnd);
|
|
534
|
-
}
|
|
535
|
-
toJSON() {
|
|
536
|
-
return this.deref();
|
|
537
|
-
}
|
|
538
|
-
toString() {
|
|
539
|
-
return strings.vector(4, 4)(this);
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
vectors.declareIndices($Color.prototype, order);
|
|
543
|
-
defConversions(spec.mode, spec.from);
|
|
544
|
-
const fromColor = (src, mode, xs) => {
|
|
545
|
-
const res = new $Color(...xs);
|
|
546
|
-
return mode !== spec.mode
|
|
547
|
-
? convert(res, src, spec.mode, mode)
|
|
548
|
-
: res.set(src);
|
|
549
|
-
};
|
|
550
|
-
const factory = (src, ...xs) => src == null
|
|
551
|
-
? new $Color()
|
|
552
|
-
: checks.isString(src)
|
|
553
|
-
? factory(parseCss(src), ...xs)
|
|
554
|
-
: checks.isArrayLike(src)
|
|
555
|
-
? checks.isString(src.mode)
|
|
556
|
-
? fromColor(src, src.mode, xs)
|
|
557
|
-
: new $Color(src, ...xs)
|
|
558
|
-
: checks.implementsFunction(src, "deref")
|
|
559
|
-
? fromColor(src.deref(), src.mode, xs)
|
|
560
|
-
: checks.isNumber(src)
|
|
561
|
-
? xs.length && xs.every(checks.isNumber)
|
|
562
|
-
? new $Color(...ensureArgs([src, ...xs]))
|
|
563
|
-
: fromColor(intArgb32Rgb([], src), "rgb", xs)
|
|
564
|
-
: errors.illegalArgs(`can't create a ${spec.mode} color from: ${src}`);
|
|
565
|
-
factory.class = $Color;
|
|
566
|
-
factory.range = [min, max];
|
|
567
|
-
factory.random = (rnd, buf, idx, stride) => new $Color(buf, idx, stride).randomize(rnd);
|
|
568
|
-
factory.mapBuffer = (buf, num = (buf.length / numChannels) | 0, start = 0, cstride = 1, estride = numChannels) => vectors.mapStridedBuffer($Color, buf, num, start, cstride, estride);
|
|
569
|
-
return factory;
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
const hueRgb = (out, hue, alpha = 1) => {
|
|
573
|
-
hue = math.fract(hue) * 6;
|
|
574
|
-
return vectors.setC4(out || [], math.clamp01(Math.abs(hue - 3) - 1), math.clamp01(2 - Math.abs(hue - 2)), math.clamp01(2 - Math.abs(hue - 4)), alpha);
|
|
575
|
-
};
|
|
576
|
-
const namedHueRgb = (out, hue, alpha = 1) => hueRgb(out, hue / 12, alpha);
|
|
577
|
-
|
|
578
|
-
const luminanceRgb = (rgb, weights = RGB_LUMINANCE_REC709) => vectors.dot3(rgb, weights);
|
|
579
|
-
const luminanceSrgb = (rgb) => vectors.dot3(rgb, RGB_LUMINANCE_REC601);
|
|
580
|
-
const luminanceIntArgb32 = (rgb) => (((rgb >>> 16) & 0xff) * 76 +
|
|
581
|
-
((rgb >>> 8) & 0xff) * 150 +
|
|
582
|
-
(rgb & 0xff) * 29) /
|
|
583
|
-
0xfe01;
|
|
584
|
-
const luminanceIntAbgr32 = (rgb) => (((rgb >>> 16) & 0xff) * 29 +
|
|
585
|
-
((rgb >>> 8) & 0xff) * 150 +
|
|
586
|
-
(rgb & 0xff) * 76) /
|
|
587
|
-
0xfe01;
|
|
588
|
-
const luminanceArgb32 = (argb) => luminanceIntArgb32(argb[0]);
|
|
589
|
-
const luminanceAbgr32 = (argb) => luminanceIntAbgr32(argb[0]);
|
|
590
|
-
|
|
591
|
-
const clamp = (out, src, alpha = 1) => vectors.setC4(out || src, math.clamp01(src[0]), math.clamp01(src[1]), math.clamp01(src[2]), ensureAlpha(src[3], alpha));
|
|
592
|
-
const clampH = (out, src, alpha = 1) => vectors.setC4(out || src, math.fract(src[0]), math.clamp01(src[1]), math.clamp01(src[2]), ensureAlpha(src[3], alpha));
|
|
593
|
-
|
|
594
|
-
const rgbHcv = (out, src) => {
|
|
595
|
-
out = clamp(out || src, src);
|
|
596
|
-
const p = out[1] < out[2]
|
|
597
|
-
? [out[2], out[1], -1, 2 / 3]
|
|
598
|
-
: [out[1], out[2], 0, -1 / 3];
|
|
599
|
-
const q = out[0] < p[0] ? [p[0], p[1], p[3], out[0]] : [out[0], p[1], p[2], p[0]];
|
|
600
|
-
const c = q[0] - Math.min(q[1], q[3]);
|
|
601
|
-
return vectors.setC3(out, math.clamp01(Math.abs((q[3] - q[1]) / (6 * c + math.EPS) + q[2])), math.clamp01(c), math.clamp01(q[0]));
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
const rgbHcy = (out, src) => {
|
|
605
|
-
const y = luminanceRgb(src);
|
|
606
|
-
out = rgbHcv(out, src);
|
|
607
|
-
const z = luminanceRgb(hueRgb([], out[0]));
|
|
608
|
-
out[1] *= y < z ? z / (y + math.EPS) : (1 - z) / (1 + math.EPS - y);
|
|
609
|
-
out[2] = y;
|
|
610
|
-
return out;
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
const hcy = defColor({
|
|
614
|
-
mode: "hcy",
|
|
615
|
-
order: ["h", "c", "y", "alpha"],
|
|
616
|
-
from: { rgb: rgbHcy, srgb: rgbHcy },
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
const SQRT32 = math.SQRT3 / 2;
|
|
620
|
-
const rgbHsi = (out, src) => {
|
|
621
|
-
out = clamp(out || src, src);
|
|
622
|
-
const { 0: r, 1: g, 2: b } = out;
|
|
623
|
-
const i = math.THIRD * (r + g + b);
|
|
624
|
-
return i < 1e-6 || (r === g && r === b)
|
|
625
|
-
? vectors.setC3(out, 0, 0, i)
|
|
626
|
-
: vectors.setC3(out, math.atan2Abs(SQRT32 * (g - b), 0.5 * (2 * r - g - b)) / math.TAU, 1 - Math.min(r, g, b) / i, i);
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
const hsi = defColor({
|
|
630
|
-
mode: "hsi",
|
|
631
|
-
order: ["h", "s", "i", "alpha"],
|
|
632
|
-
from: { rgb: rgbHsi, srgb: rgbHsi },
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
const hsvHsl = (out, src) => {
|
|
636
|
-
out = clampH(out || src, src);
|
|
637
|
-
const s = out[1];
|
|
638
|
-
const v = out[2];
|
|
639
|
-
const l = ((2 - s) * v) / 2;
|
|
640
|
-
out[2] = l;
|
|
641
|
-
out[1] = l && l < 1 ? (s * v) / (l < 0.5 ? l * 2 : 2 - l * 2) : s;
|
|
642
|
-
return out;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
|
-
const rgbHsl = (out, src) => {
|
|
646
|
-
out = rgbHcv(out, src);
|
|
647
|
-
out[2] -= out[1] * 0.5;
|
|
648
|
-
out[1] /= 1 + math.EPS - Math.abs(out[2] * 2 - 1);
|
|
649
|
-
return out;
|
|
650
|
-
};
|
|
651
|
-
|
|
652
|
-
const hsl = defColor({
|
|
653
|
-
mode: "hsl",
|
|
654
|
-
order: ["h", "s", "l", "alpha"],
|
|
655
|
-
from: { rgb: rgbHsl, srgb: rgbHsl, hsv: hsvHsl },
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
const hslHsv = (out, src) => {
|
|
659
|
-
out = clampH(out || src, src);
|
|
660
|
-
const s = out[1];
|
|
661
|
-
const l = out[2];
|
|
662
|
-
const l2 = 2 * l;
|
|
663
|
-
const v = (l2 + s * (1 - Math.abs(l2 - 1))) * 0.5;
|
|
664
|
-
out[1] = (2 * (v - l)) / v;
|
|
665
|
-
out[2] = v;
|
|
666
|
-
return out;
|
|
667
|
-
};
|
|
668
|
-
|
|
669
|
-
const rgbHsv = (out, src) => {
|
|
670
|
-
out = rgbHcv(out, src);
|
|
671
|
-
out[1] /= out[2] + math.EPS;
|
|
672
|
-
return out;
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
const hsv = defColor({
|
|
676
|
-
mode: "hsv",
|
|
677
|
-
order: ["h", "s", "v", "alpha"],
|
|
678
|
-
from: { rgb: rgbHsv, srgb: rgbHsv, hsl: hslHsv },
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
const hcyRgb = (out, src) => {
|
|
682
|
-
const h = src[0];
|
|
683
|
-
let c = src[1];
|
|
684
|
-
const y = src[2];
|
|
685
|
-
const rgb = hueRgb(out || src, h, ensureAlpha(src[3]));
|
|
686
|
-
const lum = luminanceRgb(rgb);
|
|
687
|
-
if (y < lum) {
|
|
688
|
-
c *= y / lum;
|
|
689
|
-
}
|
|
690
|
-
else if (lum < 1) {
|
|
691
|
-
c *= (1 - y) / (1 - lum);
|
|
692
|
-
}
|
|
693
|
-
return vectors.setC3(rgb, math.clamp01((rgb[0] - lum) * c + y), math.clamp01((rgb[1] - lum) * c + y), math.clamp01((rgb[2] - lum) * c + y));
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
const hsiRgb = (out, src) => {
|
|
697
|
-
out = clampH(out || src, src);
|
|
698
|
-
const s = out[1];
|
|
699
|
-
const i = out[2];
|
|
700
|
-
if (s < 1e-6) {
|
|
701
|
-
return vectors.setC3(out, i, i, i);
|
|
702
|
-
}
|
|
703
|
-
const h = (out[0] * 6) % 6;
|
|
704
|
-
const m = i * (1 - s);
|
|
705
|
-
const z = 1 - Math.abs((h % 2) - 1);
|
|
706
|
-
let c = (3 * i * s) / (1 + z);
|
|
707
|
-
const x = c * z + m;
|
|
708
|
-
c += m;
|
|
709
|
-
switch (h | 0) {
|
|
710
|
-
case 0:
|
|
711
|
-
return vectors.setC3(out, c, x, m);
|
|
712
|
-
case 1:
|
|
713
|
-
return vectors.setC3(out, x, c, m);
|
|
714
|
-
case 2:
|
|
715
|
-
return vectors.setC3(out, m, c, x);
|
|
716
|
-
case 3:
|
|
717
|
-
return vectors.setC3(out, m, x, c);
|
|
718
|
-
case 4:
|
|
719
|
-
return vectors.setC3(out, x, m, c);
|
|
720
|
-
case 5:
|
|
721
|
-
return vectors.setC3(out, c, m, x);
|
|
722
|
-
default:
|
|
723
|
-
return vectors.setC3(out, m, m, m);
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
const hslRgb = (out, src) => {
|
|
728
|
-
const s = math.clamp01(src[1]);
|
|
729
|
-
const l = math.clamp01(src[2]);
|
|
730
|
-
out = hueRgb(out || src, src[0], ensureAlpha(src[3]));
|
|
731
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
732
|
-
return vectors.setC3(out, (out[0] - 0.5) * c + l, (out[1] - 0.5) * c + l, (out[2] - 0.5) * c + l);
|
|
733
|
-
};
|
|
734
|
-
|
|
735
|
-
const hsvRgb = (out, src) => {
|
|
736
|
-
out = clampH(out || src, src);
|
|
737
|
-
const s = out[1];
|
|
738
|
-
const v = out[2];
|
|
739
|
-
hueRgb(out, src[0], out[3]);
|
|
740
|
-
return vectors.setC3(out, ((out[0] - 1) * s + 1) * v, ((out[1] - 1) * s + 1) * v, ((out[2] - 1) * s + 1) * v);
|
|
741
|
-
};
|
|
742
|
-
|
|
743
|
-
const rgbSrgb = (out, src) => vectors.setC4(out || src, linearSrgb(src[0]), linearSrgb(src[1]), linearSrgb(src[2]), ensureAlpha(src[3]));
|
|
744
|
-
const GAMMA = 1 / 2.2;
|
|
745
|
-
const rgbSrgbApprox = (out, src) => vectors.setC4(out || src, src[0] ** GAMMA, src[1] ** GAMMA, src[2] ** GAMMA, ensureAlpha(src[3]));
|
|
746
|
-
|
|
747
|
-
const srgb = defColor({
|
|
748
|
-
mode: "srgb",
|
|
749
|
-
order: ["r", "g", "b", "alpha"],
|
|
750
|
-
from: {
|
|
751
|
-
abgr32: (out, src) => intAbgr32Srgb(out, src[0]),
|
|
752
|
-
argb32: (out, src) => intArgb32Srgb(out, src[0]),
|
|
753
|
-
hcy: hcyRgb,
|
|
754
|
-
hsi: hsiRgb,
|
|
755
|
-
hsl: hslRgb,
|
|
756
|
-
hsv: hsvRgb,
|
|
757
|
-
rgb: rgbSrgb,
|
|
758
|
-
},
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
const srgbIntArgb32 = (src) => (((ensureAlpha(src[3]) * 0xff + 0.5) << 24) |
|
|
762
|
-
((math.clamp01(src[0]) * 0xff + 0.5) << 16) |
|
|
763
|
-
((math.clamp01(src[1]) * 0xff + 0.5) << 8) |
|
|
764
|
-
(math.clamp01(src[2]) * 0xff + 0.5)) >>>
|
|
765
|
-
0;
|
|
766
|
-
const srgbIntAbgr32 = (src) => (((ensureAlpha(src[3]) * 0xff + 0.5) << 24) |
|
|
767
|
-
((math.clamp01(src[2]) * 0xff + 0.5) << 16) |
|
|
768
|
-
((math.clamp01(src[1]) * 0xff + 0.5) << 8) |
|
|
769
|
-
(math.clamp01(src[0]) * 0xff + 0.5)) >>>
|
|
770
|
-
0;
|
|
771
|
-
|
|
772
|
-
class Int32 {
|
|
773
|
-
constructor(buf, offset = 0, stride = 1) {
|
|
774
|
-
this.offset = offset;
|
|
775
|
-
this.stride = stride;
|
|
776
|
-
this.buf = buf || [0];
|
|
777
|
-
}
|
|
778
|
-
get length() {
|
|
779
|
-
return 1;
|
|
780
|
-
}
|
|
781
|
-
get range() {
|
|
782
|
-
return [[0], [0xffffffff]];
|
|
783
|
-
}
|
|
784
|
-
get alpha() {
|
|
785
|
-
return (this[0] >>> 24) / 255;
|
|
786
|
-
}
|
|
787
|
-
set alpha(a) {
|
|
788
|
-
this[0] = (this[0] & 0xffffff) | ((math.clamp01(a) * 0xff + 0.5) << 24);
|
|
789
|
-
}
|
|
790
|
-
*[Symbol.iterator]() {
|
|
791
|
-
yield this[0];
|
|
792
|
-
}
|
|
793
|
-
deref() {
|
|
794
|
-
return [this[0]];
|
|
795
|
-
}
|
|
796
|
-
randomize(rnd = random.SYSTEM) {
|
|
797
|
-
const x = this[0];
|
|
798
|
-
this[0] = (x & 0xff000000) | (rnd.int() & 0xffffff);
|
|
799
|
-
return this;
|
|
800
|
-
}
|
|
801
|
-
clamp() {
|
|
802
|
-
return this;
|
|
803
|
-
}
|
|
804
|
-
set(src) {
|
|
805
|
-
this[0] = src[0];
|
|
806
|
-
return this;
|
|
807
|
-
}
|
|
808
|
-
toJSON() {
|
|
809
|
-
return [this[0]];
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
class ARGB extends Int32 {
|
|
813
|
-
get mode() {
|
|
814
|
-
return "argb32";
|
|
815
|
-
}
|
|
816
|
-
copy() {
|
|
817
|
-
return new ARGB([this[0]]);
|
|
818
|
-
}
|
|
819
|
-
copyView() {
|
|
820
|
-
return new ARGB(this.buf, this.offset, this.stride);
|
|
821
|
-
}
|
|
822
|
-
empty() {
|
|
823
|
-
return new ARGB();
|
|
824
|
-
}
|
|
825
|
-
eqDelta(o, eps = 0) {
|
|
826
|
-
return vectors.eqDelta4(intArgb32Srgb([], this[0]), intArgb32Srgb([], o[0]), eps);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
vectors.declareIndex(ARGB.prototype, "value", 0);
|
|
830
|
-
class ABGR extends Int32 {
|
|
831
|
-
get mode() {
|
|
832
|
-
return "abgr32";
|
|
833
|
-
}
|
|
834
|
-
copy() {
|
|
835
|
-
return new ABGR([this[0]]);
|
|
836
|
-
}
|
|
837
|
-
copyView() {
|
|
838
|
-
return new ABGR(this.buf, this.offset, this.stride);
|
|
839
|
-
}
|
|
840
|
-
empty() {
|
|
841
|
-
return new ABGR();
|
|
842
|
-
}
|
|
843
|
-
eqDelta(o, eps = 0) {
|
|
844
|
-
return vectors.eqDelta4(intAbgr32Srgb([], this[0]), intAbgr32Srgb([], o[0]), eps);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
vectors.declareIndex(ABGR.prototype, "value", 0);
|
|
848
|
-
const defInt = (ctor, fromSrgb) => {
|
|
849
|
-
const factory = (src, ...xs) => src == null
|
|
850
|
-
? new ARGB()
|
|
851
|
-
: checks.isNumber(src)
|
|
852
|
-
? xs.length && xs.every(checks.isNumber)
|
|
853
|
-
? new ctor([srgbIntArgb32([src, ...xs])])
|
|
854
|
-
: new ctor([src], ...xs)
|
|
855
|
-
: checks.isString(src)
|
|
856
|
-
? factory(parseCss(src))
|
|
857
|
-
: checks.isArrayLike(src)
|
|
858
|
-
? checks.isString(src.mode)
|
|
859
|
-
? new ctor([fromSrgb(srgb(src))], ...xs)
|
|
860
|
-
: new ctor(src, ...xs)
|
|
861
|
-
: checks.implementsFunction(src, "deref")
|
|
862
|
-
? new ctor([fromSrgb(srgb(src))], ...xs)
|
|
863
|
-
: errors.illegalArgs(`can't create a ARGB32 color from: ${src}`);
|
|
864
|
-
factory.class = ctor;
|
|
865
|
-
factory.range = [[0], [0xffffffff]];
|
|
866
|
-
factory.random = (rnd = random.SYSTEM, buf, idx, stride) => (new ctor(buf, idx, stride).set([
|
|
867
|
-
(rnd.int() & 0xffffff) | 0xff000000,
|
|
868
|
-
]));
|
|
869
|
-
factory.mapBuffer = (buf, num = buf.length, start = 0, cstride = 1, estride = 1) => vectors.mapStridedBuffer(ARGB, buf, num, start, cstride, estride);
|
|
870
|
-
return factory;
|
|
871
|
-
};
|
|
872
|
-
const argb32 = defInt(ARGB, srgbIntArgb32);
|
|
873
|
-
const abgr32 = defInt(ABGR, srgbIntAbgr32);
|
|
874
|
-
|
|
875
|
-
const mulV33 = (out, mat, src, clampOut = false) => {
|
|
876
|
-
const x = vectors.dotS3(mat, src, 0, 0, 3);
|
|
877
|
-
const y = vectors.dotS3(mat, src, 1, 0, 3);
|
|
878
|
-
const z = vectors.dotS3(mat, src, 2, 0, 3);
|
|
879
|
-
const a = ensureAlpha(src[3]);
|
|
880
|
-
return clampOut
|
|
881
|
-
? vectors.setC4(out || src, math.clamp01(x), math.clamp01(y), math.clamp01(z), a)
|
|
882
|
-
: vectors.setC4(out || src, x, y, z, a);
|
|
883
|
-
};
|
|
884
|
-
const mulV45 = (out, mat, src, clampOut = true) => {
|
|
885
|
-
out = vectors.setC4(out || src, src[0], src[1], src[2], ensureAlpha(src[3]));
|
|
886
|
-
const x = vectors.dotS4(out, mat, 0, 0) + mat[4];
|
|
887
|
-
const y = vectors.dotS4(out, mat, 0, 5) + mat[9];
|
|
888
|
-
const z = vectors.dotS4(out, mat, 0, 10) + mat[14];
|
|
889
|
-
const w = vectors.dotS4(out, mat, 0, 15) + mat[19];
|
|
890
|
-
return clampOut
|
|
891
|
-
? vectors.setC4(out, math.clamp01(x), math.clamp01(y), math.clamp01(z), math.clamp01(w))
|
|
892
|
-
: vectors.setC4(out, x, y, z, w);
|
|
893
|
-
};
|
|
894
|
-
const mulM45 = (a, b) => [
|
|
895
|
-
vectors.dotS4(b, a, 0, 0, 1, 5),
|
|
896
|
-
vectors.dotS4(b, a, 0, 1, 1, 5),
|
|
897
|
-
vectors.dotS4(b, a, 0, 2, 1, 5),
|
|
898
|
-
vectors.dotS4(b, a, 0, 3, 1, 5),
|
|
899
|
-
vectors.dotS4(b, a, 0, 4, 1, 5) + b[4],
|
|
900
|
-
vectors.dotS4(b, a, 5, 0, 1, 5),
|
|
901
|
-
vectors.dotS4(b, a, 5, 1, 1, 5),
|
|
902
|
-
vectors.dotS4(b, a, 5, 2, 1, 5),
|
|
903
|
-
vectors.dotS4(b, a, 5, 3, 1, 5),
|
|
904
|
-
vectors.dotS4(b, a, 5, 4, 1, 5) + b[9],
|
|
905
|
-
vectors.dotS4(b, a, 10, 0, 1, 5),
|
|
906
|
-
vectors.dotS4(b, a, 10, 1, 1, 5),
|
|
907
|
-
vectors.dotS4(b, a, 10, 2, 1, 5),
|
|
908
|
-
vectors.dotS4(b, a, 10, 3, 1, 5),
|
|
909
|
-
vectors.dotS4(b, a, 10, 4, 1, 5) + b[14],
|
|
910
|
-
vectors.dotS4(b, a, 15, 0, 1, 5),
|
|
911
|
-
vectors.dotS4(b, a, 15, 1, 1, 5),
|
|
912
|
-
vectors.dotS4(b, a, 15, 2, 1, 5),
|
|
913
|
-
vectors.dotS4(b, a, 15, 3, 1, 5),
|
|
914
|
-
vectors.dotS4(b, a, 15, 4, 1, 5) + b[19],
|
|
915
|
-
];
|
|
916
|
-
|
|
917
|
-
const rgbXyz = (out, src, mat = RGB_XYZ_D50) => mulV33(null, mat, clamp(out, src));
|
|
918
|
-
const rgbXyzD65 = (out, src) => rgbXyz(out, src, RGB_XYZ_D65);
|
|
919
|
-
|
|
920
|
-
const transform$2 = (x) => x > 0.00885645 ? Math.cbrt(x) : 7.787037 * x + 16 / 116;
|
|
921
|
-
const xyzLab = (out, src, white = D50) => {
|
|
922
|
-
const x = transform$2(src[0] / white[0]);
|
|
923
|
-
const y = transform$2(src[1] / white[1]);
|
|
924
|
-
const z = transform$2(src[2] / white[2]);
|
|
925
|
-
return vectors.setC4(out || src, 1.16 * y - 0.16, 5.0 * (x - y), 2.0 * (y - z), ensureAlpha(src[3]));
|
|
926
|
-
};
|
|
927
|
-
const xyzLabD65 = (out, src) => xyzLab(out, src, D65);
|
|
928
|
-
|
|
929
|
-
const rgbLab = (out, src) => xyzLab(null, rgbXyz(out, src));
|
|
930
|
-
const rgbLabD65 = (out, src) => xyzLabD65(null, rgbXyzD65(out, src));
|
|
931
|
-
|
|
932
|
-
const xyzXyzD65_50 = (out, src) => mulV33(out, BRADFORD_D65_D50, src);
|
|
933
|
-
const xyzXyzD50_65 = (out, src) => mulV33(out, BRADFORD_D50_D65, src);
|
|
934
|
-
|
|
935
|
-
const transform$1 = (x) => {
|
|
936
|
-
const y = x ** 3;
|
|
937
|
-
return y > 0.008856 ? y : (x - 16 / 116) / 7.787;
|
|
938
|
-
};
|
|
939
|
-
const labXyz = (out, src, white = D50) => {
|
|
940
|
-
const y = (src[0] + 0.16) / 1.16;
|
|
941
|
-
return vectors.setC4(out || src, transform$1(src[1] / 5.0 + y) * white[0], transform$1(y) * white[1], transform$1(y - src[2] / 2.0) * white[2], ensureAlpha(src[3]));
|
|
942
|
-
};
|
|
943
|
-
const labXyzD65 = (out, src) => labXyz(out, src, D65);
|
|
944
|
-
|
|
945
|
-
const labLabD50_65 = (out, src) => xyzLabD65(out, xyzXyzD50_65(out, labXyz(out, src)));
|
|
946
|
-
const labLabD65_50 = (out, src) => xyzLab(out, xyzXyzD65_50(out, labXyzD65(out, src)));
|
|
947
|
-
|
|
948
|
-
const labLch = (out, src) => {
|
|
949
|
-
const { 1: a, 2: b } = src;
|
|
950
|
-
return vectors.setC4(out || src, src[0], Math.hypot(a, b), a === 0 && b === 0 ? 0 : math.atan2Abs(b, a) * math.INV_TAU, ensureAlpha(src[3]));
|
|
951
|
-
};
|
|
952
|
-
const lchLab = (out, src) => {
|
|
953
|
-
let { 1: c, 2: h } = src;
|
|
954
|
-
h *= math.TAU;
|
|
955
|
-
const a = ensureAlpha(src[3]);
|
|
956
|
-
return c > 0
|
|
957
|
-
? vectors.setC4(out || src, src[0], Math.cos(h) * c, Math.sin(h) * c, a)
|
|
958
|
-
: vectors.setC4(out || src, src[0], 0, 0, a);
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
const labD50 = defColor({
|
|
962
|
-
mode: "lab50",
|
|
963
|
-
channels: {
|
|
964
|
-
a: { range: [-0.7929, 0.9355] },
|
|
965
|
-
b: { range: [-1.1203, 0.9339] },
|
|
966
|
-
},
|
|
967
|
-
order: ["l", "a", "b", "alpha"],
|
|
968
|
-
from: {
|
|
969
|
-
rgb: rgbLab,
|
|
970
|
-
lch: lchLab,
|
|
971
|
-
lab65: labLabD65_50,
|
|
972
|
-
xyz50: xyzLab,
|
|
973
|
-
xyz65: [xyzXyzD65_50, xyzLab],
|
|
974
|
-
},
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
const labD65 = defColor({
|
|
978
|
-
mode: "lab65",
|
|
979
|
-
channels: {
|
|
980
|
-
a: { range: [-0.8618, 0.9823] },
|
|
981
|
-
b: { range: [-1.0786, 0.9448] },
|
|
982
|
-
},
|
|
983
|
-
order: ["l", "a", "b", "alpha"],
|
|
984
|
-
from: {
|
|
985
|
-
rgb: rgbLabD65,
|
|
986
|
-
lch: [lchLab, labLabD50_65],
|
|
987
|
-
lab50: labLabD50_65,
|
|
988
|
-
xyz50: [xyzXyzD50_65, xyzLabD65],
|
|
989
|
-
xyz65: xyzLabD65,
|
|
990
|
-
},
|
|
991
|
-
});
|
|
992
|
-
|
|
993
|
-
const lch = defColor({
|
|
994
|
-
mode: "lch",
|
|
995
|
-
channels: {
|
|
996
|
-
c: { range: [0, 1.312] },
|
|
997
|
-
},
|
|
998
|
-
order: ["l", "c", "h", "alpha"],
|
|
999
|
-
from: {
|
|
1000
|
-
rgb: (out, src) => labLch(null, rgbLab(out, src)),
|
|
1001
|
-
lab50: labLch,
|
|
1002
|
-
lab65: [labLabD65_50, labLch],
|
|
1003
|
-
xyz50: [xyzLab, labLch],
|
|
1004
|
-
xyz65: [xyzXyzD65_50, xyzLab, labLch],
|
|
1005
|
-
},
|
|
1006
|
-
});
|
|
1007
|
-
|
|
1008
|
-
const CONE_LMS = [
|
|
1009
|
-
0.412165612,
|
|
1010
|
-
0.211859107,
|
|
1011
|
-
0.0883097947,
|
|
1012
|
-
0.536275208,
|
|
1013
|
-
0.6807189584,
|
|
1014
|
-
0.2818474174,
|
|
1015
|
-
0.0514575653,
|
|
1016
|
-
0.107406579,
|
|
1017
|
-
0.6302613616,
|
|
1018
|
-
];
|
|
1019
|
-
const rgbOklab = (out, src) => mulV33(null, OKLAB_M2, vectors.powN3(null, mulV33(out, CONE_LMS, src), 1 / 3));
|
|
1020
|
-
|
|
1021
|
-
const xyzOklab = (out, src) => mulV33(null, OKLAB_M2, vectors.powN3(null, mulV33(out, OKLAB_M1, src), 1 / 3));
|
|
1022
|
-
|
|
1023
|
-
const oklab = defColor({
|
|
1024
|
-
mode: "oklab",
|
|
1025
|
-
channels: {
|
|
1026
|
-
a: { range: [-0.2339, 0.2763] },
|
|
1027
|
-
b: { range: [-0.3116, 0.1985] },
|
|
1028
|
-
},
|
|
1029
|
-
order: ["l", "a", "b", "alpha"],
|
|
1030
|
-
from: {
|
|
1031
|
-
lab50: [labXyz, xyzXyzD50_65, xyzOklab],
|
|
1032
|
-
lab65: [labXyzD65, xyzOklab],
|
|
1033
|
-
lch: [lchLab, labXyzD65, xyzOklab],
|
|
1034
|
-
rgb: rgbOklab,
|
|
1035
|
-
xyz50: [xyzXyzD50_65, xyzOklab],
|
|
1036
|
-
xyz65: xyzOklab,
|
|
1037
|
-
},
|
|
1038
|
-
});
|
|
1039
|
-
|
|
1040
|
-
const xyzRgb = (out, src, mat = XYZ_RGB_D50) => mulV33(out, mat, src);
|
|
1041
|
-
const xyzRgbD65 = (out, src) => xyzRgb(out, src, XYZ_RGB_D65);
|
|
1042
|
-
|
|
1043
|
-
const labRgb = (out, src) => xyzRgb(null, labXyz(out, src));
|
|
1044
|
-
const labRgbD65 = (out, src) => xyzRgbD65(null, labXyzD65(out, src));
|
|
1045
|
-
|
|
1046
|
-
const LMS_CONE = [
|
|
1047
|
-
4.0767245293,
|
|
1048
|
-
-1.2681437731,
|
|
1049
|
-
-0.0041119885,
|
|
1050
|
-
-3.3072168827,
|
|
1051
|
-
2.6093323231,
|
|
1052
|
-
-0.7034763098,
|
|
1053
|
-
0.2307590544,
|
|
1054
|
-
-0.341134429,
|
|
1055
|
-
1.7068625689,
|
|
1056
|
-
];
|
|
1057
|
-
const oklabRgb = (out, { 0: l, 1: a, 2: b, 3: alpha }) => mulV33(out, LMS_CONE, [
|
|
1058
|
-
(l + 0.3963377774 * a + 0.2158037573 * b) ** 3,
|
|
1059
|
-
(l - 0.1055613458 * a - 0.0638541728 * b) ** 3,
|
|
1060
|
-
(l - 0.0894841775 * a - 1.291485548 * b) ** 3,
|
|
1061
|
-
alpha,
|
|
1062
|
-
]);
|
|
1063
|
-
|
|
1064
|
-
const xyyXyz = (out, src) => {
|
|
1065
|
-
const { 0: x, 1: y, 2: Y } = src;
|
|
1066
|
-
return vectors.setC4(out || src, math.safeDiv(Y * x, y), Y, math.safeDiv(Y * (1 - x - y), y), ensureAlpha(src[3]));
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
const yccRgb = (out, src, luma = RGB_LUMINANCE_REC709) => {
|
|
1070
|
-
const y = src[0];
|
|
1071
|
-
const bb = (2 - 2 * luma[2]) * src[1];
|
|
1072
|
-
const rr = (2 - 2 * luma[0]) * src[2];
|
|
1073
|
-
return vectors.setC4(out || src, y + rr, y - (luma[2] / luma[1]) * bb - (luma[0] / luma[1]) * rr, y + bb, ensureAlpha(src[3]));
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
|
-
const rgb = defColor({
|
|
1077
|
-
mode: "rgb",
|
|
1078
|
-
order: ["r", "g", "b", "alpha"],
|
|
1079
|
-
from: {
|
|
1080
|
-
abgr32: (out, src) => intAbgr32Rgb(out, src[0]),
|
|
1081
|
-
argb32: (out, src) => intArgb32Rgb(out, src[0]),
|
|
1082
|
-
hcy: hcyRgb,
|
|
1083
|
-
hsi: hsiRgb,
|
|
1084
|
-
hsl: hslRgb,
|
|
1085
|
-
hsv: hsvRgb,
|
|
1086
|
-
lab50: labRgb,
|
|
1087
|
-
lab65: labRgbD65,
|
|
1088
|
-
lch: [lchLab, labRgb],
|
|
1089
|
-
oklab: oklabRgb,
|
|
1090
|
-
rgb: vectors.set4,
|
|
1091
|
-
srgb: srgbRgb,
|
|
1092
|
-
xyy: [xyyXyz, xyzRgbD65],
|
|
1093
|
-
xyz50: xyzRgb,
|
|
1094
|
-
xyz65: xyzRgbD65,
|
|
1095
|
-
ycc: yccRgb,
|
|
1096
|
-
},
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
const xyzXyy = (out, src) => {
|
|
1100
|
-
const { 0: x, 1: Y } = src;
|
|
1101
|
-
const sum = x + Y + src[2];
|
|
1102
|
-
return vectors.setC4(out || src, math.safeDiv(x, sum), math.safeDiv(Y, sum), Y, ensureAlpha(src[3]));
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
const xyy = defColor({
|
|
1106
|
-
mode: "xyy",
|
|
1107
|
-
channels: {
|
|
1108
|
-
x: { range: [0, 0.6484] },
|
|
1109
|
-
y: { range: [0, 0.5979] },
|
|
1110
|
-
},
|
|
1111
|
-
order: ["x", "y", "Y", "alpha"],
|
|
1112
|
-
from: {
|
|
1113
|
-
rgb: (out, src) => xyzXyy(null, rgbXyzD65(out, src)),
|
|
1114
|
-
xyz50: xyzXyy,
|
|
1115
|
-
xyz65: xyzXyy,
|
|
1116
|
-
},
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
const M1I = [
|
|
1120
|
-
1.2270138511035211,
|
|
1121
|
-
-0.04058017842328059,
|
|
1122
|
-
-0.0763812845057069,
|
|
1123
|
-
-0.5577999806518222,
|
|
1124
|
-
1.1122568696168302,
|
|
1125
|
-
-0.4214819784180127,
|
|
1126
|
-
0.28125614896646783,
|
|
1127
|
-
-0.07167667866560119,
|
|
1128
|
-
1.586163220440795,
|
|
1129
|
-
];
|
|
1130
|
-
const M2I = [
|
|
1131
|
-
0.9999999984505198,
|
|
1132
|
-
1.0000000088817607,
|
|
1133
|
-
1.0000000546724108,
|
|
1134
|
-
0.3963377921737678,
|
|
1135
|
-
-0.10556134232365633,
|
|
1136
|
-
-0.08948418209496575,
|
|
1137
|
-
0.21580375806075877,
|
|
1138
|
-
-0.06385417477170588,
|
|
1139
|
-
-1.2914855378640917,
|
|
1140
|
-
];
|
|
1141
|
-
const oklabXyzD65 = (out, src) => mulV33(null, M1I, vectors.powN3(null, mulV33(out, M2I, src), 3));
|
|
1142
|
-
|
|
1143
|
-
const xyzD50 = defColor({
|
|
1144
|
-
mode: "xyz50",
|
|
1145
|
-
channels: {
|
|
1146
|
-
x: { range: [0, D50[0]] },
|
|
1147
|
-
y: { range: [0, D50[1]] },
|
|
1148
|
-
z: { range: [0, D50[2]] },
|
|
1149
|
-
},
|
|
1150
|
-
order: ["x", "y", "z", "alpha"],
|
|
1151
|
-
from: {
|
|
1152
|
-
rgb: rgbXyz,
|
|
1153
|
-
lab50: labXyz,
|
|
1154
|
-
lab65: [labXyzD65, xyzXyzD65_50],
|
|
1155
|
-
lch: [lchLab, labXyz],
|
|
1156
|
-
oklab: [oklabXyzD65, xyzXyzD65_50],
|
|
1157
|
-
xyy: xyyXyz,
|
|
1158
|
-
},
|
|
1159
|
-
});
|
|
1160
|
-
|
|
1161
|
-
const xyzD65 = defColor({
|
|
1162
|
-
mode: "xyz65",
|
|
1163
|
-
channels: {
|
|
1164
|
-
x: { range: [0, D65[0]] },
|
|
1165
|
-
y: { range: [0, D65[1]] },
|
|
1166
|
-
z: { range: [0, D65[2]] },
|
|
1167
|
-
},
|
|
1168
|
-
order: ["x", "y", "z", "alpha"],
|
|
1169
|
-
from: {
|
|
1170
|
-
rgb: rgbXyzD65,
|
|
1171
|
-
lab50: [labLabD50_65, labXyzD65],
|
|
1172
|
-
lab65: labXyzD65,
|
|
1173
|
-
lch: [lchLab, labLabD50_65, labXyzD65],
|
|
1174
|
-
oklab: oklabXyzD65,
|
|
1175
|
-
xyy: xyyXyz,
|
|
1176
|
-
},
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
const rgbYcc = (out, src, luma = RGB_LUMINANCE_REC709) => {
|
|
1180
|
-
const y = vectors.dot3(src, luma);
|
|
1181
|
-
return vectors.setC4(out || src, y, (0.5 * (src[2] - y)) / (1 - luma[2]), (0.5 * (src[0] - y)) / (1 - luma[0]), ensureAlpha(src[3]));
|
|
1182
|
-
};
|
|
1183
|
-
|
|
1184
|
-
const ycc = defColor({
|
|
1185
|
-
mode: "ycc",
|
|
1186
|
-
channels: {
|
|
1187
|
-
cb: { range: [-0.5, 0.5] },
|
|
1188
|
-
cr: { range: [-0.5, 0.5] },
|
|
1189
|
-
},
|
|
1190
|
-
order: ["y", "cb", "cr", "alpha"],
|
|
1191
|
-
from: { rgb: rgbYcc },
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
const FACTORIES = {
|
|
1195
|
-
argb32,
|
|
1196
|
-
abgr32,
|
|
1197
|
-
hcy,
|
|
1198
|
-
hsi,
|
|
1199
|
-
hsl,
|
|
1200
|
-
hsv,
|
|
1201
|
-
lab50: labD50,
|
|
1202
|
-
lab65: labD65,
|
|
1203
|
-
lch,
|
|
1204
|
-
oklab,
|
|
1205
|
-
rgb,
|
|
1206
|
-
srgb,
|
|
1207
|
-
xyy,
|
|
1208
|
-
xyz50: xyzD50,
|
|
1209
|
-
xyz65: xyzD65,
|
|
1210
|
-
ycc,
|
|
1211
|
-
};
|
|
1212
|
-
function color(src, buf, idx, stride) {
|
|
1213
|
-
if (checks.isString(src))
|
|
1214
|
-
return FACTORIES[src](buf, idx, stride);
|
|
1215
|
-
if (buf) {
|
|
1216
|
-
const res = FACTORIES[src.mode](buf, idx, stride);
|
|
1217
|
-
res.set(src.deref());
|
|
1218
|
-
return res;
|
|
1219
|
-
}
|
|
1220
|
-
return FACTORIES[src.mode](src.deref());
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
const hslCss = (src) => {
|
|
1224
|
-
const h = exports.FF(math.fract(src[0]) * 360);
|
|
1225
|
-
const s = exports.PC(math.clamp01(src[1]));
|
|
1226
|
-
const l = exports.PC(math.clamp01(src[2]));
|
|
1227
|
-
const a = ensureAlpha(src[3]);
|
|
1228
|
-
return a < 1 ? `hsla(${h},${s},${l},${exports.FF(a)})` : `hsl(${h},${s},${l})`;
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
|
-
const hsvCss = (src) => hslCss(hsvHsl([], src));
|
|
1232
|
-
|
|
1233
|
-
const intArgb32Css = (src) => {
|
|
1234
|
-
const a = src >>> 24;
|
|
1235
|
-
return a < 255
|
|
1236
|
-
? `rgba(${(src >> 16) & 0xff},${(src >> 8) & 0xff},${src & 0xff},${exports.FF(a * INV8BIT)})`
|
|
1237
|
-
: `#${strings.U24(src & 0xffffff)}`;
|
|
1238
|
-
};
|
|
1239
|
-
const intRgb24Css = (src) => `#${strings.U24(src & 0xffffff)}`;
|
|
1240
|
-
|
|
1241
|
-
const intArgb32Abgr32 = binary.swapLane13;
|
|
1242
|
-
const intAbgr32Argb32 = binary.swapLane13;
|
|
1243
|
-
|
|
1244
|
-
const srgbCss = (src) => {
|
|
1245
|
-
const r = (math.clamp01(src[0]) * 0xff + 0.5) | 0;
|
|
1246
|
-
const g = (math.clamp01(src[1]) * 0xff + 0.5) | 0;
|
|
1247
|
-
const b = (math.clamp01(src[2]) * 0xff + 0.5) | 0;
|
|
1248
|
-
const a = ensureAlpha(src[3]);
|
|
1249
|
-
return a < 1
|
|
1250
|
-
? `rgba(${r},${g},${b},${exports.FF(a)})`
|
|
1251
|
-
: `#${strings.U24((r << 16) | (g << 8) | b)}`;
|
|
1252
|
-
};
|
|
1253
|
-
|
|
1254
|
-
const rgbCss = (src) => srgbCss(rgbSrgb([], src));
|
|
1255
|
-
|
|
1256
|
-
const CSS_CONVERSIONS = {
|
|
1257
|
-
abgr32: (x) => intArgb32Css(intAbgr32Argb32(x[0])),
|
|
1258
|
-
argb32: (x) => intArgb32Css(x[0]),
|
|
1259
|
-
hsl: hslCss,
|
|
1260
|
-
hsv: hsvCss,
|
|
1261
|
-
lab50: (src) => srgbCss(rgbSrgb(null, labRgb([], src))),
|
|
1262
|
-
lab65: (src) => srgbCss(rgbSrgb(null, labRgbD65([], src))),
|
|
1263
|
-
lch: (src) => srgbCss(rgbSrgb(null, labRgb(null, lchLab([], src)))),
|
|
1264
|
-
rgb: rgbCss,
|
|
1265
|
-
srgb: srgbCss,
|
|
1266
|
-
};
|
|
1267
|
-
const css = (src) => {
|
|
1268
|
-
let asCss;
|
|
1269
|
-
return checks.isString(src)
|
|
1270
|
-
? src
|
|
1271
|
-
: checks.isNumber(src)
|
|
1272
|
-
? intArgb32Css(src)
|
|
1273
|
-
: src.mode
|
|
1274
|
-
? (asCss = CSS_CONVERSIONS[src.mode])
|
|
1275
|
-
? asCss(src)
|
|
1276
|
-
: CSS_CONVERSIONS.rgb(convert([], src, "rgb", src.mode))
|
|
1277
|
-
: srgbCss(src);
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
const labCss = (src) => {
|
|
1281
|
-
const l = exports.PC(math.clamp0(src[0]));
|
|
1282
|
-
const a = exports.FF(src[1] * 100);
|
|
1283
|
-
const b = exports.FF(src[2] * 100);
|
|
1284
|
-
const alpha = ensureAlpha(src[3]);
|
|
1285
|
-
return `lab(${l} ${a} ${b}` + (alpha < 1 ? `/${exports.FF(alpha)})` : ")");
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
const lchCss = (src) => {
|
|
1289
|
-
const l = exports.PC(math.clamp0(src[0]));
|
|
1290
|
-
const c = exports.FF(math.clamp0(src[1]) * 100);
|
|
1291
|
-
const h = exports.FF(math.fract(src[2]) * 360);
|
|
1292
|
-
const a = ensureAlpha(src[3]);
|
|
1293
|
-
return `lch(${l} ${c} ${h}` + (a < 1 ? `/${exports.FF(a)})` : ")");
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
const alpha = (src) => src[3] !== undefined ? src[3] : 1;
|
|
1297
|
-
const setAlpha = (out, src, alpha) => vectors.setC4(out || src, src[0], src[1], src[2], alpha);
|
|
1298
|
-
|
|
1299
|
-
const analogU = (x, delta, rnd) => delta !== 0 ? x + rnd.norm(delta) : x;
|
|
1300
|
-
const analogN = (x, delta, rnd, post = math.clamp01) => delta !== 0 ? post(x + rnd.norm(delta)) : x;
|
|
1301
|
-
const analogH = (x, delta, rnd) => analogN(x, delta, rnd, math.fract);
|
|
1302
|
-
const analogA = (a, delta, rnd) => delta !== 0
|
|
1303
|
-
? math.clamp01((a !== undefined ? a : 1) + rnd.norm(delta))
|
|
1304
|
-
: ensureAlpha(a);
|
|
1305
|
-
const defAnalog = (x, y, z) => (out, src, delta, rnd = random.SYSTEM) => vectors.setC4(out || src, x(src[0], delta, rnd), y(src[1], delta, rnd), z(src[2], delta, rnd), ensureAlpha(src[3]));
|
|
1306
|
-
const analogHNN = defAnalog(analogH, analogN, analogN);
|
|
1307
|
-
const analogNNN = defAnalog(analogN, analogN, analogN);
|
|
1308
|
-
const analogNUU = defAnalog(analogN, analogU, analogU);
|
|
1309
|
-
const analog = defmulti.defmulti((_, src) => src.mode);
|
|
1310
|
-
analog.add(defmulti.DEFAULT, analogNNN);
|
|
1311
|
-
analog.addAll({
|
|
1312
|
-
hcy: analogHNN,
|
|
1313
|
-
hsi: analogHNN,
|
|
1314
|
-
hsl: analogHNN,
|
|
1315
|
-
hsv: analogHNN,
|
|
1316
|
-
lab50: analogNUU,
|
|
1317
|
-
lab65: analogNUU,
|
|
1318
|
-
lch: defAnalog(analogN, analogN, analogH),
|
|
1319
|
-
ycc: analogNUU,
|
|
1320
|
-
});
|
|
1321
|
-
const analogHsv = (out, src, deltaH, deltaS = 0, deltaV = 0, deltaA = 0, rnd = random.SYSTEM) => vectors.setC4(out || src, analogN(src[0], deltaH, rnd, math.fract), analogN(src[1], deltaS, rnd), analogN(src[2], deltaV, rnd), analogA(src[3], deltaA, rnd));
|
|
1322
|
-
const analogRgb = (out, src, deltaR, deltaG = deltaR, deltaB = deltaR, deltaA = 0, rnd = random.SYSTEM) => vectors.setC4(out || src, analogN(src[0], deltaR, rnd), analogN(src[1], deltaG, rnd), analogN(src[2], deltaB, rnd), analogA(src[3], deltaA, rnd));
|
|
1323
|
-
|
|
1324
|
-
const closestHue = (h) => Math.round(math.fract(h) * 12) % 12;
|
|
1325
|
-
const closestPrimaryHue = (h) => closestHue(h) & 0xe;
|
|
1326
|
-
|
|
1327
|
-
const isBlackHsv = (x, eps = EPS) => x[2] <= eps;
|
|
1328
|
-
const isBlackRgb = (x, eps = EPS) => x[0] <= eps && x[1] <= eps && x[2] <= eps;
|
|
1329
|
-
const isBlackLch = (x, eps = EPS) => x[0] <= eps;
|
|
1330
|
-
const isBlack = defmulti.defmulti((x) => x.mode);
|
|
1331
|
-
isBlack.addAll({
|
|
1332
|
-
hcy: isBlackHsv,
|
|
1333
|
-
hsi: isBlackHsv,
|
|
1334
|
-
hsl: isBlackHsv,
|
|
1335
|
-
hsv: isBlackHsv,
|
|
1336
|
-
labD50: isBlackLch,
|
|
1337
|
-
labD65: isBlackLch,
|
|
1338
|
-
lch: isBlackLch,
|
|
1339
|
-
rgb: isBlackRgb,
|
|
1340
|
-
ycc: isBlackRgb,
|
|
1341
|
-
});
|
|
1342
|
-
isBlack.add(defmulti.DEFAULT, (x) => isBlackRgb(rgb(x)));
|
|
1343
|
-
|
|
1344
|
-
const isGrayHsv = (x, eps = EPS) => x[1] <= eps;
|
|
1345
|
-
const isGrayRgb = (x, eps = EPS) => math.eqDelta(x[0], x[1], eps) && math.eqDelta(x[0], x[2], eps);
|
|
1346
|
-
const isGrayLab = (x, eps = EPS) => math.eqDelta(x[1], 0, eps) && math.eqDelta(x[2], 0, eps);
|
|
1347
|
-
const isGray = defmulti.defmulti((x) => x.mode);
|
|
1348
|
-
isGray.addAll({
|
|
1349
|
-
hcy: isGrayHsv,
|
|
1350
|
-
hsi: isGrayHsv,
|
|
1351
|
-
hsl: isGrayHsv,
|
|
1352
|
-
hsv: isGrayHsv,
|
|
1353
|
-
labD50: isGrayLab,
|
|
1354
|
-
labD65: isGrayLab,
|
|
1355
|
-
lch: isGrayHsv,
|
|
1356
|
-
rgb: isGrayRgb,
|
|
1357
|
-
srgb: isGrayRgb,
|
|
1358
|
-
ycc: isGrayLab,
|
|
1359
|
-
});
|
|
1360
|
-
isGray.add(defmulti.DEFAULT, (x) => isGrayRgb(rgb(x)));
|
|
1361
|
-
|
|
1362
|
-
const isWhiteHsv = (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps;
|
|
1363
|
-
const isWhiteRgb = (x, eps = EPS) => {
|
|
1364
|
-
eps = 1 - eps;
|
|
1365
|
-
return x[0] >= eps && x[1] >= eps && x[2] >= eps;
|
|
1366
|
-
};
|
|
1367
|
-
const isWhiteLch = (x, eps = EPS) => x[1] <= eps && x[0] >= 1 - eps;
|
|
1368
|
-
const isWhite = defmulti.defmulti((x) => x.mode);
|
|
1369
|
-
isWhite.addAll({
|
|
1370
|
-
hcy: (x, eps = EPS) => x[1] <= eps && x[2] >= 1 - eps,
|
|
1371
|
-
hsi: isWhiteHsv,
|
|
1372
|
-
hsl: isWhiteHsv,
|
|
1373
|
-
hsv: isWhiteHsv,
|
|
1374
|
-
labD50: isWhiteLch,
|
|
1375
|
-
labD65: isWhiteLch,
|
|
1376
|
-
lch: isWhiteLch,
|
|
1377
|
-
rgb: isWhiteRgb,
|
|
1378
|
-
ycc: isWhiteLch,
|
|
1379
|
-
});
|
|
1380
|
-
isWhite.add(defmulti.DEFAULT, (x) => isWhiteRgb(rgb(x)));
|
|
1381
|
-
|
|
1382
|
-
const COLOR_RANGES = {
|
|
1383
|
-
light: {
|
|
1384
|
-
c: [[0.3, 0.7]],
|
|
1385
|
-
l: [[0.9, 1]],
|
|
1386
|
-
b: [[0.35, 0.5]],
|
|
1387
|
-
w: [[0.6, 1]],
|
|
1388
|
-
},
|
|
1389
|
-
dark: {
|
|
1390
|
-
c: [[0.7, 1]],
|
|
1391
|
-
l: [[0.15, 0.4]],
|
|
1392
|
-
b: [[0, 0.4]],
|
|
1393
|
-
w: [[0.4, 0.6]],
|
|
1394
|
-
},
|
|
1395
|
-
bright: {
|
|
1396
|
-
c: [[0.75, 0.95]],
|
|
1397
|
-
l: [[0.8, 1]],
|
|
1398
|
-
},
|
|
1399
|
-
weak: {
|
|
1400
|
-
c: [[0.15, 0.3]],
|
|
1401
|
-
l: [[0.7, 1]],
|
|
1402
|
-
b: [[0.4, 0.6]],
|
|
1403
|
-
w: [[0.8, 1]],
|
|
1404
|
-
},
|
|
1405
|
-
neutral: {
|
|
1406
|
-
c: [[0.25, 0.35]],
|
|
1407
|
-
l: [[0.3, 0.7]],
|
|
1408
|
-
b: [[0.25, 0.4]],
|
|
1409
|
-
w: [[0.9, 1]],
|
|
1410
|
-
},
|
|
1411
|
-
fresh: {
|
|
1412
|
-
c: [[0.4, 0.8]],
|
|
1413
|
-
l: [[0.8, 1]],
|
|
1414
|
-
b: [[0.05, 0.3]],
|
|
1415
|
-
w: [[0.8, 1]],
|
|
1416
|
-
},
|
|
1417
|
-
soft: {
|
|
1418
|
-
c: [[0.2, 0.3]],
|
|
1419
|
-
l: [[0.6, 0.9]],
|
|
1420
|
-
b: [[0.05, 0.15]],
|
|
1421
|
-
w: [[0.6, 0.9]],
|
|
1422
|
-
},
|
|
1423
|
-
hard: {
|
|
1424
|
-
c: [[0.85, 0.95]],
|
|
1425
|
-
l: [[0.4, 1]],
|
|
1426
|
-
},
|
|
1427
|
-
warm: {
|
|
1428
|
-
c: [[0.6, 0.9]],
|
|
1429
|
-
l: [[0.4, 0.9]],
|
|
1430
|
-
b: [[0.2, 0.3]],
|
|
1431
|
-
w: [[0.8, 1]],
|
|
1432
|
-
},
|
|
1433
|
-
cool: {
|
|
1434
|
-
c: [[0.05, 0.2]],
|
|
1435
|
-
l: [[0.9, 1]],
|
|
1436
|
-
b: [[0, 0.95]],
|
|
1437
|
-
w: [[0.95, 1]],
|
|
1438
|
-
},
|
|
1439
|
-
intense: {
|
|
1440
|
-
c: [[0.9, 1]],
|
|
1441
|
-
l: [
|
|
1442
|
-
[0.2, 0.35],
|
|
1443
|
-
[0.8, 1],
|
|
1444
|
-
],
|
|
1445
|
-
},
|
|
1446
|
-
};
|
|
1447
|
-
const FULL = [[0, 1]];
|
|
1448
|
-
const DEFAULT_RANGE = {
|
|
1449
|
-
h: FULL,
|
|
1450
|
-
c: FULL,
|
|
1451
|
-
l: FULL,
|
|
1452
|
-
b: FULL,
|
|
1453
|
-
w: FULL,
|
|
1454
|
-
a: [[1, 1]],
|
|
1455
|
-
};
|
|
1456
|
-
const DEFAULT_OPTS = {
|
|
1457
|
-
num: Infinity,
|
|
1458
|
-
variance: 0.025,
|
|
1459
|
-
eps: 1e-3,
|
|
1460
|
-
rnd: random.SYSTEM,
|
|
1461
|
-
};
|
|
1462
|
-
const $rnd = (ranges, rnd) => rnd.minmax(...ranges[rnd.int() % ranges.length]);
|
|
1463
|
-
const colorFromRange = (range, opts) => {
|
|
1464
|
-
range = Object.assign(Object.assign({}, DEFAULT_RANGE), (checks.isString(range) ? COLOR_RANGES[range] : range));
|
|
1465
|
-
const { base, variance, rnd, eps } = Object.assign(Object.assign({}, DEFAULT_OPTS), opts);
|
|
1466
|
-
let h;
|
|
1467
|
-
let c;
|
|
1468
|
-
let l;
|
|
1469
|
-
let a;
|
|
1470
|
-
if (base) {
|
|
1471
|
-
const col = lch(base);
|
|
1472
|
-
h = col[2];
|
|
1473
|
-
a = ensureAlpha(col[3]);
|
|
1474
|
-
if (isBlack(col, eps)) {
|
|
1475
|
-
c = 0;
|
|
1476
|
-
l = $rnd(range.b, rnd);
|
|
1477
|
-
}
|
|
1478
|
-
else if (isWhite(col, eps)) {
|
|
1479
|
-
c = 0;
|
|
1480
|
-
l = $rnd(range.w, rnd);
|
|
1481
|
-
}
|
|
1482
|
-
else if (isGray(col, eps)) {
|
|
1483
|
-
c = 0;
|
|
1484
|
-
l = $rnd(random.coin(rnd) ? range.b : range.w, rnd);
|
|
1485
|
-
}
|
|
1486
|
-
else {
|
|
1487
|
-
h = math.fract(h + rnd.norm(variance));
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
else {
|
|
1491
|
-
h = $rnd(range.h, rnd);
|
|
1492
|
-
a = $rnd(range.a, rnd);
|
|
1493
|
-
}
|
|
1494
|
-
return lch([
|
|
1495
|
-
l != undefined ? l : $rnd(range.l, rnd),
|
|
1496
|
-
c !== undefined ? c : $rnd(range.c, rnd),
|
|
1497
|
-
h,
|
|
1498
|
-
a,
|
|
1499
|
-
]);
|
|
1500
|
-
};
|
|
1501
|
-
function* colorsFromRange(range, opts = {}) {
|
|
1502
|
-
let num = opts.num != undefined ? opts.num : Infinity;
|
|
1503
|
-
while (--num >= 0)
|
|
1504
|
-
yield colorFromRange(range, opts);
|
|
1505
|
-
}
|
|
1506
|
-
const compileThemePart = (part, opts) => {
|
|
1507
|
-
let spec;
|
|
1508
|
-
if (checks.isArray(part)) {
|
|
1509
|
-
spec = themePartFromTuple(part);
|
|
1510
|
-
}
|
|
1511
|
-
else if (checks.isString(part)) {
|
|
1512
|
-
spec = themePartFromString(part);
|
|
1513
|
-
}
|
|
1514
|
-
else {
|
|
1515
|
-
spec = Object.assign({}, part);
|
|
1516
|
-
spec.weight == null && (spec.weight = 1);
|
|
1517
|
-
}
|
|
1518
|
-
checks.isString(spec.range) && (spec.range = COLOR_RANGES[spec.range]);
|
|
1519
|
-
checks.isString(spec.base) && (spec.base = lch(parseCss(spec.base)));
|
|
1520
|
-
if (spec.base !== undefined) {
|
|
1521
|
-
opts = Object.assign(Object.assign({}, opts), { base: spec.base });
|
|
1522
|
-
}
|
|
1523
|
-
return { spec, opts };
|
|
1524
|
-
};
|
|
1525
|
-
const themePartFromTuple = (part) => {
|
|
1526
|
-
let weight;
|
|
1527
|
-
const [range, ...xs] = part;
|
|
1528
|
-
if (checks.isNumber(arrays.peek(xs))) {
|
|
1529
|
-
weight = arrays.peek(xs);
|
|
1530
|
-
xs.pop();
|
|
1531
|
-
}
|
|
1532
|
-
else {
|
|
1533
|
-
weight = 1;
|
|
1534
|
-
}
|
|
1535
|
-
return ((xs.length === 1
|
|
1536
|
-
? { range, base: xs[0], weight }
|
|
1537
|
-
: xs.length === 0
|
|
1538
|
-
? COLOR_RANGES[range]
|
|
1539
|
-
? { range, weight }
|
|
1540
|
-
: { base: range, weight }
|
|
1541
|
-
: errors.illegalArgs(`invalid theme part: "${part}"`)));
|
|
1542
|
-
};
|
|
1543
|
-
const themePartFromString = (part) => ((COLOR_RANGES[part]
|
|
1544
|
-
? { range: part, weight: 1 }
|
|
1545
|
-
: { base: part, weight: 1 }));
|
|
1546
|
-
function* colorsFromTheme(parts, opts = {}) {
|
|
1547
|
-
let { num, variance, rnd } = Object.assign(Object.assign({}, DEFAULT_OPTS), opts);
|
|
1548
|
-
const theme = parts.map((p) => compileThemePart(p, opts));
|
|
1549
|
-
const choice = random.weightedRandom(theme, theme.map((x) => x.spec.weight), rnd);
|
|
1550
|
-
while (--num >= 0) {
|
|
1551
|
-
const { spec, opts } = choice();
|
|
1552
|
-
if (spec.range) {
|
|
1553
|
-
yield colorFromRange(spec.range, opts);
|
|
1554
|
-
}
|
|
1555
|
-
else if (spec.base) {
|
|
1556
|
-
yield analog(lch(), lch(spec.base), variance, rnd);
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
const COSINE_GRADIENTS = {
|
|
1562
|
-
"blue-cyan": [
|
|
1563
|
-
[0, 0.5, 0.5, 1],
|
|
1564
|
-
[0, 0.5, 0.5, 0],
|
|
1565
|
-
[0, 0.5, 0.3333, 0],
|
|
1566
|
-
[0, 0.5, 0.6666, 0],
|
|
1567
|
-
],
|
|
1568
|
-
"blue-magenta-orange": [
|
|
1569
|
-
[0.938, 0.328, 0.718, 1],
|
|
1570
|
-
[0.659, 0.438, 0.328, 0],
|
|
1571
|
-
[0.388, 0.388, 0.296, 0],
|
|
1572
|
-
[2.538, 2.478, 0.168, 0],
|
|
1573
|
-
],
|
|
1574
|
-
"blue-white-red": [
|
|
1575
|
-
[0.66, 0.56, 0.68, 1],
|
|
1576
|
-
[0.718, 0.438, 0.72, 0],
|
|
1577
|
-
[0.52, 0.8, 0.52, 0],
|
|
1578
|
-
[-0.43, -0.397, -0.083, 0],
|
|
1579
|
-
],
|
|
1580
|
-
"cyan-magenta": [
|
|
1581
|
-
[0.61, 0.498, 0.65, 1],
|
|
1582
|
-
[0.388, 0.498, 0.35, 0],
|
|
1583
|
-
[0.53, 0.498, 0.62, 0],
|
|
1584
|
-
[3.438, 3.012, 4.025, 0],
|
|
1585
|
-
],
|
|
1586
|
-
"green-blue-orange": [
|
|
1587
|
-
[0.892, 0.725, 0, 1],
|
|
1588
|
-
[0.878, 0.278, 0.725, 0],
|
|
1589
|
-
[0.332, 0.518, 0.545, 0],
|
|
1590
|
-
[2.44, 5.043, 0.732, 0],
|
|
1591
|
-
],
|
|
1592
|
-
"green-cyan": [
|
|
1593
|
-
[0, 0.5, 0.5, 1],
|
|
1594
|
-
[0, 0.5, 0.5, 0],
|
|
1595
|
-
[0, 0.3333, 0.5, 0],
|
|
1596
|
-
[0, 0.6666, 0.5, 0],
|
|
1597
|
-
],
|
|
1598
|
-
"green-magenta": [
|
|
1599
|
-
[0.6666, 0.5, 0.5, 1],
|
|
1600
|
-
[0.5, 0.6666, 0.5, 0],
|
|
1601
|
-
[0.6666, 0.666, 0.5, 0],
|
|
1602
|
-
[0.2, 0, 0.5, 0],
|
|
1603
|
-
],
|
|
1604
|
-
"green-red": [
|
|
1605
|
-
[0.5, 0.5, 0, 1],
|
|
1606
|
-
[0.5, 0.5, 0, 0],
|
|
1607
|
-
[0.5, 0.5, 0, 0],
|
|
1608
|
-
[0.5, 0, 0, 0],
|
|
1609
|
-
],
|
|
1610
|
-
heat1: [
|
|
1611
|
-
[0.5, 0.4, 0.25, 1],
|
|
1612
|
-
[0.5, 0.5, 0.666, 0],
|
|
1613
|
-
[0.5, 0.666, 0.8, 0],
|
|
1614
|
-
[0.5, 0.666, 0.8, 0],
|
|
1615
|
-
],
|
|
1616
|
-
"magenta-green": [
|
|
1617
|
-
[0.59, 0.811, 0.12, 1],
|
|
1618
|
-
[0.41, 0.392, 0.59, 0],
|
|
1619
|
-
[0.94, 0.548, 0.278, 0],
|
|
1620
|
-
[-4.242, -6.611, -4.045, 0],
|
|
1621
|
-
],
|
|
1622
|
-
"orange-blue": [
|
|
1623
|
-
[0.5, 0.5, 0.5, 1],
|
|
1624
|
-
[0.5, 0.5, 0.5, 0],
|
|
1625
|
-
[0.8, 0.8, 0.5, 0],
|
|
1626
|
-
[0, 0.2, 0.5, 0],
|
|
1627
|
-
],
|
|
1628
|
-
"orange-magenta-blue": [
|
|
1629
|
-
[0.821, 0.328, 0.242, 1],
|
|
1630
|
-
[0.659, 0.481, 0.896, 0],
|
|
1631
|
-
[0.612, 0.34, 0.296, 0],
|
|
1632
|
-
[2.82, 3.026, -0.273, 0],
|
|
1633
|
-
],
|
|
1634
|
-
"purple-orange-cyan": [
|
|
1635
|
-
[0.5, 0.5, 0.5, 1],
|
|
1636
|
-
[0.5, 0.5, 0.5, 0],
|
|
1637
|
-
[0.5, 0.5, 1, 0],
|
|
1638
|
-
[-0.25, 0.5, 1, 0],
|
|
1639
|
-
],
|
|
1640
|
-
rainbow1: [
|
|
1641
|
-
[0.5, 0.5, 0.5, 1],
|
|
1642
|
-
[0.5, 0.5, 0.5, 0],
|
|
1643
|
-
[1.0, 1.0, 1.0, 0],
|
|
1644
|
-
[0, 0.3333, 0.6666, 0],
|
|
1645
|
-
],
|
|
1646
|
-
rainbow2: [
|
|
1647
|
-
[0.5, 0.5, 0.5, 1],
|
|
1648
|
-
[0.666, 0.666, 0.666, 0],
|
|
1649
|
-
[1.0, 1.0, 1.0, 0],
|
|
1650
|
-
[0, 0.3333, 0.6666, 0],
|
|
1651
|
-
],
|
|
1652
|
-
rainbow3: [
|
|
1653
|
-
[0.5, 0.5, 0.5, 1],
|
|
1654
|
-
[0.75, 0.75, 0.75, 0],
|
|
1655
|
-
[1.0, 1.0, 1.0, 0],
|
|
1656
|
-
[0, 0.3333, 0.6666, 0],
|
|
1657
|
-
],
|
|
1658
|
-
rainbow4: [
|
|
1659
|
-
[0.5, 0.5, 0.5, 1],
|
|
1660
|
-
[1, 1, 1, 0],
|
|
1661
|
-
[1.0, 1.0, 1.0, 0],
|
|
1662
|
-
[0, 0.3333, 0.6666, 0],
|
|
1663
|
-
],
|
|
1664
|
-
"red-blue": [
|
|
1665
|
-
[0.5, 0, 0.5, 1],
|
|
1666
|
-
[0.5, 0, 0.5, 0],
|
|
1667
|
-
[0.5, 0, 0.5, 0],
|
|
1668
|
-
[0, 0, 0.5, 0],
|
|
1669
|
-
],
|
|
1670
|
-
"yellow-green-blue": [
|
|
1671
|
-
[0.65, 0.5, 0.31, 1],
|
|
1672
|
-
[-0.65, 0.5, 0.6, 0],
|
|
1673
|
-
[0.333, 0.278, 0.278, 0],
|
|
1674
|
-
[0.66, 0, 0.667, 0],
|
|
1675
|
-
],
|
|
1676
|
-
"yellow-magenta-cyan": [
|
|
1677
|
-
[1, 0.5, 0.5, 1],
|
|
1678
|
-
[0.5, 0.5, 0.5, 0],
|
|
1679
|
-
[0.75, 1.0, 0.6666, 0],
|
|
1680
|
-
[0.8, 1.0, 0.3333, 0],
|
|
1681
|
-
],
|
|
1682
|
-
"yellow-purple-magenta": [
|
|
1683
|
-
[0.731, 1.098, 0.192, 1],
|
|
1684
|
-
[0.358, 1.09, 0.657, 0],
|
|
1685
|
-
[1.077, 0.36, 0.328, 0],
|
|
1686
|
-
[0.965, 2.265, 0.837, 0],
|
|
1687
|
-
],
|
|
1688
|
-
"yellow-red": [
|
|
1689
|
-
[0.5, 0.5, 0, 1],
|
|
1690
|
-
[0.5, 0.5, 0, 0],
|
|
1691
|
-
[0.1, 0.5, 0, 0],
|
|
1692
|
-
[0, 0, 0, 0],
|
|
1693
|
-
],
|
|
1694
|
-
};
|
|
1695
|
-
const cosineColor = (spec, t) => transducers.transduce(transducers.map(([a, b, c, d]) => math.clamp01(a + b * Math.cos(math.TAU * (c * t + d)))), transducers.push(),
|
|
1696
|
-
transducers.zip(...spec));
|
|
1697
|
-
const cosineGradient = (n, spec, tx) => transducers.transduce(transducers.comp(transducers.map(compose.partial(cosineColor, spec)), tx ? transducers.map(tx) : transducers.noop()), transducers.push(), transducers.normRange(n - 1));
|
|
1698
|
-
const cosineGradientBuffer = (n, spec, buffer = [], offset = 0, cstride = 1, estride = 4) => {
|
|
1699
|
-
for (let t of transducers.normRange(n - 1)) {
|
|
1700
|
-
vectors.setS4(buffer, cosineColor(spec, t), offset, 0, cstride);
|
|
1701
|
-
offset += estride;
|
|
1702
|
-
}
|
|
1703
|
-
return buffer;
|
|
1704
|
-
};
|
|
1705
|
-
const cosineCoeffs = (from, to) => {
|
|
1706
|
-
from = clamp([], from);
|
|
1707
|
-
to = clamp([], to);
|
|
1708
|
-
const amp = [...transducers.map(([a, b]) => 0.5 * (a - b), transducers.zip(from, to))];
|
|
1709
|
-
return [
|
|
1710
|
-
[...transducers.map(([s, a]) => s - a, transducers.zip(from, amp))],
|
|
1711
|
-
amp,
|
|
1712
|
-
[-0.5, -0.5, -0.5, -0.5],
|
|
1713
|
-
[0, 0, 0, 0],
|
|
1714
|
-
];
|
|
1715
|
-
};
|
|
1716
|
-
const multiCosineGradient = (opts) => transducers.transduce(opts.tx ? transducers.map(opts.tx) : transducers.noop(), transducers.push(), transducers.tween({
|
|
1717
|
-
num: opts.num,
|
|
1718
|
-
stops: opts.stops,
|
|
1719
|
-
easing: opts.easing,
|
|
1720
|
-
min: 0,
|
|
1721
|
-
max: 1,
|
|
1722
|
-
init: cosineCoeffs,
|
|
1723
|
-
mix: cosineColor,
|
|
1724
|
-
}));
|
|
1725
|
-
|
|
1726
|
-
const { abs, cos, hypot, sin, sqrt } = Math;
|
|
1727
|
-
const distChannel = (id) => (a, b) => abs(a[id] - b[id]);
|
|
1728
|
-
const distHsv = (a, b) => {
|
|
1729
|
-
const aa = math.cossin(a[0] * math.TAU, a[1]);
|
|
1730
|
-
const bb = math.cossin(b[0] * math.TAU, b[1]);
|
|
1731
|
-
return hypot(aa[0] - bb[0], aa[1] - bb[1], a[2] - b[2]);
|
|
1732
|
-
};
|
|
1733
|
-
const distHsvSat = distChannel(1);
|
|
1734
|
-
const distHsvLuma = distChannel(2);
|
|
1735
|
-
const distEucledian3 = vectors.dist3;
|
|
1736
|
-
const distEucledian4 = vectors.dist4;
|
|
1737
|
-
const distRgbLuma = (a, b) => abs(luminanceRgb(a) - luminanceRgb(b));
|
|
1738
|
-
const distSrgbLuma = (a, b) => abs(luminanceSrgb(a) - luminanceSrgb(b));
|
|
1739
|
-
const distRgbRed = distChannel(0);
|
|
1740
|
-
const distRgbGreen = distChannel(1);
|
|
1741
|
-
const distRgbBlue = distChannel(1);
|
|
1742
|
-
const H6 = 6 * math.DEG2RAD;
|
|
1743
|
-
const H25 = 25 * math.DEG2RAD;
|
|
1744
|
-
const H63 = 63 * math.DEG2RAD;
|
|
1745
|
-
const H275 = 275 * math.DEG2RAD;
|
|
1746
|
-
const distCIEDE2000 = (weights = vectors.ONE3) => (a, b) => {
|
|
1747
|
-
let { 0: l1, 1: a1, 2: b1 } = labD50(a);
|
|
1748
|
-
let { 0: l2, 1: a2, 2: b2 } = labD50(b);
|
|
1749
|
-
l1 *= 100;
|
|
1750
|
-
a1 *= 100;
|
|
1751
|
-
b1 *= 100;
|
|
1752
|
-
l2 *= 100;
|
|
1753
|
-
a2 *= 100;
|
|
1754
|
-
b2 *= 100;
|
|
1755
|
-
const c1ab = hypot(a1, b1);
|
|
1756
|
-
const c2ab = hypot(a2, b2);
|
|
1757
|
-
const cab = (c1ab + c2ab) * 0.5;
|
|
1758
|
-
const g = 1 + 0.5 * (1 - c7Coeff(cab));
|
|
1759
|
-
a1 *= g;
|
|
1760
|
-
a2 *= g;
|
|
1761
|
-
const c1 = hypot(a1, b1);
|
|
1762
|
-
const c2 = hypot(a2, b2);
|
|
1763
|
-
const cmean = (c1 + c2) * 0.5;
|
|
1764
|
-
const { deltaH, H } = computeDeltaH(a1, b1, a2, b2, c1, c2);
|
|
1765
|
-
const T = 1 -
|
|
1766
|
-
0.17 * cos(H - math.SIXTH_PI) +
|
|
1767
|
-
0.24 * cos(2 * H) +
|
|
1768
|
-
0.32 * cos(3 * H + H6) -
|
|
1769
|
-
0.2 * cos(4 * H - H63);
|
|
1770
|
-
const Rt = -2 *
|
|
1771
|
-
c7Coeff(cmean) *
|
|
1772
|
-
sin(math.THIRD_PI * Math.exp(-(((H - H275) / H25) ** 2)));
|
|
1773
|
-
const L50 = ((l1 + l2) * 0.5 - 50) ** 2;
|
|
1774
|
-
const Sl = 1 + (0.015 * L50) / sqrt(20 + L50);
|
|
1775
|
-
const Sc = 1 + 0.045 * cmean;
|
|
1776
|
-
const Sh = 1 + 0.015 * cmean * T;
|
|
1777
|
-
const termL = (l2 - l1) / (weights[0] * Sl);
|
|
1778
|
-
const termC = (c2 - c1) / (weights[1] * Sc);
|
|
1779
|
-
const termH = deltaH / (weights[2] * Sh);
|
|
1780
|
-
return sqrt(termL ** 2 + termC ** 2 + termH ** 2 + Rt * termC * termH);
|
|
1781
|
-
};
|
|
1782
|
-
const c7Coeff = (c) => {
|
|
1783
|
-
c = c ** 7;
|
|
1784
|
-
return sqrt(c / (c + 25 ** 7));
|
|
1785
|
-
};
|
|
1786
|
-
const computeDeltaH = (a1, b1, a2, b2, c1, c2, eps = 1e-3) => {
|
|
1787
|
-
const h1 = math.atan2Abs(b1, a1);
|
|
1788
|
-
const h2 = math.atan2Abs(b2, a2);
|
|
1789
|
-
if (c1 <= eps || c2 <= eps)
|
|
1790
|
-
return { deltaH: 0, H: h1 + h2 };
|
|
1791
|
-
let dh = h2 - h1;
|
|
1792
|
-
const sumH = h1 + h2;
|
|
1793
|
-
const absH = abs(dh);
|
|
1794
|
-
dh = absH <= math.PI ? dh : h2 <= h1 ? dh + math.TAU : dh - math.TAU;
|
|
1795
|
-
const deltaH = 2 * sqrt(c1 * c2) * sin(dh / 2);
|
|
1796
|
-
const H = 0.5 * (absH <= math.PI ? sumH : sumH < math.TAU ? sumH + math.TAU : sumH - math.TAU);
|
|
1797
|
-
return { deltaH, H };
|
|
1798
|
-
};
|
|
1799
|
-
const H35 = 35 * math.DEG2RAD;
|
|
1800
|
-
const H164 = 164 * math.DEG2RAD;
|
|
1801
|
-
const H168 = 168 * math.DEG2RAD;
|
|
1802
|
-
const H345 = 345 * math.DEG2RAD;
|
|
1803
|
-
const distCMC = (kl = 1, kc = 1) => (a, b) => {
|
|
1804
|
-
let { 0: l1, 1: a1, 2: b1 } = labD65(a);
|
|
1805
|
-
let { 0: l2, 1: a2, 2: b2 } = labD65(b);
|
|
1806
|
-
l1 *= 100;
|
|
1807
|
-
a1 *= 100;
|
|
1808
|
-
b1 *= 100;
|
|
1809
|
-
l2 *= 100;
|
|
1810
|
-
a2 *= 100;
|
|
1811
|
-
b2 *= 100;
|
|
1812
|
-
const c1 = hypot(a1, b1);
|
|
1813
|
-
const c2 = hypot(a2, b2);
|
|
1814
|
-
const dC = c1 - c2;
|
|
1815
|
-
const dH = sqrt((a2 - a1) ** 2 + (b2 - b1) ** 2 - dC ** 2);
|
|
1816
|
-
const h1 = math.atan2Abs(b1, a1);
|
|
1817
|
-
const t = h1 >= H164 && h1 <= H345
|
|
1818
|
-
? 0.56 + abs(0.2 * cos(h1 + H168))
|
|
1819
|
-
: 0.36 + abs(0.4 * cos(h1 + H35));
|
|
1820
|
-
const c14 = c1 ** 4;
|
|
1821
|
-
const f = sqrt(c14 / (c14 + 1900));
|
|
1822
|
-
const Sl = l1 >= 16 ? (0.040975 * l1) / (1 + 0.01765 * l1) : 0.511;
|
|
1823
|
-
const Sc = (0.0638 * c1) / (1 + 0.0131 * c1) + 0.638;
|
|
1824
|
-
const Sh = Sc * (f * t + 1 - f);
|
|
1825
|
-
return hypot((l1 - l2) / (kl * Sl), dC / (kc * Sc), dH / Sh);
|
|
1826
|
-
};
|
|
1827
|
-
|
|
1828
|
-
const defMix = (x, y, z, alpha) => (out, a, b, t) => vectors.setC4(out || a, x(a[0], b[0], t), y(a[1], b[1], t), z(a[2], b[2], t), alpha(a[3], b[3], t));
|
|
1829
|
-
const mixH = (a, b, t) => {
|
|
1830
|
-
a = math.fract(a);
|
|
1831
|
-
b = math.fract(b);
|
|
1832
|
-
const delta = b - a;
|
|
1833
|
-
return math.fract(a +
|
|
1834
|
-
(Math.abs(delta) > 0.5
|
|
1835
|
-
? delta < 0
|
|
1836
|
-
? delta + 1
|
|
1837
|
-
: -(1 - delta)
|
|
1838
|
-
: delta) *
|
|
1839
|
-
t);
|
|
1840
|
-
};
|
|
1841
|
-
const mixN = math.mix;
|
|
1842
|
-
const mixHNNN = defMix(mixH, mixN, mixN, mixN);
|
|
1843
|
-
const mixNNHN = defMix(mixN, mixN, mixH, mixN);
|
|
1844
|
-
const mixNNNN = vectors.mixN4;
|
|
1845
|
-
const mix = defmulti.defmulti((_, a) => a.mode);
|
|
1846
|
-
mix.add(defmulti.DEFAULT, vectors.mixN4);
|
|
1847
|
-
mix.addAll({
|
|
1848
|
-
hcy: mixHNNN,
|
|
1849
|
-
hsi: mixHNNN,
|
|
1850
|
-
hsl: mixHNNN,
|
|
1851
|
-
hsv: mixHNNN,
|
|
1852
|
-
lch: mixNNHN,
|
|
1853
|
-
});
|
|
1854
|
-
|
|
1855
|
-
const multiColorGradient = (opts) => [...gradient(opts)];
|
|
1856
|
-
const multiColorGradientBuffer = (opts, buffer = [], offset = 0, cstride = 1, estride = 4) => {
|
|
1857
|
-
for (let col of gradient(opts)) {
|
|
1858
|
-
vectors.setS4(buffer, col, offset, 0, cstride);
|
|
1859
|
-
offset += estride;
|
|
1860
|
-
}
|
|
1861
|
-
return buffer;
|
|
1862
|
-
};
|
|
1863
|
-
const gradient = ({ num, stops, easing, mix: mix$1, }) => transducers.tween({
|
|
1864
|
-
num: num - 1,
|
|
1865
|
-
stops,
|
|
1866
|
-
easing,
|
|
1867
|
-
min: 0,
|
|
1868
|
-
max: 1,
|
|
1869
|
-
init: (a, b) => [a, b],
|
|
1870
|
-
mix: mix$1
|
|
1871
|
-
? ([a, b], t) => mix$1(a.empty(), a, b, t)
|
|
1872
|
-
: ([a, b], t) => mix(a.empty(), a, b, t),
|
|
1873
|
-
});
|
|
1874
|
-
|
|
1875
|
-
const invertRgb = (out, src) => ((out = clamp(out || src, src)), vectors.sub3(out, vectors.ONE3, out));
|
|
1876
|
-
const invertInt = (src) => src ^ 0xffffff;
|
|
1877
|
-
|
|
1878
|
-
const luminance = defmulti.defmulti((col) => col.mode);
|
|
1879
|
-
luminance.addAll({
|
|
1880
|
-
argb32: luminanceArgb32,
|
|
1881
|
-
abgr32: luminanceAbgr32,
|
|
1882
|
-
hcy: (x) => x[2],
|
|
1883
|
-
lab: (x) => x[0],
|
|
1884
|
-
rgb: luminanceRgb,
|
|
1885
|
-
srgb: luminanceSrgb,
|
|
1886
|
-
xyz: (x) => x[1],
|
|
1887
|
-
});
|
|
1888
|
-
luminance.isa("lch", "lab");
|
|
1889
|
-
luminance.isa("oklab", "lab");
|
|
1890
|
-
luminance.isa("ycc", "lab");
|
|
1891
|
-
luminance.isa("xyy", "hcy");
|
|
1892
|
-
luminance.add(defmulti.DEFAULT, (x) => luminanceRgb(rgb(x)));
|
|
1893
|
-
|
|
1894
|
-
const selectChannel = (id) => (col) => col[id];
|
|
1895
|
-
const proximity = (target, dist = distEucledian3) => (col) => dist(target, col);
|
|
1896
|
-
const sort = (colors, key, isReverse = false) => arrays.sortByCachedKey(colors, key, isReverse ? compare.compareNumDesc : compare.compareNumAsc);
|
|
1897
|
-
const sortMapped = (colors, key, isReverse = false) => {
|
|
1898
|
-
if (!colors.length)
|
|
1899
|
-
return colors;
|
|
1900
|
-
const keys = colors.map(key);
|
|
1901
|
-
const tmp = api.typedArray(api.typedArrayType(colors[0].buf), colors[0].length);
|
|
1902
|
-
arrays.quickSort(keys, isReverse ? compare.compareNumDesc : compare.compareNumAsc, (_, x, y) => {
|
|
1903
|
-
arrays.swap(keys, x, y);
|
|
1904
|
-
tmp.set(colors[x]);
|
|
1905
|
-
colors[x].set(colors[y]);
|
|
1906
|
-
colors[y].set(tmp);
|
|
1907
|
-
});
|
|
1908
|
-
return colors;
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
const swatches = (cols, shapeFn, attribs = {}) => ["g", attribs, ...cols.map(shapeFn)];
|
|
1912
|
-
const swatchesH = (cols, w = 5, h = 50, gap = 0, attribs) => swatches(cols, (fill, i) => ["rect", { fill }, [i * (w + gap), 0], w, h], attribs);
|
|
1913
|
-
const dotsH = (cols, r = 25, gap = 0, attribs) => swatches(cols, (fill, i) => ["circle", { fill }, [i * (r * 2 + gap), 0], r], attribs);
|
|
1914
|
-
const swatchesV = (cols, w = 50, h = 5, gap = 0, attribs = {}) => swatches(cols, (fill, i) => ["rect", { fill }, [0, i * (h + gap)], w, h], attribs);
|
|
1915
|
-
const dotsV = (cols, r = 25, gap = 0, attribs) => swatches(cols, (fill, i) => ["circle", { fill }, [0, i * (r * 2 + gap)], r], attribs);
|
|
1916
|
-
|
|
1917
|
-
const S0 = 0.072;
|
|
1918
|
-
const S1 = 0.213;
|
|
1919
|
-
const S2 = 0.285;
|
|
1920
|
-
const S3 = 0.715;
|
|
1921
|
-
const S4 = 0.787;
|
|
1922
|
-
const S5 = 0.928;
|
|
1923
|
-
const S6 = 0.14;
|
|
1924
|
-
const S7 = 0.143;
|
|
1925
|
-
const S8 = 0.283;
|
|
1926
|
-
const transform = mulV45;
|
|
1927
|
-
const concat = (mat, ...xs) => xs.reduce(mulM45, mat);
|
|
1928
|
-
const IDENTITY = [
|
|
1929
|
-
1, 0, 0, 0, 0,
|
|
1930
|
-
0, 1, 0, 0, 0,
|
|
1931
|
-
0, 0, 1, 0, 0,
|
|
1932
|
-
0, 0, 0, 1, 0
|
|
1933
|
-
];
|
|
1934
|
-
const subtract = (src = WHITE) => [
|
|
1935
|
-
-1, 0, 0, 0, src[0],
|
|
1936
|
-
0, -1, 0, 0, src[1],
|
|
1937
|
-
0, 0, -1, 0, src[2],
|
|
1938
|
-
0, 0, 0, 1, 0
|
|
1939
|
-
];
|
|
1940
|
-
const brightness = (x) => [
|
|
1941
|
-
1, 0, 0, 0, x,
|
|
1942
|
-
0, 1, 0, 0, x,
|
|
1943
|
-
0, 0, 1, 0, x,
|
|
1944
|
-
0, 0, 0, 1, 0
|
|
1945
|
-
];
|
|
1946
|
-
const contrast = (x, o = 0.5 * (1 - x)) => [
|
|
1947
|
-
x, 0, 0, 0, o,
|
|
1948
|
-
0, x, 0, 0, o,
|
|
1949
|
-
0, 0, x, 0, o,
|
|
1950
|
-
0, 0, 0, 1, 0
|
|
1951
|
-
];
|
|
1952
|
-
const exposure = (x) => [
|
|
1953
|
-
x, 0, 0, 0, 0,
|
|
1954
|
-
0, x, 0, 0, 0,
|
|
1955
|
-
0, 0, x, 0, 0,
|
|
1956
|
-
0, 0, 0, 1, 0
|
|
1957
|
-
];
|
|
1958
|
-
const saturation = (x) => [
|
|
1959
|
-
S1 + S4 * x, S3 - S3 * x, S0 - S0 * x, 0, 0,
|
|
1960
|
-
S1 - S1 * x, S3 + S2 * x, S0 - S0 * x, 0, 0,
|
|
1961
|
-
S1 - S1 * x, S3 - S3 * x, S0 + S5 * x, 0, 0,
|
|
1962
|
-
0, 0, 0, 1, 0
|
|
1963
|
-
];
|
|
1964
|
-
const hueRotate = (theta) => {
|
|
1965
|
-
const s = Math.sin(theta);
|
|
1966
|
-
const c = Math.cos(theta);
|
|
1967
|
-
return [
|
|
1968
|
-
S1 + c * S4 - s * S1, S3 - c * S3 - s * S3, S0 - c * S0 + s * S5, 0, 0,
|
|
1969
|
-
S1 - c * S1 + s * S7, S3 + c * S2 + s * S6, S0 - c * S0 - s * S8, 0, 0,
|
|
1970
|
-
S1 - c * S1 - s * S4, S3 - c * S3 + s * S3, S0 + c * S5 + s * S0, 0, 0,
|
|
1971
|
-
0, 0, 0, 1, 0
|
|
1972
|
-
];
|
|
1973
|
-
};
|
|
1974
|
-
const temperature = (x) => [
|
|
1975
|
-
1 + x, 0, 0, 0, 0,
|
|
1976
|
-
0, 1, 0, 0, 0,
|
|
1977
|
-
0, 0, 1 - x, 0, 0,
|
|
1978
|
-
0, 0, 0, 1, 0
|
|
1979
|
-
];
|
|
1980
|
-
const sepia = (x = 1) => [
|
|
1981
|
-
math.mix(1, 0.393, x), 0.769 * x, 0.189 * x, 0, 0,
|
|
1982
|
-
0.349 * x, math.mix(1, 0.686, x), 0.168 * x, 0, 0,
|
|
1983
|
-
0.272 * x, 0.534 * x, math.mix(1, 0.131, x), 0, 0,
|
|
1984
|
-
0, 0, 0, 1, 0
|
|
1985
|
-
];
|
|
1986
|
-
const tint = (x) => [
|
|
1987
|
-
1 + x, 0, 0, 0, 0,
|
|
1988
|
-
0, 1, 0, 0, 0,
|
|
1989
|
-
0, 0, 1 + x, 0, 0,
|
|
1990
|
-
0, 0, 0, 1, 0
|
|
1991
|
-
];
|
|
1992
|
-
const grayscale = ([r, g, b] = RGB_LUMINANCE_REC709, offset = 0) => [
|
|
1993
|
-
r, g, b, 0, offset,
|
|
1994
|
-
r, g, b, 0, offset,
|
|
1995
|
-
r, g, b, 0, offset,
|
|
1996
|
-
0, 0, 0, 1, 0
|
|
1997
|
-
];
|
|
1998
|
-
const luminanceAlpha = ([r, g, b] = RGB_LUMINANCE_REC709) => [
|
|
1999
|
-
0, 0, 0, 0, 0,
|
|
2000
|
-
0, 0, 0, 0, 0,
|
|
2001
|
-
0, 0, 0, 0, 0,
|
|
2002
|
-
r, g, b, 0, 0
|
|
2003
|
-
];
|
|
2004
|
-
|
|
2005
|
-
const G1 = -0.6088425710866344;
|
|
2006
|
-
const G2 = -0.001748900018414868;
|
|
2007
|
-
const G3 = 0.4097731842899564;
|
|
2008
|
-
const G4 = 1.2762722061615583;
|
|
2009
|
-
const G5 = 0.0003115080994769546;
|
|
2010
|
-
const G6 = 0.11013841706194392;
|
|
2011
|
-
const R1 = 1.3803015908551253;
|
|
2012
|
-
const R2 = 0.0004478684462124118;
|
|
2013
|
-
const R3 = -0.15785750232675008;
|
|
2014
|
-
const B1 = -0.9990954974165059;
|
|
2015
|
-
const B2 = 0.0032447435545127036;
|
|
2016
|
-
const B3 = 0.453646839257496;
|
|
2017
|
-
const kelvinRgb = (out, kelvin, alpha = 1) => {
|
|
2018
|
-
kelvin *= 0.01;
|
|
2019
|
-
let t;
|
|
2020
|
-
return kelvin < 66
|
|
2021
|
-
? (vectors.setC4(out || srgb(), 1, math.clamp01(G1 + G2 * (t = kelvin - 2) + G3 * Math.log(t)), kelvin < 20
|
|
2022
|
-
? 0
|
|
2023
|
-
: math.clamp01(B1 + B2 * (t = kelvin - 10) + B3 * Math.log(t)), alpha))
|
|
2024
|
-
: (vectors.setC4(out || srgb(), math.clamp01(R1 + R2 * (t = kelvin - 55) + R3 * Math.log(t)), math.clamp01(G4 + G5 * (t = kelvin - 50) - G6 * Math.log(t)), 1, alpha));
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
|
-
const wavelengthXyz = (out, lambda, alpha = 1) => {
|
|
2028
|
-
lambda *= 10;
|
|
2029
|
-
return (vectors.setC4(out || xyzD65(), gaussian(lambda, 1.056, 5998, 379, 310) +
|
|
2030
|
-
gaussian(lambda, 0.362, 4420, 160, 267) +
|
|
2031
|
-
gaussian(lambda, -0.065, 5011, 204, 262), gaussian(lambda, 0.821, 5688, 469, 405) +
|
|
2032
|
-
gaussian(lambda, 0.286, 5309, 163, 311), gaussian(lambda, 1.217, 4370, 118, 360) +
|
|
2033
|
-
gaussian(lambda, 0.681, 4590, 260, 138), alpha));
|
|
2034
|
-
};
|
|
2035
|
-
const gaussian = (x, alpha, m, s1, s2) => {
|
|
2036
|
-
const t = (x - m) / (x < m ? s1 : s2);
|
|
2037
|
-
return alpha * Math.exp(-(t * t) / 2);
|
|
2038
|
-
};
|
|
2039
|
-
|
|
2040
|
-
exports.ABGR = ABGR;
|
|
2041
|
-
exports.ARGB = ARGB;
|
|
2042
|
-
exports.BLACK = BLACK;
|
|
2043
|
-
exports.BLUE = BLUE;
|
|
2044
|
-
exports.BRADFORD_D50_D65 = BRADFORD_D50_D65;
|
|
2045
|
-
exports.BRADFORD_D65_D50 = BRADFORD_D65_D50;
|
|
2046
|
-
exports.COLOR_RANGES = COLOR_RANGES;
|
|
2047
|
-
exports.CONVERSIONS = CONVERSIONS;
|
|
2048
|
-
exports.COSINE_GRADIENTS = COSINE_GRADIENTS;
|
|
2049
|
-
exports.CSS_NAMES = CSS_NAMES;
|
|
2050
|
-
exports.CSS_SYSTEM_COLORS = CSS_SYSTEM_COLORS;
|
|
2051
|
-
exports.CYAN = CYAN;
|
|
2052
|
-
exports.D50 = D50;
|
|
2053
|
-
exports.D65 = D65;
|
|
2054
|
-
exports.EPS = EPS;
|
|
2055
|
-
exports.GREEN = GREEN;
|
|
2056
|
-
exports.IDENTITY = IDENTITY;
|
|
2057
|
-
exports.INV8BIT = INV8BIT;
|
|
2058
|
-
exports.Int32 = Int32;
|
|
2059
|
-
exports.MAGENTA = MAGENTA;
|
|
2060
|
-
exports.OKLAB_M1 = OKLAB_M1;
|
|
2061
|
-
exports.OKLAB_M2 = OKLAB_M2;
|
|
2062
|
-
exports.ParsedColor = ParsedColor;
|
|
2063
|
-
exports.RED = RED;
|
|
2064
|
-
exports.RGB_LUMINANCE_REC2020 = RGB_LUMINANCE_REC2020;
|
|
2065
|
-
exports.RGB_LUMINANCE_REC601 = RGB_LUMINANCE_REC601;
|
|
2066
|
-
exports.RGB_LUMINANCE_REC709 = RGB_LUMINANCE_REC709;
|
|
2067
|
-
exports.RGB_XYZ_D50 = RGB_XYZ_D50;
|
|
2068
|
-
exports.RGB_XYZ_D65 = RGB_XYZ_D65;
|
|
2069
|
-
exports.WHITE = WHITE;
|
|
2070
|
-
exports.XYZ_RGB_D50 = XYZ_RGB_D50;
|
|
2071
|
-
exports.XYZ_RGB_D65 = XYZ_RGB_D65;
|
|
2072
|
-
exports.YELLOW = YELLOW;
|
|
2073
|
-
exports.abgr32 = abgr32;
|
|
2074
|
-
exports.alpha = alpha;
|
|
2075
|
-
exports.analog = analog;
|
|
2076
|
-
exports.analogHsv = analogHsv;
|
|
2077
|
-
exports.analogRgb = analogRgb;
|
|
2078
|
-
exports.argb32 = argb32;
|
|
2079
|
-
exports.brightness = brightness;
|
|
2080
|
-
exports.clamp = clamp;
|
|
2081
|
-
exports.clampH = clampH;
|
|
2082
|
-
exports.closestHue = closestHue;
|
|
2083
|
-
exports.closestPrimaryHue = closestPrimaryHue;
|
|
2084
|
-
exports.color = color;
|
|
2085
|
-
exports.colorFromRange = colorFromRange;
|
|
2086
|
-
exports.colorsFromRange = colorsFromRange;
|
|
2087
|
-
exports.colorsFromTheme = colorsFromTheme;
|
|
2088
|
-
exports.concat = concat;
|
|
2089
|
-
exports.contrast = contrast;
|
|
2090
|
-
exports.convert = convert;
|
|
2091
|
-
exports.cosineCoeffs = cosineCoeffs;
|
|
2092
|
-
exports.cosineColor = cosineColor;
|
|
2093
|
-
exports.cosineGradient = cosineGradient;
|
|
2094
|
-
exports.cosineGradientBuffer = cosineGradientBuffer;
|
|
2095
|
-
exports.css = css;
|
|
2096
|
-
exports.defAnalog = defAnalog;
|
|
2097
|
-
exports.defColor = defColor;
|
|
2098
|
-
exports.defConversions = defConversions;
|
|
2099
|
-
exports.defMix = defMix;
|
|
2100
|
-
exports.distCIEDE2000 = distCIEDE2000;
|
|
2101
|
-
exports.distCMC = distCMC;
|
|
2102
|
-
exports.distChannel = distChannel;
|
|
2103
|
-
exports.distEucledian3 = distEucledian3;
|
|
2104
|
-
exports.distEucledian4 = distEucledian4;
|
|
2105
|
-
exports.distHsv = distHsv;
|
|
2106
|
-
exports.distHsvLuma = distHsvLuma;
|
|
2107
|
-
exports.distHsvSat = distHsvSat;
|
|
2108
|
-
exports.distRgbBlue = distRgbBlue;
|
|
2109
|
-
exports.distRgbGreen = distRgbGreen;
|
|
2110
|
-
exports.distRgbLuma = distRgbLuma;
|
|
2111
|
-
exports.distRgbRed = distRgbRed;
|
|
2112
|
-
exports.distSrgbLuma = distSrgbLuma;
|
|
2113
|
-
exports.dotsH = dotsH;
|
|
2114
|
-
exports.dotsV = dotsV;
|
|
2115
|
-
exports.exposure = exposure;
|
|
2116
|
-
exports.grayscale = grayscale;
|
|
2117
|
-
exports.hcy = hcy;
|
|
2118
|
-
exports.hcyRgb = hcyRgb;
|
|
2119
|
-
exports.hsi = hsi;
|
|
2120
|
-
exports.hsiRgb = hsiRgb;
|
|
2121
|
-
exports.hsl = hsl;
|
|
2122
|
-
exports.hslCss = hslCss;
|
|
2123
|
-
exports.hslHsv = hslHsv;
|
|
2124
|
-
exports.hslRgb = hslRgb;
|
|
2125
|
-
exports.hsv = hsv;
|
|
2126
|
-
exports.hsvCss = hsvCss;
|
|
2127
|
-
exports.hsvHsl = hsvHsl;
|
|
2128
|
-
exports.hsvRgb = hsvRgb;
|
|
2129
|
-
exports.hueRgb = hueRgb;
|
|
2130
|
-
exports.hueRotate = hueRotate;
|
|
2131
|
-
exports.intAbgr32Argb32 = intAbgr32Argb32;
|
|
2132
|
-
exports.intAbgr32Rgb = intAbgr32Rgb;
|
|
2133
|
-
exports.intAbgr32Srgb = intAbgr32Srgb;
|
|
2134
|
-
exports.intArgb32Abgr32 = intArgb32Abgr32;
|
|
2135
|
-
exports.intArgb32Css = intArgb32Css;
|
|
2136
|
-
exports.intArgb32Rgb = intArgb32Rgb;
|
|
2137
|
-
exports.intArgb32Srgb = intArgb32Srgb;
|
|
2138
|
-
exports.intBgr24Rgb = intBgr24Rgb;
|
|
2139
|
-
exports.intBgr24Srgb = intBgr24Srgb;
|
|
2140
|
-
exports.intRgb24Css = intRgb24Css;
|
|
2141
|
-
exports.intRgb24Rgb = intRgb24Rgb;
|
|
2142
|
-
exports.intRgb24Srgb = intRgb24Srgb;
|
|
2143
|
-
exports.invertInt = invertInt;
|
|
2144
|
-
exports.invertRgb = invertRgb;
|
|
2145
|
-
exports.isGray = isGray;
|
|
2146
|
-
exports.kelvinRgb = kelvinRgb;
|
|
2147
|
-
exports.labCss = labCss;
|
|
2148
|
-
exports.labD50 = labD50;
|
|
2149
|
-
exports.labD65 = labD65;
|
|
2150
|
-
exports.labLabD50_65 = labLabD50_65;
|
|
2151
|
-
exports.labLabD65_50 = labLabD65_50;
|
|
2152
|
-
exports.labLch = labLch;
|
|
2153
|
-
exports.labRgb = labRgb;
|
|
2154
|
-
exports.labRgbD65 = labRgbD65;
|
|
2155
|
-
exports.labXyz = labXyz;
|
|
2156
|
-
exports.labXyzD65 = labXyzD65;
|
|
2157
|
-
exports.lch = lch;
|
|
2158
|
-
exports.lchCss = lchCss;
|
|
2159
|
-
exports.lchLab = lchLab;
|
|
2160
|
-
exports.linearSrgb = linearSrgb;
|
|
2161
|
-
exports.luminance = luminance;
|
|
2162
|
-
exports.luminanceAbgr32 = luminanceAbgr32;
|
|
2163
|
-
exports.luminanceAlpha = luminanceAlpha;
|
|
2164
|
-
exports.luminanceArgb32 = luminanceArgb32;
|
|
2165
|
-
exports.luminanceIntAbgr32 = luminanceIntAbgr32;
|
|
2166
|
-
exports.luminanceIntArgb32 = luminanceIntArgb32;
|
|
2167
|
-
exports.luminanceRgb = luminanceRgb;
|
|
2168
|
-
exports.luminanceSrgb = luminanceSrgb;
|
|
2169
|
-
exports.mix = mix;
|
|
2170
|
-
exports.mixH = mixH;
|
|
2171
|
-
exports.mixHNNN = mixHNNN;
|
|
2172
|
-
exports.mixN = mixN;
|
|
2173
|
-
exports.mixNNHN = mixNNHN;
|
|
2174
|
-
exports.mixNNNN = mixNNNN;
|
|
2175
|
-
exports.multiColorGradient = multiColorGradient;
|
|
2176
|
-
exports.multiColorGradientBuffer = multiColorGradientBuffer;
|
|
2177
|
-
exports.multiCosineGradient = multiCosineGradient;
|
|
2178
|
-
exports.namedHueRgb = namedHueRgb;
|
|
2179
|
-
exports.oklab = oklab;
|
|
2180
|
-
exports.oklabRgb = oklabRgb;
|
|
2181
|
-
exports.oklabXyzD65 = oklabXyzD65;
|
|
2182
|
-
exports.parseCss = parseCss;
|
|
2183
|
-
exports.parseHex = parseHex;
|
|
2184
|
-
exports.proximity = proximity;
|
|
2185
|
-
exports.rgb = rgb;
|
|
2186
|
-
exports.rgbCss = rgbCss;
|
|
2187
|
-
exports.rgbHcv = rgbHcv;
|
|
2188
|
-
exports.rgbHcy = rgbHcy;
|
|
2189
|
-
exports.rgbHsi = rgbHsi;
|
|
2190
|
-
exports.rgbHsl = rgbHsl;
|
|
2191
|
-
exports.rgbHsv = rgbHsv;
|
|
2192
|
-
exports.rgbLab = rgbLab;
|
|
2193
|
-
exports.rgbLabD65 = rgbLabD65;
|
|
2194
|
-
exports.rgbOklab = rgbOklab;
|
|
2195
|
-
exports.rgbSrgb = rgbSrgb;
|
|
2196
|
-
exports.rgbSrgbApprox = rgbSrgbApprox;
|
|
2197
|
-
exports.rgbXyz = rgbXyz;
|
|
2198
|
-
exports.rgbXyzD65 = rgbXyzD65;
|
|
2199
|
-
exports.rgbYcc = rgbYcc;
|
|
2200
|
-
exports.saturation = saturation;
|
|
2201
|
-
exports.selectChannel = selectChannel;
|
|
2202
|
-
exports.sepia = sepia;
|
|
2203
|
-
exports.setAlpha = setAlpha;
|
|
2204
|
-
exports.setPrecision = setPrecision;
|
|
2205
|
-
exports.setSystemColors = setSystemColors;
|
|
2206
|
-
exports.sort = sort;
|
|
2207
|
-
exports.sortMapped = sortMapped;
|
|
2208
|
-
exports.srgb = srgb;
|
|
2209
|
-
exports.srgbCss = srgbCss;
|
|
2210
|
-
exports.srgbIntAbgr32 = srgbIntAbgr32;
|
|
2211
|
-
exports.srgbIntArgb32 = srgbIntArgb32;
|
|
2212
|
-
exports.srgbLinear = srgbLinear;
|
|
2213
|
-
exports.srgbRgb = srgbRgb;
|
|
2214
|
-
exports.srgbRgbApprox = srgbRgbApprox;
|
|
2215
|
-
exports.subtract = subtract;
|
|
2216
|
-
exports.swatches = swatches;
|
|
2217
|
-
exports.swatchesH = swatchesH;
|
|
2218
|
-
exports.swatchesV = swatchesV;
|
|
2219
|
-
exports.temperature = temperature;
|
|
2220
|
-
exports.tint = tint;
|
|
2221
|
-
exports.transform = transform;
|
|
2222
|
-
exports.wavelengthXyz = wavelengthXyz;
|
|
2223
|
-
exports.xyy = xyy;
|
|
2224
|
-
exports.xyyXyz = xyyXyz;
|
|
2225
|
-
exports.xyzD50 = xyzD50;
|
|
2226
|
-
exports.xyzD65 = xyzD65;
|
|
2227
|
-
exports.xyzLab = xyzLab;
|
|
2228
|
-
exports.xyzLabD65 = xyzLabD65;
|
|
2229
|
-
exports.xyzOklab = xyzOklab;
|
|
2230
|
-
exports.xyzRgb = xyzRgb;
|
|
2231
|
-
exports.xyzRgbD65 = xyzRgbD65;
|
|
2232
|
-
exports.xyzXyy = xyzXyy;
|
|
2233
|
-
exports.xyzXyzD50_65 = xyzXyzD50_65;
|
|
2234
|
-
exports.xyzXyzD65_50 = xyzXyzD65_50;
|
|
2235
|
-
exports.ycc = ycc;
|
|
2236
|
-
exports.yccRgb = yccRgb;
|