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