imagescript 1.2.15 → 1.2.17

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.
Files changed (53) hide show
  1. package/ImageScript.d.ts +233 -223
  2. package/ImageScript.js +1658 -1646
  3. package/LICENSE +12 -619
  4. package/LICENSE.AGPL-3.0 +619 -0
  5. package/LICENSE.MIT +19 -0
  6. package/README.md +51 -46
  7. package/bench/_.mjs +165 -165
  8. package/bench/all.mjs +3 -3
  9. package/bench/blur.mjs +58 -58
  10. package/bench/flip.mjs +62 -62
  11. package/bench/overlay.mjs +34 -34
  12. package/bench/package.json +6 -6
  13. package/bench/readme.md +63 -63
  14. package/bench/resize.mjs +51 -51
  15. package/codecs/LICENSE +20 -20
  16. package/codecs/lib.d.ts +49 -49
  17. package/codecs/lib.js +5 -5
  18. package/codecs/node/index.js +2 -2
  19. package/codecs/node/index.mjs +5 -5
  20. package/codecs/package.json +13 -13
  21. package/codecs/readme.md +37 -37
  22. package/package.json +41 -41
  23. package/png/node.js +1137 -1137
  24. package/png/src/crc.mjs +48 -48
  25. package/png/src/mem.mjs +23 -23
  26. package/png/src/png.mjs +254 -254
  27. package/png/src/zlib.mjs +617 -617
  28. package/tsconfig.json +21 -21
  29. package/utils/mem.js +25 -25
  30. package/v2/codecs/magic.js +24 -24
  31. package/v2/framebuffer.d.ts +66 -66
  32. package/v2/framebuffer.js +2352 -2352
  33. package/v2/framebuffer.mjs +125 -125
  34. package/v2/framebuffer.rs +1263 -1263
  35. package/v2/index.d.ts +83 -83
  36. package/v2/index.js +260 -260
  37. package/v2/ops/blur.mjs +302 -302
  38. package/v2/ops/color.mjs +276 -276
  39. package/v2/ops/crop.mjs +63 -63
  40. package/v2/ops/fill.mjs +32 -32
  41. package/v2/ops/flip.mjs +32 -32
  42. package/v2/ops/index.mjs +8 -8
  43. package/v2/ops/iterator.mjs +33 -33
  44. package/v2/ops/overlay.mjs +62 -62
  45. package/v2/ops/resize.mjs +165 -165
  46. package/v2/ops/rotate.mjs +116 -116
  47. package/v2/util/mem.mjs +23 -23
  48. package/wasm/node/font.js +141 -141
  49. package/wasm/node/gif.js +76 -76
  50. package/wasm/node/jpeg.js +91 -91
  51. package/wasm/node/png.js +49 -49
  52. package/wasm/node/svg.js +55 -55
  53. package/wasm/node/tiff.js +46 -46
