@visactor/vrender-components 0.21.0-alpha.4 → 0.21.0-alpha.5
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/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 +884 -1246
- package/es/axis/type.d.ts +2 -2
- package/es/axis/type.js.map +1 -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 +8 -8
- 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
|
@@ -2009,6 +2009,7 @@ const DefaultStrokeStyle = Object.assign({
|
|
|
2009
2009
|
const DefaultTextStyle = {
|
|
2010
2010
|
text: "",
|
|
2011
2011
|
maxLineWidth: 1 / 0,
|
|
2012
|
+
maxWidth: 1 / 0,
|
|
2012
2013
|
textAlign: "left",
|
|
2013
2014
|
textBaseline: "alphabetic",
|
|
2014
2015
|
fontSize: 16,
|
|
@@ -2086,7 +2087,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
|
|
|
2086
2087
|
globalZIndex: 1,
|
|
2087
2088
|
globalCompositeOperation: "",
|
|
2088
2089
|
overflow: "hidden",
|
|
2089
|
-
shadowPickMode: "graphic"
|
|
2090
|
+
shadowPickMode: "graphic",
|
|
2091
|
+
keepStrokeScale: !1
|
|
2090
2092
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
2091
2093
|
const DefaultArcAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
2092
2094
|
startAngle: 0,
|
|
@@ -2353,10 +2355,32 @@ let ATextMeasure = class {
|
|
|
2353
2355
|
configure(service, env) {
|
|
2354
2356
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
2355
2357
|
}
|
|
2356
|
-
|
|
2357
|
-
if (!this.context) return this.estimate(text, options).width;
|
|
2358
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
2358
2359
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2359
|
-
|
|
2360
|
+
const metrics = this.context.measureText(text);
|
|
2361
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2362
|
+
}
|
|
2363
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
2364
|
+
this.context.setTextStyle(options);
|
|
2365
|
+
const metrics = this.context.measureText(text);
|
|
2366
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
2367
|
+
}
|
|
2368
|
+
compatibleMetrics(metrics, options) {
|
|
2369
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
2370
|
+
const {
|
|
2371
|
+
ascent: ascent,
|
|
2372
|
+
descent: descent
|
|
2373
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
2374
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
2375
|
+
}
|
|
2376
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
2377
|
+
const {
|
|
2378
|
+
left: left,
|
|
2379
|
+
right: right
|
|
2380
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
2381
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
2382
|
+
}
|
|
2383
|
+
return metrics;
|
|
2360
2384
|
}
|
|
2361
2385
|
estimate(text, _ref) {
|
|
2362
2386
|
let {
|
|
@@ -2370,19 +2394,85 @@ let ATextMeasure = class {
|
|
|
2370
2394
|
height: fontSize
|
|
2371
2395
|
};
|
|
2372
2396
|
}
|
|
2373
|
-
|
|
2397
|
+
measureTextWidth(text, options, textMeasure) {
|
|
2398
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2399
|
+
}
|
|
2400
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
2401
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
2402
|
+
}
|
|
2403
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
2404
|
+
return this.context ? {
|
|
2405
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
2406
|
+
right: textMeasure.actualBoundingBoxRight
|
|
2407
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
2408
|
+
}
|
|
2409
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
2374
2410
|
var _a;
|
|
2375
|
-
|
|
2376
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
2377
|
-
const textMeasure = this.context.measureText(text);
|
|
2378
|
-
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
2411
|
+
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;
|
|
2379
2412
|
}
|
|
2380
|
-
|
|
2413
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
2414
|
+
return this.context ? {
|
|
2415
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
2416
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
2417
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2418
|
+
}
|
|
2419
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
2381
2420
|
var _a;
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
return
|
|
2421
|
+
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;
|
|
2422
|
+
}
|
|
2423
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
2424
|
+
return this.context ? {
|
|
2425
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
2426
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
2427
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
2428
|
+
}
|
|
2429
|
+
measureTextBoundADscentEstimate(options) {
|
|
2430
|
+
var _a;
|
|
2431
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
2432
|
+
{
|
|
2433
|
+
textBaseline: textBaseline
|
|
2434
|
+
} = options;
|
|
2435
|
+
return "bottom" === textBaseline ? {
|
|
2436
|
+
ascent: fontSize,
|
|
2437
|
+
descent: 0
|
|
2438
|
+
} : "middle" === textBaseline ? {
|
|
2439
|
+
ascent: fontSize / 2,
|
|
2440
|
+
descent: fontSize / 2
|
|
2441
|
+
} : "alphabetic" === textBaseline ? {
|
|
2442
|
+
ascent: .79 * fontSize,
|
|
2443
|
+
descent: .21 * fontSize
|
|
2444
|
+
} : {
|
|
2445
|
+
ascent: 0,
|
|
2446
|
+
descent: fontSize
|
|
2447
|
+
};
|
|
2448
|
+
}
|
|
2449
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
2450
|
+
var _a;
|
|
2451
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
2452
|
+
{
|
|
2453
|
+
textAlign: textAlign
|
|
2454
|
+
} = options;
|
|
2455
|
+
return "center" === textAlign ? {
|
|
2456
|
+
left: fontSize / 2,
|
|
2457
|
+
right: fontSize / 2
|
|
2458
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
2459
|
+
left: fontSize,
|
|
2460
|
+
right: 0
|
|
2461
|
+
} : {
|
|
2462
|
+
left: 0,
|
|
2463
|
+
right: fontSize
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
measureTextPixelADscentAndWidth(text, options) {
|
|
2467
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
2468
|
+
width: this.estimate(text, options).width
|
|
2469
|
+
});
|
|
2470
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
2471
|
+
return {
|
|
2472
|
+
ascent: out.actualBoundingBoxAscent,
|
|
2473
|
+
descent: out.actualBoundingBoxDescent,
|
|
2474
|
+
width: out.width
|
|
2475
|
+
};
|
|
2386
2476
|
}
|
|
2387
2477
|
measureText(text, options) {
|
|
2388
2478
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -4372,7 +4462,7 @@ class ResourceLoader {
|
|
|
4372
4462
|
}
|
|
4373
4463
|
static GetFile(url, type) {
|
|
4374
4464
|
let data = ResourceLoader.cache.get(url);
|
|
4375
|
-
return data ? "fail" === data.loadState ? Promise.reject() : "
|
|
4465
|
+
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
4466
|
type: type,
|
|
4377
4467
|
loadState: "init"
|
|
4378
4468
|
}, 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 +6126,6 @@ const SymbolRenderContribution = Symbol.for("SymbolRenderContribution");
|
|
|
6036
6126
|
const TextRenderContribution = Symbol.for("TextRenderContribution");
|
|
6037
6127
|
const InteractiveSubRenderContribution = Symbol.for("InteractiveSubRenderContribution");
|
|
6038
6128
|
|
|
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
6129
|
function textDrawOffsetX(textAlign, width) {
|
|
6043
6130
|
return "end" === textAlign || "right" === textAlign ? -width : "center" === textAlign ? -width / 2 : 0;
|
|
6044
6131
|
}
|
|
@@ -6517,7 +6604,7 @@ class BaseRender {
|
|
|
6517
6604
|
}
|
|
6518
6605
|
}
|
|
6519
6606
|
|
|
6520
|
-
const parse
|
|
6607
|
+
const parse = function () {
|
|
6521
6608
|
const tokens = {
|
|
6522
6609
|
linearGradient: /^(linear\-gradient)/i,
|
|
6523
6610
|
radialGradient: /^(radial\-gradient)/i,
|
|
@@ -6670,7 +6757,7 @@ class GradientParser {
|
|
|
6670
6757
|
}
|
|
6671
6758
|
static Parse(c) {
|
|
6672
6759
|
if (GradientParser.IsGradientStr(c)) try {
|
|
6673
|
-
const datum = parse
|
|
6760
|
+
const datum = parse(c)[0];
|
|
6674
6761
|
if (datum) {
|
|
6675
6762
|
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
6676
6763
|
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
@@ -7027,7 +7114,8 @@ class DefaultArcRenderContribution {
|
|
|
7027
7114
|
x: originX = arcAttribute.x,
|
|
7028
7115
|
y: originY = arcAttribute.y,
|
|
7029
7116
|
scaleX = arcAttribute.scaleX,
|
|
7030
|
-
scaleY = arcAttribute.scaleY
|
|
7117
|
+
scaleY = arcAttribute.scaleY,
|
|
7118
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
7031
7119
|
} = arc.attribute;
|
|
7032
7120
|
let {
|
|
7033
7121
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -7039,7 +7127,7 @@ class DefaultArcRenderContribution {
|
|
|
7039
7127
|
{
|
|
7040
7128
|
distance = arcAttribute[key].distance
|
|
7041
7129
|
} = borderStyle,
|
|
7042
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7130
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7043
7131
|
deltaAngle = distance / outerRadius,
|
|
7044
7132
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7045
7133
|
if (arc.setAttributes({
|
|
@@ -7084,14 +7172,15 @@ class DefaultCircleRenderContribution {
|
|
|
7084
7172
|
x: originX = circleAttribute.x,
|
|
7085
7173
|
y: originY = circleAttribute.y,
|
|
7086
7174
|
scaleX = circleAttribute.scaleX,
|
|
7087
|
-
scaleY = circleAttribute.scaleY
|
|
7175
|
+
scaleY = circleAttribute.scaleY,
|
|
7176
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
7088
7177
|
} = circle.attribute,
|
|
7089
7178
|
renderBorder = (borderStyle, key) => {
|
|
7090
7179
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7091
7180
|
{
|
|
7092
7181
|
distance = circleAttribute[key].distance
|
|
7093
7182
|
} = borderStyle,
|
|
7094
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7183
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7095
7184
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7096
7185
|
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
7186
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -7210,7 +7299,8 @@ class DefaultRectRenderContribution {
|
|
|
7210
7299
|
scaleX = rectAttribute.scaleX,
|
|
7211
7300
|
scaleY = rectAttribute.scaleY,
|
|
7212
7301
|
x1: x1,
|
|
7213
|
-
y1: y1
|
|
7302
|
+
y1: y1,
|
|
7303
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
7214
7304
|
} = rect.attribute;
|
|
7215
7305
|
let {
|
|
7216
7306
|
width: width,
|
|
@@ -7223,7 +7313,7 @@ class DefaultRectRenderContribution {
|
|
|
7223
7313
|
{
|
|
7224
7314
|
distance = rectAttribute[key].distance
|
|
7225
7315
|
} = borderStyle,
|
|
7226
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7316
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7227
7317
|
nextX = x + sign * d,
|
|
7228
7318
|
nextY = y + sign * d,
|
|
7229
7319
|
dw = 2 * d;
|
|
@@ -7353,9 +7443,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
7353
7443
|
constructor() {
|
|
7354
7444
|
super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
7355
7445
|
}
|
|
7356
|
-
drawShape(
|
|
7357
|
-
|
|
7358
|
-
image.renderFrame(context, x, y);
|
|
7446
|
+
drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
7447
|
+
return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
7359
7448
|
}
|
|
7360
7449
|
}
|
|
7361
7450
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -7381,14 +7470,15 @@ class DefaultSymbolRenderContribution {
|
|
|
7381
7470
|
x: originX = symbolAttribute.x,
|
|
7382
7471
|
y: originY = symbolAttribute.y,
|
|
7383
7472
|
scaleX = symbolAttribute.scaleX,
|
|
7384
|
-
scaleY = symbolAttribute.scaleY
|
|
7473
|
+
scaleY = symbolAttribute.scaleY,
|
|
7474
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
7385
7475
|
} = symbol.attribute,
|
|
7386
7476
|
renderBorder = (borderStyle, key) => {
|
|
7387
7477
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
7388
7478
|
{
|
|
7389
7479
|
distance = symbolAttribute[key].distance
|
|
7390
7480
|
} = borderStyle,
|
|
7391
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
7481
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
7392
7482
|
sign = "outerBorder" === key ? 1 : -1;
|
|
7393
7483
|
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
7484
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -8664,16 +8754,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8664
8754
|
verticalMode = textAttribute.verticalMode,
|
|
8665
8755
|
x: originX = textAttribute.x,
|
|
8666
8756
|
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,
|
|
8757
|
+
} = text.attribute,
|
|
8758
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
8677
8759
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
8678
8760
|
if (!data) return;
|
|
8679
8761
|
const {
|
|
@@ -8693,79 +8775,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8693
8775
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
8694
8776
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
8695
8777
|
}
|
|
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)
|
|
8778
|
+
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
8779
|
};
|
|
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
|
-
});
|
|
8780
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
8781
|
+
const {
|
|
8782
|
+
multilineLayout: multilineLayout
|
|
8783
|
+
} = text;
|
|
8784
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
8785
|
+
const {
|
|
8786
|
+
xOffset: xOffset,
|
|
8787
|
+
yOffset: yOffset
|
|
8788
|
+
} = multilineLayout.bbox;
|
|
8789
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8790
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
8791
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
8792
|
+
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, {
|
|
8793
|
+
width: line.width
|
|
8742
8794
|
});
|
|
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);
|
|
8795
|
+
})));
|
|
8749
8796
|
} else {
|
|
8797
|
+
let {
|
|
8798
|
+
textAlign = textAttribute.textAlign,
|
|
8799
|
+
textBaseline = textAttribute.textBaseline
|
|
8800
|
+
} = text.attribute;
|
|
8801
|
+
if (!verticalMode) {
|
|
8802
|
+
const t = textAlign;
|
|
8803
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
8804
|
+
}
|
|
8750
8805
|
text.tryUpdateAABBBounds();
|
|
8751
|
-
const cache = text.cache
|
|
8752
|
-
|
|
8753
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
8754
|
-
const {
|
|
8806
|
+
const cache = text.cache,
|
|
8807
|
+
{
|
|
8755
8808
|
verticalList: verticalList
|
|
8756
8809
|
} = cache;
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8810
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
8811
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
8812
|
+
let totalW = 0;
|
|
8813
|
+
verticalList.forEach(verticalData => {
|
|
8814
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
8815
|
+
totalW = max(_w, totalW);
|
|
8816
|
+
});
|
|
8817
|
+
let offsetY = 0,
|
|
8818
|
+
offsetX = 0;
|
|
8819
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
8820
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
8821
|
+
dw = totalW - currentW;
|
|
8822
|
+
let currentOffsetY = offsetY;
|
|
8823
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
8761
8824
|
const {
|
|
8762
8825
|
text: text,
|
|
8763
8826
|
width: width,
|
|
8764
8827
|
direction: direction
|
|
8765
8828
|
} = item;
|
|
8766
|
-
drawText(text, offsetX,
|
|
8829
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
8767
8830
|
});
|
|
8768
|
-
}
|
|
8831
|
+
});
|
|
8769
8832
|
}
|
|
8770
8833
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
8771
8834
|
}
|
|
@@ -8777,12 +8840,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8777
8840
|
computed3dMatrix = !keepDirIn3d;
|
|
8778
8841
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
8779
8842
|
}
|
|
8780
|
-
drawUnderLine(underline, lineThrough, text,
|
|
8843
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
8781
8844
|
if (lineThrough + underline <= 0) return;
|
|
8782
8845
|
const {
|
|
8783
8846
|
textAlign = textAttribute.textAlign,
|
|
8784
|
-
textBaseline = textAttribute.textBaseline,
|
|
8785
|
-
fontSize = textAttribute.fontSize,
|
|
8786
8847
|
fill = textAttribute.fill,
|
|
8787
8848
|
opacity = textAttribute.opacity,
|
|
8788
8849
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -8792,23 +8853,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
|
|
|
8792
8853
|
isMulti = !isNil(multiOption),
|
|
8793
8854
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
8794
8855
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
8795
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
8796
8856
|
attribute = {
|
|
8797
8857
|
lineWidth: 0,
|
|
8798
8858
|
stroke: fill,
|
|
8799
8859
|
opacity: opacity,
|
|
8800
8860
|
strokeOpacity: fillOpacity
|
|
8801
8861
|
};
|
|
8802
|
-
let deltaY = isMulti ? -3 : 0;
|
|
8803
8862
|
if (underline) {
|
|
8804
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
8805
|
-
const dy =
|
|
8806
|
-
context.moveTo(
|
|
8863
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
8864
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
8865
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8807
8866
|
}
|
|
8808
|
-
if (
|
|
8809
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
8810
|
-
const dy =
|
|
8811
|
-
context.moveTo(
|
|
8867
|
+
if (lineThrough) {
|
|
8868
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
8869
|
+
const dy = anchorY + offsetThroughLineY;
|
|
8870
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
8812
8871
|
}
|
|
8813
8872
|
}
|
|
8814
8873
|
};
|
|
@@ -9093,12 +9152,10 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
9093
9152
|
const {
|
|
9094
9153
|
image: url
|
|
9095
9154
|
} = image.attribute;
|
|
9096
|
-
if (!image.
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
if ("success" !== res.state) return;
|
|
9101
|
-
}
|
|
9155
|
+
if (!url || !image.resources) return;
|
|
9156
|
+
const res = image.resources.get(url);
|
|
9157
|
+
if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
|
|
9158
|
+
if ("success" !== res.state) return;
|
|
9102
9159
|
const {
|
|
9103
9160
|
context: context
|
|
9104
9161
|
} = renderService.drawParams;
|
|
@@ -9482,28 +9539,6 @@ class CanvasTextLayout {
|
|
|
9482
9539
|
}
|
|
9483
9540
|
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
9484
9541
|
}
|
|
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
9542
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
9508
9543
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
9509
9544
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
@@ -9514,18 +9549,29 @@ class CanvasTextLayout {
|
|
|
9514
9549
|
bboxWH = [0, 0];
|
|
9515
9550
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
9516
9551
|
let width;
|
|
9517
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
9518
|
-
|
|
9519
|
-
width
|
|
9520
|
-
|
|
9552
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9553
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
9554
|
+
width = Math.min(metrics.width, lineWidth), linesLayout.push({
|
|
9555
|
+
str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
9556
|
+
width: width,
|
|
9557
|
+
ascent: metrics.ascent,
|
|
9558
|
+
descent: metrics.descent
|
|
9559
|
+
});
|
|
9560
|
+
}
|
|
9521
9561
|
bboxWH[0] = lineWidth;
|
|
9522
9562
|
} else {
|
|
9523
9563
|
let width, text;
|
|
9524
9564
|
lineWidth = 0;
|
|
9525
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9565
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9566
|
+
text = lines[i];
|
|
9567
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
9568
|
+
width = metrics.width, lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
9569
|
+
str: text,
|
|
9570
|
+
width: width,
|
|
9571
|
+
ascent: metrics.ascent,
|
|
9572
|
+
descent: metrics.descent
|
|
9573
|
+
});
|
|
9574
|
+
}
|
|
9529
9575
|
bboxWH[0] = lineWidth;
|
|
9530
9576
|
}
|
|
9531
9577
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
@@ -9554,11 +9600,11 @@ class CanvasTextLayout {
|
|
|
9554
9600
|
};
|
|
9555
9601
|
}
|
|
9556
9602
|
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 =
|
|
9603
|
+
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
9604
|
}
|
|
9559
9605
|
}
|
|
9560
9606
|
|
|
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];
|
|
9607
|
+
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
9608
|
class Text extends Graphic {
|
|
9563
9609
|
get font() {
|
|
9564
9610
|
const textTheme = this.getGraphicTheme();
|
|
@@ -9567,26 +9613,22 @@ class Text extends Graphic {
|
|
|
9567
9613
|
get clipedText() {
|
|
9568
9614
|
var _a;
|
|
9569
9615
|
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();
|
|
9616
|
+
textTheme = this.getGraphicTheme(),
|
|
9617
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9618
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
9576
9619
|
}
|
|
9577
9620
|
get clipedWidth() {
|
|
9578
|
-
|
|
9621
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
9579
9622
|
}
|
|
9580
9623
|
get cliped() {
|
|
9581
9624
|
var _a, _b;
|
|
9582
9625
|
const textTheme = this.getGraphicTheme(),
|
|
9583
9626
|
attribute = this.attribute,
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
9627
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
9628
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
9629
|
+
const {
|
|
9630
|
+
text: text
|
|
9631
|
+
} = this.attribute;
|
|
9590
9632
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
9591
9633
|
let mergedText = "";
|
|
9592
9634
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -9597,10 +9639,7 @@ class Text extends Graphic {
|
|
|
9597
9639
|
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
9640
|
}
|
|
9599
9641
|
get multilineLayout() {
|
|
9600
|
-
|
|
9601
|
-
}
|
|
9602
|
-
isSimplify() {
|
|
9603
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
9642
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
9604
9643
|
}
|
|
9605
9644
|
get isMultiLine() {
|
|
9606
9645
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -9673,8 +9712,62 @@ class Text extends Graphic {
|
|
|
9673
9712
|
}
|
|
9674
9713
|
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
9714
|
}
|
|
9715
|
+
updateSingallineAABBBounds(text) {
|
|
9716
|
+
this.updateMultilineAABBBounds([text]);
|
|
9717
|
+
const layoutData = this.cache.layoutData;
|
|
9718
|
+
if (layoutData) {
|
|
9719
|
+
const line = layoutData.lines[0];
|
|
9720
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
9721
|
+
}
|
|
9722
|
+
return this._AABBBounds;
|
|
9723
|
+
}
|
|
9724
|
+
updateMultilineAABBBounds(text) {
|
|
9725
|
+
const textTheme = this.getGraphicTheme(),
|
|
9726
|
+
{
|
|
9727
|
+
direction = textTheme.direction,
|
|
9728
|
+
underlineOffset = textTheme.underlineOffset
|
|
9729
|
+
} = this.attribute,
|
|
9730
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
9731
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
9732
|
+
}
|
|
9733
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
9734
|
+
var _a;
|
|
9735
|
+
const textTheme = this.getGraphicTheme(),
|
|
9736
|
+
attribute = this.attribute,
|
|
9737
|
+
{
|
|
9738
|
+
fontFamily = textTheme.fontFamily,
|
|
9739
|
+
textAlign = textTheme.textAlign,
|
|
9740
|
+
textBaseline = textTheme.textBaseline,
|
|
9741
|
+
fontSize = textTheme.fontSize,
|
|
9742
|
+
fontWeight = textTheme.fontWeight,
|
|
9743
|
+
ellipsis = textTheme.ellipsis,
|
|
9744
|
+
maxLineWidth: maxLineWidth,
|
|
9745
|
+
stroke = textTheme.stroke,
|
|
9746
|
+
wrap = textTheme.wrap,
|
|
9747
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
9748
|
+
lineWidth = textTheme.lineWidth,
|
|
9749
|
+
whiteSpace = textTheme.whiteSpace,
|
|
9750
|
+
suffixPosition = textTheme.suffixPosition
|
|
9751
|
+
} = attribute,
|
|
9752
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
9753
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
9754
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9755
|
+
const bbox = this.cache.layoutData.bbox;
|
|
9756
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
9757
|
+
}
|
|
9758
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
9759
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
9760
|
+
fontSize: fontSize,
|
|
9761
|
+
fontWeight: fontWeight,
|
|
9762
|
+
fontFamily: fontFamily
|
|
9763
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
9764
|
+
{
|
|
9765
|
+
bbox: bbox
|
|
9766
|
+
} = layoutData;
|
|
9767
|
+
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;
|
|
9768
|
+
}
|
|
9676
9769
|
updateWrapAABBBounds(text) {
|
|
9677
|
-
var _a, _b, _c
|
|
9770
|
+
var _a, _b, _c;
|
|
9678
9771
|
const textTheme = this.getGraphicTheme(),
|
|
9679
9772
|
{
|
|
9680
9773
|
fontFamily = textTheme.fontFamily,
|
|
@@ -9692,18 +9785,18 @@ class Text extends Graphic {
|
|
|
9692
9785
|
heightLimit = 0,
|
|
9693
9786
|
lineClamp: lineClamp
|
|
9694
9787
|
} = this.attribute,
|
|
9695
|
-
lineHeight =
|
|
9696
|
-
|
|
9697
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
9788
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme);
|
|
9789
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
9698
9790
|
const bbox = this.cache.layoutData.bbox;
|
|
9699
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;
|
|
9700
9792
|
}
|
|
9701
9793
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
9702
|
-
|
|
9794
|
+
textOptions = {
|
|
9703
9795
|
fontSize: fontSize,
|
|
9704
9796
|
fontWeight: fontWeight,
|
|
9705
9797
|
fontFamily: fontFamily
|
|
9706
|
-
},
|
|
9798
|
+
},
|
|
9799
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
9707
9800
|
lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
9708
9801
|
linesLayout = [],
|
|
9709
9802
|
bboxWH = [0, 0];
|
|
@@ -9713,29 +9806,35 @@ class Text extends Graphic {
|
|
|
9713
9806
|
const str = lines[i];
|
|
9714
9807
|
let needCut = !0;
|
|
9715
9808
|
if (i === lineCountLimit - 1) {
|
|
9716
|
-
const clip =
|
|
9809
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
9810
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
9717
9811
|
linesLayout.push({
|
|
9718
9812
|
str: clip.str,
|
|
9719
|
-
width: clip.width
|
|
9813
|
+
width: clip.width,
|
|
9814
|
+
ascent: matrics.ascent,
|
|
9815
|
+
descent: matrics.descent
|
|
9720
9816
|
});
|
|
9721
9817
|
break;
|
|
9722
9818
|
}
|
|
9723
|
-
const clip =
|
|
9819
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
9724
9820
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
9725
9821
|
if (ellipsis) {
|
|
9726
|
-
const clipEllipsis =
|
|
9727
|
-
clip.str = null !== (
|
|
9822
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
9823
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
9728
9824
|
} else clip.str = "", clip.width = 0;
|
|
9729
9825
|
needCut = !1;
|
|
9730
9826
|
}
|
|
9827
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
9731
9828
|
linesLayout.push({
|
|
9732
9829
|
str: clip.str,
|
|
9733
|
-
width: clip.width
|
|
9830
|
+
width: clip.width,
|
|
9831
|
+
ascent: matrics.ascent,
|
|
9832
|
+
descent: matrics.descent
|
|
9734
9833
|
});
|
|
9735
9834
|
let cutLength = clip.str.length;
|
|
9736
9835
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
9737
|
-
|
|
9738
|
-
|
|
9836
|
+
const newStr = str.substring(cutLength);
|
|
9837
|
+
lines.splice(i + 1, 0, newStr);
|
|
9739
9838
|
}
|
|
9740
9839
|
}
|
|
9741
9840
|
let maxWidth = 0;
|
|
@@ -9748,21 +9847,28 @@ class Text extends Graphic {
|
|
|
9748
9847
|
lineWidth = 0;
|
|
9749
9848
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
9750
9849
|
if (i === lineCountLimit - 1) {
|
|
9751
|
-
const clip =
|
|
9850
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
9851
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
9752
9852
|
linesLayout.push({
|
|
9753
9853
|
str: clip.str,
|
|
9754
|
-
width: clip.width
|
|
9854
|
+
width: clip.width,
|
|
9855
|
+
ascent: matrics.ascent,
|
|
9856
|
+
descent: matrics.descent
|
|
9755
9857
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
9756
9858
|
break;
|
|
9757
9859
|
}
|
|
9758
|
-
text = lines[i], width =
|
|
9860
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
9861
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
9862
|
+
linesLayout.push({
|
|
9759
9863
|
str: text,
|
|
9760
|
-
width: width
|
|
9864
|
+
width: width,
|
|
9865
|
+
ascent: matrics.ascent,
|
|
9866
|
+
descent: matrics.descent
|
|
9761
9867
|
});
|
|
9762
9868
|
}
|
|
9763
9869
|
bboxWH[0] = lineWidth;
|
|
9764
9870
|
}
|
|
9765
|
-
bboxWH[1] = linesLayout.length *
|
|
9871
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
9766
9872
|
const bbox = {
|
|
9767
9873
|
xOffset: 0,
|
|
9768
9874
|
yOffset: 0,
|
|
@@ -9773,210 +9879,12 @@ class Text extends Graphic {
|
|
|
9773
9879
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
9774
9880
|
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
9881
|
}
|
|
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
9882
|
updateVerticalMultilineAABBBounds(text) {
|
|
9971
|
-
var _a, _b
|
|
9883
|
+
var _a, _b;
|
|
9972
9884
|
const textTheme = this.getGraphicTheme(),
|
|
9973
9885
|
textMeasure = application.graphicUtil.textMeasure;
|
|
9974
9886
|
let width;
|
|
9975
9887
|
const attribute = this.attribute,
|
|
9976
|
-
{
|
|
9977
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
9978
|
-
} = attribute,
|
|
9979
|
-
buf = ignoreBuf ? 0 : 2,
|
|
9980
9888
|
{
|
|
9981
9889
|
maxLineWidth = textTheme.maxLineWidth,
|
|
9982
9890
|
ellipsis = textTheme.ellipsis,
|
|
@@ -9988,14 +9896,14 @@ class Text extends Graphic {
|
|
|
9988
9896
|
verticalMode = textTheme.verticalMode,
|
|
9989
9897
|
suffixPosition = textTheme.suffixPosition
|
|
9990
9898
|
} = attribute,
|
|
9991
|
-
lineHeight =
|
|
9899
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
9992
9900
|
let {
|
|
9993
9901
|
textAlign = textTheme.textAlign,
|
|
9994
9902
|
textBaseline = textTheme.textBaseline
|
|
9995
9903
|
} = attribute;
|
|
9996
9904
|
if (!verticalMode) {
|
|
9997
9905
|
const t = textAlign;
|
|
9998
|
-
textAlign = null !== (
|
|
9906
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
9999
9907
|
}
|
|
10000
9908
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
10001
9909
|
this.cache.verticalList.forEach(item => {
|
|
@@ -10043,6 +9951,15 @@ class Text extends Graphic {
|
|
|
10043
9951
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
10044
9952
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
10045
9953
|
}
|
|
9954
|
+
getMaxWidth(theme) {
|
|
9955
|
+
var _a, _b;
|
|
9956
|
+
const attribute = this.attribute;
|
|
9957
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
9958
|
+
}
|
|
9959
|
+
getLineHeight(attribute, textTheme) {
|
|
9960
|
+
var _a;
|
|
9961
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
9962
|
+
}
|
|
10046
9963
|
needUpdateTags(keys) {
|
|
10047
9964
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
10048
9965
|
return super.needUpdateTags(keys, k);
|
|
@@ -10057,6 +9974,12 @@ class Text extends Graphic {
|
|
|
10057
9974
|
getNoWorkAnimateAttr() {
|
|
10058
9975
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
10059
9976
|
}
|
|
9977
|
+
getBaselineMapAlign() {
|
|
9978
|
+
return Text.baselineMapAlign;
|
|
9979
|
+
}
|
|
9980
|
+
getAlignMapBaseline() {
|
|
9981
|
+
return Text.alignMapBaseline;
|
|
9982
|
+
}
|
|
10060
9983
|
}
|
|
10061
9984
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
10062
9985
|
ellipsis: 1,
|
|
@@ -10135,7 +10058,9 @@ class WrapText extends Text {
|
|
|
10135
10058
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10136
10059
|
linesLayout.push({
|
|
10137
10060
|
str: clip.str,
|
|
10138
|
-
width: clip.width
|
|
10061
|
+
width: clip.width,
|
|
10062
|
+
ascent: 0,
|
|
10063
|
+
descent: 0
|
|
10139
10064
|
});
|
|
10140
10065
|
break;
|
|
10141
10066
|
}
|
|
@@ -10149,7 +10074,9 @@ class WrapText extends Text {
|
|
|
10149
10074
|
}
|
|
10150
10075
|
if (linesLayout.push({
|
|
10151
10076
|
str: clip.str,
|
|
10152
|
-
width: clip.width
|
|
10077
|
+
width: clip.width,
|
|
10078
|
+
ascent: 0,
|
|
10079
|
+
descent: 0
|
|
10153
10080
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
10154
10081
|
const newStr = str.substring(clip.str.length);
|
|
10155
10082
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -10168,13 +10095,17 @@ class WrapText extends Text {
|
|
|
10168
10095
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
10169
10096
|
linesLayout.push({
|
|
10170
10097
|
str: clip.str,
|
|
10171
|
-
width: clip.width
|
|
10098
|
+
width: clip.width,
|
|
10099
|
+
ascent: 0,
|
|
10100
|
+
descent: 0
|
|
10172
10101
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
10173
10102
|
break;
|
|
10174
10103
|
}
|
|
10175
10104
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
10176
10105
|
str: text,
|
|
10177
|
-
width: width
|
|
10106
|
+
width: width,
|
|
10107
|
+
ascent: 0,
|
|
10108
|
+
descent: 0
|
|
10178
10109
|
});
|
|
10179
10110
|
}
|
|
10180
10111
|
bboxWH[0] = lineWidth;
|
|
@@ -10218,6 +10149,9 @@ class BaseSymbol {
|
|
|
10218
10149
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
10219
10150
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
10220
10151
|
}
|
|
10152
|
+
parseSize(size) {
|
|
10153
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10154
|
+
}
|
|
10221
10155
|
}
|
|
10222
10156
|
|
|
10223
10157
|
function circle(ctx, r, x, y, z) {
|
|
@@ -10228,13 +10162,13 @@ class CircleSymbol extends BaseSymbol {
|
|
|
10228
10162
|
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
10163
|
}
|
|
10230
10164
|
draw(ctx, size, x, y, z) {
|
|
10231
|
-
return circle(ctx, size / 2, x, y, z);
|
|
10165
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10232
10166
|
}
|
|
10233
10167
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10234
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
10168
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10235
10169
|
}
|
|
10236
10170
|
drawToSvgPath(size, x, y, z) {
|
|
10237
|
-
const r = size / 2;
|
|
10171
|
+
const r = this.parseSize(size) / 2;
|
|
10238
10172
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
10239
10173
|
}
|
|
10240
10174
|
}
|
|
@@ -10251,10 +10185,10 @@ class CrossSymbol extends BaseSymbol {
|
|
|
10251
10185
|
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
10186
|
}
|
|
10253
10187
|
draw(ctx, size, x, y, z) {
|
|
10254
|
-
return cross(ctx, size / 6, x, y, z);
|
|
10188
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
10255
10189
|
}
|
|
10256
10190
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10257
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
10191
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
10258
10192
|
}
|
|
10259
10193
|
}
|
|
10260
10194
|
var cross$1 = new CrossSymbol();
|
|
@@ -10267,13 +10201,13 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
10267
10201
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
10268
10202
|
}
|
|
10269
10203
|
draw(ctx, size, x, y, z) {
|
|
10270
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10204
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10271
10205
|
}
|
|
10272
10206
|
drawFitDir(ctx, size, x, y, z) {
|
|
10273
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
10207
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
10274
10208
|
}
|
|
10275
10209
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10276
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
10210
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
10277
10211
|
}
|
|
10278
10212
|
}
|
|
10279
10213
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -10287,10 +10221,10 @@ class SquareSymbol extends BaseSymbol {
|
|
|
10287
10221
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
10288
10222
|
}
|
|
10289
10223
|
draw(ctx, size, x, y) {
|
|
10290
|
-
return square(ctx, size / 2, x, y);
|
|
10224
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
10291
10225
|
}
|
|
10292
10226
|
drawOffset(ctx, size, x, y, offset) {
|
|
10293
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
10227
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10294
10228
|
}
|
|
10295
10229
|
}
|
|
10296
10230
|
var square$1 = new SquareSymbol();
|
|
@@ -10304,10 +10238,10 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
10304
10238
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
10305
10239
|
}
|
|
10306
10240
|
draw(ctx, size, x, y) {
|
|
10307
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
10241
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10308
10242
|
}
|
|
10309
10243
|
drawOffset(ctx, size, x, y, offset) {
|
|
10310
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
10244
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10311
10245
|
}
|
|
10312
10246
|
}
|
|
10313
10247
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -10339,10 +10273,10 @@ class StarSymbol extends BaseSymbol {
|
|
|
10339
10273
|
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
10274
|
}
|
|
10341
10275
|
draw(ctx, size, transX, transY) {
|
|
10342
|
-
return star(ctx, size / 2, transX, transY);
|
|
10276
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10343
10277
|
}
|
|
10344
10278
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10345
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
10279
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10346
10280
|
}
|
|
10347
10281
|
}
|
|
10348
10282
|
var star$1 = new StarSymbol();
|
|
@@ -10360,10 +10294,10 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
10360
10294
|
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
10295
|
}
|
|
10362
10296
|
draw(ctx, size, transX, transY) {
|
|
10363
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
10297
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10364
10298
|
}
|
|
10365
10299
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10366
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
10300
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10367
10301
|
}
|
|
10368
10302
|
}
|
|
10369
10303
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -10377,10 +10311,10 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
10377
10311
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
10378
10312
|
}
|
|
10379
10313
|
draw(ctx, size, transX, transY) {
|
|
10380
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
10314
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10381
10315
|
}
|
|
10382
10316
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10383
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
10317
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10384
10318
|
}
|
|
10385
10319
|
}
|
|
10386
10320
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -10393,10 +10327,10 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
10393
10327
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
10394
10328
|
}
|
|
10395
10329
|
draw(ctx, size, transX, transY) {
|
|
10396
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
10330
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10397
10331
|
}
|
|
10398
10332
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10399
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
10333
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10400
10334
|
}
|
|
10401
10335
|
}
|
|
10402
10336
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -10418,10 +10352,10 @@ class WyeSymbol extends BaseSymbol {
|
|
|
10418
10352
|
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
10353
|
}
|
|
10420
10354
|
draw(ctx, size, transX, transY) {
|
|
10421
|
-
return wye(ctx, size / 2, transX, transY);
|
|
10355
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
10422
10356
|
}
|
|
10423
10357
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10424
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
10358
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
10425
10359
|
}
|
|
10426
10360
|
}
|
|
10427
10361
|
var wye$1 = new WyeSymbol();
|
|
@@ -10434,10 +10368,10 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
10434
10368
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
10435
10369
|
}
|
|
10436
10370
|
draw(ctx, size, x, y) {
|
|
10437
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
10371
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
10438
10372
|
}
|
|
10439
10373
|
drawOffset(ctx, size, x, y, offset) {
|
|
10440
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
10374
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10441
10375
|
}
|
|
10442
10376
|
}
|
|
10443
10377
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -10451,10 +10385,10 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
10451
10385
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
10452
10386
|
}
|
|
10453
10387
|
draw(ctx, size, x, y) {
|
|
10454
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
10388
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10455
10389
|
}
|
|
10456
10390
|
drawOffset(ctx, size, x, y, offset) {
|
|
10457
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
10391
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10458
10392
|
}
|
|
10459
10393
|
}
|
|
10460
10394
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -10468,10 +10402,10 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
10468
10402
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
10469
10403
|
}
|
|
10470
10404
|
draw(ctx, size, x, y) {
|
|
10471
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
10405
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
10472
10406
|
}
|
|
10473
10407
|
drawOffset(ctx, size, x, y, offset) {
|
|
10474
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
10408
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
10475
10409
|
}
|
|
10476
10410
|
}
|
|
10477
10411
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -10486,10 +10420,10 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
10486
10420
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
10487
10421
|
}
|
|
10488
10422
|
draw(ctx, size, x, y) {
|
|
10489
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
10423
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
10490
10424
|
}
|
|
10491
10425
|
drawOffset(ctx, size, x, y, offset) {
|
|
10492
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
10426
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
10493
10427
|
}
|
|
10494
10428
|
}
|
|
10495
10429
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -10503,10 +10437,10 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
10503
10437
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
10504
10438
|
}
|
|
10505
10439
|
draw(ctx, size, transX, transY) {
|
|
10506
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
10440
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10507
10441
|
}
|
|
10508
10442
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10509
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
10443
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10510
10444
|
}
|
|
10511
10445
|
}
|
|
10512
10446
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -10520,10 +10454,10 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
10520
10454
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
10521
10455
|
}
|
|
10522
10456
|
draw(ctx, size, transX, transY) {
|
|
10523
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
10457
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10524
10458
|
}
|
|
10525
10459
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10526
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
10460
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10527
10461
|
}
|
|
10528
10462
|
}
|
|
10529
10463
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -10537,10 +10471,10 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
10537
10471
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
10538
10472
|
}
|
|
10539
10473
|
draw(ctx, size, transX, transY) {
|
|
10540
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
10474
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10541
10475
|
}
|
|
10542
10476
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10543
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
10477
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10544
10478
|
}
|
|
10545
10479
|
}
|
|
10546
10480
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -10554,10 +10488,10 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
10554
10488
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
10555
10489
|
}
|
|
10556
10490
|
draw(ctx, size, transX, transY) {
|
|
10557
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
10491
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
10558
10492
|
}
|
|
10559
10493
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
10560
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
10494
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
10561
10495
|
}
|
|
10562
10496
|
}
|
|
10563
10497
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -10570,13 +10504,13 @@ class LineVSymbol extends BaseSymbol {
|
|
|
10570
10504
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
10571
10505
|
}
|
|
10572
10506
|
draw(ctx, size, x, y, z) {
|
|
10573
|
-
return lineV(ctx, size / 2, x, y);
|
|
10507
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
10574
10508
|
}
|
|
10575
10509
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10576
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
10510
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10577
10511
|
}
|
|
10578
10512
|
drawToSvgPath(size, x, y, z) {
|
|
10579
|
-
const r = size / 2;
|
|
10513
|
+
const r = this.parseSize(size) / 2;
|
|
10580
10514
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
10581
10515
|
}
|
|
10582
10516
|
}
|
|
@@ -10590,13 +10524,13 @@ class LineHSymbol extends BaseSymbol {
|
|
|
10590
10524
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
10591
10525
|
}
|
|
10592
10526
|
draw(ctx, size, x, y, z) {
|
|
10593
|
-
return lineH(ctx, size / 2, x, y);
|
|
10527
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
10594
10528
|
}
|
|
10595
10529
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10596
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
10530
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10597
10531
|
}
|
|
10598
10532
|
drawToSvgPath(size, x, y, z) {
|
|
10599
|
-
const r = size / 2;
|
|
10533
|
+
const r = this.parseSize(size) / 2;
|
|
10600
10534
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
10601
10535
|
}
|
|
10602
10536
|
}
|
|
@@ -10610,13 +10544,13 @@ class CloseSymbol extends BaseSymbol {
|
|
|
10610
10544
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
10611
10545
|
}
|
|
10612
10546
|
draw(ctx, size, x, y, z) {
|
|
10613
|
-
return close(ctx, size / 2, x, y);
|
|
10547
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
10614
10548
|
}
|
|
10615
10549
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
10616
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
10550
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
10617
10551
|
}
|
|
10618
10552
|
drawToSvgPath(size, x, y, z) {
|
|
10619
|
-
const r = size / 2;
|
|
10553
|
+
const r = this.parseSize(size) / 2;
|
|
10620
10554
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
10621
10555
|
}
|
|
10622
10556
|
}
|
|
@@ -10650,15 +10584,18 @@ class CustomSymbolClass {
|
|
|
10650
10584
|
this.pathStr = "", this.type = type, isArray(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
10651
10585
|
}
|
|
10652
10586
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
10653
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10587
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
10654
10588
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
10655
10589
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
10656
10590
|
}
|
|
10657
10591
|
draw(ctx, size, x, y, z, cb) {
|
|
10658
|
-
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10592
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
10593
|
+
}
|
|
10594
|
+
parseSize(size) {
|
|
10595
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
10659
10596
|
}
|
|
10660
10597
|
bounds(size, bounds) {
|
|
10661
|
-
if (this.isSvg) {
|
|
10598
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
10662
10599
|
if (!this.svgCache) return;
|
|
10663
10600
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
10664
10601
|
let {
|
|
@@ -11162,7 +11099,11 @@ class Paragraph {
|
|
|
11162
11099
|
case "sub":
|
|
11163
11100
|
baseline += this.descent / 2;
|
|
11164
11101
|
}
|
|
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)
|
|
11102
|
+
"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);
|
|
11103
|
+
const {
|
|
11104
|
+
lineWidth = 1
|
|
11105
|
+
} = this.character;
|
|
11106
|
+
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
11107
|
}
|
|
11167
11108
|
getWidthWithEllips(direction) {
|
|
11168
11109
|
let text = this.text;
|
|
@@ -13349,8 +13290,9 @@ class PickerBase {
|
|
|
13349
13290
|
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
13291
|
if (picked) return !0;
|
|
13351
13292
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13352
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13353
|
-
|
|
13293
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13294
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13295
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13354
13296
|
}), pickContext.highPerformanceRestore(), picked;
|
|
13355
13297
|
}
|
|
13356
13298
|
}
|
|
@@ -13572,8 +13514,9 @@ class RectPickerBase {
|
|
|
13572
13514
|
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
13515
|
if (picked) return !0;
|
|
13574
13516
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13575
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13576
|
-
|
|
13517
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13518
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13519
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
13577
13520
|
});else {
|
|
13578
13521
|
const {
|
|
13579
13522
|
fill = rectAttribute.fill,
|
|
@@ -13752,8 +13695,9 @@ class BaseLinePicker extends BaseRender {
|
|
|
13752
13695
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
13753
13696
|
if (picked) return !0;
|
|
13754
13697
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13755
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13756
|
-
|
|
13698
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13699
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13700
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13757
13701
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13758
13702
|
}
|
|
13759
13703
|
}
|
|
@@ -13888,8 +13832,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
|
|
|
13888
13832
|
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
13833
|
if (picked) return !0;
|
|
13890
13834
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
13891
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
13892
|
-
|
|
13835
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
13836
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
13837
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
13893
13838
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
13894
13839
|
}
|
|
13895
13840
|
};
|
|
@@ -14453,88 +14398,370 @@ class ScrollBar extends AbstractComponent {
|
|
|
14453
14398
|
? clampRange([x1 + min * width, x1 + max * width], x1, width - sliderSize)
|
|
14454
14399
|
: clampRange([y1 + min * height, y1 + max * height], y1, height - sliderSize);
|
|
14455
14400
|
}
|
|
14456
|
-
_reset() {
|
|
14457
|
-
this._sliderRenderBounds = null;
|
|
14458
|
-
this._sliderLimitRange = null;
|
|
14401
|
+
_reset() {
|
|
14402
|
+
this._sliderRenderBounds = null;
|
|
14403
|
+
this._sliderLimitRange = null;
|
|
14404
|
+
}
|
|
14405
|
+
}
|
|
14406
|
+
ScrollBar.defaultAttributes = {
|
|
14407
|
+
direction: 'horizontal',
|
|
14408
|
+
round: true,
|
|
14409
|
+
sliderSize: 20,
|
|
14410
|
+
sliderStyle: {
|
|
14411
|
+
fill: 'rgba(0, 0, 0, .5)'
|
|
14412
|
+
},
|
|
14413
|
+
railStyle: {
|
|
14414
|
+
fill: 'rgba(0, 0, 0, .0)'
|
|
14415
|
+
},
|
|
14416
|
+
padding: 2,
|
|
14417
|
+
scrollRange: [0, 1],
|
|
14418
|
+
delayType: 'throttle',
|
|
14419
|
+
delayTime: 0,
|
|
14420
|
+
realTime: true
|
|
14421
|
+
};
|
|
14422
|
+
|
|
14423
|
+
/******************************************************************************
|
|
14424
|
+
Copyright (c) Microsoft Corporation.
|
|
14425
|
+
|
|
14426
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14427
|
+
purpose with or without fee is hereby granted.
|
|
14428
|
+
|
|
14429
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14430
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14431
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14432
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14433
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14434
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14435
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14436
|
+
***************************************************************************** */
|
|
14437
|
+
function __rest(s, e) {
|
|
14438
|
+
var t = {};
|
|
14439
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
14440
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
14441
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
14442
|
+
}
|
|
14443
|
+
return t;
|
|
14444
|
+
}
|
|
14445
|
+
function __decorate(decorators, target, key, desc) {
|
|
14446
|
+
var c = arguments.length,
|
|
14447
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
14448
|
+
d;
|
|
14449
|
+
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;
|
|
14450
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14451
|
+
}
|
|
14452
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
14453
|
+
function adopt(value) {
|
|
14454
|
+
return value instanceof P ? value : new P(function (resolve) {
|
|
14455
|
+
resolve(value);
|
|
14456
|
+
});
|
|
14457
|
+
}
|
|
14458
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14459
|
+
function fulfilled(value) {
|
|
14460
|
+
try {
|
|
14461
|
+
step(generator.next(value));
|
|
14462
|
+
} catch (e) {
|
|
14463
|
+
reject(e);
|
|
14464
|
+
}
|
|
14465
|
+
}
|
|
14466
|
+
function rejected(value) {
|
|
14467
|
+
try {
|
|
14468
|
+
step(generator["throw"](value));
|
|
14469
|
+
} catch (e) {
|
|
14470
|
+
reject(e);
|
|
14471
|
+
}
|
|
14472
|
+
}
|
|
14473
|
+
function step(result) {
|
|
14474
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
14475
|
+
}
|
|
14476
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14477
|
+
});
|
|
14478
|
+
}
|
|
14479
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
14480
|
+
var e = new Error(message);
|
|
14481
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
14482
|
+
};
|
|
14483
|
+
|
|
14484
|
+
var ScrollBarPlugin_1;
|
|
14485
|
+
let ScrollBarPlugin = ScrollBarPlugin_1 = class ScrollBarPlugin {
|
|
14486
|
+
constructor() {
|
|
14487
|
+
this.name = 'scrollbar';
|
|
14488
|
+
this.activeEvent = 'onRegister';
|
|
14489
|
+
this._uid = Generator.GenAutoIncrementId();
|
|
14490
|
+
this.key = this.name + this._uid;
|
|
14491
|
+
this.scroll = (e) => {
|
|
14492
|
+
var _a, _b;
|
|
14493
|
+
const graphic = e.target;
|
|
14494
|
+
const data = this.getScrollContainer(graphic);
|
|
14495
|
+
if (!data && !this.scrollContainer) {
|
|
14496
|
+
return;
|
|
14497
|
+
}
|
|
14498
|
+
if (!data && this.scrollContainer) {
|
|
14499
|
+
if (!this.scrollContainer.g.stage || this.scrollContainer.g.stage !== graphic.stage) {
|
|
14500
|
+
return;
|
|
14501
|
+
}
|
|
14502
|
+
const newScrollContainer = this.formatScrollContainer(this.scrollContainer.g);
|
|
14503
|
+
if (!newScrollContainer) {
|
|
14504
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14505
|
+
return;
|
|
14506
|
+
}
|
|
14507
|
+
if (this.scrollContainer.showH && !newScrollContainer.showH) {
|
|
14508
|
+
this.clearScrollbar(this.scrollContainer.g, 'horizontal');
|
|
14509
|
+
}
|
|
14510
|
+
if (this.scrollContainer.showV && !newScrollContainer.showV) {
|
|
14511
|
+
this.clearScrollbar(this.scrollContainer.g, 'vertical');
|
|
14512
|
+
}
|
|
14513
|
+
this.scrollContainer = newScrollContainer;
|
|
14514
|
+
}
|
|
14515
|
+
else if (data && this.scrollContainer && data.g !== this.scrollContainer.g) {
|
|
14516
|
+
this.clearScrollbar(this.scrollContainer.g, 'all');
|
|
14517
|
+
}
|
|
14518
|
+
this.scrollContainer = data !== null && data !== void 0 ? data : this.scrollContainer;
|
|
14519
|
+
const scrollContainer = data.g;
|
|
14520
|
+
const { width, height, scrollX = 0, scrollY = 0 } = scrollContainer.attribute;
|
|
14521
|
+
let newScrollX = scrollX;
|
|
14522
|
+
let newScrollY = scrollY;
|
|
14523
|
+
let { showH, showV } = data;
|
|
14524
|
+
this.scrollContainerBounds = new Bounds().set(0, 0, scrollContainer.attribute.width, scrollContainer.attribute.height);
|
|
14525
|
+
if (showH && showH) {
|
|
14526
|
+
if (abs(e.deltaX) > abs(e.deltaY)) {
|
|
14527
|
+
showH = showH && true;
|
|
14528
|
+
showV = showV && false;
|
|
14529
|
+
}
|
|
14530
|
+
else {
|
|
14531
|
+
showH = showH && false;
|
|
14532
|
+
showV = showV && true;
|
|
14533
|
+
}
|
|
14534
|
+
}
|
|
14535
|
+
const childrenBounds = this.childrenBounds;
|
|
14536
|
+
childrenBounds.clear();
|
|
14537
|
+
childrenBounds.set(0, 0, scrollContainer.AABBBounds.width(), scrollContainer.AABBBounds.height());
|
|
14538
|
+
const scrollWidth = childrenBounds.width();
|
|
14539
|
+
const scrollHeight = childrenBounds.height();
|
|
14540
|
+
if (showH) {
|
|
14541
|
+
newScrollX = Math.max(Math.min(((_a = e.deltaX) !== null && _a !== void 0 ? _a : 0) - scrollX, scrollWidth - width), 0);
|
|
14542
|
+
}
|
|
14543
|
+
else {
|
|
14544
|
+
newScrollX = -scrollX;
|
|
14545
|
+
}
|
|
14546
|
+
if (showV) {
|
|
14547
|
+
newScrollY = Math.max(Math.min(((_b = e.deltaY) !== null && _b !== void 0 ? _b : 0) - scrollY, scrollHeight - height), 0);
|
|
14548
|
+
}
|
|
14549
|
+
else {
|
|
14550
|
+
newScrollY = -scrollY;
|
|
14551
|
+
}
|
|
14552
|
+
childrenBounds.translate(-newScrollX, -newScrollY);
|
|
14553
|
+
this.addOrUpdateScroll(showH, showV, scrollContainer.parent, scrollContainer);
|
|
14554
|
+
scrollContainer.setAttributes({
|
|
14555
|
+
scrollX: -newScrollX,
|
|
14556
|
+
scrollY: -newScrollY
|
|
14557
|
+
});
|
|
14558
|
+
};
|
|
14559
|
+
this.handleScrollBarChange = (params) => {
|
|
14560
|
+
if (!this.scrollContainer ||
|
|
14561
|
+
!this.scrollContainerBounds ||
|
|
14562
|
+
!this.childrenBounds ||
|
|
14563
|
+
!params ||
|
|
14564
|
+
!params.target ||
|
|
14565
|
+
!params.detail ||
|
|
14566
|
+
!params.detail.value) {
|
|
14567
|
+
return;
|
|
14568
|
+
}
|
|
14569
|
+
const scrollbar = params.target;
|
|
14570
|
+
const newRange = params.detail.value;
|
|
14571
|
+
if (scrollbar.attribute.direction === 'horizontal') {
|
|
14572
|
+
const scrollWidth = this.childrenBounds.width();
|
|
14573
|
+
this.scrollContainer.g.setAttributes({ scrollX: -newRange[0] * scrollWidth });
|
|
14574
|
+
}
|
|
14575
|
+
else {
|
|
14576
|
+
const scrollHeight = this.childrenBounds.height();
|
|
14577
|
+
this.scrollContainer.g.setAttributes({ scrollY: -newRange[0] * scrollHeight });
|
|
14578
|
+
}
|
|
14579
|
+
};
|
|
14580
|
+
}
|
|
14581
|
+
activate(context) {
|
|
14582
|
+
this.pluginService = context;
|
|
14583
|
+
const { stage } = this.pluginService;
|
|
14584
|
+
this.childrenBounds = new AABBBounds();
|
|
14585
|
+
stage.addEventListener('wheel', this.scroll);
|
|
14586
|
+
this.params = ScrollBarPlugin_1.defaultParams;
|
|
14587
|
+
}
|
|
14588
|
+
initEventOfScrollbar(scrollContainer, scrollbar, isHorozntal) {
|
|
14589
|
+
scrollContainer.addEventListener('pointerover', () => {
|
|
14590
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14591
|
+
});
|
|
14592
|
+
scrollContainer.addEventListener('pointermove', () => {
|
|
14593
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14594
|
+
});
|
|
14595
|
+
scrollContainer.addEventListener('pointerout', () => {
|
|
14596
|
+
scrollbar.setAttribute('visibleAll', false);
|
|
14597
|
+
});
|
|
14598
|
+
scrollbar.addEventListener('pointerover', () => {
|
|
14599
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14600
|
+
});
|
|
14601
|
+
scrollbar.addEventListener('pointerout', () => {
|
|
14602
|
+
scrollbar.setAttribute('visibleAll', true);
|
|
14603
|
+
});
|
|
14604
|
+
scrollbar.addEventListener('scrollUp', this.handleScrollBarChange);
|
|
14605
|
+
scrollbar.addEventListener(SCROLLBAR_EVENT, this.handleScrollBarChange);
|
|
14606
|
+
}
|
|
14607
|
+
addOrUpdateScroll(showH, showV, container, scrollContainer) {
|
|
14608
|
+
if (showH) {
|
|
14609
|
+
const { scrollBar: hScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, true);
|
|
14610
|
+
if (!isUpdate) {
|
|
14611
|
+
this.initEventOfScrollbar(scrollContainer, hScrollbar, true);
|
|
14612
|
+
}
|
|
14613
|
+
}
|
|
14614
|
+
else {
|
|
14615
|
+
this.clearScrollbar(scrollContainer, 'horizontal');
|
|
14616
|
+
}
|
|
14617
|
+
if (showV) {
|
|
14618
|
+
const { scrollBar: vScrollbar, isUpdate } = this.addOrUpdateHScroll(scrollContainer, container, false);
|
|
14619
|
+
if (!isUpdate) {
|
|
14620
|
+
this.initEventOfScrollbar(scrollContainer, vScrollbar, false);
|
|
14621
|
+
}
|
|
14622
|
+
}
|
|
14623
|
+
else {
|
|
14624
|
+
this.clearScrollbar(scrollContainer, 'vertical');
|
|
14625
|
+
}
|
|
14626
|
+
}
|
|
14627
|
+
getDirection(isHorozntal) {
|
|
14628
|
+
return isHorozntal ? 'horizontal' : 'vertical';
|
|
14629
|
+
}
|
|
14630
|
+
addOrUpdateHScroll(scrollContainer, container, isHorozntal) {
|
|
14631
|
+
var _a;
|
|
14632
|
+
const direction = this.getDirection(isHorozntal);
|
|
14633
|
+
const name = `${(_a = scrollContainer.name) !== null && _a !== void 0 ? _a : scrollContainer._uid}_${this.getDirection(isHorozntal)}_${this.name}`;
|
|
14634
|
+
const scrollbars = container.children.filter((g) => g.name === name);
|
|
14635
|
+
let isUpdate = true;
|
|
14636
|
+
let scrollBar = scrollbars[0];
|
|
14637
|
+
const { y = 0, dy = 0, x = 0, dx = 0, height, width, zIndex = 0 } = this.scrollContainer.g.attribute;
|
|
14638
|
+
const attrs = {
|
|
14639
|
+
x: 0,
|
|
14640
|
+
y: 0,
|
|
14641
|
+
direction,
|
|
14642
|
+
zIndex: zIndex + 1,
|
|
14643
|
+
visibleAll: true,
|
|
14644
|
+
padding: [2, 0],
|
|
14645
|
+
railStyle: {
|
|
14646
|
+
fill: 'rgba(0, 0, 0, .1)'
|
|
14647
|
+
},
|
|
14648
|
+
range: [0, 0.05]
|
|
14649
|
+
};
|
|
14650
|
+
if (isHorozntal) {
|
|
14651
|
+
attrs.width = this.scrollContainerBounds.width();
|
|
14652
|
+
attrs.height = 12;
|
|
14653
|
+
}
|
|
14654
|
+
else {
|
|
14655
|
+
attrs.height = this.scrollContainerBounds.height();
|
|
14656
|
+
attrs.width = 12;
|
|
14657
|
+
}
|
|
14658
|
+
if (!scrollBar) {
|
|
14659
|
+
isUpdate = false;
|
|
14660
|
+
scrollBar = new ScrollBar(attrs);
|
|
14661
|
+
scrollBar.name = name;
|
|
14662
|
+
container.add(scrollBar);
|
|
14663
|
+
scrollBar.isScrollBar = true;
|
|
14664
|
+
}
|
|
14665
|
+
else if (scrollbars.length > 1) {
|
|
14666
|
+
scrollbars.forEach((child, index) => {
|
|
14667
|
+
var _a;
|
|
14668
|
+
if (index) {
|
|
14669
|
+
(_a = child.parent) === null || _a === void 0 ? void 0 : _a.removeChild(child);
|
|
14670
|
+
}
|
|
14671
|
+
});
|
|
14672
|
+
}
|
|
14673
|
+
const childrenBounds = this.childrenBounds;
|
|
14674
|
+
if (isHorozntal) {
|
|
14675
|
+
const ratio = Math.min(this.scrollContainerBounds.width() / childrenBounds.width(), 1);
|
|
14676
|
+
const start = Math.max(Math.min(this.childrenBounds.x1 / this.childrenBounds.width(), 0), ratio - 1);
|
|
14677
|
+
attrs.x = x + dx;
|
|
14678
|
+
attrs.y = y + dy + height - this.scrollContainerBounds.height();
|
|
14679
|
+
attrs.range = [-start, -start + ratio];
|
|
14680
|
+
}
|
|
14681
|
+
else {
|
|
14682
|
+
const ratio = Math.min(this.scrollContainerBounds.height() / childrenBounds.height(), 1);
|
|
14683
|
+
const start = Math.max(Math.min(this.childrenBounds.y1 / this.childrenBounds.height(), 0), ratio - 1);
|
|
14684
|
+
attrs.x = x + dx + width - this.scrollContainerBounds.width();
|
|
14685
|
+
attrs.y = y + dy;
|
|
14686
|
+
attrs.range = [-start, -start + ratio];
|
|
14687
|
+
}
|
|
14688
|
+
scrollBar.setAttributes(attrs);
|
|
14689
|
+
return {
|
|
14690
|
+
scrollBar,
|
|
14691
|
+
isUpdate
|
|
14692
|
+
};
|
|
14693
|
+
}
|
|
14694
|
+
clearScrollbar(scrollContainer, type) {
|
|
14695
|
+
if (!scrollContainer.parent) {
|
|
14696
|
+
return;
|
|
14697
|
+
}
|
|
14698
|
+
const scrollbarBars = scrollContainer.parent.children.filter((child) => {
|
|
14699
|
+
return child.isScrollBar && (type === 'all' || child.attribute.direction === type);
|
|
14700
|
+
});
|
|
14701
|
+
scrollbarBars.forEach((child) => {
|
|
14702
|
+
child.parent.removeChild(child);
|
|
14703
|
+
});
|
|
14704
|
+
}
|
|
14705
|
+
formatScrollContainer(g) {
|
|
14706
|
+
if (!g || g.type !== 'group' || !g.attribute) {
|
|
14707
|
+
return null;
|
|
14708
|
+
}
|
|
14709
|
+
const { overflow, width, height } = g.attribute;
|
|
14710
|
+
if (!overflow || overflow === 'hidden') {
|
|
14711
|
+
return null;
|
|
14712
|
+
}
|
|
14713
|
+
let showH = false;
|
|
14714
|
+
let showV = false;
|
|
14715
|
+
if (overflow === 'scroll') {
|
|
14716
|
+
showH = true;
|
|
14717
|
+
showV = true;
|
|
14718
|
+
}
|
|
14719
|
+
else {
|
|
14720
|
+
showH = overflow === 'scroll-x';
|
|
14721
|
+
showV = !showH;
|
|
14722
|
+
}
|
|
14723
|
+
if (!g.AABBBounds.empty()) {
|
|
14724
|
+
if (showH) {
|
|
14725
|
+
showH = width < g.AABBBounds.width();
|
|
14726
|
+
}
|
|
14727
|
+
if (showV) {
|
|
14728
|
+
showV = height < g.AABBBounds.height();
|
|
14729
|
+
}
|
|
14730
|
+
}
|
|
14731
|
+
return showH || showV ? { g: g, showH, showV } : null;
|
|
14732
|
+
}
|
|
14733
|
+
getScrollContainer(graphic) {
|
|
14734
|
+
let g = graphic;
|
|
14735
|
+
while (g) {
|
|
14736
|
+
const res = this.formatScrollContainer(g);
|
|
14737
|
+
if (res) {
|
|
14738
|
+
return res;
|
|
14739
|
+
}
|
|
14740
|
+
g = g.parent;
|
|
14741
|
+
}
|
|
14742
|
+
return null;
|
|
14743
|
+
}
|
|
14744
|
+
deactivate(context) {
|
|
14745
|
+
const { stage } = this.pluginService;
|
|
14746
|
+
stage.removeEventListener('wheel', this.scroll);
|
|
14459
14747
|
}
|
|
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
14748
|
};
|
|
14749
|
+
ScrollBarPlugin.defaultParams = {
|
|
14750
|
+
timeout: 500
|
|
14751
|
+
};
|
|
14752
|
+
ScrollBarPlugin = ScrollBarPlugin_1 = __decorate([
|
|
14753
|
+
injectable()
|
|
14754
|
+
], ScrollBarPlugin);
|
|
14477
14755
|
|
|
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);
|
|
14756
|
+
const scrollbarModule = new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
14757
|
+
if (!isBound(ScrollBarPlugin)) {
|
|
14758
|
+
bind(ScrollBarPlugin).toSelf();
|
|
14759
|
+
bind(AutoEnablePlugins).toService(ScrollBarPlugin);
|
|
14530
14760
|
}
|
|
14531
|
-
|
|
14532
|
-
|
|
14761
|
+
});
|
|
14762
|
+
function loadScrollbar() {
|
|
14763
|
+
container.load(scrollbarModule);
|
|
14533
14764
|
}
|
|
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
14765
|
|
|
14539
14766
|
function traverseGroup(group, cb) {
|
|
14540
14767
|
group.forEachChildren(node => {
|
|
@@ -15993,24 +16220,29 @@ function defaultLabelPosition(type) {
|
|
|
15993
16220
|
return DefaultPositions;
|
|
15994
16221
|
}
|
|
15995
16222
|
}
|
|
15996
|
-
function clampText(text, width, height) {
|
|
16223
|
+
function clampText(text, width, height, padding = {}) {
|
|
15997
16224
|
const { x1, x2, y1, y2 } = text.AABBBounds;
|
|
16225
|
+
const { top = 0, left = 0, right = 0, bottom = 0 } = padding;
|
|
15998
16226
|
const minX = Math.min(x1, x2);
|
|
15999
16227
|
const maxX = Math.max(x1, x2);
|
|
16000
16228
|
const minY = Math.min(y1, y2);
|
|
16001
16229
|
const maxY = Math.max(y1, y2);
|
|
16230
|
+
const minXWithPadding = 0 - left;
|
|
16231
|
+
const maxXWithPadding = width + right;
|
|
16232
|
+
const minYWithPadding = 0 - top;
|
|
16233
|
+
const maxYWithPadding = height + bottom;
|
|
16002
16234
|
let dx = 0;
|
|
16003
16235
|
let dy = 0;
|
|
16004
|
-
if (minX <
|
|
16236
|
+
if (minX < minXWithPadding && maxX - minX <= width) {
|
|
16005
16237
|
dx = -minX;
|
|
16006
16238
|
}
|
|
16007
|
-
else if (maxX >
|
|
16239
|
+
else if (maxX > maxXWithPadding && minX - (maxX - width) >= minXWithPadding) {
|
|
16008
16240
|
dx = width - maxX;
|
|
16009
16241
|
}
|
|
16010
|
-
if (minY <
|
|
16242
|
+
if (minY < minYWithPadding && maxY - minY <= height) {
|
|
16011
16243
|
dy = -minY;
|
|
16012
16244
|
}
|
|
16013
|
-
else if (maxY >
|
|
16245
|
+
else if (maxY > maxYWithPadding && minY - (maxY - height) >= minYWithPadding) {
|
|
16014
16246
|
dy = height - maxY;
|
|
16015
16247
|
}
|
|
16016
16248
|
return { dx, dy };
|
|
@@ -16310,56 +16542,121 @@ function loadLabelComponent() {
|
|
|
16310
16542
|
registerLine();
|
|
16311
16543
|
}
|
|
16312
16544
|
|
|
16313
|
-
|
|
16314
|
-
|
|
16545
|
+
const isIntersect = (top, bottom) => {
|
|
16546
|
+
return Math.ceil(top) > Math.floor(bottom);
|
|
16547
|
+
};
|
|
16548
|
+
const isXIntersect = ([a, b], [c, d]) => {
|
|
16549
|
+
return d > a && b > c;
|
|
16550
|
+
};
|
|
16551
|
+
function getIntersectionLength(range1, range2) {
|
|
16552
|
+
const [start1, end1] = range1;
|
|
16553
|
+
const [start2, end2] = range2;
|
|
16554
|
+
const start = Math.max(start1, start2);
|
|
16555
|
+
const end = Math.min(end1, end2);
|
|
16556
|
+
return Math.max(0, end - start);
|
|
16557
|
+
}
|
|
16558
|
+
function shiftY(texts, option) {
|
|
16559
|
+
const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE, labelling } = option;
|
|
16315
16560
|
const n = texts.length;
|
|
16316
16561
|
if (n <= 1) {
|
|
16317
16562
|
return texts;
|
|
16318
16563
|
}
|
|
16319
|
-
const
|
|
16320
|
-
return d > a && b > c;
|
|
16321
|
-
};
|
|
16564
|
+
const xMap = new Map();
|
|
16322
16565
|
const textInformation = new Map();
|
|
16323
|
-
const
|
|
16324
|
-
const getY = (text) => textInformation.get(text).y;
|
|
16566
|
+
const getY1Initial = (text) => textInformation.get(text).y1Initial;
|
|
16325
16567
|
const getHeight = (text) => textInformation.get(text).height;
|
|
16568
|
+
const getY1 = (text) => textInformation.get(text).y1;
|
|
16569
|
+
const getY = (text) => textInformation.get(text).y;
|
|
16570
|
+
const getX = (text) => textInformation.get(text).x;
|
|
16326
16571
|
const getX1 = (text) => textInformation.get(text).x1;
|
|
16327
16572
|
const getX2 = (text) => textInformation.get(text).x2;
|
|
16328
|
-
const
|
|
16329
|
-
textInformation.get(text).
|
|
16573
|
+
const setY1 = (text, y) => {
|
|
16574
|
+
textInformation.get(text).y1 = y;
|
|
16330
16575
|
};
|
|
16576
|
+
function adjustPositionInOneGroup(texts) {
|
|
16577
|
+
if (texts.length === 1) {
|
|
16578
|
+
return;
|
|
16579
|
+
}
|
|
16580
|
+
for (let i = texts.length - 1; i > 0; i--) {
|
|
16581
|
+
const curText = texts[i];
|
|
16582
|
+
const upperText = texts[i - 1];
|
|
16583
|
+
const lowerText = texts[i + 1];
|
|
16584
|
+
if (isIntersect(getY1(upperText) + getHeight(upperText), getY1(curText))) {
|
|
16585
|
+
const { y } = labelling(curText);
|
|
16586
|
+
if (!lowerText || !isIntersect(y + getHeight(curText) / 2, getY1(lowerText))) {
|
|
16587
|
+
if (y + getHeight(curText) / 2 <= maxY) {
|
|
16588
|
+
setY1(curText, getY1(curText) + y - getY(curText));
|
|
16589
|
+
}
|
|
16590
|
+
}
|
|
16591
|
+
}
|
|
16592
|
+
}
|
|
16593
|
+
}
|
|
16594
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16331
16595
|
for (const text of texts) {
|
|
16332
16596
|
const { y1, y2, x1, x2 } = text.AABBBounds;
|
|
16333
|
-
|
|
16597
|
+
const { x, y } = text.attribute;
|
|
16598
|
+
textInformation.set(text, { y1Initial: y1, y1, y2, y, height: y2 - y1, x1, x2, x });
|
|
16599
|
+
let hasRange = false;
|
|
16600
|
+
for (const [range, xGroupTexts] of xMap) {
|
|
16601
|
+
const { start, end } = range;
|
|
16602
|
+
if (x1 >= start && x2 <= end) {
|
|
16603
|
+
xGroupTexts.push(text);
|
|
16604
|
+
hasRange = true;
|
|
16605
|
+
}
|
|
16606
|
+
else if (isNumberClose(x, getX(xGroupTexts[0]), undefined, 5)) {
|
|
16607
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16608
|
+
xGroupTexts.push(text);
|
|
16609
|
+
xMap.set(newRange, xGroupTexts);
|
|
16610
|
+
xMap.delete(range);
|
|
16611
|
+
hasRange = true;
|
|
16612
|
+
}
|
|
16613
|
+
else if (getIntersectionLength([start, end], [x1, x2]) / (end - start) > 0.5) {
|
|
16614
|
+
const newRange = { start: Math.min(start, x1), end: Math.max(end, x2) };
|
|
16615
|
+
xGroupTexts.push(text);
|
|
16616
|
+
xMap.set(newRange, xGroupTexts);
|
|
16617
|
+
xMap.delete(range);
|
|
16618
|
+
hasRange = true;
|
|
16619
|
+
}
|
|
16620
|
+
if (hasRange) {
|
|
16621
|
+
break;
|
|
16622
|
+
}
|
|
16623
|
+
}
|
|
16624
|
+
if (!hasRange) {
|
|
16625
|
+
xMap.set({ start: x1, end: x2 }, [text]);
|
|
16626
|
+
}
|
|
16627
|
+
}
|
|
16628
|
+
for (const xTexts of xMap.values()) {
|
|
16629
|
+
xTexts.sort((a, b) => getY1Initial(a) - getY1Initial(b));
|
|
16630
|
+
adjustPositionInOneGroup(xTexts);
|
|
16334
16631
|
}
|
|
16335
16632
|
for (let iter = 0; iter < maxIterations; iter++) {
|
|
16336
|
-
texts.sort((a, b) =>
|
|
16633
|
+
texts.sort((a, b) => getY1(a) - getY1(b));
|
|
16337
16634
|
let error = 0;
|
|
16338
16635
|
for (let i = 0; i < n - 1; i++) {
|
|
16339
16636
|
const curText = texts[i];
|
|
16340
16637
|
let j = i + 1;
|
|
16341
16638
|
let nextText;
|
|
16342
16639
|
while ((nextText = texts[j]) &&
|
|
16343
|
-
!
|
|
16640
|
+
!isXIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
|
|
16344
16641
|
j += 1;
|
|
16345
16642
|
}
|
|
16346
16643
|
if (nextText) {
|
|
16347
|
-
const
|
|
16644
|
+
const y1 = getY1(curText);
|
|
16348
16645
|
const h0 = getHeight(curText);
|
|
16349
|
-
const
|
|
16350
|
-
const delta =
|
|
16646
|
+
const nextY1 = getY1(nextText);
|
|
16647
|
+
const delta = nextY1 - (y1 + h0);
|
|
16351
16648
|
if (delta < padding) {
|
|
16352
16649
|
const newDelta = (padding - delta) / 2;
|
|
16353
16650
|
error = Math.max(error, newDelta);
|
|
16354
16651
|
if (y1 + newDelta + getHeight(nextText) > maxY) {
|
|
16355
|
-
|
|
16652
|
+
setY1(curText, y1 - (padding - delta));
|
|
16356
16653
|
}
|
|
16357
|
-
else if (
|
|
16358
|
-
|
|
16654
|
+
else if (y1 - newDelta < 0) {
|
|
16655
|
+
setY1(nextText, nextY1 + (padding - delta));
|
|
16359
16656
|
}
|
|
16360
16657
|
else {
|
|
16361
|
-
|
|
16362
|
-
|
|
16658
|
+
setY1(curText, y1 - newDelta);
|
|
16659
|
+
setY1(nextText, nextY1 + newDelta);
|
|
16363
16660
|
}
|
|
16364
16661
|
}
|
|
16365
16662
|
}
|
|
@@ -16369,10 +16666,25 @@ function shiftY(texts, option = {}) {
|
|
|
16369
16666
|
}
|
|
16370
16667
|
}
|
|
16371
16668
|
for (const text of texts) {
|
|
16372
|
-
const finalY = text.attribute.y +
|
|
16669
|
+
const finalY = text.attribute.y + getY1(text) - getY1Initial(text);
|
|
16373
16670
|
text.setAttribute('y', finalY);
|
|
16374
16671
|
}
|
|
16375
|
-
|
|
16672
|
+
const result = [];
|
|
16673
|
+
texts.sort((a, b) => a.attribute.x - b.attribute.x);
|
|
16674
|
+
let start = 0;
|
|
16675
|
+
let end = texts.length - 1;
|
|
16676
|
+
while (start <= end) {
|
|
16677
|
+
if (start === end) {
|
|
16678
|
+
result.push(texts[start]);
|
|
16679
|
+
}
|
|
16680
|
+
else {
|
|
16681
|
+
result.push(texts[start]);
|
|
16682
|
+
result.push(texts[end]);
|
|
16683
|
+
}
|
|
16684
|
+
start++;
|
|
16685
|
+
end--;
|
|
16686
|
+
}
|
|
16687
|
+
return result;
|
|
16376
16688
|
}
|
|
16377
16689
|
|
|
16378
16690
|
loadLabelComponent();
|
|
@@ -16718,18 +17030,25 @@ class LabelBase extends AbstractComponent {
|
|
|
16718
17030
|
if (clampForce) {
|
|
16719
17031
|
for (let i = 0; i < result.length; i++) {
|
|
16720
17032
|
const text = labels[i];
|
|
16721
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17033
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
16722
17034
|
if (dx !== 0 || dy !== 0) {
|
|
16723
17035
|
text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
|
|
17036
|
+
text._isClamped = true;
|
|
16724
17037
|
}
|
|
16725
17038
|
}
|
|
16726
17039
|
}
|
|
16727
|
-
result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy))
|
|
17040
|
+
result = shiftY(result, Object.assign(Object.assign({ maxY: bmpTool.height }, strategy), { labelling: (text) => {
|
|
17041
|
+
const baseMark = this.getRelatedGraphic(text.attribute);
|
|
17042
|
+
const graphicBound = this._isCollectionBase
|
|
17043
|
+
? this.getGraphicBounds(null, this._idToPoint.get(text.attribute.id))
|
|
17044
|
+
: this.getGraphicBounds(baseMark, text);
|
|
17045
|
+
return this.labeling(text.AABBBounds, graphicBound, 'bottom', this.attribute.offset);
|
|
17046
|
+
} }));
|
|
16728
17047
|
for (let i = 0; i < result.length; i++) {
|
|
16729
17048
|
const text = result[i];
|
|
16730
17049
|
const bounds = text.AABBBounds;
|
|
16731
17050
|
const range = boundToRange(bmpTool, bounds, true);
|
|
16732
|
-
if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
|
|
17051
|
+
if (canPlace(bmpTool, bitmap, bounds, clampForce, text._isClamped ? 0 : overlapPadding)) {
|
|
16733
17052
|
bitmap.setRange(range);
|
|
16734
17053
|
}
|
|
16735
17054
|
else {
|
|
@@ -16802,7 +17121,7 @@ class LabelBase extends AbstractComponent {
|
|
|
16802
17121
|
}
|
|
16803
17122
|
}
|
|
16804
17123
|
if (!hasPlace && clampForce) {
|
|
16805
|
-
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
|
|
17124
|
+
const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height, bmpTool.padding);
|
|
16806
17125
|
if (dx === 0 && dy === 0) {
|
|
16807
17126
|
if (canPlace(bmpTool, bitmap, text.AABBBounds)) {
|
|
16808
17127
|
bitmap.setRange(boundToRange(bmpTool, text.AABBBounds, true));
|
|
@@ -17286,6 +17605,9 @@ class ArcLabel extends LabelBase {
|
|
|
17286
17605
|
this._alignOffset = 0;
|
|
17287
17606
|
}
|
|
17288
17607
|
_overlapping(labels) {
|
|
17608
|
+
if (['inside', 'inside-center'].includes(this.attribute.position)) {
|
|
17609
|
+
return super._overlapping(labels);
|
|
17610
|
+
}
|
|
17289
17611
|
return labels;
|
|
17290
17612
|
}
|
|
17291
17613
|
labeling(textBounds, graphicBounds, position = 'outside', offset = 0) {
|
|
@@ -29552,690 +29874,6 @@ EmptyTip.defaultAttributes = {
|
|
|
29552
29874
|
}
|
|
29553
29875
|
};
|
|
29554
29876
|
|
|
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";
|
|
29877
|
+
const version = "0.21.0-alpha.5";
|
|
30240
29878
|
|
|
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,
|
|
29879
|
+
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 };
|