@visactor/vrender 0.21.0-alpha.3 → 0.21.0-beta.0
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 +10 -11
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +482 -379
- package/dist/index.js +482 -379
- 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 +5 -5
package/dist/index.js
CHANGED
|
@@ -3919,7 +3919,6 @@
|
|
|
3919
3919
|
const DefaultTextStyle = {
|
|
3920
3920
|
text: "",
|
|
3921
3921
|
maxLineWidth: 1 / 0,
|
|
3922
|
-
maxWidth: 1 / 0,
|
|
3923
3922
|
textAlign: "left",
|
|
3924
3923
|
textBaseline: "alphabetic",
|
|
3925
3924
|
fontSize: 16,
|
|
@@ -3997,7 +3996,8 @@
|
|
|
3997
3996
|
globalZIndex: 1,
|
|
3998
3997
|
globalCompositeOperation: "",
|
|
3999
3998
|
overflow: "hidden",
|
|
4000
|
-
shadowPickMode: "graphic"
|
|
3999
|
+
shadowPickMode: "graphic",
|
|
4000
|
+
keepStrokeScale: !1
|
|
4001
4001
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
4002
4002
|
function addAttributeToPrototype(obj, c, keys) {
|
|
4003
4003
|
keys.forEach(key => {
|
|
@@ -4272,32 +4272,10 @@
|
|
|
4272
4272
|
configure(service, env) {
|
|
4273
4273
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4274
4274
|
}
|
|
4275
|
-
|
|
4275
|
+
measureTextWidth(text, options) {
|
|
4276
|
+
if (!this.context) return this.estimate(text, options).width;
|
|
4276
4277
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4277
|
-
|
|
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;
|
|
4278
|
+
return this.context.measureText(text).width;
|
|
4301
4279
|
}
|
|
4302
4280
|
estimate(text, _ref) {
|
|
4303
4281
|
let {
|
|
@@ -4311,85 +4289,19 @@
|
|
|
4311
4289
|
height: fontSize
|
|
4312
4290
|
};
|
|
4313
4291
|
}
|
|
4314
|
-
|
|
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) {
|
|
4292
|
+
measureTextPixelHeight(text, options) {
|
|
4327
4293
|
var _a;
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
return
|
|
4332
|
-
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
4333
|
-
descent: textMeasure.actualBoundingBoxDescent
|
|
4334
|
-
} : this.measureTextBoundADscentEstimate(options);
|
|
4335
|
-
}
|
|
4336
|
-
measureTextBoundHieght(text, options, textMeasure) {
|
|
4337
|
-
var _a;
|
|
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
|
-
};
|
|
4294
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4295
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4296
|
+
const textMeasure = this.context.measureText(text);
|
|
4297
|
+
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
4365
4298
|
}
|
|
4366
|
-
|
|
4299
|
+
measureTextBoundHieght(text, options) {
|
|
4367
4300
|
var _a;
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
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
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4302
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4303
|
+
const textMeasure = this.context.measureText(text);
|
|
4304
|
+
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
4393
4305
|
}
|
|
4394
4306
|
measureText(text, options) {
|
|
4395
4307
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -6501,7 +6413,7 @@
|
|
|
6501
6413
|
}
|
|
6502
6414
|
}
|
|
6503
6415
|
|
|
6504
|
-
class DefaultTicker {
|
|
6416
|
+
class DefaultTicker extends EventEmitter {
|
|
6505
6417
|
set mode(m) {
|
|
6506
6418
|
this._mode !== m && (this._mode = m, this.setupTickHandler());
|
|
6507
6419
|
}
|
|
@@ -6510,17 +6422,17 @@
|
|
|
6510
6422
|
}
|
|
6511
6423
|
constructor() {
|
|
6512
6424
|
let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6513
|
-
this.handleTick = (handler, params) => {
|
|
6425
|
+
super(), this.handleTick = (handler, params) => {
|
|
6514
6426
|
const {
|
|
6515
6427
|
once = !1
|
|
6516
6428
|
} = null != params ? params : {};
|
|
6517
|
-
this.ifCanStop() ? this.stop() : (this._handlerTick(
|
|
6518
|
-
}, this._handlerTick =
|
|
6429
|
+
this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
|
|
6430
|
+
}, this._handlerTick = () => {
|
|
6519
6431
|
const time = this.tickerHandler.getTime();
|
|
6520
6432
|
let delta = 0;
|
|
6521
6433
|
this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
|
|
6522
6434
|
t.tick(delta);
|
|
6523
|
-
}));
|
|
6435
|
+
}), this.emit("afterTick"));
|
|
6524
6436
|
}, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
|
|
6525
6437
|
}
|
|
6526
6438
|
init() {
|
|
@@ -6616,6 +6528,9 @@
|
|
|
6616
6528
|
stop() {
|
|
6617
6529
|
this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
|
|
6618
6530
|
}
|
|
6531
|
+
trySyncTickStatus() {
|
|
6532
|
+
this.status === STATUS$1.RUNNING && this._handlerTick();
|
|
6533
|
+
}
|
|
6619
6534
|
}
|
|
6620
6535
|
|
|
6621
6536
|
class ManualTickHandler {
|
|
@@ -7757,7 +7672,7 @@
|
|
|
7757
7672
|
lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
7758
7673
|
break;
|
|
7759
7674
|
}
|
|
7760
|
-
"clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
|
|
7675
|
+
"clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], 1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]), isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
|
|
7761
7676
|
let prevMatchedPoint = this.toPoints[0];
|
|
7762
7677
|
this.interpolatePoints = this.toPoints.map((point, index) => {
|
|
7763
7678
|
const matchedPoint = tagMap.get(point.context);
|
|
@@ -7769,11 +7684,19 @@
|
|
|
7769
7684
|
return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
|
|
7770
7685
|
});
|
|
7771
7686
|
}
|
|
7687
|
+
onFirstRun() {
|
|
7688
|
+
const lastClipRange = this.target.attribute.clipRange;
|
|
7689
|
+
isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
|
|
7690
|
+
}
|
|
7772
7691
|
onUpdate(end, ratio, out) {
|
|
7773
7692
|
if (this.points = this.points.map((point, index) => {
|
|
7774
7693
|
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
7775
7694
|
return newPoint.context = point.context, newPoint;
|
|
7776
|
-
}), this.clipRange
|
|
7695
|
+
}), this.clipRange) {
|
|
7696
|
+
if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints, out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
|
|
7697
|
+
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
7698
|
+
}
|
|
7699
|
+
if (this.segmentsCache && this.to.segments) {
|
|
7777
7700
|
let start = 0;
|
|
7778
7701
|
out.segments = this.to.segments.map((segment, index) => {
|
|
7779
7702
|
const end = start + this.segmentsCache[index],
|
|
@@ -12127,7 +12050,8 @@
|
|
|
12127
12050
|
x: originX = arcAttribute.x,
|
|
12128
12051
|
y: originY = arcAttribute.y,
|
|
12129
12052
|
scaleX = arcAttribute.scaleX,
|
|
12130
|
-
scaleY = arcAttribute.scaleY
|
|
12053
|
+
scaleY = arcAttribute.scaleY,
|
|
12054
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
12131
12055
|
} = arc.attribute;
|
|
12132
12056
|
let {
|
|
12133
12057
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -12139,7 +12063,7 @@
|
|
|
12139
12063
|
{
|
|
12140
12064
|
distance = arcAttribute[key].distance
|
|
12141
12065
|
} = borderStyle,
|
|
12142
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12066
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12143
12067
|
deltaAngle = distance / outerRadius,
|
|
12144
12068
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12145
12069
|
if (arc.setAttributes({
|
|
@@ -12184,14 +12108,15 @@
|
|
|
12184
12108
|
x: originX = circleAttribute.x,
|
|
12185
12109
|
y: originY = circleAttribute.y,
|
|
12186
12110
|
scaleX = circleAttribute.scaleX,
|
|
12187
|
-
scaleY = circleAttribute.scaleY
|
|
12111
|
+
scaleY = circleAttribute.scaleY,
|
|
12112
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
12188
12113
|
} = circle.attribute,
|
|
12189
12114
|
renderBorder = (borderStyle, key) => {
|
|
12190
12115
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12191
12116
|
{
|
|
12192
12117
|
distance = circleAttribute[key].distance
|
|
12193
12118
|
} = borderStyle,
|
|
12194
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12119
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12195
12120
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12196
12121
|
if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
|
|
12197
12122
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -12310,7 +12235,8 @@
|
|
|
12310
12235
|
scaleX = rectAttribute.scaleX,
|
|
12311
12236
|
scaleY = rectAttribute.scaleY,
|
|
12312
12237
|
x1: x1,
|
|
12313
|
-
y1: y1
|
|
12238
|
+
y1: y1,
|
|
12239
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
12314
12240
|
} = rect.attribute;
|
|
12315
12241
|
let {
|
|
12316
12242
|
width: width,
|
|
@@ -12323,7 +12249,7 @@
|
|
|
12323
12249
|
{
|
|
12324
12250
|
distance = rectAttribute[key].distance
|
|
12325
12251
|
} = borderStyle,
|
|
12326
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12252
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12327
12253
|
nextX = x + sign * d,
|
|
12328
12254
|
nextY = y + sign * d,
|
|
12329
12255
|
dw = 2 * d;
|
|
@@ -12480,14 +12406,15 @@
|
|
|
12480
12406
|
x: originX = symbolAttribute.x,
|
|
12481
12407
|
y: originY = symbolAttribute.y,
|
|
12482
12408
|
scaleX = symbolAttribute.scaleX,
|
|
12483
|
-
scaleY = symbolAttribute.scaleY
|
|
12409
|
+
scaleY = symbolAttribute.scaleY,
|
|
12410
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
12484
12411
|
} = symbol.attribute,
|
|
12485
12412
|
renderBorder = (borderStyle, key) => {
|
|
12486
12413
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12487
12414
|
{
|
|
12488
12415
|
distance = symbolAttribute[key].distance
|
|
12489
12416
|
} = borderStyle,
|
|
12490
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
12417
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
12491
12418
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12492
12419
|
if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
|
|
12493
12420
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -13796,50 +13723,77 @@
|
|
|
13796
13723
|
}
|
|
13797
13724
|
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());
|
|
13798
13725
|
};
|
|
13799
|
-
if (
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
context
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13726
|
+
if (text.isMultiLine) {
|
|
13727
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
13728
|
+
const {
|
|
13729
|
+
multilineLayout: multilineLayout
|
|
13730
|
+
} = text;
|
|
13731
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
13732
|
+
const {
|
|
13733
|
+
xOffset: xOffset,
|
|
13734
|
+
yOffset: yOffset
|
|
13735
|
+
} = multilineLayout.bbox;
|
|
13736
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13737
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
13738
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13739
|
+
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, {
|
|
13740
|
+
width: line.width
|
|
13741
|
+
});
|
|
13742
|
+
})));
|
|
13743
|
+
} else {
|
|
13744
|
+
text.tryUpdateAABBBounds();
|
|
13745
|
+
const cache = text.cache,
|
|
13746
|
+
{
|
|
13747
|
+
verticalList: verticalList
|
|
13748
|
+
} = cache;
|
|
13749
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
13750
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
13751
|
+
let totalW = 0;
|
|
13752
|
+
verticalList.forEach(verticalData => {
|
|
13753
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13754
|
+
totalW = max(_w, totalW);
|
|
13813
13755
|
});
|
|
13814
|
-
|
|
13756
|
+
let offsetY = 0,
|
|
13757
|
+
offsetX = 0;
|
|
13758
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13759
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13760
|
+
dw = totalW - currentW;
|
|
13761
|
+
let currentOffsetY = offsetY;
|
|
13762
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13763
|
+
const {
|
|
13764
|
+
text: text,
|
|
13765
|
+
width: width,
|
|
13766
|
+
direction: direction
|
|
13767
|
+
} = item;
|
|
13768
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13769
|
+
});
|
|
13770
|
+
});
|
|
13771
|
+
}
|
|
13772
|
+
} else if ("horizontal" === direction) {
|
|
13773
|
+
context.setTextStyle(text.attribute, textAttribute, z);
|
|
13774
|
+
const t = text.clipedText;
|
|
13775
|
+
let dy = 0;
|
|
13776
|
+
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
13815
13777
|
} else {
|
|
13816
13778
|
text.tryUpdateAABBBounds();
|
|
13817
|
-
const cache = text.cache
|
|
13818
|
-
|
|
13779
|
+
const cache = text.cache;
|
|
13780
|
+
if (cache) {
|
|
13781
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
13782
|
+
const {
|
|
13819
13783
|
verticalList: verticalList
|
|
13820
13784
|
} = cache;
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
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 => {
|
|
13785
|
+
let offsetY = 0;
|
|
13786
|
+
const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
|
|
13787
|
+
let offsetX = 0;
|
|
13788
|
+
"bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
|
|
13835
13789
|
const {
|
|
13836
13790
|
text: text,
|
|
13837
13791
|
width: width,
|
|
13838
13792
|
direction: direction
|
|
13839
13793
|
} = item;
|
|
13840
|
-
drawText(text,
|
|
13794
|
+
drawText(text, offsetX, offsetY, direction), offsetY += width;
|
|
13841
13795
|
});
|
|
13842
|
-
}
|
|
13796
|
+
}
|
|
13843
13797
|
}
|
|
13844
13798
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
13845
13799
|
}
|
|
@@ -14572,6 +14526,28 @@
|
|
|
14572
14526
|
}
|
|
14573
14527
|
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
14574
14528
|
}
|
|
14529
|
+
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
14530
|
+
const linesLayout = [],
|
|
14531
|
+
bboxWH = [width, height],
|
|
14532
|
+
bboxOffset = [0, 0];
|
|
14533
|
+
for (; str.length > 0;) {
|
|
14534
|
+
const {
|
|
14535
|
+
str: clipText
|
|
14536
|
+
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
14537
|
+
linesLayout.push({
|
|
14538
|
+
str: clipText,
|
|
14539
|
+
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
14540
|
+
}), str = str.substring(clipText.length);
|
|
14541
|
+
}
|
|
14542
|
+
"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]));
|
|
14543
|
+
const bbox = {
|
|
14544
|
+
xOffset: bboxOffset[0],
|
|
14545
|
+
yOffset: bboxOffset[1],
|
|
14546
|
+
width: bboxWH[0],
|
|
14547
|
+
height: bboxWH[1]
|
|
14548
|
+
};
|
|
14549
|
+
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14550
|
+
}
|
|
14575
14551
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
14576
14552
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
14577
14553
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
@@ -14582,29 +14558,18 @@
|
|
|
14582
14558
|
bboxWH = [0, 0];
|
|
14583
14559
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
14584
14560
|
let width;
|
|
14585
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14586
|
-
|
|
14587
|
-
width
|
|
14588
|
-
|
|
14589
|
-
width: width,
|
|
14590
|
-
ascent: metrics.ascent,
|
|
14591
|
-
descent: metrics.descent
|
|
14592
|
-
});
|
|
14593
|
-
}
|
|
14561
|
+
for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
|
|
14562
|
+
str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
14563
|
+
width: width
|
|
14564
|
+
});
|
|
14594
14565
|
bboxWH[0] = lineWidth;
|
|
14595
14566
|
} else {
|
|
14596
14567
|
let width, text;
|
|
14597
14568
|
lineWidth = 0;
|
|
14598
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14599
|
-
text
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
str: text,
|
|
14603
|
-
width: width,
|
|
14604
|
-
ascent: metrics.ascent,
|
|
14605
|
-
descent: metrics.descent
|
|
14606
|
-
});
|
|
14607
|
-
}
|
|
14569
|
+
for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
14570
|
+
str: text,
|
|
14571
|
+
width: width
|
|
14572
|
+
});
|
|
14608
14573
|
bboxWH[0] = lineWidth;
|
|
14609
14574
|
}
|
|
14610
14575
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
@@ -14633,11 +14598,11 @@
|
|
|
14633
14598
|
};
|
|
14634
14599
|
}
|
|
14635
14600
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
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 +
|
|
14601
|
+
return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
|
|
14637
14602
|
}
|
|
14638
14603
|
}
|
|
14639
14604
|
|
|
14640
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "
|
|
14605
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14641
14606
|
class Text extends Graphic {
|
|
14642
14607
|
get font() {
|
|
14643
14608
|
const textTheme = this.getGraphicTheme();
|
|
@@ -14646,22 +14611,26 @@
|
|
|
14646
14611
|
get clipedText() {
|
|
14647
14612
|
var _a;
|
|
14648
14613
|
const attribute = this.attribute,
|
|
14649
|
-
textTheme = this.getGraphicTheme()
|
|
14650
|
-
|
|
14651
|
-
|
|
14614
|
+
textTheme = this.getGraphicTheme();
|
|
14615
|
+
if (!this.isSimplify()) return;
|
|
14616
|
+
const {
|
|
14617
|
+
maxLineWidth = textTheme.maxLineWidth
|
|
14618
|
+
} = attribute;
|
|
14619
|
+
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14652
14620
|
}
|
|
14653
14621
|
get clipedWidth() {
|
|
14654
|
-
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14622
|
+
if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14655
14623
|
}
|
|
14656
14624
|
get cliped() {
|
|
14657
14625
|
var _a, _b;
|
|
14658
14626
|
const textTheme = this.getGraphicTheme(),
|
|
14659
14627
|
attribute = this.attribute,
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14628
|
+
{
|
|
14629
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14630
|
+
text: text,
|
|
14631
|
+
whiteSpace = textTheme.whiteSpace
|
|
14632
|
+
} = attribute;
|
|
14633
|
+
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
14665
14634
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
14666
14635
|
let mergedText = "";
|
|
14667
14636
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -14672,7 +14641,10 @@
|
|
|
14672
14641
|
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();
|
|
14673
14642
|
}
|
|
14674
14643
|
get multilineLayout() {
|
|
14675
|
-
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14644
|
+
if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14645
|
+
}
|
|
14646
|
+
isSimplify() {
|
|
14647
|
+
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
14676
14648
|
}
|
|
14677
14649
|
get isMultiLine() {
|
|
14678
14650
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -14745,63 +14717,8 @@
|
|
|
14745
14717
|
}
|
|
14746
14718
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
14747
14719
|
}
|
|
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
|
-
}
|
|
14803
14720
|
updateWrapAABBBounds(text) {
|
|
14804
|
-
var _a, _b, _c;
|
|
14721
|
+
var _a, _b, _c, _d;
|
|
14805
14722
|
const textTheme = this.getGraphicTheme(),
|
|
14806
14723
|
{
|
|
14807
14724
|
fontFamily = textTheme.fontFamily,
|
|
@@ -14819,19 +14736,18 @@
|
|
|
14819
14736
|
heightLimit = 0,
|
|
14820
14737
|
lineClamp: lineClamp
|
|
14821
14738
|
} = this.attribute,
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
14739
|
+
lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
|
|
14740
|
+
buf = ignoreBuf ? 0 : 2;
|
|
14741
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
14825
14742
|
const bbox = this.cache.layoutData.bbox;
|
|
14826
14743
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14827
14744
|
}
|
|
14828
14745
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
14829
|
-
|
|
14746
|
+
layoutObj = new CanvasTextLayout(fontFamily, {
|
|
14830
14747
|
fontSize: fontSize,
|
|
14831
14748
|
fontWeight: fontWeight,
|
|
14832
14749
|
fontFamily: fontFamily
|
|
14833
|
-
},
|
|
14834
|
-
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
14750
|
+
}, textMeasure),
|
|
14835
14751
|
lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
14836
14752
|
linesLayout = [],
|
|
14837
14753
|
bboxWH = [0, 0];
|
|
@@ -14841,33 +14757,29 @@
|
|
|
14841
14757
|
const str = lines[i];
|
|
14842
14758
|
let needCut = !0;
|
|
14843
14759
|
if (i === lineCountLimit - 1) {
|
|
14844
|
-
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1)
|
|
14845
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
14760
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
|
|
14846
14761
|
linesLayout.push({
|
|
14847
14762
|
str: clip.str,
|
|
14848
|
-
width: clip.width
|
|
14849
|
-
ascent: matrics.ascent,
|
|
14850
|
-
descent: matrics.descent
|
|
14763
|
+
width: clip.width
|
|
14851
14764
|
});
|
|
14852
14765
|
break;
|
|
14853
14766
|
}
|
|
14854
|
-
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-
|
|
14855
|
-
if ("" !== str && "" === clip.str) {
|
|
14767
|
+
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
14768
|
+
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
14856
14769
|
if (ellipsis) {
|
|
14857
|
-
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14858
|
-
clip.str = null !== (
|
|
14770
|
+
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14771
|
+
clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
|
|
14859
14772
|
} else clip.str = "", clip.width = 0;
|
|
14860
14773
|
needCut = !1;
|
|
14861
14774
|
}
|
|
14862
|
-
|
|
14863
|
-
if (linesLayout.push({
|
|
14775
|
+
linesLayout.push({
|
|
14864
14776
|
str: clip.str,
|
|
14865
|
-
width: clip.width
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
lines.splice(i + 1, 0, newStr);
|
|
14777
|
+
width: clip.width
|
|
14778
|
+
});
|
|
14779
|
+
let cutLength = clip.str.length;
|
|
14780
|
+
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
14781
|
+
let newStr = str.substring(cutLength);
|
|
14782
|
+
"keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
|
|
14871
14783
|
}
|
|
14872
14784
|
}
|
|
14873
14785
|
let maxWidth = 0;
|
|
@@ -14880,28 +14792,21 @@
|
|
|
14880
14792
|
lineWidth = 0;
|
|
14881
14793
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14882
14794
|
if (i === lineCountLimit - 1) {
|
|
14883
|
-
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition)
|
|
14884
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
14795
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14885
14796
|
linesLayout.push({
|
|
14886
14797
|
str: clip.str,
|
|
14887
|
-
width: clip.width
|
|
14888
|
-
ascent: matrics.ascent,
|
|
14889
|
-
descent: matrics.descent
|
|
14798
|
+
width: clip.width
|
|
14890
14799
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
14891
14800
|
break;
|
|
14892
14801
|
}
|
|
14893
|
-
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width)
|
|
14894
|
-
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
14895
|
-
linesLayout.push({
|
|
14802
|
+
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
14896
14803
|
str: text,
|
|
14897
|
-
width: width
|
|
14898
|
-
ascent: matrics.ascent,
|
|
14899
|
-
descent: matrics.descent
|
|
14804
|
+
width: width
|
|
14900
14805
|
});
|
|
14901
14806
|
}
|
|
14902
14807
|
bboxWH[0] = lineWidth;
|
|
14903
14808
|
}
|
|
14904
|
-
bboxWH[1] = linesLayout.length * lineHeight;
|
|
14809
|
+
bboxWH[1] = linesLayout.length * (lineHeight + buf);
|
|
14905
14810
|
const bbox = {
|
|
14906
14811
|
xOffset: 0,
|
|
14907
14812
|
yOffset: 0,
|
|
@@ -14912,12 +14817,210 @@
|
|
|
14912
14817
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14913
14818
|
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;
|
|
14914
14819
|
}
|
|
14915
|
-
|
|
14820
|
+
updateSingallineAABBBounds(text) {
|
|
14821
|
+
const textTheme = this.getGraphicTheme(),
|
|
14822
|
+
{
|
|
14823
|
+
direction = textTheme.direction,
|
|
14824
|
+
underlineOffset = textTheme.underlineOffset
|
|
14825
|
+
} = this.attribute,
|
|
14826
|
+
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
14827
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14828
|
+
}
|
|
14829
|
+
updateMultilineAABBBounds(text) {
|
|
14830
|
+
const textTheme = this.getGraphicTheme(),
|
|
14831
|
+
{
|
|
14832
|
+
direction = textTheme.direction,
|
|
14833
|
+
underlineOffset = textTheme.underlineOffset
|
|
14834
|
+
} = this.attribute,
|
|
14835
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14836
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14837
|
+
}
|
|
14838
|
+
updateHorizontalSinglelineAABBBounds(text) {
|
|
14916
14839
|
var _a, _b;
|
|
14840
|
+
const textTheme = this.getGraphicTheme(),
|
|
14841
|
+
{
|
|
14842
|
+
wrap = textTheme.wrap
|
|
14843
|
+
} = this.attribute;
|
|
14844
|
+
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
14845
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
14846
|
+
let width, str;
|
|
14847
|
+
const attribute = this.attribute,
|
|
14848
|
+
{
|
|
14849
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14850
|
+
ellipsis = textTheme.ellipsis,
|
|
14851
|
+
textAlign = textTheme.textAlign,
|
|
14852
|
+
textBaseline = textTheme.textBaseline,
|
|
14853
|
+
fontFamily = textTheme.fontFamily,
|
|
14854
|
+
fontSize = textTheme.fontSize,
|
|
14855
|
+
fontWeight = textTheme.fontWeight,
|
|
14856
|
+
stroke = textTheme.stroke,
|
|
14857
|
+
lineWidth = textTheme.lineWidth,
|
|
14858
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
14859
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14860
|
+
suffixPosition = textTheme.suffixPosition
|
|
14861
|
+
} = attribute;
|
|
14862
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14863
|
+
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
14864
|
+
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
14865
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
14866
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
14867
|
+
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
14868
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14869
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14870
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14871
|
+
}
|
|
14872
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
14873
|
+
if (ellipsis) {
|
|
14874
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14875
|
+
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
14876
|
+
fontSize: fontSize,
|
|
14877
|
+
fontWeight: fontWeight,
|
|
14878
|
+
fontFamily: fontFamily
|
|
14879
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14880
|
+
str = data.str, width = data.width;
|
|
14881
|
+
} else {
|
|
14882
|
+
const data = textMeasure.clipText(text.toString(), {
|
|
14883
|
+
fontSize: fontSize,
|
|
14884
|
+
fontWeight: fontWeight,
|
|
14885
|
+
fontFamily: fontFamily
|
|
14886
|
+
}, maxLineWidth, !1);
|
|
14887
|
+
str = data.str, width = data.width;
|
|
14888
|
+
}
|
|
14889
|
+
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
14890
|
+
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
14891
|
+
fontSize: fontSize,
|
|
14892
|
+
fontWeight: fontWeight,
|
|
14893
|
+
fontFamily: fontFamily
|
|
14894
|
+
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
14895
|
+
this.clearUpdateShapeTag();
|
|
14896
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
14897
|
+
let lh = lineHeight;
|
|
14898
|
+
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
14899
|
+
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
14900
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14901
|
+
}
|
|
14902
|
+
getBaselineMapAlign() {
|
|
14903
|
+
return Text.baselineMapAlign;
|
|
14904
|
+
}
|
|
14905
|
+
getAlignMapBaseline() {
|
|
14906
|
+
return Text.alignMapBaseline;
|
|
14907
|
+
}
|
|
14908
|
+
updateVerticalSinglelineAABBBounds(text) {
|
|
14909
|
+
var _a, _b, _c;
|
|
14917
14910
|
const textTheme = this.getGraphicTheme(),
|
|
14918
14911
|
textMeasure = application.graphicUtil.textMeasure;
|
|
14919
14912
|
let width;
|
|
14920
14913
|
const attribute = this.attribute,
|
|
14914
|
+
{
|
|
14915
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
14916
|
+
} = attribute,
|
|
14917
|
+
buf = ignoreBuf ? 0 : 2,
|
|
14918
|
+
{
|
|
14919
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14920
|
+
ellipsis = textTheme.ellipsis,
|
|
14921
|
+
fontSize = textTheme.fontSize,
|
|
14922
|
+
fontWeight = textTheme.fontWeight,
|
|
14923
|
+
fontFamily = textTheme.fontFamily,
|
|
14924
|
+
stroke = textTheme.stroke,
|
|
14925
|
+
lineWidth = textTheme.lineWidth,
|
|
14926
|
+
verticalMode = textTheme.verticalMode,
|
|
14927
|
+
suffixPosition = textTheme.suffixPosition
|
|
14928
|
+
} = attribute,
|
|
14929
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14930
|
+
let {
|
|
14931
|
+
textAlign = textTheme.textAlign,
|
|
14932
|
+
textBaseline = textTheme.textBaseline
|
|
14933
|
+
} = attribute;
|
|
14934
|
+
if (!verticalMode) {
|
|
14935
|
+
const t = textAlign;
|
|
14936
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
14937
|
+
}
|
|
14938
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
14939
|
+
width = this.cache.clipedWidth;
|
|
14940
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14941
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14942
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14943
|
+
}
|
|
14944
|
+
let verticalList = [verticalLayout(text.toString())];
|
|
14945
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
14946
|
+
if (ellipsis) {
|
|
14947
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14948
|
+
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
14949
|
+
fontSize: fontSize,
|
|
14950
|
+
fontWeight: fontWeight,
|
|
14951
|
+
fontFamily: fontFamily
|
|
14952
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14953
|
+
verticalList = [data.verticalList], width = data.width;
|
|
14954
|
+
} else {
|
|
14955
|
+
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
14956
|
+
fontSize: fontSize,
|
|
14957
|
+
fontWeight: fontWeight,
|
|
14958
|
+
fontFamily: fontFamily
|
|
14959
|
+
}, maxLineWidth, !1);
|
|
14960
|
+
verticalList = [data.verticalList], width = data.width;
|
|
14961
|
+
}
|
|
14962
|
+
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14963
|
+
} else width = 0, verticalList[0].forEach(t => {
|
|
14964
|
+
const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
14965
|
+
fontSize: fontSize,
|
|
14966
|
+
fontWeight: fontWeight,
|
|
14967
|
+
fontFamily: fontFamily
|
|
14968
|
+
});
|
|
14969
|
+
width += w, t.width = w;
|
|
14970
|
+
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14971
|
+
this.clearUpdateShapeTag();
|
|
14972
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14973
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14974
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14975
|
+
}
|
|
14976
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
14977
|
+
var _a, _b;
|
|
14978
|
+
const textTheme = this.getGraphicTheme(),
|
|
14979
|
+
{
|
|
14980
|
+
wrap = textTheme.wrap
|
|
14981
|
+
} = this.attribute;
|
|
14982
|
+
if (wrap) return this.updateWrapAABBBounds(text);
|
|
14983
|
+
const attribute = this.attribute,
|
|
14984
|
+
{
|
|
14985
|
+
fontFamily = textTheme.fontFamily,
|
|
14986
|
+
textAlign = textTheme.textAlign,
|
|
14987
|
+
textBaseline = textTheme.textBaseline,
|
|
14988
|
+
fontSize = textTheme.fontSize,
|
|
14989
|
+
fontWeight = textTheme.fontWeight,
|
|
14990
|
+
ellipsis = textTheme.ellipsis,
|
|
14991
|
+
maxLineWidth: maxLineWidth,
|
|
14992
|
+
stroke = textTheme.stroke,
|
|
14993
|
+
lineWidth = textTheme.lineWidth,
|
|
14994
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14995
|
+
suffixPosition = textTheme.suffixPosition
|
|
14996
|
+
} = attribute,
|
|
14997
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
14998
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14999
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
15000
|
+
const bbox = this.cache.layoutData.bbox;
|
|
15001
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
15002
|
+
}
|
|
15003
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
15004
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
15005
|
+
fontSize: fontSize,
|
|
15006
|
+
fontWeight: fontWeight,
|
|
15007
|
+
fontFamily: fontFamily
|
|
15008
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
15009
|
+
{
|
|
15010
|
+
bbox: bbox
|
|
15011
|
+
} = layoutData;
|
|
15012
|
+
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;
|
|
15013
|
+
}
|
|
15014
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
15015
|
+
var _a, _b, _c;
|
|
15016
|
+
const textTheme = this.getGraphicTheme(),
|
|
15017
|
+
textMeasure = application.graphicUtil.textMeasure;
|
|
15018
|
+
let width;
|
|
15019
|
+
const attribute = this.attribute,
|
|
15020
|
+
{
|
|
15021
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
15022
|
+
} = attribute,
|
|
15023
|
+
buf = ignoreBuf ? 0 : 2,
|
|
14921
15024
|
{
|
|
14922
15025
|
maxLineWidth = textTheme.maxLineWidth,
|
|
14923
15026
|
ellipsis = textTheme.ellipsis,
|
|
@@ -14929,14 +15032,14 @@
|
|
|
14929
15032
|
verticalMode = textTheme.verticalMode,
|
|
14930
15033
|
suffixPosition = textTheme.suffixPosition
|
|
14931
15034
|
} = attribute,
|
|
14932
|
-
lineHeight =
|
|
15035
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14933
15036
|
let {
|
|
14934
15037
|
textAlign = textTheme.textAlign,
|
|
14935
15038
|
textBaseline = textTheme.textBaseline
|
|
14936
15039
|
} = attribute;
|
|
14937
15040
|
if (!verticalMode) {
|
|
14938
15041
|
const t = textAlign;
|
|
14939
|
-
textAlign = null !== (
|
|
15042
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
14940
15043
|
}
|
|
14941
15044
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
14942
15045
|
this.cache.verticalList.forEach(item => {
|
|
@@ -14984,15 +15087,6 @@
|
|
|
14984
15087
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
14985
15088
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14986
15089
|
}
|
|
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
|
-
}
|
|
14996
15090
|
needUpdateTags(keys) {
|
|
14997
15091
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
14998
15092
|
return super.needUpdateTags(keys, k);
|
|
@@ -15007,12 +15101,6 @@
|
|
|
15007
15101
|
getNoWorkAnimateAttr() {
|
|
15008
15102
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
15009
15103
|
}
|
|
15010
|
-
getBaselineMapAlign() {
|
|
15011
|
-
return Text.baselineMapAlign;
|
|
15012
|
-
}
|
|
15013
|
-
getAlignMapBaseline() {
|
|
15014
|
-
return Text.alignMapBaseline;
|
|
15015
|
-
}
|
|
15016
15104
|
}
|
|
15017
15105
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
15018
15106
|
ellipsis: 1,
|
|
@@ -15091,9 +15179,7 @@
|
|
|
15091
15179
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15092
15180
|
linesLayout.push({
|
|
15093
15181
|
str: clip.str,
|
|
15094
|
-
width: clip.width
|
|
15095
|
-
ascent: 0,
|
|
15096
|
-
descent: 0
|
|
15182
|
+
width: clip.width
|
|
15097
15183
|
});
|
|
15098
15184
|
break;
|
|
15099
15185
|
}
|
|
@@ -15107,9 +15193,7 @@
|
|
|
15107
15193
|
}
|
|
15108
15194
|
if (linesLayout.push({
|
|
15109
15195
|
str: clip.str,
|
|
15110
|
-
width: clip.width
|
|
15111
|
-
ascent: 0,
|
|
15112
|
-
descent: 0
|
|
15196
|
+
width: clip.width
|
|
15113
15197
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
15114
15198
|
const newStr = str.substring(clip.str.length);
|
|
15115
15199
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -15128,17 +15212,13 @@
|
|
|
15128
15212
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15129
15213
|
linesLayout.push({
|
|
15130
15214
|
str: clip.str,
|
|
15131
|
-
width: clip.width
|
|
15132
|
-
ascent: 0,
|
|
15133
|
-
descent: 0
|
|
15215
|
+
width: clip.width
|
|
15134
15216
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
15135
15217
|
break;
|
|
15136
15218
|
}
|
|
15137
15219
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
15138
15220
|
str: text,
|
|
15139
|
-
width: width
|
|
15140
|
-
ascent: 0,
|
|
15141
|
-
descent: 0
|
|
15221
|
+
width: width
|
|
15142
15222
|
});
|
|
15143
15223
|
}
|
|
15144
15224
|
bboxWH[0] = lineWidth;
|
|
@@ -15182,6 +15262,9 @@
|
|
|
15182
15262
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
15183
15263
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
15184
15264
|
}
|
|
15265
|
+
parseSize(size) {
|
|
15266
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15267
|
+
}
|
|
15185
15268
|
}
|
|
15186
15269
|
|
|
15187
15270
|
function circle(ctx, r, x, y, z) {
|
|
@@ -15192,13 +15275,13 @@
|
|
|
15192
15275
|
super(...arguments), this.type = "circle", this.pathStr = "M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0";
|
|
15193
15276
|
}
|
|
15194
15277
|
draw(ctx, size, x, y, z) {
|
|
15195
|
-
return circle(ctx, size / 2, x, y, z);
|
|
15278
|
+
return circle(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15196
15279
|
}
|
|
15197
15280
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15198
|
-
return circle(ctx, size / 2 + offset, x, y, z);
|
|
15281
|
+
return circle(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
15199
15282
|
}
|
|
15200
15283
|
drawToSvgPath(size, x, y, z) {
|
|
15201
|
-
const r = size / 2;
|
|
15284
|
+
const r = this.parseSize(size) / 2;
|
|
15202
15285
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
15203
15286
|
}
|
|
15204
15287
|
}
|
|
@@ -15215,10 +15298,10 @@
|
|
|
15215
15298
|
super(...arguments), this.type = "cross", this.pathStr = "M-0.5,-0.2L-0.5,0.2L-0.2,0.2L-0.2,0.5L0.2,0.5L0.2,0.2L0.5,0.2L0.5,-0.2L0.2,-0.2L0.2,-0.5L-0.2,-0.5L-0.2,-0.2Z";
|
|
15216
15299
|
}
|
|
15217
15300
|
draw(ctx, size, x, y, z) {
|
|
15218
|
-
return cross(ctx, size / 6, x, y, z);
|
|
15301
|
+
return cross(ctx, this.parseSize(size) / 6, x, y, z);
|
|
15219
15302
|
}
|
|
15220
15303
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15221
|
-
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
15304
|
+
return crossOffset(ctx, this.parseSize(size) / 6, x, y, offset, z);
|
|
15222
15305
|
}
|
|
15223
15306
|
}
|
|
15224
15307
|
var cross$1 = new CrossSymbol();
|
|
@@ -15231,13 +15314,13 @@
|
|
|
15231
15314
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
15232
15315
|
}
|
|
15233
15316
|
draw(ctx, size, x, y, z) {
|
|
15234
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
15317
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15235
15318
|
}
|
|
15236
15319
|
drawFitDir(ctx, size, x, y, z) {
|
|
15237
|
-
return diamond(ctx, size / 2, x, y, z);
|
|
15320
|
+
return diamond(ctx, this.parseSize(size) / 2, x, y, z);
|
|
15238
15321
|
}
|
|
15239
15322
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15240
|
-
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
15323
|
+
return diamond(ctx, this.parseSize(size) / 2 + offset, x, y, z);
|
|
15241
15324
|
}
|
|
15242
15325
|
}
|
|
15243
15326
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -15251,10 +15334,10 @@
|
|
|
15251
15334
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
15252
15335
|
}
|
|
15253
15336
|
draw(ctx, size, x, y) {
|
|
15254
|
-
return square(ctx, size / 2, x, y);
|
|
15337
|
+
return square(ctx, this.parseSize(size) / 2, x, y);
|
|
15255
15338
|
}
|
|
15256
15339
|
drawOffset(ctx, size, x, y, offset) {
|
|
15257
|
-
return square(ctx, size / 2 + offset, x, y);
|
|
15340
|
+
return square(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15258
15341
|
}
|
|
15259
15342
|
}
|
|
15260
15343
|
var square$1 = new SquareSymbol();
|
|
@@ -15268,10 +15351,10 @@
|
|
|
15268
15351
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
15269
15352
|
}
|
|
15270
15353
|
draw(ctx, size, x, y) {
|
|
15271
|
-
return trianglUpOffset(ctx, size / 2, x, y);
|
|
15354
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15272
15355
|
}
|
|
15273
15356
|
drawOffset(ctx, size, x, y, offset) {
|
|
15274
|
-
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
15357
|
+
return trianglUpOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15275
15358
|
}
|
|
15276
15359
|
}
|
|
15277
15360
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -15303,10 +15386,10 @@
|
|
|
15303
15386
|
super(...arguments), this.type = "star", this.pathStr = "M0 -1L0.22451398828979266 -0.3090169943749474L0.9510565162951535 -0.30901699437494745L0.3632712640026804 0.1180339887498948L0.5877852522924732 0.8090169943749473L8.326672684688674e-17 0.3819660112501051L-0.587785252292473 0.8090169943749476L-0.3632712640026804 0.11803398874989487L-0.9510565162951536 -0.30901699437494723L-0.22451398828979274 -0.30901699437494734Z";
|
|
15304
15387
|
}
|
|
15305
15388
|
draw(ctx, size, transX, transY) {
|
|
15306
|
-
return star(ctx, size / 2, transX, transY);
|
|
15389
|
+
return star(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15307
15390
|
}
|
|
15308
15391
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15309
|
-
return star(ctx, size / 2 + offset, transX, transY);
|
|
15392
|
+
return star(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15310
15393
|
}
|
|
15311
15394
|
}
|
|
15312
15395
|
var star$1 = new StarSymbol();
|
|
@@ -15324,10 +15407,10 @@
|
|
|
15324
15407
|
super(...arguments), this.type = "arrow", this.pathStr = "M-0.07142857142857142,0.5L0.07142857142857142,0.5L0.07142857142857142,-0.0625L0.2,-0.0625L0,-0.5L-0.2,-0.0625L-0.07142857142857142,-0.0625Z";
|
|
15325
15408
|
}
|
|
15326
15409
|
draw(ctx, size, transX, transY) {
|
|
15327
|
-
return arrow(ctx, size / 2, transX, transY);
|
|
15410
|
+
return arrow(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15328
15411
|
}
|
|
15329
15412
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15330
|
-
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
15413
|
+
return arrow(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15331
15414
|
}
|
|
15332
15415
|
}
|
|
15333
15416
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -15341,10 +15424,10 @@
|
|
|
15341
15424
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
15342
15425
|
}
|
|
15343
15426
|
draw(ctx, size, transX, transY) {
|
|
15344
|
-
return wedge(ctx, size / 2, transX, transY);
|
|
15427
|
+
return wedge(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15345
15428
|
}
|
|
15346
15429
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15347
|
-
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
15430
|
+
return wedge(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15348
15431
|
}
|
|
15349
15432
|
}
|
|
15350
15433
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -15357,10 +15440,10 @@
|
|
|
15357
15440
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
15358
15441
|
}
|
|
15359
15442
|
draw(ctx, size, transX, transY) {
|
|
15360
|
-
return stroke(ctx, size / 2, transX, transY);
|
|
15443
|
+
return stroke(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15361
15444
|
}
|
|
15362
15445
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15363
|
-
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
15446
|
+
return stroke(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15364
15447
|
}
|
|
15365
15448
|
}
|
|
15366
15449
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -15382,10 +15465,10 @@
|
|
|
15382
15465
|
super(...arguments), this.type = "wye", this.pathStr = "M0.25 0.14433756729740646L0.25 0.6443375672974064L-0.25 0.6443375672974064L-0.25 0.14433756729740643L-0.6830127018922193 -0.10566243270259357L-0.4330127018922193 -0.5386751345948129L0 -0.28867513459481287L0.4330127018922193 -0.5386751345948129L0.6830127018922193 -0.10566243270259357Z";
|
|
15383
15466
|
}
|
|
15384
15467
|
draw(ctx, size, transX, transY) {
|
|
15385
|
-
return wye(ctx, size / 2, transX, transY);
|
|
15468
|
+
return wye(ctx, this.parseSize(size) / 2, transX, transY);
|
|
15386
15469
|
}
|
|
15387
15470
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15388
|
-
return wye(ctx, size / 2 + offset, transX, transY);
|
|
15471
|
+
return wye(ctx, this.parseSize(size) / 2 + offset, transX, transY);
|
|
15389
15472
|
}
|
|
15390
15473
|
}
|
|
15391
15474
|
var wye$1 = new WyeSymbol();
|
|
@@ -15398,10 +15481,10 @@
|
|
|
15398
15481
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
15399
15482
|
}
|
|
15400
15483
|
draw(ctx, size, x, y) {
|
|
15401
|
-
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
15484
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, 0);
|
|
15402
15485
|
}
|
|
15403
15486
|
drawOffset(ctx, size, x, y, offset) {
|
|
15404
|
-
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
15487
|
+
return trianglLeftOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15405
15488
|
}
|
|
15406
15489
|
}
|
|
15407
15490
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -15415,10 +15498,10 @@
|
|
|
15415
15498
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
15416
15499
|
}
|
|
15417
15500
|
draw(ctx, size, x, y) {
|
|
15418
|
-
return trianglRightOffset(ctx, size / 2, x, y);
|
|
15501
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15419
15502
|
}
|
|
15420
15503
|
drawOffset(ctx, size, x, y, offset) {
|
|
15421
|
-
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
15504
|
+
return trianglRightOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15422
15505
|
}
|
|
15423
15506
|
}
|
|
15424
15507
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -15432,10 +15515,10 @@
|
|
|
15432
15515
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
15433
15516
|
}
|
|
15434
15517
|
draw(ctx, size, x, y) {
|
|
15435
|
-
return trianglDownOffset(ctx, size / 2, x, y);
|
|
15518
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y);
|
|
15436
15519
|
}
|
|
15437
15520
|
drawOffset(ctx, size, x, y, offset) {
|
|
15438
|
-
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
15521
|
+
return trianglDownOffset(ctx, this.parseSize(size) / 2, x, y, offset);
|
|
15439
15522
|
}
|
|
15440
15523
|
}
|
|
15441
15524
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -15450,10 +15533,10 @@
|
|
|
15450
15533
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
15451
15534
|
}
|
|
15452
15535
|
draw(ctx, size, x, y) {
|
|
15453
|
-
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
15536
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3, x, y);
|
|
15454
15537
|
}
|
|
15455
15538
|
drawOffset(ctx, size, x, y, offset) {
|
|
15456
|
-
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
15539
|
+
return thinTriangle(ctx, this.parseSize(size) / 2 / sqrt3 + offset, x, y);
|
|
15457
15540
|
}
|
|
15458
15541
|
}
|
|
15459
15542
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -15467,10 +15550,10 @@
|
|
|
15467
15550
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
15468
15551
|
}
|
|
15469
15552
|
draw(ctx, size, transX, transY) {
|
|
15470
|
-
return arrow2Left(ctx, size / 4, transX, transY);
|
|
15553
|
+
return arrow2Left(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15471
15554
|
}
|
|
15472
15555
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15473
|
-
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
15556
|
+
return arrow2Left(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15474
15557
|
}
|
|
15475
15558
|
}
|
|
15476
15559
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -15484,10 +15567,10 @@
|
|
|
15484
15567
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
15485
15568
|
}
|
|
15486
15569
|
draw(ctx, size, transX, transY) {
|
|
15487
|
-
return arrow2Right(ctx, size / 4, transX, transY);
|
|
15570
|
+
return arrow2Right(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15488
15571
|
}
|
|
15489
15572
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15490
|
-
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
15573
|
+
return arrow2Right(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15491
15574
|
}
|
|
15492
15575
|
}
|
|
15493
15576
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -15501,10 +15584,10 @@
|
|
|
15501
15584
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
15502
15585
|
}
|
|
15503
15586
|
draw(ctx, size, transX, transY) {
|
|
15504
|
-
return arrow2Up(ctx, size / 4, transX, transY);
|
|
15587
|
+
return arrow2Up(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15505
15588
|
}
|
|
15506
15589
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15507
|
-
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
15590
|
+
return arrow2Up(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15508
15591
|
}
|
|
15509
15592
|
}
|
|
15510
15593
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -15518,10 +15601,10 @@
|
|
|
15518
15601
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
15519
15602
|
}
|
|
15520
15603
|
draw(ctx, size, transX, transY) {
|
|
15521
|
-
return arrow2Down(ctx, size / 4, transX, transY);
|
|
15604
|
+
return arrow2Down(ctx, this.parseSize(size) / 4, transX, transY);
|
|
15522
15605
|
}
|
|
15523
15606
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15524
|
-
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
15607
|
+
return arrow2Down(ctx, this.parseSize(size) / 4 + offset, transX, transY);
|
|
15525
15608
|
}
|
|
15526
15609
|
}
|
|
15527
15610
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -15534,13 +15617,13 @@
|
|
|
15534
15617
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
15535
15618
|
}
|
|
15536
15619
|
draw(ctx, size, x, y, z) {
|
|
15537
|
-
return lineV(ctx, size / 2, x, y);
|
|
15620
|
+
return lineV(ctx, this.parseSize(size) / 2, x, y);
|
|
15538
15621
|
}
|
|
15539
15622
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15540
|
-
return lineV(ctx, size / 2 + offset, x, y);
|
|
15623
|
+
return lineV(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15541
15624
|
}
|
|
15542
15625
|
drawToSvgPath(size, x, y, z) {
|
|
15543
|
-
const r = size / 2;
|
|
15626
|
+
const r = this.parseSize(size) / 2;
|
|
15544
15627
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
15545
15628
|
}
|
|
15546
15629
|
}
|
|
@@ -15554,13 +15637,13 @@
|
|
|
15554
15637
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
15555
15638
|
}
|
|
15556
15639
|
draw(ctx, size, x, y, z) {
|
|
15557
|
-
return lineH(ctx, size / 2, x, y);
|
|
15640
|
+
return lineH(ctx, this.parseSize(size) / 2, x, y);
|
|
15558
15641
|
}
|
|
15559
15642
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15560
|
-
return lineH(ctx, size / 2 + offset, x, y);
|
|
15643
|
+
return lineH(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15561
15644
|
}
|
|
15562
15645
|
drawToSvgPath(size, x, y, z) {
|
|
15563
|
-
const r = size / 2;
|
|
15646
|
+
const r = this.parseSize(size) / 2;
|
|
15564
15647
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
15565
15648
|
}
|
|
15566
15649
|
}
|
|
@@ -15574,13 +15657,13 @@
|
|
|
15574
15657
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
15575
15658
|
}
|
|
15576
15659
|
draw(ctx, size, x, y, z) {
|
|
15577
|
-
return close(ctx, size / 2, x, y);
|
|
15660
|
+
return close(ctx, this.parseSize(size) / 2, x, y);
|
|
15578
15661
|
}
|
|
15579
15662
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15580
|
-
return close(ctx, size / 2 + offset, x, y);
|
|
15663
|
+
return close(ctx, this.parseSize(size) / 2 + offset, x, y);
|
|
15581
15664
|
}
|
|
15582
15665
|
drawToSvgPath(size, x, y, z) {
|
|
15583
|
-
const r = size / 2;
|
|
15666
|
+
const r = this.parseSize(size) / 2;
|
|
15584
15667
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
15585
15668
|
}
|
|
15586
15669
|
}
|
|
@@ -15614,15 +15697,18 @@
|
|
|
15614
15697
|
this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
15615
15698
|
}
|
|
15616
15699
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
15617
|
-
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
15700
|
+
return size = this.parseSize(size), this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
15618
15701
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
15619
15702
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
15620
15703
|
}
|
|
15621
15704
|
draw(ctx, size, x, y, z, cb) {
|
|
15622
|
-
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
15705
|
+
return size = this.parseSize(size), this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
15706
|
+
}
|
|
15707
|
+
parseSize(size) {
|
|
15708
|
+
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15623
15709
|
}
|
|
15624
15710
|
bounds(size, bounds) {
|
|
15625
|
-
if (this.isSvg) {
|
|
15711
|
+
if (size = this.parseSize(size), this.isSvg) {
|
|
15626
15712
|
if (!this.svgCache) return;
|
|
15627
15713
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
15628
15714
|
let {
|
|
@@ -16305,7 +16391,11 @@
|
|
|
16305
16391
|
case "sub":
|
|
16306
16392
|
baseline += this.descent / 2;
|
|
16307
16393
|
}
|
|
16308
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0)
|
|
16394
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
16395
|
+
const {
|
|
16396
|
+
lineWidth = 1
|
|
16397
|
+
} = this.character;
|
|
16398
|
+
this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
16309
16399
|
}
|
|
16310
16400
|
getWidthWithEllips(direction) {
|
|
16311
16401
|
let text = this.text;
|
|
@@ -18522,7 +18612,7 @@
|
|
|
18522
18612
|
constructor() {
|
|
18523
18613
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18524
18614
|
var _a;
|
|
18525
|
-
super({}), this._onVisibleChange = visible => {
|
|
18615
|
+
super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
|
|
18526
18616
|
if (!(this._skipRender < 0)) if (visible) {
|
|
18527
18617
|
if (this.dirtyBounds) {
|
|
18528
18618
|
const b = this.window.getViewBox();
|
|
@@ -18533,7 +18623,10 @@
|
|
|
18533
18623
|
}, this.beforeRender = stage => {
|
|
18534
18624
|
this._beforeRender && this._beforeRender(stage);
|
|
18535
18625
|
}, this.afterRender = stage => {
|
|
18536
|
-
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
|
|
18626
|
+
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
|
|
18627
|
+
}, this.afterTickCb = () => {
|
|
18628
|
+
var _a;
|
|
18629
|
+
this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
|
|
18537
18630
|
}, this.params = params, this.theme = new Theme(), this.hooks = {
|
|
18538
18631
|
beforeRender: new SyncHook(["stage"]),
|
|
18539
18632
|
afterRender: new SyncHook(["stage"])
|
|
@@ -18550,7 +18643,7 @@
|
|
|
18550
18643
|
main: !0
|
|
18551
18644
|
})), 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({
|
|
18552
18645
|
background: this._background
|
|
18553
|
-
});
|
|
18646
|
+
}), this.ticker.on("afterTick", this.afterTickCb);
|
|
18554
18647
|
}
|
|
18555
18648
|
pauseRender() {
|
|
18556
18649
|
let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
@@ -18779,7 +18872,7 @@
|
|
|
18779
18872
|
if ("released" === this.releaseStatus) return;
|
|
18780
18873
|
this.ticker.start(), this.timeline.resume();
|
|
18781
18874
|
const state = this.state;
|
|
18782
|
-
this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
|
|
18875
|
+
this.state = "rendering", this.tickedBeforeRender || this.ticker.trySyncTickStatus(), this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
|
|
18783
18876
|
}
|
|
18784
18877
|
combineLayersToWindow() {
|
|
18785
18878
|
if ("harmony" === this.global.env) {
|
|
@@ -18885,7 +18978,7 @@
|
|
|
18885
18978
|
layer.release();
|
|
18886
18979
|
}), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
|
|
18887
18980
|
item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
|
|
18888
|
-
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
|
|
18981
|
+
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
|
|
18889
18982
|
}
|
|
18890
18983
|
setStage(stage) {}
|
|
18891
18984
|
dirty(b, matrix) {
|
|
@@ -23864,7 +23957,7 @@
|
|
|
23864
23957
|
startTime: startTime,
|
|
23865
23958
|
startPoints: startPoints
|
|
23866
23959
|
} = this;
|
|
23867
|
-
if (eventType) return eventType;
|
|
23960
|
+
if ("press" === eventType) return eventType;
|
|
23868
23961
|
let type;
|
|
23869
23962
|
return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
|
|
23870
23963
|
}
|
|
@@ -24396,9 +24489,10 @@
|
|
|
24396
24489
|
lineJoin = defaultParams.lineJoin,
|
|
24397
24490
|
lineDash = defaultParams.lineDash,
|
|
24398
24491
|
lineCap = defaultParams.lineCap,
|
|
24399
|
-
miterLimit = defaultParams.miterLimit
|
|
24492
|
+
miterLimit = defaultParams.miterLimit,
|
|
24493
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
24400
24494
|
} = attribute;
|
|
24401
|
-
_context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24495
|
+
_context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24402
24496
|
}
|
|
24403
24497
|
}
|
|
24404
24498
|
setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
|
|
@@ -25298,8 +25392,9 @@
|
|
|
25298
25392
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
25299
25393
|
if (picked) return !0;
|
|
25300
25394
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25301
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25302
|
-
|
|
25395
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
25396
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
25397
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25303
25398
|
}), pickContext.highPerformanceRestore(), picked;
|
|
25304
25399
|
}
|
|
25305
25400
|
}
|
|
@@ -25572,8 +25667,9 @@
|
|
|
25572
25667
|
if (!onlyTranslate || rect.shadowRoot || isNumber$1(cornerRadius, !0) && 0 !== cornerRadius || isArray$1(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
25573
25668
|
if (picked) return !0;
|
|
25574
25669
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25575
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25576
|
-
|
|
25670
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
25671
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
25672
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25577
25673
|
});else {
|
|
25578
25674
|
const {
|
|
25579
25675
|
fill = rectAttribute.fill,
|
|
@@ -25887,9 +25983,10 @@
|
|
|
25887
25983
|
lineJoin = defaultParams.lineJoin,
|
|
25888
25984
|
lineDash = defaultParams.lineDash,
|
|
25889
25985
|
lineCap = defaultParams.lineCap,
|
|
25890
|
-
miterLimit = defaultParams.miterLimit
|
|
25986
|
+
miterLimit = defaultParams.miterLimit,
|
|
25987
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
25891
25988
|
} = attribute;
|
|
25892
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
25989
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
25893
25990
|
}
|
|
25894
25991
|
}
|
|
25895
25992
|
measureText(text) {
|
|
@@ -26517,9 +26614,10 @@
|
|
|
26517
26614
|
lineJoin = defaultParams.lineJoin,
|
|
26518
26615
|
lineDash = defaultParams.lineDash,
|
|
26519
26616
|
lineCap = defaultParams.lineCap,
|
|
26520
|
-
miterLimit = defaultParams.miterLimit
|
|
26617
|
+
miterLimit = defaultParams.miterLimit,
|
|
26618
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
26521
26619
|
} = attribute;
|
|
26522
|
-
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
26620
|
+
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
26523
26621
|
}
|
|
26524
26622
|
}
|
|
26525
26623
|
setTextStyleWithoutAlignBaseline(params, defaultParams) {
|
|
@@ -27559,9 +27657,10 @@
|
|
|
27559
27657
|
lineJoin = defaultParams.lineJoin,
|
|
27560
27658
|
lineDash = defaultParams.lineDash,
|
|
27561
27659
|
lineCap = defaultParams.lineCap,
|
|
27562
|
-
miterLimit = defaultParams.miterLimit
|
|
27660
|
+
miterLimit = defaultParams.miterLimit,
|
|
27661
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
27563
27662
|
} = attribute;
|
|
27564
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
27663
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
27565
27664
|
}
|
|
27566
27665
|
}
|
|
27567
27666
|
measureText(text) {
|
|
@@ -27968,8 +28067,9 @@
|
|
|
27968
28067
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
27969
28068
|
if (picked) return !0;
|
|
27970
28069
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
27971
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
27972
|
-
|
|
28070
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28071
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28072
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
27973
28073
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
27974
28074
|
}
|
|
27975
28075
|
}
|
|
@@ -28104,8 +28204,9 @@
|
|
|
28104
28204
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
28105
28205
|
if (picked) return !0;
|
|
28106
28206
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28107
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28108
|
-
|
|
28207
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28208
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28209
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28109
28210
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28110
28211
|
}
|
|
28111
28212
|
};
|
|
@@ -28199,8 +28300,10 @@
|
|
|
28199
28300
|
} = text.attribute,
|
|
28200
28301
|
bounds = text.AABBBounds,
|
|
28201
28302
|
height = bounds.height(),
|
|
28202
|
-
width = bounds.width()
|
|
28203
|
-
|
|
28303
|
+
width = bounds.width(),
|
|
28304
|
+
offsetY = textLayoutOffsetY(textBaseline, height, fontSize),
|
|
28305
|
+
offsetX = textDrawOffsetX(textAlign, width);
|
|
28306
|
+
return context.rect(offsetX + x, offsetY + y, width, height, z), picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked;
|
|
28204
28307
|
}, (context, symbolAttribute, themeAttribute) => picked), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28205
28308
|
}
|
|
28206
28309
|
};
|
|
@@ -28540,7 +28643,7 @@
|
|
|
28540
28643
|
|
|
28541
28644
|
const roughModule = _roughModule;
|
|
28542
28645
|
|
|
28543
|
-
const version = "0.21.0-
|
|
28646
|
+
const version = "0.21.0-beta.0";
|
|
28544
28647
|
preLoadAllModule();
|
|
28545
28648
|
if (isBrowserEnv()) {
|
|
28546
28649
|
loadBrowserEnv(container);
|