@visactor/vrender-components 0.21.0-alpha.4 → 0.21.0-alpha.6
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/index.d.ts +1 -2
- 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 +2 -1
- package/cjs/label/arc.js +2 -3
- package/cjs/label/arc.js.map +1 -1
- package/cjs/label/base.js +12 -7
- package/cjs/label/base.js.map +1 -1
- package/cjs/label/overlap/place.d.ts +6 -1
- package/cjs/label/overlap/place.js +4 -4
- package/cjs/label/overlap/place.js.map +1 -1
- package/cjs/label/overlap/shiftY.d.ts +2 -1
- package/cjs/label/overlap/shiftY.js +72 -18
- 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 +1 -0
- package/cjs/scrollbar/index.js +2 -1
- package/cjs/scrollbar/index.js.map +1 -1
- package/cjs/scrollbar/scrollbar-plugin.d.ts +18 -15
- package/cjs/scrollbar/scrollbar-plugin.js +109 -97
- package/cjs/scrollbar/scrollbar-plugin.js.map +1 -1
- package/cjs/timeline/type.js.map +1 -1
- package/dist/index.es.js +934 -1253
- 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/index.d.ts +1 -2
- package/es/index.js +1 -3
- package/es/index.js.map +1 -1
- package/es/interface.js.map +1 -1
- package/es/jsx/component-type.js +2 -1
- package/es/label/arc.js +2 -3
- package/es/label/arc.js.map +1 -1
- package/es/label/base.js +12 -7
- package/es/label/base.js.map +1 -1
- package/es/label/overlap/place.d.ts +6 -1
- package/es/label/overlap/place.js +4 -4
- package/es/label/overlap/place.js.map +1 -1
- package/es/label/overlap/shiftY.d.ts +2 -1
- package/es/label/overlap/shiftY.js +68 -15
- 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 +1 -0
- package/es/scrollbar/index.js +2 -0
- package/es/scrollbar/index.js.map +1 -1
- package/es/scrollbar/scrollbar-plugin.d.ts +18 -15
- package/es/scrollbar/scrollbar-plugin.js +111 -94
- package/es/scrollbar/scrollbar-plugin.js.map +1 -1
- package/es/timeline/type.js.map +1 -1
- package/package.json +10 -10
- package/cjs/gif/gif.d.ts +0 -29
- package/cjs/gif/gif.js +0 -59
- package/cjs/gif/gif.js.map +0 -1
- package/cjs/gif/index.d.ts +0 -1
- package/cjs/gif/index.js +0 -21
- package/cjs/gif/index.js.map +0 -1
- package/es/gif/gif.d.ts +0 -29
- package/es/gif/gif.js +0 -55
- package/es/gif/gif.js.map +0 -1
- package/es/gif/index.d.ts +0 -1
- package/es/gif/index.js +0 -2
- package/es/gif/index.js.map +0 -1
package/dist/index.es.js
CHANGED
|
@@ -745,6 +745,11 @@ let DefaultGlobal = class {
|
|
|
745
745
|
};
|
|
746
746
|
DefaultGlobal = __decorate$P([injectable(), __param$z(0, inject(ContributionProvider)), __param$z(0, named(EnvContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGlobal);
|
|
747
747
|
|
|
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
|
+
|
|
748
753
|
const circleThreshold = tau - 1e-8;
|
|
749
754
|
class BoundsContext {
|
|
750
755
|
constructor(bounds) {
|
|
@@ -2009,6 +2014,7 @@ const DefaultStrokeStyle = Object.assign({
|
|
|
2009
2014
|
const DefaultTextStyle = {
|
|
2010
2015
|
text: "",
|
|
2011
2016
|
maxLineWidth: 1 / 0,
|
|
2017
|
+
maxWidth: 1 / 0,
|
|
2012
2018
|
textAlign: "left",
|
|
2013
2019
|
textBaseline: "alphabetic",
|
|
2014
2020
|
fontSize: 16,
|
|
@@ -2032,7 +2038,8 @@ const DefaultTextStyle = {
|
|
|
2032
2038
|
suffixPosition: "end",
|
|
2033
2039
|
underlineDash: [],
|
|
2034
2040
|
underlineOffset: 0,
|
|
2035
|
-
disableAutoClipedPoptip: void 0
|
|
2041
|
+
disableAutoClipedPoptip: void 0,
|
|
2042
|
+
measureMode: MeasureModeEnum.fontBounding
|
|
2036
2043
|
};
|
|
2037
2044
|
const DefaultPickStyle = {
|
|
2038
2045
|
pickStrokeBuffer: 0
|
|
@@ -2086,7 +2093,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2086
2093
|
globalZIndex: 1,
|
|
2087
2094
|
globalCompositeOperation: "",
|
|
2088
2095
|
overflow: "hidden",
|
|
2089
|
-
shadowPickMode: "graphic"
|
|
2096
|
+
shadowPickMode: "graphic",
|
|
2097
|
+
keepStrokeScale: !1
|
|
2090
2098
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2091
2099
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2092
2100
|
startAngle: 0,
|
|
@@ -2353,10 +2361,32 @@ let ATextMeasure = class {
|
|
|
2353
2361
|
configure(service, env) {
|
|
2354
2362
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2355
2363
|
}
|
|
2356
|
-
|
|
2357
|
-
if (!this.context) return this.estimate(text, options).width;
|
|
2364
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
2358
2365
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2359
|
-
|
|
2366
|
+
const metrics = this.context.measureText(text);
|
|
2367
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2368
|
+
}
|
|
2369
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
2370
|
+
this.context.setTextStyle(options);
|
|
2371
|
+
const metrics = this.context.measureText(text);
|
|
2372
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2373
|
+
}
|
|
2374
|
+
compatibleMetrics(metrics, options) {
|
|
2375
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
2376
|
+
const {
|
|
2377
|
+
ascent: ascent,
|
|
2378
|
+
descent: descent
|
|
2379
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
2380
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
2381
|
+
}
|
|
2382
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
2383
|
+
const {
|
|
2384
|
+
left: left,
|
|
2385
|
+
right: right
|
|
2386
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
2387
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
2388
|
+
}
|
|
2389
|
+
return metrics;
|
|
2360
2390
|
}
|
|
2361
2391
|
estimate(text, _ref) {
|
|
2362
2392
|
let {
|
|
@@ -2370,19 +2400,104 @@ let ATextMeasure = class {
|
|
|
2370
2400
|
height: fontSize
|
|
2371
2401
|
};
|
|
2372
2402
|
}
|
|
2373
|
-
|
|
2403
|
+
measureTextWidth(text, options, textMeasure) {
|
|
2404
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2405
|
+
}
|
|
2406
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
2407
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2408
|
+
}
|
|
2409
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
2410
|
+
return this.context ? {
|
|
2411
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
2412
|
+
right: textMeasure.actualBoundingBoxRight
|
|
2413
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
2414
|
+
}
|
|
2415
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
2374
2416
|
var _a;
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
return
|
|
2417
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2418
|
+
}
|
|
2419
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
2420
|
+
return this.context ? {
|
|
2421
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
2422
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
2423
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2379
2424
|
}
|
|
2380
|
-
measureTextBoundHieght(text, options) {
|
|
2425
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
2381
2426
|
var _a;
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
return
|
|
2427
|
+
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;
|
|
2428
|
+
}
|
|
2429
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
2430
|
+
return this.context ? {
|
|
2431
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
2432
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
2433
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2434
|
+
}
|
|
2435
|
+
measureTextBoundADscentEstimate(options) {
|
|
2436
|
+
var _a;
|
|
2437
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
2438
|
+
return {
|
|
2439
|
+
ascent: .79 * fontSize,
|
|
2440
|
+
descent: .21 * fontSize
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
2444
|
+
var _a;
|
|
2445
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
2446
|
+
{
|
|
2447
|
+
textAlign: textAlign
|
|
2448
|
+
} = options;
|
|
2449
|
+
return "center" === textAlign ? {
|
|
2450
|
+
left: fontSize / 2,
|
|
2451
|
+
right: fontSize / 2
|
|
2452
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
2453
|
+
left: fontSize,
|
|
2454
|
+
right: 0
|
|
2455
|
+
} : {
|
|
2456
|
+
left: 0,
|
|
2457
|
+
right: fontSize
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
2461
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2462
|
+
width: this.estimate(text, options).width
|
|
2463
|
+
});
|
|
2464
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
2465
|
+
if (mode === MeasureModeEnum.actualBounding) return {
|
|
2466
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2467
|
+
descent: out.actualBoundingBoxDescent,
|
|
2468
|
+
width: out.width
|
|
2469
|
+
};
|
|
2470
|
+
if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2471
|
+
width: out.width
|
|
2472
|
+
});
|
|
2473
|
+
if (mode === MeasureModeEnum.fontBounding) {
|
|
2474
|
+
const {
|
|
2475
|
+
lineHeight = options.fontSize
|
|
2476
|
+
} = options;
|
|
2477
|
+
let ratio = 1;
|
|
2478
|
+
if (lineHeight) {
|
|
2479
|
+
ratio = lineHeight / (out.fontBoundingBoxAscent + out.fontBoundingBoxDescent);
|
|
2480
|
+
}
|
|
2481
|
+
let ascent = out.fontBoundingBoxAscent * ratio,
|
|
2482
|
+
descent = out.fontBoundingBoxDescent * ratio;
|
|
2483
|
+
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
2484
|
+
const delta = out.actualBoundingBoxDescent - descent;
|
|
2485
|
+
descent += delta, ascent -= delta;
|
|
2486
|
+
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
2487
|
+
const delta = out.actualBoundingBoxAscent - ascent;
|
|
2488
|
+
ascent += delta, descent -= delta;
|
|
2489
|
+
}
|
|
2490
|
+
return {
|
|
2491
|
+
ascent: ascent,
|
|
2492
|
+
descent: descent,
|
|
2493
|
+
width: out.width
|
|
2494
|
+
};
|
|
2495
|
+
}
|
|
2496
|
+
return {
|
|
2497
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2498
|
+
descent: out.actualBoundingBoxDescent,
|
|
2499
|
+
width: out.width
|
|
2500
|
+
};
|
|
2386
2501
|
}
|
|
2387
2502
|
measureText(text, options) {
|
|
2388
2503
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -4372,7 +4487,7 @@ class ResourceLoader {
|
|
|
4372
4487
|
}
|
|
4373
4488
|
static GetFile(url, type) {
|
|
4374
4489
|
let data = ResourceLoader.cache.get(url);
|
|
4375
|
-
return data ? "fail" === data.loadState ? Promise.reject() : "
|
|
4490
|
+
return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
|
|
4376
4491
|
type: type,
|
|
4377
4492
|
loadState: "init"
|
|
4378
4493
|
}, 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));
|
|
@@ -6036,9 +6151,6 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
|
|
|
6036
6151
|
const TextRenderContribution = Symbol.for("TextRenderContribution");
|
|
6037
6152
|
const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
|
|
6038
6153
|
|
|
6039
|
-
function textDrawOffsetY(baseline, h) {
|
|
6040
|
-
return "top" === baseline ? Math.ceil(.79 * h) : "middle" === baseline ? Math.round(.3 * h) : "bottom" === baseline ? Math.round(-.21 * h) : 0;
|
|
6041
|
-
}
|
|
6042
6154
|
function textDrawOffsetX(textAlign, width) {
|
|
6043
6155
|
return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
|
|
6044
6156
|
}
|
|
@@ -6517,7 +6629,7 @@ class BaseRender {
|
|
|
6517
6629
|
}
|
|
6518
6630
|
}
|
|
6519
6631
|
|
|
6520
|
-
const parse
|
|
6632
|
+
const parse = function () {
|
|
6521
6633
|
const tokens = {
|
|
6522
6634
|
linearGradient: /^(linear\-gradient)/i,
|
|
6523
6635
|
radialGradient: /^(radial\-gradient)/i,
|
|
@@ -6670,7 +6782,7 @@ class GradientParser {
|
|
|
6670
6782
|
}
|
|
6671
6783
|
static Parse(c) {
|
|
6672
6784
|
if (GradientParser.IsGradientStr(c)) try {
|
|
6673
|
-
const datum = parse
|
|
6785
|
+
const datum = parse(c)[0];
|
|
6674
6786
|
if (datum) {
|
|
6675
6787
|
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
6676
6788
|
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
@@ -7027,7 +7139,8 @@ class DefaultArcRenderContribution {
|
|
|
7027
7139
|
x: originX = arcAttribute.x,
|
|
7028
7140
|
y: originY = arcAttribute.y,
|
|
7029
7141
|
scaleX = arcAttribute.scaleX,
|
|
7030
|
-
scaleY = arcAttribute.scaleY
|
|
7142
|
+
scaleY = arcAttribute.scaleY,
|
|
7143
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
7031
7144
|
} = arc.attribute;
|
|
7032
7145
|
let {
|
|
7033
7146
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -7039,7 +7152,7 @@ class DefaultArcRenderContribution {
|
|
|
7039
7152
|
{
|
|
7040
7153
|
distance = arcAttribute[key].distance
|
|
7041
7154
|
} = borderStyle,
|
|
7042
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7155
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7043
7156
|
deltaAngle = distance / outerRadius,
|
|
7044
7157
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7045
7158
|
if (arc.setAttributes({
|
|
@@ -7084,14 +7197,15 @@ class DefaultCircleRenderContribution {
|
|
|
7084
7197
|
x: originX = circleAttribute.x,
|
|
7085
7198
|
y: originY = circleAttribute.y,
|
|
7086
7199
|
scaleX = circleAttribute.scaleX,
|
|
7087
|
-
scaleY = circleAttribute.scaleY
|
|
7200
|
+
scaleY = circleAttribute.scaleY,
|
|
7201
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
7088
7202
|
} = circle.attribute,
|
|
7089
7203
|
renderBorder = (borderStyle, key) => {
|
|
7090
7204
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7091
7205
|
{
|
|
7092
7206
|
distance = circleAttribute[key].distance
|
|
7093
7207
|
} = borderStyle,
|
|
7094
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7208
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7095
7209
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7096
7210
|
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) {
|
|
7097
7211
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -7210,7 +7324,8 @@ class DefaultRectRenderContribution {
|
|
|
7210
7324
|
scaleX = rectAttribute.scaleX,
|
|
7211
7325
|
scaleY = rectAttribute.scaleY,
|
|
7212
7326
|
x1: x1,
|
|
7213
|
-
y1: y1
|
|
7327
|
+
y1: y1,
|
|
7328
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
7214
7329
|
} = rect.attribute;
|
|
7215
7330
|
let {
|
|
7216
7331
|
width: width,
|
|
@@ -7223,7 +7338,7 @@ class DefaultRectRenderContribution {
|
|
|
7223
7338
|
{
|
|
7224
7339
|
distance = rectAttribute[key].distance
|
|
7225
7340
|
} = borderStyle,
|
|
7226
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7341
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7227
7342
|
nextX = x + sign * d,
|
|
7228
7343
|
nextY = y + sign * d,
|
|
7229
7344
|
dw = 2 * d;
|
|
@@ -7353,9 +7468,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
7353
7468
|
constructor() {
|
|
7354
7469
|
super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
7355
7470
|
}
|
|
7356
|
-
drawShape(
|
|
7357
|
-
|
|
7358
|
-
image.renderFrame(context, x, y);
|
|
7471
|
+
drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
7472
|
+
return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
7359
7473
|
}
|
|
7360
7474
|
}
|
|
7361
7475
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -7381,14 +7495,15 @@ class DefaultSymbolRenderContribution {
|
|
|
7381
7495
|
x: originX = symbolAttribute.x,
|
|
7382
7496
|
y: originY = symbolAttribute.y,
|
|
7383
7497
|
scaleX = symbolAttribute.scaleX,
|
|
7384
|
-
scaleY = symbolAttribute.scaleY
|
|
7498
|
+
scaleY = symbolAttribute.scaleY,
|
|
7499
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
7385
7500
|
} = symbol.attribute,
|
|
7386
7501
|
renderBorder = (borderStyle, key) => {
|
|
7387
7502
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7388
7503
|
{
|
|
7389
7504
|
distance = symbolAttribute[key].distance
|
|
7390
7505
|
} = borderStyle,
|
|
7391
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7506
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7392
7507
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7393
7508
|
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) {
|
|
7394
7509
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -8664,16 +8779,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8664
8779
|
verticalMode = textAttribute.verticalMode,
|
|
8665
8780
|
x: originX = textAttribute.x,
|
|
8666
8781
|
y: originY = textAttribute.y
|
|
8667
|
-
} = text.attribute
|
|
8668
|
-
|
|
8669
|
-
textAlign = textAttribute.textAlign,
|
|
8670
|
-
textBaseline = textAttribute.textBaseline
|
|
8671
|
-
} = text.attribute;
|
|
8672
|
-
if (!verticalMode && "vertical" === direction) {
|
|
8673
|
-
const t = textAlign;
|
|
8674
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
8675
|
-
}
|
|
8676
|
-
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
8782
|
+
} = text.attribute,
|
|
8783
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
8677
8784
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
8678
8785
|
if (!data) return;
|
|
8679
8786
|
const {
|
|
@@ -8693,79 +8800,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8693
8800
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
8694
8801
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
8695
8802
|
}
|
|
8696
|
-
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)
|
|
8803
|
+
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());
|
|
8697
8804
|
};
|
|
8698
|
-
if (text.
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
width: line.width
|
|
8713
|
-
});
|
|
8714
|
-
})));
|
|
8715
|
-
} else {
|
|
8716
|
-
text.tryUpdateAABBBounds();
|
|
8717
|
-
const cache = text.cache,
|
|
8718
|
-
{
|
|
8719
|
-
verticalList: verticalList
|
|
8720
|
-
} = cache;
|
|
8721
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
8722
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
8723
|
-
let totalW = 0;
|
|
8724
|
-
verticalList.forEach(verticalData => {
|
|
8725
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8726
|
-
totalW = max(_w, totalW);
|
|
8727
|
-
});
|
|
8728
|
-
let offsetY = 0,
|
|
8729
|
-
offsetX = 0;
|
|
8730
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8731
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8732
|
-
dw = totalW - currentW;
|
|
8733
|
-
let currentOffsetY = offsetY;
|
|
8734
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8735
|
-
const {
|
|
8736
|
-
text: text,
|
|
8737
|
-
width: width,
|
|
8738
|
-
direction: direction
|
|
8739
|
-
} = item;
|
|
8740
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8741
|
-
});
|
|
8805
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
8806
|
+
const {
|
|
8807
|
+
multilineLayout: multilineLayout
|
|
8808
|
+
} = text;
|
|
8809
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
8810
|
+
const {
|
|
8811
|
+
xOffset: xOffset,
|
|
8812
|
+
yOffset: yOffset
|
|
8813
|
+
} = multilineLayout.bbox;
|
|
8814
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8815
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
8816
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8817
|
+
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, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
|
|
8818
|
+
width: line.width
|
|
8742
8819
|
});
|
|
8743
|
-
}
|
|
8744
|
-
} else if ("horizontal" === direction) {
|
|
8745
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
8746
|
-
const t = text.clipedText;
|
|
8747
|
-
let dy = 0;
|
|
8748
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
8820
|
+
})));
|
|
8749
8821
|
} else {
|
|
8822
|
+
let {
|
|
8823
|
+
textAlign = textAttribute.textAlign,
|
|
8824
|
+
textBaseline = textAttribute.textBaseline
|
|
8825
|
+
} = text.attribute;
|
|
8826
|
+
if (!verticalMode) {
|
|
8827
|
+
const t = textAlign;
|
|
8828
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
8829
|
+
}
|
|
8750
8830
|
text.tryUpdateAABBBounds();
|
|
8751
|
-
const cache = text.cache
|
|
8752
|
-
|
|
8753
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
8754
|
-
const {
|
|
8831
|
+
const cache = text.cache,
|
|
8832
|
+
{
|
|
8755
8833
|
verticalList: verticalList
|
|
8756
8834
|
} = cache;
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8835
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
8836
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
8837
|
+
let totalW = 0;
|
|
8838
|
+
verticalList.forEach(verticalData => {
|
|
8839
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8840
|
+
totalW = max(_w, totalW);
|
|
8841
|
+
});
|
|
8842
|
+
let offsetY = 0,
|
|
8843
|
+
offsetX = 0;
|
|
8844
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8845
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8846
|
+
dw = totalW - currentW;
|
|
8847
|
+
let currentOffsetY = offsetY;
|
|
8848
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8761
8849
|
const {
|
|
8762
8850
|
text: text,
|
|
8763
8851
|
width: width,
|
|
8764
8852
|
direction: direction
|
|
8765
8853
|
} = item;
|
|
8766
|
-
drawText(text, offsetX,
|
|
8854
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8767
8855
|
});
|
|
8768
|
-
}
|
|
8856
|
+
});
|
|
8769
8857
|
}
|
|
8770
8858
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
8771
8859
|
}
|
|
@@ -8777,12 +8865,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8777
8865
|
computed3dMatrix = !keepDirIn3d;
|
|
8778
8866
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
8779
8867
|
}
|
|
8780
|
-
drawUnderLine(underline, lineThrough, text,
|
|
8868
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
8781
8869
|
if (lineThrough + underline <= 0) return;
|
|
8782
8870
|
const {
|
|
8783
8871
|
textAlign = textAttribute.textAlign,
|
|
8784
|
-
textBaseline = textAttribute.textBaseline,
|
|
8785
|
-
fontSize = textAttribute.fontSize,
|
|
8786
8872
|
fill = textAttribute.fill,
|
|
8787
8873
|
opacity = textAttribute.opacity,
|
|
8788
8874
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -8792,23 +8878,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8792
8878
|
isMulti = !isNil(multiOption),
|
|
8793
8879
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
8794
8880
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
8795
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
8796
8881
|
attribute = {
|
|
8797
8882
|
lineWidth: 0,
|
|
8798
8883
|
stroke: fill,
|
|
8799
8884
|
opacity: opacity,
|
|
8800
8885
|
strokeOpacity: fillOpacity
|
|
8801
8886
|
};
|
|
8802
|
-
let deltaY = isMulti ? -3 : 0;
|
|
8803
8887
|
if (underline) {
|
|
8804
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
8805
|
-
const dy =
|
|
8806
|
-
context.moveTo(
|
|
8888
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
8889
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
8890
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8807
8891
|
}
|
|
8808
|
-
if (
|
|
8809
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
8810
|
-
const dy =
|
|
8811
|
-
context.moveTo(
|
|
8892
|
+
if (lineThrough) {
|
|
8893
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
8894
|
+
const dy = anchorY + offsetThroughLineY;
|
|
8895
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8812
8896
|
}
|
|
8813
8897
|
}
|
|
8814
8898
|
};
|
|
@@ -9093,12 +9177,10 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
9093
9177
|
const {
|
|
9094
9178
|
image: url
|
|
9095
9179
|
} = image.attribute;
|
|
9096
|
-
if (!image.
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
if ("success" !== res.state) return;
|
|
9101
|
-
}
|
|
9180
|
+
if (!url || !image.resources) return;
|
|
9181
|
+
const res = image.resources.get(url);
|
|
9182
|
+
if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
|
|
9183
|
+
if ("success" !== res.state) return;
|
|
9102
9184
|
const {
|
|
9103
9185
|
context: context
|
|
9104
9186
|
} = renderService.drawParams;
|
|
@@ -9482,51 +9564,45 @@ class CanvasTextLayout {
|
|
|
9482
9564
|
}
|
|
9483
9565
|
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
9484
9566
|
}
|
|
9485
|
-
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
9486
|
-
const linesLayout = [],
|
|
9487
|
-
bboxWH = [width, height],
|
|
9488
|
-
bboxOffset = [0, 0];
|
|
9489
|
-
for (; str.length > 0;) {
|
|
9490
|
-
const {
|
|
9491
|
-
str: clipText
|
|
9492
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
9493
|
-
linesLayout.push({
|
|
9494
|
-
str: clipText,
|
|
9495
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
9496
|
-
}), str = str.substring(clipText.length);
|
|
9497
|
-
}
|
|
9498
|
-
"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]));
|
|
9499
|
-
const bbox = {
|
|
9500
|
-
xOffset: bboxOffset[0],
|
|
9501
|
-
yOffset: bboxOffset[1],
|
|
9502
|
-
width: bboxWH[0],
|
|
9503
|
-
height: bboxWH[1]
|
|
9504
|
-
};
|
|
9505
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9506
|
-
}
|
|
9507
9567
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
9508
9568
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
9509
9569
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
9510
|
-
let
|
|
9511
|
-
|
|
9570
|
+
let params = arguments.length > 6 ? arguments[6] : undefined;
|
|
9571
|
+
const {
|
|
9572
|
+
lineWidth: lineWidth,
|
|
9573
|
+
suffixPosition = "end",
|
|
9574
|
+
measureMode = MeasureModeEnum.actualBounding
|
|
9575
|
+
} = null != params ? params : {};
|
|
9512
9576
|
lines = lines.map(l => l.toString());
|
|
9513
9577
|
const linesLayout = [],
|
|
9514
9578
|
bboxWH = [0, 0];
|
|
9515
9579
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
9516
9580
|
let width;
|
|
9517
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
9518
|
-
|
|
9519
|
-
width
|
|
9520
|
-
|
|
9581
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9582
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
9583
|
+
width = Math.min(metrics.width, lineWidth), linesLayout.push({
|
|
9584
|
+
str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
9585
|
+
width: width,
|
|
9586
|
+
ascent: metrics.ascent,
|
|
9587
|
+
descent: metrics.descent
|
|
9588
|
+
});
|
|
9589
|
+
}
|
|
9521
9590
|
bboxWH[0] = lineWidth;
|
|
9522
9591
|
} else {
|
|
9523
|
-
let width,
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9592
|
+
let width,
|
|
9593
|
+
text,
|
|
9594
|
+
_lineWidth = 0;
|
|
9595
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9596
|
+
text = lines[i];
|
|
9597
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
9598
|
+
width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
|
|
9599
|
+
str: text,
|
|
9600
|
+
width: width,
|
|
9601
|
+
ascent: metrics.ascent,
|
|
9602
|
+
descent: metrics.descent
|
|
9603
|
+
});
|
|
9604
|
+
}
|
|
9605
|
+
bboxWH[0] = _lineWidth;
|
|
9530
9606
|
}
|
|
9531
9607
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
9532
9608
|
const bbox = {
|
|
@@ -9554,11 +9630,11 @@ class CanvasTextLayout {
|
|
|
9554
9630
|
};
|
|
9555
9631
|
}
|
|
9556
9632
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
9557
|
-
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 =
|
|
9633
|
+
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 / 2 + (line.ascent - line.descent) / 2 + origin[1], origin[1] += lineHeight, line;
|
|
9558
9634
|
}
|
|
9559
9635
|
}
|
|
9560
9636
|
|
|
9561
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9637
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
9562
9638
|
class Text extends Graphic {
|
|
9563
9639
|
get font() {
|
|
9564
9640
|
const textTheme = this.getGraphicTheme();
|
|
@@ -9567,26 +9643,22 @@ class Text extends Graphic {
|
|
|
9567
9643
|
get clipedText() {
|
|
9568
9644
|
var _a;
|
|
9569
9645
|
const attribute = this.attribute,
|
|
9570
|
-
textTheme = this.getGraphicTheme()
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
9574
|
-
} = attribute;
|
|
9575
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9646
|
+
textTheme = this.getGraphicTheme(),
|
|
9647
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9648
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9576
9649
|
}
|
|
9577
9650
|
get clipedWidth() {
|
|
9578
|
-
|
|
9651
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
9579
9652
|
}
|
|
9580
9653
|
get cliped() {
|
|
9581
9654
|
var _a, _b;
|
|
9582
9655
|
const textTheme = this.getGraphicTheme(),
|
|
9583
9656
|
attribute = this.attribute,
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
9657
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9658
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
9659
|
+
const {
|
|
9660
|
+
text: text
|
|
9661
|
+
} = this.attribute;
|
|
9590
9662
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
9591
9663
|
let mergedText = "";
|
|
9592
9664
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -9597,10 +9669,7 @@ class Text extends Graphic {
|
|
|
9597
9669
|
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();
|
|
9598
9670
|
}
|
|
9599
9671
|
get multilineLayout() {
|
|
9600
|
-
|
|
9601
|
-
}
|
|
9602
|
-
isSimplify() {
|
|
9603
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
9672
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
9604
9673
|
}
|
|
9605
9674
|
get isMultiLine() {
|
|
9606
9675
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -9673,8 +9742,72 @@ class Text extends Graphic {
|
|
|
9673
9742
|
}
|
|
9674
9743
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
9675
9744
|
}
|
|
9745
|
+
updateSingallineAABBBounds(text) {
|
|
9746
|
+
this.updateMultilineAABBBounds([text]);
|
|
9747
|
+
const layoutData = this.cache.layoutData;
|
|
9748
|
+
if (layoutData) {
|
|
9749
|
+
const line = layoutData.lines[0];
|
|
9750
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
9751
|
+
}
|
|
9752
|
+
return this._AABBBounds;
|
|
9753
|
+
}
|
|
9754
|
+
updateMultilineAABBBounds(text) {
|
|
9755
|
+
const textTheme = this.getGraphicTheme(),
|
|
9756
|
+
{
|
|
9757
|
+
direction = textTheme.direction,
|
|
9758
|
+
underlineOffset = textTheme.underlineOffset
|
|
9759
|
+
} = this.attribute,
|
|
9760
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9761
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9762
|
+
}
|
|
9763
|
+
guessLineHeightBuf(fontSize) {
|
|
9764
|
+
return fontSize ? .1 * fontSize : 0;
|
|
9765
|
+
}
|
|
9766
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
9767
|
+
var _a;
|
|
9768
|
+
const textTheme = this.getGraphicTheme(),
|
|
9769
|
+
attribute = this.attribute,
|
|
9770
|
+
{
|
|
9771
|
+
fontFamily = textTheme.fontFamily,
|
|
9772
|
+
textAlign = textTheme.textAlign,
|
|
9773
|
+
textBaseline = textTheme.textBaseline,
|
|
9774
|
+
fontSize = textTheme.fontSize,
|
|
9775
|
+
fontWeight = textTheme.fontWeight,
|
|
9776
|
+
ellipsis = textTheme.ellipsis,
|
|
9777
|
+
maxLineWidth: maxLineWidth,
|
|
9778
|
+
stroke = textTheme.stroke,
|
|
9779
|
+
wrap = textTheme.wrap,
|
|
9780
|
+
measureMode = textTheme.measureMode,
|
|
9781
|
+
lineWidth = textTheme.lineWidth,
|
|
9782
|
+
whiteSpace = textTheme.whiteSpace,
|
|
9783
|
+
suffixPosition = textTheme.suffixPosition,
|
|
9784
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
9785
|
+
} = attribute,
|
|
9786
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
9787
|
+
lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
9788
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
9789
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9790
|
+
const bbox = this.cache.layoutData.bbox;
|
|
9791
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9792
|
+
}
|
|
9793
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
9794
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9795
|
+
fontSize: fontSize,
|
|
9796
|
+
fontWeight: fontWeight,
|
|
9797
|
+
fontFamily: fontFamily,
|
|
9798
|
+
lineHeight: lineHeight
|
|
9799
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
9800
|
+
lineWidth: maxLineWidth,
|
|
9801
|
+
suffixPosition: suffixPosition,
|
|
9802
|
+
measureMode: measureMode
|
|
9803
|
+
}),
|
|
9804
|
+
{
|
|
9805
|
+
bbox: bbox
|
|
9806
|
+
} = layoutData;
|
|
9807
|
+
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;
|
|
9808
|
+
}
|
|
9676
9809
|
updateWrapAABBBounds(text) {
|
|
9677
|
-
var _a, _b, _c
|
|
9810
|
+
var _a, _b, _c;
|
|
9678
9811
|
const textTheme = this.getGraphicTheme(),
|
|
9679
9812
|
{
|
|
9680
9813
|
fontFamily = textTheme.fontFamily,
|
|
@@ -9688,22 +9821,25 @@ class Text extends Graphic {
|
|
|
9688
9821
|
wordBreak = textTheme.wordBreak,
|
|
9689
9822
|
fontWeight = textTheme.fontWeight,
|
|
9690
9823
|
ignoreBuf = textTheme.ignoreBuf,
|
|
9824
|
+
measureMode = textTheme.measureMode,
|
|
9691
9825
|
suffixPosition = textTheme.suffixPosition,
|
|
9692
9826
|
heightLimit = 0,
|
|
9693
9827
|
lineClamp: lineClamp
|
|
9694
9828
|
} = this.attribute,
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
9829
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
9830
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
|
|
9831
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9698
9832
|
const bbox = this.cache.layoutData.bbox;
|
|
9699
9833
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9700
9834
|
}
|
|
9701
9835
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
9702
|
-
|
|
9836
|
+
textOptions = {
|
|
9703
9837
|
fontSize: fontSize,
|
|
9704
9838
|
fontWeight: fontWeight,
|
|
9705
|
-
fontFamily: fontFamily
|
|
9706
|
-
|
|
9839
|
+
fontFamily: fontFamily,
|
|
9840
|
+
lineHeight: lineHeight
|
|
9841
|
+
},
|
|
9842
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
9707
9843
|
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
9708
9844
|
linesLayout = [],
|
|
9709
9845
|
bboxWH = [0, 0];
|
|
@@ -9713,29 +9849,35 @@ class Text extends Graphic {
|
|
|
9713
9849
|
const str = lines[i];
|
|
9714
9850
|
let needCut = !0;
|
|
9715
9851
|
if (i === lineCountLimit - 1) {
|
|
9716
|
-
const clip =
|
|
9852
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
9853
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9717
9854
|
linesLayout.push({
|
|
9718
9855
|
str: clip.str,
|
|
9719
|
-
width: clip.width
|
|
9856
|
+
width: clip.width,
|
|
9857
|
+
ascent: matrics.ascent,
|
|
9858
|
+
descent: matrics.descent
|
|
9720
9859
|
});
|
|
9721
9860
|
break;
|
|
9722
9861
|
}
|
|
9723
|
-
const clip =
|
|
9862
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
9724
9863
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
9725
9864
|
if (ellipsis) {
|
|
9726
|
-
const clipEllipsis =
|
|
9727
|
-
clip.str = null !== (
|
|
9865
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9866
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
9728
9867
|
} else clip.str = "", clip.width = 0;
|
|
9729
9868
|
needCut = !1;
|
|
9730
9869
|
}
|
|
9870
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9731
9871
|
linesLayout.push({
|
|
9732
9872
|
str: clip.str,
|
|
9733
|
-
width: clip.width
|
|
9873
|
+
width: clip.width,
|
|
9874
|
+
ascent: matrics.ascent,
|
|
9875
|
+
descent: matrics.descent
|
|
9734
9876
|
});
|
|
9735
9877
|
let cutLength = clip.str.length;
|
|
9736
9878
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
9737
|
-
|
|
9738
|
-
|
|
9879
|
+
const newStr = str.substring(cutLength);
|
|
9880
|
+
lines.splice(i + 1, 0, newStr);
|
|
9739
9881
|
}
|
|
9740
9882
|
}
|
|
9741
9883
|
let maxWidth = 0;
|
|
@@ -9748,21 +9890,28 @@ class Text extends Graphic {
|
|
|
9748
9890
|
lineWidth = 0;
|
|
9749
9891
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9750
9892
|
if (i === lineCountLimit - 1) {
|
|
9751
|
-
const clip =
|
|
9893
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
9894
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
9752
9895
|
linesLayout.push({
|
|
9753
9896
|
str: clip.str,
|
|
9754
|
-
width: clip.width
|
|
9897
|
+
width: clip.width,
|
|
9898
|
+
ascent: matrics.ascent,
|
|
9899
|
+
descent: matrics.descent
|
|
9755
9900
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
9756
9901
|
break;
|
|
9757
9902
|
}
|
|
9758
|
-
text = lines[i], width =
|
|
9903
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
9904
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
9905
|
+
linesLayout.push({
|
|
9759
9906
|
str: text,
|
|
9760
|
-
width: width
|
|
9907
|
+
width: width,
|
|
9908
|
+
ascent: matrics.ascent,
|
|
9909
|
+
descent: matrics.descent
|
|
9761
9910
|
});
|
|
9762
9911
|
}
|
|
9763
9912
|
bboxWH[0] = lineWidth;
|
|
9764
9913
|
}
|
|
9765
|
-
bboxWH[1] = linesLayout.length *
|
|
9914
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
9766
9915
|
const bbox = {
|
|
9767
9916
|
xOffset: 0,
|
|
9768
9917
|
yOffset: 0,
|
|
@@ -9773,210 +9922,12 @@ class Text extends Graphic {
|
|
|
9773
9922
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9774
9923
|
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;
|
|
9775
9924
|
}
|
|
9776
|
-
updateSingallineAABBBounds(text) {
|
|
9777
|
-
const textTheme = this.getGraphicTheme(),
|
|
9778
|
-
{
|
|
9779
|
-
direction = textTheme.direction,
|
|
9780
|
-
underlineOffset = textTheme.underlineOffset
|
|
9781
|
-
} = this.attribute,
|
|
9782
|
-
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
9783
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9784
|
-
}
|
|
9785
|
-
updateMultilineAABBBounds(text) {
|
|
9786
|
-
const textTheme = this.getGraphicTheme(),
|
|
9787
|
-
{
|
|
9788
|
-
direction = textTheme.direction,
|
|
9789
|
-
underlineOffset = textTheme.underlineOffset
|
|
9790
|
-
} = this.attribute,
|
|
9791
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9792
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9793
|
-
}
|
|
9794
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
9795
|
-
var _a, _b;
|
|
9796
|
-
const textTheme = this.getGraphicTheme(),
|
|
9797
|
-
{
|
|
9798
|
-
wrap = textTheme.wrap
|
|
9799
|
-
} = this.attribute;
|
|
9800
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
9801
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
9802
|
-
let width, str;
|
|
9803
|
-
const attribute = this.attribute,
|
|
9804
|
-
{
|
|
9805
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
9806
|
-
ellipsis = textTheme.ellipsis,
|
|
9807
|
-
textAlign = textTheme.textAlign,
|
|
9808
|
-
textBaseline = textTheme.textBaseline,
|
|
9809
|
-
fontFamily = textTheme.fontFamily,
|
|
9810
|
-
fontSize = textTheme.fontSize,
|
|
9811
|
-
fontWeight = textTheme.fontWeight,
|
|
9812
|
-
stroke = textTheme.stroke,
|
|
9813
|
-
lineWidth = textTheme.lineWidth,
|
|
9814
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
9815
|
-
whiteSpace = textTheme.whiteSpace,
|
|
9816
|
-
suffixPosition = textTheme.suffixPosition
|
|
9817
|
-
} = attribute;
|
|
9818
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9819
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
9820
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
9821
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
9822
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
9823
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
9824
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9825
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9826
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9827
|
-
}
|
|
9828
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
9829
|
-
if (ellipsis) {
|
|
9830
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9831
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
9832
|
-
fontSize: fontSize,
|
|
9833
|
-
fontWeight: fontWeight,
|
|
9834
|
-
fontFamily: fontFamily
|
|
9835
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9836
|
-
str = data.str, width = data.width;
|
|
9837
|
-
} else {
|
|
9838
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
9839
|
-
fontSize: fontSize,
|
|
9840
|
-
fontWeight: fontWeight,
|
|
9841
|
-
fontFamily: fontFamily
|
|
9842
|
-
}, maxLineWidth, !1);
|
|
9843
|
-
str = data.str, width = data.width;
|
|
9844
|
-
}
|
|
9845
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
9846
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
9847
|
-
fontSize: fontSize,
|
|
9848
|
-
fontWeight: fontWeight,
|
|
9849
|
-
fontFamily: fontFamily
|
|
9850
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
9851
|
-
this.clearUpdateShapeTag();
|
|
9852
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
9853
|
-
let lh = lineHeight;
|
|
9854
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
9855
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
9856
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9857
|
-
}
|
|
9858
|
-
getBaselineMapAlign() {
|
|
9859
|
-
return Text.baselineMapAlign;
|
|
9860
|
-
}
|
|
9861
|
-
getAlignMapBaseline() {
|
|
9862
|
-
return Text.alignMapBaseline;
|
|
9863
|
-
}
|
|
9864
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
9865
|
-
var _a, _b, _c;
|
|
9866
|
-
const textTheme = this.getGraphicTheme(),
|
|
9867
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
9868
|
-
let width;
|
|
9869
|
-
const attribute = this.attribute,
|
|
9870
|
-
{
|
|
9871
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
9872
|
-
} = attribute,
|
|
9873
|
-
buf = ignoreBuf ? 0 : 2,
|
|
9874
|
-
{
|
|
9875
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
9876
|
-
ellipsis = textTheme.ellipsis,
|
|
9877
|
-
fontSize = textTheme.fontSize,
|
|
9878
|
-
fontWeight = textTheme.fontWeight,
|
|
9879
|
-
fontFamily = textTheme.fontFamily,
|
|
9880
|
-
stroke = textTheme.stroke,
|
|
9881
|
-
lineWidth = textTheme.lineWidth,
|
|
9882
|
-
verticalMode = textTheme.verticalMode,
|
|
9883
|
-
suffixPosition = textTheme.suffixPosition
|
|
9884
|
-
} = attribute,
|
|
9885
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
9886
|
-
let {
|
|
9887
|
-
textAlign = textTheme.textAlign,
|
|
9888
|
-
textBaseline = textTheme.textBaseline
|
|
9889
|
-
} = attribute;
|
|
9890
|
-
if (!verticalMode) {
|
|
9891
|
-
const t = textAlign;
|
|
9892
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
9893
|
-
}
|
|
9894
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
9895
|
-
width = this.cache.clipedWidth;
|
|
9896
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9897
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9898
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9899
|
-
}
|
|
9900
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
9901
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
9902
|
-
if (ellipsis) {
|
|
9903
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
9904
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
9905
|
-
fontSize: fontSize,
|
|
9906
|
-
fontWeight: fontWeight,
|
|
9907
|
-
fontFamily: fontFamily
|
|
9908
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
9909
|
-
verticalList = [data.verticalList], width = data.width;
|
|
9910
|
-
} else {
|
|
9911
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
9912
|
-
fontSize: fontSize,
|
|
9913
|
-
fontWeight: fontWeight,
|
|
9914
|
-
fontFamily: fontFamily
|
|
9915
|
-
}, maxLineWidth, !1);
|
|
9916
|
-
verticalList = [data.verticalList], width = data.width;
|
|
9917
|
-
}
|
|
9918
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9919
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
9920
|
-
const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
9921
|
-
fontSize: fontSize,
|
|
9922
|
-
fontWeight: fontWeight,
|
|
9923
|
-
fontFamily: fontFamily
|
|
9924
|
-
});
|
|
9925
|
-
width += w, t.width = w;
|
|
9926
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
9927
|
-
this.clearUpdateShapeTag();
|
|
9928
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
9929
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
9930
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9931
|
-
}
|
|
9932
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
9933
|
-
var _a, _b;
|
|
9934
|
-
const textTheme = this.getGraphicTheme(),
|
|
9935
|
-
{
|
|
9936
|
-
wrap = textTheme.wrap
|
|
9937
|
-
} = this.attribute;
|
|
9938
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
9939
|
-
const attribute = this.attribute,
|
|
9940
|
-
{
|
|
9941
|
-
fontFamily = textTheme.fontFamily,
|
|
9942
|
-
textAlign = textTheme.textAlign,
|
|
9943
|
-
textBaseline = textTheme.textBaseline,
|
|
9944
|
-
fontSize = textTheme.fontSize,
|
|
9945
|
-
fontWeight = textTheme.fontWeight,
|
|
9946
|
-
ellipsis = textTheme.ellipsis,
|
|
9947
|
-
maxLineWidth: maxLineWidth,
|
|
9948
|
-
stroke = textTheme.stroke,
|
|
9949
|
-
lineWidth = textTheme.lineWidth,
|
|
9950
|
-
whiteSpace = textTheme.whiteSpace,
|
|
9951
|
-
suffixPosition = textTheme.suffixPosition
|
|
9952
|
-
} = attribute,
|
|
9953
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
9954
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
9955
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
9956
|
-
const bbox = this.cache.layoutData.bbox;
|
|
9957
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9958
|
-
}
|
|
9959
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
9960
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9961
|
-
fontSize: fontSize,
|
|
9962
|
-
fontWeight: fontWeight,
|
|
9963
|
-
fontFamily: fontFamily
|
|
9964
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
9965
|
-
{
|
|
9966
|
-
bbox: bbox
|
|
9967
|
-
} = layoutData;
|
|
9968
|
-
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;
|
|
9969
|
-
}
|
|
9970
9925
|
updateVerticalMultilineAABBBounds(text) {
|
|
9971
|
-
var _a, _b
|
|
9926
|
+
var _a, _b;
|
|
9972
9927
|
const textTheme = this.getGraphicTheme(),
|
|
9973
9928
|
textMeasure = application.graphicUtil.textMeasure;
|
|
9974
9929
|
let width;
|
|
9975
9930
|
const attribute = this.attribute,
|
|
9976
|
-
{
|
|
9977
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
9978
|
-
} = attribute,
|
|
9979
|
-
buf = ignoreBuf ? 0 : 2,
|
|
9980
9931
|
{
|
|
9981
9932
|
maxLineWidth = textTheme.maxLineWidth,
|
|
9982
9933
|
ellipsis = textTheme.ellipsis,
|
|
@@ -9988,14 +9939,14 @@ class Text extends Graphic {
|
|
|
9988
9939
|
verticalMode = textTheme.verticalMode,
|
|
9989
9940
|
suffixPosition = textTheme.suffixPosition
|
|
9990
9941
|
} = attribute,
|
|
9991
|
-
lineHeight =
|
|
9942
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
9992
9943
|
let {
|
|
9993
9944
|
textAlign = textTheme.textAlign,
|
|
9994
9945
|
textBaseline = textTheme.textBaseline
|
|
9995
9946
|
} = attribute;
|
|
9996
9947
|
if (!verticalMode) {
|
|
9997
9948
|
const t = textAlign;
|
|
9998
|
-
textAlign = null !== (
|
|
9949
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
9999
9950
|
}
|
|
10000
9951
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
10001
9952
|
this.cache.verticalList.forEach(item => {
|
|
@@ -10043,6 +9994,15 @@ class Text extends Graphic {
|
|
|
10043
9994
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
10044
9995
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
10045
9996
|
}
|
|
9997
|
+
getMaxWidth(theme) {
|
|
9998
|
+
var _a, _b;
|
|
9999
|
+
const attribute = this.attribute;
|
|
10000
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
10001
|
+
}
|
|
10002
|
+
getLineHeight(attribute, textTheme) {
|
|
10003
|
+
var _a;
|
|
10004
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
10005
|
+
}
|
|
10046
10006
|
needUpdateTags(keys) {
|
|
10047
10007
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
10048
10008
|
return super.needUpdateTags(keys, k);
|
|
@@ -10057,6 +10017,12 @@ class Text extends Graphic {
|
|
|
10057
10017
|
getNoWorkAnimateAttr() {
|
|
10058
10018
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
10059
10019
|
}
|
|
10020
|
+
getBaselineMapAlign() {
|
|
10021
|
+
return Text.baselineMapAlign;
|
|
10022
|
+
}
|
|
10023
|
+
getAlignMapBaseline() {
|
|
10024
|
+
return Text.alignMapBaseline;
|
|
10025
|
+
}
|
|
10060
10026
|
}
|
|
10061
10027
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
10062
10028
|
ellipsis: 1,
|
|
@@ -10135,7 +10101,9 @@ class WrapText extends Text {
|
|
|
10135
10101
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10136
10102
|
linesLayout.push({
|
|
10137
10103
|
str: clip.str,
|
|
10138
|
-
width: clip.width
|
|
10104
|
+
width: clip.width,
|
|
10105
|
+
ascent: 0,
|
|
10106
|
+
descent: 0
|
|
10139
10107
|
});
|
|
10140
10108
|
break;
|
|
10141
10109
|
}
|
|
@@ -10149,7 +10117,9 @@ class WrapText extends Text {
|
|
|
10149
10117
|
}
|
|
10150
10118
|
if (linesLayout.push({
|
|
10151
10119
|
str: clip.str,
|
|
10152
|
-
width: clip.width
|
|
10120
|
+
width: clip.width,
|
|
10121
|
+
ascent: 0,
|
|
10122
|
+
descent: 0
|
|
10153
10123
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
10154
10124
|
const newStr = str.substring(clip.str.length);
|
|
10155
10125
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -10168,13 +10138,17 @@ class WrapText extends Text {
|
|
|
10168
10138
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10169
10139
|
linesLayout.push({
|
|
10170
10140
|
str: clip.str,
|
|
10171
|
-
width: clip.width
|
|
10141
|
+
width: clip.width,
|
|
10142
|
+
ascent: 0,
|
|
10143
|
+
descent: 0
|
|
10172
10144
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
10173
10145
|
break;
|
|
10174
10146
|
}
|
|
10175
10147
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
10176
10148
|
str: text,
|
|
10177
|
-
width: width
|
|
10149
|
+
width: width,
|
|
10150
|
+
ascent: 0,
|
|
10151
|
+
descent: 0
|
|
10178
10152
|
});
|
|
10179
10153
|
}
|
|
10180
10154
|
bboxWH[0] = lineWidth;
|
|
@@ -10218,6 +10192,9 @@ class BaseSymbol {
|
|
|
10218
10192
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
10219
10193
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
10220
10194
|
}
|
|
10195
|
+
parseSize(size) {
|
|
10196
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10197
|
+
}
|
|
10221
10198
|
}
|
|
10222
10199
|
|
|
10223
10200
|
function circle(ctx, r, x, y, z) {
|
|
@@ -10228,13 +10205,13 @@ class CircleSymbol extends BaseSymbol {
|
|
|
10228
10205
|
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";
|
|
10229
10206
|
}
|
|
10230
10207
|
draw(ctx, size, x, y, z) {
|
|
10231
|
-
return circle(ctx, size / 2, x, y, z);
|
|
10208
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10232
10209
|
}
|
|
10233
10210
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10234
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
10211
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10235
10212
|
}
|
|
10236
10213
|
drawToSvgPath(size, x, y, z) {
|
|
10237
|
-
const r = size / 2;
|
|
10214
|
+
const r = this.parseSize(size) / 2;
|
|
10238
10215
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
10239
10216
|
}
|
|
10240
10217
|
}
|
|
@@ -10251,10 +10228,10 @@ class CrossSymbol extends BaseSymbol {
|
|
|
10251
10228
|
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";
|
|
10252
10229
|
}
|
|
10253
10230
|
draw(ctx, size, x, y, z) {
|
|
10254
|
-
return cross(ctx, size / 6, x, y, z);
|
|
10231
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
10255
10232
|
}
|
|
10256
10233
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10257
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
10234
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
10258
10235
|
}
|
|
10259
10236
|
}
|
|
10260
10237
|
var cross$1 = new CrossSymbol();
|
|
@@ -10267,13 +10244,13 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
10267
10244
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
10268
10245
|
}
|
|
10269
10246
|
draw(ctx, size, x, y, z) {
|
|
10270
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10247
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10271
10248
|
}
|
|
10272
10249
|
drawFitDir(ctx, size, x, y, z) {
|
|
10273
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10250
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10274
10251
|
}
|
|
10275
10252
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10276
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
10253
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10277
10254
|
}
|
|
10278
10255
|
}
|
|
10279
10256
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -10287,10 +10264,10 @@ class SquareSymbol extends BaseSymbol {
|
|
|
10287
10264
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
10288
10265
|
}
|
|
10289
10266
|
draw(ctx, size, x, y) {
|
|
10290
|
-
return square(ctx, size / 2, x, y);
|
|
10267
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
10291
10268
|
}
|
|
10292
10269
|
drawOffset(ctx, size, x, y, offset) {
|
|
10293
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
10270
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10294
10271
|
}
|
|
10295
10272
|
}
|
|
10296
10273
|
var square$1 = new SquareSymbol();
|
|
@@ -10304,10 +10281,10 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
10304
10281
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
10305
10282
|
}
|
|
10306
10283
|
draw(ctx, size, x, y) {
|
|
10307
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
10284
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10308
10285
|
}
|
|
10309
10286
|
drawOffset(ctx, size, x, y, offset) {
|
|
10310
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
10287
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10311
10288
|
}
|
|
10312
10289
|
}
|
|
10313
10290
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -10339,10 +10316,10 @@ class StarSymbol extends BaseSymbol {
|
|
|
10339
10316
|
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";
|
|
10340
10317
|
}
|
|
10341
10318
|
draw(ctx, size, transX, transY) {
|
|
10342
|
-
return star(ctx, size / 2, transX, transY);
|
|
10319
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10343
10320
|
}
|
|
10344
10321
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10345
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
10322
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10346
10323
|
}
|
|
10347
10324
|
}
|
|
10348
10325
|
var star$1 = new StarSymbol();
|
|
@@ -10360,10 +10337,10 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
10360
10337
|
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";
|
|
10361
10338
|
}
|
|
10362
10339
|
draw(ctx, size, transX, transY) {
|
|
10363
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
10340
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10364
10341
|
}
|
|
10365
10342
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10366
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
10343
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10367
10344
|
}
|
|
10368
10345
|
}
|
|
10369
10346
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -10377,10 +10354,10 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
10377
10354
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
10378
10355
|
}
|
|
10379
10356
|
draw(ctx, size, transX, transY) {
|
|
10380
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
10357
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10381
10358
|
}
|
|
10382
10359
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10383
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
10360
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10384
10361
|
}
|
|
10385
10362
|
}
|
|
10386
10363
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -10393,10 +10370,10 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
10393
10370
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
10394
10371
|
}
|
|
10395
10372
|
draw(ctx, size, transX, transY) {
|
|
10396
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
10373
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10397
10374
|
}
|
|
10398
10375
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10399
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
10376
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10400
10377
|
}
|
|
10401
10378
|
}
|
|
10402
10379
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -10418,10 +10395,10 @@ class WyeSymbol extends BaseSymbol {
|
|
|
10418
10395
|
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";
|
|
10419
10396
|
}
|
|
10420
10397
|
draw(ctx, size, transX, transY) {
|
|
10421
|
-
return wye(ctx, size / 2, transX, transY);
|
|
10398
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10422
10399
|
}
|
|
10423
10400
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10424
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
10401
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10425
10402
|
}
|
|
10426
10403
|
}
|
|
10427
10404
|
var wye$1 = new WyeSymbol();
|
|
@@ -10434,10 +10411,10 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
10434
10411
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
10435
10412
|
}
|
|
10436
10413
|
draw(ctx, size, x, y) {
|
|
10437
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
10414
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
10438
10415
|
}
|
|
10439
10416
|
drawOffset(ctx, size, x, y, offset) {
|
|
10440
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
10417
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10441
10418
|
}
|
|
10442
10419
|
}
|
|
10443
10420
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -10451,10 +10428,10 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
10451
10428
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
10452
10429
|
}
|
|
10453
10430
|
draw(ctx, size, x, y) {
|
|
10454
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
10431
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10455
10432
|
}
|
|
10456
10433
|
drawOffset(ctx, size, x, y, offset) {
|
|
10457
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
10434
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10458
10435
|
}
|
|
10459
10436
|
}
|
|
10460
10437
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -10468,10 +10445,10 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
10468
10445
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
10469
10446
|
}
|
|
10470
10447
|
draw(ctx, size, x, y) {
|
|
10471
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
10448
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10472
10449
|
}
|
|
10473
10450
|
drawOffset(ctx, size, x, y, offset) {
|
|
10474
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
10451
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10475
10452
|
}
|
|
10476
10453
|
}
|
|
10477
10454
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -10486,10 +10463,10 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
10486
10463
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
10487
10464
|
}
|
|
10488
10465
|
draw(ctx, size, x, y) {
|
|
10489
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
10466
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
10490
10467
|
}
|
|
10491
10468
|
drawOffset(ctx, size, x, y, offset) {
|
|
10492
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
10469
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
10493
10470
|
}
|
|
10494
10471
|
}
|
|
10495
10472
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -10503,10 +10480,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
10503
10480
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
10504
10481
|
}
|
|
10505
10482
|
draw(ctx, size, transX, transY) {
|
|
10506
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
10483
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10507
10484
|
}
|
|
10508
10485
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10509
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
10486
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10510
10487
|
}
|
|
10511
10488
|
}
|
|
10512
10489
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -10520,10 +10497,10 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
10520
10497
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
10521
10498
|
}
|
|
10522
10499
|
draw(ctx, size, transX, transY) {
|
|
10523
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
10500
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10524
10501
|
}
|
|
10525
10502
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10526
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
10503
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10527
10504
|
}
|
|
10528
10505
|
}
|
|
10529
10506
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -10537,10 +10514,10 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
10537
10514
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
10538
10515
|
}
|
|
10539
10516
|
draw(ctx, size, transX, transY) {
|
|
10540
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
10517
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10541
10518
|
}
|
|
10542
10519
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10543
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
10520
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10544
10521
|
}
|
|
10545
10522
|
}
|
|
10546
10523
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -10554,10 +10531,10 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
10554
10531
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
10555
10532
|
}
|
|
10556
10533
|
draw(ctx, size, transX, transY) {
|
|
10557
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
10534
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10558
10535
|
}
|
|
10559
10536
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10560
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
10537
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10561
10538
|
}
|
|
10562
10539
|
}
|
|
10563
10540
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -10570,13 +10547,13 @@ class LineVSymbol extends BaseSymbol {
|
|
|
10570
10547
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
10571
10548
|
}
|
|
10572
10549
|
draw(ctx, size, x, y, z) {
|
|
10573
|
-
return lineV(ctx, size / 2, x, y);
|
|
10550
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
10574
10551
|
}
|
|
10575
10552
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10576
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
10553
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10577
10554
|
}
|
|
10578
10555
|
drawToSvgPath(size, x, y, z) {
|
|
10579
|
-
const r = size / 2;
|
|
10556
|
+
const r = this.parseSize(size) / 2;
|
|
10580
10557
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
10581
10558
|
}
|
|
10582
10559
|
}
|
|
@@ -10590,13 +10567,13 @@ class LineHSymbol extends BaseSymbol {
|
|
|
10590
10567
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
10591
10568
|
}
|
|
10592
10569
|
draw(ctx, size, x, y, z) {
|
|
10593
|
-
return lineH(ctx, size / 2, x, y);
|
|
10570
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
10594
10571
|
}
|
|
10595
10572
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10596
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
10573
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10597
10574
|
}
|
|
10598
10575
|
drawToSvgPath(size, x, y, z) {
|
|
10599
|
-
const r = size / 2;
|
|
10576
|
+
const r = this.parseSize(size) / 2;
|
|
10600
10577
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
10601
10578
|
}
|
|
10602
10579
|
}
|
|
@@ -10610,13 +10587,13 @@ class CloseSymbol extends BaseSymbol {
|
|
|
10610
10587
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
10611
10588
|
}
|
|
10612
10589
|
draw(ctx, size, x, y, z) {
|
|
10613
|
-
return close(ctx, size / 2, x, y);
|
|
10590
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
10614
10591
|
}
|
|
10615
10592
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10616
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
10593
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10617
10594
|
}
|
|
10618
10595
|
drawToSvgPath(size, x, y, z) {
|
|
10619
|
-
const r = size / 2;
|
|
10596
|
+
const r = this.parseSize(size) / 2;
|
|
10620
10597
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
10621
10598
|
}
|
|
10622
10599
|
}
|
|
@@ -10650,15 +10627,18 @@ class CustomSymbolClass {
|
|
|
10650
10627
|
this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
10651
10628
|
}
|
|
10652
10629
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
10653
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10630
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10654
10631
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
10655
10632
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
10656
10633
|
}
|
|
10657
10634
|
draw(ctx, size, x, y, z, cb) {
|
|
10658
|
-
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10635
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10636
|
+
}
|
|
10637
|
+
parseSize(size) {
|
|
10638
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10659
10639
|
}
|
|
10660
10640
|
bounds(size, bounds) {
|
|
10661
|
-
if (this.isSvg) {
|
|
10641
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
10662
10642
|
if (!this.svgCache) return;
|
|
10663
10643
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
10664
10644
|
let {
|
|
@@ -11162,7 +11142,11 @@ class Paragraph {
|
|
|
11162
11142
|
case "sub":
|
|
11163
11143
|
baseline += this.descent / 2;
|
|
11164
11144
|
}
|
|
11165
|
-
"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)
|
|
11145
|
+
"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);
|
|
11146
|
+
const {
|
|
11147
|
+
lineWidth = 1
|
|
11148
|
+
} = this.character;
|
|
11149
|
+
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();
|
|
11166
11150
|
}
|
|
11167
11151
|
getWidthWithEllips(direction) {
|
|
11168
11152
|
let text = this.text;
|
|
@@ -13349,8 +13333,9 @@ class PickerBase {
|
|
|
13349
13333
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
13350
13334
|
if (picked) return !0;
|
|
13351
13335
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13352
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13353
|
-
|
|
13336
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13337
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13338
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13354
13339
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13355
13340
|
}
|
|
13356
13341
|
}
|
|
@@ -13572,8 +13557,9 @@ class RectPickerBase {
|
|
|
13572
13557
|
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) => {
|
|
13573
13558
|
if (picked) return !0;
|
|
13574
13559
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13575
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13576
|
-
|
|
13560
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13561
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13562
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13577
13563
|
});else {
|
|
13578
13564
|
const {
|
|
13579
13565
|
fill = rectAttribute.fill,
|
|
@@ -13752,8 +13738,9 @@ class BaseLinePicker extends BaseRender {
|
|
|
13752
13738
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
13753
13739
|
if (picked) return !0;
|
|
13754
13740
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13755
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13756
|
-
|
|
13741
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13742
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13743
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13757
13744
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13758
13745
|
}
|
|
13759
13746
|
}
|
|
@@ -13888,8 +13875,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
13888
13875
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
13889
13876
|
if (picked) return !0;
|
|
13890
13877
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13891
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13892
|
-
|
|
13878
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13879
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13880
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13893
13881
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13894
13882
|
}
|
|
13895
13883
|
};
|
|
@@ -14453,88 +14441,370 @@ class ScrollBar extends AbstractComponent {
|
|
|
14453
14441
|
? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
|
|
14454
14442
|
: clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
|
|
14455
14443
|
}
|
|
14456
|
-
_reset() {
|
|
14457
|
-
this._sliderRenderBounds = null;
|
|
14458
|
-
this._sliderLimitRange = null;
|
|
14444
|
+
_reset() {
|
|
14445
|
+
this._sliderRenderBounds = null;
|
|
14446
|
+
this._sliderLimitRange = null;
|
|
14447
|
+
}
|
|
14448
|
+
}
|
|
14449
|
+
ScrollBar.defaultAttributes = {
|
|
14450
|
+
direction: 'horizontal',
|
|
14451
|
+
round: true,
|
|
14452
|
+
sliderSize: 20,
|
|
14453
|
+
sliderStyle: {
|
|
14454
|
+
fill: 'rgba(0, 0, 0, .5)'
|
|
14455
|
+
},
|
|
14456
|
+
railStyle: {
|
|
14457
|
+
fill: 'rgba(0, 0, 0, .0)'
|
|
14458
|
+
},
|
|
14459
|
+
padding: 2,
|
|
14460
|
+
scrollRange: [0, 1],
|
|
14461
|
+
delayType: 'throttle',
|
|
14462
|
+
delayTime: 0,
|
|
14463
|
+
realTime: true
|
|
14464
|
+
};
|
|
14465
|
+
|
|
14466
|
+
/******************************************************************************
|
|
14467
|
+
Copyright (c) Microsoft Corporation.
|
|
14468
|
+
|
|
14469
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14470
|
+
purpose with or without fee is hereby granted.
|
|
14471
|
+
|
|
14472
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14473
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14474
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14475
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14476
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14477
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14478
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14479
|
+
***************************************************************************** */
|
|
14480
|
+
function __rest(s, e) {
|
|
14481
|
+
var t = {};
|
|
14482
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14483
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14484
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
14485
|
+
}
|
|
14486
|
+
return t;
|
|
14487
|
+
}
|
|
14488
|
+
function __decorate(decorators, target, key, desc) {
|
|
14489
|
+
var c = arguments.length,
|
|
14490
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
14491
|
+
d;
|
|
14492
|
+
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;
|
|
14493
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14494
|
+
}
|
|
14495
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14496
|
+
function adopt(value) {
|
|
14497
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
14498
|
+
resolve(value);
|
|
14499
|
+
});
|
|
14500
|
+
}
|
|
14501
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14502
|
+
function fulfilled(value) {
|
|
14503
|
+
try {
|
|
14504
|
+
step(generator.next(value));
|
|
14505
|
+
} catch (e) {
|
|
14506
|
+
reject(e);
|
|
14507
|
+
}
|
|
14508
|
+
}
|
|
14509
|
+
function rejected(value) {
|
|
14510
|
+
try {
|
|
14511
|
+
step(generator["throw"](value));
|
|
14512
|
+
} catch (e) {
|
|
14513
|
+
reject(e);
|
|
14514
|
+
}
|
|
14515
|
+
}
|
|
14516
|
+
function step(result) {
|
|
14517
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
14518
|
+
}
|
|
14519
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14520
|
+
});
|
|
14521
|
+
}
|
|
14522
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
14523
|
+
var e = new Error(message);
|
|
14524
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14525
|
+
};
|
|
14526
|
+
|
|
14527
|
+
var ScrollBarPlugin_1;
|
|
14528
|
+
let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
|
|
14529
|
+
constructor() {
|
|
14530
|
+
this.name = 'scrollbar';
|
|
14531
|
+
this.activeEvent = 'onRegister';
|
|
14532
|
+
this._uid = Generator.GenAutoIncrementId();
|
|
14533
|
+
this.key = this.name + this._uid;
|
|
14534
|
+
this.scroll = (e) => {
|
|
14535
|
+
var _a, _b;
|
|
14536
|
+
const graphic = e.target;
|
|
14537
|
+
const data = this.getScrollContainer(graphic);
|
|
14538
|
+
if (!data && !this.scrollContainer) {
|
|
14539
|
+
return;
|
|
14540
|
+
}
|
|
14541
|
+
if (!data && this.scrollContainer) {
|
|
14542
|
+
if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
|
|
14543
|
+
return;
|
|
14544
|
+
}
|
|
14545
|
+
const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
|
|
14546
|
+
if (!newScrollContainer) {
|
|
14547
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14548
|
+
return;
|
|
14549
|
+
}
|
|
14550
|
+
if (this.scrollContainer.showH && !newScrollContainer.showH) {
|
|
14551
|
+
this.clearScrollbar(this.scrollContainer.g, 'horizontal');
|
|
14552
|
+
}
|
|
14553
|
+
if (this.scrollContainer.showV && !newScrollContainer.showV) {
|
|
14554
|
+
this.clearScrollbar(this.scrollContainer.g, 'vertical');
|
|
14555
|
+
}
|
|
14556
|
+
this.scrollContainer = newScrollContainer;
|
|
14557
|
+
}
|
|
14558
|
+
else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
|
|
14559
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14560
|
+
}
|
|
14561
|
+
this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
|
|
14562
|
+
const scrollContainer = data.g;
|
|
14563
|
+
const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
|
|
14564
|
+
let newScrollX = scrollX;
|
|
14565
|
+
let newScrollY = scrollY;
|
|
14566
|
+
let { showH, showV } = data;
|
|
14567
|
+
this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
|
|
14568
|
+
if (showH && showH) {
|
|
14569
|
+
if (abs(e.deltaX) > abs(e.deltaY)) {
|
|
14570
|
+
showH = showH && true;
|
|
14571
|
+
showV = showV && false;
|
|
14572
|
+
}
|
|
14573
|
+
else {
|
|
14574
|
+
showH = showH && false;
|
|
14575
|
+
showV = showV && true;
|
|
14576
|
+
}
|
|
14577
|
+
}
|
|
14578
|
+
const childrenBounds = this.childrenBounds;
|
|
14579
|
+
childrenBounds.clear();
|
|
14580
|
+
childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
|
|
14581
|
+
const scrollWidth = childrenBounds.width();
|
|
14582
|
+
const scrollHeight = childrenBounds.height();
|
|
14583
|
+
if (showH) {
|
|
14584
|
+
newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
|
|
14585
|
+
}
|
|
14586
|
+
else {
|
|
14587
|
+
newScrollX = -scrollX;
|
|
14588
|
+
}
|
|
14589
|
+
if (showV) {
|
|
14590
|
+
newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
|
|
14591
|
+
}
|
|
14592
|
+
else {
|
|
14593
|
+
newScrollY = -scrollY;
|
|
14594
|
+
}
|
|
14595
|
+
childrenBounds.translate(-newScrollX, -newScrollY);
|
|
14596
|
+
this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
|
|
14597
|
+
scrollContainer.setAttributes({
|
|
14598
|
+
scrollX: -newScrollX,
|
|
14599
|
+
scrollY: -newScrollY
|
|
14600
|
+
});
|
|
14601
|
+
};
|
|
14602
|
+
this.handleScrollBarChange = (params) => {
|
|
14603
|
+
if (!this.scrollContainer ||
|
|
14604
|
+
!this.scrollContainerBounds ||
|
|
14605
|
+
!this.childrenBounds ||
|
|
14606
|
+
!params ||
|
|
14607
|
+
!params.target ||
|
|
14608
|
+
!params.detail ||
|
|
14609
|
+
!params.detail.value) {
|
|
14610
|
+
return;
|
|
14611
|
+
}
|
|
14612
|
+
const scrollbar = params.target;
|
|
14613
|
+
const newRange = params.detail.value;
|
|
14614
|
+
if (scrollbar.attribute.direction === 'horizontal') {
|
|
14615
|
+
const scrollWidth = this.childrenBounds.width();
|
|
14616
|
+
this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
|
|
14617
|
+
}
|
|
14618
|
+
else {
|
|
14619
|
+
const scrollHeight = this.childrenBounds.height();
|
|
14620
|
+
this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
|
|
14621
|
+
}
|
|
14622
|
+
};
|
|
14623
|
+
}
|
|
14624
|
+
activate(context) {
|
|
14625
|
+
this.pluginService = context;
|
|
14626
|
+
const { stage } = this.pluginService;
|
|
14627
|
+
this.childrenBounds = new AABBBounds();
|
|
14628
|
+
stage.addEventListener('wheel', this.scroll);
|
|
14629
|
+
this.params = ScrollBarPlugin_1.defaultParams;
|
|
14630
|
+
}
|
|
14631
|
+
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
14632
|
+
scrollContainer.addEventListener('pointerover', () => {
|
|
14633
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14634
|
+
});
|
|
14635
|
+
scrollContainer.addEventListener('pointermove', () => {
|
|
14636
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14637
|
+
});
|
|
14638
|
+
scrollContainer.addEventListener('pointerout', () => {
|
|
14639
|
+
scrollbar.setAttribute('visibleAll', false);
|
|
14640
|
+
});
|
|
14641
|
+
scrollbar.addEventListener('pointerover', () => {
|
|
14642
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14643
|
+
});
|
|
14644
|
+
scrollbar.addEventListener('pointerout', () => {
|
|
14645
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14646
|
+
});
|
|
14647
|
+
scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
|
|
14648
|
+
scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
|
|
14649
|
+
}
|
|
14650
|
+
addOrUpdateScroll(showH, showV, container, scrollContainer) {
|
|
14651
|
+
if (showH) {
|
|
14652
|
+
const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
|
|
14653
|
+
if (!isUpdate) {
|
|
14654
|
+
this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
|
|
14655
|
+
}
|
|
14656
|
+
}
|
|
14657
|
+
else {
|
|
14658
|
+
this.clearScrollbar(scrollContainer, 'horizontal');
|
|
14659
|
+
}
|
|
14660
|
+
if (showV) {
|
|
14661
|
+
const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
|
|
14662
|
+
if (!isUpdate) {
|
|
14663
|
+
this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
|
|
14664
|
+
}
|
|
14665
|
+
}
|
|
14666
|
+
else {
|
|
14667
|
+
this.clearScrollbar(scrollContainer, 'vertical');
|
|
14668
|
+
}
|
|
14669
|
+
}
|
|
14670
|
+
getDirection(isHorozntal) {
|
|
14671
|
+
return isHorozntal ? 'horizontal' : 'vertical';
|
|
14672
|
+
}
|
|
14673
|
+
addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
|
|
14674
|
+
var _a;
|
|
14675
|
+
const direction = this.getDirection(isHorozntal);
|
|
14676
|
+
const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
|
|
14677
|
+
const scrollbars = container.children.filter((g) => g.name === name);
|
|
14678
|
+
let isUpdate = true;
|
|
14679
|
+
let scrollBar = scrollbars[0];
|
|
14680
|
+
const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
|
|
14681
|
+
const attrs = {
|
|
14682
|
+
x: 0,
|
|
14683
|
+
y: 0,
|
|
14684
|
+
direction,
|
|
14685
|
+
zIndex: zIndex + 1,
|
|
14686
|
+
visibleAll: true,
|
|
14687
|
+
padding: [2, 0],
|
|
14688
|
+
railStyle: {
|
|
14689
|
+
fill: 'rgba(0, 0, 0, .1)'
|
|
14690
|
+
},
|
|
14691
|
+
range: [0, 0.05]
|
|
14692
|
+
};
|
|
14693
|
+
if (isHorozntal) {
|
|
14694
|
+
attrs.width = this.scrollContainerBounds.width();
|
|
14695
|
+
attrs.height = 12;
|
|
14696
|
+
}
|
|
14697
|
+
else {
|
|
14698
|
+
attrs.height = this.scrollContainerBounds.height();
|
|
14699
|
+
attrs.width = 12;
|
|
14700
|
+
}
|
|
14701
|
+
if (!scrollBar) {
|
|
14702
|
+
isUpdate = false;
|
|
14703
|
+
scrollBar = new ScrollBar(attrs);
|
|
14704
|
+
scrollBar.name = name;
|
|
14705
|
+
container.add(scrollBar);
|
|
14706
|
+
scrollBar.isScrollBar = true;
|
|
14707
|
+
}
|
|
14708
|
+
else if (scrollbars.length > 1) {
|
|
14709
|
+
scrollbars.forEach((child, index) => {
|
|
14710
|
+
var _a;
|
|
14711
|
+
if (index) {
|
|
14712
|
+
(_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
|
14713
|
+
}
|
|
14714
|
+
});
|
|
14715
|
+
}
|
|
14716
|
+
const childrenBounds = this.childrenBounds;
|
|
14717
|
+
if (isHorozntal) {
|
|
14718
|
+
const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
|
|
14719
|
+
const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
|
|
14720
|
+
attrs.x = x + dx;
|
|
14721
|
+
attrs.y = y + dy + height - this.scrollContainerBounds.height();
|
|
14722
|
+
attrs.range = [-start, -start + ratio];
|
|
14723
|
+
}
|
|
14724
|
+
else {
|
|
14725
|
+
const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
|
|
14726
|
+
const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
|
|
14727
|
+
attrs.x = x + dx + width - this.scrollContainerBounds.width();
|
|
14728
|
+
attrs.y = y + dy;
|
|
14729
|
+
attrs.range = [-start, -start + ratio];
|
|
14730
|
+
}
|
|
14731
|
+
scrollBar.setAttributes(attrs);
|
|
14732
|
+
return {
|
|
14733
|
+
scrollBar,
|
|
14734
|
+
isUpdate
|
|
14735
|
+
};
|
|
14736
|
+
}
|
|
14737
|
+
clearScrollbar(scrollContainer, type) {
|
|
14738
|
+
if (!scrollContainer.parent) {
|
|
14739
|
+
return;
|
|
14740
|
+
}
|
|
14741
|
+
const scrollbarBars = scrollContainer.parent.children.filter((child) => {
|
|
14742
|
+
return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
|
|
14743
|
+
});
|
|
14744
|
+
scrollbarBars.forEach((child) => {
|
|
14745
|
+
child.parent.removeChild(child);
|
|
14746
|
+
});
|
|
14747
|
+
}
|
|
14748
|
+
formatScrollContainer(g) {
|
|
14749
|
+
if (!g || g.type !== 'group' || !g.attribute) {
|
|
14750
|
+
return null;
|
|
14751
|
+
}
|
|
14752
|
+
const { overflow, width, height } = g.attribute;
|
|
14753
|
+
if (!overflow || overflow === 'hidden') {
|
|
14754
|
+
return null;
|
|
14755
|
+
}
|
|
14756
|
+
let showH = false;
|
|
14757
|
+
let showV = false;
|
|
14758
|
+
if (overflow === 'scroll') {
|
|
14759
|
+
showH = true;
|
|
14760
|
+
showV = true;
|
|
14761
|
+
}
|
|
14762
|
+
else {
|
|
14763
|
+
showH = overflow === 'scroll-x';
|
|
14764
|
+
showV = !showH;
|
|
14765
|
+
}
|
|
14766
|
+
if (!g.AABBBounds.empty()) {
|
|
14767
|
+
if (showH) {
|
|
14768
|
+
showH = width < g.AABBBounds.width();
|
|
14769
|
+
}
|
|
14770
|
+
if (showV) {
|
|
14771
|
+
showV = height < g.AABBBounds.height();
|
|
14772
|
+
}
|
|
14773
|
+
}
|
|
14774
|
+
return showH || showV ? { g: g, showH, showV } : null;
|
|
14775
|
+
}
|
|
14776
|
+
getScrollContainer(graphic) {
|
|
14777
|
+
let g = graphic;
|
|
14778
|
+
while (g) {
|
|
14779
|
+
const res = this.formatScrollContainer(g);
|
|
14780
|
+
if (res) {
|
|
14781
|
+
return res;
|
|
14782
|
+
}
|
|
14783
|
+
g = g.parent;
|
|
14784
|
+
}
|
|
14785
|
+
return null;
|
|
14786
|
+
}
|
|
14787
|
+
deactivate(context) {
|
|
14788
|
+
const { stage } = this.pluginService;
|
|
14789
|
+
stage.removeEventListener('wheel', this.scroll);
|
|
14459
14790
|
}
|
|
14460
|
-
}
|
|
14461
|
-
ScrollBar.defaultAttributes = {
|
|
14462
|
-
direction: 'horizontal',
|
|
14463
|
-
round: true,
|
|
14464
|
-
sliderSize: 20,
|
|
14465
|
-
sliderStyle: {
|
|
14466
|
-
fill: 'rgba(0, 0, 0, .5)'
|
|
14467
|
-
},
|
|
14468
|
-
railStyle: {
|
|
14469
|
-
fill: 'rgba(0, 0, 0, .0)'
|
|
14470
|
-
},
|
|
14471
|
-
padding: 2,
|
|
14472
|
-
scrollRange: [0, 1],
|
|
14473
|
-
delayType: 'throttle',
|
|
14474
|
-
delayTime: 0,
|
|
14475
|
-
realTime: true
|
|
14476
14791
|
};
|
|
14792
|
+
ScrollBarPlugin.defaultParams = {
|
|
14793
|
+
timeout: 500
|
|
14794
|
+
};
|
|
14795
|
+
ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
|
|
14796
|
+
injectable()
|
|
14797
|
+
], ScrollBarPlugin);
|
|
14477
14798
|
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
purpose with or without fee is hereby granted.
|
|
14483
|
-
|
|
14484
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14485
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14486
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14487
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14488
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14489
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14490
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14491
|
-
***************************************************************************** */
|
|
14492
|
-
function __rest(s, e) {
|
|
14493
|
-
var t = {};
|
|
14494
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14495
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14496
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
14497
|
-
}
|
|
14498
|
-
return t;
|
|
14499
|
-
}
|
|
14500
|
-
function __decorate(decorators, target, key, desc) {
|
|
14501
|
-
var c = arguments.length,
|
|
14502
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
14503
|
-
d;
|
|
14504
|
-
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;
|
|
14505
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14506
|
-
}
|
|
14507
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14508
|
-
function adopt(value) {
|
|
14509
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
14510
|
-
resolve(value);
|
|
14511
|
-
});
|
|
14512
|
-
}
|
|
14513
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14514
|
-
function fulfilled(value) {
|
|
14515
|
-
try {
|
|
14516
|
-
step(generator.next(value));
|
|
14517
|
-
} catch (e) {
|
|
14518
|
-
reject(e);
|
|
14519
|
-
}
|
|
14520
|
-
}
|
|
14521
|
-
function rejected(value) {
|
|
14522
|
-
try {
|
|
14523
|
-
step(generator["throw"](value));
|
|
14524
|
-
} catch (e) {
|
|
14525
|
-
reject(e);
|
|
14526
|
-
}
|
|
14527
|
-
}
|
|
14528
|
-
function step(result) {
|
|
14529
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
14799
|
+
const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
14800
|
+
if (!isBound(ScrollBarPlugin)) {
|
|
14801
|
+
bind(ScrollBarPlugin).toSelf();
|
|
14802
|
+
bind(AutoEnablePlugins).toService(ScrollBarPlugin);
|
|
14530
14803
|
}
|
|
14531
|
-
|
|
14532
|
-
|
|
14804
|
+
});
|
|
14805
|
+
function loadScrollbar() {
|
|
14806
|
+
container.load(scrollbarModule);
|
|
14533
14807
|
}
|
|
14534
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
14535
|
-
var e = new Error(message);
|
|
14536
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14537
|
-
};
|
|
14538
14808
|
|
|
14539
14809
|
function traverseGroup(group, cb) {
|
|
14540
14810
|
group.forEachChildren(node => {
|
|
@@ -15993,24 +16263,29 @@ function defaultLabelPosition(type) {
|
|
|
15993
16263
|
return DefaultPositions;
|
|
15994
16264
|
}
|
|
15995
16265
|
}
|
|
15996
|
-
function clampText(text, width, height) {
|
|
16266
|
+
function clampText(text, width, height, padding = {}) {
|
|
15997
16267
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16268
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
15998
16269
|
const minX = Math.min(x1, x2);
|
|
15999
16270
|
const maxX = Math.max(x1, x2);
|
|
16000
16271
|
const minY = Math.min(y1, y2);
|
|
16001
16272
|
const maxY = Math.max(y1, y2);
|
|
16273
|
+
const minXWithPadding = 0 - left;
|
|
16274
|
+
const maxXWithPadding = width + right;
|
|
16275
|
+
const minYWithPadding = 0 - top;
|
|
16276
|
+
const maxYWithPadding = height + bottom;
|
|
16002
16277
|
let dx = 0;
|
|
16003
16278
|
let dy = 0;
|
|
16004
|
-
if (minX <
|
|
16279
|
+
if (minX < minXWithPadding && maxX - minX <= width) {
|
|
16005
16280
|
dx = -minX;
|
|
16006
16281
|
}
|
|
16007
|
-
else if (maxX >
|
|
16282
|
+
else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
|
|
16008
16283
|
dx = width - maxX;
|
|
16009
16284
|
}
|
|
16010
|
-
if (minY <
|
|
16285
|
+
if (minY < minYWithPadding && maxY - minY <= height) {
|
|
16011
16286
|
dy = -minY;
|
|
16012
16287
|
}
|
|
16013
|
-
else if (maxY >
|
|
16288
|
+
else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
|
|
16014
16289
|
dy = height - maxY;
|
|
16015
16290
|
}
|
|
16016
16291
|
return { dx, dy };
|
|
@@ -16310,56 +16585,121 @@ function loadLabelComponent() {
|
|
|
16310
16585
|
registerLine();
|
|
16311
16586
|
}
|
|
16312
16587
|
|
|
16313
|
-
|
|
16314
|
-
|
|
16588
|
+
const isIntersect = (top, bottom) => {
|
|
16589
|
+
return Math.ceil(top) > Math.floor(bottom);
|
|
16590
|
+
};
|
|
16591
|
+
const isXIntersect = ([a, b], [c, d]) => {
|
|
16592
|
+
return d > a && b > c;
|
|
16593
|
+
};
|
|
16594
|
+
function getIntersectionLength(range1, range2) {
|
|
16595
|
+
const [start1, end1] = range1;
|
|
16596
|
+
const [start2, end2] = range2;
|
|
16597
|
+
const start = Math.max(start1, start2);
|
|
16598
|
+
const end = Math.min(end1, end2);
|
|
16599
|
+
return Math.max(0, end - start);
|
|
16600
|
+
}
|
|
16601
|
+
function shiftY(texts, option) {
|
|
16602
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
|
|
16315
16603
|
const n = texts.length;
|
|
16316
16604
|
if (n <= 1) {
|
|
16317
16605
|
return texts;
|
|
16318
16606
|
}
|
|
16319
|
-
const
|
|
16320
|
-
return d > a && b > c;
|
|
16321
|
-
};
|
|
16607
|
+
const xMap = new Map();
|
|
16322
16608
|
const textInformation = new Map();
|
|
16323
|
-
const
|
|
16324
|
-
const getY = (text) => textInformation.get(text).y;
|
|
16609
|
+
const getY1Initial = (text) => textInformation.get(text).y1Initial;
|
|
16325
16610
|
const getHeight = (text) => textInformation.get(text).height;
|
|
16611
|
+
const getY1 = (text) => textInformation.get(text).y1;
|
|
16612
|
+
const getY = (text) => textInformation.get(text).y;
|
|
16613
|
+
const getX = (text) => textInformation.get(text).x;
|
|
16326
16614
|
const getX1 = (text) => textInformation.get(text).x1;
|
|
16327
16615
|
const getX2 = (text) => textInformation.get(text).x2;
|
|
16328
|
-
const
|
|
16329
|
-
textInformation.get(text).
|
|
16616
|
+
const setY1 = (text, y) => {
|
|
16617
|
+
textInformation.get(text).y1 = y;
|
|
16330
16618
|
};
|
|
16619
|
+
function adjustPositionInOneGroup(texts) {
|
|
16620
|
+
if (texts.length === 1) {
|
|
16621
|
+
return;
|
|
16622
|
+
}
|
|
16623
|
+
for (let i = texts.length - 1; i > 0; i--) {
|
|
16624
|
+
const curText = texts[i];
|
|
16625
|
+
const upperText = texts[i - 1];
|
|
16626
|
+
const lowerText = texts[i + 1];
|
|
16627
|
+
if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
|
|
16628
|
+
const { y } = labelling(curText);
|
|
16629
|
+
if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
|
|
16630
|
+
if (y + getHeight(curText) / 2 <= maxY) {
|
|
16631
|
+
setY1(curText, getY1(curText) + y - getY(curText));
|
|
16632
|
+
}
|
|
16633
|
+
}
|
|
16634
|
+
}
|
|
16635
|
+
}
|
|
16636
|
+
}
|
|
16637
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16331
16638
|
for (const text of texts) {
|
|
16332
16639
|
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16333
|
-
|
|
16640
|
+
const { x, y } = text.attribute;
|
|
16641
|
+
textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
|
|
16642
|
+
let hasRange = false;
|
|
16643
|
+
for (const [range, xGroupTexts] of xMap) {
|
|
16644
|
+
const { start, end } = range;
|
|
16645
|
+
if (x1 >= start && x2 <= end) {
|
|
16646
|
+
xGroupTexts.push(text);
|
|
16647
|
+
hasRange = true;
|
|
16648
|
+
}
|
|
16649
|
+
else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
|
|
16650
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16651
|
+
xGroupTexts.push(text);
|
|
16652
|
+
xMap.set(newRange, xGroupTexts);
|
|
16653
|
+
xMap.delete(range);
|
|
16654
|
+
hasRange = true;
|
|
16655
|
+
}
|
|
16656
|
+
else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
|
|
16657
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16658
|
+
xGroupTexts.push(text);
|
|
16659
|
+
xMap.set(newRange, xGroupTexts);
|
|
16660
|
+
xMap.delete(range);
|
|
16661
|
+
hasRange = true;
|
|
16662
|
+
}
|
|
16663
|
+
if (hasRange) {
|
|
16664
|
+
break;
|
|
16665
|
+
}
|
|
16666
|
+
}
|
|
16667
|
+
if (!hasRange) {
|
|
16668
|
+
xMap.set({ start: x1, end: x2 }, [text]);
|
|
16669
|
+
}
|
|
16670
|
+
}
|
|
16671
|
+
for (const xTexts of xMap.values()) {
|
|
16672
|
+
xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
|
|
16673
|
+
adjustPositionInOneGroup(xTexts);
|
|
16334
16674
|
}
|
|
16335
16675
|
for (let iter = 0; iter < maxIterations; iter++) {
|
|
16336
|
-
texts.sort((a, b) =>
|
|
16676
|
+
texts.sort((a, b) => getY1(a) - getY1(b));
|
|
16337
16677
|
let error = 0;
|
|
16338
16678
|
for (let i = 0; i < n - 1; i++) {
|
|
16339
16679
|
const curText = texts[i];
|
|
16340
16680
|
let j = i + 1;
|
|
16341
16681
|
let nextText;
|
|
16342
16682
|
while ((nextText = texts[j]) &&
|
|
16343
|
-
!
|
|
16683
|
+
!isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
|
|
16344
16684
|
j += 1;
|
|
16345
16685
|
}
|
|
16346
16686
|
if (nextText) {
|
|
16347
|
-
const
|
|
16687
|
+
const y1 = getY1(curText);
|
|
16348
16688
|
const h0 = getHeight(curText);
|
|
16349
|
-
const
|
|
16350
|
-
const delta =
|
|
16689
|
+
const nextY1 = getY1(nextText);
|
|
16690
|
+
const delta = nextY1 - (y1 + h0);
|
|
16351
16691
|
if (delta < padding) {
|
|
16352
16692
|
const newDelta = (padding - delta) / 2;
|
|
16353
16693
|
error = Math.max(error, newDelta);
|
|
16354
16694
|
if (y1 + newDelta + getHeight(nextText) > maxY) {
|
|
16355
|
-
|
|
16695
|
+
setY1(curText, y1 - (padding - delta));
|
|
16356
16696
|
}
|
|
16357
|
-
else if (
|
|
16358
|
-
|
|
16697
|
+
else if (y1 - newDelta < 0) {
|
|
16698
|
+
setY1(nextText, nextY1 + (padding - delta));
|
|
16359
16699
|
}
|
|
16360
16700
|
else {
|
|
16361
|
-
|
|
16362
|
-
|
|
16701
|
+
setY1(curText, y1 - newDelta);
|
|
16702
|
+
setY1(nextText, nextY1 + newDelta);
|
|
16363
16703
|
}
|
|
16364
16704
|
}
|
|
16365
16705
|
}
|
|
@@ -16369,10 +16709,25 @@ function shiftY(texts, option = {}) {
|
|
|
16369
16709
|
}
|
|
16370
16710
|
}
|
|
16371
16711
|
for (const text of texts) {
|
|
16372
|
-
const finalY = text.attribute.y +
|
|
16712
|
+
const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
|
|
16373
16713
|
text.setAttribute('y', finalY);
|
|
16374
16714
|
}
|
|
16375
|
-
|
|
16715
|
+
const result = [];
|
|
16716
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16717
|
+
let start = 0;
|
|
16718
|
+
let end = texts.length - 1;
|
|
16719
|
+
while (start <= end) {
|
|
16720
|
+
if (start === end) {
|
|
16721
|
+
result.push(texts[start]);
|
|
16722
|
+
}
|
|
16723
|
+
else {
|
|
16724
|
+
result.push(texts[start]);
|
|
16725
|
+
result.push(texts[end]);
|
|
16726
|
+
}
|
|
16727
|
+
start++;
|
|
16728
|
+
end--;
|
|
16729
|
+
}
|
|
16730
|
+
return result;
|
|
16376
16731
|
}
|
|
16377
16732
|
|
|
16378
16733
|
loadLabelComponent();
|
|
@@ -16718,18 +17073,25 @@ class LabelBase extends AbstractComponent {
|
|
|
16718
17073
|
if (clampForce) {
|
|
16719
17074
|
for (let i = 0; i < result.length; i++) {
|
|
16720
17075
|
const text = labels[i];
|
|
16721
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17076
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
16722
17077
|
if (dx !== 0 || dy !== 0) {
|
|
16723
17078
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
17079
|
+
text._isClamped = true;
|
|
16724
17080
|
}
|
|
16725
17081
|
}
|
|
16726
17082
|
}
|
|
16727
|
-
result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy))
|
|
17083
|
+
result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
|
|
17084
|
+
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
17085
|
+
const graphicBound = this._isCollectionBase
|
|
17086
|
+
? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
|
|
17087
|
+
: this.getGraphicBounds(baseMark, text);
|
|
17088
|
+
return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
|
|
17089
|
+
} }));
|
|
16728
17090
|
for (let i = 0; i < result.length; i++) {
|
|
16729
17091
|
const text = result[i];
|
|
16730
17092
|
const bounds = text.AABBBounds;
|
|
16731
17093
|
const range = boundToRange(bmpTool, bounds, true);
|
|
16732
|
-
if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
|
|
17094
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
|
|
16733
17095
|
bitmap.setRange(range);
|
|
16734
17096
|
}
|
|
16735
17097
|
else {
|
|
@@ -16802,7 +17164,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16802
17164
|
}
|
|
16803
17165
|
}
|
|
16804
17166
|
if (!hasPlace && clampForce) {
|
|
16805
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17167
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
16806
17168
|
if (dx === 0 && dy === 0) {
|
|
16807
17169
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
16808
17170
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -17286,6 +17648,9 @@ class ArcLabel extends LabelBase {
|
|
|
17286
17648
|
this._alignOffset = 0;
|
|
17287
17649
|
}
|
|
17288
17650
|
_overlapping(labels) {
|
|
17651
|
+
if (['inside', 'inside-center'].includes(this.attribute.position)) {
|
|
17652
|
+
return super._overlapping(labels);
|
|
17653
|
+
}
|
|
17289
17654
|
return labels;
|
|
17290
17655
|
}
|
|
17291
17656
|
labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
|
|
@@ -29552,690 +29917,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29552
29917
|
}
|
|
29553
29918
|
};
|
|
29554
29919
|
|
|
29555
|
-
|
|
29556
|
-
|
|
29557
|
-
var gif = {};
|
|
29558
|
-
|
|
29559
|
-
var lib = {};
|
|
29560
|
-
|
|
29561
|
-
Object.defineProperty(lib, "__esModule", {
|
|
29562
|
-
value: true
|
|
29563
|
-
});
|
|
29564
|
-
lib.loop = lib.conditional = lib.parse = void 0;
|
|
29565
|
-
var parse = function parse(stream, schema) {
|
|
29566
|
-
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
29567
|
-
var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : result;
|
|
29568
|
-
if (Array.isArray(schema)) {
|
|
29569
|
-
schema.forEach(function (partSchema) {
|
|
29570
|
-
return parse(stream, partSchema, result, parent);
|
|
29571
|
-
});
|
|
29572
|
-
} else if (typeof schema === 'function') {
|
|
29573
|
-
schema(stream, result, parent, parse);
|
|
29574
|
-
} else {
|
|
29575
|
-
var key = Object.keys(schema)[0];
|
|
29576
|
-
if (Array.isArray(schema[key])) {
|
|
29577
|
-
parent[key] = {};
|
|
29578
|
-
parse(stream, schema[key], result, parent[key]);
|
|
29579
|
-
} else {
|
|
29580
|
-
parent[key] = schema[key](stream, result, parent, parse);
|
|
29581
|
-
}
|
|
29582
|
-
}
|
|
29583
|
-
return result;
|
|
29584
|
-
};
|
|
29585
|
-
lib.parse = parse;
|
|
29586
|
-
var conditional = function conditional(schema, conditionFunc) {
|
|
29587
|
-
return function (stream, result, parent, parse) {
|
|
29588
|
-
if (conditionFunc(stream, result, parent)) {
|
|
29589
|
-
parse(stream, schema, result, parent);
|
|
29590
|
-
}
|
|
29591
|
-
};
|
|
29592
|
-
};
|
|
29593
|
-
lib.conditional = conditional;
|
|
29594
|
-
var loop = function loop(schema, continueFunc) {
|
|
29595
|
-
return function (stream, result, parent, parse) {
|
|
29596
|
-
var arr = [];
|
|
29597
|
-
var lastStreamPos = stream.pos;
|
|
29598
|
-
while (continueFunc(stream, result, parent)) {
|
|
29599
|
-
var newParent = {};
|
|
29600
|
-
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
|
|
29601
|
-
// it falls into infinite recursion, null check to avoid the same
|
|
29602
|
-
|
|
29603
|
-
if (stream.pos === lastStreamPos) {
|
|
29604
|
-
break;
|
|
29605
|
-
}
|
|
29606
|
-
lastStreamPos = stream.pos;
|
|
29607
|
-
arr.push(newParent);
|
|
29608
|
-
}
|
|
29609
|
-
return arr;
|
|
29610
|
-
};
|
|
29611
|
-
};
|
|
29612
|
-
lib.loop = loop;
|
|
29613
|
-
|
|
29614
|
-
var uint8 = {};
|
|
29615
|
-
|
|
29616
|
-
Object.defineProperty(uint8, "__esModule", {
|
|
29617
|
-
value: true
|
|
29618
|
-
});
|
|
29619
|
-
uint8.readBits = uint8.readArray = uint8.readUnsigned = uint8.readString = uint8.peekBytes = uint8.readBytes = uint8.peekByte = uint8.readByte = uint8.buildStream = void 0;
|
|
29620
|
-
|
|
29621
|
-
// Default stream and parsers for Uint8TypedArray data type
|
|
29622
|
-
var buildStream = function buildStream(uint8Data) {
|
|
29623
|
-
return {
|
|
29624
|
-
data: uint8Data,
|
|
29625
|
-
pos: 0
|
|
29626
|
-
};
|
|
29627
|
-
};
|
|
29628
|
-
uint8.buildStream = buildStream;
|
|
29629
|
-
var readByte = function readByte() {
|
|
29630
|
-
return function (stream) {
|
|
29631
|
-
return stream.data[stream.pos++];
|
|
29632
|
-
};
|
|
29633
|
-
};
|
|
29634
|
-
uint8.readByte = readByte;
|
|
29635
|
-
var peekByte = function peekByte() {
|
|
29636
|
-
var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
29637
|
-
return function (stream) {
|
|
29638
|
-
return stream.data[stream.pos + offset];
|
|
29639
|
-
};
|
|
29640
|
-
};
|
|
29641
|
-
uint8.peekByte = peekByte;
|
|
29642
|
-
var readBytes = function readBytes(length) {
|
|
29643
|
-
return function (stream) {
|
|
29644
|
-
return stream.data.subarray(stream.pos, stream.pos += length);
|
|
29645
|
-
};
|
|
29646
|
-
};
|
|
29647
|
-
uint8.readBytes = readBytes;
|
|
29648
|
-
var peekBytes = function peekBytes(length) {
|
|
29649
|
-
return function (stream) {
|
|
29650
|
-
return stream.data.subarray(stream.pos, stream.pos + length);
|
|
29651
|
-
};
|
|
29652
|
-
};
|
|
29653
|
-
uint8.peekBytes = peekBytes;
|
|
29654
|
-
var readString = function readString(length) {
|
|
29655
|
-
return function (stream) {
|
|
29656
|
-
return Array.from(readBytes(length)(stream)).map(function (value) {
|
|
29657
|
-
return String.fromCharCode(value);
|
|
29658
|
-
}).join('');
|
|
29659
|
-
};
|
|
29660
|
-
};
|
|
29661
|
-
uint8.readString = readString;
|
|
29662
|
-
var readUnsigned = function readUnsigned(littleEndian) {
|
|
29663
|
-
return function (stream) {
|
|
29664
|
-
var bytes = readBytes(2)(stream);
|
|
29665
|
-
return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1];
|
|
29666
|
-
};
|
|
29667
|
-
};
|
|
29668
|
-
uint8.readUnsigned = readUnsigned;
|
|
29669
|
-
var readArray = function readArray(byteSize, totalOrFunc) {
|
|
29670
|
-
return function (stream, result, parent) {
|
|
29671
|
-
var total = typeof totalOrFunc === 'function' ? totalOrFunc(stream, result, parent) : totalOrFunc;
|
|
29672
|
-
var parser = readBytes(byteSize);
|
|
29673
|
-
var arr = new Array(total);
|
|
29674
|
-
for (var i = 0; i < total; i++) {
|
|
29675
|
-
arr[i] = parser(stream);
|
|
29676
|
-
}
|
|
29677
|
-
return arr;
|
|
29678
|
-
};
|
|
29679
|
-
};
|
|
29680
|
-
uint8.readArray = readArray;
|
|
29681
|
-
var subBitsTotal = function subBitsTotal(bits, startIndex, length) {
|
|
29682
|
-
var result = 0;
|
|
29683
|
-
for (var i = 0; i < length; i++) {
|
|
29684
|
-
result += bits[startIndex + i] && Math.pow(2, length - i - 1);
|
|
29685
|
-
}
|
|
29686
|
-
return result;
|
|
29687
|
-
};
|
|
29688
|
-
var readBits = function readBits(schema) {
|
|
29689
|
-
return function (stream) {
|
|
29690
|
-
var _byte = readByte()(stream); // convert the byte to bit array
|
|
29691
|
-
|
|
29692
|
-
var bits = new Array(8);
|
|
29693
|
-
for (var i = 0; i < 8; i++) {
|
|
29694
|
-
bits[7 - i] = !!(_byte & 1 << i);
|
|
29695
|
-
} // convert the bit array to values based on the schema
|
|
29696
|
-
|
|
29697
|
-
return Object.keys(schema).reduce(function (res, key) {
|
|
29698
|
-
var def = schema[key];
|
|
29699
|
-
if (def.length) {
|
|
29700
|
-
res[key] = subBitsTotal(bits, def.index, def.length);
|
|
29701
|
-
} else {
|
|
29702
|
-
res[key] = bits[def.index];
|
|
29703
|
-
}
|
|
29704
|
-
return res;
|
|
29705
|
-
}, {});
|
|
29706
|
-
};
|
|
29707
|
-
};
|
|
29708
|
-
uint8.readBits = readBits;
|
|
29709
|
-
|
|
29710
|
-
(function (exports) {
|
|
29711
|
-
|
|
29712
|
-
Object.defineProperty(exports, "__esModule", {
|
|
29713
|
-
value: true
|
|
29714
|
-
});
|
|
29715
|
-
exports["default"] = void 0;
|
|
29716
|
-
var _ = lib;
|
|
29717
|
-
var _uint = uint8;
|
|
29718
|
-
|
|
29719
|
-
// a set of 0x00 terminated subblocks
|
|
29720
|
-
var subBlocksSchema = {
|
|
29721
|
-
blocks: function blocks(stream) {
|
|
29722
|
-
var terminator = 0x00;
|
|
29723
|
-
var chunks = [];
|
|
29724
|
-
var streamSize = stream.data.length;
|
|
29725
|
-
var total = 0;
|
|
29726
|
-
for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) {
|
|
29727
|
-
// size becomes undefined for some case when file is corrupted and terminator is not proper
|
|
29728
|
-
// null check to avoid recursion
|
|
29729
|
-
if (!size) break; // catch corrupted files with no terminator
|
|
29730
|
-
|
|
29731
|
-
if (stream.pos + size >= streamSize) {
|
|
29732
|
-
var availableSize = streamSize - stream.pos;
|
|
29733
|
-
chunks.push((0, _uint.readBytes)(availableSize)(stream));
|
|
29734
|
-
total += availableSize;
|
|
29735
|
-
break;
|
|
29736
|
-
}
|
|
29737
|
-
chunks.push((0, _uint.readBytes)(size)(stream));
|
|
29738
|
-
total += size;
|
|
29739
|
-
}
|
|
29740
|
-
var result = new Uint8Array(total);
|
|
29741
|
-
var offset = 0;
|
|
29742
|
-
for (var i = 0; i < chunks.length; i++) {
|
|
29743
|
-
result.set(chunks[i], offset);
|
|
29744
|
-
offset += chunks[i].length;
|
|
29745
|
-
}
|
|
29746
|
-
return result;
|
|
29747
|
-
}
|
|
29748
|
-
}; // global control extension
|
|
29749
|
-
|
|
29750
|
-
var gceSchema = (0, _.conditional)({
|
|
29751
|
-
gce: [{
|
|
29752
|
-
codes: (0, _uint.readBytes)(2)
|
|
29753
|
-
}, {
|
|
29754
|
-
byteSize: (0, _uint.readByte)()
|
|
29755
|
-
}, {
|
|
29756
|
-
extras: (0, _uint.readBits)({
|
|
29757
|
-
future: {
|
|
29758
|
-
index: 0,
|
|
29759
|
-
length: 3
|
|
29760
|
-
},
|
|
29761
|
-
disposal: {
|
|
29762
|
-
index: 3,
|
|
29763
|
-
length: 3
|
|
29764
|
-
},
|
|
29765
|
-
userInput: {
|
|
29766
|
-
index: 6
|
|
29767
|
-
},
|
|
29768
|
-
transparentColorGiven: {
|
|
29769
|
-
index: 7
|
|
29770
|
-
}
|
|
29771
|
-
})
|
|
29772
|
-
}, {
|
|
29773
|
-
delay: (0, _uint.readUnsigned)(true)
|
|
29774
|
-
}, {
|
|
29775
|
-
transparentColorIndex: (0, _uint.readByte)()
|
|
29776
|
-
}, {
|
|
29777
|
-
terminator: (0, _uint.readByte)()
|
|
29778
|
-
}]
|
|
29779
|
-
}, function (stream) {
|
|
29780
|
-
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29781
|
-
return codes[0] === 0x21 && codes[1] === 0xf9;
|
|
29782
|
-
}); // image pipeline block
|
|
29783
|
-
|
|
29784
|
-
var imageSchema = (0, _.conditional)({
|
|
29785
|
-
image: [{
|
|
29786
|
-
code: (0, _uint.readByte)()
|
|
29787
|
-
}, {
|
|
29788
|
-
descriptor: [{
|
|
29789
|
-
left: (0, _uint.readUnsigned)(true)
|
|
29790
|
-
}, {
|
|
29791
|
-
top: (0, _uint.readUnsigned)(true)
|
|
29792
|
-
}, {
|
|
29793
|
-
width: (0, _uint.readUnsigned)(true)
|
|
29794
|
-
}, {
|
|
29795
|
-
height: (0, _uint.readUnsigned)(true)
|
|
29796
|
-
}, {
|
|
29797
|
-
lct: (0, _uint.readBits)({
|
|
29798
|
-
exists: {
|
|
29799
|
-
index: 0
|
|
29800
|
-
},
|
|
29801
|
-
interlaced: {
|
|
29802
|
-
index: 1
|
|
29803
|
-
},
|
|
29804
|
-
sort: {
|
|
29805
|
-
index: 2
|
|
29806
|
-
},
|
|
29807
|
-
future: {
|
|
29808
|
-
index: 3,
|
|
29809
|
-
length: 2
|
|
29810
|
-
},
|
|
29811
|
-
size: {
|
|
29812
|
-
index: 5,
|
|
29813
|
-
length: 3
|
|
29814
|
-
}
|
|
29815
|
-
})
|
|
29816
|
-
}]
|
|
29817
|
-
}, (0, _.conditional)({
|
|
29818
|
-
lct: (0, _uint.readArray)(3, function (stream, result, parent) {
|
|
29819
|
-
return Math.pow(2, parent.descriptor.lct.size + 1);
|
|
29820
|
-
})
|
|
29821
|
-
}, function (stream, result, parent) {
|
|
29822
|
-
return parent.descriptor.lct.exists;
|
|
29823
|
-
}), {
|
|
29824
|
-
data: [{
|
|
29825
|
-
minCodeSize: (0, _uint.readByte)()
|
|
29826
|
-
}, subBlocksSchema]
|
|
29827
|
-
}]
|
|
29828
|
-
}, function (stream) {
|
|
29829
|
-
return (0, _uint.peekByte)()(stream) === 0x2c;
|
|
29830
|
-
}); // plain text block
|
|
29831
|
-
|
|
29832
|
-
var textSchema = (0, _.conditional)({
|
|
29833
|
-
text: [{
|
|
29834
|
-
codes: (0, _uint.readBytes)(2)
|
|
29835
|
-
}, {
|
|
29836
|
-
blockSize: (0, _uint.readByte)()
|
|
29837
|
-
}, {
|
|
29838
|
-
preData: function preData(stream, result, parent) {
|
|
29839
|
-
return (0, _uint.readBytes)(parent.text.blockSize)(stream);
|
|
29840
|
-
}
|
|
29841
|
-
}, subBlocksSchema]
|
|
29842
|
-
}, function (stream) {
|
|
29843
|
-
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29844
|
-
return codes[0] === 0x21 && codes[1] === 0x01;
|
|
29845
|
-
}); // application block
|
|
29846
|
-
|
|
29847
|
-
var applicationSchema = (0, _.conditional)({
|
|
29848
|
-
application: [{
|
|
29849
|
-
codes: (0, _uint.readBytes)(2)
|
|
29850
|
-
}, {
|
|
29851
|
-
blockSize: (0, _uint.readByte)()
|
|
29852
|
-
}, {
|
|
29853
|
-
id: function id(stream, result, parent) {
|
|
29854
|
-
return (0, _uint.readString)(parent.blockSize)(stream);
|
|
29855
|
-
}
|
|
29856
|
-
}, subBlocksSchema]
|
|
29857
|
-
}, function (stream) {
|
|
29858
|
-
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29859
|
-
return codes[0] === 0x21 && codes[1] === 0xff;
|
|
29860
|
-
}); // comment block
|
|
29861
|
-
|
|
29862
|
-
var commentSchema = (0, _.conditional)({
|
|
29863
|
-
comment: [{
|
|
29864
|
-
codes: (0, _uint.readBytes)(2)
|
|
29865
|
-
}, subBlocksSchema]
|
|
29866
|
-
}, function (stream) {
|
|
29867
|
-
var codes = (0, _uint.peekBytes)(2)(stream);
|
|
29868
|
-
return codes[0] === 0x21 && codes[1] === 0xfe;
|
|
29869
|
-
});
|
|
29870
|
-
var schema = [{
|
|
29871
|
-
header: [{
|
|
29872
|
-
signature: (0, _uint.readString)(3)
|
|
29873
|
-
}, {
|
|
29874
|
-
version: (0, _uint.readString)(3)
|
|
29875
|
-
}]
|
|
29876
|
-
}, {
|
|
29877
|
-
lsd: [{
|
|
29878
|
-
width: (0, _uint.readUnsigned)(true)
|
|
29879
|
-
}, {
|
|
29880
|
-
height: (0, _uint.readUnsigned)(true)
|
|
29881
|
-
}, {
|
|
29882
|
-
gct: (0, _uint.readBits)({
|
|
29883
|
-
exists: {
|
|
29884
|
-
index: 0
|
|
29885
|
-
},
|
|
29886
|
-
resolution: {
|
|
29887
|
-
index: 1,
|
|
29888
|
-
length: 3
|
|
29889
|
-
},
|
|
29890
|
-
sort: {
|
|
29891
|
-
index: 4
|
|
29892
|
-
},
|
|
29893
|
-
size: {
|
|
29894
|
-
index: 5,
|
|
29895
|
-
length: 3
|
|
29896
|
-
}
|
|
29897
|
-
})
|
|
29898
|
-
}, {
|
|
29899
|
-
backgroundColorIndex: (0, _uint.readByte)()
|
|
29900
|
-
}, {
|
|
29901
|
-
pixelAspectRatio: (0, _uint.readByte)()
|
|
29902
|
-
}]
|
|
29903
|
-
}, (0, _.conditional)({
|
|
29904
|
-
gct: (0, _uint.readArray)(3, function (stream, result) {
|
|
29905
|
-
return Math.pow(2, result.lsd.gct.size + 1);
|
|
29906
|
-
})
|
|
29907
|
-
}, function (stream, result) {
|
|
29908
|
-
return result.lsd.gct.exists;
|
|
29909
|
-
}),
|
|
29910
|
-
// content frames
|
|
29911
|
-
{
|
|
29912
|
-
frames: (0, _.loop)([gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], function (stream) {
|
|
29913
|
-
var nextCode = (0, _uint.peekByte)()(stream); // rather than check for a terminator, we should check for the existence
|
|
29914
|
-
// of an ext or image block to avoid infinite loops
|
|
29915
|
-
//var terminator = 0x3B;
|
|
29916
|
-
//return nextCode !== terminator;
|
|
29917
|
-
|
|
29918
|
-
return nextCode === 0x21 || nextCode === 0x2c;
|
|
29919
|
-
})
|
|
29920
|
-
}];
|
|
29921
|
-
var _default = schema;
|
|
29922
|
-
exports["default"] = _default;
|
|
29923
|
-
})(gif);
|
|
29924
|
-
|
|
29925
|
-
var deinterlace$1 = {};
|
|
29926
|
-
|
|
29927
|
-
Object.defineProperty(deinterlace$1, "__esModule", {
|
|
29928
|
-
value: true
|
|
29929
|
-
});
|
|
29930
|
-
deinterlace$1.deinterlace = void 0;
|
|
29931
|
-
|
|
29932
|
-
/**
|
|
29933
|
-
* Deinterlace function from https://github.com/shachaf/jsgif
|
|
29934
|
-
*/
|
|
29935
|
-
var deinterlace = function deinterlace(pixels, width) {
|
|
29936
|
-
var newPixels = new Array(pixels.length);
|
|
29937
|
-
var rows = pixels.length / width;
|
|
29938
|
-
var cpRow = function cpRow(toRow, fromRow) {
|
|
29939
|
-
var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
|
|
29940
|
-
newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
|
|
29941
|
-
}; // See appendix E.
|
|
29942
|
-
|
|
29943
|
-
var offsets = [0, 4, 2, 1];
|
|
29944
|
-
var steps = [8, 8, 4, 2];
|
|
29945
|
-
var fromRow = 0;
|
|
29946
|
-
for (var pass = 0; pass < 4; pass++) {
|
|
29947
|
-
for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
|
|
29948
|
-
cpRow(toRow, fromRow);
|
|
29949
|
-
fromRow++;
|
|
29950
|
-
}
|
|
29951
|
-
}
|
|
29952
|
-
return newPixels;
|
|
29953
|
-
};
|
|
29954
|
-
deinterlace$1.deinterlace = deinterlace;
|
|
29955
|
-
|
|
29956
|
-
var lzw$1 = {};
|
|
29957
|
-
|
|
29958
|
-
Object.defineProperty(lzw$1, "__esModule", {
|
|
29959
|
-
value: true
|
|
29960
|
-
});
|
|
29961
|
-
lzw$1.lzw = void 0;
|
|
29962
|
-
|
|
29963
|
-
/**
|
|
29964
|
-
* javascript port of java LZW decompression
|
|
29965
|
-
* Original java author url: https://gist.github.com/devunwired/4479231
|
|
29966
|
-
*/
|
|
29967
|
-
var lzw = function lzw(minCodeSize, data, pixelCount) {
|
|
29968
|
-
var MAX_STACK_SIZE = 4096;
|
|
29969
|
-
var nullCode = -1;
|
|
29970
|
-
var npix = pixelCount;
|
|
29971
|
-
var available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, i, datum, data_size, first, top, bi, pi;
|
|
29972
|
-
var dstPixels = new Array(pixelCount);
|
|
29973
|
-
var prefix = new Array(MAX_STACK_SIZE);
|
|
29974
|
-
var suffix = new Array(MAX_STACK_SIZE);
|
|
29975
|
-
var pixelStack = new Array(MAX_STACK_SIZE + 1); // Initialize GIF data stream decoder.
|
|
29976
|
-
|
|
29977
|
-
data_size = minCodeSize;
|
|
29978
|
-
clear = 1 << data_size;
|
|
29979
|
-
end_of_information = clear + 1;
|
|
29980
|
-
available = clear + 2;
|
|
29981
|
-
old_code = nullCode;
|
|
29982
|
-
code_size = data_size + 1;
|
|
29983
|
-
code_mask = (1 << code_size) - 1;
|
|
29984
|
-
for (code = 0; code < clear; code++) {
|
|
29985
|
-
prefix[code] = 0;
|
|
29986
|
-
suffix[code] = code;
|
|
29987
|
-
} // Decode GIF pixel stream.
|
|
29988
|
-
|
|
29989
|
-
var datum, bits, first, top, pi, bi;
|
|
29990
|
-
datum = bits = first = top = pi = bi = 0;
|
|
29991
|
-
for (i = 0; i < npix;) {
|
|
29992
|
-
if (top === 0) {
|
|
29993
|
-
if (bits < code_size) {
|
|
29994
|
-
// get the next byte
|
|
29995
|
-
datum += data[bi] << bits;
|
|
29996
|
-
bits += 8;
|
|
29997
|
-
bi++;
|
|
29998
|
-
continue;
|
|
29999
|
-
} // Get the next code.
|
|
30000
|
-
|
|
30001
|
-
code = datum & code_mask;
|
|
30002
|
-
datum >>= code_size;
|
|
30003
|
-
bits -= code_size; // Interpret the code
|
|
30004
|
-
|
|
30005
|
-
if (code > available || code == end_of_information) {
|
|
30006
|
-
break;
|
|
30007
|
-
}
|
|
30008
|
-
if (code == clear) {
|
|
30009
|
-
// Reset decoder.
|
|
30010
|
-
code_size = data_size + 1;
|
|
30011
|
-
code_mask = (1 << code_size) - 1;
|
|
30012
|
-
available = clear + 2;
|
|
30013
|
-
old_code = nullCode;
|
|
30014
|
-
continue;
|
|
30015
|
-
}
|
|
30016
|
-
if (old_code == nullCode) {
|
|
30017
|
-
pixelStack[top++] = suffix[code];
|
|
30018
|
-
old_code = code;
|
|
30019
|
-
first = code;
|
|
30020
|
-
continue;
|
|
30021
|
-
}
|
|
30022
|
-
in_code = code;
|
|
30023
|
-
if (code == available) {
|
|
30024
|
-
pixelStack[top++] = first;
|
|
30025
|
-
code = old_code;
|
|
30026
|
-
}
|
|
30027
|
-
while (code > clear) {
|
|
30028
|
-
pixelStack[top++] = suffix[code];
|
|
30029
|
-
code = prefix[code];
|
|
30030
|
-
}
|
|
30031
|
-
first = suffix[code] & 0xff;
|
|
30032
|
-
pixelStack[top++] = first; // add a new string to the table, but only if space is available
|
|
30033
|
-
// if not, just continue with current table until a clear code is found
|
|
30034
|
-
// (deferred clear code implementation as per GIF spec)
|
|
30035
|
-
|
|
30036
|
-
if (available < MAX_STACK_SIZE) {
|
|
30037
|
-
prefix[available] = old_code;
|
|
30038
|
-
suffix[available] = first;
|
|
30039
|
-
available++;
|
|
30040
|
-
if ((available & code_mask) === 0 && available < MAX_STACK_SIZE) {
|
|
30041
|
-
code_size++;
|
|
30042
|
-
code_mask += available;
|
|
30043
|
-
}
|
|
30044
|
-
}
|
|
30045
|
-
old_code = in_code;
|
|
30046
|
-
} // Pop a pixel off the pixel stack.
|
|
30047
|
-
|
|
30048
|
-
top--;
|
|
30049
|
-
dstPixels[pi++] = pixelStack[top];
|
|
30050
|
-
i++;
|
|
30051
|
-
}
|
|
30052
|
-
for (i = pi; i < npix; i++) {
|
|
30053
|
-
dstPixels[i] = 0; // clear missing pixels
|
|
30054
|
-
}
|
|
30055
|
-
|
|
30056
|
-
return dstPixels;
|
|
30057
|
-
};
|
|
30058
|
-
lzw$1.lzw = lzw;
|
|
30059
|
-
|
|
30060
|
-
Object.defineProperty(lib$1, "__esModule", {
|
|
30061
|
-
value: true
|
|
30062
|
-
});
|
|
30063
|
-
var decompressFrames_1 = lib$1.decompressFrames = lib$1.decompressFrame = parseGIF_1 = lib$1.parseGIF = void 0;
|
|
30064
|
-
var _gif = _interopRequireDefault(gif);
|
|
30065
|
-
var _jsBinarySchemaParser = lib;
|
|
30066
|
-
var _uint = uint8;
|
|
30067
|
-
var _deinterlace = deinterlace$1;
|
|
30068
|
-
var _lzw = lzw$1;
|
|
30069
|
-
function _interopRequireDefault(obj) {
|
|
30070
|
-
return obj && obj.__esModule ? obj : {
|
|
30071
|
-
"default": obj
|
|
30072
|
-
};
|
|
30073
|
-
}
|
|
30074
|
-
var parseGIF = function parseGIF(arrayBuffer) {
|
|
30075
|
-
var byteData = new Uint8Array(arrayBuffer);
|
|
30076
|
-
return (0, _jsBinarySchemaParser.parse)((0, _uint.buildStream)(byteData), _gif["default"]);
|
|
30077
|
-
};
|
|
30078
|
-
var parseGIF_1 = lib$1.parseGIF = parseGIF;
|
|
30079
|
-
var generatePatch = function generatePatch(image) {
|
|
30080
|
-
var totalPixels = image.pixels.length;
|
|
30081
|
-
var patchData = new Uint8ClampedArray(totalPixels * 4);
|
|
30082
|
-
for (var i = 0; i < totalPixels; i++) {
|
|
30083
|
-
var pos = i * 4;
|
|
30084
|
-
var colorIndex = image.pixels[i];
|
|
30085
|
-
var color = image.colorTable[colorIndex] || [0, 0, 0];
|
|
30086
|
-
patchData[pos] = color[0];
|
|
30087
|
-
patchData[pos + 1] = color[1];
|
|
30088
|
-
patchData[pos + 2] = color[2];
|
|
30089
|
-
patchData[pos + 3] = colorIndex !== image.transparentIndex ? 255 : 0;
|
|
30090
|
-
}
|
|
30091
|
-
return patchData;
|
|
30092
|
-
};
|
|
30093
|
-
var decompressFrame = function decompressFrame(frame, gct, buildImagePatch) {
|
|
30094
|
-
if (!frame.image) {
|
|
30095
|
-
console.warn('gif frame does not have associated image.');
|
|
30096
|
-
return;
|
|
30097
|
-
}
|
|
30098
|
-
var image = frame.image; // get the number of pixels
|
|
30099
|
-
|
|
30100
|
-
var totalPixels = image.descriptor.width * image.descriptor.height; // do lzw decompression
|
|
30101
|
-
|
|
30102
|
-
var pixels = (0, _lzw.lzw)(image.data.minCodeSize, image.data.blocks, totalPixels); // deal with interlacing if necessary
|
|
30103
|
-
|
|
30104
|
-
if (image.descriptor.lct.interlaced) {
|
|
30105
|
-
pixels = (0, _deinterlace.deinterlace)(pixels, image.descriptor.width);
|
|
30106
|
-
}
|
|
30107
|
-
var resultImage = {
|
|
30108
|
-
pixels: pixels,
|
|
30109
|
-
dims: {
|
|
30110
|
-
top: frame.image.descriptor.top,
|
|
30111
|
-
left: frame.image.descriptor.left,
|
|
30112
|
-
width: frame.image.descriptor.width,
|
|
30113
|
-
height: frame.image.descriptor.height
|
|
30114
|
-
}
|
|
30115
|
-
}; // color table
|
|
30116
|
-
|
|
30117
|
-
if (image.descriptor.lct && image.descriptor.lct.exists) {
|
|
30118
|
-
resultImage.colorTable = image.lct;
|
|
30119
|
-
} else {
|
|
30120
|
-
resultImage.colorTable = gct;
|
|
30121
|
-
} // add per frame relevant gce information
|
|
30122
|
-
|
|
30123
|
-
if (frame.gce) {
|
|
30124
|
-
resultImage.delay = (frame.gce.delay || 10) * 10; // convert to ms
|
|
30125
|
-
|
|
30126
|
-
resultImage.disposalType = frame.gce.extras.disposal; // transparency
|
|
30127
|
-
|
|
30128
|
-
if (frame.gce.extras.transparentColorGiven) {
|
|
30129
|
-
resultImage.transparentIndex = frame.gce.transparentColorIndex;
|
|
30130
|
-
}
|
|
30131
|
-
} // create canvas usable imagedata if desired
|
|
30132
|
-
|
|
30133
|
-
if (buildImagePatch) {
|
|
30134
|
-
resultImage.patch = generatePatch(resultImage);
|
|
30135
|
-
}
|
|
30136
|
-
return resultImage;
|
|
30137
|
-
};
|
|
30138
|
-
lib$1.decompressFrame = decompressFrame;
|
|
30139
|
-
var decompressFrames = function decompressFrames(parsedGif, buildImagePatches) {
|
|
30140
|
-
return parsedGif.frames.filter(function (f) {
|
|
30141
|
-
return f.image;
|
|
30142
|
-
}).map(function (f) {
|
|
30143
|
-
return decompressFrame(f, parsedGif.gct, buildImagePatches);
|
|
30144
|
-
});
|
|
30145
|
-
};
|
|
30146
|
-
decompressFrames_1 = lib$1.decompressFrames = decompressFrames;
|
|
30147
|
-
|
|
30148
|
-
class GifImage extends Image {
|
|
30149
|
-
constructor(params) {
|
|
30150
|
-
super(params);
|
|
30151
|
-
this.isGifImage = true;
|
|
30152
|
-
this.loadGif();
|
|
30153
|
-
}
|
|
30154
|
-
loadGif() {
|
|
30155
|
-
if (isString(this.attribute.gifImage)) {
|
|
30156
|
-
ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')
|
|
30157
|
-
.then((res) => {
|
|
30158
|
-
const gif = parseGIF_1(res);
|
|
30159
|
-
const frames = decompressFrames_1(gif, true);
|
|
30160
|
-
this.renderGIF(frames);
|
|
30161
|
-
})
|
|
30162
|
-
.catch(e => {
|
|
30163
|
-
console.error('Gif load error: ', e);
|
|
30164
|
-
});
|
|
30165
|
-
}
|
|
30166
|
-
else if (this.attribute.gifImage instanceof ArrayBuffer) {
|
|
30167
|
-
const gif = parseGIF_1(this.attribute.gifImage);
|
|
30168
|
-
const frames = decompressFrames_1(gif, true);
|
|
30169
|
-
this.renderGIF(frames);
|
|
30170
|
-
}
|
|
30171
|
-
}
|
|
30172
|
-
renderGIF(frames) {
|
|
30173
|
-
this.loadedFrames = frames;
|
|
30174
|
-
this.frameIndex = 0;
|
|
30175
|
-
if (!this.tempCanvas) {
|
|
30176
|
-
this.tempCanvas = application.global.createCanvas({});
|
|
30177
|
-
this.tempCtx = this.tempCanvas.getContext('2d');
|
|
30178
|
-
}
|
|
30179
|
-
if (!this.gifCanvas) {
|
|
30180
|
-
this.gifCanvas = application.global.createCanvas({});
|
|
30181
|
-
this.gifCtx = this.gifCanvas.getContext('2d');
|
|
30182
|
-
}
|
|
30183
|
-
this.gifCanvas.width = frames[0].dims.width;
|
|
30184
|
-
this.gifCanvas.height = frames[0].dims.height;
|
|
30185
|
-
this.playing = true;
|
|
30186
|
-
this.lastTime = new Date().getTime();
|
|
30187
|
-
const animation = this.animate();
|
|
30188
|
-
if (this.attribute.timeline) {
|
|
30189
|
-
animation.setTimeline(this.attribute.timeline);
|
|
30190
|
-
}
|
|
30191
|
-
animation.to({}, 1000, 'linear').loop(Infinity);
|
|
30192
|
-
}
|
|
30193
|
-
renderFrame(context, x, y) {
|
|
30194
|
-
const frame = this.loadedFrames[this.frameIndex || 0];
|
|
30195
|
-
if (frame.disposalType === 2) {
|
|
30196
|
-
this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);
|
|
30197
|
-
}
|
|
30198
|
-
this.drawPatch(frame);
|
|
30199
|
-
this.manipulate(context, x, y);
|
|
30200
|
-
const diff = new Date().getTime() - this.lastTime;
|
|
30201
|
-
if (frame.delay < diff) {
|
|
30202
|
-
this.frameIndex++;
|
|
30203
|
-
this.lastTime = new Date().getTime();
|
|
30204
|
-
}
|
|
30205
|
-
if (this.frameIndex >= this.loadedFrames.length) {
|
|
30206
|
-
this.frameIndex = 0;
|
|
30207
|
-
}
|
|
30208
|
-
}
|
|
30209
|
-
drawPatch(frame) {
|
|
30210
|
-
const dims = frame.dims;
|
|
30211
|
-
if (!this.frameImageData ||
|
|
30212
|
-
dims.width !== this.frameImageData.width ||
|
|
30213
|
-
dims.height !== this.frameImageData.height) {
|
|
30214
|
-
this.tempCanvas.width = dims.width;
|
|
30215
|
-
this.tempCanvas.height = dims.height;
|
|
30216
|
-
this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);
|
|
30217
|
-
}
|
|
30218
|
-
this.frameImageData.data.set(frame.patch);
|
|
30219
|
-
this.tempCtx.putImageData(this.frameImageData, 0, 0);
|
|
30220
|
-
this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);
|
|
30221
|
-
}
|
|
30222
|
-
manipulate(context, x, y) {
|
|
30223
|
-
context.drawImage(this.gifCanvas, 0, 0, this.gifCanvas.width, this.gifCanvas.height, x, y, this.attribute.width, this.attribute.height);
|
|
30224
|
-
}
|
|
30225
|
-
setAttribute(key, value, forceUpdateTag, context) {
|
|
30226
|
-
super.setAttribute(key, value, forceUpdateTag, context);
|
|
30227
|
-
if (key === 'gifImage') {
|
|
30228
|
-
this.loadGif();
|
|
30229
|
-
}
|
|
30230
|
-
}
|
|
30231
|
-
setAttributes(params, forceUpdateTag, context) {
|
|
30232
|
-
super.setAttributes(params, forceUpdateTag, context);
|
|
30233
|
-
if (params.gifImage) {
|
|
30234
|
-
this.loadGif();
|
|
30235
|
-
}
|
|
30236
|
-
}
|
|
30237
|
-
}
|
|
30238
|
-
|
|
30239
|
-
const version = "0.21.0-alpha.4";
|
|
29920
|
+
const version = "0.21.0-alpha.6";
|
|
30240
29921
|
|
|
30241
|
-
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,
|
|
29922
|
+
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, loadScrollbar, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, scrollbarModule, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
|