package/v2/ops/color.mjs CHANGED
@@ -1,277 +1,277 @@
1
- const short_hex_regex = /^#?([\da-f]{3,4})$/;
2
- const long_hex_regex = /^#?((?:[\da-f]{2}){3,4})$/;
3
- const rgb_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)(?: +| *, *)(?<g>(?:\d*\.)?\d+)(?: +| *, *)(?<b>(?:\d*\.)?\d+)(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
4
- const rgb_percentage_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)%(?: +| *, *)(?<g>(?:\d*\.)?\d+)%(?: +| *, *)(?<b>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
5
- const hsl_regex = /^hsla?\((?<h>(?:\d*\.)?\d+)(?<t>|deg|rad|grad|turn)(?: +| *, *)(?<s>(?:\d*\.)?\d+)%(?: +| *, *)(?<l>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
6
-
7
- function clamp(min, max, int) {
8
- return Math.min(Math.max(Math.round(int), min), max);
9
- }
10
-
11
- export function to_rgba(int) {
12
- return [(int >> 24) & 0xff, (int >> 16) & 0xff, (int >> 8) & 0xff, int & 0xff];
13
- }
14
-
15
- export function from_rgba(r, g, b, a) {
16
- return ((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff);
17
- }
18
-
19
- function parse_alpha(a) {
20
- return clamp(0, 255, ('%' === a[a.length - 1]) ? ((255 / 100) * parseFloat(a)) : (+a * 255));
21
- }
22
-
23
- function hue_from_type(h, t) {
24
- if (t === 'turn') return h / 1;
25
- if (t === 'grad') return h / 400;
26
- if (!t || t === 'deg') return h / 360;
27
- if (t === 'rad') return h / (2 * Math.PI);
28
- }
29
-
30
- function hue2rgb(p, q, t) {
31
- if (t < 0) t += 1;
32
- else if (t > 1) t -= 1;
33
- if (t < 1 / 2) return q;
34
- if (t < 1 / 6) return p + 6 * t * (q - p);
35
- if (t < 2 / 3) return p + 6 * (q - p) * (2 / 3 - t);
36
-
37
- return p;
38
- };
39
-
40
- export function blend(fg, bg) {
41
- const fa = fg & 0xff;
42
- const alpha = fa + 1 | 0;
43
- const inv_alpha = 256 - fa | 0;
44
- const r = (alpha * (fg >>> 24) + inv_alpha * (bg >>> 24)) >> 8;
45
- const b = (alpha * (fg >> 8 & 0xff) + inv_alpha * (bg >> 8 & 0xff)) >> 8;
46
- const g = (alpha * (fg >> 16 & 0xff) + inv_alpha * (bg >> 16 & 0xff)) >> 8;
47
- return (((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (Math.max(fa, bg & 0xff) & 0xff));
48
- }
49
-
50
- export function parse(any) {
51
- let x = null;
52
- if (undefined !== (x = colors.get(any))) return x;
53
- if (x = long_hex_regex.exec(any)) return parseInt(`${x[1]}${8 === x[1].length ? '' : 'ff'}`, 16);
54
- if (x = hsl_regex.exec(any)) return color.hsla(hue_from_type(x[1], x[2]), x[3] / 100, x[4] / 100, x[5] ? ((1 / 255) * parse_alpha(x[5])) : 1);
55
- if (x = rgb_regex.exec(any)) return color.rgba(clamp(0, 255, +x[1]), clamp(0, 255, +x[2]), clamp(0, 255, +x[3]), x[4] ? parse_alpha(x[4]) : 255);
56
- if (x = short_hex_regex.exec(any)) return parseInt(`${x[1][0]}${x[1][0]}${x[1][1]}${x[1][1]}${x[1][2]}${x[1][2]}${3 === x[1].length ? 'ff' : `${x[1][3]}${x[1][3]}`}`, 16);
57
- if (x = rgb_percentage_regex.exec(any)) return color.rgba(clamp(0, 255, +x[1] * (255 / 100)), clamp(0, 255, +x[2] * (255 / 100)), clamp(0, 255, +x[3] * (255 / 100)), x[4] ? parse_alpha(x[4]) : 255);
58
-
59
- return null;
60
- }
61
-
62
- export default class color {
63
- constructor(any) {
64
- this.value = parse(String(any).toLowerCase());
65
- if (null === this.value) throw new Error(`invalid css color (${any})`);
66
- }
67
-
68
- static rgb(r, g, b) {
69
- return this.rgba(r, g, b, 255);
70
- }
71
-
72
- static rgba(r, g, b, a) {
73
- return (((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
74
- }
75
-
76
- static hsla(h, s, l, a) {
77
- s = Math.min(1, Math.max(0, s));
78
- a = Math.min(1, Math.max(0, a));
79
- if (s === 0) return this.rgba(255, 255, 255, a * 255);
80
-
81
- h %= 1;
82
- l = Math.min(1, Math.max(0, l));
83
- const q = l < .5 ? l + s * l : l + s - l * s;
84
-
85
- const p = 2 * l - q;
86
- const g = hue2rgb(p, q, h);
87
- const r = hue2rgb(p, q, h + 1 / 3);
88
- const b = hue2rgb(p, q, h - 1 / 3);
89
- return this.rgba(r * 255, g * 355, b * 255, a * 255);
90
- }
91
-
92
- valueOf() {
93
- return this.value;
94
- }
95
-
96
- toJSON() {
97
- return this.value >>> 0;
98
- }
99
-
100
- get rgb() {
101
- return [this.value >>> 24, this.value >> 16 & 0xff, this.value >> 8 & 0xff];
102
- }
103
-
104
- get rgba() {
105
- return [this.value >>> 24, this.value >> 16 & 0xff, this.value >> 8 & 0xff, this.value & 0xff];
106
- }
107
-
108
- get name() {
109
- for (const color of colors.keys()) {
110
- if (this.value === colors.get(color)) return color;
111
- }
112
-
113
- return null;
114
- }
115
-
116
- toString(radix) {
117
- const type = String(radix).toLowerCase();
118
-
119
- const rgba = this.rgba;
120
- if (type === 'rgb' || type === 'rgba') return `rgb${type[3] ? 'a' : ''}(${rgba[0]}, ${rgba[1]}, ${rgba[2]}${type[3] ? `, ${clamp(0, 100, 100 / 255 * rgba[3])}%` : ''})`;
121
- if (type === '16' || type === 'hex') return `#${rgba[0].toString(16).padStart(2, '0')}${rgba[1].toString(16).padStart(2, '0')}${rgba[2].toString(16).padStart(2, '0')}${rgba[3] === 255 ? '' : rgba[3].toString(16).padStart(2, '0')}`;
122
-
123
- return this.value.toString();
124
- }
125
- }
126
-
127
- const colors = new Map([
128
- ['aliceblue', 0xf0f8ffff],
129
- ['antiquewhite', 0xfaebd7ff],
130
- ['aqua', 0x00ffffff],
131
- ['aquamarine', 0x7fffd4ff],
132
- ['azure', 0xf0ffffff],
133
- ['beige', 0xf5f5dcff],
134
- ['bisque', 0xffe4c4ff],
135
- ['black', 0x000000ff],
136
- ['blanchedalmond', 0xffebcdff],
137
- ['blue', 0x0000ffff],
138
- ['blueviolet', 0x8a2be2ff],
139
- ['brown', 0xa52a2aff],
140
- ['burlywood', 0xdeb887ff],
141
- ['cadetblue', 0x5f9ea0ff],
142
- ['chartreuse', 0x7fff00ff],
143
- ['chocolate', 0xd2691eff],
144
- ['coral', 0xff7f50ff],
145
- ['cornflowerblue', 0x6495edff],
146
- ['cornsilk', 0xfff8dcff],
147
- ['crimson', 0xdc143cff],
148
- ['cyan', 0x00ffffff],
149
- ['darkblue', 0x00008bff],
150
- ['darkcyan', 0x008b8bff],
151
- ['darkgoldenrod', 0xb8860bff],
152
- ['darkgray', 0xa9a9a9ff],
153
- ['darkgreen', 0x006400ff],
154
- ['darkgrey', 0xa9a9a9ff],
155
- ['darkkhaki', 0xbdb76bff],
156
- ['darkmagenta', 0x8b008bff],
157
- ['darkolivegreen', 0x556b2fff],
158
- ['darkorange', 0xff8c00ff],
159
- ['darkorchid', 0x9932ccff],
160
- ['darkred', 0x8b0000ff],
161
- ['darksalmon', 0xe9967aff],
162
- ['darkseagreen', 0x8fbc8fff],
163
- ['darkslateblue', 0x483d8bff],
164
- ['darkslategray', 0x2f4f4fff],
165
- ['darkslategrey', 0x2f4f4fff],
166
- ['darkturquoise', 0x00ced1ff],
167
- ['darkviolet', 0x9400d3ff],
168
- ['deeppink', 0xff1493ff],
169
- ['deepskyblue', 0x00bfffff],
170
- ['dimgray', 0x696969ff],
171
- ['dimgrey', 0x696969ff],
172
- ['dodgerblue', 0x1e90ffff],
173
- ['firebrick', 0xb22222ff],
174
- ['floralwhite', 0xfffaf0ff],
175
- ['forestgreen', 0x228b22ff],
176
- ['fuchsia', 0xff00ffff],
177
- ['gainsboro', 0xdcdcdcff],
178
- ['ghostwhite', 0xf8f8ffff],
179
- ['gold', 0xffd700ff],
180
- ['goldenrod', 0xdaa520ff],
181
- ['gray', 0x808080ff],
182
- ['green', 0x008000ff],
183
- ['greenyellow', 0xadff2fff],
184
- ['grey', 0x808080ff],
185
- ['honeydew', 0xf0fff0ff],
186
- ['hotpink', 0xff69b4ff],
187
- ['indianred', 0xcd5c5cff],
188
- ['indigo', 0x4b0082ff],
189
- ['ivory', 0xfffff0ff],
190
- ['khaki', 0xf0e68cff],
191
- ['lavender', 0xe6e6faff],
192
- ['lavenderblush', 0xfff0f5ff],
193
- ['lawngreen', 0x7cfc00ff],
194
- ['lemonchiffon', 0xfffacdff],
195
- ['lightblue', 0xadd8e6ff],
196
- ['lightcoral', 0xf08080ff],
197
- ['lightcyan', 0xe0ffffff],
198
- ['lightgoldenrodyellow', 0xfafad2ff],
199
- ['lightgray', 0xd3d3d3ff],
200
- ['lightgreen', 0x90ee90ff],
201
- ['lightgrey', 0xd3d3d3ff],
202
- ['lightpink', 0xffb6c1ff],
203
- ['lightsalmon', 0xffa07aff],
204
- ['lightseagreen', 0x20b2aaff],
205
- ['lightskyblue', 0x87cefaff],
206
- ['lightslategray', 0x778899ff],
207
- ['lightslategrey', 0x778899ff],
208
- ['lightsteelblue', 0xb0c4deff],
209
- ['lightyellow', 0xffffe0ff],
210
- ['lime', 0x00ff00ff],
211
- ['limegreen', 0x32cd32ff],
212
- ['linen', 0xfaf0e6ff],
213
- ['magenta', 0xff00ffff],
214
- ['maroon', 0x800000ff],
215
- ['mediumaquamarine', 0x66cdaaff],
216
- ['mediumblue', 0x0000cdff],
217
- ['mediumorchid', 0xba55d3ff],
218
- ['mediumpurple', 0x9370dbff],
219
- ['mediumseagreen', 0x3cb371ff],
220
- ['mediumslateblue', 0x7b68eeff],
221
- ['mediumspringgreen', 0x00fa9aff],
222
- ['mediumturquoise', 0x48d1ccff],
223
- ['mediumvioletred', 0xc71585ff],
224
- ['midnightblue', 0x191970ff],
225
- ['mintcream', 0xf5fffaff],
226
- ['mistyrose', 0xffe4e1ff],
227
- ['moccasin', 0xffe4b5ff],
228
- ['navajowhite', 0xffdeadff],
229
- ['navy', 0x000080ff],
230
- ['oldlace', 0xfdf5e6ff],
231
- ['olive', 0x808000ff],
232
- ['olivedrab', 0x6b8e23ff],
233
- ['orange', 0xffa500ff],
234
- ['orangered', 0xff4500ff],
235
- ['orchid', 0xda70d6ff],
236
- ['palegoldenrod', 0xeee8aaff],
237
- ['palegreen', 0x98fb98ff],
238
- ['paleturquoise', 0xafeeeeff],
239
- ['palevioletred', 0xdb7093ff],
240
- ['papayawhip', 0xffefd5ff],
241
- ['peachpuff', 0xffdab9ff],
242
- ['peru', 0xcd853fff],
243
- ['pink', 0xffc0cbff],
244
- ['plum', 0xdda0ddff],
245
- ['powderblue', 0xb0e0e6ff],
246
- ['purple', 0x800080ff],
247
- ['rebeccapurple', 0x663399ff],
248
- ['red', 0xff0000ff],
249
- ['rosybrown', 0xbc8f8fff],
250
- ['royalblue', 0x4169e1ff],
251
- ['saddlebrown', 0x8b4513ff],
252
- ['salmon', 0xfa8072ff],
253
- ['sandybrown', 0xf4a460ff],
254
- ['seagreen', 0x2e8b57ff],
255
- ['seashell', 0xfff5eeff],
256
- ['sienna', 0xa0522dff],
257
- ['silver', 0xc0c0c0ff],
258
- ['skyblue', 0x87ceebff],
259
- ['slateblue', 0x6a5acdff],
260
- ['slategray', 0x708090ff],
261
- ['slategrey', 0x708090ff],
262
- ['snow', 0xfffafaff],
263
- ['springgreen', 0x00ff7fff],
264
- ['steelblue', 0x4682b4ff],
265
- ['tan', 0xd2b48cff],
266
- ['teal', 0x008080ff],
267
- ['thistle', 0xd8bfd8ff],
268
- ['tomato', 0xff6347ff],
269
- ['transparent', 0x00000000],
270
- ['turquoise', 0x40e0d0ff],
271
- ['violet', 0xee82eeff],
272
- ['wheat', 0xf5deb3ff],
273
- ['white', 0xffffffff],
274
- ['whitesmoke', 0xf5f5f5ff],
275
- ['yellow', 0xffff00ff],
276
- ['yellowgreen', 0x9acd32ff],
1
+ const short_hex_regex = /^#?([\da-f]{3,4})$/;
2
+ const long_hex_regex = /^#?((?:[\da-f]{2}){3,4})$/;
3
+ const rgb_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)(?: +| *, *)(?<g>(?:\d*\.)?\d+)(?: +| *, *)(?<b>(?:\d*\.)?\d+)(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
4
+ const rgb_percentage_regex = /^rgba?\((?<r>(?:\d*\.)?\d+)%(?: +| *, *)(?<g>(?:\d*\.)?\d+)%(?: +| *, *)(?<b>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
5
+ const hsl_regex = /^hsla?\((?<h>(?:\d*\.)?\d+)(?<t>|deg|rad|grad|turn)(?: +| *, *)(?<s>(?:\d*\.)?\d+)%(?: +| *, *)(?<l>(?:\d*\.)?\d+)%(?:(?: +| *, *)(?<a>\d+|\d*\.\d+|\d+(?:\.\d+)?%))?\)$/;
6
+
7
+ function clamp(min, max, int) {
8
+ return Math.min(Math.max(Math.round(int), min), max);
9
+ }
10
+
11
+ export function to_rgba(int) {
12
+ return [(int >> 24) & 0xff, (int >> 16) & 0xff, (int >> 8) & 0xff, int & 0xff];
13
+ }
14
+
15
+ export function from_rgba(r, g, b, a) {
16
+ return ((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff);
17
+ }
18
+
19
+ function parse_alpha(a) {
20
+ return clamp(0, 255, ('%' === a[a.length - 1]) ? ((255 / 100) * parseFloat(a)) : (+a * 255));
21
+ }
22
+
23
+ function hue_from_type(h, t) {
24
+ if (t === 'turn') return h / 1;
25
+ if (t === 'grad') return h / 400;
26
+ if (!t || t === 'deg') return h / 360;
27
+ if (t === 'rad') return h / (2 * Math.PI);
28
+ }
29
+
30
+ function hue2rgb(p, q, t) {
31
+ if (t < 0) t += 1;
32
+ else if (t > 1) t -= 1;
33
+ if (t < 1 / 2) return q;
34
+ if (t < 1 / 6) return p + 6 * t * (q - p);
35
+ if (t < 2 / 3) return p + 6 * (q - p) * (2 / 3 - t);
36
+
37
+ return p;
38
+ };
39
+
40
+ export function blend(fg, bg) {
41
+ const fa = fg & 0xff;
42
+ const alpha = fa + 1 | 0;
43
+ const inv_alpha = 256 - fa | 0;
44
+ const r = (alpha * (fg >>> 24) + inv_alpha * (bg >>> 24)) >> 8;
45
+ const b = (alpha * (fg >> 8 & 0xff) + inv_alpha * (bg >> 8 & 0xff)) >> 8;
46
+ const g = (alpha * (fg >> 16 & 0xff) + inv_alpha * (bg >> 16 & 0xff)) >> 8;
47
+ return (((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (Math.max(fa, bg & 0xff) & 0xff));
48
+ }
49
+
50
+ export function parse(any) {
51
+ let x = null;
52
+ if (undefined !== (x = colors.get(any))) return x;
53
+ if (x = long_hex_regex.exec(any)) return parseInt(`${x[1]}${8 === x[1].length ? '' : 'ff'}`, 16);
54
+ if (x = hsl_regex.exec(any)) return color.hsla(hue_from_type(x[1], x[2]), x[3] / 100, x[4] / 100, x[5] ? ((1 / 255) * parse_alpha(x[5])) : 1);
55
+ if (x = rgb_regex.exec(any)) return color.rgba(clamp(0, 255, +x[1]), clamp(0, 255, +x[2]), clamp(0, 255, +x[3]), x[4] ? parse_alpha(x[4]) : 255);
56
+ if (x = short_hex_regex.exec(any)) return parseInt(`${x[1][0]}${x[1][0]}${x[1][1]}${x[1][1]}${x[1][2]}${x[1][2]}${3 === x[1].length ? 'ff' : `${x[1][3]}${x[1][3]}`}`, 16);
57
+ if (x = rgb_percentage_regex.exec(any)) return color.rgba(clamp(0, 255, +x[1] * (255 / 100)), clamp(0, 255, +x[2] * (255 / 100)), clamp(0, 255, +x[3] * (255 / 100)), x[4] ? parse_alpha(x[4]) : 255);
58
+
59
+ return null;
60
+ }
61
+
62
+ export default class color {
63
+ constructor(any) {
64
+ this.value = parse(String(any).toLowerCase());
65
+ if (null === this.value) throw new Error(`invalid css color (${any})`);
66
+ }
67
+
68
+ static rgb(r, g, b) {
69
+ return this.rgba(r, g, b, 255);
70
+ }
71
+
72
+ static rgba(r, g, b, a) {
73
+ return (((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8) | (a & 0xff));
74
+ }
75
+
76
+ static hsla(h, s, l, a) {
77
+ s = Math.min(1, Math.max(0, s));
78
+ a = Math.min(1, Math.max(0, a));
79
+ if (s === 0) return this.rgba(255, 255, 255, a * 255);
80
+
81
+ h %= 1;
82
+ l = Math.min(1, Math.max(0, l));
83
+ const q = l < .5 ? l + s * l : l + s - l * s;
84
+
85
+ const p = 2 * l - q;
86
+ const g = hue2rgb(p, q, h);
87
+ const r = hue2rgb(p, q, h + 1 / 3);
88
+ const b = hue2rgb(p, q, h - 1 / 3);
89
+ return this.rgba(r * 255, g * 355, b * 255, a * 255);
90
+ }
91
+
92
+ valueOf() {
93
+ return this.value;
94
+ }
95
+
96
+ toJSON() {
97
+ return this.value >>> 0;
98
+ }
99
+
100
+ get rgb() {
101
+ return [this.value >>> 24, this.value >> 16 & 0xff, this.value >> 8 & 0xff];
102
+ }
103
+
104
+ get rgba() {
105
+ return [this.value >>> 24, this.value >> 16 & 0xff, this.value >> 8 & 0xff, this.value & 0xff];
106
+ }
107
+
108
+ get name() {
109
+ for (const color of colors.keys()) {
110
+ if (this.value === colors.get(color)) return color;
111
+ }
112
+
113
+ return null;
114
+ }
115
+
116
+ toString(radix) {
117
+ const type = String(radix).toLowerCase();
118
+
119
+ const rgba = this.rgba;
120
+ if (type === 'rgb' || type === 'rgba') return `rgb${type[3] ? 'a' : ''}(${rgba[0]}, ${rgba[1]}, ${rgba[2]}${type[3] ? `, ${clamp(0, 100, 100 / 255 * rgba[3])}%` : ''})`;
121
+ if (type === '16' || type === 'hex') return `#${rgba[0].toString(16).padStart(2, '0')}${rgba[1].toString(16).padStart(2, '0')}${rgba[2].toString(16).padStart(2, '0')}${rgba[3] === 255 ? '' : rgba[3].toString(16).padStart(2, '0')}`;
122
+
123
+ return this.value.toString();
124
+ }
125
+ }
126
+
127
+ const colors = new Map([
128
+ ['aliceblue', 0xf0f8ffff],
129
+ ['antiquewhite', 0xfaebd7ff],
130
+ ['aqua', 0x00ffffff],
131
+ ['aquamarine', 0x7fffd4ff],
132
+ ['azure', 0xf0ffffff],
133
+ ['beige', 0xf5f5dcff],
134
+ ['bisque', 0xffe4c4ff],
135
+ ['black', 0x000000ff],
136
+ ['blanchedalmond', 0xffebcdff],
137
+ ['blue', 0x0000ffff],
138
+ ['blueviolet', 0x8a2be2ff],
139
+ ['brown', 0xa52a2aff],
140
+ ['burlywood', 0xdeb887ff],
141
+ ['cadetblue', 0x5f9ea0ff],
142
+ ['chartreuse', 0x7fff00ff],
143
+ ['chocolate', 0xd2691eff],
144
+ ['coral', 0xff7f50ff],
145
+ ['cornflowerblue', 0x6495edff],
146
+ ['cornsilk', 0xfff8dcff],
147
+ ['crimson', 0xdc143cff],
148
+ ['cyan', 0x00ffffff],
149
+ ['darkblue', 0x00008bff],
150
+ ['darkcyan', 0x008b8bff],
151
+ ['darkgoldenrod', 0xb8860bff],
152
+ ['darkgray', 0xa9a9a9ff],
153
+ ['darkgreen', 0x006400ff],
154
+ ['darkgrey', 0xa9a9a9ff],
155
+ ['darkkhaki', 0xbdb76bff],
156
+ ['darkmagenta', 0x8b008bff],
157
+ ['darkolivegreen', 0x556b2fff],
158
+ ['darkorange', 0xff8c00ff],
159
+ ['darkorchid', 0x9932ccff],
160
+ ['darkred', 0x8b0000ff],
161
+ ['darksalmon', 0xe9967aff],
162
+ ['darkseagreen', 0x8fbc8fff],
163
+ ['darkslateblue', 0x483d8bff],
164
+ ['darkslategray', 0x2f4f4fff],
165
+ ['darkslategrey', 0x2f4f4fff],
166
+ ['darkturquoise', 0x00ced1ff],
167
+ ['darkviolet', 0x9400d3ff],
168
+ ['deeppink', 0xff1493ff],
169
+ ['deepskyblue', 0x00bfffff],
170
+ ['dimgray', 0x696969ff],
171
+ ['dimgrey', 0x696969ff],
172
+ ['dodgerblue', 0x1e90ffff],
173
+ ['firebrick', 0xb22222ff],
174
+ ['floralwhite', 0xfffaf0ff],
175
+ ['forestgreen', 0x228b22ff],
176
+ ['fuchsia', 0xff00ffff],
177
+ ['gainsboro', 0xdcdcdcff],
178
+ ['ghostwhite', 0xf8f8ffff],
179
+ ['gold', 0xffd700ff],
180
+ ['goldenrod', 0xdaa520ff],
181
+ ['gray', 0x808080ff],
182
+ ['green', 0x008000ff],
183
+ ['greenyellow', 0xadff2fff],
184
+ ['grey', 0x808080ff],
185
+ ['honeydew', 0xf0fff0ff],
186
+ ['hotpink', 0xff69b4ff],
187
+ ['indianred', 0xcd5c5cff],
188
+ ['indigo', 0x4b0082ff],
189
+ ['ivory', 0xfffff0ff],
190
+ ['khaki', 0xf0e68cff],
191
+ ['lavender', 0xe6e6faff],
192
+ ['lavenderblush', 0xfff0f5ff],
193
+ ['lawngreen', 0x7cfc00ff],
194
+ ['lemonchiffon', 0xfffacdff],
195
+ ['lightblue', 0xadd8e6ff],
196
+ ['lightcoral', 0xf08080ff],
197
+ ['lightcyan', 0xe0ffffff],
198
+ ['lightgoldenrodyellow', 0xfafad2ff],
199
+ ['lightgray', 0xd3d3d3ff],
200
+ ['lightgreen', 0x90ee90ff],
201
+ ['lightgrey', 0xd3d3d3ff],
202
+ ['lightpink', 0xffb6c1ff],
203
+ ['lightsalmon', 0xffa07aff],
204
+ ['lightseagreen', 0x20b2aaff],
205
+ ['lightskyblue', 0x87cefaff],
206
+ ['lightslategray', 0x778899ff],
207
+ ['lightslategrey', 0x778899ff],
208
+ ['lightsteelblue', 0xb0c4deff],
209
+ ['lightyellow', 0xffffe0ff],
210
+ ['lime', 0x00ff00ff],
211
+ ['limegreen', 0x32cd32ff],
212
+ ['linen', 0xfaf0e6ff],
213
+ ['magenta', 0xff00ffff],
214
+ ['maroon', 0x800000ff],
215
+ ['mediumaquamarine', 0x66cdaaff],
216
+ ['mediumblue', 0x0000cdff],
217
+ ['mediumorchid', 0xba55d3ff],
218
+ ['mediumpurple', 0x9370dbff],
219
+ ['mediumseagreen', 0x3cb371ff],
220
+ ['mediumslateblue', 0x7b68eeff],
221
+ ['mediumspringgreen', 0x00fa9aff],
222
+ ['mediumturquoise', 0x48d1ccff],
223
+ ['mediumvioletred', 0xc71585ff],
224
+ ['midnightblue', 0x191970ff],
225
+ ['mintcream', 0xf5fffaff],
226
+ ['mistyrose', 0xffe4e1ff],
227
+ ['moccasin', 0xffe4b5ff],
228
+ ['navajowhite', 0xffdeadff],
229
+ ['navy', 0x000080ff],
230
+ ['oldlace', 0xfdf5e6ff],
231
+ ['olive', 0x808000ff],
232
+ ['olivedrab', 0x6b8e23ff],
233
+ ['orange', 0xffa500ff],
234
+ ['orangered', 0xff4500ff],
235
+ ['orchid', 0xda70d6ff],
236
+ ['palegoldenrod', 0xeee8aaff],
237
+ ['palegreen', 0x98fb98ff],
238
+ ['paleturquoise', 0xafeeeeff],
239
+ ['palevioletred', 0xdb7093ff],
240
+ ['papayawhip', 0xffefd5ff],
241
+ ['peachpuff', 0xffdab9ff],
242
+ ['peru', 0xcd853fff],
243
+ ['pink', 0xffc0cbff],
244
+ ['plum', 0xdda0ddff],
245
+ ['powderblue', 0xb0e0e6ff],
246
+ ['purple', 0x800080ff],
247
+ ['rebeccapurple', 0x663399ff],
248
+ ['red', 0xff0000ff],
249
+ ['rosybrown', 0xbc8f8fff],
250
+ ['royalblue', 0x4169e1ff],
251
+ ['saddlebrown', 0x8b4513ff],
252
+ ['salmon', 0xfa8072ff],
253
+ ['sandybrown', 0xf4a460ff],
254
+ ['seagreen', 0x2e8b57ff],
255
+ ['seashell', 0xfff5eeff],
256
+ ['sienna', 0xa0522dff],
257
+ ['silver', 0xc0c0c0ff],
258
+ ['skyblue', 0x87ceebff],
259
+ ['slateblue', 0x6a5acdff],
260
+ ['slategray', 0x708090ff],
261
+ ['slategrey', 0x708090ff],
262
+ ['snow', 0xfffafaff],
263
+ ['springgreen', 0x00ff7fff],
264
+ ['steelblue', 0x4682b4ff],
265
+ ['tan', 0xd2b48cff],
266
+ ['teal', 0x008080ff],
267
+ ['thistle', 0xd8bfd8ff],
268
+ ['tomato', 0xff6347ff],
269
+ ['transparent', 0x00000000],
270
+ ['turquoise', 0x40e0d0ff],
271
+ ['violet', 0xee82eeff],
272
+ ['wheat', 0xf5deb3ff],
273
+ ['white', 0xffffffff],
274
+ ['whitesmoke', 0xf5f5f5ff],
275
+ ['yellow', 0xffff00ff],
276
+ ['yellowgreen', 0x9acd32ff],
277
277
  ]);