@visactor/vrender-components 0.21.0-alpha.11 → 0.21.0-alpha.13
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/axis/type.d.ts +2 -2
- package/cjs/axis/type.js.map +1 -1
- package/cjs/brush/brush.js +1 -2
- package/cjs/brush/type.js +2 -1
- package/cjs/data-zoom/type.d.ts +1 -1
- package/cjs/data-zoom/type.js.map +1 -1
- package/cjs/gif/gif.d.ts +29 -0
- package/cjs/gif/gif.js +59 -0
- package/cjs/gif/gif.js.map +1 -0
- package/cjs/gif/index.d.ts +1 -0
- package/cjs/gif/index.js +21 -0
- package/cjs/gif/index.js.map +1 -0
- package/cjs/index.d.ts +2 -1
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/interface.js.map +1 -1
- package/cjs/jsx/component-type.js +1 -2
- package/cjs/label/arc.js +3 -2
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.js +7 -12
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +1 -6
- package/cjs/label/overlap/place.js +4 -4
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/shiftY.d.ts +1 -2
- package/cjs/label/overlap/shiftY.js +18 -72
- package/cjs/label/overlap/shiftY.js.map +1 -1
- package/cjs/label/polygon.js +1 -1
- package/cjs/label/rect.js +1 -1
- package/cjs/legend/color/type.d.ts +2 -2
- package/cjs/legend/color/type.js.map +1 -1
- package/cjs/legend/discrete/type.d.ts +1 -1
- package/cjs/legend/discrete/type.js.map +1 -1
- package/cjs/marker/type.d.ts +2 -2
- package/cjs/marker/type.js.map +1 -1
- package/cjs/player/type/discrete-player.d.ts +3 -3
- package/cjs/player/type/discrete-player.js.map +1 -1
- package/cjs/player/type/index.d.ts +2 -2
- package/cjs/player/type/index.js.map +1 -1
- package/cjs/scrollbar/index.d.ts +0 -1
- package/cjs/scrollbar/index.js +1 -2
- package/cjs/scrollbar/index.js.map +1 -1
- package/cjs/scrollbar/scrollbar-plugin.d.ts +15 -18
- package/cjs/scrollbar/scrollbar-plugin.js +97 -109
- package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
- package/cjs/timeline/type.js.map +1 -1
- package/dist/index.es.js +1268 -964
- package/es/axis/type.d.ts +2 -2
- package/es/axis/type.js.map +1 -1
- package/es/brush/brush.js +1 -2
- package/es/brush/type.js +2 -1
- package/es/data-zoom/type.d.ts +1 -1
- package/es/data-zoom/type.js.map +1 -1
- package/es/gif/gif.d.ts +29 -0
- package/es/gif/gif.js +55 -0
- package/es/gif/gif.js.map +1 -0
- package/es/gif/index.d.ts +1 -0
- package/es/gif/index.js +2 -0
- package/es/gif/index.js.map +1 -0
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -1
- package/es/index.js.map +1 -1
- package/es/interface.js.map +1 -1
- package/es/jsx/component-type.js +1 -2
- package/es/label/arc.js +3 -2
- package/es/label/arc.js.map +1 -1
- package/es/label/base.js +7 -12
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +1 -6
- package/es/label/overlap/place.js +4 -4
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/shiftY.d.ts +1 -2
- package/es/label/overlap/shiftY.js +15 -68
- package/es/label/overlap/shiftY.js.map +1 -1
- package/es/label/polygon.js +1 -1
- package/es/label/rect.js +1 -1
- package/es/legend/color/type.d.ts +2 -2
- package/es/legend/color/type.js.map +1 -1
- package/es/legend/discrete/type.d.ts +1 -1
- package/es/legend/discrete/type.js.map +1 -1
- package/es/marker/type.d.ts +2 -2
- package/es/marker/type.js.map +1 -1
- package/es/player/type/discrete-player.d.ts +3 -3
- package/es/player/type/discrete-player.js.map +1 -1
- package/es/player/type/index.d.ts +2 -2
- package/es/player/type/index.js.map +1 -1
- package/es/scrollbar/index.d.ts +0 -1
- package/es/scrollbar/index.js +0 -2
- package/es/scrollbar/index.js.map +1 -1
- package/es/scrollbar/scrollbar-plugin.d.ts +15 -18
- package/es/scrollbar/scrollbar-plugin.js +94 -111
- package/es/scrollbar/scrollbar-plugin.js.map +1 -1
- package/es/timeline/type.js.map +1 -1
- package/package.json +9 -9
package/dist/index.es.js
CHANGED
|
@@ -592,6 +592,12 @@ let DefaultGlobal = class {
|
|
|
592
592
|
get env() {
|
|
593
593
|
return this._env;
|
|
594
594
|
}
|
|
595
|
+
get isImageAnonymous() {
|
|
596
|
+
return this._isImageAnonymous;
|
|
597
|
+
}
|
|
598
|
+
set isImageAnonymous(isImageAnonymous) {
|
|
599
|
+
this._isImageAnonymous = isImageAnonymous;
|
|
600
|
+
}
|
|
595
601
|
get devicePixelRatio() {
|
|
596
602
|
return this._env || this.setEnv("browser"), this.envContribution.getDevicePixelRatio();
|
|
597
603
|
}
|
|
@@ -626,7 +632,7 @@ let DefaultGlobal = class {
|
|
|
626
632
|
this._env || this.setEnv("browser"), this.envContribution.applyStyles = support;
|
|
627
633
|
}
|
|
628
634
|
constructor(contributions) {
|
|
629
|
-
this.contributions = contributions, this.id = Generator.GenAutoIncrementId(), this.hooks = {
|
|
635
|
+
this.contributions = contributions, this._isImageAnonymous = !0, this.id = Generator.GenAutoIncrementId(), this.hooks = {
|
|
630
636
|
onSetEnv: new SyncHook(["lastEnv", "env", "global"])
|
|
631
637
|
}, this.measureTextMethod = "native", this.optimizeVisible = !1;
|
|
632
638
|
}
|
|
@@ -745,11 +751,6 @@ let DefaultGlobal = class {
|
|
|
745
751
|
};
|
|
746
752
|
DefaultGlobal = __decorate$P([injectable(), __param$z(0, inject(ContributionProvider)), __param$z(0, named(EnvContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGlobal);
|
|
747
753
|
|
|
748
|
-
var MeasureModeEnum;
|
|
749
|
-
!function (MeasureModeEnum) {
|
|
750
|
-
MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
|
|
751
|
-
}(MeasureModeEnum || (MeasureModeEnum = {}));
|
|
752
|
-
|
|
753
754
|
const circleThreshold = tau - 1e-8;
|
|
754
755
|
class BoundsContext {
|
|
755
756
|
constructor(bounds) {
|
|
@@ -2014,7 +2015,6 @@ const DefaultStrokeStyle = Object.assign({
|
|
|
2014
2015
|
const DefaultTextStyle = {
|
|
2015
2016
|
text: "",
|
|
2016
2017
|
maxLineWidth: 1 / 0,
|
|
2017
|
-
maxWidth: 1 / 0,
|
|
2018
2018
|
textAlign: "left",
|
|
2019
2019
|
textBaseline: "alphabetic",
|
|
2020
2020
|
fontSize: 16,
|
|
@@ -2038,9 +2038,7 @@ const DefaultTextStyle = {
|
|
|
2038
2038
|
suffixPosition: "end",
|
|
2039
2039
|
underlineDash: [],
|
|
2040
2040
|
underlineOffset: 0,
|
|
2041
|
-
disableAutoClipedPoptip: void 0
|
|
2042
|
-
measureMode: MeasureModeEnum.fontBounding,
|
|
2043
|
-
keepCenterInLine: !1
|
|
2041
|
+
disableAutoClipedPoptip: void 0
|
|
2044
2042
|
};
|
|
2045
2043
|
const DefaultPickStyle = {
|
|
2046
2044
|
pickStrokeBuffer: 0
|
|
@@ -2094,8 +2092,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2094
2092
|
globalZIndex: 1,
|
|
2095
2093
|
globalCompositeOperation: "",
|
|
2096
2094
|
overflow: "hidden",
|
|
2097
|
-
shadowPickMode: "graphic"
|
|
2098
|
-
keepStrokeScale: !1
|
|
2095
|
+
shadowPickMode: "graphic"
|
|
2099
2096
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2100
2097
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2101
2098
|
startAngle: 0,
|
|
@@ -2362,32 +2359,10 @@ let ATextMeasure = class {
|
|
|
2362
2359
|
configure(service, env) {
|
|
2363
2360
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2364
2361
|
}
|
|
2365
|
-
|
|
2362
|
+
measureTextWidth(text, options) {
|
|
2363
|
+
if (!this.context) return this.estimate(text, options).width;
|
|
2366
2364
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2367
|
-
|
|
2368
|
-
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2369
|
-
}
|
|
2370
|
-
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
2371
|
-
this.context.setTextStyle(options);
|
|
2372
|
-
const metrics = this.context.measureText(text);
|
|
2373
|
-
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2374
|
-
}
|
|
2375
|
-
compatibleMetrics(metrics, options) {
|
|
2376
|
-
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
2377
|
-
const {
|
|
2378
|
-
ascent: ascent,
|
|
2379
|
-
descent: descent
|
|
2380
|
-
} = this.measureTextBoundADscentEstimate(options);
|
|
2381
|
-
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
2382
|
-
}
|
|
2383
|
-
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
2384
|
-
const {
|
|
2385
|
-
left: left,
|
|
2386
|
-
right: right
|
|
2387
|
-
} = this.measureTextBoundLeftRightEstimate(options);
|
|
2388
|
-
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
2389
|
-
}
|
|
2390
|
-
return metrics;
|
|
2365
|
+
return this.context.measureText(text).width;
|
|
2391
2366
|
}
|
|
2392
2367
|
estimate(text, _ref) {
|
|
2393
2368
|
let {
|
|
@@ -2401,97 +2376,19 @@ let ATextMeasure = class {
|
|
|
2401
2376
|
height: fontSize
|
|
2402
2377
|
};
|
|
2403
2378
|
}
|
|
2404
|
-
|
|
2405
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2406
|
-
}
|
|
2407
|
-
measureTextBoundsWidth(text, options, textMeasure) {
|
|
2408
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2409
|
-
}
|
|
2410
|
-
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
2411
|
-
return this.context ? {
|
|
2412
|
-
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
2413
|
-
right: textMeasure.actualBoundingBoxRight
|
|
2414
|
-
} : this.measureTextBoundLeftRightEstimate(options);
|
|
2415
|
-
}
|
|
2416
|
-
measureTextPixelHeight(text, options, textMeasure) {
|
|
2379
|
+
measureTextPixelHeight(text, options) {
|
|
2417
2380
|
var _a;
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
return
|
|
2422
|
-
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
2423
|
-
descent: textMeasure.actualBoundingBoxDescent
|
|
2424
|
-
} : this.measureTextBoundADscentEstimate(options);
|
|
2425
|
-
}
|
|
2426
|
-
measureTextBoundHieght(text, options, textMeasure) {
|
|
2427
|
-
var _a;
|
|
2428
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2429
|
-
}
|
|
2430
|
-
measureTextBoundADscent(text, options, textMeasure) {
|
|
2431
|
-
return this.context ? {
|
|
2432
|
-
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
2433
|
-
descent: textMeasure.fontBoundingBoxDescent
|
|
2434
|
-
} : this.measureTextBoundADscentEstimate(options);
|
|
2435
|
-
}
|
|
2436
|
-
measureTextBoundADscentEstimate(options) {
|
|
2437
|
-
var _a;
|
|
2438
|
-
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2439
|
-
return {
|
|
2440
|
-
ascent: .79 * fontSize,
|
|
2441
|
-
descent: .21 * fontSize
|
|
2442
|
-
};
|
|
2381
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2382
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2383
|
+
const textMeasure = this.context.measureText(text);
|
|
2384
|
+
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
2443
2385
|
}
|
|
2444
|
-
|
|
2386
|
+
measureTextBoundHieght(text, options) {
|
|
2445
2387
|
var _a;
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
return "center" === textAlign ? {
|
|
2451
|
-
left: fontSize / 2,
|
|
2452
|
-
right: fontSize / 2
|
|
2453
|
-
} : "right" === textAlign || "end" === textAlign ? {
|
|
2454
|
-
left: fontSize,
|
|
2455
|
-
right: 0
|
|
2456
|
-
} : {
|
|
2457
|
-
left: 0,
|
|
2458
|
-
right: fontSize
|
|
2459
|
-
};
|
|
2460
|
-
}
|
|
2461
|
-
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
2462
|
-
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2463
|
-
width: this.estimate(text, options).width
|
|
2464
|
-
});
|
|
2465
|
-
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
2466
|
-
if (mode === MeasureModeEnum.actualBounding) return {
|
|
2467
|
-
ascent: out.actualBoundingBoxAscent,
|
|
2468
|
-
descent: out.actualBoundingBoxDescent,
|
|
2469
|
-
width: out.width
|
|
2470
|
-
};
|
|
2471
|
-
if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2472
|
-
width: out.width
|
|
2473
|
-
});
|
|
2474
|
-
if (mode === MeasureModeEnum.fontBounding) {
|
|
2475
|
-
let ascent = out.fontBoundingBoxAscent,
|
|
2476
|
-
descent = out.fontBoundingBoxDescent;
|
|
2477
|
-
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
2478
|
-
const delta = out.actualBoundingBoxDescent - descent;
|
|
2479
|
-
descent += delta, ascent -= delta;
|
|
2480
|
-
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
2481
|
-
const delta = out.actualBoundingBoxAscent - ascent;
|
|
2482
|
-
ascent += delta, descent -= delta;
|
|
2483
|
-
}
|
|
2484
|
-
return {
|
|
2485
|
-
ascent: ascent,
|
|
2486
|
-
descent: descent,
|
|
2487
|
-
width: out.width
|
|
2488
|
-
};
|
|
2489
|
-
}
|
|
2490
|
-
return {
|
|
2491
|
-
ascent: out.actualBoundingBoxAscent,
|
|
2492
|
-
descent: out.actualBoundingBoxDescent,
|
|
2493
|
-
width: out.width
|
|
2494
|
-
};
|
|
2388
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2389
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2390
|
+
const textMeasure = this.context.measureText(text);
|
|
2391
|
+
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
2495
2392
|
}
|
|
2496
2393
|
measureText(text, options) {
|
|
2497
2394
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -4481,7 +4378,7 @@ class ResourceLoader {
|
|
|
4481
4378
|
}
|
|
4482
4379
|
static GetFile(url, type) {
|
|
4483
4380
|
let data = ResourceLoader.cache.get(url);
|
|
4484
|
-
return data ? "
|
|
4381
|
+
return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
|
|
4485
4382
|
type: type,
|
|
4486
4383
|
loadState: "init"
|
|
4487
4384
|
}, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
|
|
@@ -6145,6 +6042,9 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
|
|
|
6145
6042
|
const TextRenderContribution = Symbol.for("TextRenderContribution");
|
|
6146
6043
|
const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
|
|
6147
6044
|
|
|
6045
|
+
function textDrawOffsetY(baseline, h) {
|
|
6046
|
+
return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
|
|
6047
|
+
}
|
|
6148
6048
|
function textDrawOffsetX(textAlign, width) {
|
|
6149
6049
|
return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
|
|
6150
6050
|
}
|
|
@@ -6623,7 +6523,7 @@ class BaseRender {
|
|
|
6623
6523
|
}
|
|
6624
6524
|
}
|
|
6625
6525
|
|
|
6626
|
-
const parse = function () {
|
|
6526
|
+
const parse$1 = function () {
|
|
6627
6527
|
const tokens = {
|
|
6628
6528
|
linearGradient: /^(linear\-gradient)/i,
|
|
6629
6529
|
radialGradient: /^(radial\-gradient)/i,
|
|
@@ -6776,7 +6676,7 @@ class GradientParser {
|
|
|
6776
6676
|
}
|
|
6777
6677
|
static Parse(c) {
|
|
6778
6678
|
if (GradientParser.IsGradientStr(c)) try {
|
|
6779
|
-
const datum = parse(c)[0];
|
|
6679
|
+
const datum = parse$1(c)[0];
|
|
6780
6680
|
if (datum) {
|
|
6781
6681
|
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
6782
6682
|
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
@@ -7133,8 +7033,7 @@ class DefaultArcRenderContribution {
|
|
|
7133
7033
|
x: originX = arcAttribute.x,
|
|
7134
7034
|
y: originY = arcAttribute.y,
|
|
7135
7035
|
scaleX = arcAttribute.scaleX,
|
|
7136
|
-
scaleY = arcAttribute.scaleY
|
|
7137
|
-
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
7036
|
+
scaleY = arcAttribute.scaleY
|
|
7138
7037
|
} = arc.attribute;
|
|
7139
7038
|
let {
|
|
7140
7039
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -7146,7 +7045,7 @@ class DefaultArcRenderContribution {
|
|
|
7146
7045
|
{
|
|
7147
7046
|
distance = arcAttribute[key].distance
|
|
7148
7047
|
} = borderStyle,
|
|
7149
|
-
d =
|
|
7048
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
7150
7049
|
deltaAngle = distance / outerRadius,
|
|
7151
7050
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7152
7051
|
if (arc.setAttributes({
|
|
@@ -7191,15 +7090,14 @@ class DefaultCircleRenderContribution {
|
|
|
7191
7090
|
x: originX = circleAttribute.x,
|
|
7192
7091
|
y: originY = circleAttribute.y,
|
|
7193
7092
|
scaleX = circleAttribute.scaleX,
|
|
7194
|
-
scaleY = circleAttribute.scaleY
|
|
7195
|
-
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
7093
|
+
scaleY = circleAttribute.scaleY
|
|
7196
7094
|
} = circle.attribute,
|
|
7197
7095
|
renderBorder = (borderStyle, key) => {
|
|
7198
7096
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7199
7097
|
{
|
|
7200
7098
|
distance = circleAttribute[key].distance
|
|
7201
7099
|
} = borderStyle,
|
|
7202
|
-
d =
|
|
7100
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
7203
7101
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7204
7102
|
if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
|
|
7205
7103
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -7318,8 +7216,7 @@ class DefaultRectRenderContribution {
|
|
|
7318
7216
|
scaleX = rectAttribute.scaleX,
|
|
7319
7217
|
scaleY = rectAttribute.scaleY,
|
|
7320
7218
|
x1: x1,
|
|
7321
|
-
y1: y1
|
|
7322
|
-
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
7219
|
+
y1: y1
|
|
7323
7220
|
} = rect.attribute;
|
|
7324
7221
|
let {
|
|
7325
7222
|
width: width,
|
|
@@ -7332,7 +7229,7 @@ class DefaultRectRenderContribution {
|
|
|
7332
7229
|
{
|
|
7333
7230
|
distance = rectAttribute[key].distance
|
|
7334
7231
|
} = borderStyle,
|
|
7335
|
-
d =
|
|
7232
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
7336
7233
|
nextX = x + sign * d,
|
|
7337
7234
|
nextY = y + sign * d,
|
|
7338
7235
|
dw = 2 * d;
|
|
@@ -7462,8 +7359,9 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
7462
7359
|
constructor() {
|
|
7463
7360
|
super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
7464
7361
|
}
|
|
7465
|
-
drawShape(
|
|
7466
|
-
return super.drawShape(
|
|
7362
|
+
drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
7363
|
+
if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
7364
|
+
image.renderFrame(context, x, y);
|
|
7467
7365
|
}
|
|
7468
7366
|
}
|
|
7469
7367
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -7489,15 +7387,14 @@ class DefaultSymbolRenderContribution {
|
|
|
7489
7387
|
x: originX = symbolAttribute.x,
|
|
7490
7388
|
y: originY = symbolAttribute.y,
|
|
7491
7389
|
scaleX = symbolAttribute.scaleX,
|
|
7492
|
-
scaleY = symbolAttribute.scaleY
|
|
7493
|
-
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
7390
|
+
scaleY = symbolAttribute.scaleY
|
|
7494
7391
|
} = symbol.attribute,
|
|
7495
7392
|
renderBorder = (borderStyle, key) => {
|
|
7496
7393
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7497
7394
|
{
|
|
7498
7395
|
distance = symbolAttribute[key].distance
|
|
7499
7396
|
} = borderStyle,
|
|
7500
|
-
d =
|
|
7397
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
7501
7398
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7502
7399
|
if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
|
|
7503
7400
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -8773,8 +8670,16 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8773
8670
|
verticalMode = textAttribute.verticalMode,
|
|
8774
8671
|
x: originX = textAttribute.x,
|
|
8775
8672
|
y: originY = textAttribute.y
|
|
8776
|
-
} = text.attribute
|
|
8777
|
-
|
|
8673
|
+
} = text.attribute;
|
|
8674
|
+
let {
|
|
8675
|
+
textAlign = textAttribute.textAlign,
|
|
8676
|
+
textBaseline = textAttribute.textBaseline
|
|
8677
|
+
} = text.attribute;
|
|
8678
|
+
if (!verticalMode && "vertical" === direction) {
|
|
8679
|
+
const t = textAlign;
|
|
8680
|
+
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
8681
|
+
}
|
|
8682
|
+
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
8778
8683
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
8779
8684
|
if (!data) return;
|
|
8780
8685
|
const {
|
|
@@ -8794,60 +8699,79 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8794
8699
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
8795
8700
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
8796
8701
|
}
|
|
8797
|
-
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
8702
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
8798
8703
|
};
|
|
8799
|
-
if (
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
context
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8704
|
+
if (text.isMultiLine) {
|
|
8705
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
8706
|
+
const {
|
|
8707
|
+
multilineLayout: multilineLayout
|
|
8708
|
+
} = text;
|
|
8709
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
8710
|
+
const {
|
|
8711
|
+
xOffset: xOffset,
|
|
8712
|
+
yOffset: yOffset
|
|
8713
|
+
} = multilineLayout.bbox;
|
|
8714
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8715
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
8716
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8717
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
|
|
8718
|
+
width: line.width
|
|
8719
|
+
});
|
|
8720
|
+
})));
|
|
8721
|
+
} else {
|
|
8722
|
+
text.tryUpdateAABBBounds();
|
|
8723
|
+
const cache = text.cache,
|
|
8724
|
+
{
|
|
8725
|
+
verticalList: verticalList
|
|
8726
|
+
} = cache;
|
|
8727
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
8728
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
8729
|
+
let totalW = 0;
|
|
8730
|
+
verticalList.forEach(verticalData => {
|
|
8731
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8732
|
+
totalW = max(_w, totalW);
|
|
8733
|
+
});
|
|
8734
|
+
let offsetY = 0,
|
|
8735
|
+
offsetX = 0;
|
|
8736
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8737
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8738
|
+
dw = totalW - currentW;
|
|
8739
|
+
let currentOffsetY = offsetY;
|
|
8740
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8741
|
+
const {
|
|
8742
|
+
text: text,
|
|
8743
|
+
width: width,
|
|
8744
|
+
direction: direction
|
|
8745
|
+
} = item;
|
|
8746
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8747
|
+
});
|
|
8813
8748
|
});
|
|
8814
|
-
})));
|
|
8815
|
-
} else {
|
|
8816
|
-
let {
|
|
8817
|
-
textAlign = textAttribute.textAlign,
|
|
8818
|
-
textBaseline = textAttribute.textBaseline
|
|
8819
|
-
} = text.attribute;
|
|
8820
|
-
if (!verticalMode) {
|
|
8821
|
-
const t = textAlign;
|
|
8822
|
-
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
8823
8749
|
}
|
|
8750
|
+
} else if ("horizontal" === direction) {
|
|
8751
|
+
context.setTextStyle(text.attribute, textAttribute, z);
|
|
8752
|
+
const t = text.clipedText;
|
|
8753
|
+
let dy = 0;
|
|
8754
|
+
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
8755
|
+
} else {
|
|
8824
8756
|
text.tryUpdateAABBBounds();
|
|
8825
|
-
const cache = text.cache
|
|
8826
|
-
|
|
8757
|
+
const cache = text.cache;
|
|
8758
|
+
if (cache) {
|
|
8759
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
8760
|
+
const {
|
|
8827
8761
|
verticalList: verticalList
|
|
8828
8762
|
} = cache;
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8834
|
-
totalW = max(_w, totalW);
|
|
8835
|
-
});
|
|
8836
|
-
let offsetY = 0,
|
|
8837
|
-
offsetX = 0;
|
|
8838
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8839
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8840
|
-
dw = totalW - currentW;
|
|
8841
|
-
let currentOffsetY = offsetY;
|
|
8842
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8763
|
+
let offsetY = 0;
|
|
8764
|
+
const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
|
|
8765
|
+
let offsetX = 0;
|
|
8766
|
+
"bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
|
|
8843
8767
|
const {
|
|
8844
8768
|
text: text,
|
|
8845
8769
|
width: width,
|
|
8846
8770
|
direction: direction
|
|
8847
8771
|
} = item;
|
|
8848
|
-
drawText(text,
|
|
8772
|
+
drawText(text, offsetX, offsetY, direction), offsetY += width;
|
|
8849
8773
|
});
|
|
8850
|
-
}
|
|
8774
|
+
}
|
|
8851
8775
|
}
|
|
8852
8776
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
8853
8777
|
}
|
|
@@ -8859,10 +8783,12 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8859
8783
|
computed3dMatrix = !keepDirIn3d;
|
|
8860
8784
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
8861
8785
|
}
|
|
8862
|
-
drawUnderLine(underline, lineThrough, text,
|
|
8786
|
+
drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
|
|
8863
8787
|
if (lineThrough + underline <= 0) return;
|
|
8864
8788
|
const {
|
|
8865
8789
|
textAlign = textAttribute.textAlign,
|
|
8790
|
+
textBaseline = textAttribute.textBaseline,
|
|
8791
|
+
fontSize = textAttribute.fontSize,
|
|
8866
8792
|
fill = textAttribute.fill,
|
|
8867
8793
|
opacity = textAttribute.opacity,
|
|
8868
8794
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -8872,21 +8798,23 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8872
8798
|
isMulti = !isNil(multiOption),
|
|
8873
8799
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
8874
8800
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
8801
|
+
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
8875
8802
|
attribute = {
|
|
8876
8803
|
lineWidth: 0,
|
|
8877
8804
|
stroke: fill,
|
|
8878
8805
|
opacity: opacity,
|
|
8879
8806
|
strokeOpacity: fillOpacity
|
|
8880
8807
|
};
|
|
8808
|
+
let deltaY = isMulti ? -3 : 0;
|
|
8881
8809
|
if (underline) {
|
|
8882
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
8883
|
-
const dy =
|
|
8884
|
-
context.moveTo(
|
|
8810
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
8811
|
+
const dy = y + offsetY + fontSize + underlineOffset + deltaY;
|
|
8812
|
+
context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
|
|
8885
8813
|
}
|
|
8886
|
-
if (lineThrough) {
|
|
8887
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
8888
|
-
const dy =
|
|
8889
|
-
context.moveTo(
|
|
8814
|
+
if (isMulti && (deltaY = -1), lineThrough) {
|
|
8815
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
|
|
8816
|
+
const dy = y + offsetY + fontSize / 2 + deltaY;
|
|
8817
|
+
context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
|
|
8890
8818
|
}
|
|
8891
8819
|
}
|
|
8892
8820
|
};
|
|
@@ -9171,10 +9099,12 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
9171
9099
|
const {
|
|
9172
9100
|
image: url
|
|
9173
9101
|
} = image.attribute;
|
|
9174
|
-
if (!
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9102
|
+
if (!image.isGifImage) {
|
|
9103
|
+
if (!url || !image.resources) return;
|
|
9104
|
+
const res = image.resources.get(url);
|
|
9105
|
+
if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
|
|
9106
|
+
if ("success" !== res.state) return;
|
|
9107
|
+
}
|
|
9178
9108
|
const {
|
|
9179
9109
|
context: context
|
|
9180
9110
|
} = renderService.drawParams;
|
|
@@ -9551,63 +9481,58 @@ class CanvasTextLayout {
|
|
|
9551
9481
|
constructor(fontFamily, options, textMeasure) {
|
|
9552
9482
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
9553
9483
|
}
|
|
9554
|
-
LayoutBBox(bbox, textAlign, textBaseline
|
|
9484
|
+
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
9555
9485
|
if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
|
|
9556
9486
|
if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
|
|
9557
9487
|
bbox.xOffset = -bbox.width;
|
|
9558
9488
|
}
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9489
|
+
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
9490
|
+
}
|
|
9491
|
+
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
9492
|
+
const linesLayout = [],
|
|
9493
|
+
bboxWH = [width, height],
|
|
9494
|
+
bboxOffset = [0, 0];
|
|
9495
|
+
for (; str.length > 0;) {
|
|
9496
|
+
const {
|
|
9497
|
+
str: clipText
|
|
9498
|
+
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
9499
|
+
linesLayout.push({
|
|
9500
|
+
str: clipText,
|
|
9501
|
+
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
9502
|
+
}), str = str.substring(clipText.length);
|
|
9503
|
+
}
|
|
9504
|
+
"left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
|
|
9505
|
+
const bbox = {
|
|
9506
|
+
xOffset: bboxOffset[0],
|
|
9507
|
+
yOffset: bboxOffset[1],
|
|
9508
|
+
width: bboxWH[0],
|
|
9509
|
+
height: bboxWH[1]
|
|
9510
|
+
};
|
|
9511
|
+
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9568
9512
|
}
|
|
9569
9513
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
9570
9514
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
9571
9515
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
9572
|
-
let
|
|
9573
|
-
|
|
9574
|
-
lineWidth: lineWidth,
|
|
9575
|
-
suffixPosition = "end",
|
|
9576
|
-
measureMode = MeasureModeEnum.actualBounding,
|
|
9577
|
-
keepCenterInLine = !1
|
|
9578
|
-
} = null != params ? params : {};
|
|
9516
|
+
let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
|
|
9517
|
+
let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
|
|
9579
9518
|
lines = lines.map(l => l.toString());
|
|
9580
9519
|
const linesLayout = [],
|
|
9581
9520
|
bboxWH = [0, 0];
|
|
9582
9521
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
9583
9522
|
let width;
|
|
9584
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9585
|
-
|
|
9586
|
-
width
|
|
9587
|
-
|
|
9588
|
-
width: width,
|
|
9589
|
-
ascent: metrics.ascent,
|
|
9590
|
-
descent: metrics.descent,
|
|
9591
|
-
keepCenterInLine: keepCenterInLine
|
|
9592
|
-
});
|
|
9593
|
-
}
|
|
9523
|
+
for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
|
|
9524
|
+
str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
9525
|
+
width: width
|
|
9526
|
+
});
|
|
9594
9527
|
bboxWH[0] = lineWidth;
|
|
9595
9528
|
} else {
|
|
9596
|
-
let width,
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
str: text,
|
|
9604
|
-
width: width,
|
|
9605
|
-
ascent: metrics.ascent,
|
|
9606
|
-
descent: metrics.descent,
|
|
9607
|
-
keepCenterInLine: keepCenterInLine
|
|
9608
|
-
});
|
|
9609
|
-
}
|
|
9610
|
-
bboxWH[0] = _lineWidth;
|
|
9529
|
+
let width, text;
|
|
9530
|
+
lineWidth = 0;
|
|
9531
|
+
for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
9532
|
+
str: text,
|
|
9533
|
+
width: width
|
|
9534
|
+
});
|
|
9535
|
+
bboxWH[0] = lineWidth;
|
|
9611
9536
|
}
|
|
9612
9537
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
9613
9538
|
const bbox = {
|
|
@@ -9616,7 +9541,7 @@ class CanvasTextLayout {
|
|
|
9616
9541
|
width: bboxWH[0],
|
|
9617
9542
|
height: bboxWH[1]
|
|
9618
9543
|
};
|
|
9619
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline
|
|
9544
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9620
9545
|
}
|
|
9621
9546
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
9622
9547
|
const origin = [0, 0],
|
|
@@ -9635,16 +9560,11 @@ class CanvasTextLayout {
|
|
|
9635
9560
|
};
|
|
9636
9561
|
}
|
|
9637
9562
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
9638
|
-
|
|
9639
|
-
const buf = 0,
|
|
9640
|
-
actualHeightWithBuf = line.ascent + line.descent + buf;
|
|
9641
|
-
actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2));
|
|
9642
|
-
}
|
|
9643
|
-
return origin[1] += lineHeight, line;
|
|
9563
|
+
return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
|
|
9644
9564
|
}
|
|
9645
9565
|
}
|
|
9646
9566
|
|
|
9647
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "
|
|
9567
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9648
9568
|
class Text extends Graphic {
|
|
9649
9569
|
get font() {
|
|
9650
9570
|
const textTheme = this.getGraphicTheme();
|
|
@@ -9653,22 +9573,26 @@ class Text extends Graphic {
|
|
|
9653
9573
|
get clipedText() {
|
|
9654
9574
|
var _a;
|
|
9655
9575
|
const attribute = this.attribute,
|
|
9656
|
-
textTheme = this.getGraphicTheme()
|
|
9657
|
-
|
|
9658
|
-
|
|
9576
|
+
textTheme = this.getGraphicTheme();
|
|
9577
|
+
if (!this.isSimplify()) return;
|
|
9578
|
+
const {
|
|
9579
|
+
maxLineWidth = textTheme.maxLineWidth
|
|
9580
|
+
} = attribute;
|
|
9581
|
+
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9659
9582
|
}
|
|
9660
9583
|
get clipedWidth() {
|
|
9661
|
-
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
9584
|
+
if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
9662
9585
|
}
|
|
9663
9586
|
get cliped() {
|
|
9664
9587
|
var _a, _b;
|
|
9665
9588
|
const textTheme = this.getGraphicTheme(),
|
|
9666
9589
|
attribute = this.attribute,
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9590
|
+
{
|
|
9591
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
9592
|
+
text: text,
|
|
9593
|
+
whiteSpace = textTheme.whiteSpace
|
|
9594
|
+
} = attribute;
|
|
9595
|
+
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
9672
9596
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
9673
9597
|
let mergedText = "";
|
|
9674
9598
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -9679,7 +9603,10 @@ class Text extends Graphic {
|
|
|
9679
9603
|
return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
|
|
9680
9604
|
}
|
|
9681
9605
|
get multilineLayout() {
|
|
9682
|
-
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
9606
|
+
if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
9607
|
+
}
|
|
9608
|
+
isSimplify() {
|
|
9609
|
+
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
9683
9610
|
}
|
|
9684
9611
|
get isMultiLine() {
|
|
9685
9612
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -9752,74 +9679,8 @@ class Text extends Graphic {
|
|
|
9752
9679
|
}
|
|
9753
9680
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
9754
9681
|
}
|
|
9755
|
-
updateSingallineAABBBounds(text) {
|
|
9756
|
-
this.updateMultilineAABBBounds([text]);
|
|
9757
|
-
const layoutData = this.cache.layoutData;
|
|
9758
|
-
if (layoutData) {
|
|
9759
|
-
const line = layoutData.lines[0];
|
|
9760
|
-
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
9761
|
-
}
|
|
9762
|
-
return this._AABBBounds;
|
|
9763
|
-
}
|
|
9764
|
-
updateMultilineAABBBounds(text) {
|
|
9765
|
-
const textTheme = this.getGraphicTheme(),
|
|
9766
|
-
{
|
|
9767
|
-
direction = textTheme.direction,
|
|
9768
|
-
underlineOffset = textTheme.underlineOffset
|
|
9769
|
-
} = this.attribute,
|
|
9770
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9771
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9772
|
-
}
|
|
9773
|
-
guessLineHeightBuf(fontSize) {
|
|
9774
|
-
return fontSize ? .1 * fontSize : 0;
|
|
9775
|
-
}
|
|
9776
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
9777
|
-
var _a;
|
|
9778
|
-
const textTheme = this.getGraphicTheme(),
|
|
9779
|
-
attribute = this.attribute,
|
|
9780
|
-
{
|
|
9781
|
-
fontFamily = textTheme.fontFamily,
|
|
9782
|
-
textAlign = textTheme.textAlign,
|
|
9783
|
-
textBaseline = textTheme.textBaseline,
|
|
9784
|
-
fontSize = textTheme.fontSize,
|
|
9785
|
-
fontWeight = textTheme.fontWeight,
|
|
9786
|
-
ellipsis = textTheme.ellipsis,
|
|
9787
|
-
maxLineWidth: maxLineWidth,
|
|
9788
|
-
stroke = textTheme.stroke,
|
|
9789
|
-
wrap = textTheme.wrap,
|
|
9790
|
-
measureMode = textTheme.measureMode,
|
|
9791
|
-
lineWidth = textTheme.lineWidth,
|
|
9792
|
-
whiteSpace = textTheme.whiteSpace,
|
|
9793
|
-
suffixPosition = textTheme.suffixPosition,
|
|
9794
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
9795
|
-
keepCenterInLine = textTheme.keepCenterInLine
|
|
9796
|
-
} = attribute,
|
|
9797
|
-
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
9798
|
-
lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
9799
|
-
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
9800
|
-
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9801
|
-
const bbox = this.cache.layoutData.bbox;
|
|
9802
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9803
|
-
}
|
|
9804
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
9805
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9806
|
-
fontSize: fontSize,
|
|
9807
|
-
fontWeight: fontWeight,
|
|
9808
|
-
fontFamily: fontFamily,
|
|
9809
|
-
lineHeight: lineHeight
|
|
9810
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
9811
|
-
lineWidth: maxLineWidth,
|
|
9812
|
-
suffixPosition: suffixPosition,
|
|
9813
|
-
measureMode: measureMode,
|
|
9814
|
-
keepCenterInLine: keepCenterInLine
|
|
9815
|
-
}),
|
|
9816
|
-
{
|
|
9817
|
-
bbox: bbox
|
|
9818
|
-
} = layoutData;
|
|
9819
|
-
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9820
|
-
}
|
|
9821
9682
|
updateWrapAABBBounds(text) {
|
|
9822
|
-
var _a, _b, _c;
|
|
9683
|
+
var _a, _b, _c, _d;
|
|
9823
9684
|
const textTheme = this.getGraphicTheme(),
|
|
9824
9685
|
{
|
|
9825
9686
|
fontFamily = textTheme.fontFamily,
|
|
@@ -9833,26 +9694,22 @@ class Text extends Graphic {
|
|
|
9833
9694
|
wordBreak = textTheme.wordBreak,
|
|
9834
9695
|
fontWeight = textTheme.fontWeight,
|
|
9835
9696
|
ignoreBuf = textTheme.ignoreBuf,
|
|
9836
|
-
measureMode = textTheme.measureMode,
|
|
9837
9697
|
suffixPosition = textTheme.suffixPosition,
|
|
9838
9698
|
heightLimit = 0,
|
|
9839
|
-
lineClamp: lineClamp
|
|
9840
|
-
keepCenterInLine = textTheme.keepCenterInLine
|
|
9699
|
+
lineClamp: lineClamp
|
|
9841
9700
|
} = this.attribute,
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
9701
|
+
lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
|
|
9702
|
+
buf = ignoreBuf ? 0 : 2;
|
|
9703
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
9845
9704
|
const bbox = this.cache.layoutData.bbox;
|
|
9846
9705
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9847
9706
|
}
|
|
9848
9707
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
9849
|
-
|
|
9708
|
+
layoutObj = new CanvasTextLayout(fontFamily, {
|
|
9850
9709
|
fontSize: fontSize,
|
|
9851
9710
|
fontWeight: fontWeight,
|
|
9852
|
-
fontFamily: fontFamily
|
|
9853
|
-
|
|
9854
|
-
},
|
|
9855
|
-
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
9711
|
+
fontFamily: fontFamily
|
|
9712
|
+
}, textMeasure),
|
|
9856
9713
|
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
9857
9714
|
linesLayout = [],
|
|
9858
9715
|
bboxWH = [0, 0];
|
|
@@ -9862,37 +9719,29 @@ class Text extends Graphic {
|
|
|
9862
9719
|
const str = lines[i];
|
|
9863
9720
|
let needCut = !0;
|
|
9864
9721
|
if (i === lineCountLimit - 1) {
|
|
9865
|
-
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1)
|
|
9866
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9722
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
|
|
9867
9723
|
linesLayout.push({
|
|
9868
9724
|
str: clip.str,
|
|
9869
|
-
width: clip.width
|
|
9870
|
-
ascent: matrics.ascent,
|
|
9871
|
-
descent: matrics.descent,
|
|
9872
|
-
keepCenterInLine: keepCenterInLine
|
|
9725
|
+
width: clip.width
|
|
9873
9726
|
});
|
|
9874
9727
|
break;
|
|
9875
9728
|
}
|
|
9876
|
-
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
9729
|
+
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
9877
9730
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
9878
9731
|
if (ellipsis) {
|
|
9879
|
-
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9880
|
-
clip.str = null !== (
|
|
9732
|
+
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9733
|
+
clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
|
|
9881
9734
|
} else clip.str = "", clip.width = 0;
|
|
9882
9735
|
needCut = !1;
|
|
9883
9736
|
}
|
|
9884
|
-
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9885
9737
|
linesLayout.push({
|
|
9886
9738
|
str: clip.str,
|
|
9887
|
-
width: clip.width
|
|
9888
|
-
ascent: matrics.ascent,
|
|
9889
|
-
descent: matrics.descent,
|
|
9890
|
-
keepCenterInLine: keepCenterInLine
|
|
9739
|
+
width: clip.width
|
|
9891
9740
|
});
|
|
9892
9741
|
let cutLength = clip.str.length;
|
|
9893
9742
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
9894
|
-
|
|
9895
|
-
lines.splice(i + 1, 0, newStr);
|
|
9743
|
+
let newStr = str.substring(cutLength);
|
|
9744
|
+
"keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
|
|
9896
9745
|
}
|
|
9897
9746
|
}
|
|
9898
9747
|
let maxWidth = 0;
|
|
@@ -9905,46 +9754,235 @@ class Text extends Graphic {
|
|
|
9905
9754
|
lineWidth = 0;
|
|
9906
9755
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9907
9756
|
if (i === lineCountLimit - 1) {
|
|
9908
|
-
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition)
|
|
9909
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9757
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9910
9758
|
linesLayout.push({
|
|
9911
9759
|
str: clip.str,
|
|
9912
|
-
width: clip.width
|
|
9913
|
-
ascent: matrics.ascent,
|
|
9914
|
-
descent: matrics.descent,
|
|
9915
|
-
keepCenterInLine: keepCenterInLine
|
|
9760
|
+
width: clip.width
|
|
9916
9761
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
9917
9762
|
break;
|
|
9918
9763
|
}
|
|
9919
|
-
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width)
|
|
9920
|
-
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
9921
|
-
linesLayout.push({
|
|
9764
|
+
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
9922
9765
|
str: text,
|
|
9923
|
-
width: width
|
|
9924
|
-
ascent: matrics.ascent,
|
|
9925
|
-
descent: matrics.descent,
|
|
9926
|
-
keepCenterInLine: keepCenterInLine
|
|
9766
|
+
width: width
|
|
9927
9767
|
});
|
|
9928
9768
|
}
|
|
9929
9769
|
bboxWH[0] = lineWidth;
|
|
9930
9770
|
}
|
|
9931
|
-
bboxWH[1] = linesLayout.length * lineHeight;
|
|
9771
|
+
bboxWH[1] = linesLayout.length * (lineHeight + buf);
|
|
9932
9772
|
const bbox = {
|
|
9933
9773
|
xOffset: 0,
|
|
9934
9774
|
yOffset: 0,
|
|
9935
9775
|
width: bboxWH[0],
|
|
9936
9776
|
height: bboxWH[1]
|
|
9937
9777
|
};
|
|
9938
|
-
layoutObj.LayoutBBox(bbox, textAlign, textBaseline
|
|
9778
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
9939
9779
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9940
9780
|
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9941
9781
|
}
|
|
9942
|
-
|
|
9782
|
+
updateSingallineAABBBounds(text) {
|
|
9783
|
+
const textTheme = this.getGraphicTheme(),
|
|
9784
|
+
{
|
|
9785
|
+
direction = textTheme.direction,
|
|
9786
|
+
underlineOffset = textTheme.underlineOffset
|
|
9787
|
+
} = this.attribute,
|
|
9788
|
+
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
9789
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9790
|
+
}
|
|
9791
|
+
updateMultilineAABBBounds(text) {
|
|
9792
|
+
const textTheme = this.getGraphicTheme(),
|
|
9793
|
+
{
|
|
9794
|
+
direction = textTheme.direction,
|
|
9795
|
+
underlineOffset = textTheme.underlineOffset
|
|
9796
|
+
} = this.attribute,
|
|
9797
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9798
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9799
|
+
}
|
|
9800
|
+
updateHorizontalSinglelineAABBBounds(text) {
|
|
9943
9801
|
var _a, _b;
|
|
9802
|
+
const textTheme = this.getGraphicTheme(),
|
|
9803
|
+
{
|
|
9804
|
+
wrap = textTheme.wrap
|
|
9805
|
+
} = this.attribute;
|
|
9806
|
+
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
9807
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
9808
|
+
let width, str;
|
|
9809
|
+
const attribute = this.attribute,
|
|
9810
|
+
{
|
|
9811
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
9812
|
+
ellipsis = textTheme.ellipsis,
|
|
9813
|
+
textAlign = textTheme.textAlign,
|
|
9814
|
+
textBaseline = textTheme.textBaseline,
|
|
9815
|
+
fontFamily = textTheme.fontFamily,
|
|
9816
|
+
fontSize = textTheme.fontSize,
|
|
9817
|
+
fontWeight = textTheme.fontWeight,
|
|
9818
|
+
stroke = textTheme.stroke,
|
|
9819
|
+
lineWidth = textTheme.lineWidth,
|
|
9820
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
9821
|
+
whiteSpace = textTheme.whiteSpace,
|
|
9822
|
+
suffixPosition = textTheme.suffixPosition
|
|
9823
|
+
} = attribute;
|
|
9824
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9825
|
+
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
9826
|
+
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
9827
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
9828
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
9829
|
+
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
9830
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
9831
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9832
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9833
|
+
}
|
|
9834
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
9835
|
+
if (ellipsis) {
|
|
9836
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9837
|
+
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
9838
|
+
fontSize: fontSize,
|
|
9839
|
+
fontWeight: fontWeight,
|
|
9840
|
+
fontFamily: fontFamily
|
|
9841
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9842
|
+
str = data.str, width = data.width;
|
|
9843
|
+
} else {
|
|
9844
|
+
const data = textMeasure.clipText(text.toString(), {
|
|
9845
|
+
fontSize: fontSize,
|
|
9846
|
+
fontWeight: fontWeight,
|
|
9847
|
+
fontFamily: fontFamily
|
|
9848
|
+
}, maxLineWidth, !1);
|
|
9849
|
+
str = data.str, width = data.width;
|
|
9850
|
+
}
|
|
9851
|
+
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
9852
|
+
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
9853
|
+
fontSize: fontSize,
|
|
9854
|
+
fontWeight: fontWeight,
|
|
9855
|
+
fontFamily: fontFamily
|
|
9856
|
+
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
9857
|
+
this.clearUpdateShapeTag();
|
|
9858
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
9859
|
+
let lh = lineHeight;
|
|
9860
|
+
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
9861
|
+
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
9862
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9863
|
+
}
|
|
9864
|
+
getBaselineMapAlign() {
|
|
9865
|
+
return Text.baselineMapAlign;
|
|
9866
|
+
}
|
|
9867
|
+
getAlignMapBaseline() {
|
|
9868
|
+
return Text.alignMapBaseline;
|
|
9869
|
+
}
|
|
9870
|
+
updateVerticalSinglelineAABBBounds(text) {
|
|
9871
|
+
var _a, _b, _c;
|
|
9944
9872
|
const textTheme = this.getGraphicTheme(),
|
|
9945
9873
|
textMeasure = application.graphicUtil.textMeasure;
|
|
9946
9874
|
let width;
|
|
9947
9875
|
const attribute = this.attribute,
|
|
9876
|
+
{
|
|
9877
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
9878
|
+
} = attribute,
|
|
9879
|
+
buf = ignoreBuf ? 0 : 2,
|
|
9880
|
+
{
|
|
9881
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
9882
|
+
ellipsis = textTheme.ellipsis,
|
|
9883
|
+
fontSize = textTheme.fontSize,
|
|
9884
|
+
fontWeight = textTheme.fontWeight,
|
|
9885
|
+
fontFamily = textTheme.fontFamily,
|
|
9886
|
+
stroke = textTheme.stroke,
|
|
9887
|
+
lineWidth = textTheme.lineWidth,
|
|
9888
|
+
verticalMode = textTheme.verticalMode,
|
|
9889
|
+
suffixPosition = textTheme.suffixPosition
|
|
9890
|
+
} = attribute,
|
|
9891
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
9892
|
+
let {
|
|
9893
|
+
textAlign = textTheme.textAlign,
|
|
9894
|
+
textBaseline = textTheme.textBaseline
|
|
9895
|
+
} = attribute;
|
|
9896
|
+
if (!verticalMode) {
|
|
9897
|
+
const t = textAlign;
|
|
9898
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
9899
|
+
}
|
|
9900
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
9901
|
+
width = this.cache.clipedWidth;
|
|
9902
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
9903
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9904
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9905
|
+
}
|
|
9906
|
+
let verticalList = [verticalLayout(text.toString())];
|
|
9907
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
9908
|
+
if (ellipsis) {
|
|
9909
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9910
|
+
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
9911
|
+
fontSize: fontSize,
|
|
9912
|
+
fontWeight: fontWeight,
|
|
9913
|
+
fontFamily: fontFamily
|
|
9914
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9915
|
+
verticalList = [data.verticalList], width = data.width;
|
|
9916
|
+
} else {
|
|
9917
|
+
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
9918
|
+
fontSize: fontSize,
|
|
9919
|
+
fontWeight: fontWeight,
|
|
9920
|
+
fontFamily: fontFamily
|
|
9921
|
+
}, maxLineWidth, !1);
|
|
9922
|
+
verticalList = [data.verticalList], width = data.width;
|
|
9923
|
+
}
|
|
9924
|
+
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9925
|
+
} else width = 0, verticalList[0].forEach(t => {
|
|
9926
|
+
const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
9927
|
+
fontSize: fontSize,
|
|
9928
|
+
fontWeight: fontWeight,
|
|
9929
|
+
fontFamily: fontFamily
|
|
9930
|
+
});
|
|
9931
|
+
width += w, t.width = w;
|
|
9932
|
+
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9933
|
+
this.clearUpdateShapeTag();
|
|
9934
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
9935
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9936
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9937
|
+
}
|
|
9938
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
9939
|
+
var _a, _b;
|
|
9940
|
+
const textTheme = this.getGraphicTheme(),
|
|
9941
|
+
{
|
|
9942
|
+
wrap = textTheme.wrap
|
|
9943
|
+
} = this.attribute;
|
|
9944
|
+
if (wrap) return this.updateWrapAABBBounds(text);
|
|
9945
|
+
const attribute = this.attribute,
|
|
9946
|
+
{
|
|
9947
|
+
fontFamily = textTheme.fontFamily,
|
|
9948
|
+
textAlign = textTheme.textAlign,
|
|
9949
|
+
textBaseline = textTheme.textBaseline,
|
|
9950
|
+
fontSize = textTheme.fontSize,
|
|
9951
|
+
fontWeight = textTheme.fontWeight,
|
|
9952
|
+
ellipsis = textTheme.ellipsis,
|
|
9953
|
+
maxLineWidth: maxLineWidth,
|
|
9954
|
+
stroke = textTheme.stroke,
|
|
9955
|
+
lineWidth = textTheme.lineWidth,
|
|
9956
|
+
whiteSpace = textTheme.whiteSpace,
|
|
9957
|
+
suffixPosition = textTheme.suffixPosition
|
|
9958
|
+
} = attribute,
|
|
9959
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
9960
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9961
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
9962
|
+
const bbox = this.cache.layoutData.bbox;
|
|
9963
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9964
|
+
}
|
|
9965
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
9966
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9967
|
+
fontSize: fontSize,
|
|
9968
|
+
fontWeight: fontWeight,
|
|
9969
|
+
fontFamily: fontFamily
|
|
9970
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
9971
|
+
{
|
|
9972
|
+
bbox: bbox
|
|
9973
|
+
} = layoutData;
|
|
9974
|
+
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9975
|
+
}
|
|
9976
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
9977
|
+
var _a, _b, _c;
|
|
9978
|
+
const textTheme = this.getGraphicTheme(),
|
|
9979
|
+
textMeasure = application.graphicUtil.textMeasure;
|
|
9980
|
+
let width;
|
|
9981
|
+
const attribute = this.attribute,
|
|
9982
|
+
{
|
|
9983
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
9984
|
+
} = attribute,
|
|
9985
|
+
buf = ignoreBuf ? 0 : 2,
|
|
9948
9986
|
{
|
|
9949
9987
|
maxLineWidth = textTheme.maxLineWidth,
|
|
9950
9988
|
ellipsis = textTheme.ellipsis,
|
|
@@ -9956,14 +9994,14 @@ class Text extends Graphic {
|
|
|
9956
9994
|
verticalMode = textTheme.verticalMode,
|
|
9957
9995
|
suffixPosition = textTheme.suffixPosition
|
|
9958
9996
|
} = attribute,
|
|
9959
|
-
lineHeight =
|
|
9997
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
9960
9998
|
let {
|
|
9961
9999
|
textAlign = textTheme.textAlign,
|
|
9962
10000
|
textBaseline = textTheme.textBaseline
|
|
9963
10001
|
} = attribute;
|
|
9964
10002
|
if (!verticalMode) {
|
|
9965
10003
|
const t = textAlign;
|
|
9966
|
-
textAlign = null !== (
|
|
10004
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
9967
10005
|
}
|
|
9968
10006
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
9969
10007
|
this.cache.verticalList.forEach(item => {
|
|
@@ -10011,15 +10049,6 @@ class Text extends Graphic {
|
|
|
10011
10049
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
10012
10050
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
10013
10051
|
}
|
|
10014
|
-
getMaxWidth(theme) {
|
|
10015
|
-
var _a, _b;
|
|
10016
|
-
const attribute = this.attribute;
|
|
10017
|
-
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
10018
|
-
}
|
|
10019
|
-
getLineHeight(attribute, textTheme) {
|
|
10020
|
-
var _a;
|
|
10021
|
-
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
10022
|
-
}
|
|
10023
10052
|
needUpdateTags(keys) {
|
|
10024
10053
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
10025
10054
|
return super.needUpdateTags(keys, k);
|
|
@@ -10034,12 +10063,6 @@ class Text extends Graphic {
|
|
|
10034
10063
|
getNoWorkAnimateAttr() {
|
|
10035
10064
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
10036
10065
|
}
|
|
10037
|
-
getBaselineMapAlign() {
|
|
10038
|
-
return Text.baselineMapAlign;
|
|
10039
|
-
}
|
|
10040
|
-
getAlignMapBaseline() {
|
|
10041
|
-
return Text.alignMapBaseline;
|
|
10042
|
-
}
|
|
10043
10066
|
}
|
|
10044
10067
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
10045
10068
|
ellipsis: 1,
|
|
@@ -10118,10 +10141,7 @@ class WrapText extends Text {
|
|
|
10118
10141
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10119
10142
|
linesLayout.push({
|
|
10120
10143
|
str: clip.str,
|
|
10121
|
-
width: clip.width
|
|
10122
|
-
ascent: 0,
|
|
10123
|
-
descent: 0,
|
|
10124
|
-
keepCenterInLine: !1
|
|
10144
|
+
width: clip.width
|
|
10125
10145
|
});
|
|
10126
10146
|
break;
|
|
10127
10147
|
}
|
|
@@ -10135,10 +10155,7 @@ class WrapText extends Text {
|
|
|
10135
10155
|
}
|
|
10136
10156
|
if (linesLayout.push({
|
|
10137
10157
|
str: clip.str,
|
|
10138
|
-
width: clip.width
|
|
10139
|
-
ascent: 0,
|
|
10140
|
-
descent: 0,
|
|
10141
|
-
keepCenterInLine: !1
|
|
10158
|
+
width: clip.width
|
|
10142
10159
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
10143
10160
|
const newStr = str.substring(clip.str.length);
|
|
10144
10161
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -10157,19 +10174,13 @@ class WrapText extends Text {
|
|
|
10157
10174
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10158
10175
|
linesLayout.push({
|
|
10159
10176
|
str: clip.str,
|
|
10160
|
-
width: clip.width
|
|
10161
|
-
ascent: 0,
|
|
10162
|
-
descent: 0,
|
|
10163
|
-
keepCenterInLine: !1
|
|
10177
|
+
width: clip.width
|
|
10164
10178
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
10165
10179
|
break;
|
|
10166
10180
|
}
|
|
10167
10181
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
10168
10182
|
str: text,
|
|
10169
|
-
width: width
|
|
10170
|
-
ascent: 0,
|
|
10171
|
-
descent: 0,
|
|
10172
|
-
keepCenterInLine: !1
|
|
10183
|
+
width: width
|
|
10173
10184
|
});
|
|
10174
10185
|
}
|
|
10175
10186
|
bboxWH[0] = lineWidth;
|
|
@@ -10213,9 +10224,6 @@ class BaseSymbol {
|
|
|
10213
10224
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
10214
10225
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
10215
10226
|
}
|
|
10216
|
-
parseSize(size) {
|
|
10217
|
-
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10218
|
-
}
|
|
10219
10227
|
}
|
|
10220
10228
|
|
|
10221
10229
|
function circle(ctx, r, x, y, z) {
|
|
@@ -10226,13 +10234,13 @@ class CircleSymbol extends BaseSymbol {
|
|
|
10226
10234
|
super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
|
|
10227
10235
|
}
|
|
10228
10236
|
draw(ctx, size, x, y, z) {
|
|
10229
|
-
return circle(ctx,
|
|
10237
|
+
return circle(ctx, size / 2, x, y, z);
|
|
10230
10238
|
}
|
|
10231
10239
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10232
|
-
return circle(ctx,
|
|
10240
|
+
return circle(ctx, size / 2 + offset, x, y, z);
|
|
10233
10241
|
}
|
|
10234
10242
|
drawToSvgPath(size, x, y, z) {
|
|
10235
|
-
const r =
|
|
10243
|
+
const r = size / 2;
|
|
10236
10244
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
10237
10245
|
}
|
|
10238
10246
|
}
|
|
@@ -10249,10 +10257,10 @@ class CrossSymbol extends BaseSymbol {
|
|
|
10249
10257
|
super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
|
|
10250
10258
|
}
|
|
10251
10259
|
draw(ctx, size, x, y, z) {
|
|
10252
|
-
return cross(ctx,
|
|
10260
|
+
return cross(ctx, size / 6, x, y, z);
|
|
10253
10261
|
}
|
|
10254
10262
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10255
|
-
return crossOffset(ctx,
|
|
10263
|
+
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
10256
10264
|
}
|
|
10257
10265
|
}
|
|
10258
10266
|
var cross$1 = new CrossSymbol();
|
|
@@ -10265,13 +10273,13 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
10265
10273
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
10266
10274
|
}
|
|
10267
10275
|
draw(ctx, size, x, y, z) {
|
|
10268
|
-
return diamond(ctx,
|
|
10276
|
+
return diamond(ctx, size / 2, x, y, z);
|
|
10269
10277
|
}
|
|
10270
10278
|
drawFitDir(ctx, size, x, y, z) {
|
|
10271
|
-
return diamond(ctx,
|
|
10279
|
+
return diamond(ctx, size / 2, x, y, z);
|
|
10272
10280
|
}
|
|
10273
10281
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10274
|
-
return diamond(ctx,
|
|
10282
|
+
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
10275
10283
|
}
|
|
10276
10284
|
}
|
|
10277
10285
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -10285,10 +10293,10 @@ class SquareSymbol extends BaseSymbol {
|
|
|
10285
10293
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
10286
10294
|
}
|
|
10287
10295
|
draw(ctx, size, x, y) {
|
|
10288
|
-
return square(ctx,
|
|
10296
|
+
return square(ctx, size / 2, x, y);
|
|
10289
10297
|
}
|
|
10290
10298
|
drawOffset(ctx, size, x, y, offset) {
|
|
10291
|
-
return square(ctx,
|
|
10299
|
+
return square(ctx, size / 2 + offset, x, y);
|
|
10292
10300
|
}
|
|
10293
10301
|
}
|
|
10294
10302
|
var square$1 = new SquareSymbol();
|
|
@@ -10302,10 +10310,10 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
10302
10310
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
10303
10311
|
}
|
|
10304
10312
|
draw(ctx, size, x, y) {
|
|
10305
|
-
return trianglUpOffset(ctx,
|
|
10313
|
+
return trianglUpOffset(ctx, size / 2, x, y);
|
|
10306
10314
|
}
|
|
10307
10315
|
drawOffset(ctx, size, x, y, offset) {
|
|
10308
|
-
return trianglUpOffset(ctx,
|
|
10316
|
+
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
10309
10317
|
}
|
|
10310
10318
|
}
|
|
10311
10319
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -10337,10 +10345,10 @@ class StarSymbol extends BaseSymbol {
|
|
|
10337
10345
|
super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
|
|
10338
10346
|
}
|
|
10339
10347
|
draw(ctx, size, transX, transY) {
|
|
10340
|
-
return star(ctx,
|
|
10348
|
+
return star(ctx, size / 2, transX, transY);
|
|
10341
10349
|
}
|
|
10342
10350
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10343
|
-
return star(ctx,
|
|
10351
|
+
return star(ctx, size / 2 + offset, transX, transY);
|
|
10344
10352
|
}
|
|
10345
10353
|
}
|
|
10346
10354
|
var star$1 = new StarSymbol();
|
|
@@ -10358,10 +10366,10 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
10358
10366
|
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
|
|
10359
10367
|
}
|
|
10360
10368
|
draw(ctx, size, transX, transY) {
|
|
10361
|
-
return arrow(ctx,
|
|
10369
|
+
return arrow(ctx, size / 2, transX, transY);
|
|
10362
10370
|
}
|
|
10363
10371
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10364
|
-
return arrow(ctx,
|
|
10372
|
+
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
10365
10373
|
}
|
|
10366
10374
|
}
|
|
10367
10375
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -10375,10 +10383,10 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
10375
10383
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
10376
10384
|
}
|
|
10377
10385
|
draw(ctx, size, transX, transY) {
|
|
10378
|
-
return wedge(ctx,
|
|
10386
|
+
return wedge(ctx, size / 2, transX, transY);
|
|
10379
10387
|
}
|
|
10380
10388
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10381
|
-
return wedge(ctx,
|
|
10389
|
+
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
10382
10390
|
}
|
|
10383
10391
|
}
|
|
10384
10392
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -10391,10 +10399,10 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
10391
10399
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
10392
10400
|
}
|
|
10393
10401
|
draw(ctx, size, transX, transY) {
|
|
10394
|
-
return stroke(ctx,
|
|
10402
|
+
return stroke(ctx, size / 2, transX, transY);
|
|
10395
10403
|
}
|
|
10396
10404
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10397
|
-
return stroke(ctx,
|
|
10405
|
+
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
10398
10406
|
}
|
|
10399
10407
|
}
|
|
10400
10408
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -10416,10 +10424,10 @@ class WyeSymbol extends BaseSymbol {
|
|
|
10416
10424
|
super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
|
|
10417
10425
|
}
|
|
10418
10426
|
draw(ctx, size, transX, transY) {
|
|
10419
|
-
return wye(ctx,
|
|
10427
|
+
return wye(ctx, size / 2, transX, transY);
|
|
10420
10428
|
}
|
|
10421
10429
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10422
|
-
return wye(ctx,
|
|
10430
|
+
return wye(ctx, size / 2 + offset, transX, transY);
|
|
10423
10431
|
}
|
|
10424
10432
|
}
|
|
10425
10433
|
var wye$1 = new WyeSymbol();
|
|
@@ -10432,10 +10440,10 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
10432
10440
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
10433
10441
|
}
|
|
10434
10442
|
draw(ctx, size, x, y) {
|
|
10435
|
-
return trianglLeftOffset(ctx,
|
|
10443
|
+
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
10436
10444
|
}
|
|
10437
10445
|
drawOffset(ctx, size, x, y, offset) {
|
|
10438
|
-
return trianglLeftOffset(ctx,
|
|
10446
|
+
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
10439
10447
|
}
|
|
10440
10448
|
}
|
|
10441
10449
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -10449,10 +10457,10 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
10449
10457
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
10450
10458
|
}
|
|
10451
10459
|
draw(ctx, size, x, y) {
|
|
10452
|
-
return trianglRightOffset(ctx,
|
|
10460
|
+
return trianglRightOffset(ctx, size / 2, x, y);
|
|
10453
10461
|
}
|
|
10454
10462
|
drawOffset(ctx, size, x, y, offset) {
|
|
10455
|
-
return trianglRightOffset(ctx,
|
|
10463
|
+
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
10456
10464
|
}
|
|
10457
10465
|
}
|
|
10458
10466
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -10466,10 +10474,10 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
10466
10474
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
10467
10475
|
}
|
|
10468
10476
|
draw(ctx, size, x, y) {
|
|
10469
|
-
return trianglDownOffset(ctx,
|
|
10477
|
+
return trianglDownOffset(ctx, size / 2, x, y);
|
|
10470
10478
|
}
|
|
10471
10479
|
drawOffset(ctx, size, x, y, offset) {
|
|
10472
|
-
return trianglDownOffset(ctx,
|
|
10480
|
+
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
10473
10481
|
}
|
|
10474
10482
|
}
|
|
10475
10483
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -10484,10 +10492,10 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
10484
10492
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
10485
10493
|
}
|
|
10486
10494
|
draw(ctx, size, x, y) {
|
|
10487
|
-
return thinTriangle(ctx,
|
|
10495
|
+
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
10488
10496
|
}
|
|
10489
10497
|
drawOffset(ctx, size, x, y, offset) {
|
|
10490
|
-
return thinTriangle(ctx,
|
|
10498
|
+
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
10491
10499
|
}
|
|
10492
10500
|
}
|
|
10493
10501
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -10501,10 +10509,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
10501
10509
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
10502
10510
|
}
|
|
10503
10511
|
draw(ctx, size, transX, transY) {
|
|
10504
|
-
return arrow2Left(ctx,
|
|
10512
|
+
return arrow2Left(ctx, size / 4, transX, transY);
|
|
10505
10513
|
}
|
|
10506
10514
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10507
|
-
return arrow2Left(ctx,
|
|
10515
|
+
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
10508
10516
|
}
|
|
10509
10517
|
}
|
|
10510
10518
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -10518,10 +10526,10 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
10518
10526
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
10519
10527
|
}
|
|
10520
10528
|
draw(ctx, size, transX, transY) {
|
|
10521
|
-
return arrow2Right(ctx,
|
|
10529
|
+
return arrow2Right(ctx, size / 4, transX, transY);
|
|
10522
10530
|
}
|
|
10523
10531
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10524
|
-
return arrow2Right(ctx,
|
|
10532
|
+
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
10525
10533
|
}
|
|
10526
10534
|
}
|
|
10527
10535
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -10535,10 +10543,10 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
10535
10543
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
10536
10544
|
}
|
|
10537
10545
|
draw(ctx, size, transX, transY) {
|
|
10538
|
-
return arrow2Up(ctx,
|
|
10546
|
+
return arrow2Up(ctx, size / 4, transX, transY);
|
|
10539
10547
|
}
|
|
10540
10548
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10541
|
-
return arrow2Up(ctx,
|
|
10549
|
+
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
10542
10550
|
}
|
|
10543
10551
|
}
|
|
10544
10552
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -10552,10 +10560,10 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
10552
10560
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
10553
10561
|
}
|
|
10554
10562
|
draw(ctx, size, transX, transY) {
|
|
10555
|
-
return arrow2Down(ctx,
|
|
10563
|
+
return arrow2Down(ctx, size / 4, transX, transY);
|
|
10556
10564
|
}
|
|
10557
10565
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10558
|
-
return arrow2Down(ctx,
|
|
10566
|
+
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
10559
10567
|
}
|
|
10560
10568
|
}
|
|
10561
10569
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -10568,13 +10576,13 @@ class LineVSymbol extends BaseSymbol {
|
|
|
10568
10576
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
10569
10577
|
}
|
|
10570
10578
|
draw(ctx, size, x, y, z) {
|
|
10571
|
-
return lineV(ctx,
|
|
10579
|
+
return lineV(ctx, size / 2, x, y);
|
|
10572
10580
|
}
|
|
10573
10581
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10574
|
-
return lineV(ctx,
|
|
10582
|
+
return lineV(ctx, size / 2 + offset, x, y);
|
|
10575
10583
|
}
|
|
10576
10584
|
drawToSvgPath(size, x, y, z) {
|
|
10577
|
-
const r =
|
|
10585
|
+
const r = size / 2;
|
|
10578
10586
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
10579
10587
|
}
|
|
10580
10588
|
}
|
|
@@ -10588,13 +10596,13 @@ class LineHSymbol extends BaseSymbol {
|
|
|
10588
10596
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
10589
10597
|
}
|
|
10590
10598
|
draw(ctx, size, x, y, z) {
|
|
10591
|
-
return lineH(ctx,
|
|
10599
|
+
return lineH(ctx, size / 2, x, y);
|
|
10592
10600
|
}
|
|
10593
10601
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10594
|
-
return lineH(ctx,
|
|
10602
|
+
return lineH(ctx, size / 2 + offset, x, y);
|
|
10595
10603
|
}
|
|
10596
10604
|
drawToSvgPath(size, x, y, z) {
|
|
10597
|
-
const r =
|
|
10605
|
+
const r = size / 2;
|
|
10598
10606
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
10599
10607
|
}
|
|
10600
10608
|
}
|
|
@@ -10608,13 +10616,13 @@ class CloseSymbol extends BaseSymbol {
|
|
|
10608
10616
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
10609
10617
|
}
|
|
10610
10618
|
draw(ctx, size, x, y, z) {
|
|
10611
|
-
return close(ctx,
|
|
10619
|
+
return close(ctx, size / 2, x, y);
|
|
10612
10620
|
}
|
|
10613
10621
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10614
|
-
return close(ctx,
|
|
10622
|
+
return close(ctx, size / 2 + offset, x, y);
|
|
10615
10623
|
}
|
|
10616
10624
|
drawToSvgPath(size, x, y, z) {
|
|
10617
|
-
const r =
|
|
10625
|
+
const r = size / 2;
|
|
10618
10626
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
10619
10627
|
}
|
|
10620
10628
|
}
|
|
@@ -10648,18 +10656,15 @@ class CustomSymbolClass {
|
|
|
10648
10656
|
this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
10649
10657
|
}
|
|
10650
10658
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
10651
|
-
return
|
|
10659
|
+
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10652
10660
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
10653
10661
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
10654
10662
|
}
|
|
10655
10663
|
draw(ctx, size, x, y, z, cb) {
|
|
10656
|
-
return
|
|
10657
|
-
}
|
|
10658
|
-
parseSize(size) {
|
|
10659
|
-
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10664
|
+
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10660
10665
|
}
|
|
10661
10666
|
bounds(size, bounds) {
|
|
10662
|
-
if (
|
|
10667
|
+
if (this.isSvg) {
|
|
10663
10668
|
if (!this.svgCache) return;
|
|
10664
10669
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
10665
10670
|
let {
|
|
@@ -11163,11 +11168,7 @@ class Paragraph {
|
|
|
11163
11168
|
case "sub":
|
|
11164
11169
|
baseline += this.descent / 2;
|
|
11165
11170
|
}
|
|
11166
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
11167
|
-
const {
|
|
11168
|
-
lineWidth = 1
|
|
11169
|
-
} = this.character;
|
|
11170
|
-
this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
11171
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
11171
11172
|
}
|
|
11172
11173
|
getWidthWithEllips(direction) {
|
|
11173
11174
|
let text = this.text;
|
|
@@ -13354,9 +13355,8 @@ class PickerBase {
|
|
|
13354
13355
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
13355
13356
|
if (picked) return !0;
|
|
13356
13357
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13357
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13358
|
-
|
|
13359
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13358
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
13359
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13360
13360
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13361
13361
|
}
|
|
13362
13362
|
}
|
|
@@ -13578,9 +13578,8 @@ class RectPickerBase {
|
|
|
13578
13578
|
if (!onlyTranslate || rect.shadowRoot || isNumber(cornerRadius, !0) && 0 !== cornerRadius || isArray(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
13579
13579
|
if (picked) return !0;
|
|
13580
13580
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13581
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13582
|
-
|
|
13583
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13581
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
13582
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13584
13583
|
});else {
|
|
13585
13584
|
const {
|
|
13586
13585
|
fill = rectAttribute.fill,
|
|
@@ -13759,9 +13758,8 @@ class BaseLinePicker extends BaseRender {
|
|
|
13759
13758
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
13760
13759
|
if (picked) return !0;
|
|
13761
13760
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13762
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13763
|
-
|
|
13764
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13761
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
13762
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13765
13763
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13766
13764
|
}
|
|
13767
13765
|
}
|
|
@@ -13896,9 +13894,8 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
13896
13894
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
13897
13895
|
if (picked) return !0;
|
|
13898
13896
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13899
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13900
|
-
|
|
13901
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13897
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
13898
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13902
13899
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13903
13900
|
}
|
|
13904
13901
|
};
|
|
@@ -14458,374 +14455,92 @@ class ScrollBar extends AbstractComponent {
|
|
|
14458
14455
|
const [min, max] = clampRange(limitRange, 0, 1);
|
|
14459
14456
|
const { width, height, x1, y1 } = this.getSliderRenderBounds();
|
|
14460
14457
|
const sliderSize = this._sliderSize;
|
|
14461
|
-
return direction === 'horizontal'
|
|
14462
|
-
? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
|
|
14463
|
-
: clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
|
|
14464
|
-
}
|
|
14465
|
-
_reset() {
|
|
14466
|
-
this._sliderRenderBounds = null;
|
|
14467
|
-
this._sliderLimitRange = null;
|
|
14468
|
-
}
|
|
14469
|
-
}
|
|
14470
|
-
ScrollBar.defaultAttributes = {
|
|
14471
|
-
direction: 'horizontal',
|
|
14472
|
-
round: true,
|
|
14473
|
-
sliderSize: 20,
|
|
14474
|
-
sliderStyle: {
|
|
14475
|
-
fill: 'rgba(0, 0, 0, .5)'
|
|
14476
|
-
},
|
|
14477
|
-
railStyle: {
|
|
14478
|
-
fill: 'rgba(0, 0, 0, .0)'
|
|
14479
|
-
},
|
|
14480
|
-
padding: 2,
|
|
14481
|
-
scrollRange: [0, 1],
|
|
14482
|
-
delayType: 'throttle',
|
|
14483
|
-
delayTime: 0,
|
|
14484
|
-
realTime: true
|
|
14485
|
-
};
|
|
14486
|
-
|
|
14487
|
-
/******************************************************************************
|
|
14488
|
-
Copyright (c) Microsoft Corporation.
|
|
14489
|
-
|
|
14490
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14491
|
-
purpose with or without fee is hereby granted.
|
|
14492
|
-
|
|
14493
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14494
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14495
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14496
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14497
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14498
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14499
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14500
|
-
***************************************************************************** */
|
|
14501
|
-
function __rest(s, e) {
|
|
14502
|
-
var t = {};
|
|
14503
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14504
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14505
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
14506
|
-
}
|
|
14507
|
-
return t;
|
|
14508
|
-
}
|
|
14509
|
-
function __decorate(decorators, target, key, desc) {
|
|
14510
|
-
var c = arguments.length,
|
|
14511
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
14512
|
-
d;
|
|
14513
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14514
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14515
|
-
}
|
|
14516
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14517
|
-
function adopt(value) {
|
|
14518
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
14519
|
-
resolve(value);
|
|
14520
|
-
});
|
|
14521
|
-
}
|
|
14522
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14523
|
-
function fulfilled(value) {
|
|
14524
|
-
try {
|
|
14525
|
-
step(generator.next(value));
|
|
14526
|
-
} catch (e) {
|
|
14527
|
-
reject(e);
|
|
14528
|
-
}
|
|
14529
|
-
}
|
|
14530
|
-
function rejected(value) {
|
|
14531
|
-
try {
|
|
14532
|
-
step(generator["throw"](value));
|
|
14533
|
-
} catch (e) {
|
|
14534
|
-
reject(e);
|
|
14535
|
-
}
|
|
14536
|
-
}
|
|
14537
|
-
function step(result) {
|
|
14538
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
14539
|
-
}
|
|
14540
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14541
|
-
});
|
|
14542
|
-
}
|
|
14543
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
14544
|
-
var e = new Error(message);
|
|
14545
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14546
|
-
};
|
|
14547
|
-
|
|
14548
|
-
var ScrollBarPlugin_1;
|
|
14549
|
-
let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
|
|
14550
|
-
constructor() {
|
|
14551
|
-
this.name = 'scrollbar';
|
|
14552
|
-
this.activeEvent = 'onRegister';
|
|
14553
|
-
this._uid = Generator.GenAutoIncrementId();
|
|
14554
|
-
this.key = this.name + this._uid;
|
|
14555
|
-
this.scroll = (e) => {
|
|
14556
|
-
var _a, _b;
|
|
14557
|
-
const graphic = e.target;
|
|
14558
|
-
const data = this.getScrollContainer(graphic);
|
|
14559
|
-
if (!data && !this.scrollContainer) {
|
|
14560
|
-
return;
|
|
14561
|
-
}
|
|
14562
|
-
if (!data && this.scrollContainer) {
|
|
14563
|
-
if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
|
|
14564
|
-
return;
|
|
14565
|
-
}
|
|
14566
|
-
const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
|
|
14567
|
-
if (!newScrollContainer) {
|
|
14568
|
-
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14569
|
-
return;
|
|
14570
|
-
}
|
|
14571
|
-
if (this.scrollContainer.showH && !newScrollContainer.showH) {
|
|
14572
|
-
this.clearScrollbar(this.scrollContainer.g, 'horizontal');
|
|
14573
|
-
}
|
|
14574
|
-
if (this.scrollContainer.showV && !newScrollContainer.showV) {
|
|
14575
|
-
this.clearScrollbar(this.scrollContainer.g, 'vertical');
|
|
14576
|
-
}
|
|
14577
|
-
this.scrollContainer = newScrollContainer;
|
|
14578
|
-
}
|
|
14579
|
-
else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
|
|
14580
|
-
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14581
|
-
}
|
|
14582
|
-
this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
|
|
14583
|
-
const scrollContainer = data.g;
|
|
14584
|
-
const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
|
|
14585
|
-
let newScrollX = scrollX;
|
|
14586
|
-
let newScrollY = scrollY;
|
|
14587
|
-
let { showH, showV } = data;
|
|
14588
|
-
this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
|
|
14589
|
-
if (showH && showH) {
|
|
14590
|
-
if (abs(e.deltaX) > abs(e.deltaY)) {
|
|
14591
|
-
showH = showH && true;
|
|
14592
|
-
showV = showV && false;
|
|
14593
|
-
}
|
|
14594
|
-
else {
|
|
14595
|
-
showH = showH && false;
|
|
14596
|
-
showV = showV && true;
|
|
14597
|
-
}
|
|
14598
|
-
}
|
|
14599
|
-
const childrenBounds = this.childrenBounds;
|
|
14600
|
-
childrenBounds.clear();
|
|
14601
|
-
childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
|
|
14602
|
-
const scrollWidth = childrenBounds.width();
|
|
14603
|
-
const scrollHeight = childrenBounds.height();
|
|
14604
|
-
if (showH) {
|
|
14605
|
-
newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
|
|
14606
|
-
}
|
|
14607
|
-
else {
|
|
14608
|
-
newScrollX = -scrollX;
|
|
14609
|
-
}
|
|
14610
|
-
if (showV) {
|
|
14611
|
-
newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
|
|
14612
|
-
}
|
|
14613
|
-
else {
|
|
14614
|
-
newScrollY = -scrollY;
|
|
14615
|
-
}
|
|
14616
|
-
childrenBounds.translate(-newScrollX, -newScrollY);
|
|
14617
|
-
this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
|
|
14618
|
-
scrollContainer.setAttributes({
|
|
14619
|
-
scrollX: -newScrollX,
|
|
14620
|
-
scrollY: -newScrollY
|
|
14621
|
-
});
|
|
14622
|
-
};
|
|
14623
|
-
this.handleScrollBarChange = (params) => {
|
|
14624
|
-
if (!this.scrollContainer ||
|
|
14625
|
-
!this.scrollContainerBounds ||
|
|
14626
|
-
!this.childrenBounds ||
|
|
14627
|
-
!params ||
|
|
14628
|
-
!params.target ||
|
|
14629
|
-
!params.detail ||
|
|
14630
|
-
!params.detail.value) {
|
|
14631
|
-
return;
|
|
14632
|
-
}
|
|
14633
|
-
const scrollbar = params.target;
|
|
14634
|
-
const newRange = params.detail.value;
|
|
14635
|
-
if (scrollbar.attribute.direction === 'horizontal') {
|
|
14636
|
-
const scrollWidth = this.childrenBounds.width();
|
|
14637
|
-
this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
|
|
14638
|
-
}
|
|
14639
|
-
else {
|
|
14640
|
-
const scrollHeight = this.childrenBounds.height();
|
|
14641
|
-
this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
|
|
14642
|
-
}
|
|
14643
|
-
};
|
|
14644
|
-
}
|
|
14645
|
-
activate(context) {
|
|
14646
|
-
this.pluginService = context;
|
|
14647
|
-
const { stage } = this.pluginService;
|
|
14648
|
-
this.childrenBounds = new AABBBounds();
|
|
14649
|
-
stage.addEventListener('wheel', this.scroll);
|
|
14650
|
-
this.params = ScrollBarPlugin_1.defaultParams;
|
|
14651
|
-
}
|
|
14652
|
-
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
14653
|
-
scrollContainer.addEventListener('pointerover', () => {
|
|
14654
|
-
scrollbar.setAttribute('visibleAll', true);
|
|
14655
|
-
});
|
|
14656
|
-
scrollContainer.addEventListener('pointermove', () => {
|
|
14657
|
-
scrollbar.setAttribute('visibleAll', true);
|
|
14658
|
-
});
|
|
14659
|
-
scrollContainer.addEventListener('pointerout', () => {
|
|
14660
|
-
scrollbar.setAttribute('visibleAll', false);
|
|
14661
|
-
});
|
|
14662
|
-
scrollbar.addEventListener('pointerover', () => {
|
|
14663
|
-
scrollbar.setAttribute('visibleAll', true);
|
|
14664
|
-
});
|
|
14665
|
-
scrollbar.addEventListener('pointerout', () => {
|
|
14666
|
-
scrollbar.setAttribute('visibleAll', true);
|
|
14667
|
-
});
|
|
14668
|
-
scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
|
|
14669
|
-
scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
|
|
14670
|
-
}
|
|
14671
|
-
addOrUpdateScroll(showH, showV, container, scrollContainer) {
|
|
14672
|
-
if (showH) {
|
|
14673
|
-
const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
|
|
14674
|
-
if (!isUpdate) {
|
|
14675
|
-
this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
|
|
14676
|
-
}
|
|
14677
|
-
}
|
|
14678
|
-
else {
|
|
14679
|
-
this.clearScrollbar(scrollContainer, 'horizontal');
|
|
14680
|
-
}
|
|
14681
|
-
if (showV) {
|
|
14682
|
-
const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
|
|
14683
|
-
if (!isUpdate) {
|
|
14684
|
-
this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
|
|
14685
|
-
}
|
|
14686
|
-
}
|
|
14687
|
-
else {
|
|
14688
|
-
this.clearScrollbar(scrollContainer, 'vertical');
|
|
14689
|
-
}
|
|
14690
|
-
}
|
|
14691
|
-
getDirection(isHorozntal) {
|
|
14692
|
-
return isHorozntal ? 'horizontal' : 'vertical';
|
|
14693
|
-
}
|
|
14694
|
-
addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
|
|
14695
|
-
var _a;
|
|
14696
|
-
const direction = this.getDirection(isHorozntal);
|
|
14697
|
-
const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
|
|
14698
|
-
const scrollbars = container.children.filter((g) => g.name === name);
|
|
14699
|
-
let isUpdate = true;
|
|
14700
|
-
let scrollBar = scrollbars[0];
|
|
14701
|
-
const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
|
|
14702
|
-
const attrs = {
|
|
14703
|
-
x: 0,
|
|
14704
|
-
y: 0,
|
|
14705
|
-
direction,
|
|
14706
|
-
zIndex: zIndex + 1,
|
|
14707
|
-
visibleAll: true,
|
|
14708
|
-
padding: [2, 0],
|
|
14709
|
-
railStyle: {
|
|
14710
|
-
fill: 'rgba(0, 0, 0, .1)'
|
|
14711
|
-
},
|
|
14712
|
-
range: [0, 0.05]
|
|
14713
|
-
};
|
|
14714
|
-
if (isHorozntal) {
|
|
14715
|
-
attrs.width = this.scrollContainerBounds.width();
|
|
14716
|
-
attrs.height = 12;
|
|
14717
|
-
}
|
|
14718
|
-
else {
|
|
14719
|
-
attrs.height = this.scrollContainerBounds.height();
|
|
14720
|
-
attrs.width = 12;
|
|
14721
|
-
}
|
|
14722
|
-
if (!scrollBar) {
|
|
14723
|
-
isUpdate = false;
|
|
14724
|
-
scrollBar = new ScrollBar(attrs);
|
|
14725
|
-
scrollBar.name = name;
|
|
14726
|
-
container.add(scrollBar);
|
|
14727
|
-
scrollBar.isScrollBar = true;
|
|
14728
|
-
}
|
|
14729
|
-
else if (scrollbars.length > 1) {
|
|
14730
|
-
scrollbars.forEach((child, index) => {
|
|
14731
|
-
var _a;
|
|
14732
|
-
if (index) {
|
|
14733
|
-
(_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
|
14734
|
-
}
|
|
14735
|
-
});
|
|
14736
|
-
}
|
|
14737
|
-
const childrenBounds = this.childrenBounds;
|
|
14738
|
-
if (isHorozntal) {
|
|
14739
|
-
const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
|
|
14740
|
-
const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
|
|
14741
|
-
attrs.x = x + dx;
|
|
14742
|
-
attrs.y = y + dy + height - this.scrollContainerBounds.height();
|
|
14743
|
-
attrs.range = [-start, -start + ratio];
|
|
14744
|
-
}
|
|
14745
|
-
else {
|
|
14746
|
-
const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
|
|
14747
|
-
const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
|
|
14748
|
-
attrs.x = x + dx + width - this.scrollContainerBounds.width();
|
|
14749
|
-
attrs.y = y + dy;
|
|
14750
|
-
attrs.range = [-start, -start + ratio];
|
|
14751
|
-
}
|
|
14752
|
-
scrollBar.setAttributes(attrs);
|
|
14753
|
-
return {
|
|
14754
|
-
scrollBar,
|
|
14755
|
-
isUpdate
|
|
14756
|
-
};
|
|
14757
|
-
}
|
|
14758
|
-
clearScrollbar(scrollContainer, type) {
|
|
14759
|
-
if (!scrollContainer.parent) {
|
|
14760
|
-
return;
|
|
14761
|
-
}
|
|
14762
|
-
const scrollbarBars = scrollContainer.parent.children.filter((child) => {
|
|
14763
|
-
return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
|
|
14764
|
-
});
|
|
14765
|
-
scrollbarBars.forEach((child) => {
|
|
14766
|
-
child.parent.removeChild(child);
|
|
14767
|
-
});
|
|
14768
|
-
}
|
|
14769
|
-
formatScrollContainer(g) {
|
|
14770
|
-
if (!g || g.type !== 'group' || !g.attribute) {
|
|
14771
|
-
return null;
|
|
14772
|
-
}
|
|
14773
|
-
const { overflow, width, height } = g.attribute;
|
|
14774
|
-
if (!overflow || overflow === 'hidden') {
|
|
14775
|
-
return null;
|
|
14776
|
-
}
|
|
14777
|
-
let showH = false;
|
|
14778
|
-
let showV = false;
|
|
14779
|
-
if (overflow === 'scroll') {
|
|
14780
|
-
showH = true;
|
|
14781
|
-
showV = true;
|
|
14782
|
-
}
|
|
14783
|
-
else {
|
|
14784
|
-
showH = overflow === 'scroll-x';
|
|
14785
|
-
showV = !showH;
|
|
14786
|
-
}
|
|
14787
|
-
if (!g.AABBBounds.empty()) {
|
|
14788
|
-
if (showH) {
|
|
14789
|
-
showH = width < g.AABBBounds.width();
|
|
14790
|
-
}
|
|
14791
|
-
if (showV) {
|
|
14792
|
-
showV = height < g.AABBBounds.height();
|
|
14793
|
-
}
|
|
14794
|
-
}
|
|
14795
|
-
return showH || showV ? { g: g, showH, showV } : null;
|
|
14796
|
-
}
|
|
14797
|
-
getScrollContainer(graphic) {
|
|
14798
|
-
let g = graphic;
|
|
14799
|
-
while (g) {
|
|
14800
|
-
const res = this.formatScrollContainer(g);
|
|
14801
|
-
if (res) {
|
|
14802
|
-
return res;
|
|
14803
|
-
}
|
|
14804
|
-
g = g.parent;
|
|
14805
|
-
}
|
|
14806
|
-
return null;
|
|
14458
|
+
return direction === 'horizontal'
|
|
14459
|
+
? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
|
|
14460
|
+
: clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
|
|
14807
14461
|
}
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
|
|
14462
|
+
_reset() {
|
|
14463
|
+
this._sliderRenderBounds = null;
|
|
14464
|
+
this._sliderLimitRange = null;
|
|
14811
14465
|
}
|
|
14466
|
+
}
|
|
14467
|
+
ScrollBar.defaultAttributes = {
|
|
14468
|
+
direction: 'horizontal',
|
|
14469
|
+
round: true,
|
|
14470
|
+
sliderSize: 20,
|
|
14471
|
+
sliderStyle: {
|
|
14472
|
+
fill: 'rgba(0, 0, 0, .5)'
|
|
14473
|
+
},
|
|
14474
|
+
railStyle: {
|
|
14475
|
+
fill: 'rgba(0, 0, 0, .0)'
|
|
14476
|
+
},
|
|
14477
|
+
padding: 2,
|
|
14478
|
+
scrollRange: [0, 1],
|
|
14479
|
+
delayType: 'throttle',
|
|
14480
|
+
delayTime: 0,
|
|
14481
|
+
realTime: true
|
|
14812
14482
|
};
|
|
14813
|
-
ScrollBarPlugin.defaultParams = {
|
|
14814
|
-
timeout: 500
|
|
14815
|
-
};
|
|
14816
|
-
ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
|
|
14817
|
-
injectable()
|
|
14818
|
-
], ScrollBarPlugin);
|
|
14819
14483
|
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14484
|
+
/******************************************************************************
|
|
14485
|
+
Copyright (c) Microsoft Corporation.
|
|
14486
|
+
|
|
14487
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14488
|
+
purpose with or without fee is hereby granted.
|
|
14489
|
+
|
|
14490
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14491
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14492
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14493
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14494
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14495
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14496
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14497
|
+
***************************************************************************** */
|
|
14498
|
+
function __rest(s, e) {
|
|
14499
|
+
var t = {};
|
|
14500
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14501
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14502
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
14503
|
+
}
|
|
14504
|
+
return t;
|
|
14505
|
+
}
|
|
14506
|
+
function __decorate(decorators, target, key, desc) {
|
|
14507
|
+
var c = arguments.length,
|
|
14508
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
14509
|
+
d;
|
|
14510
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14511
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14512
|
+
}
|
|
14513
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14514
|
+
function adopt(value) {
|
|
14515
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
14516
|
+
resolve(value);
|
|
14517
|
+
});
|
|
14518
|
+
}
|
|
14519
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14520
|
+
function fulfilled(value) {
|
|
14521
|
+
try {
|
|
14522
|
+
step(generator.next(value));
|
|
14523
|
+
} catch (e) {
|
|
14524
|
+
reject(e);
|
|
14525
|
+
}
|
|
14824
14526
|
}
|
|
14825
|
-
|
|
14826
|
-
|
|
14827
|
-
|
|
14527
|
+
function rejected(value) {
|
|
14528
|
+
try {
|
|
14529
|
+
step(generator["throw"](value));
|
|
14530
|
+
} catch (e) {
|
|
14531
|
+
reject(e);
|
|
14532
|
+
}
|
|
14533
|
+
}
|
|
14534
|
+
function step(result) {
|
|
14535
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
14536
|
+
}
|
|
14537
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14538
|
+
});
|
|
14828
14539
|
}
|
|
14540
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
14541
|
+
var e = new Error(message);
|
|
14542
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14543
|
+
};
|
|
14829
14544
|
|
|
14830
14545
|
function traverseGroup(group, cb) {
|
|
14831
14546
|
group.forEachChildren(node => {
|
|
@@ -16284,29 +15999,24 @@ function defaultLabelPosition(type) {
|
|
|
16284
15999
|
return DefaultPositions;
|
|
16285
16000
|
}
|
|
16286
16001
|
}
|
|
16287
|
-
function clampText(text, width, height
|
|
16002
|
+
function clampText(text, width, height) {
|
|
16288
16003
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16289
|
-
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
16290
16004
|
const minX = Math.min(x1, x2);
|
|
16291
16005
|
const maxX = Math.max(x1, x2);
|
|
16292
16006
|
const minY = Math.min(y1, y2);
|
|
16293
16007
|
const maxY = Math.max(y1, y2);
|
|
16294
|
-
const minXWithPadding = 0 - left;
|
|
16295
|
-
const maxXWithPadding = width + right;
|
|
16296
|
-
const minYWithPadding = 0 - top;
|
|
16297
|
-
const maxYWithPadding = height + bottom;
|
|
16298
16008
|
let dx = 0;
|
|
16299
16009
|
let dy = 0;
|
|
16300
|
-
if (minX <
|
|
16010
|
+
if (minX < 0 && maxX - minX <= width) {
|
|
16301
16011
|
dx = -minX;
|
|
16302
16012
|
}
|
|
16303
|
-
else if (maxX >
|
|
16013
|
+
else if (maxX > width && minX - (maxX - width) >= 0) {
|
|
16304
16014
|
dx = width - maxX;
|
|
16305
16015
|
}
|
|
16306
|
-
if (minY <
|
|
16016
|
+
if (minY < 0 && maxY - minY <= height) {
|
|
16307
16017
|
dy = -minY;
|
|
16308
16018
|
}
|
|
16309
|
-
else if (maxY >
|
|
16019
|
+
else if (maxY > height && minY - (maxY - height) >= 0) {
|
|
16310
16020
|
dy = height - maxY;
|
|
16311
16021
|
}
|
|
16312
16022
|
return { dx, dy };
|
|
@@ -16606,121 +16316,56 @@ function loadLabelComponent() {
|
|
|
16606
16316
|
registerLine();
|
|
16607
16317
|
}
|
|
16608
16318
|
|
|
16609
|
-
|
|
16610
|
-
|
|
16611
|
-
};
|
|
16612
|
-
const isXIntersect = ([a, b], [c, d]) => {
|
|
16613
|
-
return d > a && b > c;
|
|
16614
|
-
};
|
|
16615
|
-
function getIntersectionLength(range1, range2) {
|
|
16616
|
-
const [start1, end1] = range1;
|
|
16617
|
-
const [start2, end2] = range2;
|
|
16618
|
-
const start = Math.max(start1, start2);
|
|
16619
|
-
const end = Math.min(end1, end2);
|
|
16620
|
-
return Math.max(0, end - start);
|
|
16621
|
-
}
|
|
16622
|
-
function shiftY(texts, option) {
|
|
16623
|
-
const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
|
|
16319
|
+
function shiftY(texts, option = {}) {
|
|
16320
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE } = option;
|
|
16624
16321
|
const n = texts.length;
|
|
16625
16322
|
if (n <= 1) {
|
|
16626
16323
|
return texts;
|
|
16627
16324
|
}
|
|
16628
|
-
const
|
|
16325
|
+
const isIntersect = ([a, b], [c, d]) => {
|
|
16326
|
+
return d > a && b > c;
|
|
16327
|
+
};
|
|
16629
16328
|
const textInformation = new Map();
|
|
16630
|
-
const
|
|
16631
|
-
const getHeight = (text) => textInformation.get(text).height;
|
|
16632
|
-
const getY1 = (text) => textInformation.get(text).y1;
|
|
16329
|
+
const getY0 = (text) => textInformation.get(text).y0;
|
|
16633
16330
|
const getY = (text) => textInformation.get(text).y;
|
|
16634
|
-
const
|
|
16331
|
+
const getHeight = (text) => textInformation.get(text).height;
|
|
16635
16332
|
const getX1 = (text) => textInformation.get(text).x1;
|
|
16636
16333
|
const getX2 = (text) => textInformation.get(text).x2;
|
|
16637
|
-
const
|
|
16638
|
-
textInformation.get(text).
|
|
16334
|
+
const setY = (text, y) => {
|
|
16335
|
+
textInformation.get(text).y = y;
|
|
16639
16336
|
};
|
|
16640
|
-
function adjustPositionInOneGroup(texts) {
|
|
16641
|
-
if (texts.length === 1) {
|
|
16642
|
-
return;
|
|
16643
|
-
}
|
|
16644
|
-
for (let i = texts.length - 1; i > 0; i--) {
|
|
16645
|
-
const curText = texts[i];
|
|
16646
|
-
const upperText = texts[i - 1];
|
|
16647
|
-
const lowerText = texts[i + 1];
|
|
16648
|
-
if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
|
|
16649
|
-
const { y } = labelling(curText);
|
|
16650
|
-
if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
|
|
16651
|
-
if (y + getHeight(curText) / 2 <= maxY) {
|
|
16652
|
-
setY1(curText, getY1(curText) + y - getY(curText));
|
|
16653
|
-
}
|
|
16654
|
-
}
|
|
16655
|
-
}
|
|
16656
|
-
}
|
|
16657
|
-
}
|
|
16658
|
-
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16659
16337
|
for (const text of texts) {
|
|
16660
16338
|
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16661
|
-
|
|
16662
|
-
textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
|
|
16663
|
-
let hasRange = false;
|
|
16664
|
-
for (const [range, xGroupTexts] of xMap) {
|
|
16665
|
-
const { start, end } = range;
|
|
16666
|
-
if (x1 >= start && x2 <= end) {
|
|
16667
|
-
xGroupTexts.push(text);
|
|
16668
|
-
hasRange = true;
|
|
16669
|
-
}
|
|
16670
|
-
else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
|
|
16671
|
-
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16672
|
-
xGroupTexts.push(text);
|
|
16673
|
-
xMap.set(newRange, xGroupTexts);
|
|
16674
|
-
xMap.delete(range);
|
|
16675
|
-
hasRange = true;
|
|
16676
|
-
}
|
|
16677
|
-
else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
|
|
16678
|
-
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16679
|
-
xGroupTexts.push(text);
|
|
16680
|
-
xMap.set(newRange, xGroupTexts);
|
|
16681
|
-
xMap.delete(range);
|
|
16682
|
-
hasRange = true;
|
|
16683
|
-
}
|
|
16684
|
-
if (hasRange) {
|
|
16685
|
-
break;
|
|
16686
|
-
}
|
|
16687
|
-
}
|
|
16688
|
-
if (!hasRange) {
|
|
16689
|
-
xMap.set({ start: x1, end: x2 }, [text]);
|
|
16690
|
-
}
|
|
16691
|
-
}
|
|
16692
|
-
for (const xTexts of xMap.values()) {
|
|
16693
|
-
xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
|
|
16694
|
-
adjustPositionInOneGroup(xTexts);
|
|
16339
|
+
textInformation.set(text, { y0: y1, y: y1, height: y2 - y1, x1, x2 });
|
|
16695
16340
|
}
|
|
16696
16341
|
for (let iter = 0; iter < maxIterations; iter++) {
|
|
16697
|
-
texts.sort((a, b) =>
|
|
16342
|
+
texts.sort((a, b) => getY(a) - getY(b));
|
|
16698
16343
|
let error = 0;
|
|
16699
16344
|
for (let i = 0; i < n - 1; i++) {
|
|
16700
16345
|
const curText = texts[i];
|
|
16701
16346
|
let j = i + 1;
|
|
16702
16347
|
let nextText;
|
|
16703
16348
|
while ((nextText = texts[j]) &&
|
|
16704
|
-
!
|
|
16349
|
+
!isIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
|
|
16705
16350
|
j += 1;
|
|
16706
16351
|
}
|
|
16707
16352
|
if (nextText) {
|
|
16708
|
-
const
|
|
16353
|
+
const y0 = getY(curText);
|
|
16709
16354
|
const h0 = getHeight(curText);
|
|
16710
|
-
const
|
|
16711
|
-
const delta =
|
|
16355
|
+
const y1 = getY(nextText);
|
|
16356
|
+
const delta = y1 - (y0 + h0);
|
|
16712
16357
|
if (delta < padding) {
|
|
16713
16358
|
const newDelta = (padding - delta) / 2;
|
|
16714
16359
|
error = Math.max(error, newDelta);
|
|
16715
16360
|
if (y1 + newDelta + getHeight(nextText) > maxY) {
|
|
16716
|
-
|
|
16361
|
+
setY(curText, y0 - (padding - delta));
|
|
16717
16362
|
}
|
|
16718
|
-
else if (
|
|
16719
|
-
|
|
16363
|
+
else if (y0 - newDelta < 0) {
|
|
16364
|
+
setY(nextText, y1 + (padding - delta));
|
|
16720
16365
|
}
|
|
16721
16366
|
else {
|
|
16722
|
-
|
|
16723
|
-
|
|
16367
|
+
setY(curText, y0 - newDelta);
|
|
16368
|
+
setY(nextText, y1 + newDelta);
|
|
16724
16369
|
}
|
|
16725
16370
|
}
|
|
16726
16371
|
}
|
|
@@ -16730,25 +16375,10 @@ function shiftY(texts, option) {
|
|
|
16730
16375
|
}
|
|
16731
16376
|
}
|
|
16732
16377
|
for (const text of texts) {
|
|
16733
|
-
const finalY = text.attribute.y +
|
|
16378
|
+
const finalY = text.attribute.y + getY(text) - getY0(text);
|
|
16734
16379
|
text.setAttribute('y', finalY);
|
|
16735
16380
|
}
|
|
16736
|
-
|
|
16737
|
-
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16738
|
-
let start = 0;
|
|
16739
|
-
let end = texts.length - 1;
|
|
16740
|
-
while (start <= end) {
|
|
16741
|
-
if (start === end) {
|
|
16742
|
-
result.push(texts[start]);
|
|
16743
|
-
}
|
|
16744
|
-
else {
|
|
16745
|
-
result.push(texts[start]);
|
|
16746
|
-
result.push(texts[end]);
|
|
16747
|
-
}
|
|
16748
|
-
start++;
|
|
16749
|
-
end--;
|
|
16750
|
-
}
|
|
16751
|
-
return result;
|
|
16381
|
+
return texts;
|
|
16752
16382
|
}
|
|
16753
16383
|
|
|
16754
16384
|
loadLabelComponent();
|
|
@@ -17094,25 +16724,18 @@ class LabelBase extends AbstractComponent {
|
|
|
17094
16724
|
if (clampForce) {
|
|
17095
16725
|
for (let i = 0; i < result.length; i++) {
|
|
17096
16726
|
const text = labels[i];
|
|
17097
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height
|
|
16727
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17098
16728
|
if (dx !== 0 || dy !== 0) {
|
|
17099
16729
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
17100
|
-
text._isClamped = true;
|
|
17101
16730
|
}
|
|
17102
16731
|
}
|
|
17103
16732
|
}
|
|
17104
|
-
result = shiftY(result, Object.assign(
|
|
17105
|
-
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
17106
|
-
const graphicBound = this._isCollectionBase
|
|
17107
|
-
? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
|
|
17108
|
-
: this.getGraphicBounds(baseMark, text);
|
|
17109
|
-
return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
|
|
17110
|
-
} }));
|
|
16733
|
+
result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy));
|
|
17111
16734
|
for (let i = 0; i < result.length; i++) {
|
|
17112
16735
|
const text = result[i];
|
|
17113
16736
|
const bounds = text.AABBBounds;
|
|
17114
16737
|
const range = boundToRange(bmpTool, bounds, true);
|
|
17115
|
-
if (canPlace(bmpTool, bitmap, bounds, clampForce,
|
|
16738
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
|
|
17116
16739
|
bitmap.setRange(range);
|
|
17117
16740
|
}
|
|
17118
16741
|
else {
|
|
@@ -17185,7 +16808,7 @@ class LabelBase extends AbstractComponent {
|
|
|
17185
16808
|
}
|
|
17186
16809
|
}
|
|
17187
16810
|
if (!hasPlace && clampForce) {
|
|
17188
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height
|
|
16811
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17189
16812
|
if (dx === 0 && dy === 0) {
|
|
17190
16813
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
17191
16814
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -17669,9 +17292,6 @@ class ArcLabel extends LabelBase {
|
|
|
17669
17292
|
this._alignOffset = 0;
|
|
17670
17293
|
}
|
|
17671
17294
|
_overlapping(labels) {
|
|
17672
|
-
if (['inside', 'inside-center'].includes(this.attribute.position)) {
|
|
17673
|
-
return super._overlapping(labels);
|
|
17674
|
-
}
|
|
17675
17295
|
return labels;
|
|
17676
17296
|
}
|
|
17677
17297
|
labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
|
|
@@ -29938,6 +29558,690 @@ EmptyTip.defaultAttributes = {
|
|
|
29938
29558
|
}
|
|
29939
29559
|
};
|
|
29940
29560
|
|
|
29941
|
-
|
|
29561
|
+
var lib$1 = {};
|
|
29562
|
+
|
|
29563
|
+
var gif = {};
|
|
29564
|
+
|
|
29565
|
+
var lib = {};
|
|
29566
|
+
|
|
29567
|
+
Object.defineProperty(lib, "__esModule", {
|
|
29568
|
+
value: true
|
|
29569
|
+
});
|
|
29570
|
+
lib.loop = lib.conditional = lib.parse = void 0;
|
|
29571
|
+
var parse = function parse(stream, schema) {
|
|
29572
|
+
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
29573
|
+
var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : result;
|
|
29574
|
+
if (Array.isArray(schema)) {
|
|
29575
|
+
schema.forEach(function (partSchema) {
|
|
29576
|
+
return parse(stream, partSchema, result, parent);
|
|
29577
|
+
});
|
|
29578
|
+
} else if (typeof schema === 'function') {
|
|
29579
|
+
schema(stream, result, parent, parse);
|
|
29580
|
+
} else {
|
|
29581
|
+
var key = Object.keys(schema)[0];
|
|
29582
|
+
if (Array.isArray(schema[key])) {
|
|
29583
|
+
parent[key] = {};
|
|
29584
|
+
parse(stream, schema[key], result, parent[key]);
|
|
29585
|
+
} else {
|
|
29586
|
+
parent[key] = schema[key](stream, result, parent, parse);
|
|
29587
|
+
}
|
|
29588
|
+
}
|
|
29589
|
+
return result;
|
|
29590
|
+
};
|
|
29591
|
+
lib.parse = parse;
|
|
29592
|
+
var conditional = function conditional(schema, conditionFunc) {
|
|
29593
|
+
return function (stream, result, parent, parse) {
|
|
29594
|
+
if (conditionFunc(stream, result, parent)) {
|
|
29595
|
+
parse(stream, schema, result, parent);
|
|
29596
|
+
}
|
|
29597
|
+
};
|
|
29598
|
+
};
|
|
29599
|
+
lib.conditional = conditional;
|
|
29600
|
+
var loop = function loop(schema, continueFunc) {
|
|
29601
|
+
return function (stream, result, parent, parse) {
|
|
29602
|
+
var arr = [];
|
|
29603
|
+
var lastStreamPos = stream.pos;
|
|
29604
|
+
while (continueFunc(stream, result, parent)) {
|
|
29605
|
+
var newParent = {};
|
|
29606
|
+
parse(stream, schema, result, newParent); // cases when whole file is parsed but no termination is there and stream position is not getting updated as well
|
|
29607
|
+
// it falls into infinite recursion, null check to avoid the same
|
|
29608
|
+
|
|
29609
|
+
if (stream.pos === lastStreamPos) {
|
|
29610
|
+
break;
|
|
29611
|
+
}
|
|
29612
|
+
lastStreamPos = stream.pos;
|
|
29613
|
+
arr.push(newParent);
|
|
29614
|
+
}
|
|
29615
|
+
return arr;
|
|
29616
|
+
};
|
|
29617
|
+
};
|
|
29618
|
+
lib.loop = loop;
|
|
29619
|
+
|
|
29620
|
+
var uint8 = {};
|
|
29621
|
+
|
|
29622
|
+
Object.defineProperty(uint8, "__esModule", {
|
|
29623
|
+
value: true
|
|
29624
|
+
});
|
|
29625
|
+
uint8.readBits = uint8.readArray = uint8.readUnsigned = uint8.readString = uint8.peekBytes = uint8.readBytes = uint8.peekByte = uint8.readByte = uint8.buildStream = void 0;
|
|
29626
|
+
|
|
29627
|
+
// Default stream and parsers for Uint8TypedArray data type
|
|
29628
|
+
var buildStream = function buildStream(uint8Data) {
|
|
29629
|
+
return {
|
|
29630
|
+
data: uint8Data,
|
|
29631
|
+
pos: 0
|
|
29632
|
+
};
|
|
29633
|
+
};
|
|
29634
|
+
uint8.buildStream = buildStream;
|
|
29635
|
+
var readByte = function readByte() {
|
|
29636
|
+
return function (stream) {
|
|
29637
|
+
return stream.data[stream.pos++];
|
|
29638
|
+
};
|
|
29639
|
+
};
|
|
29640
|
+
uint8.readByte = readByte;
|
|
29641
|
+
var peekByte = function peekByte() {
|
|
29642
|
+
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
29643
|
+
return function (stream) {
|
|
29644
|
+
return stream.data[stream.pos + offset];
|
|
29645
|
+
};
|
|
29646
|
+
};
|
|
29647
|
+
uint8.peekByte = peekByte;
|
|
29648
|
+
var readBytes = function readBytes(length) {
|
|
29649
|
+
return function (stream) {
|
|
29650
|
+
return stream.data.subarray(stream.pos, stream.pos += length);
|
|
29651
|
+
};
|
|
29652
|
+
};
|
|
29653
|
+
uint8.readBytes = readBytes;
|
|
29654
|
+
var peekBytes = function peekBytes(length) {
|
|
29655
|
+
return function (stream) {
|
|
29656
|
+
return stream.data.subarray(stream.pos, stream.pos + length);
|
|
29657
|
+
};
|
|
29658
|
+
};
|
|
29659
|
+
uint8.peekBytes = peekBytes;
|
|
29660
|
+
var readString = function readString(length) {
|
|
29661
|
+
return function (stream) {
|
|
29662
|
+
return Array.from(readBytes(length)(stream)).map(function (value) {
|
|
29663
|
+
return String.fromCharCode(value);
|
|
29664
|
+
}).join('');
|
|
29665
|
+
};
|
|
29666
|
+
};
|
|
29667
|
+
uint8.readString = readString;
|
|
29668
|
+
var readUnsigned = function readUnsigned(littleEndian) {
|
|
29669
|
+
return function (stream) {
|
|
29670
|
+
var bytes = readBytes(2)(stream);
|
|
29671
|
+
return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1];
|
|
29672
|
+
};
|
|
29673
|
+
};
|
|
29674
|
+
uint8.readUnsigned = readUnsigned;
|
|
29675
|
+
var readArray = function readArray(byteSize, totalOrFunc) {
|
|
29676
|
+
return function (stream, result, parent) {
|
|
29677
|
+
var total = typeof totalOrFunc === 'function' ? totalOrFunc(stream, result, parent) : totalOrFunc;
|
|
29678
|
+
var parser = readBytes(byteSize);
|
|
29679
|
+
var arr = new Array(total);
|
|
29680
|
+
for (var i = 0; i < total; i++) {
|
|
29681
|
+
arr[i] = parser(stream);
|
|
29682
|
+
}
|
|
29683
|
+
return arr;
|
|
29684
|
+
};
|
|
29685
|
+
};
|
|
29686
|
+
uint8.readArray = readArray;
|
|
29687
|
+
var subBitsTotal = function subBitsTotal(bits, startIndex, length) {
|
|
29688
|
+
var result = 0;
|
|
29689
|
+
for (var i = 0; i < length; i++) {
|
|
29690
|
+
result += bits[startIndex + i] && Math.pow(2, length - i - 1);
|
|
29691
|
+
}
|
|
29692
|
+
return result;
|
|
29693
|
+
};
|
|
29694
|
+
var readBits = function readBits(schema) {
|
|
29695
|
+
return function (stream) {
|
|
29696
|
+
var _byte = readByte()(stream); // convert the byte to bit array
|
|
29697
|
+
|
|
29698
|
+
var bits = new Array(8);
|
|
29699
|
+
for (var i = 0; i < 8; i++) {
|
|
29700
|
+
bits[7 - i] = !!(_byte & 1 << i);
|
|
29701
|
+
} // convert the bit array to values based on the schema
|
|
29702
|
+
|
|
29703
|
+
return Object.keys(schema).reduce(function (res, key) {
|
|
29704
|
+
var def = schema[key];
|
|
29705
|
+
if (def.length) {
|
|
29706
|
+
res[key] = subBitsTotal(bits, def.index, def.length);
|
|
29707
|
+
} else {
|
|
29708
|
+
res[key] = bits[def.index];
|
|
29709
|
+
}
|
|
29710
|
+
return res;
|
|
29711
|
+
}, {});
|
|
29712
|
+
};
|
|
29713
|
+
};
|
|
29714
|
+
uint8.readBits = readBits;
|
|
29715
|
+
|
|
29716
|
+
(function (exports) {
|
|
29717
|
+
|
|
29718
|
+
Object.defineProperty(exports, "__esModule", {
|
|
29719
|
+
value: true
|
|
29720
|
+
});
|
|
29721
|
+
exports["default"] = void 0;
|
|
29722
|
+
var _ = lib;
|
|
29723
|
+
var _uint = uint8;
|
|
29724
|
+
|
|
29725
|
+
// a set of 0x00 terminated subblocks
|
|
29726
|
+
var subBlocksSchema = {
|
|
29727
|
+
blocks: function blocks(stream) {
|
|
29728
|
+
var terminator = 0x00;
|
|
29729
|
+
var chunks = [];
|
|
29730
|
+
var streamSize = stream.data.length;
|
|
29731
|
+
var total = 0;
|
|
29732
|
+
for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) {
|
|
29733
|
+
// size becomes undefined for some case when file is corrupted and terminator is not proper
|
|
29734
|
+
// null check to avoid recursion
|
|
29735
|
+
if (!size) break; // catch corrupted files with no terminator
|
|
29736
|
+
|
|
29737
|
+
if (stream.pos + size >= streamSize) {
|
|
29738
|
+
var availableSize = streamSize - stream.pos;
|
|
29739
|
+
chunks.push((0, _uint.readBytes)(availableSize)(stream));
|
|
29740
|
+
total += availableSize;
|
|
29741
|
+
break;
|
|
29742
|
+
}
|
|
29743
|
+
chunks.push((0, _uint.readBytes)(size)(stream));
|
|
29744
|
+
total += size;
|
|
29745
|
+
}
|
|
29746
|
+
var result = new Uint8Array(total);
|
|
29747
|
+
var offset = 0;
|
|
29748
|
+
for (var i = 0; i < chunks.length; i++) {
|
|
29749
|
+
result.set(chunks[i], offset);
|
|
29750
|
+
offset += chunks[i].length;
|
|
29751
|
+
}
|
|
29752
|
+
return result;
|
|
29753
|
+
}
|
|
29754
|
+
}; // global control extension
|
|
29755
|
+
|
|
29756
|
+
var gceSchema = (0, _.conditional)({
|
|
29757
|
+
gce: [{
|
|
29758
|
+
codes: (0, _uint.readBytes)(2)
|
|
29759
|
+
}, {
|
|
29760
|
+
byteSize: (0, _uint.readByte)()
|
|
29761
|
+
}, {
|
|
29762
|
+
extras: (0, _uint.readBits)({
|
|
29763
|
+
future: {
|
|
29764
|
+
index: 0,
|
|
29765
|
+
length: 3
|
|
29766
|
+
},
|
|
29767
|
+
disposal: {
|
|
29768
|
+
index: 3,
|
|
29769
|
+
length: 3
|
|
29770
|
+
},
|
|
29771
|
+
userInput: {
|
|
29772
|
+
index: 6
|
|
29773
|
+
},
|
|
29774
|
+
transparentColorGiven: {
|
|
29775
|
+
index: 7
|
|
29776
|
+
}
|
|
29777
|
+
})
|
|
29778
|
+
}, {
|
|
29779
|
+
delay: (0, _uint.readUnsigned)(true)
|
|
29780
|
+
}, {
|
|
29781
|
+
transparentColorIndex: (0, _uint.readByte)()
|
|
29782
|
+
}, {
|
|
29783
|
+
terminator: (0, _uint.readByte)()
|
|
29784
|
+
}]
|
|
29785
|
+
}, function (stream) {
|
|
29786
|
+
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29787
|
+
return codes[0] === 0x21 && codes[1] === 0xf9;
|
|
29788
|
+
}); // image pipeline block
|
|
29789
|
+
|
|
29790
|
+
var imageSchema = (0, _.conditional)({
|
|
29791
|
+
image: [{
|
|
29792
|
+
code: (0, _uint.readByte)()
|
|
29793
|
+
}, {
|
|
29794
|
+
descriptor: [{
|
|
29795
|
+
left: (0, _uint.readUnsigned)(true)
|
|
29796
|
+
}, {
|
|
29797
|
+
top: (0, _uint.readUnsigned)(true)
|
|
29798
|
+
}, {
|
|
29799
|
+
width: (0, _uint.readUnsigned)(true)
|
|
29800
|
+
}, {
|
|
29801
|
+
height: (0, _uint.readUnsigned)(true)
|
|
29802
|
+
}, {
|
|
29803
|
+
lct: (0, _uint.readBits)({
|
|
29804
|
+
exists: {
|
|
29805
|
+
index: 0
|
|
29806
|
+
},
|
|
29807
|
+
interlaced: {
|
|
29808
|
+
index: 1
|
|
29809
|
+
},
|
|
29810
|
+
sort: {
|
|
29811
|
+
index: 2
|
|
29812
|
+
},
|
|
29813
|
+
future: {
|
|
29814
|
+
index: 3,
|
|
29815
|
+
length: 2
|
|
29816
|
+
},
|
|
29817
|
+
size: {
|
|
29818
|
+
index: 5,
|
|
29819
|
+
length: 3
|
|
29820
|
+
}
|
|
29821
|
+
})
|
|
29822
|
+
}]
|
|
29823
|
+
}, (0, _.conditional)({
|
|
29824
|
+
lct: (0, _uint.readArray)(3, function (stream, result, parent) {
|
|
29825
|
+
return Math.pow(2, parent.descriptor.lct.size + 1);
|
|
29826
|
+
})
|
|
29827
|
+
}, function (stream, result, parent) {
|
|
29828
|
+
return parent.descriptor.lct.exists;
|
|
29829
|
+
}), {
|
|
29830
|
+
data: [{
|
|
29831
|
+
minCodeSize: (0, _uint.readByte)()
|
|
29832
|
+
}, subBlocksSchema]
|
|
29833
|
+
}]
|
|
29834
|
+
}, function (stream) {
|
|
29835
|
+
return (0, _uint.peekByte)()(stream) === 0x2c;
|
|
29836
|
+
}); // plain text block
|
|
29837
|
+
|
|
29838
|
+
var textSchema = (0, _.conditional)({
|
|
29839
|
+
text: [{
|
|
29840
|
+
codes: (0, _uint.readBytes)(2)
|
|
29841
|
+
}, {
|
|
29842
|
+
blockSize: (0, _uint.readByte)()
|
|
29843
|
+
}, {
|
|
29844
|
+
preData: function preData(stream, result, parent) {
|
|
29845
|
+
return (0, _uint.readBytes)(parent.text.blockSize)(stream);
|
|
29846
|
+
}
|
|
29847
|
+
}, subBlocksSchema]
|
|
29848
|
+
}, function (stream) {
|
|
29849
|
+
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29850
|
+
return codes[0] === 0x21 && codes[1] === 0x01;
|
|
29851
|
+
}); // application block
|
|
29852
|
+
|
|
29853
|
+
var applicationSchema = (0, _.conditional)({
|
|
29854
|
+
application: [{
|
|
29855
|
+
codes: (0, _uint.readBytes)(2)
|
|
29856
|
+
}, {
|
|
29857
|
+
blockSize: (0, _uint.readByte)()
|
|
29858
|
+
}, {
|
|
29859
|
+
id: function id(stream, result, parent) {
|
|
29860
|
+
return (0, _uint.readString)(parent.blockSize)(stream);
|
|
29861
|
+
}
|
|
29862
|
+
}, subBlocksSchema]
|
|
29863
|
+
}, function (stream) {
|
|
29864
|
+
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29865
|
+
return codes[0] === 0x21 && codes[1] === 0xff;
|
|
29866
|
+
}); // comment block
|
|
29867
|
+
|
|
29868
|
+
var commentSchema = (0, _.conditional)({
|
|
29869
|
+
comment: [{
|
|
29870
|
+
codes: (0, _uint.readBytes)(2)
|
|
29871
|
+
}, subBlocksSchema]
|
|
29872
|
+
}, function (stream) {
|
|
29873
|
+
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29874
|
+
return codes[0] === 0x21 && codes[1] === 0xfe;
|
|
29875
|
+
});
|
|
29876
|
+
var schema = [{
|
|
29877
|
+
header: [{
|
|
29878
|
+
signature: (0, _uint.readString)(3)
|
|
29879
|
+
}, {
|
|
29880
|
+
version: (0, _uint.readString)(3)
|
|
29881
|
+
}]
|
|
29882
|
+
}, {
|
|
29883
|
+
lsd: [{
|
|
29884
|
+
width: (0, _uint.readUnsigned)(true)
|
|
29885
|
+
}, {
|
|
29886
|
+
height: (0, _uint.readUnsigned)(true)
|
|
29887
|
+
}, {
|
|
29888
|
+
gct: (0, _uint.readBits)({
|
|
29889
|
+
exists: {
|
|
29890
|
+
index: 0
|
|
29891
|
+
},
|
|
29892
|
+
resolution: {
|
|
29893
|
+
index: 1,
|
|
29894
|
+
length: 3
|
|
29895
|
+
},
|
|
29896
|
+
sort: {
|
|
29897
|
+
index: 4
|
|
29898
|
+
},
|
|
29899
|
+
size: {
|
|
29900
|
+
index: 5,
|
|
29901
|
+
length: 3
|
|
29902
|
+
}
|
|
29903
|
+
})
|
|
29904
|
+
}, {
|
|
29905
|
+
backgroundColorIndex: (0, _uint.readByte)()
|
|
29906
|
+
}, {
|
|
29907
|
+
pixelAspectRatio: (0, _uint.readByte)()
|
|
29908
|
+
}]
|
|
29909
|
+
}, (0, _.conditional)({
|
|
29910
|
+
gct: (0, _uint.readArray)(3, function (stream, result) {
|
|
29911
|
+
return Math.pow(2, result.lsd.gct.size + 1);
|
|
29912
|
+
})
|
|
29913
|
+
}, function (stream, result) {
|
|
29914
|
+
return result.lsd.gct.exists;
|
|
29915
|
+
}),
|
|
29916
|
+
// content frames
|
|
29917
|
+
{
|
|
29918
|
+
frames: (0, _.loop)([gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], function (stream) {
|
|
29919
|
+
var nextCode = (0, _uint.peekByte)()(stream); // rather than check for a terminator, we should check for the existence
|
|
29920
|
+
// of an ext or image block to avoid infinite loops
|
|
29921
|
+
//var terminator = 0x3B;
|
|
29922
|
+
//return nextCode !== terminator;
|
|
29923
|
+
|
|
29924
|
+
return nextCode === 0x21 || nextCode === 0x2c;
|
|
29925
|
+
})
|
|
29926
|
+
}];
|
|
29927
|
+
var _default = schema;
|
|
29928
|
+
exports["default"] = _default;
|
|
29929
|
+
})(gif);
|
|
29930
|
+
|
|
29931
|
+
var deinterlace$1 = {};
|
|
29932
|
+
|
|
29933
|
+
Object.defineProperty(deinterlace$1, "__esModule", {
|
|
29934
|
+
value: true
|
|
29935
|
+
});
|
|
29936
|
+
deinterlace$1.deinterlace = void 0;
|
|
29937
|
+
|
|
29938
|
+
/**
|
|
29939
|
+
* Deinterlace function from https://github.com/shachaf/jsgif
|
|
29940
|
+
*/
|
|
29941
|
+
var deinterlace = function deinterlace(pixels, width) {
|
|
29942
|
+
var newPixels = new Array(pixels.length);
|
|
29943
|
+
var rows = pixels.length / width;
|
|
29944
|
+
var cpRow = function cpRow(toRow, fromRow) {
|
|
29945
|
+
var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
|
|
29946
|
+
newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
|
|
29947
|
+
}; // See appendix E.
|
|
29948
|
+
|
|
29949
|
+
var offsets = [0, 4, 2, 1];
|
|
29950
|
+
var steps = [8, 8, 4, 2];
|
|
29951
|
+
var fromRow = 0;
|
|
29952
|
+
for (var pass = 0; pass < 4; pass++) {
|
|
29953
|
+
for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
|
|
29954
|
+
cpRow(toRow, fromRow);
|
|
29955
|
+
fromRow++;
|
|
29956
|
+
}
|
|
29957
|
+
}
|
|
29958
|
+
return newPixels;
|
|
29959
|
+
};
|
|
29960
|
+
deinterlace$1.deinterlace = deinterlace;
|
|
29961
|
+
|
|
29962
|
+
var lzw$1 = {};
|
|
29963
|
+
|
|
29964
|
+
Object.defineProperty(lzw$1, "__esModule", {
|
|
29965
|
+
value: true
|
|
29966
|
+
});
|
|
29967
|
+
lzw$1.lzw = void 0;
|
|
29968
|
+
|
|
29969
|
+
/**
|
|
29970
|
+
* javascript port of java LZW decompression
|
|
29971
|
+
* Original java author url: https://gist.github.com/devunwired/4479231
|
|
29972
|
+
*/
|
|
29973
|
+
var lzw = function lzw(minCodeSize, data, pixelCount) {
|
|
29974
|
+
var MAX_STACK_SIZE = 4096;
|
|
29975
|
+
var nullCode = -1;
|
|
29976
|
+
var npix = pixelCount;
|
|
29977
|
+
var available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, i, datum, data_size, first, top, bi, pi;
|
|
29978
|
+
var dstPixels = new Array(pixelCount);
|
|
29979
|
+
var prefix = new Array(MAX_STACK_SIZE);
|
|
29980
|
+
var suffix = new Array(MAX_STACK_SIZE);
|
|
29981
|
+
var pixelStack = new Array(MAX_STACK_SIZE + 1); // Initialize GIF data stream decoder.
|
|
29982
|
+
|
|
29983
|
+
data_size = minCodeSize;
|
|
29984
|
+
clear = 1 << data_size;
|
|
29985
|
+
end_of_information = clear + 1;
|
|
29986
|
+
available = clear + 2;
|
|
29987
|
+
old_code = nullCode;
|
|
29988
|
+
code_size = data_size + 1;
|
|
29989
|
+
code_mask = (1 << code_size) - 1;
|
|
29990
|
+
for (code = 0; code < clear; code++) {
|
|
29991
|
+
prefix[code] = 0;
|
|
29992
|
+
suffix[code] = code;
|
|
29993
|
+
} // Decode GIF pixel stream.
|
|
29994
|
+
|
|
29995
|
+
var datum, bits, first, top, pi, bi;
|
|
29996
|
+
datum = bits = first = top = pi = bi = 0;
|
|
29997
|
+
for (i = 0; i < npix;) {
|
|
29998
|
+
if (top === 0) {
|
|
29999
|
+
if (bits < code_size) {
|
|
30000
|
+
// get the next byte
|
|
30001
|
+
datum += data[bi] << bits;
|
|
30002
|
+
bits += 8;
|
|
30003
|
+
bi++;
|
|
30004
|
+
continue;
|
|
30005
|
+
} // Get the next code.
|
|
30006
|
+
|
|
30007
|
+
code = datum & code_mask;
|
|
30008
|
+
datum >>= code_size;
|
|
30009
|
+
bits -= code_size; // Interpret the code
|
|
30010
|
+
|
|
30011
|
+
if (code > available || code == end_of_information) {
|
|
30012
|
+
break;
|
|
30013
|
+
}
|
|
30014
|
+
if (code == clear) {
|
|
30015
|
+
// Reset decoder.
|
|
30016
|
+
code_size = data_size + 1;
|
|
30017
|
+
code_mask = (1 << code_size) - 1;
|
|
30018
|
+
available = clear + 2;
|
|
30019
|
+
old_code = nullCode;
|
|
30020
|
+
continue;
|
|
30021
|
+
}
|
|
30022
|
+
if (old_code == nullCode) {
|
|
30023
|
+
pixelStack[top++] = suffix[code];
|
|
30024
|
+
old_code = code;
|
|
30025
|
+
first = code;
|
|
30026
|
+
continue;
|
|
30027
|
+
}
|
|
30028
|
+
in_code = code;
|
|
30029
|
+
if (code == available) {
|
|
30030
|
+
pixelStack[top++] = first;
|
|
30031
|
+
code = old_code;
|
|
30032
|
+
}
|
|
30033
|
+
while (code > clear) {
|
|
30034
|
+
pixelStack[top++] = suffix[code];
|
|
30035
|
+
code = prefix[code];
|
|
30036
|
+
}
|
|
30037
|
+
first = suffix[code] & 0xff;
|
|
30038
|
+
pixelStack[top++] = first; // add a new string to the table, but only if space is available
|
|
30039
|
+
// if not, just continue with current table until a clear code is found
|
|
30040
|
+
// (deferred clear code implementation as per GIF spec)
|
|
30041
|
+
|
|
30042
|
+
if (available < MAX_STACK_SIZE) {
|
|
30043
|
+
prefix[available] = old_code;
|
|
30044
|
+
suffix[available] = first;
|
|
30045
|
+
available++;
|
|
30046
|
+
if ((available & code_mask) === 0 && available < MAX_STACK_SIZE) {
|
|
30047
|
+
code_size++;
|
|
30048
|
+
code_mask += available;
|
|
30049
|
+
}
|
|
30050
|
+
}
|
|
30051
|
+
old_code = in_code;
|
|
30052
|
+
} // Pop a pixel off the pixel stack.
|
|
30053
|
+
|
|
30054
|
+
top--;
|
|
30055
|
+
dstPixels[pi++] = pixelStack[top];
|
|
30056
|
+
i++;
|
|
30057
|
+
}
|
|
30058
|
+
for (i = pi; i < npix; i++) {
|
|
30059
|
+
dstPixels[i] = 0; // clear missing pixels
|
|
30060
|
+
}
|
|
30061
|
+
|
|
30062
|
+
return dstPixels;
|
|
30063
|
+
};
|
|
30064
|
+
lzw$1.lzw = lzw;
|
|
30065
|
+
|
|
30066
|
+
Object.defineProperty(lib$1, "__esModule", {
|
|
30067
|
+
value: true
|
|
30068
|
+
});
|
|
30069
|
+
var decompressFrames_1 = lib$1.decompressFrames = lib$1.decompressFrame = parseGIF_1 = lib$1.parseGIF = void 0;
|
|
30070
|
+
var _gif = _interopRequireDefault(gif);
|
|
30071
|
+
var _jsBinarySchemaParser = lib;
|
|
30072
|
+
var _uint = uint8;
|
|
30073
|
+
var _deinterlace = deinterlace$1;
|
|
30074
|
+
var _lzw = lzw$1;
|
|
30075
|
+
function _interopRequireDefault(obj) {
|
|
30076
|
+
return obj && obj.__esModule ? obj : {
|
|
30077
|
+
"default": obj
|
|
30078
|
+
};
|
|
30079
|
+
}
|
|
30080
|
+
var parseGIF = function parseGIF(arrayBuffer) {
|
|
30081
|
+
var byteData = new Uint8Array(arrayBuffer);
|
|
30082
|
+
return (0, _jsBinarySchemaParser.parse)((0, _uint.buildStream)(byteData), _gif["default"]);
|
|
30083
|
+
};
|
|
30084
|
+
var parseGIF_1 = lib$1.parseGIF = parseGIF;
|
|
30085
|
+
var generatePatch = function generatePatch(image) {
|
|
30086
|
+
var totalPixels = image.pixels.length;
|
|
30087
|
+
var patchData = new Uint8ClampedArray(totalPixels * 4);
|
|
30088
|
+
for (var i = 0; i < totalPixels; i++) {
|
|
30089
|
+
var pos = i * 4;
|
|
30090
|
+
var colorIndex = image.pixels[i];
|
|
30091
|
+
var color = image.colorTable[colorIndex] || [0, 0, 0];
|
|
30092
|
+
patchData[pos] = color[0];
|
|
30093
|
+
patchData[pos + 1] = color[1];
|
|
30094
|
+
patchData[pos + 2] = color[2];
|
|
30095
|
+
patchData[pos + 3] = colorIndex !== image.transparentIndex ? 255 : 0;
|
|
30096
|
+
}
|
|
30097
|
+
return patchData;
|
|
30098
|
+
};
|
|
30099
|
+
var decompressFrame = function decompressFrame(frame, gct, buildImagePatch) {
|
|
30100
|
+
if (!frame.image) {
|
|
30101
|
+
console.warn('gif frame does not have associated image.');
|
|
30102
|
+
return;
|
|
30103
|
+
}
|
|
30104
|
+
var image = frame.image; // get the number of pixels
|
|
30105
|
+
|
|
30106
|
+
var totalPixels = image.descriptor.width * image.descriptor.height; // do lzw decompression
|
|
30107
|
+
|
|
30108
|
+
var pixels = (0, _lzw.lzw)(image.data.minCodeSize, image.data.blocks, totalPixels); // deal with interlacing if necessary
|
|
30109
|
+
|
|
30110
|
+
if (image.descriptor.lct.interlaced) {
|
|
30111
|
+
pixels = (0, _deinterlace.deinterlace)(pixels, image.descriptor.width);
|
|
30112
|
+
}
|
|
30113
|
+
var resultImage = {
|
|
30114
|
+
pixels: pixels,
|
|
30115
|
+
dims: {
|
|
30116
|
+
top: frame.image.descriptor.top,
|
|
30117
|
+
left: frame.image.descriptor.left,
|
|
30118
|
+
width: frame.image.descriptor.width,
|
|
30119
|
+
height: frame.image.descriptor.height
|
|
30120
|
+
}
|
|
30121
|
+
}; // color table
|
|
30122
|
+
|
|
30123
|
+
if (image.descriptor.lct && image.descriptor.lct.exists) {
|
|
30124
|
+
resultImage.colorTable = image.lct;
|
|
30125
|
+
} else {
|
|
30126
|
+
resultImage.colorTable = gct;
|
|
30127
|
+
} // add per frame relevant gce information
|
|
30128
|
+
|
|
30129
|
+
if (frame.gce) {
|
|
30130
|
+
resultImage.delay = (frame.gce.delay || 10) * 10; // convert to ms
|
|
30131
|
+
|
|
30132
|
+
resultImage.disposalType = frame.gce.extras.disposal; // transparency
|
|
30133
|
+
|
|
30134
|
+
if (frame.gce.extras.transparentColorGiven) {
|
|
30135
|
+
resultImage.transparentIndex = frame.gce.transparentColorIndex;
|
|
30136
|
+
}
|
|
30137
|
+
} // create canvas usable imagedata if desired
|
|
30138
|
+
|
|
30139
|
+
if (buildImagePatch) {
|
|
30140
|
+
resultImage.patch = generatePatch(resultImage);
|
|
30141
|
+
}
|
|
30142
|
+
return resultImage;
|
|
30143
|
+
};
|
|
30144
|
+
lib$1.decompressFrame = decompressFrame;
|
|
30145
|
+
var decompressFrames = function decompressFrames(parsedGif, buildImagePatches) {
|
|
30146
|
+
return parsedGif.frames.filter(function (f) {
|
|
30147
|
+
return f.image;
|
|
30148
|
+
}).map(function (f) {
|
|
30149
|
+
return decompressFrame(f, parsedGif.gct, buildImagePatches);
|
|
30150
|
+
});
|
|
30151
|
+
};
|
|
30152
|
+
decompressFrames_1 = lib$1.decompressFrames = decompressFrames;
|
|
30153
|
+
|
|
30154
|
+
class GifImage extends Image {
|
|
30155
|
+
constructor(params) {
|
|
30156
|
+
super(params);
|
|
30157
|
+
this.isGifImage = true;
|
|
30158
|
+
this.loadGif();
|
|
30159
|
+
}
|
|
30160
|
+
loadGif() {
|
|
30161
|
+
if (isString(this.attribute.gifImage)) {
|
|
30162
|
+
ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')
|
|
30163
|
+
.then((res) => {
|
|
30164
|
+
const gif = parseGIF_1(res);
|
|
30165
|
+
const frames = decompressFrames_1(gif, true);
|
|
30166
|
+
this.renderGIF(frames);
|
|
30167
|
+
})
|
|
30168
|
+
.catch(e => {
|
|
30169
|
+
console.error('Gif load error: ', e);
|
|
30170
|
+
});
|
|
30171
|
+
}
|
|
30172
|
+
else if (this.attribute.gifImage instanceof ArrayBuffer) {
|
|
30173
|
+
const gif = parseGIF_1(this.attribute.gifImage);
|
|
30174
|
+
const frames = decompressFrames_1(gif, true);
|
|
30175
|
+
this.renderGIF(frames);
|
|
30176
|
+
}
|
|
30177
|
+
}
|
|
30178
|
+
renderGIF(frames) {
|
|
30179
|
+
this.loadedFrames = frames;
|
|
30180
|
+
this.frameIndex = 0;
|
|
30181
|
+
if (!this.tempCanvas) {
|
|
30182
|
+
this.tempCanvas = application.global.createCanvas({});
|
|
30183
|
+
this.tempCtx = this.tempCanvas.getContext('2d');
|
|
30184
|
+
}
|
|
30185
|
+
if (!this.gifCanvas) {
|
|
30186
|
+
this.gifCanvas = application.global.createCanvas({});
|
|
30187
|
+
this.gifCtx = this.gifCanvas.getContext('2d');
|
|
30188
|
+
}
|
|
30189
|
+
this.gifCanvas.width = frames[0].dims.width;
|
|
30190
|
+
this.gifCanvas.height = frames[0].dims.height;
|
|
30191
|
+
this.playing = true;
|
|
30192
|
+
this.lastTime = new Date().getTime();
|
|
30193
|
+
const animation = this.animate();
|
|
30194
|
+
if (this.attribute.timeline) {
|
|
30195
|
+
animation.setTimeline(this.attribute.timeline);
|
|
30196
|
+
}
|
|
30197
|
+
animation.to({}, 1000, 'linear').loop(Infinity);
|
|
30198
|
+
}
|
|
30199
|
+
renderFrame(context, x, y) {
|
|
30200
|
+
const frame = this.loadedFrames[this.frameIndex || 0];
|
|
30201
|
+
if (frame.disposalType === 2) {
|
|
30202
|
+
this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);
|
|
30203
|
+
}
|
|
30204
|
+
this.drawPatch(frame);
|
|
30205
|
+
this.manipulate(context, x, y);
|
|
30206
|
+
const diff = new Date().getTime() - this.lastTime;
|
|
30207
|
+
if (frame.delay < diff) {
|
|
30208
|
+
this.frameIndex++;
|
|
30209
|
+
this.lastTime = new Date().getTime();
|
|
30210
|
+
}
|
|
30211
|
+
if (this.frameIndex >= this.loadedFrames.length) {
|
|
30212
|
+
this.frameIndex = 0;
|
|
30213
|
+
}
|
|
30214
|
+
}
|
|
30215
|
+
drawPatch(frame) {
|
|
30216
|
+
const dims = frame.dims;
|
|
30217
|
+
if (!this.frameImageData ||
|
|
30218
|
+
dims.width !== this.frameImageData.width ||
|
|
30219
|
+
dims.height !== this.frameImageData.height) {
|
|
30220
|
+
this.tempCanvas.width = dims.width;
|
|
30221
|
+
this.tempCanvas.height = dims.height;
|
|
30222
|
+
this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);
|
|
30223
|
+
}
|
|
30224
|
+
this.frameImageData.data.set(frame.patch);
|
|
30225
|
+
this.tempCtx.putImageData(this.frameImageData, 0, 0);
|
|
30226
|
+
this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);
|
|
30227
|
+
}
|
|
30228
|
+
manipulate(context, x, y) {
|
|
30229
|
+
context.drawImage(this.gifCanvas, 0, 0, this.gifCanvas.width, this.gifCanvas.height, x, y, this.attribute.width, this.attribute.height);
|
|
30230
|
+
}
|
|
30231
|
+
setAttribute(key, value, forceUpdateTag, context) {
|
|
30232
|
+
super.setAttribute(key, value, forceUpdateTag, context);
|
|
30233
|
+
if (key === 'gifImage') {
|
|
30234
|
+
this.loadGif();
|
|
30235
|
+
}
|
|
30236
|
+
}
|
|
30237
|
+
setAttributes(params, forceUpdateTag, context) {
|
|
30238
|
+
super.setAttributes(params, forceUpdateTag, context);
|
|
30239
|
+
if (params.gifImage) {
|
|
30240
|
+
this.loadGif();
|
|
30241
|
+
}
|
|
30242
|
+
}
|
|
30243
|
+
}
|
|
30244
|
+
|
|
30245
|
+
const version = "0.21.0-alpha.13";
|
|
29942
30246
|
|
|
29943
|
-
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip,
|
|
30247
|
+
export { AXIS_ELEMENT_NAME, AbstractComponent, ArcInfo, ArcLabel, ArcSegment, AxisStateValue, BasePlayer, Brush, CheckBox, CircleAxis, CircleAxisGrid, CircleCrosshair, ColorContinuousLegend, ContinuousPlayer, DEFAULT_ITEM_SPACE_COL, DEFAULT_ITEM_SPACE_ROW, DEFAULT_LABEL_SPACE, DEFAULT_PAGER_SPACE, DEFAULT_SHAPE_SIZE, DEFAULT_SHAPE_SPACE, DEFAULT_STATES$1 as DEFAULT_STATES, DEFAULT_TITLE_SPACE, DEFAULT_VALUE_SPACE, DataLabel, DataZoom, DataZoomActiveTag, DirectionEnum, DiscreteLegend, DiscretePlayer, EmptyTip, GifImage, GroupTransition, IMarkAreaLabelPosition, IMarkCommonArcLabelPosition, IMarkLineLabelPosition, IMarkPointItemPosition, IOperateType, Indicator, LEGEND_ELEMENT_NAME, LabelBase, LegendEvent, LegendStateValue, LineAxis, LineAxisGrid, LineCrosshair, LineLabel, LinkPath, MarkArcArea, MarkArcLine, MarkArea, MarkLine, MarkPoint, Pager, PlayerEventEnum, PolygonCrosshair, PopTip, Radio, RectCrosshair, RectLabel, SLIDER_ELEMENT_NAME, ScrollBar, SectorCrosshair, Segment, SizeContinuousLegend, Slider, SymbolLabel, Tag, Timeline, Title, Tooltip, TopZIndex, VTag, alignTextInLine, angle, angleLabelOrientAttribute, angleTo, cartesianTicks, clampRadian, computeOffsetForlimit, continuousTicks, contrastAccessibilityChecker, convertDomainToTickData, createTextGraphicByType, deltaXYToAngle, fuzzyEqualNumber, getAxisBreakSymbolAttrs, getCircleLabelPosition, getCirclePoints, getCircleVerticalVector, getElMap, getHorizontalPath, getMarksByName, getNoneGroupMarksByName, getPolarAngleLabelPosition, getPolygonPath, getSizeHandlerPath, getTextAlignAttrOfVerticalDir, getTextType, getVerticalCoord, getVerticalPath, hasOverlap, htmlAttributeTransform, initTextMeasure, isInRange, isPostiveXAxis, isRichText, isVisible, labelSmartInvert, length, limitShapeInBounds, linearDiscreteTicks, loadPoptip, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|