@visactor/vrender 0.21.0-alpha.1 → 0.21.0-alpha.3
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/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +521 -464
- package/dist/index.js +521 -464
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2732,11 +2732,12 @@
|
|
|
2732
2732
|
for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
|
|
2733
2733
|
for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
|
|
2734
2734
|
if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
|
|
2735
|
-
let subCommand
|
|
2735
|
+
let subCommand,
|
|
2736
|
+
bestCommandChar = commandChar;
|
|
2736
2737
|
for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
|
|
2737
|
-
subCommand = [
|
|
2738
|
+
subCommand = [bestCommandChar];
|
|
2738
2739
|
for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
|
|
2739
|
-
result.push(subCommand);
|
|
2740
|
+
result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
|
|
2740
2741
|
}
|
|
2741
2742
|
} else result.push(currCommandData);
|
|
2742
2743
|
} else result.push(currCommandData);
|
|
@@ -3918,6 +3919,7 @@
|
|
|
3918
3919
|
const DefaultTextStyle = {
|
|
3919
3920
|
text: "",
|
|
3920
3921
|
maxLineWidth: 1 / 0,
|
|
3922
|
+
maxWidth: 1 / 0,
|
|
3921
3923
|
textAlign: "left",
|
|
3922
3924
|
textBaseline: "alphabetic",
|
|
3923
3925
|
fontSize: 16,
|
|
@@ -3985,6 +3987,7 @@
|
|
|
3985
3987
|
zIndex: 0,
|
|
3986
3988
|
layout: null,
|
|
3987
3989
|
boundsPadding: 0,
|
|
3990
|
+
fillStrokeOrder: 0,
|
|
3988
3991
|
renderStyle: "default",
|
|
3989
3992
|
pickMode: "accurate",
|
|
3990
3993
|
customPickShape: null,
|
|
@@ -4063,6 +4066,7 @@
|
|
|
4063
4066
|
});
|
|
4064
4067
|
const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
|
|
4065
4068
|
path: new CustomPath2D(),
|
|
4069
|
+
fillStrokeOrder: 1,
|
|
4066
4070
|
customPath: () => {
|
|
4067
4071
|
Logger.getInstance().warn("空函数");
|
|
4068
4072
|
}
|
|
@@ -4268,10 +4272,32 @@
|
|
|
4268
4272
|
configure(service, env) {
|
|
4269
4273
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4270
4274
|
}
|
|
4271
|
-
|
|
4272
|
-
if (!this.context) return this.estimate(text, options).width;
|
|
4275
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
4273
4276
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4274
|
-
|
|
4277
|
+
const metrics = this.context.measureText(text);
|
|
4278
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4279
|
+
}
|
|
4280
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
4281
|
+
this.context.setTextStyle(options);
|
|
4282
|
+
const metrics = this.context.measureText(text);
|
|
4283
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4284
|
+
}
|
|
4285
|
+
compatibleMetrics(metrics, options) {
|
|
4286
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
4287
|
+
const {
|
|
4288
|
+
ascent: ascent,
|
|
4289
|
+
descent: descent
|
|
4290
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
4291
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
4292
|
+
}
|
|
4293
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
4294
|
+
const {
|
|
4295
|
+
left: left,
|
|
4296
|
+
right: right
|
|
4297
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
4298
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
4299
|
+
}
|
|
4300
|
+
return metrics;
|
|
4275
4301
|
}
|
|
4276
4302
|
estimate(text, _ref) {
|
|
4277
4303
|
let {
|
|
@@ -4285,19 +4311,85 @@
|
|
|
4285
4311
|
height: fontSize
|
|
4286
4312
|
};
|
|
4287
4313
|
}
|
|
4288
|
-
|
|
4314
|
+
measureTextWidth(text, options, textMeasure) {
|
|
4315
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4316
|
+
}
|
|
4317
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
4318
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4319
|
+
}
|
|
4320
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
4321
|
+
return this.context ? {
|
|
4322
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
4323
|
+
right: textMeasure.actualBoundingBoxRight
|
|
4324
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
4325
|
+
}
|
|
4326
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
4289
4327
|
var _a;
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
return
|
|
4328
|
+
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;
|
|
4329
|
+
}
|
|
4330
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
4331
|
+
return this.context ? {
|
|
4332
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
4333
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
4334
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4294
4335
|
}
|
|
4295
|
-
measureTextBoundHieght(text, options) {
|
|
4336
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
4296
4337
|
var _a;
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
return
|
|
4338
|
+
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;
|
|
4339
|
+
}
|
|
4340
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
4341
|
+
return this.context ? {
|
|
4342
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
4343
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
4344
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4345
|
+
}
|
|
4346
|
+
measureTextBoundADscentEstimate(options) {
|
|
4347
|
+
var _a;
|
|
4348
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
4349
|
+
{
|
|
4350
|
+
textBaseline: textBaseline
|
|
4351
|
+
} = options;
|
|
4352
|
+
return "bottom" === textBaseline ? {
|
|
4353
|
+
ascent: fontSize,
|
|
4354
|
+
descent: 0
|
|
4355
|
+
} : "middle" === textBaseline ? {
|
|
4356
|
+
ascent: fontSize / 2,
|
|
4357
|
+
descent: fontSize / 2
|
|
4358
|
+
} : "alphabetic" === textBaseline ? {
|
|
4359
|
+
ascent: .79 * fontSize,
|
|
4360
|
+
descent: .21 * fontSize
|
|
4361
|
+
} : {
|
|
4362
|
+
ascent: 0,
|
|
4363
|
+
descent: fontSize
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4366
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
4367
|
+
var _a;
|
|
4368
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
4369
|
+
{
|
|
4370
|
+
textAlign: textAlign
|
|
4371
|
+
} = options;
|
|
4372
|
+
return "center" === textAlign ? {
|
|
4373
|
+
left: fontSize / 2,
|
|
4374
|
+
right: fontSize / 2
|
|
4375
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
4376
|
+
left: fontSize,
|
|
4377
|
+
right: 0
|
|
4378
|
+
} : {
|
|
4379
|
+
left: 0,
|
|
4380
|
+
right: fontSize
|
|
4381
|
+
};
|
|
4382
|
+
}
|
|
4383
|
+
measureTextPixelADscentAndWidth(text, options) {
|
|
4384
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4385
|
+
width: this.estimate(text, options).width
|
|
4386
|
+
});
|
|
4387
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
4388
|
+
return {
|
|
4389
|
+
ascent: out.actualBoundingBoxAscent,
|
|
4390
|
+
descent: out.actualBoundingBoxDescent,
|
|
4391
|
+
width: out.width
|
|
4392
|
+
};
|
|
4301
4393
|
}
|
|
4302
4394
|
measureText(text, options) {
|
|
4303
4395
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -4375,6 +4467,14 @@
|
|
|
4375
4467
|
return data;
|
|
4376
4468
|
}
|
|
4377
4469
|
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
4470
|
+
if (leftIdx === rightIdx) {
|
|
4471
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
4472
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
4473
|
+
return {
|
|
4474
|
+
str: subText,
|
|
4475
|
+
width: this.measureTextWidth(subText, options)
|
|
4476
|
+
};
|
|
4477
|
+
}
|
|
4378
4478
|
const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
|
|
4379
4479
|
subText = text.substring(0, middleIdx + 1),
|
|
4380
4480
|
strWidth = this.measureTextWidth(subText, options);
|
|
@@ -4408,7 +4508,7 @@
|
|
|
4408
4508
|
}
|
|
4409
4509
|
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
4410
4510
|
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
|
|
4411
|
-
subText = text.substring(middleIdx - 1, text.length
|
|
4511
|
+
subText = text.substring(middleIdx - 1, text.length),
|
|
4412
4512
|
strWidth = this.measureTextWidth(subText, options);
|
|
4413
4513
|
let length;
|
|
4414
4514
|
if (strWidth > width) {
|
|
@@ -4416,18 +4516,18 @@
|
|
|
4416
4516
|
str: "",
|
|
4417
4517
|
width: 0
|
|
4418
4518
|
};
|
|
4419
|
-
const str = text.substring(middleIdx, text.length
|
|
4519
|
+
const str = text.substring(middleIdx, text.length);
|
|
4420
4520
|
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
4421
4521
|
str: str,
|
|
4422
4522
|
width: length
|
|
4423
|
-
} : this._clipTextStart(text, options, width, middleIdx, text.length
|
|
4523
|
+
} : this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
4424
4524
|
}
|
|
4425
4525
|
if (strWidth < width) {
|
|
4426
4526
|
if (middleIdx <= 0) return {
|
|
4427
4527
|
str: text,
|
|
4428
4528
|
width: this.measureTextWidth(text, options)
|
|
4429
4529
|
};
|
|
4430
|
-
const str = text.substring(middleIdx - 2, text.length
|
|
4530
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
4431
4531
|
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
4432
4532
|
str: subText,
|
|
4433
4533
|
width: strWidth
|
|
@@ -5088,7 +5188,7 @@
|
|
|
5088
5188
|
}
|
|
5089
5189
|
hasSubView() {
|
|
5090
5190
|
const viewBox = this._handler.getViewBox();
|
|
5091
|
-
return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width
|
|
5191
|
+
return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
|
|
5092
5192
|
}
|
|
5093
5193
|
isVisible(bbox) {
|
|
5094
5194
|
return this._handler.isVisible(bbox);
|
|
@@ -6012,7 +6112,7 @@
|
|
|
6012
6112
|
timeStamp: now
|
|
6013
6113
|
});
|
|
6014
6114
|
const clickHistory = trackingData.clicksByButton[from.button];
|
|
6015
|
-
clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
|
|
6115
|
+
clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && this._config.supportsTouchEvents && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
|
|
6016
6116
|
}
|
|
6017
6117
|
this.freeEvent(e);
|
|
6018
6118
|
}, this.onPointerUpOutside = (from, target) => {
|
|
@@ -6229,7 +6329,8 @@
|
|
|
6229
6329
|
supportsPointerEvents = global.supportsPointerEvents
|
|
6230
6330
|
} = params;
|
|
6231
6331
|
this.manager = new EventManager(rootNode, {
|
|
6232
|
-
clickInterval: clickInterval
|
|
6332
|
+
clickInterval: clickInterval,
|
|
6333
|
+
supportsTouchEvents: supportsTouchEvents
|
|
6233
6334
|
}), this.globalObj = global, this.supportsPointerEvents = supportsPointerEvents, this.supportsTouchEvents = supportsTouchEvents, this.supportsMouseEvents = global.supportsMouseEvents, this.applyStyles = global.applyStyles, this.autoPreventDefault = autoPreventDefault, this.eventsAdded = !1, this.rootPointerEvent = new FederatedPointerEvent(), this.rootWheelEvent = new FederatedWheelEvent(), this.cursorStyles = {
|
|
6234
6335
|
default: "inherit",
|
|
6235
6336
|
pointer: "pointer"
|
|
@@ -12506,7 +12607,8 @@
|
|
|
12506
12607
|
fill = arcAttribute.fill,
|
|
12507
12608
|
stroke = arcAttribute.stroke,
|
|
12508
12609
|
x: originX = arcAttribute.x,
|
|
12509
|
-
y: originY = arcAttribute.y
|
|
12610
|
+
y: originY = arcAttribute.y,
|
|
12611
|
+
fillStrokeOrder = arcAttribute.fillStrokeOrder
|
|
12510
12612
|
} = arc.attribute,
|
|
12511
12613
|
data = this.valid(arc, arcAttribute, fillCb, strokeCb);
|
|
12512
12614
|
if (!data) return;
|
|
@@ -12542,7 +12644,17 @@
|
|
|
12542
12644
|
isFullStroke: isFullStroke,
|
|
12543
12645
|
stroke: arrayStroke
|
|
12544
12646
|
} = parseStroke(stroke);
|
|
12545
|
-
if (
|
|
12647
|
+
if (doFill || isFullStroke) {
|
|
12648
|
+
context.beginPath(), drawArcPath$1(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
12649
|
+
const _runFill = () => {
|
|
12650
|
+
doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
|
|
12651
|
+
},
|
|
12652
|
+
_runStroke = () => {
|
|
12653
|
+
doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()));
|
|
12654
|
+
};
|
|
12655
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
|
|
12656
|
+
}
|
|
12657
|
+
if (!isFullStroke && doStroke) {
|
|
12546
12658
|
context.beginPath();
|
|
12547
12659
|
drawArcPath$1(arc, context, x, y, outerRadius, innerRadius, arrayStroke);
|
|
12548
12660
|
beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke());
|
|
@@ -12560,14 +12672,20 @@
|
|
|
12560
12672
|
fill = arcAttribute.fill
|
|
12561
12673
|
} = arc.attribute,
|
|
12562
12674
|
startAngle = endAngle;
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
|
|
12566
|
-
|
|
12567
|
-
|
|
12568
|
-
|
|
12569
|
-
|
|
12570
|
-
|
|
12675
|
+
this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
12676
|
+
const _runFill = () => {
|
|
12677
|
+
if (doFill) {
|
|
12678
|
+
const color = fill;
|
|
12679
|
+
if ("conical" === color.gradient) {
|
|
12680
|
+
const lastColor = getConicGradientAt(0, 0, endAngle, color);
|
|
12681
|
+
fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
|
|
12682
|
+
}
|
|
12683
|
+
}
|
|
12684
|
+
},
|
|
12685
|
+
_runStroke = () => {
|
|
12686
|
+
doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
|
|
12687
|
+
};
|
|
12688
|
+
_runFill(), _runStroke();
|
|
12571
12689
|
}
|
|
12572
12690
|
}
|
|
12573
12691
|
this.afterRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), tempChangeConicalColor && (fill.startAngle += conicalOffset, fill.endAngle += conicalOffset);
|
|
@@ -12605,7 +12723,8 @@
|
|
|
12605
12723
|
startAngle = circleAttribute.startAngle,
|
|
12606
12724
|
endAngle = circleAttribute.endAngle,
|
|
12607
12725
|
x: originX = circleAttribute.x,
|
|
12608
|
-
y: originY = circleAttribute.y
|
|
12726
|
+
y: originY = circleAttribute.y,
|
|
12727
|
+
fillStrokeOrder = circleAttribute.fillStrokeOrder
|
|
12609
12728
|
} = circle.attribute,
|
|
12610
12729
|
data = this.valid(circle, circleAttribute, fillCb, strokeCb);
|
|
12611
12730
|
if (!data) return;
|
|
@@ -12615,7 +12734,14 @@
|
|
|
12615
12734
|
doFill: doFill,
|
|
12616
12735
|
doStroke: doStroke
|
|
12617
12736
|
} = data;
|
|
12618
|
-
context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb)
|
|
12737
|
+
context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
12738
|
+
const _runFill = () => {
|
|
12739
|
+
doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill()));
|
|
12740
|
+
},
|
|
12741
|
+
_runStroke = () => {
|
|
12742
|
+
doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke()));
|
|
12743
|
+
};
|
|
12744
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
12619
12745
|
}
|
|
12620
12746
|
draw(circle, renderService, drawContext, params) {
|
|
12621
12747
|
const circleAttribute = getTheme(circle, null == params ? void 0 : params.theme).circle;
|
|
@@ -13056,7 +13182,7 @@
|
|
|
13056
13182
|
super(), this.areaRenderContribitions = areaRenderContribitions, this.numberType = AREA_NUMBER_TYPE, this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution], this.init(areaRenderContribitions);
|
|
13057
13183
|
}
|
|
13058
13184
|
drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
|
|
13059
|
-
var _a, _b, _c
|
|
13185
|
+
var _a, _b, _c;
|
|
13060
13186
|
const {
|
|
13061
13187
|
points: points
|
|
13062
13188
|
} = area.attribute;
|
|
@@ -13080,28 +13206,31 @@
|
|
|
13080
13206
|
x: originX = 0,
|
|
13081
13207
|
x: originY = 0
|
|
13082
13208
|
} = area.attribute;
|
|
13083
|
-
|
|
13209
|
+
!1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
|
|
13084
13210
|
attribute: area.attribute
|
|
13085
|
-
}),
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13211
|
+
}), (() => {
|
|
13212
|
+
var _a, _b;
|
|
13213
|
+
if (stroke) {
|
|
13214
|
+
const {
|
|
13215
|
+
stroke = areaAttribute && areaAttribute.stroke
|
|
13216
|
+
} = area.attribute;
|
|
13217
|
+
if (isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
|
|
13218
|
+
context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
|
|
13219
|
+
for (let i = 1; i < points.length; i++) {
|
|
13220
|
+
const p = points[i];
|
|
13221
|
+
context.lineTo(p.x + offsetX, p.y + offsetY, z);
|
|
13222
|
+
}
|
|
13223
|
+
} else if (stroke[2]) {
|
|
13224
|
+
const endP = points[points.length - 1];
|
|
13225
|
+
context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
|
|
13226
|
+
for (let i = points.length - 2; i >= 0; i--) {
|
|
13227
|
+
const p = points[i];
|
|
13228
|
+
context.lineTo((null !== (_a = p.x1) && void 0 !== _a ? _a : p.x) + offsetX, (null !== (_b = p.y1) && void 0 !== _b ? _b : p.y) + offsetY, z);
|
|
13229
|
+
}
|
|
13101
13230
|
}
|
|
13231
|
+
strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
|
|
13102
13232
|
}
|
|
13103
|
-
|
|
13104
|
-
}
|
|
13233
|
+
})();
|
|
13105
13234
|
}
|
|
13106
13235
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
13107
13236
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -13266,23 +13395,24 @@
|
|
|
13266
13395
|
x: originX = 0,
|
|
13267
13396
|
x: originY = 0
|
|
13268
13397
|
} = attribute;
|
|
13269
|
-
|
|
13398
|
+
return !1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
|
|
13270
13399
|
attribute: attribute
|
|
13271
|
-
}),
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13400
|
+
}), (() => {
|
|
13401
|
+
if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
|
|
13402
|
+
const {
|
|
13403
|
+
stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
|
|
13404
|
+
} = attribute;
|
|
13405
|
+
isArray$1(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === exports.Direction.ROW ? "x" : "y", {
|
|
13406
|
+
offsetX: offsetX,
|
|
13407
|
+
offsetY: offsetY,
|
|
13408
|
+
offsetZ: offsetZ,
|
|
13409
|
+
drawConnect: connect,
|
|
13410
|
+
mode: connectedType,
|
|
13411
|
+
zeroX: connectedX,
|
|
13412
|
+
zeroY: connectedY
|
|
13413
|
+
})), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
|
|
13414
|
+
}
|
|
13415
|
+
})(), !1;
|
|
13286
13416
|
}
|
|
13287
13417
|
};
|
|
13288
13418
|
exports.DefaultCanvasAreaRender = __decorate$1v([injectable(), __param$N(0, inject(ContributionProvider)), __param$N(0, named(AreaRenderContribution)), __metadata$19("design:paramtypes", [Object])], exports.DefaultCanvasAreaRender);
|
|
@@ -13314,7 +13444,8 @@
|
|
|
13314
13444
|
const pathAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(path, null == params ? void 0 : params.theme).path,
|
|
13315
13445
|
{
|
|
13316
13446
|
x: originX = pathAttribute.x,
|
|
13317
|
-
y: originY = pathAttribute.y
|
|
13447
|
+
y: originY = pathAttribute.y,
|
|
13448
|
+
fillStrokeOrder = pathAttribute.fillStrokeOrder
|
|
13318
13449
|
} = path.attribute,
|
|
13319
13450
|
z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
|
|
13320
13451
|
data = this.valid(path, pathAttribute, fillCb, strokeCb);
|
|
@@ -13329,7 +13460,14 @@
|
|
|
13329
13460
|
const path2D = null !== (_c = path.attribute.path) && void 0 !== _c ? _c : pathAttribute.path;
|
|
13330
13461
|
renderCommandList(path2D.commandList, context, x, y, 1, 1, z);
|
|
13331
13462
|
}
|
|
13332
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb)
|
|
13463
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
13464
|
+
const _runStroke = () => {
|
|
13465
|
+
doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke()));
|
|
13466
|
+
},
|
|
13467
|
+
_runFill = () => {
|
|
13468
|
+
doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill()));
|
|
13469
|
+
};
|
|
13470
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
13333
13471
|
}
|
|
13334
13472
|
draw(path, renderService, drawContext, params) {
|
|
13335
13473
|
const pathAttribute = getTheme(path, null == params ? void 0 : params.theme).path;
|
|
@@ -13373,7 +13511,8 @@
|
|
|
13373
13511
|
x1: x1,
|
|
13374
13512
|
y1: y1,
|
|
13375
13513
|
x: originX = rectAttribute.x,
|
|
13376
|
-
y: originY = rectAttribute.y
|
|
13514
|
+
y: originY = rectAttribute.y,
|
|
13515
|
+
fillStrokeOrder = rectAttribute.fillStrokeOrder
|
|
13377
13516
|
} = rect.attribute;
|
|
13378
13517
|
let {
|
|
13379
13518
|
width: width,
|
|
@@ -13392,7 +13531,14 @@
|
|
|
13392
13531
|
doFill: doFill,
|
|
13393
13532
|
doStroke: doStroke
|
|
13394
13533
|
};
|
|
13395
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke)
|
|
13534
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
|
|
13535
|
+
const _runFill = () => {
|
|
13536
|
+
doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill()));
|
|
13537
|
+
},
|
|
13538
|
+
_runStroke = () => {
|
|
13539
|
+
doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke()));
|
|
13540
|
+
};
|
|
13541
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
13396
13542
|
}
|
|
13397
13543
|
draw(rect, renderService, drawContext, params) {
|
|
13398
13544
|
const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
|
|
@@ -13428,7 +13574,8 @@
|
|
|
13428
13574
|
x: originX = symbolAttribute.x,
|
|
13429
13575
|
y: originY = symbolAttribute.y,
|
|
13430
13576
|
scaleX = symbolAttribute.scaleX,
|
|
13431
|
-
scaleY = symbolAttribute.scaleY
|
|
13577
|
+
scaleY = symbolAttribute.scaleY,
|
|
13578
|
+
fillStrokeOrder = symbolAttribute.fillStrokeOrder
|
|
13432
13579
|
} = symbol.attribute,
|
|
13433
13580
|
data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
|
|
13434
13581
|
if (!data) return;
|
|
@@ -13451,14 +13598,27 @@
|
|
|
13451
13598
|
const obj = Object.assign({}, a);
|
|
13452
13599
|
obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill, obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity, obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke, a = obj;
|
|
13453
13600
|
}
|
|
13454
|
-
|
|
13601
|
+
const _runFill = () => {
|
|
13602
|
+
a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill()));
|
|
13603
|
+
},
|
|
13604
|
+
_runStroke = () => {
|
|
13605
|
+
a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
|
|
13606
|
+
};
|
|
13607
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
|
|
13455
13608
|
};
|
|
13456
13609
|
if (keepDirIn3d && context.camera && context.project) {
|
|
13457
13610
|
const p = context.project(x, y, z),
|
|
13458
13611
|
camera = context.camera;
|
|
13459
13612
|
context.camera = null, !1 === parsedPath.draw(context, isArray$1(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(), context.camera = camera;
|
|
13460
13613
|
} else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
|
|
13461
|
-
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb)
|
|
13614
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
13615
|
+
const _runFill = () => {
|
|
13616
|
+
doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill()));
|
|
13617
|
+
},
|
|
13618
|
+
_runStroke = () => {
|
|
13619
|
+
doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
|
|
13620
|
+
};
|
|
13621
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
13462
13622
|
}
|
|
13463
13623
|
draw(symbol, renderService, drawContext, params) {
|
|
13464
13624
|
const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
|
|
@@ -13636,77 +13796,50 @@
|
|
|
13636
13796
|
}
|
|
13637
13797
|
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
13638
13798
|
};
|
|
13639
|
-
if (text.
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
width: line.width
|
|
13654
|
-
});
|
|
13655
|
-
})));
|
|
13656
|
-
} else {
|
|
13657
|
-
text.tryUpdateAABBBounds();
|
|
13658
|
-
const cache = text.cache,
|
|
13659
|
-
{
|
|
13660
|
-
verticalList: verticalList
|
|
13661
|
-
} = cache;
|
|
13662
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
13663
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
13664
|
-
let totalW = 0;
|
|
13665
|
-
verticalList.forEach(verticalData => {
|
|
13666
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13667
|
-
totalW = max(_w, totalW);
|
|
13668
|
-
});
|
|
13669
|
-
let offsetY = 0,
|
|
13670
|
-
offsetX = 0;
|
|
13671
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13672
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13673
|
-
dw = totalW - currentW;
|
|
13674
|
-
let currentOffsetY = offsetY;
|
|
13675
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13676
|
-
const {
|
|
13677
|
-
text: text,
|
|
13678
|
-
width: width,
|
|
13679
|
-
direction: direction
|
|
13680
|
-
} = item;
|
|
13681
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13682
|
-
});
|
|
13799
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
13800
|
+
const {
|
|
13801
|
+
multilineLayout: multilineLayout
|
|
13802
|
+
} = text;
|
|
13803
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
13804
|
+
const {
|
|
13805
|
+
xOffset: xOffset,
|
|
13806
|
+
yOffset: yOffset
|
|
13807
|
+
} = multilineLayout.bbox;
|
|
13808
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13809
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
13810
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13811
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
|
|
13812
|
+
width: line.width
|
|
13683
13813
|
});
|
|
13684
|
-
}
|
|
13685
|
-
} else if ("horizontal" === direction) {
|
|
13686
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
13687
|
-
const t = text.clipedText;
|
|
13688
|
-
let dy = 0;
|
|
13689
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
13814
|
+
})));
|
|
13690
13815
|
} else {
|
|
13691
13816
|
text.tryUpdateAABBBounds();
|
|
13692
|
-
const cache = text.cache
|
|
13693
|
-
|
|
13694
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
13695
|
-
const {
|
|
13817
|
+
const cache = text.cache,
|
|
13818
|
+
{
|
|
13696
13819
|
verticalList: verticalList
|
|
13697
13820
|
} = cache;
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13821
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
13822
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
13823
|
+
let totalW = 0;
|
|
13824
|
+
verticalList.forEach(verticalData => {
|
|
13825
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13826
|
+
totalW = max(_w, totalW);
|
|
13827
|
+
});
|
|
13828
|
+
let offsetY = 0,
|
|
13829
|
+
offsetX = 0;
|
|
13830
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13831
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13832
|
+
dw = totalW - currentW;
|
|
13833
|
+
let currentOffsetY = offsetY;
|
|
13834
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13702
13835
|
const {
|
|
13703
13836
|
text: text,
|
|
13704
13837
|
width: width,
|
|
13705
13838
|
direction: direction
|
|
13706
13839
|
} = item;
|
|
13707
|
-
drawText(text, offsetX,
|
|
13840
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13708
13841
|
});
|
|
13709
|
-
}
|
|
13842
|
+
});
|
|
13710
13843
|
}
|
|
13711
13844
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
13712
13845
|
}
|
|
@@ -13845,7 +13978,8 @@
|
|
|
13845
13978
|
cornerRadius = polygonAttribute.cornerRadius,
|
|
13846
13979
|
x: originX = polygonAttribute.x,
|
|
13847
13980
|
y: originY = polygonAttribute.y,
|
|
13848
|
-
closePath = polygonAttribute.closePath
|
|
13981
|
+
closePath = polygonAttribute.closePath,
|
|
13982
|
+
fillStrokeOrder = polygonAttribute.fillStrokeOrder
|
|
13849
13983
|
} = polygon.attribute,
|
|
13850
13984
|
data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
|
|
13851
13985
|
if (!data) return;
|
|
@@ -13855,7 +13989,14 @@
|
|
|
13855
13989
|
doFill: doFill,
|
|
13856
13990
|
doStroke: doStroke
|
|
13857
13991
|
} = data;
|
|
13858
|
-
context.beginPath(), cornerRadius <= 0 || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb)
|
|
13992
|
+
context.beginPath(), cornerRadius <= 0 || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
13993
|
+
const _runFill = () => {
|
|
13994
|
+
doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill()));
|
|
13995
|
+
},
|
|
13996
|
+
_runStroke = () => {
|
|
13997
|
+
doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke()));
|
|
13998
|
+
};
|
|
13999
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
13859
14000
|
}
|
|
13860
14001
|
draw(polygon, renderService, drawContext, params) {
|
|
13861
14002
|
const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon;
|
|
@@ -13898,7 +14039,10 @@
|
|
|
13898
14039
|
cornerRadius = groupAttribute.cornerRadius,
|
|
13899
14040
|
path = groupAttribute.path,
|
|
13900
14041
|
lineWidth = groupAttribute.lineWidth,
|
|
13901
|
-
visible = groupAttribute.visible
|
|
14042
|
+
visible = groupAttribute.visible,
|
|
14043
|
+
fillStrokeOrder = groupAttribute.fillStrokeOrder,
|
|
14044
|
+
x: originX = groupAttribute.x,
|
|
14045
|
+
y: originY = groupAttribute.y
|
|
13902
14046
|
} = group.attribute,
|
|
13903
14047
|
fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
|
|
13904
14048
|
sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
|
|
@@ -13924,7 +14068,14 @@
|
|
|
13924
14068
|
};
|
|
13925
14069
|
this._groupRenderContribitions.forEach(c => {
|
|
13926
14070
|
c.time === exports.BaseRenderContributionTime.beforeFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
|
|
13927
|
-
}), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute)
|
|
14071
|
+
}), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
|
|
14072
|
+
const _runFill = () => {
|
|
14073
|
+
doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.fill()));
|
|
14074
|
+
},
|
|
14075
|
+
_runStroke = () => {
|
|
14076
|
+
doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.stroke()));
|
|
14077
|
+
};
|
|
14078
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this._groupRenderContribitions.forEach(c => {
|
|
13928
14079
|
c.time === exports.BaseRenderContributionTime.afterFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb);
|
|
13929
14080
|
});
|
|
13930
14081
|
}
|
|
@@ -13990,6 +14141,7 @@
|
|
|
13990
14141
|
x: originX = imageAttribute.x,
|
|
13991
14142
|
y: originY = imageAttribute.y,
|
|
13992
14143
|
cornerRadius = imageAttribute.cornerRadius,
|
|
14144
|
+
fillStrokeOrder = imageAttribute.fillStrokeOrder,
|
|
13993
14145
|
image: url
|
|
13994
14146
|
} = image.attribute,
|
|
13995
14147
|
data = this.valid(image, imageAttribute, fillCb);
|
|
@@ -14000,20 +14152,26 @@
|
|
|
14000
14152
|
doFill: doFill,
|
|
14001
14153
|
doStroke: doStroke
|
|
14002
14154
|
} = data;
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14155
|
+
context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
|
|
14156
|
+
const _runFill = () => {
|
|
14157
|
+
if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
|
|
14158
|
+
if (!url || !image.resources) return;
|
|
14159
|
+
const res = image.resources.get(url);
|
|
14160
|
+
if ("success" !== res.state) return;
|
|
14161
|
+
let needRestore = !1;
|
|
14162
|
+
0 === cornerRadius || isArray$1(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
14163
|
+
let repeat = 0;
|
|
14164
|
+
if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
|
|
14165
|
+
const pattern = context.createPattern(res.data, repeatStr[repeat]);
|
|
14166
|
+
context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
|
|
14167
|
+
} else context.drawImage(res.data, x, y, width, height);
|
|
14168
|
+
needRestore && context.restore();
|
|
14169
|
+
}
|
|
14170
|
+
},
|
|
14171
|
+
_runStroke = () => {
|
|
14172
|
+
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
|
|
14173
|
+
};
|
|
14174
|
+
fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
|
|
14017
14175
|
}
|
|
14018
14176
|
draw(image, renderService, drawContext) {
|
|
14019
14177
|
const {
|
|
@@ -14414,28 +14572,6 @@
|
|
|
14414
14572
|
}
|
|
14415
14573
|
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
14416
14574
|
}
|
|
14417
|
-
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
14418
|
-
const linesLayout = [],
|
|
14419
|
-
bboxWH = [width, height],
|
|
14420
|
-
bboxOffset = [0, 0];
|
|
14421
|
-
for (; str.length > 0;) {
|
|
14422
|
-
const {
|
|
14423
|
-
str: clipText
|
|
14424
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
14425
|
-
linesLayout.push({
|
|
14426
|
-
str: clipText,
|
|
14427
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
14428
|
-
}), str = str.substring(clipText.length);
|
|
14429
|
-
}
|
|
14430
|
-
"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]));
|
|
14431
|
-
const bbox = {
|
|
14432
|
-
xOffset: bboxOffset[0],
|
|
14433
|
-
yOffset: bboxOffset[1],
|
|
14434
|
-
width: bboxWH[0],
|
|
14435
|
-
height: bboxWH[1]
|
|
14436
|
-
};
|
|
14437
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14438
|
-
}
|
|
14439
14575
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
14440
14576
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
14441
14577
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
@@ -14446,18 +14582,29 @@
|
|
|
14446
14582
|
bboxWH = [0, 0];
|
|
14447
14583
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
14448
14584
|
let width;
|
|
14449
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
14450
|
-
|
|
14451
|
-
width
|
|
14452
|
-
|
|
14585
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14586
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
14587
|
+
width = Math.min(metrics.width, lineWidth), linesLayout.push({
|
|
14588
|
+
str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
14589
|
+
width: width,
|
|
14590
|
+
ascent: metrics.ascent,
|
|
14591
|
+
descent: metrics.descent
|
|
14592
|
+
});
|
|
14593
|
+
}
|
|
14453
14594
|
bboxWH[0] = lineWidth;
|
|
14454
14595
|
} else {
|
|
14455
14596
|
let width, text;
|
|
14456
14597
|
lineWidth = 0;
|
|
14457
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14598
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14599
|
+
text = lines[i];
|
|
14600
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
14601
|
+
width = metrics.width, lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
14602
|
+
str: text,
|
|
14603
|
+
width: width,
|
|
14604
|
+
ascent: metrics.ascent,
|
|
14605
|
+
descent: metrics.descent
|
|
14606
|
+
});
|
|
14607
|
+
}
|
|
14461
14608
|
bboxWH[0] = lineWidth;
|
|
14462
14609
|
}
|
|
14463
14610
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
@@ -14486,11 +14633,11 @@
|
|
|
14486
14633
|
};
|
|
14487
14634
|
}
|
|
14488
14635
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
14489
|
-
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 =
|
|
14636
|
+
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;
|
|
14490
14637
|
}
|
|
14491
14638
|
}
|
|
14492
14639
|
|
|
14493
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14640
|
+
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];
|
|
14494
14641
|
class Text extends Graphic {
|
|
14495
14642
|
get font() {
|
|
14496
14643
|
const textTheme = this.getGraphicTheme();
|
|
@@ -14499,26 +14646,22 @@
|
|
|
14499
14646
|
get clipedText() {
|
|
14500
14647
|
var _a;
|
|
14501
14648
|
const attribute = this.attribute,
|
|
14502
|
-
textTheme = this.getGraphicTheme()
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
14506
|
-
} = attribute;
|
|
14507
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14649
|
+
textTheme = this.getGraphicTheme(),
|
|
14650
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
14651
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14508
14652
|
}
|
|
14509
14653
|
get clipedWidth() {
|
|
14510
|
-
|
|
14654
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14511
14655
|
}
|
|
14512
14656
|
get cliped() {
|
|
14513
14657
|
var _a, _b;
|
|
14514
14658
|
const textTheme = this.getGraphicTheme(),
|
|
14515
14659
|
attribute = this.attribute,
|
|
14516
|
-
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
14660
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
14661
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
14662
|
+
const {
|
|
14663
|
+
text: text
|
|
14664
|
+
} = this.attribute;
|
|
14522
14665
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
14523
14666
|
let mergedText = "";
|
|
14524
14667
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -14529,10 +14672,7 @@
|
|
|
14529
14672
|
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();
|
|
14530
14673
|
}
|
|
14531
14674
|
get multilineLayout() {
|
|
14532
|
-
|
|
14533
|
-
}
|
|
14534
|
-
isSimplify() {
|
|
14535
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
14675
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14536
14676
|
}
|
|
14537
14677
|
get isMultiLine() {
|
|
14538
14678
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -14605,8 +14745,63 @@
|
|
|
14605
14745
|
}
|
|
14606
14746
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
14607
14747
|
}
|
|
14748
|
+
updateSingallineAABBBounds(text) {
|
|
14749
|
+
this.updateMultilineAABBBounds([text]);
|
|
14750
|
+
const layoutData = this.cache.layoutData;
|
|
14751
|
+
if (layoutData) {
|
|
14752
|
+
const line = layoutData.lines[0];
|
|
14753
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
14754
|
+
}
|
|
14755
|
+
return this._AABBBounds;
|
|
14756
|
+
}
|
|
14757
|
+
updateMultilineAABBBounds(text) {
|
|
14758
|
+
const textTheme = this.getGraphicTheme(),
|
|
14759
|
+
{
|
|
14760
|
+
direction = textTheme.direction,
|
|
14761
|
+
underlineOffset = textTheme.underlineOffset
|
|
14762
|
+
} = this.attribute,
|
|
14763
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14764
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14765
|
+
}
|
|
14766
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
14767
|
+
var _a;
|
|
14768
|
+
const textTheme = this.getGraphicTheme(),
|
|
14769
|
+
attribute = this.attribute,
|
|
14770
|
+
{
|
|
14771
|
+
fontFamily = textTheme.fontFamily,
|
|
14772
|
+
textAlign = textTheme.textAlign,
|
|
14773
|
+
textBaseline = textTheme.textBaseline,
|
|
14774
|
+
fontSize = textTheme.fontSize,
|
|
14775
|
+
fontWeight = textTheme.fontWeight,
|
|
14776
|
+
ellipsis = textTheme.ellipsis,
|
|
14777
|
+
maxLineWidth: maxLineWidth,
|
|
14778
|
+
stroke = textTheme.stroke,
|
|
14779
|
+
wrap = textTheme.wrap,
|
|
14780
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
14781
|
+
lineWidth = textTheme.lineWidth,
|
|
14782
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14783
|
+
suffixPosition = textTheme.suffixPosition
|
|
14784
|
+
} = attribute,
|
|
14785
|
+
buf = ignoreBuf ? 0 : 2,
|
|
14786
|
+
lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
14787
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
14788
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
14789
|
+
const bbox = this.cache.layoutData.bbox;
|
|
14790
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14791
|
+
}
|
|
14792
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
14793
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14794
|
+
fontSize: fontSize,
|
|
14795
|
+
fontWeight: fontWeight,
|
|
14796
|
+
fontFamily: fontFamily
|
|
14797
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
14798
|
+
{
|
|
14799
|
+
bbox: bbox
|
|
14800
|
+
} = layoutData;
|
|
14801
|
+
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;
|
|
14802
|
+
}
|
|
14608
14803
|
updateWrapAABBBounds(text) {
|
|
14609
|
-
var _a, _b, _c
|
|
14804
|
+
var _a, _b, _c;
|
|
14610
14805
|
const textTheme = this.getGraphicTheme(),
|
|
14611
14806
|
{
|
|
14612
14807
|
fontFamily = textTheme.fontFamily,
|
|
@@ -14624,18 +14819,19 @@
|
|
|
14624
14819
|
heightLimit = 0,
|
|
14625
14820
|
lineClamp: lineClamp
|
|
14626
14821
|
} = this.attribute,
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
14822
|
+
buf = ignoreBuf ? 0 : 2,
|
|
14823
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
|
|
14824
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
14630
14825
|
const bbox = this.cache.layoutData.bbox;
|
|
14631
14826
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14632
14827
|
}
|
|
14633
14828
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
14634
|
-
|
|
14829
|
+
textOptions = {
|
|
14635
14830
|
fontSize: fontSize,
|
|
14636
14831
|
fontWeight: fontWeight,
|
|
14637
14832
|
fontFamily: fontFamily
|
|
14638
|
-
},
|
|
14833
|
+
},
|
|
14834
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
14639
14835
|
lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
14640
14836
|
linesLayout = [],
|
|
14641
14837
|
bboxWH = [0, 0];
|
|
@@ -14645,29 +14841,33 @@
|
|
|
14645
14841
|
const str = lines[i];
|
|
14646
14842
|
let needCut = !0;
|
|
14647
14843
|
if (i === lineCountLimit - 1) {
|
|
14648
|
-
const clip =
|
|
14844
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
14845
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
14649
14846
|
linesLayout.push({
|
|
14650
14847
|
str: clip.str,
|
|
14651
|
-
width: clip.width
|
|
14848
|
+
width: clip.width,
|
|
14849
|
+
ascent: matrics.ascent,
|
|
14850
|
+
descent: matrics.descent
|
|
14652
14851
|
});
|
|
14653
14852
|
break;
|
|
14654
14853
|
}
|
|
14655
|
-
const clip =
|
|
14656
|
-
if ("" !== str && "" === clip.str
|
|
14854
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-word" === wordBreak);
|
|
14855
|
+
if ("" !== str && "" === clip.str) {
|
|
14657
14856
|
if (ellipsis) {
|
|
14658
|
-
const clipEllipsis =
|
|
14659
|
-
clip.str = null !== (
|
|
14857
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14858
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
14660
14859
|
} else clip.str = "", clip.width = 0;
|
|
14661
14860
|
needCut = !1;
|
|
14662
14861
|
}
|
|
14663
|
-
|
|
14862
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
14863
|
+
if (linesLayout.push({
|
|
14664
14864
|
str: clip.str,
|
|
14665
|
-
width: clip.width
|
|
14666
|
-
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14865
|
+
width: clip.width,
|
|
14866
|
+
ascent: matrics.ascent,
|
|
14867
|
+
descent: matrics.descent
|
|
14868
|
+
}), clip.str.length === str.length) ;else if (needCut) {
|
|
14869
|
+
const newStr = str.substring(clip.str.length);
|
|
14870
|
+
lines.splice(i + 1, 0, newStr);
|
|
14671
14871
|
}
|
|
14672
14872
|
}
|
|
14673
14873
|
let maxWidth = 0;
|
|
@@ -14680,21 +14880,28 @@
|
|
|
14680
14880
|
lineWidth = 0;
|
|
14681
14881
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14682
14882
|
if (i === lineCountLimit - 1) {
|
|
14683
|
-
const clip =
|
|
14883
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
14884
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
14684
14885
|
linesLayout.push({
|
|
14685
14886
|
str: clip.str,
|
|
14686
|
-
width: clip.width
|
|
14887
|
+
width: clip.width,
|
|
14888
|
+
ascent: matrics.ascent,
|
|
14889
|
+
descent: matrics.descent
|
|
14687
14890
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
14688
14891
|
break;
|
|
14689
14892
|
}
|
|
14690
|
-
text = lines[i], width =
|
|
14893
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
14894
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
14895
|
+
linesLayout.push({
|
|
14691
14896
|
str: text,
|
|
14692
|
-
width: width
|
|
14897
|
+
width: width,
|
|
14898
|
+
ascent: matrics.ascent,
|
|
14899
|
+
descent: matrics.descent
|
|
14693
14900
|
});
|
|
14694
14901
|
}
|
|
14695
14902
|
bboxWH[0] = lineWidth;
|
|
14696
14903
|
}
|
|
14697
|
-
bboxWH[1] = linesLayout.length *
|
|
14904
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
14698
14905
|
const bbox = {
|
|
14699
14906
|
xOffset: 0,
|
|
14700
14907
|
yOffset: 0,
|
|
@@ -14705,210 +14912,12 @@
|
|
|
14705
14912
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14706
14913
|
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;
|
|
14707
14914
|
}
|
|
14708
|
-
updateSingallineAABBBounds(text) {
|
|
14709
|
-
const textTheme = this.getGraphicTheme(),
|
|
14710
|
-
{
|
|
14711
|
-
direction = textTheme.direction,
|
|
14712
|
-
underlineOffset = textTheme.underlineOffset
|
|
14713
|
-
} = this.attribute,
|
|
14714
|
-
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
14715
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14716
|
-
}
|
|
14717
|
-
updateMultilineAABBBounds(text) {
|
|
14718
|
-
const textTheme = this.getGraphicTheme(),
|
|
14719
|
-
{
|
|
14720
|
-
direction = textTheme.direction,
|
|
14721
|
-
underlineOffset = textTheme.underlineOffset
|
|
14722
|
-
} = this.attribute,
|
|
14723
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14724
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14725
|
-
}
|
|
14726
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
14727
|
-
var _a, _b;
|
|
14728
|
-
const textTheme = this.getGraphicTheme(),
|
|
14729
|
-
{
|
|
14730
|
-
wrap = textTheme.wrap
|
|
14731
|
-
} = this.attribute;
|
|
14732
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
14733
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
14734
|
-
let width, str;
|
|
14735
|
-
const attribute = this.attribute,
|
|
14736
|
-
{
|
|
14737
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
14738
|
-
ellipsis = textTheme.ellipsis,
|
|
14739
|
-
textAlign = textTheme.textAlign,
|
|
14740
|
-
textBaseline = textTheme.textBaseline,
|
|
14741
|
-
fontFamily = textTheme.fontFamily,
|
|
14742
|
-
fontSize = textTheme.fontSize,
|
|
14743
|
-
fontWeight = textTheme.fontWeight,
|
|
14744
|
-
stroke = textTheme.stroke,
|
|
14745
|
-
lineWidth = textTheme.lineWidth,
|
|
14746
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
14747
|
-
whiteSpace = textTheme.whiteSpace,
|
|
14748
|
-
suffixPosition = textTheme.suffixPosition
|
|
14749
|
-
} = attribute;
|
|
14750
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14751
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
14752
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
14753
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
14754
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
14755
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
14756
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14757
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14758
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14759
|
-
}
|
|
14760
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
14761
|
-
if (ellipsis) {
|
|
14762
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14763
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
14764
|
-
fontSize: fontSize,
|
|
14765
|
-
fontWeight: fontWeight,
|
|
14766
|
-
fontFamily: fontFamily
|
|
14767
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14768
|
-
str = data.str, width = data.width;
|
|
14769
|
-
} else {
|
|
14770
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
14771
|
-
fontSize: fontSize,
|
|
14772
|
-
fontWeight: fontWeight,
|
|
14773
|
-
fontFamily: fontFamily
|
|
14774
|
-
}, maxLineWidth, !1);
|
|
14775
|
-
str = data.str, width = data.width;
|
|
14776
|
-
}
|
|
14777
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
14778
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
14779
|
-
fontSize: fontSize,
|
|
14780
|
-
fontWeight: fontWeight,
|
|
14781
|
-
fontFamily: fontFamily
|
|
14782
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
14783
|
-
this.clearUpdateShapeTag();
|
|
14784
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
14785
|
-
let lh = lineHeight;
|
|
14786
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
14787
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
14788
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14789
|
-
}
|
|
14790
|
-
getBaselineMapAlign() {
|
|
14791
|
-
return Text.baselineMapAlign;
|
|
14792
|
-
}
|
|
14793
|
-
getAlignMapBaseline() {
|
|
14794
|
-
return Text.alignMapBaseline;
|
|
14795
|
-
}
|
|
14796
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
14797
|
-
var _a, _b, _c;
|
|
14798
|
-
const textTheme = this.getGraphicTheme(),
|
|
14799
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
14800
|
-
let width;
|
|
14801
|
-
const attribute = this.attribute,
|
|
14802
|
-
{
|
|
14803
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
14804
|
-
} = attribute,
|
|
14805
|
-
buf = ignoreBuf ? 0 : 2,
|
|
14806
|
-
{
|
|
14807
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
14808
|
-
ellipsis = textTheme.ellipsis,
|
|
14809
|
-
fontSize = textTheme.fontSize,
|
|
14810
|
-
fontWeight = textTheme.fontWeight,
|
|
14811
|
-
fontFamily = textTheme.fontFamily,
|
|
14812
|
-
stroke = textTheme.stroke,
|
|
14813
|
-
lineWidth = textTheme.lineWidth,
|
|
14814
|
-
verticalMode = textTheme.verticalMode,
|
|
14815
|
-
suffixPosition = textTheme.suffixPosition
|
|
14816
|
-
} = attribute,
|
|
14817
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14818
|
-
let {
|
|
14819
|
-
textAlign = textTheme.textAlign,
|
|
14820
|
-
textBaseline = textTheme.textBaseline
|
|
14821
|
-
} = attribute;
|
|
14822
|
-
if (!verticalMode) {
|
|
14823
|
-
const t = textAlign;
|
|
14824
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
14825
|
-
}
|
|
14826
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
14827
|
-
width = this.cache.clipedWidth;
|
|
14828
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14829
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14830
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14831
|
-
}
|
|
14832
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
14833
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
14834
|
-
if (ellipsis) {
|
|
14835
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14836
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
14837
|
-
fontSize: fontSize,
|
|
14838
|
-
fontWeight: fontWeight,
|
|
14839
|
-
fontFamily: fontFamily
|
|
14840
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14841
|
-
verticalList = [data.verticalList], width = data.width;
|
|
14842
|
-
} else {
|
|
14843
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
14844
|
-
fontSize: fontSize,
|
|
14845
|
-
fontWeight: fontWeight,
|
|
14846
|
-
fontFamily: fontFamily
|
|
14847
|
-
}, maxLineWidth, !1);
|
|
14848
|
-
verticalList = [data.verticalList], width = data.width;
|
|
14849
|
-
}
|
|
14850
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14851
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
14852
|
-
const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
14853
|
-
fontSize: fontSize,
|
|
14854
|
-
fontWeight: fontWeight,
|
|
14855
|
-
fontFamily: fontFamily
|
|
14856
|
-
});
|
|
14857
|
-
width += w, t.width = w;
|
|
14858
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14859
|
-
this.clearUpdateShapeTag();
|
|
14860
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14861
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14862
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14863
|
-
}
|
|
14864
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
14865
|
-
var _a, _b;
|
|
14866
|
-
const textTheme = this.getGraphicTheme(),
|
|
14867
|
-
{
|
|
14868
|
-
wrap = textTheme.wrap
|
|
14869
|
-
} = this.attribute;
|
|
14870
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
14871
|
-
const attribute = this.attribute,
|
|
14872
|
-
{
|
|
14873
|
-
fontFamily = textTheme.fontFamily,
|
|
14874
|
-
textAlign = textTheme.textAlign,
|
|
14875
|
-
textBaseline = textTheme.textBaseline,
|
|
14876
|
-
fontSize = textTheme.fontSize,
|
|
14877
|
-
fontWeight = textTheme.fontWeight,
|
|
14878
|
-
ellipsis = textTheme.ellipsis,
|
|
14879
|
-
maxLineWidth: maxLineWidth,
|
|
14880
|
-
stroke = textTheme.stroke,
|
|
14881
|
-
lineWidth = textTheme.lineWidth,
|
|
14882
|
-
whiteSpace = textTheme.whiteSpace,
|
|
14883
|
-
suffixPosition = textTheme.suffixPosition
|
|
14884
|
-
} = attribute,
|
|
14885
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
14886
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14887
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
14888
|
-
const bbox = this.cache.layoutData.bbox;
|
|
14889
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14890
|
-
}
|
|
14891
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
14892
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14893
|
-
fontSize: fontSize,
|
|
14894
|
-
fontWeight: fontWeight,
|
|
14895
|
-
fontFamily: fontFamily
|
|
14896
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
14897
|
-
{
|
|
14898
|
-
bbox: bbox
|
|
14899
|
-
} = layoutData;
|
|
14900
|
-
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;
|
|
14901
|
-
}
|
|
14902
14915
|
updateVerticalMultilineAABBBounds(text) {
|
|
14903
|
-
var _a, _b
|
|
14916
|
+
var _a, _b;
|
|
14904
14917
|
const textTheme = this.getGraphicTheme(),
|
|
14905
14918
|
textMeasure = application.graphicUtil.textMeasure;
|
|
14906
14919
|
let width;
|
|
14907
14920
|
const attribute = this.attribute,
|
|
14908
|
-
{
|
|
14909
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
14910
|
-
} = attribute,
|
|
14911
|
-
buf = ignoreBuf ? 0 : 2,
|
|
14912
14921
|
{
|
|
14913
14922
|
maxLineWidth = textTheme.maxLineWidth,
|
|
14914
14923
|
ellipsis = textTheme.ellipsis,
|
|
@@ -14920,14 +14929,14 @@
|
|
|
14920
14929
|
verticalMode = textTheme.verticalMode,
|
|
14921
14930
|
suffixPosition = textTheme.suffixPosition
|
|
14922
14931
|
} = attribute,
|
|
14923
|
-
lineHeight =
|
|
14932
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
14924
14933
|
let {
|
|
14925
14934
|
textAlign = textTheme.textAlign,
|
|
14926
14935
|
textBaseline = textTheme.textBaseline
|
|
14927
14936
|
} = attribute;
|
|
14928
14937
|
if (!verticalMode) {
|
|
14929
14938
|
const t = textAlign;
|
|
14930
|
-
textAlign = null !== (
|
|
14939
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
14931
14940
|
}
|
|
14932
14941
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
14933
14942
|
this.cache.verticalList.forEach(item => {
|
|
@@ -14975,6 +14984,15 @@
|
|
|
14975
14984
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
14976
14985
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14977
14986
|
}
|
|
14987
|
+
getMaxWidth(theme) {
|
|
14988
|
+
var _a, _b;
|
|
14989
|
+
const attribute = this.attribute;
|
|
14990
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
14991
|
+
}
|
|
14992
|
+
getLineHeight(attribute, textTheme) {
|
|
14993
|
+
var _a;
|
|
14994
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
14995
|
+
}
|
|
14978
14996
|
needUpdateTags(keys) {
|
|
14979
14997
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
14980
14998
|
return super.needUpdateTags(keys, k);
|
|
@@ -14989,6 +15007,12 @@
|
|
|
14989
15007
|
getNoWorkAnimateAttr() {
|
|
14990
15008
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
14991
15009
|
}
|
|
15010
|
+
getBaselineMapAlign() {
|
|
15011
|
+
return Text.baselineMapAlign;
|
|
15012
|
+
}
|
|
15013
|
+
getAlignMapBaseline() {
|
|
15014
|
+
return Text.alignMapBaseline;
|
|
15015
|
+
}
|
|
14992
15016
|
}
|
|
14993
15017
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14994
15018
|
ellipsis: 1,
|
|
@@ -15067,7 +15091,9 @@
|
|
|
15067
15091
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15068
15092
|
linesLayout.push({
|
|
15069
15093
|
str: clip.str,
|
|
15070
|
-
width: clip.width
|
|
15094
|
+
width: clip.width,
|
|
15095
|
+
ascent: 0,
|
|
15096
|
+
descent: 0
|
|
15071
15097
|
});
|
|
15072
15098
|
break;
|
|
15073
15099
|
}
|
|
@@ -15081,7 +15107,9 @@
|
|
|
15081
15107
|
}
|
|
15082
15108
|
if (linesLayout.push({
|
|
15083
15109
|
str: clip.str,
|
|
15084
|
-
width: clip.width
|
|
15110
|
+
width: clip.width,
|
|
15111
|
+
ascent: 0,
|
|
15112
|
+
descent: 0
|
|
15085
15113
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
15086
15114
|
const newStr = str.substring(clip.str.length);
|
|
15087
15115
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -15100,13 +15128,17 @@
|
|
|
15100
15128
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15101
15129
|
linesLayout.push({
|
|
15102
15130
|
str: clip.str,
|
|
15103
|
-
width: clip.width
|
|
15131
|
+
width: clip.width,
|
|
15132
|
+
ascent: 0,
|
|
15133
|
+
descent: 0
|
|
15104
15134
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
15105
15135
|
break;
|
|
15106
15136
|
}
|
|
15107
15137
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
15108
15138
|
str: text,
|
|
15109
|
-
width: width
|
|
15139
|
+
width: width,
|
|
15140
|
+
ascent: 0,
|
|
15141
|
+
descent: 0
|
|
15110
15142
|
});
|
|
15111
15143
|
}
|
|
15112
15144
|
bboxWH[0] = lineWidth;
|
|
@@ -18278,6 +18310,42 @@
|
|
|
18278
18310
|
}
|
|
18279
18311
|
}
|
|
18280
18312
|
|
|
18313
|
+
class AutoRefreshPlugin {
|
|
18314
|
+
constructor() {
|
|
18315
|
+
this.name = "AutoRefreshPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handleChange = graphic => {
|
|
18316
|
+
graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
|
|
18317
|
+
};
|
|
18318
|
+
}
|
|
18319
|
+
activate(context) {
|
|
18320
|
+
this.pluginService = context, this.dpr = application.global.devicePixelRatio, this.refresh();
|
|
18321
|
+
}
|
|
18322
|
+
refresh() {
|
|
18323
|
+
this._refreshByMediaQuery() || this._refreshByRaf();
|
|
18324
|
+
}
|
|
18325
|
+
_refreshByRaf() {
|
|
18326
|
+
const raf = application.global.getRequestAnimationFrame();
|
|
18327
|
+
this.rafId = raf(() => {
|
|
18328
|
+
application.global.devicePixelRatio !== this.dpr && (this.dpr = application.global.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0)), this.refresh();
|
|
18329
|
+
});
|
|
18330
|
+
}
|
|
18331
|
+
_refreshByMediaQuery() {
|
|
18332
|
+
try {
|
|
18333
|
+
const mqString = `(resolution: ${window.devicePixelRatio}dppx)`,
|
|
18334
|
+
updatePixelRatio = () => {
|
|
18335
|
+
window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
|
|
18336
|
+
};
|
|
18337
|
+
matchMedia(mqString).addEventListener("change", updatePixelRatio);
|
|
18338
|
+
} catch (err) {
|
|
18339
|
+
return !1;
|
|
18340
|
+
}
|
|
18341
|
+
return !0;
|
|
18342
|
+
}
|
|
18343
|
+
deactivate(context) {
|
|
18344
|
+
const craf = application.global.getCancelAnimationFrame();
|
|
18345
|
+
craf && this.rafId && craf(this.rafId);
|
|
18346
|
+
}
|
|
18347
|
+
}
|
|
18348
|
+
|
|
18281
18349
|
class IncrementalAutoRenderPlugin {
|
|
18282
18350
|
constructor() {
|
|
18283
18351
|
this.name = "IncrementalAutoRenderPlugin", this.activeEvent = "onRegister", this.nextFrameRenderGroupSet = new Set(), this.willNextFrameRender = !1, this.nextUserParams = {}, this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid;
|
|
@@ -18480,7 +18548,7 @@
|
|
|
18480
18548
|
canvas: params.canvas
|
|
18481
18549
|
}), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig$1.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
|
|
18482
18550
|
main: !0
|
|
18483
|
-
})), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this.ticker = params.ticker || defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer, this.timeline = new DefaultTimeline(), this.ticker.addTimeline(this.timeline), this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
|
|
18551
|
+
})), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this.ticker = params.ticker || defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer, this.timeline = new DefaultTimeline(), this.ticker.addTimeline(this.timeline), this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
|
|
18484
18552
|
background: this._background
|
|
18485
18553
|
});
|
|
18486
18554
|
}
|
|
@@ -18615,6 +18683,14 @@
|
|
|
18615
18683
|
this.pluginService.unRegister(plugin);
|
|
18616
18684
|
}));
|
|
18617
18685
|
}
|
|
18686
|
+
enableAutoRefresh() {
|
|
18687
|
+
this.autoRefresh || (this.autoRefresh = !0, this.pluginService.register(new AutoRefreshPlugin()));
|
|
18688
|
+
}
|
|
18689
|
+
disableAutoRefresh() {
|
|
18690
|
+
this.autoRefresh && (this.autoRefresh = !1, this.pluginService.findPluginsByName("AutoRefreshPlugin").forEach(plugin => {
|
|
18691
|
+
this.pluginService.unRegister(plugin);
|
|
18692
|
+
}));
|
|
18693
|
+
}
|
|
18618
18694
|
enableIncrementalAutoRender() {
|
|
18619
18695
|
this.increaseAutoRender || (this.increaseAutoRender = !0, this.pluginService.register(new IncrementalAutoRenderPlugin()));
|
|
18620
18696
|
}
|
|
@@ -19621,27 +19697,9 @@
|
|
|
19621
19697
|
for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
|
|
19622
19698
|
return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
|
|
19623
19699
|
}
|
|
19624
|
-
function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
|
|
19625
|
-
let maxSqDist = sqTolerance,
|
|
19626
|
-
nextIdx = startIdx;
|
|
19627
|
-
const startX = points[startIdx].x,
|
|
19628
|
-
startY = points[startIdx].y,
|
|
19629
|
-
vecX2 = points[endIdx].x - startX,
|
|
19630
|
-
vecY2 = points[endIdx].y - startY,
|
|
19631
|
-
sqLength = vecX2 * vecX2 + vecY2 * vecY2;
|
|
19632
|
-
let area, sqArea, sqDistance, vecX1, vecY1;
|
|
19633
|
-
for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
|
|
19634
|
-
maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
|
|
19635
|
-
}
|
|
19636
|
-
function simplifyDouglasPeucker(points, sqTolerance) {
|
|
19637
|
-
const lastIdx = points.length - 1,
|
|
19638
|
-
simplified = [points[0]];
|
|
19639
|
-
return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
|
|
19640
|
-
}
|
|
19641
19700
|
function flatten_simplify(points, tolerance, highestQuality) {
|
|
19642
19701
|
if (points.length <= 10) return points;
|
|
19643
|
-
|
|
19644
|
-
return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
|
|
19702
|
+
return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
|
|
19645
19703
|
}
|
|
19646
19704
|
|
|
19647
19705
|
function findCursorIndexIgnoreLinebreak(textConfig, cursorIndex) {
|
|
@@ -23678,7 +23736,7 @@
|
|
|
23678
23736
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23679
23737
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23680
23738
|
super(), this.cachedEvents = [], this.startPoints = [], this.processEvent = {}, this.throttleTimer = 0, this.emitThrottles = [], this.lastTapTarget = null, this.onStart = ev => {
|
|
23681
|
-
this.reset(), this.startTime = clock.now();
|
|
23739
|
+
this.cachedEvents = [], this.startPoints = [], this.reset(), this.startTime = clock.now();
|
|
23682
23740
|
const {
|
|
23683
23741
|
cachedEvents: cachedEvents,
|
|
23684
23742
|
startPoints: startPoints
|
|
@@ -23698,7 +23756,7 @@
|
|
|
23698
23756
|
if (1 !== startPoints.length) this.startDistance = calcDistance(startPoints[0], startPoints[1]), this.center = getCenter([startPoints[0], startPoints[1]]);else {
|
|
23699
23757
|
const event = cachedEvents[0];
|
|
23700
23758
|
this.pressTimeout = setTimeout(() => {
|
|
23701
|
-
event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none";
|
|
23759
|
+
event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none", this.pressTimeout = null;
|
|
23702
23760
|
}, this.config.press.time);
|
|
23703
23761
|
}
|
|
23704
23762
|
}, this.onMove = ev => {
|
|
@@ -23761,10 +23819,10 @@
|
|
|
23761
23819
|
lastMovePoint = this.lastMovePoint || startPoints[0],
|
|
23762
23820
|
distance = calcDistance(prevMovePoint, lastMovePoint),
|
|
23763
23821
|
velocity = distance / intervalTime;
|
|
23764
|
-
velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold
|
|
23822
|
+
if (velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold) return endEvent.velocity = velocity, endEvent.direction = calcDirection(prevMovePoint, lastMovePoint), this.triggerEvent("swipe", endEvent), this.cachedEvents = [], this.startPoints = [], void this.reset();
|
|
23765
23823
|
}
|
|
23766
23824
|
}
|
|
23767
|
-
now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0);
|
|
23825
|
+
now - this.startTime < this.config.press.time && (now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0));
|
|
23768
23826
|
}
|
|
23769
23827
|
for (let i = 0, len = cachedEvents.length; i < len; i++) if (cachedEvents[i].pointerId === endEvent.pointerId) {
|
|
23770
23828
|
cachedEvents.splice(i, 1), startPoints.splice(i, 1);
|
|
@@ -23840,6 +23898,7 @@
|
|
|
23840
23898
|
emitThrottles: emitThrottles
|
|
23841
23899
|
} = this;
|
|
23842
23900
|
throttleTimer || (this.throttleTimer = application.global.getRequestAnimationFrame()(() => {
|
|
23901
|
+
application.global.getCancelAnimationFrame()(this.throttleTimer), this.throttleTimer = null;
|
|
23843
23902
|
for (let i = 0, len = emitThrottles.length; i < len; i++) {
|
|
23844
23903
|
const {
|
|
23845
23904
|
type: type,
|
|
@@ -23847,7 +23906,7 @@
|
|
|
23847
23906
|
} = emitThrottles[i];
|
|
23848
23907
|
this.emitEvent(type, ev);
|
|
23849
23908
|
}
|
|
23850
|
-
this.
|
|
23909
|
+
this.emitThrottles.length = 0;
|
|
23851
23910
|
}));
|
|
23852
23911
|
}
|
|
23853
23912
|
triggerStartEvent(type, ev) {
|
|
@@ -28140,10 +28199,8 @@
|
|
|
28140
28199
|
} = text.attribute,
|
|
28141
28200
|
bounds = text.AABBBounds,
|
|
28142
28201
|
height = bounds.height(),
|
|
28143
|
-
width = bounds.width()
|
|
28144
|
-
|
|
28145
|
-
offsetX = textDrawOffsetX(textAlign, width);
|
|
28146
|
-
return context.rect(offsetX + x, offsetY + y, width, height, z), picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked;
|
|
28202
|
+
width = bounds.width();
|
|
28203
|
+
return context.rect(bounds.x1, bounds.y1, width, height, z), picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked;
|
|
28147
28204
|
}, (context, symbolAttribute, themeAttribute) => picked), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28148
28205
|
}
|
|
28149
28206
|
};
|
|
@@ -28483,7 +28540,7 @@
|
|
|
28483
28540
|
|
|
28484
28541
|
const roughModule = _roughModule;
|
|
28485
28542
|
|
|
28486
|
-
const version = "0.21.0-alpha.
|
|
28543
|
+
const version = "0.21.0-alpha.3";
|
|
28487
28544
|
preLoadAllModule();
|
|
28488
28545
|
if (isBrowserEnv()) {
|
|
28489
28546
|
loadBrowserEnv(container);
|