@antv/g-lite 2.2.15 → 2.2.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +417 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +417 -32
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +4 -4
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/types/services/TextService.d.ts.map +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g-lite
|
|
3
3
|
* @description A core module for rendering engine implements DOM API.
|
|
4
|
-
* @version 2.2.
|
|
5
|
-
* @date 1/
|
|
4
|
+
* @version 2.2.16
|
|
5
|
+
* @date 1/23/2025, 8:31:51 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -21,32 +21,12 @@ require('@babel/runtime/helpers/readOnlyError');
|
|
|
21
21
|
var util = require('@antv/util');
|
|
22
22
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
23
23
|
var _superPropGet = require('@babel/runtime/helpers/superPropGet');
|
|
24
|
-
var d3 = require('d3-color');
|
|
25
24
|
var gMath = require('@antv/g-math');
|
|
26
25
|
var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
|
|
27
26
|
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
28
27
|
var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
|
|
29
28
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
30
29
|
|
|
31
|
-
function _interopNamespaceDefault(e) {
|
|
32
|
-
var n = Object.create(null);
|
|
33
|
-
if (e) {
|
|
34
|
-
Object.keys(e).forEach(function (k) {
|
|
35
|
-
if (k !== 'default') {
|
|
36
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
37
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return e[k]; }
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
n.default = e;
|
|
45
|
-
return Object.freeze(n);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var d3__namespace = /*#__PURE__*/_interopNamespaceDefault(d3);
|
|
49
|
-
|
|
50
30
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
51
31
|
|
|
52
32
|
var rbush = {exports: {}};
|
|
@@ -2573,6 +2553,412 @@ var PropertySyntax = /*#__PURE__*/function (PropertySyntax) {
|
|
|
2573
2553
|
return PropertySyntax;
|
|
2574
2554
|
}({});
|
|
2575
2555
|
|
|
2556
|
+
function define(constructor, factory, prototype) {
|
|
2557
|
+
constructor.prototype = factory.prototype = prototype;
|
|
2558
|
+
prototype.constructor = constructor;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
function extend(parent, definition) {
|
|
2562
|
+
var prototype = Object.create(parent.prototype);
|
|
2563
|
+
for (var key in definition) prototype[key] = definition[key];
|
|
2564
|
+
return prototype;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
function Color() {}
|
|
2568
|
+
|
|
2569
|
+
var darker = 0.7;
|
|
2570
|
+
var brighter = 1 / darker;
|
|
2571
|
+
|
|
2572
|
+
var reI = "\\s*([+-]?\\d+)\\s*",
|
|
2573
|
+
reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
|
|
2574
|
+
reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
|
|
2575
|
+
reHex = /^#([0-9a-f]{3,8})$/,
|
|
2576
|
+
reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
|
|
2577
|
+
reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
|
|
2578
|
+
reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
|
|
2579
|
+
reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
|
|
2580
|
+
reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
|
|
2581
|
+
reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
|
|
2582
|
+
|
|
2583
|
+
var named = {
|
|
2584
|
+
aliceblue: 0xf0f8ff,
|
|
2585
|
+
antiquewhite: 0xfaebd7,
|
|
2586
|
+
aqua: 0x00ffff,
|
|
2587
|
+
aquamarine: 0x7fffd4,
|
|
2588
|
+
azure: 0xf0ffff,
|
|
2589
|
+
beige: 0xf5f5dc,
|
|
2590
|
+
bisque: 0xffe4c4,
|
|
2591
|
+
black: 0x000000,
|
|
2592
|
+
blanchedalmond: 0xffebcd,
|
|
2593
|
+
blue: 0x0000ff,
|
|
2594
|
+
blueviolet: 0x8a2be2,
|
|
2595
|
+
brown: 0xa52a2a,
|
|
2596
|
+
burlywood: 0xdeb887,
|
|
2597
|
+
cadetblue: 0x5f9ea0,
|
|
2598
|
+
chartreuse: 0x7fff00,
|
|
2599
|
+
chocolate: 0xd2691e,
|
|
2600
|
+
coral: 0xff7f50,
|
|
2601
|
+
cornflowerblue: 0x6495ed,
|
|
2602
|
+
cornsilk: 0xfff8dc,
|
|
2603
|
+
crimson: 0xdc143c,
|
|
2604
|
+
cyan: 0x00ffff,
|
|
2605
|
+
darkblue: 0x00008b,
|
|
2606
|
+
darkcyan: 0x008b8b,
|
|
2607
|
+
darkgoldenrod: 0xb8860b,
|
|
2608
|
+
darkgray: 0xa9a9a9,
|
|
2609
|
+
darkgreen: 0x006400,
|
|
2610
|
+
darkgrey: 0xa9a9a9,
|
|
2611
|
+
darkkhaki: 0xbdb76b,
|
|
2612
|
+
darkmagenta: 0x8b008b,
|
|
2613
|
+
darkolivegreen: 0x556b2f,
|
|
2614
|
+
darkorange: 0xff8c00,
|
|
2615
|
+
darkorchid: 0x9932cc,
|
|
2616
|
+
darkred: 0x8b0000,
|
|
2617
|
+
darksalmon: 0xe9967a,
|
|
2618
|
+
darkseagreen: 0x8fbc8f,
|
|
2619
|
+
darkslateblue: 0x483d8b,
|
|
2620
|
+
darkslategray: 0x2f4f4f,
|
|
2621
|
+
darkslategrey: 0x2f4f4f,
|
|
2622
|
+
darkturquoise: 0x00ced1,
|
|
2623
|
+
darkviolet: 0x9400d3,
|
|
2624
|
+
deeppink: 0xff1493,
|
|
2625
|
+
deepskyblue: 0x00bfff,
|
|
2626
|
+
dimgray: 0x696969,
|
|
2627
|
+
dimgrey: 0x696969,
|
|
2628
|
+
dodgerblue: 0x1e90ff,
|
|
2629
|
+
firebrick: 0xb22222,
|
|
2630
|
+
floralwhite: 0xfffaf0,
|
|
2631
|
+
forestgreen: 0x228b22,
|
|
2632
|
+
fuchsia: 0xff00ff,
|
|
2633
|
+
gainsboro: 0xdcdcdc,
|
|
2634
|
+
ghostwhite: 0xf8f8ff,
|
|
2635
|
+
gold: 0xffd700,
|
|
2636
|
+
goldenrod: 0xdaa520,
|
|
2637
|
+
gray: 0x808080,
|
|
2638
|
+
green: 0x008000,
|
|
2639
|
+
greenyellow: 0xadff2f,
|
|
2640
|
+
grey: 0x808080,
|
|
2641
|
+
honeydew: 0xf0fff0,
|
|
2642
|
+
hotpink: 0xff69b4,
|
|
2643
|
+
indianred: 0xcd5c5c,
|
|
2644
|
+
indigo: 0x4b0082,
|
|
2645
|
+
ivory: 0xfffff0,
|
|
2646
|
+
khaki: 0xf0e68c,
|
|
2647
|
+
lavender: 0xe6e6fa,
|
|
2648
|
+
lavenderblush: 0xfff0f5,
|
|
2649
|
+
lawngreen: 0x7cfc00,
|
|
2650
|
+
lemonchiffon: 0xfffacd,
|
|
2651
|
+
lightblue: 0xadd8e6,
|
|
2652
|
+
lightcoral: 0xf08080,
|
|
2653
|
+
lightcyan: 0xe0ffff,
|
|
2654
|
+
lightgoldenrodyellow: 0xfafad2,
|
|
2655
|
+
lightgray: 0xd3d3d3,
|
|
2656
|
+
lightgreen: 0x90ee90,
|
|
2657
|
+
lightgrey: 0xd3d3d3,
|
|
2658
|
+
lightpink: 0xffb6c1,
|
|
2659
|
+
lightsalmon: 0xffa07a,
|
|
2660
|
+
lightseagreen: 0x20b2aa,
|
|
2661
|
+
lightskyblue: 0x87cefa,
|
|
2662
|
+
lightslategray: 0x778899,
|
|
2663
|
+
lightslategrey: 0x778899,
|
|
2664
|
+
lightsteelblue: 0xb0c4de,
|
|
2665
|
+
lightyellow: 0xffffe0,
|
|
2666
|
+
lime: 0x00ff00,
|
|
2667
|
+
limegreen: 0x32cd32,
|
|
2668
|
+
linen: 0xfaf0e6,
|
|
2669
|
+
magenta: 0xff00ff,
|
|
2670
|
+
maroon: 0x800000,
|
|
2671
|
+
mediumaquamarine: 0x66cdaa,
|
|
2672
|
+
mediumblue: 0x0000cd,
|
|
2673
|
+
mediumorchid: 0xba55d3,
|
|
2674
|
+
mediumpurple: 0x9370db,
|
|
2675
|
+
mediumseagreen: 0x3cb371,
|
|
2676
|
+
mediumslateblue: 0x7b68ee,
|
|
2677
|
+
mediumspringgreen: 0x00fa9a,
|
|
2678
|
+
mediumturquoise: 0x48d1cc,
|
|
2679
|
+
mediumvioletred: 0xc71585,
|
|
2680
|
+
midnightblue: 0x191970,
|
|
2681
|
+
mintcream: 0xf5fffa,
|
|
2682
|
+
mistyrose: 0xffe4e1,
|
|
2683
|
+
moccasin: 0xffe4b5,
|
|
2684
|
+
navajowhite: 0xffdead,
|
|
2685
|
+
navy: 0x000080,
|
|
2686
|
+
oldlace: 0xfdf5e6,
|
|
2687
|
+
olive: 0x808000,
|
|
2688
|
+
olivedrab: 0x6b8e23,
|
|
2689
|
+
orange: 0xffa500,
|
|
2690
|
+
orangered: 0xff4500,
|
|
2691
|
+
orchid: 0xda70d6,
|
|
2692
|
+
palegoldenrod: 0xeee8aa,
|
|
2693
|
+
palegreen: 0x98fb98,
|
|
2694
|
+
paleturquoise: 0xafeeee,
|
|
2695
|
+
palevioletred: 0xdb7093,
|
|
2696
|
+
papayawhip: 0xffefd5,
|
|
2697
|
+
peachpuff: 0xffdab9,
|
|
2698
|
+
peru: 0xcd853f,
|
|
2699
|
+
pink: 0xffc0cb,
|
|
2700
|
+
plum: 0xdda0dd,
|
|
2701
|
+
powderblue: 0xb0e0e6,
|
|
2702
|
+
purple: 0x800080,
|
|
2703
|
+
rebeccapurple: 0x663399,
|
|
2704
|
+
red: 0xff0000,
|
|
2705
|
+
rosybrown: 0xbc8f8f,
|
|
2706
|
+
royalblue: 0x4169e1,
|
|
2707
|
+
saddlebrown: 0x8b4513,
|
|
2708
|
+
salmon: 0xfa8072,
|
|
2709
|
+
sandybrown: 0xf4a460,
|
|
2710
|
+
seagreen: 0x2e8b57,
|
|
2711
|
+
seashell: 0xfff5ee,
|
|
2712
|
+
sienna: 0xa0522d,
|
|
2713
|
+
silver: 0xc0c0c0,
|
|
2714
|
+
skyblue: 0x87ceeb,
|
|
2715
|
+
slateblue: 0x6a5acd,
|
|
2716
|
+
slategray: 0x708090,
|
|
2717
|
+
slategrey: 0x708090,
|
|
2718
|
+
snow: 0xfffafa,
|
|
2719
|
+
springgreen: 0x00ff7f,
|
|
2720
|
+
steelblue: 0x4682b4,
|
|
2721
|
+
tan: 0xd2b48c,
|
|
2722
|
+
teal: 0x008080,
|
|
2723
|
+
thistle: 0xd8bfd8,
|
|
2724
|
+
tomato: 0xff6347,
|
|
2725
|
+
turquoise: 0x40e0d0,
|
|
2726
|
+
violet: 0xee82ee,
|
|
2727
|
+
wheat: 0xf5deb3,
|
|
2728
|
+
white: 0xffffff,
|
|
2729
|
+
whitesmoke: 0xf5f5f5,
|
|
2730
|
+
yellow: 0xffff00,
|
|
2731
|
+
yellowgreen: 0x9acd32
|
|
2732
|
+
};
|
|
2733
|
+
|
|
2734
|
+
define(Color, color, {
|
|
2735
|
+
copy(channels) {
|
|
2736
|
+
return Object.assign(new this.constructor, this, channels);
|
|
2737
|
+
},
|
|
2738
|
+
displayable() {
|
|
2739
|
+
return this.rgb().displayable();
|
|
2740
|
+
},
|
|
2741
|
+
hex: color_formatHex, // Deprecated! Use color.formatHex.
|
|
2742
|
+
formatHex: color_formatHex,
|
|
2743
|
+
formatHex8: color_formatHex8,
|
|
2744
|
+
formatHsl: color_formatHsl,
|
|
2745
|
+
formatRgb: color_formatRgb,
|
|
2746
|
+
toString: color_formatRgb
|
|
2747
|
+
});
|
|
2748
|
+
|
|
2749
|
+
function color_formatHex() {
|
|
2750
|
+
return this.rgb().formatHex();
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
function color_formatHex8() {
|
|
2754
|
+
return this.rgb().formatHex8();
|
|
2755
|
+
}
|
|
2756
|
+
|
|
2757
|
+
function color_formatHsl() {
|
|
2758
|
+
return hslConvert(this).formatHsl();
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
function color_formatRgb() {
|
|
2762
|
+
return this.rgb().formatRgb();
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
function color(format) {
|
|
2766
|
+
var m, l;
|
|
2767
|
+
format = (format + "").trim().toLowerCase();
|
|
2768
|
+
return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
|
|
2769
|
+
: l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
|
|
2770
|
+
: l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
|
|
2771
|
+
: l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
|
|
2772
|
+
: null) // invalid hex
|
|
2773
|
+
: (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
|
|
2774
|
+
: (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
|
|
2775
|
+
: (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
|
|
2776
|
+
: (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
|
|
2777
|
+
: (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
|
|
2778
|
+
: (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
|
|
2779
|
+
: named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
|
|
2780
|
+
: format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
|
|
2781
|
+
: null;
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
function rgbn(n) {
|
|
2785
|
+
return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
function rgba(r, g, b, a) {
|
|
2789
|
+
if (a <= 0) r = g = b = NaN;
|
|
2790
|
+
return new Rgb(r, g, b, a);
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
function rgbConvert(o) {
|
|
2794
|
+
if (!(o instanceof Color)) o = color(o);
|
|
2795
|
+
if (!o) return new Rgb;
|
|
2796
|
+
o = o.rgb();
|
|
2797
|
+
return new Rgb(o.r, o.g, o.b, o.opacity);
|
|
2798
|
+
}
|
|
2799
|
+
|
|
2800
|
+
function rgb(r, g, b, opacity) {
|
|
2801
|
+
return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
function Rgb(r, g, b, opacity) {
|
|
2805
|
+
this.r = +r;
|
|
2806
|
+
this.g = +g;
|
|
2807
|
+
this.b = +b;
|
|
2808
|
+
this.opacity = +opacity;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
define(Rgb, rgb, extend(Color, {
|
|
2812
|
+
brighter(k) {
|
|
2813
|
+
k = k == null ? brighter : Math.pow(brighter, k);
|
|
2814
|
+
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
2815
|
+
},
|
|
2816
|
+
darker(k) {
|
|
2817
|
+
k = k == null ? darker : Math.pow(darker, k);
|
|
2818
|
+
return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
|
|
2819
|
+
},
|
|
2820
|
+
rgb() {
|
|
2821
|
+
return this;
|
|
2822
|
+
},
|
|
2823
|
+
clamp() {
|
|
2824
|
+
return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
|
|
2825
|
+
},
|
|
2826
|
+
displayable() {
|
|
2827
|
+
return (-0.5 <= this.r && this.r < 255.5)
|
|
2828
|
+
&& (-0.5 <= this.g && this.g < 255.5)
|
|
2829
|
+
&& (-0.5 <= this.b && this.b < 255.5)
|
|
2830
|
+
&& (0 <= this.opacity && this.opacity <= 1);
|
|
2831
|
+
},
|
|
2832
|
+
hex: rgb_formatHex, // Deprecated! Use color.formatHex.
|
|
2833
|
+
formatHex: rgb_formatHex,
|
|
2834
|
+
formatHex8: rgb_formatHex8,
|
|
2835
|
+
formatRgb: rgb_formatRgb,
|
|
2836
|
+
toString: rgb_formatRgb
|
|
2837
|
+
}));
|
|
2838
|
+
|
|
2839
|
+
function rgb_formatHex() {
|
|
2840
|
+
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2843
|
+
function rgb_formatHex8() {
|
|
2844
|
+
return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
|
|
2845
|
+
}
|
|
2846
|
+
|
|
2847
|
+
function rgb_formatRgb() {
|
|
2848
|
+
const a = clampa(this.opacity);
|
|
2849
|
+
return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
function clampa(opacity) {
|
|
2853
|
+
return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
function clampi(value) {
|
|
2857
|
+
return Math.max(0, Math.min(255, Math.round(value) || 0));
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
function hex(value) {
|
|
2861
|
+
value = clampi(value);
|
|
2862
|
+
return (value < 16 ? "0" : "") + value.toString(16);
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
function hsla(h, s, l, a) {
|
|
2866
|
+
if (a <= 0) h = s = l = NaN;
|
|
2867
|
+
else if (l <= 0 || l >= 1) h = s = NaN;
|
|
2868
|
+
else if (s <= 0) h = NaN;
|
|
2869
|
+
return new Hsl(h, s, l, a);
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
function hslConvert(o) {
|
|
2873
|
+
if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
|
|
2874
|
+
if (!(o instanceof Color)) o = color(o);
|
|
2875
|
+
if (!o) return new Hsl;
|
|
2876
|
+
if (o instanceof Hsl) return o;
|
|
2877
|
+
o = o.rgb();
|
|
2878
|
+
var r = o.r / 255,
|
|
2879
|
+
g = o.g / 255,
|
|
2880
|
+
b = o.b / 255,
|
|
2881
|
+
min = Math.min(r, g, b),
|
|
2882
|
+
max = Math.max(r, g, b),
|
|
2883
|
+
h = NaN,
|
|
2884
|
+
s = max - min,
|
|
2885
|
+
l = (max + min) / 2;
|
|
2886
|
+
if (s) {
|
|
2887
|
+
if (r === max) h = (g - b) / s + (g < b) * 6;
|
|
2888
|
+
else if (g === max) h = (b - r) / s + 2;
|
|
2889
|
+
else h = (r - g) / s + 4;
|
|
2890
|
+
s /= l < 0.5 ? max + min : 2 - max - min;
|
|
2891
|
+
h *= 60;
|
|
2892
|
+
} else {
|
|
2893
|
+
s = l > 0 && l < 1 ? 0 : h;
|
|
2894
|
+
}
|
|
2895
|
+
return new Hsl(h, s, l, o.opacity);
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
function hsl(h, s, l, opacity) {
|
|
2899
|
+
return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
function Hsl(h, s, l, opacity) {
|
|
2903
|
+
this.h = +h;
|
|
2904
|
+
this.s = +s;
|
|
2905
|
+
this.l = +l;
|
|
2906
|
+
this.opacity = +opacity;
|
|
2907
|
+
}
|
|
2908
|
+
|
|
2909
|
+
define(Hsl, hsl, extend(Color, {
|
|
2910
|
+
brighter(k) {
|
|
2911
|
+
k = k == null ? brighter : Math.pow(brighter, k);
|
|
2912
|
+
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
2913
|
+
},
|
|
2914
|
+
darker(k) {
|
|
2915
|
+
k = k == null ? darker : Math.pow(darker, k);
|
|
2916
|
+
return new Hsl(this.h, this.s, this.l * k, this.opacity);
|
|
2917
|
+
},
|
|
2918
|
+
rgb() {
|
|
2919
|
+
var h = this.h % 360 + (this.h < 0) * 360,
|
|
2920
|
+
s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
|
|
2921
|
+
l = this.l,
|
|
2922
|
+
m2 = l + (l < 0.5 ? l : 1 - l) * s,
|
|
2923
|
+
m1 = 2 * l - m2;
|
|
2924
|
+
return new Rgb(
|
|
2925
|
+
hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
|
|
2926
|
+
hsl2rgb(h, m1, m2),
|
|
2927
|
+
hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
|
|
2928
|
+
this.opacity
|
|
2929
|
+
);
|
|
2930
|
+
},
|
|
2931
|
+
clamp() {
|
|
2932
|
+
return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
|
|
2933
|
+
},
|
|
2934
|
+
displayable() {
|
|
2935
|
+
return (0 <= this.s && this.s <= 1 || isNaN(this.s))
|
|
2936
|
+
&& (0 <= this.l && this.l <= 1)
|
|
2937
|
+
&& (0 <= this.opacity && this.opacity <= 1);
|
|
2938
|
+
},
|
|
2939
|
+
formatHsl() {
|
|
2940
|
+
const a = clampa(this.opacity);
|
|
2941
|
+
return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
|
|
2942
|
+
}
|
|
2943
|
+
}));
|
|
2944
|
+
|
|
2945
|
+
function clamph(value) {
|
|
2946
|
+
value = (value || 0) % 360;
|
|
2947
|
+
return value < 0 ? value + 360 : value;
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
function clampt(value) {
|
|
2951
|
+
return Math.max(0, Math.min(1, value || 0));
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
/* From FvD 13.37, CSS Color Module Level 3 */
|
|
2955
|
+
function hsl2rgb(h, m1, m2) {
|
|
2956
|
+
return (h < 60 ? m1 + (m2 - m1) * h / 60
|
|
2957
|
+
: h < 180 ? m2
|
|
2958
|
+
: h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
|
|
2959
|
+
: m1) * 255;
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2576
2962
|
function memoize(func, resolver) {
|
|
2577
2963
|
if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
|
|
2578
2964
|
throw new TypeError('Expected a function');
|
|
@@ -4183,13 +4569,13 @@ var parseColor = memoize(function (colorStr) {
|
|
|
4183
4569
|
}
|
|
4184
4570
|
|
|
4185
4571
|
// constants
|
|
4186
|
-
var color =
|
|
4572
|
+
var color$1 = color(colorStr);
|
|
4187
4573
|
var rgba = [0, 0, 0, 0];
|
|
4188
|
-
if (color !== null) {
|
|
4189
|
-
rgba[0] = color.r || 0;
|
|
4190
|
-
rgba[1] = color.g || 0;
|
|
4191
|
-
rgba[2] = color.b || 0;
|
|
4192
|
-
rgba[3] = color.opacity;
|
|
4574
|
+
if (color$1 !== null) {
|
|
4575
|
+
rgba[0] = color$1.r || 0;
|
|
4576
|
+
rgba[1] = color$1.g || 0;
|
|
4577
|
+
rgba[2] = color$1.b || 0;
|
|
4578
|
+
rgba[3] = color$1.opacity;
|
|
4193
4579
|
}
|
|
4194
4580
|
|
|
4195
4581
|
// return new CSSRGB(...rgba);
|
|
@@ -11742,7 +12128,7 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11742
12128
|
}
|
|
11743
12129
|
if (!this.canBreakInLastChar(_char2)) {
|
|
11744
12130
|
lines = this.trimToBreakable(lines);
|
|
11745
|
-
currentLineWidth = this.sumTextWidthByCache(lines[currentLineIndex] || '',
|
|
12131
|
+
currentLineWidth = this.sumTextWidthByCache(lines[currentLineIndex] || '', calcWidth);
|
|
11746
12132
|
}
|
|
11747
12133
|
if (this.shouldBreakByKinsokuShorui(_char2, nextChar)) {
|
|
11748
12134
|
lines = this.trimByKinsokuShorui(lines);
|
|
@@ -11793,10 +12179,9 @@ var TextService = /*#__PURE__*/function () {
|
|
|
11793
12179
|
}
|
|
11794
12180
|
}, {
|
|
11795
12181
|
key: "sumTextWidthByCache",
|
|
11796
|
-
value: function sumTextWidthByCache(text,
|
|
12182
|
+
value: function sumTextWidthByCache(text, calcWidthWithCache) {
|
|
11797
12183
|
return text.split('').reduce(function (sum, c) {
|
|
11798
|
-
|
|
11799
|
-
return sum + cache[c];
|
|
12184
|
+
return sum + calcWidthWithCache(c);
|
|
11800
12185
|
}, 0);
|
|
11801
12186
|
}
|
|
11802
12187
|
}, {
|