@eggjs/mock 6.1.0-beta.10 → 6.1.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh_CN.md +1 -1
- package/dist/_virtual/rolldown_runtime.js +1 -24
- package/dist/inject_mocha.d.ts +1 -1
- package/dist/inject_mocha.js +2 -3
- package/dist/lib/context.js +1 -3
- package/package.json +6 -8
- package/dist/node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js +0 -142
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js +0 -157
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js +0 -97
- package/dist/node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js +0 -40
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js +0 -814
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js +0 -50
- package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js +0 -68
- package/dist/node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js +0 -752
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/browser.js +0 -203
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/common.js +0 -209
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/index.js +0 -18
- package/dist/node_modules/.pnpm/debug@4.4.3_supports-color@8.1.1/node_modules/debug/src/node.js +0 -215
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/dmp.js +0 -24
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/convert/xml.js +0 -33
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/array.js +0 -29
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/base.js +0 -185
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/character.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/css.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/json.js +0 -83
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/line.js +0 -51
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/sentence.js +0 -26
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/diff/word.js +0 -151
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.js +0 -178
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/apply.js +0 -168
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/create.js +0 -301
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/line-endings.js +0 -137
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/merge.js +0 -367
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/parse.js +0 -91
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/patch/reverse.js +0 -99
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/array.js +0 -23
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/distance-iterator.js +0 -30
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/params.js +0 -22
- package/dist/node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/util/string.js +0 -97
- package/dist/node_modules/.pnpm/escape-string-regexp@4.0.0/node_modules/escape-string-regexp/index.js +0 -14
- package/dist/node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js +0 -16
- package/dist/node_modules/.pnpm/he@1.2.0/node_modules/he/he.js +0 -4093
- package/dist/node_modules/.pnpm/is-unicode-supported@0.1.0/node_modules/is-unicode-supported/index.js +0 -14
- package/dist/node_modules/.pnpm/log-symbols@4.1.0/node_modules/log-symbols/index.js +0 -27
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/index.js +0 -12
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/context.js +0 -83
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/error-constants.js +0 -35
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/errors.js +0 -392
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/hook.js +0 -86
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/bdd.js +0 -104
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/common.js +0 -99
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/exports.js +0 -65
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/index.js +0 -18
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/qunit.js +0 -95
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/interfaces/tdd.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocha.js +0 -1037
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/mocharc.js +0 -24
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +0 -152
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/esm-utils.js +0 -74
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/file-unloader.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/parallel-buffered-runner.js +0 -329
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/nodejs/serializer.js +0 -314
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/pending.js +0 -22
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/base.js +0 -417
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/doc.js +0 -79
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/dot.js +0 -75
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/html.js +0 -283
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/index.js +0 -40
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json-stream.js +0 -90
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/json.js +0 -145
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/landing.js +0 -107
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/list.js +0 -77
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/markdown.js +0 -106
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/min.js +0 -57
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/nyan.js +0 -233
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/progress.js +0 -92
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/spec.js +0 -91
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/tap.js +0 -261
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/reporters/xunit.js +0 -166
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runnable.js +0 -346
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/runner.js +0 -922
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/stats-collector.js +0 -72
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/suite.js +0 -517
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/test.js +0 -105
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/lib/utils.js +0 -505
- package/dist/node_modules/.pnpm/mocha@11.7.2/node_modules/mocha/package.js +0 -225
- package/dist/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +0 -124
- package/dist/node_modules/.pnpm/randombytes@2.1.0/node_modules/randombytes/index.js +0 -11
- package/dist/node_modules/.pnpm/serialize-javascript@6.0.2/node_modules/serialize-javascript/index.js +0 -114
- package/dist/node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js +0 -76
- package/dist/node_modules/.pnpm/supports-color@8.1.1/node_modules/supports-color/index.js +0 -89
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Pool.js +0 -366
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/Promise.js +0 -248
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/WorkerHandler.js +0 -419
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/debug-port-allocator.js +0 -27
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/environment.js +0 -18
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/generated/embeddedWorker.js +0 -16
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/index.js +0 -63
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/transfer.js +0 -21
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/validateOptions.js +0 -9
- package/dist/node_modules/.pnpm/workerpool@9.3.4/node_modules/workerpool/src/worker.js +0 -277
package/dist/node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js
DELETED
|
@@ -1,814 +0,0 @@
|
|
|
1
|
-
import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { require_color_name } from "../../../color-name@1.1.4/node_modules/color-name/index.js";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js
|
|
5
|
-
var require_conversions = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js": ((exports, module) => {
|
|
6
|
-
const cssKeywords = require_color_name();
|
|
7
|
-
const reverseKeywords = {};
|
|
8
|
-
for (const key of Object.keys(cssKeywords)) reverseKeywords[cssKeywords[key]] = key;
|
|
9
|
-
const convert = {
|
|
10
|
-
rgb: {
|
|
11
|
-
channels: 3,
|
|
12
|
-
labels: "rgb"
|
|
13
|
-
},
|
|
14
|
-
hsl: {
|
|
15
|
-
channels: 3,
|
|
16
|
-
labels: "hsl"
|
|
17
|
-
},
|
|
18
|
-
hsv: {
|
|
19
|
-
channels: 3,
|
|
20
|
-
labels: "hsv"
|
|
21
|
-
},
|
|
22
|
-
hwb: {
|
|
23
|
-
channels: 3,
|
|
24
|
-
labels: "hwb"
|
|
25
|
-
},
|
|
26
|
-
cmyk: {
|
|
27
|
-
channels: 4,
|
|
28
|
-
labels: "cmyk"
|
|
29
|
-
},
|
|
30
|
-
xyz: {
|
|
31
|
-
channels: 3,
|
|
32
|
-
labels: "xyz"
|
|
33
|
-
},
|
|
34
|
-
lab: {
|
|
35
|
-
channels: 3,
|
|
36
|
-
labels: "lab"
|
|
37
|
-
},
|
|
38
|
-
lch: {
|
|
39
|
-
channels: 3,
|
|
40
|
-
labels: "lch"
|
|
41
|
-
},
|
|
42
|
-
hex: {
|
|
43
|
-
channels: 1,
|
|
44
|
-
labels: ["hex"]
|
|
45
|
-
},
|
|
46
|
-
keyword: {
|
|
47
|
-
channels: 1,
|
|
48
|
-
labels: ["keyword"]
|
|
49
|
-
},
|
|
50
|
-
ansi16: {
|
|
51
|
-
channels: 1,
|
|
52
|
-
labels: ["ansi16"]
|
|
53
|
-
},
|
|
54
|
-
ansi256: {
|
|
55
|
-
channels: 1,
|
|
56
|
-
labels: ["ansi256"]
|
|
57
|
-
},
|
|
58
|
-
hcg: {
|
|
59
|
-
channels: 3,
|
|
60
|
-
labels: [
|
|
61
|
-
"h",
|
|
62
|
-
"c",
|
|
63
|
-
"g"
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
apple: {
|
|
67
|
-
channels: 3,
|
|
68
|
-
labels: [
|
|
69
|
-
"r16",
|
|
70
|
-
"g16",
|
|
71
|
-
"b16"
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
gray: {
|
|
75
|
-
channels: 1,
|
|
76
|
-
labels: ["gray"]
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
module.exports = convert;
|
|
80
|
-
for (const model of Object.keys(convert)) {
|
|
81
|
-
if (!("channels" in convert[model])) throw new Error("missing channels property: " + model);
|
|
82
|
-
if (!("labels" in convert[model])) throw new Error("missing channel labels property: " + model);
|
|
83
|
-
if (convert[model].labels.length !== convert[model].channels) throw new Error("channel and label counts mismatch: " + model);
|
|
84
|
-
const { channels, labels } = convert[model];
|
|
85
|
-
delete convert[model].channels;
|
|
86
|
-
delete convert[model].labels;
|
|
87
|
-
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
88
|
-
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
89
|
-
}
|
|
90
|
-
convert.rgb.hsl = function(rgb) {
|
|
91
|
-
const r = rgb[0] / 255;
|
|
92
|
-
const g = rgb[1] / 255;
|
|
93
|
-
const b = rgb[2] / 255;
|
|
94
|
-
const min = Math.min(r, g, b);
|
|
95
|
-
const max = Math.max(r, g, b);
|
|
96
|
-
const delta = max - min;
|
|
97
|
-
let h;
|
|
98
|
-
let s;
|
|
99
|
-
if (max === min) h = 0;
|
|
100
|
-
else if (r === max) h = (g - b) / delta;
|
|
101
|
-
else if (g === max) h = 2 + (b - r) / delta;
|
|
102
|
-
else if (b === max) h = 4 + (r - g) / delta;
|
|
103
|
-
h = Math.min(h * 60, 360);
|
|
104
|
-
if (h < 0) h += 360;
|
|
105
|
-
const l = (min + max) / 2;
|
|
106
|
-
if (max === min) s = 0;
|
|
107
|
-
else if (l <= .5) s = delta / (max + min);
|
|
108
|
-
else s = delta / (2 - max - min);
|
|
109
|
-
return [
|
|
110
|
-
h,
|
|
111
|
-
s * 100,
|
|
112
|
-
l * 100
|
|
113
|
-
];
|
|
114
|
-
};
|
|
115
|
-
convert.rgb.hsv = function(rgb) {
|
|
116
|
-
let rdif;
|
|
117
|
-
let gdif;
|
|
118
|
-
let bdif;
|
|
119
|
-
let h;
|
|
120
|
-
let s;
|
|
121
|
-
const r = rgb[0] / 255;
|
|
122
|
-
const g = rgb[1] / 255;
|
|
123
|
-
const b = rgb[2] / 255;
|
|
124
|
-
const v = Math.max(r, g, b);
|
|
125
|
-
const diff = v - Math.min(r, g, b);
|
|
126
|
-
const diffc = function(c) {
|
|
127
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
128
|
-
};
|
|
129
|
-
if (diff === 0) {
|
|
130
|
-
h = 0;
|
|
131
|
-
s = 0;
|
|
132
|
-
} else {
|
|
133
|
-
s = diff / v;
|
|
134
|
-
rdif = diffc(r);
|
|
135
|
-
gdif = diffc(g);
|
|
136
|
-
bdif = diffc(b);
|
|
137
|
-
if (r === v) h = bdif - gdif;
|
|
138
|
-
else if (g === v) h = 1 / 3 + rdif - bdif;
|
|
139
|
-
else if (b === v) h = 2 / 3 + gdif - rdif;
|
|
140
|
-
if (h < 0) h += 1;
|
|
141
|
-
else if (h > 1) h -= 1;
|
|
142
|
-
}
|
|
143
|
-
return [
|
|
144
|
-
h * 360,
|
|
145
|
-
s * 100,
|
|
146
|
-
v * 100
|
|
147
|
-
];
|
|
148
|
-
};
|
|
149
|
-
convert.rgb.hwb = function(rgb) {
|
|
150
|
-
const r = rgb[0];
|
|
151
|
-
const g = rgb[1];
|
|
152
|
-
let b = rgb[2];
|
|
153
|
-
const h = convert.rgb.hsl(rgb)[0];
|
|
154
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
155
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
156
|
-
return [
|
|
157
|
-
h,
|
|
158
|
-
w * 100,
|
|
159
|
-
b * 100
|
|
160
|
-
];
|
|
161
|
-
};
|
|
162
|
-
convert.rgb.cmyk = function(rgb) {
|
|
163
|
-
const r = rgb[0] / 255;
|
|
164
|
-
const g = rgb[1] / 255;
|
|
165
|
-
const b = rgb[2] / 255;
|
|
166
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
167
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
168
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
169
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
170
|
-
return [
|
|
171
|
-
c * 100,
|
|
172
|
-
m * 100,
|
|
173
|
-
y * 100,
|
|
174
|
-
k * 100
|
|
175
|
-
];
|
|
176
|
-
};
|
|
177
|
-
function comparativeDistance(x, y) {
|
|
178
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
179
|
-
}
|
|
180
|
-
convert.rgb.keyword = function(rgb) {
|
|
181
|
-
const reversed = reverseKeywords[rgb];
|
|
182
|
-
if (reversed) return reversed;
|
|
183
|
-
let currentClosestDistance = Infinity;
|
|
184
|
-
let currentClosestKeyword;
|
|
185
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
186
|
-
const value = cssKeywords[keyword];
|
|
187
|
-
const distance = comparativeDistance(rgb, value);
|
|
188
|
-
if (distance < currentClosestDistance) {
|
|
189
|
-
currentClosestDistance = distance;
|
|
190
|
-
currentClosestKeyword = keyword;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return currentClosestKeyword;
|
|
194
|
-
};
|
|
195
|
-
convert.keyword.rgb = function(keyword) {
|
|
196
|
-
return cssKeywords[keyword];
|
|
197
|
-
};
|
|
198
|
-
convert.rgb.xyz = function(rgb) {
|
|
199
|
-
let r = rgb[0] / 255;
|
|
200
|
-
let g = rgb[1] / 255;
|
|
201
|
-
let b = rgb[2] / 255;
|
|
202
|
-
r = r > .04045 ? ((r + .055) / 1.055) ** 2.4 : r / 12.92;
|
|
203
|
-
g = g > .04045 ? ((g + .055) / 1.055) ** 2.4 : g / 12.92;
|
|
204
|
-
b = b > .04045 ? ((b + .055) / 1.055) ** 2.4 : b / 12.92;
|
|
205
|
-
const x = r * .4124 + g * .3576 + b * .1805;
|
|
206
|
-
const y = r * .2126 + g * .7152 + b * .0722;
|
|
207
|
-
const z = r * .0193 + g * .1192 + b * .9505;
|
|
208
|
-
return [
|
|
209
|
-
x * 100,
|
|
210
|
-
y * 100,
|
|
211
|
-
z * 100
|
|
212
|
-
];
|
|
213
|
-
};
|
|
214
|
-
convert.rgb.lab = function(rgb) {
|
|
215
|
-
const xyz = convert.rgb.xyz(rgb);
|
|
216
|
-
let x = xyz[0];
|
|
217
|
-
let y = xyz[1];
|
|
218
|
-
let z = xyz[2];
|
|
219
|
-
x /= 95.047;
|
|
220
|
-
y /= 100;
|
|
221
|
-
z /= 108.883;
|
|
222
|
-
x = x > .008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
223
|
-
y = y > .008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
224
|
-
z = z > .008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
225
|
-
const l = 116 * y - 16;
|
|
226
|
-
const a = 500 * (x - y);
|
|
227
|
-
const b = 200 * (y - z);
|
|
228
|
-
return [
|
|
229
|
-
l,
|
|
230
|
-
a,
|
|
231
|
-
b
|
|
232
|
-
];
|
|
233
|
-
};
|
|
234
|
-
convert.hsl.rgb = function(hsl) {
|
|
235
|
-
const h = hsl[0] / 360;
|
|
236
|
-
const s = hsl[1] / 100;
|
|
237
|
-
const l = hsl[2] / 100;
|
|
238
|
-
let t2;
|
|
239
|
-
let t3;
|
|
240
|
-
let val;
|
|
241
|
-
if (s === 0) {
|
|
242
|
-
val = l * 255;
|
|
243
|
-
return [
|
|
244
|
-
val,
|
|
245
|
-
val,
|
|
246
|
-
val
|
|
247
|
-
];
|
|
248
|
-
}
|
|
249
|
-
if (l < .5) t2 = l * (1 + s);
|
|
250
|
-
else t2 = l + s - l * s;
|
|
251
|
-
const t1 = 2 * l - t2;
|
|
252
|
-
const rgb = [
|
|
253
|
-
0,
|
|
254
|
-
0,
|
|
255
|
-
0
|
|
256
|
-
];
|
|
257
|
-
for (let i = 0; i < 3; i++) {
|
|
258
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
259
|
-
if (t3 < 0) t3++;
|
|
260
|
-
if (t3 > 1) t3--;
|
|
261
|
-
if (6 * t3 < 1) val = t1 + (t2 - t1) * 6 * t3;
|
|
262
|
-
else if (2 * t3 < 1) val = t2;
|
|
263
|
-
else if (3 * t3 < 2) val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
264
|
-
else val = t1;
|
|
265
|
-
rgb[i] = val * 255;
|
|
266
|
-
}
|
|
267
|
-
return rgb;
|
|
268
|
-
};
|
|
269
|
-
convert.hsl.hsv = function(hsl) {
|
|
270
|
-
const h = hsl[0];
|
|
271
|
-
let s = hsl[1] / 100;
|
|
272
|
-
let l = hsl[2] / 100;
|
|
273
|
-
let smin = s;
|
|
274
|
-
const lmin = Math.max(l, .01);
|
|
275
|
-
l *= 2;
|
|
276
|
-
s *= l <= 1 ? l : 2 - l;
|
|
277
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
278
|
-
const v = (l + s) / 2;
|
|
279
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
280
|
-
return [
|
|
281
|
-
h,
|
|
282
|
-
sv * 100,
|
|
283
|
-
v * 100
|
|
284
|
-
];
|
|
285
|
-
};
|
|
286
|
-
convert.hsv.rgb = function(hsv) {
|
|
287
|
-
const h = hsv[0] / 60;
|
|
288
|
-
const s = hsv[1] / 100;
|
|
289
|
-
let v = hsv[2] / 100;
|
|
290
|
-
const hi = Math.floor(h) % 6;
|
|
291
|
-
const f = h - Math.floor(h);
|
|
292
|
-
const p = 255 * v * (1 - s);
|
|
293
|
-
const q = 255 * v * (1 - s * f);
|
|
294
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
295
|
-
v *= 255;
|
|
296
|
-
switch (hi) {
|
|
297
|
-
case 0: return [
|
|
298
|
-
v,
|
|
299
|
-
t,
|
|
300
|
-
p
|
|
301
|
-
];
|
|
302
|
-
case 1: return [
|
|
303
|
-
q,
|
|
304
|
-
v,
|
|
305
|
-
p
|
|
306
|
-
];
|
|
307
|
-
case 2: return [
|
|
308
|
-
p,
|
|
309
|
-
v,
|
|
310
|
-
t
|
|
311
|
-
];
|
|
312
|
-
case 3: return [
|
|
313
|
-
p,
|
|
314
|
-
q,
|
|
315
|
-
v
|
|
316
|
-
];
|
|
317
|
-
case 4: return [
|
|
318
|
-
t,
|
|
319
|
-
p,
|
|
320
|
-
v
|
|
321
|
-
];
|
|
322
|
-
case 5: return [
|
|
323
|
-
v,
|
|
324
|
-
p,
|
|
325
|
-
q
|
|
326
|
-
];
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
convert.hsv.hsl = function(hsv) {
|
|
330
|
-
const h = hsv[0];
|
|
331
|
-
const s = hsv[1] / 100;
|
|
332
|
-
const v = hsv[2] / 100;
|
|
333
|
-
const vmin = Math.max(v, .01);
|
|
334
|
-
let sl;
|
|
335
|
-
let l;
|
|
336
|
-
l = (2 - s) * v;
|
|
337
|
-
const lmin = (2 - s) * vmin;
|
|
338
|
-
sl = s * vmin;
|
|
339
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
340
|
-
sl = sl || 0;
|
|
341
|
-
l /= 2;
|
|
342
|
-
return [
|
|
343
|
-
h,
|
|
344
|
-
sl * 100,
|
|
345
|
-
l * 100
|
|
346
|
-
];
|
|
347
|
-
};
|
|
348
|
-
convert.hwb.rgb = function(hwb) {
|
|
349
|
-
const h = hwb[0] / 360;
|
|
350
|
-
let wh = hwb[1] / 100;
|
|
351
|
-
let bl = hwb[2] / 100;
|
|
352
|
-
const ratio = wh + bl;
|
|
353
|
-
let f;
|
|
354
|
-
if (ratio > 1) {
|
|
355
|
-
wh /= ratio;
|
|
356
|
-
bl /= ratio;
|
|
357
|
-
}
|
|
358
|
-
const i = Math.floor(6 * h);
|
|
359
|
-
const v = 1 - bl;
|
|
360
|
-
f = 6 * h - i;
|
|
361
|
-
if ((i & 1) !== 0) f = 1 - f;
|
|
362
|
-
const n = wh + f * (v - wh);
|
|
363
|
-
let r;
|
|
364
|
-
let g;
|
|
365
|
-
let b;
|
|
366
|
-
switch (i) {
|
|
367
|
-
default:
|
|
368
|
-
case 6:
|
|
369
|
-
case 0:
|
|
370
|
-
r = v;
|
|
371
|
-
g = n;
|
|
372
|
-
b = wh;
|
|
373
|
-
break;
|
|
374
|
-
case 1:
|
|
375
|
-
r = n;
|
|
376
|
-
g = v;
|
|
377
|
-
b = wh;
|
|
378
|
-
break;
|
|
379
|
-
case 2:
|
|
380
|
-
r = wh;
|
|
381
|
-
g = v;
|
|
382
|
-
b = n;
|
|
383
|
-
break;
|
|
384
|
-
case 3:
|
|
385
|
-
r = wh;
|
|
386
|
-
g = n;
|
|
387
|
-
b = v;
|
|
388
|
-
break;
|
|
389
|
-
case 4:
|
|
390
|
-
r = n;
|
|
391
|
-
g = wh;
|
|
392
|
-
b = v;
|
|
393
|
-
break;
|
|
394
|
-
case 5:
|
|
395
|
-
r = v;
|
|
396
|
-
g = wh;
|
|
397
|
-
b = n;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
return [
|
|
401
|
-
r * 255,
|
|
402
|
-
g * 255,
|
|
403
|
-
b * 255
|
|
404
|
-
];
|
|
405
|
-
};
|
|
406
|
-
convert.cmyk.rgb = function(cmyk) {
|
|
407
|
-
const c = cmyk[0] / 100;
|
|
408
|
-
const m = cmyk[1] / 100;
|
|
409
|
-
const y = cmyk[2] / 100;
|
|
410
|
-
const k = cmyk[3] / 100;
|
|
411
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
412
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
413
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
414
|
-
return [
|
|
415
|
-
r * 255,
|
|
416
|
-
g * 255,
|
|
417
|
-
b * 255
|
|
418
|
-
];
|
|
419
|
-
};
|
|
420
|
-
convert.xyz.rgb = function(xyz) {
|
|
421
|
-
const x = xyz[0] / 100;
|
|
422
|
-
const y = xyz[1] / 100;
|
|
423
|
-
const z = xyz[2] / 100;
|
|
424
|
-
let r;
|
|
425
|
-
let g;
|
|
426
|
-
let b;
|
|
427
|
-
r = x * 3.2406 + y * -1.5372 + z * -.4986;
|
|
428
|
-
g = x * -.9689 + y * 1.8758 + z * .0415;
|
|
429
|
-
b = x * .0557 + y * -.204 + z * 1.057;
|
|
430
|
-
r = r > .0031308 ? 1.055 * r ** (1 / 2.4) - .055 : r * 12.92;
|
|
431
|
-
g = g > .0031308 ? 1.055 * g ** (1 / 2.4) - .055 : g * 12.92;
|
|
432
|
-
b = b > .0031308 ? 1.055 * b ** (1 / 2.4) - .055 : b * 12.92;
|
|
433
|
-
r = Math.min(Math.max(0, r), 1);
|
|
434
|
-
g = Math.min(Math.max(0, g), 1);
|
|
435
|
-
b = Math.min(Math.max(0, b), 1);
|
|
436
|
-
return [
|
|
437
|
-
r * 255,
|
|
438
|
-
g * 255,
|
|
439
|
-
b * 255
|
|
440
|
-
];
|
|
441
|
-
};
|
|
442
|
-
convert.xyz.lab = function(xyz) {
|
|
443
|
-
let x = xyz[0];
|
|
444
|
-
let y = xyz[1];
|
|
445
|
-
let z = xyz[2];
|
|
446
|
-
x /= 95.047;
|
|
447
|
-
y /= 100;
|
|
448
|
-
z /= 108.883;
|
|
449
|
-
x = x > .008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
450
|
-
y = y > .008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
451
|
-
z = z > .008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
452
|
-
const l = 116 * y - 16;
|
|
453
|
-
const a = 500 * (x - y);
|
|
454
|
-
const b = 200 * (y - z);
|
|
455
|
-
return [
|
|
456
|
-
l,
|
|
457
|
-
a,
|
|
458
|
-
b
|
|
459
|
-
];
|
|
460
|
-
};
|
|
461
|
-
convert.lab.xyz = function(lab) {
|
|
462
|
-
const l = lab[0];
|
|
463
|
-
const a = lab[1];
|
|
464
|
-
const b = lab[2];
|
|
465
|
-
let x;
|
|
466
|
-
let y;
|
|
467
|
-
let z;
|
|
468
|
-
y = (l + 16) / 116;
|
|
469
|
-
x = a / 500 + y;
|
|
470
|
-
z = y - b / 200;
|
|
471
|
-
const y2 = y ** 3;
|
|
472
|
-
const x2 = x ** 3;
|
|
473
|
-
const z2 = z ** 3;
|
|
474
|
-
y = y2 > .008856 ? y2 : (y - 16 / 116) / 7.787;
|
|
475
|
-
x = x2 > .008856 ? x2 : (x - 16 / 116) / 7.787;
|
|
476
|
-
z = z2 > .008856 ? z2 : (z - 16 / 116) / 7.787;
|
|
477
|
-
x *= 95.047;
|
|
478
|
-
y *= 100;
|
|
479
|
-
z *= 108.883;
|
|
480
|
-
return [
|
|
481
|
-
x,
|
|
482
|
-
y,
|
|
483
|
-
z
|
|
484
|
-
];
|
|
485
|
-
};
|
|
486
|
-
convert.lab.lch = function(lab) {
|
|
487
|
-
const l = lab[0];
|
|
488
|
-
const a = lab[1];
|
|
489
|
-
const b = lab[2];
|
|
490
|
-
let h;
|
|
491
|
-
h = Math.atan2(b, a) * 360 / 2 / Math.PI;
|
|
492
|
-
if (h < 0) h += 360;
|
|
493
|
-
const c = Math.sqrt(a * a + b * b);
|
|
494
|
-
return [
|
|
495
|
-
l,
|
|
496
|
-
c,
|
|
497
|
-
h
|
|
498
|
-
];
|
|
499
|
-
};
|
|
500
|
-
convert.lch.lab = function(lch) {
|
|
501
|
-
const l = lch[0];
|
|
502
|
-
const c = lch[1];
|
|
503
|
-
const hr = lch[2] / 360 * 2 * Math.PI;
|
|
504
|
-
const a = c * Math.cos(hr);
|
|
505
|
-
const b = c * Math.sin(hr);
|
|
506
|
-
return [
|
|
507
|
-
l,
|
|
508
|
-
a,
|
|
509
|
-
b
|
|
510
|
-
];
|
|
511
|
-
};
|
|
512
|
-
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
513
|
-
const [r, g, b] = args;
|
|
514
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
515
|
-
value = Math.round(value / 50);
|
|
516
|
-
if (value === 0) return 30;
|
|
517
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
518
|
-
if (value === 2) ansi += 60;
|
|
519
|
-
return ansi;
|
|
520
|
-
};
|
|
521
|
-
convert.hsv.ansi16 = function(args) {
|
|
522
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
523
|
-
};
|
|
524
|
-
convert.rgb.ansi256 = function(args) {
|
|
525
|
-
const r = args[0];
|
|
526
|
-
const g = args[1];
|
|
527
|
-
const b = args[2];
|
|
528
|
-
if (r === g && g === b) {
|
|
529
|
-
if (r < 8) return 16;
|
|
530
|
-
if (r > 248) return 231;
|
|
531
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
532
|
-
}
|
|
533
|
-
return 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
534
|
-
};
|
|
535
|
-
convert.ansi16.rgb = function(args) {
|
|
536
|
-
let color = args % 10;
|
|
537
|
-
if (color === 0 || color === 7) {
|
|
538
|
-
if (args > 50) color += 3.5;
|
|
539
|
-
color = color / 10.5 * 255;
|
|
540
|
-
return [
|
|
541
|
-
color,
|
|
542
|
-
color,
|
|
543
|
-
color
|
|
544
|
-
];
|
|
545
|
-
}
|
|
546
|
-
const mult = (~~(args > 50) + 1) * .5;
|
|
547
|
-
const r = (color & 1) * mult * 255;
|
|
548
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
549
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
550
|
-
return [
|
|
551
|
-
r,
|
|
552
|
-
g,
|
|
553
|
-
b
|
|
554
|
-
];
|
|
555
|
-
};
|
|
556
|
-
convert.ansi256.rgb = function(args) {
|
|
557
|
-
if (args >= 232) {
|
|
558
|
-
const c = (args - 232) * 10 + 8;
|
|
559
|
-
return [
|
|
560
|
-
c,
|
|
561
|
-
c,
|
|
562
|
-
c
|
|
563
|
-
];
|
|
564
|
-
}
|
|
565
|
-
args -= 16;
|
|
566
|
-
let rem;
|
|
567
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
568
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
569
|
-
const b = rem % 6 / 5 * 255;
|
|
570
|
-
return [
|
|
571
|
-
r,
|
|
572
|
-
g,
|
|
573
|
-
b
|
|
574
|
-
];
|
|
575
|
-
};
|
|
576
|
-
convert.rgb.hex = function(args) {
|
|
577
|
-
const string = (((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255)).toString(16).toUpperCase();
|
|
578
|
-
return "000000".substring(string.length) + string;
|
|
579
|
-
};
|
|
580
|
-
convert.hex.rgb = function(args) {
|
|
581
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
582
|
-
if (!match) return [
|
|
583
|
-
0,
|
|
584
|
-
0,
|
|
585
|
-
0
|
|
586
|
-
];
|
|
587
|
-
let colorString = match[0];
|
|
588
|
-
if (match[0].length === 3) colorString = colorString.split("").map((char) => {
|
|
589
|
-
return char + char;
|
|
590
|
-
}).join("");
|
|
591
|
-
const integer = parseInt(colorString, 16);
|
|
592
|
-
const r = integer >> 16 & 255;
|
|
593
|
-
const g = integer >> 8 & 255;
|
|
594
|
-
const b = integer & 255;
|
|
595
|
-
return [
|
|
596
|
-
r,
|
|
597
|
-
g,
|
|
598
|
-
b
|
|
599
|
-
];
|
|
600
|
-
};
|
|
601
|
-
convert.rgb.hcg = function(rgb) {
|
|
602
|
-
const r = rgb[0] / 255;
|
|
603
|
-
const g = rgb[1] / 255;
|
|
604
|
-
const b = rgb[2] / 255;
|
|
605
|
-
const max = Math.max(Math.max(r, g), b);
|
|
606
|
-
const min = Math.min(Math.min(r, g), b);
|
|
607
|
-
const chroma = max - min;
|
|
608
|
-
let grayscale;
|
|
609
|
-
let hue;
|
|
610
|
-
if (chroma < 1) grayscale = min / (1 - chroma);
|
|
611
|
-
else grayscale = 0;
|
|
612
|
-
if (chroma <= 0) hue = 0;
|
|
613
|
-
else if (max === r) hue = (g - b) / chroma % 6;
|
|
614
|
-
else if (max === g) hue = 2 + (b - r) / chroma;
|
|
615
|
-
else hue = 4 + (r - g) / chroma;
|
|
616
|
-
hue /= 6;
|
|
617
|
-
hue %= 1;
|
|
618
|
-
return [
|
|
619
|
-
hue * 360,
|
|
620
|
-
chroma * 100,
|
|
621
|
-
grayscale * 100
|
|
622
|
-
];
|
|
623
|
-
};
|
|
624
|
-
convert.hsl.hcg = function(hsl) {
|
|
625
|
-
const s = hsl[1] / 100;
|
|
626
|
-
const l = hsl[2] / 100;
|
|
627
|
-
const c = l < .5 ? 2 * s * l : 2 * s * (1 - l);
|
|
628
|
-
let f = 0;
|
|
629
|
-
if (c < 1) f = (l - .5 * c) / (1 - c);
|
|
630
|
-
return [
|
|
631
|
-
hsl[0],
|
|
632
|
-
c * 100,
|
|
633
|
-
f * 100
|
|
634
|
-
];
|
|
635
|
-
};
|
|
636
|
-
convert.hsv.hcg = function(hsv) {
|
|
637
|
-
const s = hsv[1] / 100;
|
|
638
|
-
const v = hsv[2] / 100;
|
|
639
|
-
const c = s * v;
|
|
640
|
-
let f = 0;
|
|
641
|
-
if (c < 1) f = (v - c) / (1 - c);
|
|
642
|
-
return [
|
|
643
|
-
hsv[0],
|
|
644
|
-
c * 100,
|
|
645
|
-
f * 100
|
|
646
|
-
];
|
|
647
|
-
};
|
|
648
|
-
convert.hcg.rgb = function(hcg) {
|
|
649
|
-
const h = hcg[0] / 360;
|
|
650
|
-
const c = hcg[1] / 100;
|
|
651
|
-
const g = hcg[2] / 100;
|
|
652
|
-
if (c === 0) return [
|
|
653
|
-
g * 255,
|
|
654
|
-
g * 255,
|
|
655
|
-
g * 255
|
|
656
|
-
];
|
|
657
|
-
const pure = [
|
|
658
|
-
0,
|
|
659
|
-
0,
|
|
660
|
-
0
|
|
661
|
-
];
|
|
662
|
-
const hi = h % 1 * 6;
|
|
663
|
-
const v = hi % 1;
|
|
664
|
-
const w = 1 - v;
|
|
665
|
-
let mg = 0;
|
|
666
|
-
switch (Math.floor(hi)) {
|
|
667
|
-
case 0:
|
|
668
|
-
pure[0] = 1;
|
|
669
|
-
pure[1] = v;
|
|
670
|
-
pure[2] = 0;
|
|
671
|
-
break;
|
|
672
|
-
case 1:
|
|
673
|
-
pure[0] = w;
|
|
674
|
-
pure[1] = 1;
|
|
675
|
-
pure[2] = 0;
|
|
676
|
-
break;
|
|
677
|
-
case 2:
|
|
678
|
-
pure[0] = 0;
|
|
679
|
-
pure[1] = 1;
|
|
680
|
-
pure[2] = v;
|
|
681
|
-
break;
|
|
682
|
-
case 3:
|
|
683
|
-
pure[0] = 0;
|
|
684
|
-
pure[1] = w;
|
|
685
|
-
pure[2] = 1;
|
|
686
|
-
break;
|
|
687
|
-
case 4:
|
|
688
|
-
pure[0] = v;
|
|
689
|
-
pure[1] = 0;
|
|
690
|
-
pure[2] = 1;
|
|
691
|
-
break;
|
|
692
|
-
default:
|
|
693
|
-
pure[0] = 1;
|
|
694
|
-
pure[1] = 0;
|
|
695
|
-
pure[2] = w;
|
|
696
|
-
}
|
|
697
|
-
mg = (1 - c) * g;
|
|
698
|
-
return [
|
|
699
|
-
(c * pure[0] + mg) * 255,
|
|
700
|
-
(c * pure[1] + mg) * 255,
|
|
701
|
-
(c * pure[2] + mg) * 255
|
|
702
|
-
];
|
|
703
|
-
};
|
|
704
|
-
convert.hcg.hsv = function(hcg) {
|
|
705
|
-
const c = hcg[1] / 100;
|
|
706
|
-
const g = hcg[2] / 100;
|
|
707
|
-
const v = c + g * (1 - c);
|
|
708
|
-
let f = 0;
|
|
709
|
-
if (v > 0) f = c / v;
|
|
710
|
-
return [
|
|
711
|
-
hcg[0],
|
|
712
|
-
f * 100,
|
|
713
|
-
v * 100
|
|
714
|
-
];
|
|
715
|
-
};
|
|
716
|
-
convert.hcg.hsl = function(hcg) {
|
|
717
|
-
const c = hcg[1] / 100;
|
|
718
|
-
const l = hcg[2] / 100 * (1 - c) + .5 * c;
|
|
719
|
-
let s = 0;
|
|
720
|
-
if (l > 0 && l < .5) s = c / (2 * l);
|
|
721
|
-
else if (l >= .5 && l < 1) s = c / (2 * (1 - l));
|
|
722
|
-
return [
|
|
723
|
-
hcg[0],
|
|
724
|
-
s * 100,
|
|
725
|
-
l * 100
|
|
726
|
-
];
|
|
727
|
-
};
|
|
728
|
-
convert.hcg.hwb = function(hcg) {
|
|
729
|
-
const c = hcg[1] / 100;
|
|
730
|
-
const g = hcg[2] / 100;
|
|
731
|
-
const v = c + g * (1 - c);
|
|
732
|
-
return [
|
|
733
|
-
hcg[0],
|
|
734
|
-
(v - c) * 100,
|
|
735
|
-
(1 - v) * 100
|
|
736
|
-
];
|
|
737
|
-
};
|
|
738
|
-
convert.hwb.hcg = function(hwb) {
|
|
739
|
-
const w = hwb[1] / 100;
|
|
740
|
-
const v = 1 - hwb[2] / 100;
|
|
741
|
-
const c = v - w;
|
|
742
|
-
let g = 0;
|
|
743
|
-
if (c < 1) g = (v - c) / (1 - c);
|
|
744
|
-
return [
|
|
745
|
-
hwb[0],
|
|
746
|
-
c * 100,
|
|
747
|
-
g * 100
|
|
748
|
-
];
|
|
749
|
-
};
|
|
750
|
-
convert.apple.rgb = function(apple) {
|
|
751
|
-
return [
|
|
752
|
-
apple[0] / 65535 * 255,
|
|
753
|
-
apple[1] / 65535 * 255,
|
|
754
|
-
apple[2] / 65535 * 255
|
|
755
|
-
];
|
|
756
|
-
};
|
|
757
|
-
convert.rgb.apple = function(rgb) {
|
|
758
|
-
return [
|
|
759
|
-
rgb[0] / 255 * 65535,
|
|
760
|
-
rgb[1] / 255 * 65535,
|
|
761
|
-
rgb[2] / 255 * 65535
|
|
762
|
-
];
|
|
763
|
-
};
|
|
764
|
-
convert.gray.rgb = function(args) {
|
|
765
|
-
return [
|
|
766
|
-
args[0] / 100 * 255,
|
|
767
|
-
args[0] / 100 * 255,
|
|
768
|
-
args[0] / 100 * 255
|
|
769
|
-
];
|
|
770
|
-
};
|
|
771
|
-
convert.gray.hsl = function(args) {
|
|
772
|
-
return [
|
|
773
|
-
0,
|
|
774
|
-
0,
|
|
775
|
-
args[0]
|
|
776
|
-
];
|
|
777
|
-
};
|
|
778
|
-
convert.gray.hsv = convert.gray.hsl;
|
|
779
|
-
convert.gray.hwb = function(gray) {
|
|
780
|
-
return [
|
|
781
|
-
0,
|
|
782
|
-
100,
|
|
783
|
-
gray[0]
|
|
784
|
-
];
|
|
785
|
-
};
|
|
786
|
-
convert.gray.cmyk = function(gray) {
|
|
787
|
-
return [
|
|
788
|
-
0,
|
|
789
|
-
0,
|
|
790
|
-
0,
|
|
791
|
-
gray[0]
|
|
792
|
-
];
|
|
793
|
-
};
|
|
794
|
-
convert.gray.lab = function(gray) {
|
|
795
|
-
return [
|
|
796
|
-
gray[0],
|
|
797
|
-
0,
|
|
798
|
-
0
|
|
799
|
-
];
|
|
800
|
-
};
|
|
801
|
-
convert.gray.hex = function(gray) {
|
|
802
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
803
|
-
const string = ((val << 16) + (val << 8) + val).toString(16).toUpperCase();
|
|
804
|
-
return "000000".substring(string.length) + string;
|
|
805
|
-
};
|
|
806
|
-
convert.rgb.gray = function(rgb) {
|
|
807
|
-
return [(rgb[0] + rgb[1] + rgb[2]) / 3 / 255 * 100];
|
|
808
|
-
};
|
|
809
|
-
}) });
|
|
810
|
-
|
|
811
|
-
//#endregion
|
|
812
|
-
export default require_conversions();
|
|
813
|
-
|
|
814
|
-
export { require_conversions };
|