@visactor/vutils 0.15.9 → 0.15.11-alpha.1
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/cjs/color/Color.d.ts +17 -1
- package/cjs/color/Color.js +74 -3
- package/cjs/color/Color.js.map +1 -1
- package/cjs/graphics/text/measure/index.d.ts +0 -1
- package/cjs/graphics/text/measure/index.js +1 -1
- package/cjs/graphics/text/measure/index.js.map +1 -1
- package/cjs/math.d.ts +3 -0
- package/cjs/math.js +16 -2
- package/cjs/math.js.map +1 -1
- package/dist/index.js +126 -82
- package/dist/index.min.js +1 -1
- package/es/color/Color.d.ts +17 -1
- package/es/color/Color.js +74 -3
- package/es/color/Color.js.map +1 -1
- package/es/graphics/text/measure/index.d.ts +0 -1
- package/es/graphics/text/measure/index.js +0 -2
- package/es/graphics/text/measure/index.js.map +1 -1
- package/es/math.d.ts +3 -0
- package/es/math.js +13 -0
- package/es/math.js.map +1 -1
- package/package.json +2 -1
- package/cjs/graphics/text/measure/test.d.ts +0 -14
- package/cjs/graphics/text/measure/test.js +0 -67
- package/cjs/graphics/text/measure/test.js.map +0 -1
- package/es/graphics/text/measure/test.d.ts +0 -14
- package/es/graphics/text/measure/test.js +0 -65
- package/es/graphics/text/measure/test.js.map +0 -1
package/cjs/color/Color.d.ts
CHANGED
|
@@ -159,14 +159,30 @@ export declare class Color {
|
|
|
159
159
|
toString(): string;
|
|
160
160
|
toHex(): string;
|
|
161
161
|
toHsl(): string;
|
|
162
|
-
setOpacity(o?: number): this;
|
|
163
162
|
brighter(k: number): this;
|
|
163
|
+
add(color: Color): this;
|
|
164
|
+
sub(color: Color): this;
|
|
165
|
+
multiply(color: Color): this;
|
|
164
166
|
getHSVBrightness(): number;
|
|
165
167
|
getHSLBrightness(): number;
|
|
166
168
|
setHsl(h?: number | null | undefined, s?: number | null | undefined, l?: number | null | undefined): this;
|
|
169
|
+
setRGB(r: number, g: number, b: number): this;
|
|
170
|
+
setHex(value: string): RGB | this;
|
|
171
|
+
setColorName(name: string): this;
|
|
172
|
+
setScalar(scalar: number): this;
|
|
173
|
+
setOpacity(o?: number): this;
|
|
167
174
|
getLuminance(): number;
|
|
168
175
|
getLuminance2(): number;
|
|
169
176
|
getLuminance3(): number;
|
|
177
|
+
clone(): Color;
|
|
178
|
+
copyGammaToLinear(color: Color, gammaFactor?: number): this;
|
|
179
|
+
copyLinearToGamma(color: Color, gammaFactor?: number): this;
|
|
180
|
+
convertGammaToLinear(gammaFactor: number): this;
|
|
181
|
+
convertLinearToGamma(gammaFactor: number): this;
|
|
182
|
+
copySRGBToLinear(color: Color): this;
|
|
183
|
+
copyLinearToSRGB(color: Color): this;
|
|
184
|
+
convertSRGBToLinear(): this;
|
|
185
|
+
convertLinearToSRGB(): this;
|
|
170
186
|
}
|
|
171
187
|
export declare class RGB {
|
|
172
188
|
r: number;
|
package/cjs/color/Color.js
CHANGED
|
@@ -28,6 +28,14 @@ function rgba(value) {
|
|
|
28
28
|
common_1.isArray)(value) ? new RGB(value[0], value[1], value[2], value[3]) : new RGB(255, 255, 255, 1);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function SRGBToLinear(c) {
|
|
32
|
+
return c < .04045 ? .0773993808 * c : Math.pow(.9478672986 * c + .0521327014, 2.4);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function LinearToSRGB(c) {
|
|
36
|
+
return c < .0031308 ? 12.92 * c : 1.055 * Math.pow(c, .41666) - .055;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
exports.DEFAULT_COLORS = {
|
|
32
40
|
aliceblue: 15792383,
|
|
33
41
|
antiquewhite: 16444375,
|
|
@@ -240,14 +248,26 @@ class Color {
|
|
|
240
248
|
toHsl() {
|
|
241
249
|
return this.color.formatHsl();
|
|
242
250
|
}
|
|
243
|
-
setOpacity(o = 1) {
|
|
244
|
-
return this.color.opacity = o, this;
|
|
245
|
-
}
|
|
246
251
|
brighter(k) {
|
|
247
252
|
const {r: r, g: g, b: b} = this.color;
|
|
248
253
|
return this.color.r = Math.max(0, Math.min(255, Math.floor(r * k))), this.color.g = Math.max(0, Math.min(255, Math.floor(g * k))),
|
|
249
254
|
this.color.b = Math.max(0, Math.min(255, Math.floor(b * k))), this;
|
|
250
255
|
}
|
|
256
|
+
add(color) {
|
|
257
|
+
const {r: r, g: g, b: b} = this.color;
|
|
258
|
+
return this.color.r += Math.min(255, r + color.color.r), this.color.g += Math.min(255, g + color.color.g),
|
|
259
|
+
this.color.b += Math.min(255, b + color.color.b), this;
|
|
260
|
+
}
|
|
261
|
+
sub(color) {
|
|
262
|
+
return this.color.r = Math.max(0, this.color.r - color.color.r), this.color.g = Math.max(0, this.color.g - color.color.g),
|
|
263
|
+
this.color.b = Math.max(0, this.color.b - color.color.b), this;
|
|
264
|
+
}
|
|
265
|
+
multiply(color) {
|
|
266
|
+
const {r: r, g: g, b: b} = this.color;
|
|
267
|
+
return this.color.r = Math.max(0, Math.min(255, Math.floor(r * color.color.r))),
|
|
268
|
+
this.color.g = Math.max(0, Math.min(255, Math.floor(g * color.color.g))), this.color.b = Math.max(0, Math.min(255, Math.floor(b * color.color.b))),
|
|
269
|
+
this;
|
|
270
|
+
}
|
|
251
271
|
getHSVBrightness() {
|
|
252
272
|
return Math.max(this.color.r, this.color.g, this.color.b) / 255;
|
|
253
273
|
}
|
|
@@ -260,6 +280,25 @@ class Color {
|
|
|
260
280
|
common_1.isNil)(s) ? hsl.s : s >= 0 && s <= 1 ? 100 * s : s, (0, common_1.isNil)(l) ? hsl.l : l <= 1 && l >= 0 ? 100 * l : l);
|
|
261
281
|
return this.color = new RGB(rgb.r, rgb.g, rgb.b, opacity), this;
|
|
262
282
|
}
|
|
283
|
+
setRGB(r, g, b) {
|
|
284
|
+
return !(0, common_1.isNil)(r) && (this.color.r = r), !(0, common_1.isNil)(g) && (this.color.g = g),
|
|
285
|
+
!(0, common_1.isNil)(b) && (this.color.b = b), this;
|
|
286
|
+
}
|
|
287
|
+
setHex(value) {
|
|
288
|
+
const formatValue = `${value}`.trim().toLowerCase(), isHex = REG_HEX.exec(formatValue), hex = parseInt(isHex[1], 16), hexLength = isHex[1].length;
|
|
289
|
+
return 3 === hexLength ? new RGB((hex >> 8 & 15) + ((hex >> 8 & 15) << 4), (hex >> 4 & 15) + ((hex >> 4 & 15) << 4), (15 & hex) + ((15 & hex) << 4), 1) : 6 === hexLength ? rgb(hex) : 8 === hexLength ? new RGB(hex >> 24 & 255, hex >> 16 & 255, hex >> 8 & 255, (255 & hex) / 255) : this;
|
|
290
|
+
}
|
|
291
|
+
setColorName(name) {
|
|
292
|
+
const hex = exports.DEFAULT_COLORS[name.toLowerCase()];
|
|
293
|
+
return void 0 !== hex ? this.setHex(hex) : console.warn("THREE.Color: Unknown color " + name),
|
|
294
|
+
this;
|
|
295
|
+
}
|
|
296
|
+
setScalar(scalar) {
|
|
297
|
+
return this.color.r = scalar, this.color.g = scalar, this.color.b = scalar, this;
|
|
298
|
+
}
|
|
299
|
+
setOpacity(o = 1) {
|
|
300
|
+
return this.color.opacity = o, this;
|
|
301
|
+
}
|
|
263
302
|
getLuminance() {
|
|
264
303
|
return (.2126 * this.color.r + .7152 * this.color.g + .0722 * this.color.b) / 255;
|
|
265
304
|
}
|
|
@@ -269,6 +308,38 @@ class Color {
|
|
|
269
308
|
getLuminance3() {
|
|
270
309
|
return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
|
|
271
310
|
}
|
|
311
|
+
clone() {
|
|
312
|
+
return new Color(this.color.toString());
|
|
313
|
+
}
|
|
314
|
+
copyGammaToLinear(color, gammaFactor = 2) {
|
|
315
|
+
return this.color.r = Math.pow(color.color.r, gammaFactor), this.color.g = Math.pow(color.color.g, gammaFactor),
|
|
316
|
+
this.color.b = Math.pow(color.color.b, gammaFactor), this;
|
|
317
|
+
}
|
|
318
|
+
copyLinearToGamma(color, gammaFactor = 2) {
|
|
319
|
+
const safeInverse = gammaFactor > 0 ? 1 / gammaFactor : 1;
|
|
320
|
+
return this.color.r = Math.pow(color.color.r, safeInverse), this.color.g = Math.pow(color.color.g, safeInverse),
|
|
321
|
+
this.color.b = Math.pow(color.color.b, safeInverse), this;
|
|
322
|
+
}
|
|
323
|
+
convertGammaToLinear(gammaFactor) {
|
|
324
|
+
return this.copyGammaToLinear(this, gammaFactor), this;
|
|
325
|
+
}
|
|
326
|
+
convertLinearToGamma(gammaFactor) {
|
|
327
|
+
return this.copyLinearToGamma(this, gammaFactor), this;
|
|
328
|
+
}
|
|
329
|
+
copySRGBToLinear(color) {
|
|
330
|
+
return this.color.r = SRGBToLinear(color.color.r), this.color.g = SRGBToLinear(color.color.g),
|
|
331
|
+
this.color.b = SRGBToLinear(color.color.b), this;
|
|
332
|
+
}
|
|
333
|
+
copyLinearToSRGB(color) {
|
|
334
|
+
return this.color.r = LinearToSRGB(color.color.r), this.color.g = LinearToSRGB(color.color.g),
|
|
335
|
+
this.color.b = LinearToSRGB(color.color.b), this;
|
|
336
|
+
}
|
|
337
|
+
convertSRGBToLinear() {
|
|
338
|
+
return this.copySRGBToLinear(this), this;
|
|
339
|
+
}
|
|
340
|
+
convertLinearToSRGB() {
|
|
341
|
+
return this.copyLinearToSRGB(this), this;
|
|
342
|
+
}
|
|
272
343
|
}
|
|
273
344
|
|
|
274
345
|
exports.Color = Color;
|
package/cjs/color/Color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/color/Color.ts"],"names":[],"mappings":";;;;;;AAkCA,sCAAqE;AACrE,0DAAkC;AAClC,0DAAkC;AAElC,MAAM,OAAO,GAAG,oBAAoB,CAAC;AAErC,MAAM,sBAAsB,GAAG;IAC7B,WAAW,EAAE,UAAU;CACxB,CAAC;AAEW,QAAA,cAAc,GAAG;IAC5B,SAAS,EAAE,QAAQ;IACnB,YAAY,EAAE,QAAQ;IACtB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,QAAQ;IACf,KAAK,EA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GAAG,CAAC,CAAC,EAAE,CAAC;IAC7G,CAAC;IACD,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,OAAO,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,EAAE,CAAC;IACnH,CAAC;IAED,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,OAAO,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,EAAE,CAAC;IACtG,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AAnCD,kBAmCC","file":"Color.js","sourcesContent":["/*\nCopyright (c) 2013, Jason Davies.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n * The name Jason Davies may not be used to endorse or promote products\n derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL JASON DAVIES BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\nADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Mike Bostock, https://github.com/d3/d3-color\n/**\n * 参考 d3-color 实现。用于颜色转化\n * 16进制/rgb 转化为r,g,b, o\n */\nimport { clamp, isArray, isNil, isNumber, isValid } from '../common';\nimport hslToRgb from './hslToRgb';\nimport rgbToHsl from './rgbToHsl';\n\nconst REG_HEX = /^#([0-9a-f]{3,8})$/;\n\nconst DEFAULT_COLORS_OPACITY = {\n transparent: 0xffffff00\n};\n\nexport const DEFAULT_COLORS = {\n aliceblue: 0xf0f8ff,\n antiquewhite: 0xfaebd7,\n aqua: 0x00ffff,\n aquamarine: 0x7fffd4,\n azure: 0xf0ffff,\n beige: 0xf5f5dc,\n bisque: 0xffe4c4,\n black: 0x000000,\n blanchedalmond: 0xffebcd,\n blue: 0x0000ff,\n blueviolet: 0x8a2be2,\n brown: 0xa52a2a,\n burlywood: 0xdeb887,\n cadetblue: 0x5f9ea0,\n chartreuse: 0x7fff00,\n chocolate: 0xd2691e,\n coral: 0xff7f50,\n cornflowerblue: 0x6495ed,\n cornsilk: 0xfff8dc,\n crimson: 0xdc143c,\n cyan: 0x00ffff,\n darkblue: 0x00008b,\n darkcyan: 0x008b8b,\n darkgoldenrod: 0xb8860b,\n darkgray: 0xa9a9a9,\n darkgreen: 0x006400,\n darkgrey: 0xa9a9a9,\n darkkhaki: 0xbdb76b,\n darkmagenta: 0x8b008b,\n darkolivegreen: 0x556b2f,\n darkorange: 0xff8c00,\n darkorchid: 0x9932cc,\n darkred: 0x8b0000,\n darksalmon: 0xe9967a,\n darkseagreen: 0x8fbc8f,\n darkslateblue: 0x483d8b,\n darkslategray: 0x2f4f4f,\n darkslategrey: 0x2f4f4f,\n darkturquoise: 0x00ced1,\n darkviolet: 0x9400d3,\n deeppink: 0xff1493,\n deepskyblue: 0x00bfff,\n dimgray: 0x696969,\n dimgrey: 0x696969,\n dodgerblue: 0x1e90ff,\n firebrick: 0xb22222,\n floralwhite: 0xfffaf0,\n forestgreen: 0x228b22,\n fuchsia: 0xff00ff,\n gainsboro: 0xdcdcdc,\n ghostwhite: 0xf8f8ff,\n gold: 0xffd700,\n goldenrod: 0xdaa520,\n gray: 0x808080,\n green: 0x008000,\n greenyellow: 0xadff2f,\n grey: 0x808080,\n honeydew: 0xf0fff0,\n hotpink: 0xff69b4,\n indianred: 0xcd5c5c,\n indigo: 0x4b0082,\n ivory: 0xfffff0,\n khaki: 0xf0e68c,\n lavender: 0xe6e6fa,\n lavenderblush: 0xfff0f5,\n lawngreen: 0x7cfc00,\n lemonchiffon: 0xfffacd,\n lightblue: 0xadd8e6,\n lightcoral: 0xf08080,\n lightcyan: 0xe0ffff,\n lightgoldenrodyellow: 0xfafad2,\n lightgray: 0xd3d3d3,\n lightgreen: 0x90ee90,\n lightgrey: 0xd3d3d3,\n lightpink: 0xffb6c1,\n lightsalmon: 0xffa07a,\n lightseagreen: 0x20b2aa,\n lightskyblue: 0x87cefa,\n lightslategray: 0x778899,\n lightslategrey: 0x778899,\n lightsteelblue: 0xb0c4de,\n lightyellow: 0xffffe0,\n lime: 0x00ff00,\n limegreen: 0x32cd32,\n linen: 0xfaf0e6,\n magenta: 0xff00ff,\n maroon: 0x800000,\n mediumaquamarine: 0x66cdaa,\n mediumblue: 0x0000cd,\n mediumorchid: 0xba55d3,\n mediumpurple: 0x9370db,\n mediumseagreen: 0x3cb371,\n mediumslateblue: 0x7b68ee,\n mediumspringgreen: 0x00fa9a,\n mediumturquoise: 0x48d1cc,\n mediumvioletred: 0xc71585,\n midnightblue: 0x191970,\n mintcream: 0xf5fffa,\n mistyrose: 0xffe4e1,\n moccasin: 0xffe4b5,\n navajowhite: 0xffdead,\n navy: 0x000080,\n oldlace: 0xfdf5e6,\n olive: 0x808000,\n olivedrab: 0x6b8e23,\n orange: 0xffa500,\n orangered: 0xff4500,\n orchid: 0xda70d6,\n palegoldenrod: 0xeee8aa,\n palegreen: 0x98fb98,\n paleturquoise: 0xafeeee,\n palevioletred: 0xdb7093,\n papayawhip: 0xffefd5,\n peachpuff: 0xffdab9,\n peru: 0xcd853f,\n pink: 0xffc0cb,\n plum: 0xdda0dd,\n powderblue: 0xb0e0e6,\n purple: 0x800080,\n rebeccapurple: 0x663399,\n red: 0xff0000,\n rosybrown: 0xbc8f8f,\n royalblue: 0x4169e1,\n saddlebrown: 0x8b4513,\n salmon: 0xfa8072,\n sandybrown: 0xf4a460,\n seagreen: 0x2e8b57,\n seashell: 0xfff5ee,\n sienna: 0xa0522d,\n silver: 0xc0c0c0,\n skyblue: 0x87ceeb,\n slateblue: 0x6a5acd,\n slategray: 0x708090,\n slategrey: 0x708090,\n snow: 0xfffafa,\n springgreen: 0x00ff7f,\n steelblue: 0x4682b4,\n tan: 0xd2b48c,\n teal: 0x008080,\n thistle: 0xd8bfd8,\n tomato: 0xff6347,\n turquoise: 0x40e0d0,\n violet: 0xee82ee,\n wheat: 0xf5deb3,\n white: 0xffffff,\n whitesmoke: 0xf5f5f5,\n yellow: 0xffff00,\n yellowgreen: 0x9acd32\n};\n\nfunction hex(value: number) {\n value = Math.max(0, Math.min(255, Math.round(value) || 0));\n return (value < 16 ? '0' : '') + value.toString(16);\n}\n\nfunction rgb(value: number | number[]): RGB {\n if (isNumber(value)) {\n return new RGB((value as number) >> 16, ((value as number) >> 8) & 0xff, (value as number) & 0xff, 1);\n } else if (isArray(value)) {\n return new RGB(value[0], value[1], value[2]);\n }\n\n // default return\n return new RGB(255, 255, 255);\n}\n\nfunction rgba(value: number | number[]): RGB {\n if (isNumber(value)) {\n return new RGB(\n (value as number) >>> 24,\n ((value as number) >>> 16) & 0xff,\n ((value as number) >>> 8) & 0xff,\n (value as number) & 0xff\n );\n } else if (isArray(value)) {\n return new RGB(value[0], value[1], value[2], value[3]);\n }\n\n // default return\n return new RGB(255, 255, 255, 1);\n}\n\nexport class Color {\n color!: RGB;\n\n static Brighter(source: string, b = 1) {\n if (b === 1) {\n return source;\n }\n return new Color(source).brighter(b).toRGBA();\n }\n\n static SetOpacity(source: string, o = 1) {\n if (o === 1) {\n return source;\n }\n return new Color(source).setOpacity(o).toRGBA();\n }\n\n static getColorBrightness(source: string | Color, model: 'hsv' | 'hsl' | 'lum' | 'lum2' | 'lum3' = 'hsl') {\n const color = source instanceof Color ? source : new Color(source);\n switch (model) {\n case 'hsv':\n return color.getHSVBrightness();\n case 'hsl':\n return color.getHSLBrightness();\n case 'lum':\n return color.getLuminance();\n case 'lum2':\n return color.getLuminance2();\n case 'lum3':\n return color.getLuminance3();\n default:\n return color.getHSVBrightness();\n }\n }\n\n static parseColorString(value: string) {\n // case0: transparent\n if (isValid(DEFAULT_COLORS_OPACITY[value])) {\n return rgba(DEFAULT_COLORS_OPACITY[value]);\n }\n\n // case1: 简写 ['blue','red']\n if (isValid(DEFAULT_COLORS[value])) {\n return rgb(DEFAULT_COLORS[value]);\n }\n const formatValue = `${value}`.trim().toLowerCase();\n const isHex = REG_HEX.exec(formatValue);\n\n // case2: 16进制\n if (isHex) {\n const hex = parseInt(isHex[1], 16);\n const hexLength = isHex[1].length;\n // #fff\n if (hexLength === 3) {\n return new RGB(\n ((hex >> 8) & 0xf) + (((hex >> 8) & 0xf) << 4),\n ((hex >> 4) & 0xf) + (((hex >> 4) & 0xf) << 4),\n (hex & 0xf) + ((hex & 0xf) << 4),\n 1\n );\n }\n // #ffffff\n if (hexLength === 6) {\n return rgb(hex);\n }\n // #ffffffaa\n else if (hexLength === 8) {\n return new RGB((hex >> 24) & 0xff, (hex >> 16) & 0xff, (hex >> 8) & 0xff, (hex & 0xff) / 0xff);\n }\n\n return;\n }\n\n // case3 : rgb\n if (/^(rgb|RGB|rgba|RGBA)/.test(formatValue)) {\n const aColor = formatValue.replace(/(?:\\(|\\)|rgba|RGBA|rgb|RGB)*/g, '').split(',');\n return new RGB(parseInt(aColor[0], 10), parseInt(aColor[1], 10), parseInt(aColor[2], 10), parseFloat(aColor[3]));\n }\n\n // case4: hsl\n if (/^(hsl|HSL|hsla|HSLA)/.test(formatValue)) {\n const aColor = formatValue.replace(/(?:\\(|\\)|hsla|HSLA|hsl|HSL)*/g, '').split(',');\n const rgb = hslToRgb(parseInt(aColor[0], 10), parseInt(aColor[1], 10), parseInt(aColor[2], 10));\n\n return new RGB(rgb.r, rgb.g, rgb.b, parseFloat(aColor[3]));\n }\n\n return;\n }\n\n constructor(value: string) {\n const color = Color.parseColorString(value);\n\n // case0: transparent\n if (color) {\n this.color = color;\n } else {\n // default: 白色\n console.warn(`Warn: 传入${value}无法解析为Color`);\n this.color = new RGB(255, 255, 255);\n }\n }\n toRGBA() {\n return this.color.formatRgb();\n }\n toString() {\n return this.color.formatRgb();\n }\n toHex() {\n return this.color.formatHex();\n }\n toHsl() {\n return this.color.formatHsl();\n }\n setOpacity(o = 1) {\n this.color.opacity = o;\n return this;\n }\n brighter(k: number) {\n const { r, g, b } = this.color;\n this.color.r = Math.max(0, Math.min(255, Math.floor(r * k)));\n this.color.g = Math.max(0, Math.min(255, Math.floor(g * k)));\n this.color.b = Math.max(0, Math.min(255, Math.floor(b * k)));\n return this;\n }\n\n // todo: 这里亮度计算都没考虑alpha通道\n getHSVBrightness() {\n return Math.max(this.color.r, this.color.g, this.color.b) / 255;\n }\n\n getHSLBrightness() {\n return (\n (Math.max(this.color.r, this.color.g, this.color.b) / 255 +\n Math.min(this.color.r, this.color.g, this.color.b) / 255) *\n 0.5\n );\n }\n\n setHsl(h?: number | null | undefined, s?: number | null | undefined, l?: number | null | undefined) {\n const opacity = this.color.opacity;\n const hsl = rgbToHsl(this.color.r, this.color.g, this.color.b);\n\n const rgb = hslToRgb(\n isNil(h) ? hsl.h : clamp(h as number, 0, 360),\n isNil(s) ? hsl.s : s >= 0 && s <= 1 ? s * 100 : s,\n isNil(l) ? hsl.l : l <= 1 && l >= 0 ? l * 100 : l\n );\n this.color = new RGB(rgb.r, rgb.g, rgb.b, opacity);\n\n return this;\n }\n\n getLuminance() {\n return (0.2126 * this.color.r + 0.7152 * this.color.g + 0.0722 * this.color.b) / 255;\n }\n\n getLuminance2() {\n return (0.2627 * this.color.r + 0.678 * this.color.g + 0.0593 * this.color.b) / 255;\n }\n\n getLuminance3() {\n return (0.299 * this.color.r + 0.587 * this.color.g + 0.114 * this.color.b) / 255;\n }\n}\n\nexport class RGB {\n r: number;\n g: number;\n b: number;\n opacity: number;\n constructor(r: number, g: number, b: number, opacity?: number) {\n this.r = isNaN(+r) ? 255 : Math.max(0, Math.min(255, +r));\n this.g = isNaN(+g) ? 255 : Math.max(0, Math.min(255, +g));\n this.b = isNaN(+b) ? 255 : Math.max(0, Math.min(255, +b));\n\n if (isValid(opacity)) {\n this.opacity = isNaN(+(opacity as number)) ? 1 : Math.max(0, Math.min(1, +(opacity as number)));\n } else {\n this.opacity = 1;\n }\n }\n // 转为16进制\n formatHex() {\n return `#${hex(this.r) + hex(this.g) + hex(this.b) + (this.opacity === 1 ? '' : hex(this.opacity * 255))}`;\n }\n formatRgb() {\n const opacity = this.opacity;\n return `${opacity === 1 ? 'rgb(' : 'rgba('}${this.r},${this.g},${this.b}${opacity === 1 ? ')' : `,${opacity})`}`;\n }\n\n formatHsl() {\n const opacity = this.opacity;\n const { h, s, l } = rgbToHsl(this.r, this.g, this.b);\n\n return `${opacity === 1 ? 'hsl(' : 'hsla('}${h},${s}%,${l}%${opacity === 1 ? ')' : `,${opacity})`}`;\n }\n // 转为16进制\n toString() {\n return this.formatHex();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/color/Color.ts"],"names":[],"mappings":";;;;;;AAkCA,sCAAqE;AACrE,0DAAkC;AAClC,0DAAkC;AAElC,MAAM,OAAO,GAAG,oBAAoB,CAAC;AAErC,MAAM,sBAAsB,GAAG;IAC7B,WAAW,EAAE,UAAU;CACxB,CAAC;AAEW,QAAA,cAAc,GAAG;IAC5B,SAAS,EAAE,QAAQ;IACnB,YAAY,EAAE,QAAQ;IACtB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,QAAQ;IACf,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,cAAc,EAAE,QAAQ;IACxB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ;IACnB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,QAAQ;IACnB,KAAK,EAAE,QAAQ;IACf,cAAc,EAAE,QAAQ;IACxB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,QAAQ;IACnB,WAAW,EAAE,QAAQ;IACrB,cAAc,EAAE,QAAQ;IACxB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,OAAO,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,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,EAAE,CAAC;IACnH,CAAC;IAED,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAA,kBAAQ,EAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAErD,OAAO,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,EAAE,CAAC;IACtG,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;CACF;AAnCD,kBAmCC","file":"Color.js","sourcesContent":["/*\nCopyright (c) 2013, Jason Davies.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n * The name Jason Davies may not be used to endorse or promote products\n derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL JASON DAVIES BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\nPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\nLIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\nOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\nADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n// Mike Bostock, https://github.com/d3/d3-color\n/**\n * 参考 d3-color 实现。用于颜色转化\n * 16进制/rgb 转化为r,g,b, o\n */\nimport { clamp, isArray, isNil, isNumber, isValid } from '../common';\nimport hslToRgb from './hslToRgb';\nimport rgbToHsl from './rgbToHsl';\n\nconst REG_HEX = /^#([0-9a-f]{3,8})$/;\n\nconst DEFAULT_COLORS_OPACITY = {\n transparent: 0xffffff00\n};\n\nexport const DEFAULT_COLORS = {\n aliceblue: 0xf0f8ff,\n antiquewhite: 0xfaebd7,\n aqua: 0x00ffff,\n aquamarine: 0x7fffd4,\n azure: 0xf0ffff,\n beige: 0xf5f5dc,\n bisque: 0xffe4c4,\n black: 0x000000,\n blanchedalmond: 0xffebcd,\n blue: 0x0000ff,\n blueviolet: 0x8a2be2,\n brown: 0xa52a2a,\n burlywood: 0xdeb887,\n cadetblue: 0x5f9ea0,\n chartreuse: 0x7fff00,\n chocolate: 0xd2691e,\n coral: 0xff7f50,\n cornflowerblue: 0x6495ed,\n cornsilk: 0xfff8dc,\n crimson: 0xdc143c,\n cyan: 0x00ffff,\n darkblue: 0x00008b,\n darkcyan: 0x008b8b,\n darkgoldenrod: 0xb8860b,\n darkgray: 0xa9a9a9,\n darkgreen: 0x006400,\n darkgrey: 0xa9a9a9,\n darkkhaki: 0xbdb76b,\n darkmagenta: 0x8b008b,\n darkolivegreen: 0x556b2f,\n darkorange: 0xff8c00,\n darkorchid: 0x9932cc,\n darkred: 0x8b0000,\n darksalmon: 0xe9967a,\n darkseagreen: 0x8fbc8f,\n darkslateblue: 0x483d8b,\n darkslategray: 0x2f4f4f,\n darkslategrey: 0x2f4f4f,\n darkturquoise: 0x00ced1,\n darkviolet: 0x9400d3,\n deeppink: 0xff1493,\n deepskyblue: 0x00bfff,\n dimgray: 0x696969,\n dimgrey: 0x696969,\n dodgerblue: 0x1e90ff,\n firebrick: 0xb22222,\n floralwhite: 0xfffaf0,\n forestgreen: 0x228b22,\n fuchsia: 0xff00ff,\n gainsboro: 0xdcdcdc,\n ghostwhite: 0xf8f8ff,\n gold: 0xffd700,\n goldenrod: 0xdaa520,\n gray: 0x808080,\n green: 0x008000,\n greenyellow: 0xadff2f,\n grey: 0x808080,\n honeydew: 0xf0fff0,\n hotpink: 0xff69b4,\n indianred: 0xcd5c5c,\n indigo: 0x4b0082,\n ivory: 0xfffff0,\n khaki: 0xf0e68c,\n lavender: 0xe6e6fa,\n lavenderblush: 0xfff0f5,\n lawngreen: 0x7cfc00,\n lemonchiffon: 0xfffacd,\n lightblue: 0xadd8e6,\n lightcoral: 0xf08080,\n lightcyan: 0xe0ffff,\n lightgoldenrodyellow: 0xfafad2,\n lightgray: 0xd3d3d3,\n lightgreen: 0x90ee90,\n lightgrey: 0xd3d3d3,\n lightpink: 0xffb6c1,\n lightsalmon: 0xffa07a,\n lightseagreen: 0x20b2aa,\n lightskyblue: 0x87cefa,\n lightslategray: 0x778899,\n lightslategrey: 0x778899,\n lightsteelblue: 0xb0c4de,\n lightyellow: 0xffffe0,\n lime: 0x00ff00,\n limegreen: 0x32cd32,\n linen: 0xfaf0e6,\n magenta: 0xff00ff,\n maroon: 0x800000,\n mediumaquamarine: 0x66cdaa,\n mediumblue: 0x0000cd,\n mediumorchid: 0xba55d3,\n mediumpurple: 0x9370db,\n mediumseagreen: 0x3cb371,\n mediumslateblue: 0x7b68ee,\n mediumspringgreen: 0x00fa9a,\n mediumturquoise: 0x48d1cc,\n mediumvioletred: 0xc71585,\n midnightblue: 0x191970,\n mintcream: 0xf5fffa,\n mistyrose: 0xffe4e1,\n moccasin: 0xffe4b5,\n navajowhite: 0xffdead,\n navy: 0x000080,\n oldlace: 0xfdf5e6,\n olive: 0x808000,\n olivedrab: 0x6b8e23,\n orange: 0xffa500,\n orangered: 0xff4500,\n orchid: 0xda70d6,\n palegoldenrod: 0xeee8aa,\n palegreen: 0x98fb98,\n paleturquoise: 0xafeeee,\n palevioletred: 0xdb7093,\n papayawhip: 0xffefd5,\n peachpuff: 0xffdab9,\n peru: 0xcd853f,\n pink: 0xffc0cb,\n plum: 0xdda0dd,\n powderblue: 0xb0e0e6,\n purple: 0x800080,\n rebeccapurple: 0x663399,\n red: 0xff0000,\n rosybrown: 0xbc8f8f,\n royalblue: 0x4169e1,\n saddlebrown: 0x8b4513,\n salmon: 0xfa8072,\n sandybrown: 0xf4a460,\n seagreen: 0x2e8b57,\n seashell: 0xfff5ee,\n sienna: 0xa0522d,\n silver: 0xc0c0c0,\n skyblue: 0x87ceeb,\n slateblue: 0x6a5acd,\n slategray: 0x708090,\n slategrey: 0x708090,\n snow: 0xfffafa,\n springgreen: 0x00ff7f,\n steelblue: 0x4682b4,\n tan: 0xd2b48c,\n teal: 0x008080,\n thistle: 0xd8bfd8,\n tomato: 0xff6347,\n turquoise: 0x40e0d0,\n violet: 0xee82ee,\n wheat: 0xf5deb3,\n white: 0xffffff,\n whitesmoke: 0xf5f5f5,\n yellow: 0xffff00,\n yellowgreen: 0x9acd32\n};\n\nfunction hex(value: number) {\n value = Math.max(0, Math.min(255, Math.round(value) || 0));\n return (value < 16 ? '0' : '') + value.toString(16);\n}\n\nfunction rgb(value: number | number[]): RGB {\n if (isNumber(value)) {\n return new RGB((value as number) >> 16, ((value as number) >> 8) & 0xff, (value as number) & 0xff, 1);\n } else if (isArray(value)) {\n return new RGB(value[0], value[1], value[2]);\n }\n\n // default return\n return new RGB(255, 255, 255);\n}\n\nfunction rgba(value: number | number[]): RGB {\n if (isNumber(value)) {\n return new RGB(\n (value as number) >>> 24,\n ((value as number) >>> 16) & 0xff,\n ((value as number) >>> 8) & 0xff,\n (value as number) & 0xff\n );\n } else if (isArray(value)) {\n return new RGB(value[0], value[1], value[2], value[3]);\n }\n\n // default return\n return new RGB(255, 255, 255, 1);\n}\n\nfunction SRGBToLinear(c: number) {\n return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);\n}\n\nfunction LinearToSRGB(c: number) {\n return c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;\n}\n\nexport class Color {\n color!: RGB;\n\n static Brighter(source: string, b = 1) {\n if (b === 1) {\n return source;\n }\n return new Color(source).brighter(b).toRGBA();\n }\n\n static SetOpacity(source: string, o = 1) {\n if (o === 1) {\n return source;\n }\n return new Color(source).setOpacity(o).toRGBA();\n }\n\n static getColorBrightness(source: string | Color, model: 'hsv' | 'hsl' | 'lum' | 'lum2' | 'lum3' = 'hsl') {\n const color = source instanceof Color ? source : new Color(source);\n switch (model) {\n case 'hsv':\n return color.getHSVBrightness();\n case 'hsl':\n return color.getHSLBrightness();\n case 'lum':\n return color.getLuminance();\n case 'lum2':\n return color.getLuminance2();\n case 'lum3':\n return color.getLuminance3();\n default:\n return color.getHSVBrightness();\n }\n }\n\n static parseColorString(value: string) {\n // case0: transparent\n if (isValid(DEFAULT_COLORS_OPACITY[value])) {\n return rgba(DEFAULT_COLORS_OPACITY[value]);\n }\n\n // case1: 简写 ['blue','red']\n if (isValid(DEFAULT_COLORS[value])) {\n return rgb(DEFAULT_COLORS[value]);\n }\n const formatValue = `${value}`.trim().toLowerCase();\n const isHex = REG_HEX.exec(formatValue);\n\n // case2: 16进制\n if (isHex) {\n const hex = parseInt(isHex[1], 16);\n const hexLength = isHex[1].length;\n // #fff\n if (hexLength === 3) {\n return new RGB(\n ((hex >> 8) & 0xf) + (((hex >> 8) & 0xf) << 4),\n ((hex >> 4) & 0xf) + (((hex >> 4) & 0xf) << 4),\n (hex & 0xf) + ((hex & 0xf) << 4),\n 1\n );\n }\n // #ffffff\n if (hexLength === 6) {\n return rgb(hex);\n }\n // #ffffffaa\n else if (hexLength === 8) {\n return new RGB((hex >> 24) & 0xff, (hex >> 16) & 0xff, (hex >> 8) & 0xff, (hex & 0xff) / 0xff);\n }\n\n return;\n }\n\n // case3 : rgb\n if (/^(rgb|RGB|rgba|RGBA)/.test(formatValue)) {\n const aColor = formatValue.replace(/(?:\\(|\\)|rgba|RGBA|rgb|RGB)*/g, '').split(',');\n return new RGB(parseInt(aColor[0], 10), parseInt(aColor[1], 10), parseInt(aColor[2], 10), parseFloat(aColor[3]));\n }\n\n // case4: hsl\n if (/^(hsl|HSL|hsla|HSLA)/.test(formatValue)) {\n const aColor = formatValue.replace(/(?:\\(|\\)|hsla|HSLA|hsl|HSL)*/g, '').split(',');\n const rgb = hslToRgb(parseInt(aColor[0], 10), parseInt(aColor[1], 10), parseInt(aColor[2], 10));\n\n return new RGB(rgb.r, rgb.g, rgb.b, parseFloat(aColor[3]));\n }\n\n return;\n }\n\n constructor(value: string) {\n const color = Color.parseColorString(value);\n\n // case0: transparent\n if (color) {\n this.color = color;\n } else {\n // default: 白色\n console.warn(`Warn: 传入${value}无法解析为Color`);\n this.color = new RGB(255, 255, 255);\n }\n }\n toRGBA() {\n return this.color.formatRgb();\n }\n toString() {\n return this.color.formatRgb();\n }\n toHex() {\n return this.color.formatHex();\n }\n toHsl() {\n return this.color.formatHsl();\n }\n\n brighter(k: number) {\n const { r, g, b } = this.color;\n this.color.r = Math.max(0, Math.min(255, Math.floor(r * k)));\n this.color.g = Math.max(0, Math.min(255, Math.floor(g * k)));\n this.color.b = Math.max(0, Math.min(255, Math.floor(b * k)));\n return this;\n }\n\n add(color: Color) {\n const { r, g, b } = this.color;\n this.color.r += Math.min(255, r + color.color.r);\n this.color.g += Math.min(255, g + color.color.g);\n this.color.b += Math.min(255, b + color.color.b);\n return this;\n }\n\n sub(color: Color) {\n this.color.r = Math.max(0, this.color.r - color.color.r);\n this.color.g = Math.max(0, this.color.g - color.color.g);\n this.color.b = Math.max(0, this.color.b - color.color.b);\n return this;\n }\n\n multiply(color: Color) {\n const { r, g, b } = this.color;\n this.color.r = Math.max(0, Math.min(255, Math.floor(r * color.color.r)));\n this.color.g = Math.max(0, Math.min(255, Math.floor(g * color.color.g)));\n this.color.b = Math.max(0, Math.min(255, Math.floor(b * color.color.b)));\n return this;\n }\n\n // todo: 这里亮度计算都没考虑alpha通道\n getHSVBrightness() {\n return Math.max(this.color.r, this.color.g, this.color.b) / 255;\n }\n\n getHSLBrightness() {\n return (\n (Math.max(this.color.r, this.color.g, this.color.b) / 255 +\n Math.min(this.color.r, this.color.g, this.color.b) / 255) *\n 0.5\n );\n }\n\n setHsl(h?: number | null | undefined, s?: number | null | undefined, l?: number | null | undefined) {\n const opacity = this.color.opacity;\n const hsl = rgbToHsl(this.color.r, this.color.g, this.color.b);\n\n const rgb = hslToRgb(\n isNil(h) ? hsl.h : clamp(h as number, 0, 360),\n isNil(s) ? hsl.s : s >= 0 && s <= 1 ? s * 100 : s,\n isNil(l) ? hsl.l : l <= 1 && l >= 0 ? l * 100 : l\n );\n this.color = new RGB(rgb.r, rgb.g, rgb.b, opacity);\n\n return this;\n }\n\n setRGB(r: number, g: number, b: number) {\n !isNil(r) && (this.color.r = r);\n !isNil(g) && (this.color.g = g);\n !isNil(b) && (this.color.b = b);\n\n return this;\n }\n\n setHex(value: string) {\n const formatValue = `${value}`.trim().toLowerCase();\n const isHex = REG_HEX.exec(formatValue);\n\n const hex = parseInt(isHex[1], 16);\n const hexLength = isHex[1].length;\n // #fff\n if (hexLength === 3) {\n return new RGB(\n ((hex >> 8) & 0xf) + (((hex >> 8) & 0xf) << 4),\n ((hex >> 4) & 0xf) + (((hex >> 4) & 0xf) << 4),\n (hex & 0xf) + ((hex & 0xf) << 4),\n 1\n );\n }\n // #ffffff\n if (hexLength === 6) {\n return rgb(hex);\n }\n // #ffffffaa\n else if (hexLength === 8) {\n return new RGB((hex >> 24) & 0xff, (hex >> 16) & 0xff, (hex >> 8) & 0xff, (hex & 0xff) / 0xff);\n }\n return this;\n }\n\n setColorName(name: string) {\n // color keywords\n const hex = DEFAULT_COLORS[name.toLowerCase()];\n\n if (typeof hex !== 'undefined') {\n // red\n this.setHex(hex);\n } else {\n // unknown color\n console.warn('THREE.Color: Unknown color ' + name);\n }\n\n return this;\n }\n\n setScalar(scalar: number) {\n this.color.r = scalar;\n this.color.g = scalar;\n this.color.b = scalar;\n return this;\n }\n\n setOpacity(o = 1) {\n this.color.opacity = o;\n return this;\n }\n\n getLuminance() {\n return (0.2126 * this.color.r + 0.7152 * this.color.g + 0.0722 * this.color.b) / 255;\n }\n\n getLuminance2() {\n return (0.2627 * this.color.r + 0.678 * this.color.g + 0.0593 * this.color.b) / 255;\n }\n\n getLuminance3() {\n return (0.299 * this.color.r + 0.587 * this.color.g + 0.114 * this.color.b) / 255;\n }\n\n clone() {\n return new Color(this.color.toString());\n }\n\n copyGammaToLinear(color: Color, gammaFactor = 2.0) {\n this.color.r = Math.pow(color.color.r, gammaFactor);\n this.color.g = Math.pow(color.color.g, gammaFactor);\n this.color.b = Math.pow(color.color.b, gammaFactor);\n return this;\n }\n\n copyLinearToGamma(color: Color, gammaFactor = 2.0) {\n const safeInverse = gammaFactor > 0 ? 1.0 / gammaFactor : 1.0;\n\n this.color.r = Math.pow(color.color.r, safeInverse);\n this.color.g = Math.pow(color.color.g, safeInverse);\n this.color.b = Math.pow(color.color.b, safeInverse);\n\n return this;\n }\n\n convertGammaToLinear(gammaFactor: number) {\n this.copyGammaToLinear(this, gammaFactor);\n return this;\n }\n\n convertLinearToGamma(gammaFactor: number) {\n this.copyLinearToGamma(this, gammaFactor);\n return this;\n }\n\n copySRGBToLinear(color: Color) {\n this.color.r = SRGBToLinear(color.color.r);\n this.color.g = SRGBToLinear(color.color.g);\n this.color.b = SRGBToLinear(color.color.b);\n return this;\n }\n\n copyLinearToSRGB(color: Color) {\n this.color.r = LinearToSRGB(color.color.r);\n this.color.g = LinearToSRGB(color.color.g);\n this.color.b = LinearToSRGB(color.color.b);\n return this;\n }\n\n convertSRGBToLinear() {\n this.copySRGBToLinear(this);\n return this;\n }\n\n convertLinearToSRGB() {\n this.copyLinearToSRGB(this);\n return this;\n }\n}\n\nexport class RGB {\n r: number;\n g: number;\n b: number;\n opacity: number;\n constructor(r: number, g: number, b: number, opacity?: number) {\n this.r = isNaN(+r) ? 255 : Math.max(0, Math.min(255, +r));\n this.g = isNaN(+g) ? 255 : Math.max(0, Math.min(255, +g));\n this.b = isNaN(+b) ? 255 : Math.max(0, Math.min(255, +b));\n\n if (isValid(opacity)) {\n this.opacity = isNaN(+(opacity as number)) ? 1 : Math.max(0, Math.min(1, +(opacity as number)));\n } else {\n this.opacity = 1;\n }\n }\n // 转为16进制\n formatHex() {\n return `#${hex(this.r) + hex(this.g) + hex(this.b) + (this.opacity === 1 ? '' : hex(this.opacity * 255))}`;\n }\n formatRgb() {\n const opacity = this.opacity;\n return `${opacity === 1 ? 'rgb(' : 'rgba('}${this.r},${this.g},${this.b}${opacity === 1 ? ')' : `,${opacity})`}`;\n }\n\n formatHsl() {\n const opacity = this.opacity;\n const { h, s, l } = rgbToHsl(this.r, this.g, this.b);\n\n return `${opacity === 1 ? 'hsl(' : 'hsla('}${h},${s}%,${l}%${opacity === 1 ? ')' : `,${opacity})`}`;\n }\n // 转为16进制\n toString() {\n return this.formatHex();\n }\n}\n"]}
|
|
@@ -18,5 +18,5 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), __exportStar(require("./textMeasure"), exports), __exportStar(require("./interface"), exports),
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./util"), exports);
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphics/text/measure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB
|
|
1
|
+
{"version":3,"sources":["../src/graphics/text/measure/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,8CAA4B;AAC5B,yCAAuB","file":"index.js","sourcesContent":["export * from './textMeasure';\nexport * from './interface';\nexport * from './util';\n"]}
|
package/cjs/math.d.ts
CHANGED
|
@@ -64,3 +64,6 @@ export declare function crossProductPoint(dir1: {
|
|
|
64
64
|
export declare function fuzzyEqualNumber(a: number, b: number): boolean;
|
|
65
65
|
export declare function fuzzyEqualVec(a: vec2, b: vec2): boolean;
|
|
66
66
|
export declare function fixPrecision(num: number, precision?: number): number;
|
|
67
|
+
export declare function getDecimalPlaces(n: number): number;
|
|
68
|
+
export declare function precisionAdd(a: number, b: number): number;
|
|
69
|
+
export declare function precisionSub(a: number, b: number): number;
|
package/cjs/math.js
CHANGED
|
@@ -42,9 +42,22 @@ function fixPrecision(num, precision = 10) {
|
|
|
42
42
|
return Math.round(num * precision) / precision;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
function getDecimalPlaces(n) {
|
|
46
|
+
const dStr = n.toString().split(/[eE]/), s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
|
|
47
|
+
return s > 0 ? s : 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function precisionAdd(a, b) {
|
|
51
|
+
return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function precisionSub(a, b) {
|
|
55
|
+
return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
Object.defineProperty(exports, "__esModule", {
|
|
46
59
|
value: !0
|
|
47
|
-
}), exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
|
|
60
|
+
}), exports.precisionSub = exports.precisionAdd = exports.getDecimalPlaces = exports.fixPrecision = exports.fuzzyEqualVec = exports.fuzzyEqualNumber = exports.crossProductPoint = exports.crossProduct = exports.lengthFromPointToLine = exports.pointAt = exports.asin = exports.acos = exports.pow = exports.sqrt = exports.sin = exports.min = exports.max = exports.cos = exports.atan2 = exports.abs = exports.pi2 = exports.SUBDIVISION_MAX_ITERATIONS = exports.SUBDIVISION_PRECISION = exports.NEWTON_MIN_SLOPE = exports.NEWTON_ITERATIONS = exports.tau = exports.halfPi = exports.pi = exports.epsilon = void 0,
|
|
48
61
|
exports.epsilon = 1e-12, exports.pi = Math.PI, exports.halfPi = exports.pi / 2,
|
|
49
62
|
exports.tau = 2 * exports.pi, exports.NEWTON_ITERATIONS = 4, exports.NEWTON_MIN_SLOPE = .001,
|
|
50
63
|
exports.SUBDIVISION_PRECISION = 1e-7, exports.SUBDIVISION_MAX_ITERATIONS = 10, exports.pi2 = 2 * Math.PI,
|
|
@@ -53,5 +66,6 @@ exports.min = Math.min, exports.sin = Math.sin, exports.sqrt = Math.sqrt, export
|
|
|
53
66
|
exports.acos = acos, exports.asin = asin, exports.pointAt = pointAt, exports.lengthFromPointToLine = lengthFromPointToLine,
|
|
54
67
|
exports.crossProduct = crossProduct, exports.crossProductPoint = crossProductPoint,
|
|
55
68
|
exports.fuzzyEqualNumber = fuzzyEqualNumber, exports.fuzzyEqualVec = fuzzyEqualVec,
|
|
56
|
-
exports.fixPrecision = fixPrecision
|
|
69
|
+
exports.fixPrecision = fixPrecision, exports.getDecimalPlaces = getDecimalPlaces,
|
|
70
|
+
exports.precisionAdd = precisionAdd, exports.precisionSub = precisionSub;
|
|
57
71
|
//# sourceMappingURL=math.js.map
|
package/cjs/math.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AACb,QAAA,MAAM,GAAG,UAAE,GAAG,CAAC,CAAC;AAChB,QAAA,GAAG,GAAG,CAAC,GAAG,UAAE,CAAC;AACb,QAAA,iBAAiB,GAAG,CAAC,CAAC;AACtB,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAClC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AA2BlB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AACnB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AACjB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAE5B,SAAgB,IAAI,CAAC,CAAS;IAC5B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,C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Pi = pi / 2;\nexport const tau = 2 * pi;\nexport const NEWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/math.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;AACb,QAAA,MAAM,GAAG,UAAE,GAAG,CAAC,CAAC;AAChB,QAAA,GAAG,GAAG,CAAC,GAAG,UAAE,CAAC;AACb,QAAA,iBAAiB,GAAG,CAAC,CAAC;AACtB,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,qBAAqB,GAAG,SAAS,CAAC;AAClC,QAAA,0BAA0B,GAAG,EAAE,CAAC;AAChC,QAAA,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AA2BlB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;AACnB,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AACf,QAAA,GAAG,GAAG,IAAI,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EWTON_ITERATIONS = 4;\nexport const NEWTON_MIN_SLOPE = 0.001;\nexport const SUBDIVISION_PRECISION = 0.0000001;\nexport const SUBDIVISION_MAX_ITERATIONS = 10;\nexport const pi2 = Math.PI * 2;\n\nexport type vec2 = [number, number] | Float32Array;\nexport type vec3 = [number, number, number] | Float32Array;\nexport type vec4 = [number, number, number, number] | Float32Array;\nexport type vec8 = [number, number, number, number, number, number, number, number] | Float32Array;\nexport type mat4 =\n | [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n ]\n | Float32Array;\n\nexport const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\nexport const pow = Math.pow;\n\nexport function acos(x: number) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x: number) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n\n/**\n * 根据比例获直线上的点\n * @param {number} x1 起始点 x\n * @param {number} y1 起始点 y\n * @param {number} x2 结束点 x\n * @param {number} y2 结束点 y\n * @param {number} t 指定比例\n * @return {object} 包含 x, y 的点\n */\nexport function pointAt(\n x1: number | null | undefined,\n y1: number | null | undefined,\n x2: number | null | undefined,\n y2: number | null | undefined,\n t: number\n): {\n x: undefined | number;\n y: undefined | number;\n} {\n let x: number | undefined;\n let y: number | undefined;\n if (typeof x1 === 'number' && typeof x2 === 'number') {\n x = (1 - t) * x1 + t * x2;\n }\n if (typeof y1 === 'number' && typeof y2 === 'number') {\n y = (1 - t) * y1 + t * y2;\n }\n return {\n x,\n y\n };\n}\n\nexport function lengthFromPointToLine(\n point: { x: number; y: number },\n point1: { x: number; y: number },\n point2: { x: number; y: number }\n): number {\n // 面积\n const dir1X = point2.x - point1.x;\n const dir1Y = point2.y - point1.y;\n const dir2X = point.x - point1.x;\n const dir2Y = point.y - point1.y;\n const s = Math.abs(dir1X * dir2Y - dir2X * dir1Y);\n const length = Math.sqrt(dir1X * dir1X + dir1Y * dir1Y);\n return s / length;\n}\n\nexport function crossProduct(dir1: vec2, dir2: vec2): number {\n return dir1[0] * dir2[1] - dir1[1] * dir2[0];\n}\n\nexport function crossProductPoint(dir1: { x: number; y: number }, dir2: { x: number; y: number }): number {\n return dir1.x * dir2.y - dir1.y * dir2.x;\n}\n\nexport function fuzzyEqualNumber(a: number, b: number): boolean {\n return abs(a - b) < epsilon;\n}\n\nexport function fuzzyEqualVec(a: vec2, b: vec2): boolean {\n return abs(a[0] - b[0]) + abs(a[1] - b[1]) < epsilon;\n}\n\nexport function fixPrecision(num: number, precision = 10) {\n return Math.round(num * precision) / precision;\n}\n\nexport function getDecimalPlaces(n: number): number {\n const dStr = n.toString().split(/[eE]/);\n const s = (dStr[0].split('.')[1] || '').length - (+dStr[1] || 0);\n return s > 0 ? s : 0;\n}\n\nexport function precisionAdd(a: number, b: number) {\n return fixPrecision(a + b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n\nexport function precisionSub(a: number, b: number) {\n return fixPrecision(a - b, 10 ** Math.max(getDecimalPlaces(a), getDecimalPlaces(b)));\n}\n"]}
|