@visactor/vrender 0.21.0-alpha.12 → 0.21.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +512 -537
- package/dist/index.js +511 -537
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -595,6 +595,12 @@
|
|
|
595
595
|
get env() {
|
|
596
596
|
return this._env;
|
|
597
597
|
}
|
|
598
|
+
get isImageAnonymous() {
|
|
599
|
+
return this._isImageAnonymous;
|
|
600
|
+
}
|
|
601
|
+
set isImageAnonymous(isImageAnonymous) {
|
|
602
|
+
this._isImageAnonymous = isImageAnonymous;
|
|
603
|
+
}
|
|
598
604
|
get devicePixelRatio() {
|
|
599
605
|
return this._env || this.setEnv("browser"), this.envContribution.getDevicePixelRatio();
|
|
600
606
|
}
|
|
@@ -629,7 +635,7 @@
|
|
|
629
635
|
this._env || this.setEnv("browser"), this.envContribution.applyStyles = support;
|
|
630
636
|
}
|
|
631
637
|
constructor(contributions) {
|
|
632
|
-
this.contributions = contributions, this.id = Generator.GenAutoIncrementId(), this.hooks = {
|
|
638
|
+
this.contributions = contributions, this._isImageAnonymous = !0, this.id = Generator.GenAutoIncrementId(), this.hooks = {
|
|
633
639
|
onSetEnv: new SyncHook(["lastEnv", "env", "global"])
|
|
634
640
|
}, this.measureTextMethod = "native", this.optimizeVisible = !1;
|
|
635
641
|
}
|
|
@@ -748,13 +754,6 @@
|
|
|
748
754
|
};
|
|
749
755
|
exports.DefaultGlobal = __decorate$1H([injectable(), __param$T(0, inject(ContributionProvider)), __param$T(0, named(EnvContribution)), __metadata$1h("design:paramtypes", [Object])], exports.DefaultGlobal);
|
|
750
756
|
|
|
751
|
-
exports.MeasureModeEnum = void 0;
|
|
752
|
-
!function (MeasureModeEnum) {
|
|
753
|
-
MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
|
|
754
|
-
}(exports.MeasureModeEnum || (exports.MeasureModeEnum = {}));
|
|
755
|
-
|
|
756
|
-
const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
|
|
757
|
-
|
|
758
757
|
function getDefaultExportFromCjs (x) {
|
|
759
758
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
760
759
|
}
|
|
@@ -1709,9 +1708,7 @@
|
|
|
1709
1708
|
} = this.textSpec;
|
|
1710
1709
|
return {
|
|
1711
1710
|
width: metrics.width,
|
|
1712
|
-
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
|
|
1713
|
-
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
|
|
1714
|
-
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
|
|
1711
|
+
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
|
|
1715
1712
|
};
|
|
1716
1713
|
}
|
|
1717
1714
|
quickMeasure(text) {
|
|
@@ -1725,7 +1722,7 @@
|
|
|
1725
1722
|
for (let i = 0; i < text.length; i++) {
|
|
1726
1723
|
const char = text[i];
|
|
1727
1724
|
let size = this._measureSpecialChar(char);
|
|
1728
|
-
isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height)
|
|
1725
|
+
isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height);
|
|
1729
1726
|
}
|
|
1730
1727
|
return totalSize;
|
|
1731
1728
|
}
|
|
@@ -1774,9 +1771,7 @@
|
|
|
1774
1771
|
const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
|
|
1775
1772
|
this._numberCharSize = {
|
|
1776
1773
|
width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
|
|
1777
|
-
height: numberBounds.height
|
|
1778
|
-
fontBoundingBoxAscent: numberBounds.fontBoundingBoxAscent,
|
|
1779
|
-
fontBoundingBoxDescent: numberBounds.fontBoundingBoxDescent
|
|
1774
|
+
height: numberBounds.height
|
|
1780
1775
|
};
|
|
1781
1776
|
}
|
|
1782
1777
|
return this._numberCharSize;
|
|
@@ -1789,9 +1784,7 @@
|
|
|
1789
1784
|
const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
|
|
1790
1785
|
this._letterCharSize = {
|
|
1791
1786
|
width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
|
|
1792
|
-
height: alphabetBounds.height
|
|
1793
|
-
fontBoundingBoxAscent: alphabetBounds.fontBoundingBoxAscent,
|
|
1794
|
-
fontBoundingBoxDescent: alphabetBounds.fontBoundingBoxDescent
|
|
1787
|
+
height: alphabetBounds.height
|
|
1795
1788
|
};
|
|
1796
1789
|
}
|
|
1797
1790
|
return this._letterCharSize;
|
|
@@ -3932,7 +3925,6 @@
|
|
|
3932
3925
|
const DefaultTextStyle = {
|
|
3933
3926
|
text: "",
|
|
3934
3927
|
maxLineWidth: 1 / 0,
|
|
3935
|
-
maxWidth: 1 / 0,
|
|
3936
3928
|
textAlign: "left",
|
|
3937
3929
|
textBaseline: "alphabetic",
|
|
3938
3930
|
fontSize: 16,
|
|
@@ -3956,9 +3948,7 @@
|
|
|
3956
3948
|
suffixPosition: "end",
|
|
3957
3949
|
underlineDash: [],
|
|
3958
3950
|
underlineOffset: 0,
|
|
3959
|
-
disableAutoClipedPoptip: void 0
|
|
3960
|
-
measureMode: exports.MeasureModeEnum.fontBounding,
|
|
3961
|
-
keepCenterInLine: !1
|
|
3951
|
+
disableAutoClipedPoptip: void 0
|
|
3962
3952
|
};
|
|
3963
3953
|
const DefaultPickStyle = {
|
|
3964
3954
|
pickStrokeBuffer: 0
|
|
@@ -4012,8 +4002,7 @@
|
|
|
4012
4002
|
globalZIndex: 1,
|
|
4013
4003
|
globalCompositeOperation: "",
|
|
4014
4004
|
overflow: "hidden",
|
|
4015
|
-
shadowPickMode: "graphic"
|
|
4016
|
-
keepStrokeScale: !1
|
|
4005
|
+
shadowPickMode: "graphic"
|
|
4017
4006
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
4018
4007
|
function addAttributeToPrototype(obj, c, keys) {
|
|
4019
4008
|
keys.forEach(key => {
|
|
@@ -4288,32 +4277,10 @@
|
|
|
4288
4277
|
configure(service, env) {
|
|
4289
4278
|
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4290
4279
|
}
|
|
4291
|
-
|
|
4280
|
+
measureTextWidth(text, options) {
|
|
4281
|
+
if (!this.context) return this.estimate(text, options).width;
|
|
4292
4282
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4293
|
-
|
|
4294
|
-
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4295
|
-
}
|
|
4296
|
-
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
4297
|
-
this.context.setTextStyle(options);
|
|
4298
|
-
const metrics = this.context.measureText(text);
|
|
4299
|
-
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4300
|
-
}
|
|
4301
|
-
compatibleMetrics(metrics, options) {
|
|
4302
|
-
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
4303
|
-
const {
|
|
4304
|
-
ascent: ascent,
|
|
4305
|
-
descent: descent
|
|
4306
|
-
} = this.measureTextBoundADscentEstimate(options);
|
|
4307
|
-
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
4308
|
-
}
|
|
4309
|
-
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
4310
|
-
const {
|
|
4311
|
-
left: left,
|
|
4312
|
-
right: right
|
|
4313
|
-
} = this.measureTextBoundLeftRightEstimate(options);
|
|
4314
|
-
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
4315
|
-
}
|
|
4316
|
-
return metrics;
|
|
4283
|
+
return this.context.measureText(text).width;
|
|
4317
4284
|
}
|
|
4318
4285
|
estimate(text, _ref) {
|
|
4319
4286
|
let {
|
|
@@ -4327,97 +4294,19 @@
|
|
|
4327
4294
|
height: fontSize
|
|
4328
4295
|
};
|
|
4329
4296
|
}
|
|
4330
|
-
|
|
4331
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4332
|
-
}
|
|
4333
|
-
measureTextBoundsWidth(text, options, textMeasure) {
|
|
4334
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4335
|
-
}
|
|
4336
|
-
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
4337
|
-
return this.context ? {
|
|
4338
|
-
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
4339
|
-
right: textMeasure.actualBoundingBoxRight
|
|
4340
|
-
} : this.measureTextBoundLeftRightEstimate(options);
|
|
4341
|
-
}
|
|
4342
|
-
measureTextPixelHeight(text, options, textMeasure) {
|
|
4343
|
-
var _a;
|
|
4344
|
-
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4345
|
-
}
|
|
4346
|
-
measureTextPixelADscent(text, options, textMeasure) {
|
|
4347
|
-
return this.context ? {
|
|
4348
|
-
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
4349
|
-
descent: textMeasure.actualBoundingBoxDescent
|
|
4350
|
-
} : this.measureTextBoundADscentEstimate(options);
|
|
4351
|
-
}
|
|
4352
|
-
measureTextBoundHieght(text, options, textMeasure) {
|
|
4297
|
+
measureTextPixelHeight(text, options) {
|
|
4353
4298
|
var _a;
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
return
|
|
4358
|
-
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
4359
|
-
descent: textMeasure.fontBoundingBoxDescent
|
|
4360
|
-
} : this.measureTextBoundADscentEstimate(options);
|
|
4361
|
-
}
|
|
4362
|
-
measureTextBoundADscentEstimate(options) {
|
|
4363
|
-
var _a;
|
|
4364
|
-
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4365
|
-
return {
|
|
4366
|
-
ascent: .79 * fontSize,
|
|
4367
|
-
descent: .21 * fontSize
|
|
4368
|
-
};
|
|
4299
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4300
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4301
|
+
const textMeasure = this.context.measureText(text);
|
|
4302
|
+
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
4369
4303
|
}
|
|
4370
|
-
|
|
4304
|
+
measureTextBoundHieght(text, options) {
|
|
4371
4305
|
var _a;
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
return "center" === textAlign ? {
|
|
4377
|
-
left: fontSize / 2,
|
|
4378
|
-
right: fontSize / 2
|
|
4379
|
-
} : "right" === textAlign || "end" === textAlign ? {
|
|
4380
|
-
left: fontSize,
|
|
4381
|
-
right: 0
|
|
4382
|
-
} : {
|
|
4383
|
-
left: 0,
|
|
4384
|
-
right: fontSize
|
|
4385
|
-
};
|
|
4386
|
-
}
|
|
4387
|
-
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
4388
|
-
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4389
|
-
width: this.estimate(text, options).width
|
|
4390
|
-
});
|
|
4391
|
-
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
4392
|
-
if (mode === exports.MeasureModeEnum.actualBounding) return {
|
|
4393
|
-
ascent: out.actualBoundingBoxAscent,
|
|
4394
|
-
descent: out.actualBoundingBoxDescent,
|
|
4395
|
-
width: out.width
|
|
4396
|
-
};
|
|
4397
|
-
if (mode === exports.MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4398
|
-
width: out.width
|
|
4399
|
-
});
|
|
4400
|
-
if (mode === exports.MeasureModeEnum.fontBounding) {
|
|
4401
|
-
let ascent = out.fontBoundingBoxAscent,
|
|
4402
|
-
descent = out.fontBoundingBoxDescent;
|
|
4403
|
-
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
4404
|
-
const delta = out.actualBoundingBoxDescent - descent;
|
|
4405
|
-
descent += delta, ascent -= delta;
|
|
4406
|
-
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
4407
|
-
const delta = out.actualBoundingBoxAscent - ascent;
|
|
4408
|
-
ascent += delta, descent -= delta;
|
|
4409
|
-
}
|
|
4410
|
-
return {
|
|
4411
|
-
ascent: ascent,
|
|
4412
|
-
descent: descent,
|
|
4413
|
-
width: out.width
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
return {
|
|
4417
|
-
ascent: out.actualBoundingBoxAscent,
|
|
4418
|
-
descent: out.actualBoundingBoxDescent,
|
|
4419
|
-
width: out.width
|
|
4420
|
-
};
|
|
4306
|
+
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4307
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4308
|
+
const textMeasure = this.context.measureText(text);
|
|
4309
|
+
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
4421
4310
|
}
|
|
4422
4311
|
measureText(text, options) {
|
|
4423
4312
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
@@ -6529,7 +6418,7 @@
|
|
|
6529
6418
|
}
|
|
6530
6419
|
}
|
|
6531
6420
|
|
|
6532
|
-
class DefaultTicker
|
|
6421
|
+
class DefaultTicker {
|
|
6533
6422
|
set mode(m) {
|
|
6534
6423
|
this._mode !== m && (this._mode = m, this.setupTickHandler());
|
|
6535
6424
|
}
|
|
@@ -6538,17 +6427,17 @@
|
|
|
6538
6427
|
}
|
|
6539
6428
|
constructor() {
|
|
6540
6429
|
let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6541
|
-
|
|
6430
|
+
this.handleTick = (handler, params) => {
|
|
6542
6431
|
const {
|
|
6543
6432
|
once = !1
|
|
6544
6433
|
} = null != params ? params : {};
|
|
6545
|
-
this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
|
|
6546
|
-
}, this._handlerTick =
|
|
6434
|
+
this.ifCanStop() ? this.stop() : (this._handlerTick(handler), once || handler.tick(this.interval, this.handleTick));
|
|
6435
|
+
}, this._handlerTick = handler => {
|
|
6547
6436
|
const time = this.tickerHandler.getTime();
|
|
6548
6437
|
let delta = 0;
|
|
6549
6438
|
this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
|
|
6550
6439
|
t.tick(delta);
|
|
6551
|
-
})
|
|
6440
|
+
}));
|
|
6552
6441
|
}, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
|
|
6553
6442
|
}
|
|
6554
6443
|
init() {
|
|
@@ -6644,9 +6533,6 @@
|
|
|
6644
6533
|
stop() {
|
|
6645
6534
|
this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
|
|
6646
6535
|
}
|
|
6647
|
-
trySyncTickStatus() {
|
|
6648
|
-
this.status === STATUS$1.RUNNING && this._handlerTick();
|
|
6649
|
-
}
|
|
6650
6536
|
}
|
|
6651
6537
|
|
|
6652
6538
|
class ManualTickHandler {
|
|
@@ -7346,16 +7232,12 @@
|
|
|
7346
7232
|
}
|
|
7347
7233
|
RafBasedSTO.TimeOut = 1e3 / 60;
|
|
7348
7234
|
const rafBasedSto = new RafBasedSTO();
|
|
7349
|
-
const
|
|
7235
|
+
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
7350
7236
|
if (isString$1(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
|
|
7351
7237
|
return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
|
|
7352
7238
|
}
|
|
7353
7239
|
return lineHeight;
|
|
7354
7240
|
};
|
|
7355
|
-
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
7356
|
-
const _lh = _calculateLineHeight(lineHeight, fontSize);
|
|
7357
|
-
return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
|
|
7358
|
-
};
|
|
7359
7241
|
|
|
7360
7242
|
class IncreaseCount extends ACustomAnimate {
|
|
7361
7243
|
constructor(from, to, duration, easing, params) {
|
|
@@ -7792,7 +7674,7 @@
|
|
|
7792
7674
|
lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
7793
7675
|
break;
|
|
7794
7676
|
}
|
|
7795
|
-
"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],
|
|
7677
|
+
"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);
|
|
7796
7678
|
let prevMatchedPoint = this.toPoints[0];
|
|
7797
7679
|
this.interpolatePoints = this.toPoints.map((point, index) => {
|
|
7798
7680
|
const matchedPoint = tagMap.get(point.context);
|
|
@@ -7804,19 +7686,11 @@
|
|
|
7804
7686
|
return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
|
|
7805
7687
|
});
|
|
7806
7688
|
}
|
|
7807
|
-
onFirstRun() {
|
|
7808
|
-
const lastClipRange = this.target.attribute.clipRange;
|
|
7809
|
-
isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
|
|
7810
|
-
}
|
|
7811
7689
|
onUpdate(end, ratio, out) {
|
|
7812
7690
|
if (this.points = this.points.map((point, index) => {
|
|
7813
7691
|
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
7814
7692
|
return newPoint.context = point.context, newPoint;
|
|
7815
|
-
}), this.clipRange) {
|
|
7816
|
-
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));
|
|
7817
|
-
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
7818
|
-
}
|
|
7819
|
-
if (this.segmentsCache && this.to.segments) {
|
|
7693
|
+
}), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
|
|
7820
7694
|
let start = 0;
|
|
7821
7695
|
out.segments = this.to.segments.map((segment, index) => {
|
|
7822
7696
|
const end = start + this.segmentsCache[index],
|
|
@@ -9232,7 +9106,7 @@
|
|
|
9232
9106
|
}
|
|
9233
9107
|
static GetFile(url, type) {
|
|
9234
9108
|
let data = ResourceLoader.cache.get(url);
|
|
9235
|
-
return data ? "
|
|
9109
|
+
return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
|
|
9236
9110
|
type: type,
|
|
9237
9111
|
loadState: "init"
|
|
9238
9112
|
}, ResourceLoader.cache.set(url, data), "arrayBuffer" === type ? data.dataPromise = application.global.loadArrayBuffer(url) : "blob" === type ? data.dataPromise = application.global.loadBlob(url) : "json" === type && (data.dataPromise = application.global.loadJson(url)), data.dataPromise.then(data => data.data));
|
|
@@ -12170,8 +12044,7 @@
|
|
|
12170
12044
|
x: originX = arcAttribute.x,
|
|
12171
12045
|
y: originY = arcAttribute.y,
|
|
12172
12046
|
scaleX = arcAttribute.scaleX,
|
|
12173
|
-
scaleY = arcAttribute.scaleY
|
|
12174
|
-
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
12047
|
+
scaleY = arcAttribute.scaleY
|
|
12175
12048
|
} = arc.attribute;
|
|
12176
12049
|
let {
|
|
12177
12050
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -12183,7 +12056,7 @@
|
|
|
12183
12056
|
{
|
|
12184
12057
|
distance = arcAttribute[key].distance
|
|
12185
12058
|
} = borderStyle,
|
|
12186
|
-
d =
|
|
12059
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
12187
12060
|
deltaAngle = distance / outerRadius,
|
|
12188
12061
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12189
12062
|
if (arc.setAttributes({
|
|
@@ -12228,15 +12101,14 @@
|
|
|
12228
12101
|
x: originX = circleAttribute.x,
|
|
12229
12102
|
y: originY = circleAttribute.y,
|
|
12230
12103
|
scaleX = circleAttribute.scaleX,
|
|
12231
|
-
scaleY = circleAttribute.scaleY
|
|
12232
|
-
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
12104
|
+
scaleY = circleAttribute.scaleY
|
|
12233
12105
|
} = circle.attribute,
|
|
12234
12106
|
renderBorder = (borderStyle, key) => {
|
|
12235
12107
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12236
12108
|
{
|
|
12237
12109
|
distance = circleAttribute[key].distance
|
|
12238
12110
|
} = borderStyle,
|
|
12239
|
-
d =
|
|
12111
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
12240
12112
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12241
12113
|
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) {
|
|
12242
12114
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -12355,8 +12227,7 @@
|
|
|
12355
12227
|
scaleX = rectAttribute.scaleX,
|
|
12356
12228
|
scaleY = rectAttribute.scaleY,
|
|
12357
12229
|
x1: x1,
|
|
12358
|
-
y1: y1
|
|
12359
|
-
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
12230
|
+
y1: y1
|
|
12360
12231
|
} = rect.attribute;
|
|
12361
12232
|
let {
|
|
12362
12233
|
width: width,
|
|
@@ -12369,7 +12240,7 @@
|
|
|
12369
12240
|
{
|
|
12370
12241
|
distance = rectAttribute[key].distance
|
|
12371
12242
|
} = borderStyle,
|
|
12372
|
-
d =
|
|
12243
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
12373
12244
|
nextX = x + sign * d,
|
|
12374
12245
|
nextY = y + sign * d,
|
|
12375
12246
|
dw = 2 * d;
|
|
@@ -12499,8 +12370,9 @@
|
|
|
12499
12370
|
constructor() {
|
|
12500
12371
|
super(...arguments), this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
12501
12372
|
}
|
|
12502
|
-
drawShape(
|
|
12503
|
-
return super.drawShape(
|
|
12373
|
+
drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
12374
|
+
if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
12375
|
+
image.renderFrame(context, x, y);
|
|
12504
12376
|
}
|
|
12505
12377
|
}
|
|
12506
12378
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -12526,15 +12398,14 @@
|
|
|
12526
12398
|
x: originX = symbolAttribute.x,
|
|
12527
12399
|
y: originY = symbolAttribute.y,
|
|
12528
12400
|
scaleX = symbolAttribute.scaleX,
|
|
12529
|
-
scaleY = symbolAttribute.scaleY
|
|
12530
|
-
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
12401
|
+
scaleY = symbolAttribute.scaleY
|
|
12531
12402
|
} = symbol.attribute,
|
|
12532
12403
|
renderBorder = (borderStyle, key) => {
|
|
12533
12404
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
12534
12405
|
{
|
|
12535
12406
|
distance = symbolAttribute[key].distance
|
|
12536
12407
|
} = borderStyle,
|
|
12537
|
-
d =
|
|
12408
|
+
d = getScaledStroke(context, distance, context.dpr),
|
|
12538
12409
|
sign = "outerBorder" === key ? 1 : -1;
|
|
12539
12410
|
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) {
|
|
12540
12411
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -13812,8 +13683,16 @@
|
|
|
13812
13683
|
verticalMode = textAttribute.verticalMode,
|
|
13813
13684
|
x: originX = textAttribute.x,
|
|
13814
13685
|
y: originY = textAttribute.y
|
|
13815
|
-
} = text.attribute
|
|
13816
|
-
|
|
13686
|
+
} = text.attribute;
|
|
13687
|
+
let {
|
|
13688
|
+
textAlign = textAttribute.textAlign,
|
|
13689
|
+
textBaseline = textAttribute.textBaseline
|
|
13690
|
+
} = text.attribute;
|
|
13691
|
+
if (!verticalMode && "vertical" === direction) {
|
|
13692
|
+
const t = textAlign;
|
|
13693
|
+
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
13694
|
+
}
|
|
13695
|
+
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
13817
13696
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
13818
13697
|
if (!data) return;
|
|
13819
13698
|
const {
|
|
@@ -13833,60 +13712,79 @@
|
|
|
13833
13712
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
13834
13713
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
13835
13714
|
}
|
|
13836
|
-
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
13715
|
+
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());
|
|
13837
13716
|
};
|
|
13838
|
-
if (
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
context
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13717
|
+
if (text.isMultiLine) {
|
|
13718
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
13719
|
+
const {
|
|
13720
|
+
multilineLayout: multilineLayout
|
|
13721
|
+
} = text;
|
|
13722
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
13723
|
+
const {
|
|
13724
|
+
xOffset: xOffset,
|
|
13725
|
+
yOffset: yOffset
|
|
13726
|
+
} = multilineLayout.bbox;
|
|
13727
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13728
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
13729
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13730
|
+
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, {
|
|
13731
|
+
width: line.width
|
|
13732
|
+
});
|
|
13733
|
+
})));
|
|
13734
|
+
} else {
|
|
13735
|
+
text.tryUpdateAABBBounds();
|
|
13736
|
+
const cache = text.cache,
|
|
13737
|
+
{
|
|
13738
|
+
verticalList: verticalList
|
|
13739
|
+
} = cache;
|
|
13740
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
13741
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
13742
|
+
let totalW = 0;
|
|
13743
|
+
verticalList.forEach(verticalData => {
|
|
13744
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13745
|
+
totalW = max(_w, totalW);
|
|
13746
|
+
});
|
|
13747
|
+
let offsetY = 0,
|
|
13748
|
+
offsetX = 0;
|
|
13749
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13750
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13751
|
+
dw = totalW - currentW;
|
|
13752
|
+
let currentOffsetY = offsetY;
|
|
13753
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13754
|
+
const {
|
|
13755
|
+
text: text,
|
|
13756
|
+
width: width,
|
|
13757
|
+
direction: direction
|
|
13758
|
+
} = item;
|
|
13759
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13760
|
+
});
|
|
13852
13761
|
});
|
|
13853
|
-
})));
|
|
13854
|
-
} else {
|
|
13855
|
-
let {
|
|
13856
|
-
textAlign = textAttribute.textAlign,
|
|
13857
|
-
textBaseline = textAttribute.textBaseline
|
|
13858
|
-
} = text.attribute;
|
|
13859
|
-
if (!verticalMode) {
|
|
13860
|
-
const t = textAlign;
|
|
13861
|
-
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
13862
13762
|
}
|
|
13763
|
+
} else if ("horizontal" === direction) {
|
|
13764
|
+
context.setTextStyle(text.attribute, textAttribute, z);
|
|
13765
|
+
const t = text.clipedText;
|
|
13766
|
+
let dy = 0;
|
|
13767
|
+
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
13768
|
+
} else {
|
|
13863
13769
|
text.tryUpdateAABBBounds();
|
|
13864
|
-
const cache = text.cache
|
|
13865
|
-
|
|
13770
|
+
const cache = text.cache;
|
|
13771
|
+
if (cache) {
|
|
13772
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
13773
|
+
const {
|
|
13866
13774
|
verticalList: verticalList
|
|
13867
13775
|
} = cache;
|
|
13868
|
-
|
|
13869
|
-
|
|
13870
|
-
|
|
13871
|
-
|
|
13872
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13873
|
-
totalW = max(_w, totalW);
|
|
13874
|
-
});
|
|
13875
|
-
let offsetY = 0,
|
|
13876
|
-
offsetX = 0;
|
|
13877
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13878
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13879
|
-
dw = totalW - currentW;
|
|
13880
|
-
let currentOffsetY = offsetY;
|
|
13881
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13776
|
+
let offsetY = 0;
|
|
13777
|
+
const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
|
|
13778
|
+
let offsetX = 0;
|
|
13779
|
+
"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 => {
|
|
13882
13780
|
const {
|
|
13883
13781
|
text: text,
|
|
13884
13782
|
width: width,
|
|
13885
13783
|
direction: direction
|
|
13886
13784
|
} = item;
|
|
13887
|
-
drawText(text,
|
|
13785
|
+
drawText(text, offsetX, offsetY, direction), offsetY += width;
|
|
13888
13786
|
});
|
|
13889
|
-
}
|
|
13787
|
+
}
|
|
13890
13788
|
}
|
|
13891
13789
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
13892
13790
|
}
|
|
@@ -13898,10 +13796,12 @@
|
|
|
13898
13796
|
computed3dMatrix = !keepDirIn3d;
|
|
13899
13797
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
13900
13798
|
}
|
|
13901
|
-
drawUnderLine(underline, lineThrough, text,
|
|
13799
|
+
drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
|
|
13902
13800
|
if (lineThrough + underline <= 0) return;
|
|
13903
13801
|
const {
|
|
13904
13802
|
textAlign = textAttribute.textAlign,
|
|
13803
|
+
textBaseline = textAttribute.textBaseline,
|
|
13804
|
+
fontSize = textAttribute.fontSize,
|
|
13905
13805
|
fill = textAttribute.fill,
|
|
13906
13806
|
opacity = textAttribute.opacity,
|
|
13907
13807
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -13911,21 +13811,23 @@
|
|
|
13911
13811
|
isMulti = !isNil$1(multiOption),
|
|
13912
13812
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
13913
13813
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
13814
|
+
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
13914
13815
|
attribute = {
|
|
13915
13816
|
lineWidth: 0,
|
|
13916
13817
|
stroke: fill,
|
|
13917
13818
|
opacity: opacity,
|
|
13918
13819
|
strokeOpacity: fillOpacity
|
|
13919
13820
|
};
|
|
13821
|
+
let deltaY = isMulti ? -3 : 0;
|
|
13920
13822
|
if (underline) {
|
|
13921
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
13922
|
-
const dy =
|
|
13923
|
-
context.moveTo(
|
|
13823
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
13824
|
+
const dy = y + offsetY + fontSize + underlineOffset + deltaY;
|
|
13825
|
+
context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
|
|
13924
13826
|
}
|
|
13925
|
-
if (lineThrough) {
|
|
13926
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
13927
|
-
const dy =
|
|
13928
|
-
context.moveTo(
|
|
13827
|
+
if (isMulti && (deltaY = -1), lineThrough) {
|
|
13828
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
|
|
13829
|
+
const dy = y + offsetY + fontSize / 2 + deltaY;
|
|
13830
|
+
context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
|
|
13929
13831
|
}
|
|
13930
13832
|
}
|
|
13931
13833
|
};
|
|
@@ -14220,10 +14122,12 @@
|
|
|
14220
14122
|
const {
|
|
14221
14123
|
image: url
|
|
14222
14124
|
} = image.attribute;
|
|
14223
|
-
if (!
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14125
|
+
if (!image.isGifImage) {
|
|
14126
|
+
if (!url || !image.resources) return;
|
|
14127
|
+
const res = image.resources.get(url);
|
|
14128
|
+
if ("loading" === res.state && isString$1(url)) return void ResourceLoader.improveImageLoading(url);
|
|
14129
|
+
if ("success" !== res.state) return;
|
|
14130
|
+
}
|
|
14227
14131
|
const {
|
|
14228
14132
|
context: context
|
|
14229
14133
|
} = renderService.drawParams;
|
|
@@ -14608,59 +14512,58 @@
|
|
|
14608
14512
|
constructor(fontFamily, options, textMeasure) {
|
|
14609
14513
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
14610
14514
|
}
|
|
14611
|
-
LayoutBBox(bbox, textAlign, textBaseline
|
|
14612
|
-
if (
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14515
|
+
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
14516
|
+
if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
|
|
14517
|
+
if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
|
|
14518
|
+
bbox.xOffset = -bbox.width;
|
|
14519
|
+
}
|
|
14520
|
+
return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
|
|
14521
|
+
}
|
|
14522
|
+
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
14523
|
+
const linesLayout = [],
|
|
14524
|
+
bboxWH = [width, height],
|
|
14525
|
+
bboxOffset = [0, 0];
|
|
14526
|
+
for (; str.length > 0;) {
|
|
14527
|
+
const {
|
|
14528
|
+
str: clipText
|
|
14529
|
+
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
14530
|
+
linesLayout.push({
|
|
14531
|
+
str: clipText,
|
|
14532
|
+
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
14533
|
+
}), str = str.substring(clipText.length);
|
|
14534
|
+
}
|
|
14535
|
+
"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]));
|
|
14536
|
+
const bbox = {
|
|
14537
|
+
xOffset: bboxOffset[0],
|
|
14538
|
+
yOffset: bboxOffset[1],
|
|
14539
|
+
width: bboxWH[0],
|
|
14540
|
+
height: bboxWH[1]
|
|
14541
|
+
};
|
|
14542
|
+
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14621
14543
|
}
|
|
14622
14544
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
14623
14545
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
14624
14546
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
14625
|
-
let
|
|
14626
|
-
|
|
14627
|
-
lineWidth: lineWidth,
|
|
14628
|
-
suffixPosition = "end",
|
|
14629
|
-
measureMode = exports.MeasureModeEnum.actualBounding,
|
|
14630
|
-
keepCenterInLine = !1
|
|
14631
|
-
} = null != params ? params : {};
|
|
14547
|
+
let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
|
|
14548
|
+
let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
|
|
14632
14549
|
lines = lines.map(l => l.toString());
|
|
14633
14550
|
const linesLayout = [],
|
|
14634
14551
|
bboxWH = [0, 0];
|
|
14635
14552
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
14636
14553
|
let width;
|
|
14637
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14638
|
-
|
|
14639
|
-
width
|
|
14640
|
-
|
|
14641
|
-
width: width,
|
|
14642
|
-
ascent: metrics.ascent,
|
|
14643
|
-
descent: metrics.descent,
|
|
14644
|
-
keepCenterInLine: keepCenterInLine
|
|
14645
|
-
});
|
|
14646
|
-
}
|
|
14554
|
+
for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
|
|
14555
|
+
str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
14556
|
+
width: width
|
|
14557
|
+
});
|
|
14647
14558
|
bboxWH[0] = lineWidth;
|
|
14648
14559
|
} else {
|
|
14649
|
-
let width,
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
str: text,
|
|
14657
|
-
width: width,
|
|
14658
|
-
ascent: metrics.ascent,
|
|
14659
|
-
descent: metrics.descent,
|
|
14660
|
-
keepCenterInLine: keepCenterInLine
|
|
14661
|
-
});
|
|
14662
|
-
}
|
|
14663
|
-
bboxWH[0] = _lineWidth;
|
|
14560
|
+
let width, text;
|
|
14561
|
+
lineWidth = 0;
|
|
14562
|
+
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({
|
|
14563
|
+
str: text,
|
|
14564
|
+
width: width
|
|
14565
|
+
});
|
|
14566
|
+
bboxWH[0] = lineWidth;
|
|
14664
14567
|
}
|
|
14665
14568
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
14666
14569
|
const bbox = {
|
|
@@ -14669,7 +14572,7 @@
|
|
|
14669
14572
|
width: bboxWH[0],
|
|
14670
14573
|
height: bboxWH[1]
|
|
14671
14574
|
};
|
|
14672
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline
|
|
14575
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14673
14576
|
}
|
|
14674
14577
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
14675
14578
|
const origin = [0, 0],
|
|
@@ -14688,19 +14591,11 @@
|
|
|
14688
14591
|
};
|
|
14689
14592
|
}
|
|
14690
14593
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
14691
|
-
|
|
14692
|
-
const buf = 0,
|
|
14693
|
-
actualHeightWithBuf = line.ascent + line.descent + buf;
|
|
14694
|
-
if (actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), "alphabetic" === textBaseline) {
|
|
14695
|
-
const ratio = lineHeight / (line.ascent + line.descent);
|
|
14696
|
-
line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 * ratio + origin[1];
|
|
14697
|
-
}
|
|
14698
|
-
}
|
|
14699
|
-
return origin[1] += lineHeight, line;
|
|
14594
|
+
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;
|
|
14700
14595
|
}
|
|
14701
14596
|
}
|
|
14702
14597
|
|
|
14703
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "
|
|
14598
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14704
14599
|
class Text extends Graphic {
|
|
14705
14600
|
get font() {
|
|
14706
14601
|
const textTheme = this.getGraphicTheme();
|
|
@@ -14709,22 +14604,26 @@
|
|
|
14709
14604
|
get clipedText() {
|
|
14710
14605
|
var _a;
|
|
14711
14606
|
const attribute = this.attribute,
|
|
14712
|
-
textTheme = this.getGraphicTheme()
|
|
14713
|
-
|
|
14714
|
-
|
|
14607
|
+
textTheme = this.getGraphicTheme();
|
|
14608
|
+
if (!this.isSimplify()) return;
|
|
14609
|
+
const {
|
|
14610
|
+
maxLineWidth = textTheme.maxLineWidth
|
|
14611
|
+
} = attribute;
|
|
14612
|
+
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14715
14613
|
}
|
|
14716
14614
|
get clipedWidth() {
|
|
14717
|
-
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14615
|
+
if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14718
14616
|
}
|
|
14719
14617
|
get cliped() {
|
|
14720
14618
|
var _a, _b;
|
|
14721
14619
|
const textTheme = this.getGraphicTheme(),
|
|
14722
14620
|
attribute = this.attribute,
|
|
14723
|
-
|
|
14724
|
-
|
|
14725
|
-
|
|
14726
|
-
|
|
14727
|
-
|
|
14621
|
+
{
|
|
14622
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14623
|
+
text: text,
|
|
14624
|
+
whiteSpace = textTheme.whiteSpace
|
|
14625
|
+
} = attribute;
|
|
14626
|
+
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
14728
14627
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
14729
14628
|
let mergedText = "";
|
|
14730
14629
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -14735,7 +14634,10 @@
|
|
|
14735
14634
|
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();
|
|
14736
14635
|
}
|
|
14737
14636
|
get multilineLayout() {
|
|
14738
|
-
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14637
|
+
if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14638
|
+
}
|
|
14639
|
+
isSimplify() {
|
|
14640
|
+
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
14739
14641
|
}
|
|
14740
14642
|
get isMultiLine() {
|
|
14741
14643
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -14808,74 +14710,8 @@
|
|
|
14808
14710
|
}
|
|
14809
14711
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
14810
14712
|
}
|
|
14811
|
-
updateSingallineAABBBounds(text) {
|
|
14812
|
-
this.updateMultilineAABBBounds([text]);
|
|
14813
|
-
const layoutData = this.cache.layoutData;
|
|
14814
|
-
if (layoutData && layoutData.lines && layoutData.lines.length) {
|
|
14815
|
-
const line = layoutData.lines[0];
|
|
14816
|
-
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
14817
|
-
}
|
|
14818
|
-
return this._AABBBounds;
|
|
14819
|
-
}
|
|
14820
|
-
updateMultilineAABBBounds(text) {
|
|
14821
|
-
const textTheme = this.getGraphicTheme(),
|
|
14822
|
-
{
|
|
14823
|
-
direction = textTheme.direction,
|
|
14824
|
-
underlineOffset = textTheme.underlineOffset
|
|
14825
|
-
} = this.attribute,
|
|
14826
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14827
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14828
|
-
}
|
|
14829
|
-
guessLineHeightBuf(fontSize) {
|
|
14830
|
-
return fontSize ? .1 * fontSize : 0;
|
|
14831
|
-
}
|
|
14832
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
14833
|
-
var _a;
|
|
14834
|
-
const textTheme = this.getGraphicTheme(),
|
|
14835
|
-
attribute = this.attribute,
|
|
14836
|
-
{
|
|
14837
|
-
fontFamily = textTheme.fontFamily,
|
|
14838
|
-
textAlign = textTheme.textAlign,
|
|
14839
|
-
textBaseline = textTheme.textBaseline,
|
|
14840
|
-
fontSize = textTheme.fontSize,
|
|
14841
|
-
fontWeight = textTheme.fontWeight,
|
|
14842
|
-
ellipsis = textTheme.ellipsis,
|
|
14843
|
-
maxLineWidth: maxLineWidth,
|
|
14844
|
-
stroke = textTheme.stroke,
|
|
14845
|
-
wrap = textTheme.wrap,
|
|
14846
|
-
measureMode = textTheme.measureMode,
|
|
14847
|
-
lineWidth = textTheme.lineWidth,
|
|
14848
|
-
whiteSpace = textTheme.whiteSpace,
|
|
14849
|
-
suffixPosition = textTheme.suffixPosition,
|
|
14850
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
14851
|
-
keepCenterInLine = textTheme.keepCenterInLine
|
|
14852
|
-
} = attribute,
|
|
14853
|
-
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
14854
|
-
lineHeight = this.getLineHeight(attribute, textTheme, buf);
|
|
14855
|
-
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
14856
|
-
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
14857
|
-
const bbox = this.cache.layoutData.bbox;
|
|
14858
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14859
|
-
}
|
|
14860
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
14861
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14862
|
-
fontSize: fontSize,
|
|
14863
|
-
fontWeight: fontWeight,
|
|
14864
|
-
fontFamily: fontFamily,
|
|
14865
|
-
lineHeight: lineHeight
|
|
14866
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
14867
|
-
lineWidth: maxLineWidth,
|
|
14868
|
-
suffixPosition: suffixPosition,
|
|
14869
|
-
measureMode: measureMode,
|
|
14870
|
-
keepCenterInLine: keepCenterInLine
|
|
14871
|
-
}),
|
|
14872
|
-
{
|
|
14873
|
-
bbox: bbox
|
|
14874
|
-
} = layoutData;
|
|
14875
|
-
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;
|
|
14876
|
-
}
|
|
14877
14713
|
updateWrapAABBBounds(text) {
|
|
14878
|
-
var _a, _b, _c;
|
|
14714
|
+
var _a, _b, _c, _d;
|
|
14879
14715
|
const textTheme = this.getGraphicTheme(),
|
|
14880
14716
|
{
|
|
14881
14717
|
fontFamily = textTheme.fontFamily,
|
|
@@ -14889,26 +14725,22 @@
|
|
|
14889
14725
|
wordBreak = textTheme.wordBreak,
|
|
14890
14726
|
fontWeight = textTheme.fontWeight,
|
|
14891
14727
|
ignoreBuf = textTheme.ignoreBuf,
|
|
14892
|
-
measureMode = textTheme.measureMode,
|
|
14893
14728
|
suffixPosition = textTheme.suffixPosition,
|
|
14894
14729
|
heightLimit = 0,
|
|
14895
|
-
lineClamp: lineClamp
|
|
14896
|
-
keepCenterInLine = textTheme.keepCenterInLine
|
|
14730
|
+
lineClamp: lineClamp
|
|
14897
14731
|
} = this.attribute,
|
|
14898
|
-
|
|
14899
|
-
|
|
14900
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
14732
|
+
lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
|
|
14733
|
+
buf = ignoreBuf ? 0 : 2;
|
|
14734
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
14901
14735
|
const bbox = this.cache.layoutData.bbox;
|
|
14902
14736
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14903
14737
|
}
|
|
14904
14738
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
14905
|
-
|
|
14739
|
+
layoutObj = new CanvasTextLayout(fontFamily, {
|
|
14906
14740
|
fontSize: fontSize,
|
|
14907
14741
|
fontWeight: fontWeight,
|
|
14908
|
-
fontFamily: fontFamily
|
|
14909
|
-
|
|
14910
|
-
},
|
|
14911
|
-
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
14742
|
+
fontFamily: fontFamily
|
|
14743
|
+
}, textMeasure),
|
|
14912
14744
|
lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
14913
14745
|
linesLayout = [],
|
|
14914
14746
|
bboxWH = [0, 0];
|
|
@@ -14918,37 +14750,29 @@
|
|
|
14918
14750
|
const str = lines[i];
|
|
14919
14751
|
let needCut = !0;
|
|
14920
14752
|
if (i === lineCountLimit - 1) {
|
|
14921
|
-
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1)
|
|
14922
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14753
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
|
|
14923
14754
|
linesLayout.push({
|
|
14924
14755
|
str: clip.str,
|
|
14925
|
-
width: clip.width
|
|
14926
|
-
ascent: matrics.ascent,
|
|
14927
|
-
descent: matrics.descent,
|
|
14928
|
-
keepCenterInLine: keepCenterInLine
|
|
14756
|
+
width: clip.width
|
|
14929
14757
|
});
|
|
14930
14758
|
break;
|
|
14931
14759
|
}
|
|
14932
|
-
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
14760
|
+
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
14933
14761
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
14934
14762
|
if (ellipsis) {
|
|
14935
|
-
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14936
|
-
clip.str = null !== (
|
|
14763
|
+
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14764
|
+
clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
|
|
14937
14765
|
} else clip.str = "", clip.width = 0;
|
|
14938
14766
|
needCut = !1;
|
|
14939
14767
|
}
|
|
14940
|
-
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14941
14768
|
linesLayout.push({
|
|
14942
14769
|
str: clip.str,
|
|
14943
|
-
width: clip.width
|
|
14944
|
-
ascent: matrics.ascent,
|
|
14945
|
-
descent: matrics.descent,
|
|
14946
|
-
keepCenterInLine: keepCenterInLine
|
|
14770
|
+
width: clip.width
|
|
14947
14771
|
});
|
|
14948
14772
|
let cutLength = clip.str.length;
|
|
14949
14773
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
14950
|
-
|
|
14951
|
-
lines.splice(i + 1, 0, newStr);
|
|
14774
|
+
let newStr = str.substring(cutLength);
|
|
14775
|
+
"keep-all" === wordBreak && (newStr = newStr.replace(/^\s+/g, "")), lines.splice(i + 1, 0, newStr);
|
|
14952
14776
|
}
|
|
14953
14777
|
}
|
|
14954
14778
|
let maxWidth = 0;
|
|
@@ -14961,46 +14785,235 @@
|
|
|
14961
14785
|
lineWidth = 0;
|
|
14962
14786
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14963
14787
|
if (i === lineCountLimit - 1) {
|
|
14964
|
-
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition)
|
|
14965
|
-
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14788
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14966
14789
|
linesLayout.push({
|
|
14967
14790
|
str: clip.str,
|
|
14968
|
-
width: clip.width
|
|
14969
|
-
ascent: matrics.ascent,
|
|
14970
|
-
descent: matrics.descent,
|
|
14971
|
-
keepCenterInLine: keepCenterInLine
|
|
14791
|
+
width: clip.width
|
|
14972
14792
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
14973
14793
|
break;
|
|
14974
14794
|
}
|
|
14975
|
-
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width)
|
|
14976
|
-
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
14977
|
-
linesLayout.push({
|
|
14795
|
+
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
14978
14796
|
str: text,
|
|
14979
|
-
width: width
|
|
14980
|
-
ascent: matrics.ascent,
|
|
14981
|
-
descent: matrics.descent,
|
|
14982
|
-
keepCenterInLine: keepCenterInLine
|
|
14797
|
+
width: width
|
|
14983
14798
|
});
|
|
14984
14799
|
}
|
|
14985
14800
|
bboxWH[0] = lineWidth;
|
|
14986
14801
|
}
|
|
14987
|
-
bboxWH[1] = linesLayout.length * lineHeight;
|
|
14802
|
+
bboxWH[1] = linesLayout.length * (lineHeight + buf);
|
|
14988
14803
|
const bbox = {
|
|
14989
14804
|
xOffset: 0,
|
|
14990
14805
|
yOffset: 0,
|
|
14991
14806
|
width: bboxWH[0],
|
|
14992
14807
|
height: bboxWH[1]
|
|
14993
14808
|
};
|
|
14994
|
-
layoutObj.LayoutBBox(bbox, textAlign, textBaseline
|
|
14809
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
14995
14810
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14996
14811
|
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;
|
|
14997
14812
|
}
|
|
14998
|
-
|
|
14813
|
+
updateSingallineAABBBounds(text) {
|
|
14814
|
+
const textTheme = this.getGraphicTheme(),
|
|
14815
|
+
{
|
|
14816
|
+
direction = textTheme.direction,
|
|
14817
|
+
underlineOffset = textTheme.underlineOffset
|
|
14818
|
+
} = this.attribute,
|
|
14819
|
+
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
14820
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14821
|
+
}
|
|
14822
|
+
updateMultilineAABBBounds(text) {
|
|
14823
|
+
const textTheme = this.getGraphicTheme(),
|
|
14824
|
+
{
|
|
14825
|
+
direction = textTheme.direction,
|
|
14826
|
+
underlineOffset = textTheme.underlineOffset
|
|
14827
|
+
} = this.attribute,
|
|
14828
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14829
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14830
|
+
}
|
|
14831
|
+
updateHorizontalSinglelineAABBBounds(text) {
|
|
14999
14832
|
var _a, _b;
|
|
14833
|
+
const textTheme = this.getGraphicTheme(),
|
|
14834
|
+
{
|
|
14835
|
+
wrap = textTheme.wrap
|
|
14836
|
+
} = this.attribute;
|
|
14837
|
+
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
14838
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
14839
|
+
let width, str;
|
|
14840
|
+
const attribute = this.attribute,
|
|
14841
|
+
{
|
|
14842
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14843
|
+
ellipsis = textTheme.ellipsis,
|
|
14844
|
+
textAlign = textTheme.textAlign,
|
|
14845
|
+
textBaseline = textTheme.textBaseline,
|
|
14846
|
+
fontFamily = textTheme.fontFamily,
|
|
14847
|
+
fontSize = textTheme.fontSize,
|
|
14848
|
+
fontWeight = textTheme.fontWeight,
|
|
14849
|
+
stroke = textTheme.stroke,
|
|
14850
|
+
lineWidth = textTheme.lineWidth,
|
|
14851
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
14852
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14853
|
+
suffixPosition = textTheme.suffixPosition
|
|
14854
|
+
} = attribute;
|
|
14855
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14856
|
+
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
14857
|
+
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
14858
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
14859
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
14860
|
+
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
14861
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14862
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14863
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14864
|
+
}
|
|
14865
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
14866
|
+
if (ellipsis) {
|
|
14867
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14868
|
+
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
14869
|
+
fontSize: fontSize,
|
|
14870
|
+
fontWeight: fontWeight,
|
|
14871
|
+
fontFamily: fontFamily
|
|
14872
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14873
|
+
str = data.str, width = data.width;
|
|
14874
|
+
} else {
|
|
14875
|
+
const data = textMeasure.clipText(text.toString(), {
|
|
14876
|
+
fontSize: fontSize,
|
|
14877
|
+
fontWeight: fontWeight,
|
|
14878
|
+
fontFamily: fontFamily
|
|
14879
|
+
}, maxLineWidth, !1);
|
|
14880
|
+
str = data.str, width = data.width;
|
|
14881
|
+
}
|
|
14882
|
+
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
14883
|
+
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
14884
|
+
fontSize: fontSize,
|
|
14885
|
+
fontWeight: fontWeight,
|
|
14886
|
+
fontFamily: fontFamily
|
|
14887
|
+
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
14888
|
+
this.clearUpdateShapeTag();
|
|
14889
|
+
const dx = textDrawOffsetX(textAlign, width);
|
|
14890
|
+
let lh = lineHeight;
|
|
14891
|
+
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
14892
|
+
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
14893
|
+
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14894
|
+
}
|
|
14895
|
+
getBaselineMapAlign() {
|
|
14896
|
+
return Text.baselineMapAlign;
|
|
14897
|
+
}
|
|
14898
|
+
getAlignMapBaseline() {
|
|
14899
|
+
return Text.alignMapBaseline;
|
|
14900
|
+
}
|
|
14901
|
+
updateVerticalSinglelineAABBBounds(text) {
|
|
14902
|
+
var _a, _b, _c;
|
|
15000
14903
|
const textTheme = this.getGraphicTheme(),
|
|
15001
14904
|
textMeasure = application.graphicUtil.textMeasure;
|
|
15002
14905
|
let width;
|
|
15003
14906
|
const attribute = this.attribute,
|
|
14907
|
+
{
|
|
14908
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
14909
|
+
} = attribute,
|
|
14910
|
+
buf = ignoreBuf ? 0 : 2,
|
|
14911
|
+
{
|
|
14912
|
+
maxLineWidth = textTheme.maxLineWidth,
|
|
14913
|
+
ellipsis = textTheme.ellipsis,
|
|
14914
|
+
fontSize = textTheme.fontSize,
|
|
14915
|
+
fontWeight = textTheme.fontWeight,
|
|
14916
|
+
fontFamily = textTheme.fontFamily,
|
|
14917
|
+
stroke = textTheme.stroke,
|
|
14918
|
+
lineWidth = textTheme.lineWidth,
|
|
14919
|
+
verticalMode = textTheme.verticalMode,
|
|
14920
|
+
suffixPosition = textTheme.suffixPosition
|
|
14921
|
+
} = attribute,
|
|
14922
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14923
|
+
let {
|
|
14924
|
+
textAlign = textTheme.textAlign,
|
|
14925
|
+
textBaseline = textTheme.textBaseline
|
|
14926
|
+
} = attribute;
|
|
14927
|
+
if (!verticalMode) {
|
|
14928
|
+
const t = textAlign;
|
|
14929
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
14930
|
+
}
|
|
14931
|
+
if (!this.shouldUpdateShape() && this.cache) {
|
|
14932
|
+
width = this.cache.clipedWidth;
|
|
14933
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14934
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14935
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14936
|
+
}
|
|
14937
|
+
let verticalList = [verticalLayout(text.toString())];
|
|
14938
|
+
if (Number.isFinite(maxLineWidth)) {
|
|
14939
|
+
if (ellipsis) {
|
|
14940
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14941
|
+
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
14942
|
+
fontSize: fontSize,
|
|
14943
|
+
fontWeight: fontWeight,
|
|
14944
|
+
fontFamily: fontFamily
|
|
14945
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14946
|
+
verticalList = [data.verticalList], width = data.width;
|
|
14947
|
+
} else {
|
|
14948
|
+
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
14949
|
+
fontSize: fontSize,
|
|
14950
|
+
fontWeight: fontWeight,
|
|
14951
|
+
fontFamily: fontFamily
|
|
14952
|
+
}, maxLineWidth, !1);
|
|
14953
|
+
verticalList = [data.verticalList], width = data.width;
|
|
14954
|
+
}
|
|
14955
|
+
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14956
|
+
} else width = 0, verticalList[0].forEach(t => {
|
|
14957
|
+
const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
14958
|
+
fontSize: fontSize,
|
|
14959
|
+
fontWeight: fontWeight,
|
|
14960
|
+
fontFamily: fontFamily
|
|
14961
|
+
});
|
|
14962
|
+
width += w, t.width = w;
|
|
14963
|
+
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14964
|
+
this.clearUpdateShapeTag();
|
|
14965
|
+
const dx = textDrawOffsetX(textAlign, width),
|
|
14966
|
+
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14967
|
+
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14968
|
+
}
|
|
14969
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
14970
|
+
var _a, _b;
|
|
14971
|
+
const textTheme = this.getGraphicTheme(),
|
|
14972
|
+
{
|
|
14973
|
+
wrap = textTheme.wrap
|
|
14974
|
+
} = this.attribute;
|
|
14975
|
+
if (wrap) return this.updateWrapAABBBounds(text);
|
|
14976
|
+
const attribute = this.attribute,
|
|
14977
|
+
{
|
|
14978
|
+
fontFamily = textTheme.fontFamily,
|
|
14979
|
+
textAlign = textTheme.textAlign,
|
|
14980
|
+
textBaseline = textTheme.textBaseline,
|
|
14981
|
+
fontSize = textTheme.fontSize,
|
|
14982
|
+
fontWeight = textTheme.fontWeight,
|
|
14983
|
+
ellipsis = textTheme.ellipsis,
|
|
14984
|
+
maxLineWidth: maxLineWidth,
|
|
14985
|
+
stroke = textTheme.stroke,
|
|
14986
|
+
lineWidth = textTheme.lineWidth,
|
|
14987
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14988
|
+
suffixPosition = textTheme.suffixPosition
|
|
14989
|
+
} = attribute,
|
|
14990
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
14991
|
+
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14992
|
+
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
14993
|
+
const bbox = this.cache.layoutData.bbox;
|
|
14994
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14995
|
+
}
|
|
14996
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
14997
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14998
|
+
fontSize: fontSize,
|
|
14999
|
+
fontWeight: fontWeight,
|
|
15000
|
+
fontFamily: fontFamily
|
|
15001
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
15002
|
+
{
|
|
15003
|
+
bbox: bbox
|
|
15004
|
+
} = layoutData;
|
|
15005
|
+
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;
|
|
15006
|
+
}
|
|
15007
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
15008
|
+
var _a, _b, _c;
|
|
15009
|
+
const textTheme = this.getGraphicTheme(),
|
|
15010
|
+
textMeasure = application.graphicUtil.textMeasure;
|
|
15011
|
+
let width;
|
|
15012
|
+
const attribute = this.attribute,
|
|
15013
|
+
{
|
|
15014
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
15015
|
+
} = attribute,
|
|
15016
|
+
buf = ignoreBuf ? 0 : 2,
|
|
15004
15017
|
{
|
|
15005
15018
|
maxLineWidth = textTheme.maxLineWidth,
|
|
15006
15019
|
ellipsis = textTheme.ellipsis,
|
|
@@ -15012,14 +15025,14 @@
|
|
|
15012
15025
|
verticalMode = textTheme.verticalMode,
|
|
15013
15026
|
suffixPosition = textTheme.suffixPosition
|
|
15014
15027
|
} = attribute,
|
|
15015
|
-
lineHeight =
|
|
15028
|
+
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
15016
15029
|
let {
|
|
15017
15030
|
textAlign = textTheme.textAlign,
|
|
15018
15031
|
textBaseline = textTheme.textBaseline
|
|
15019
15032
|
} = attribute;
|
|
15020
15033
|
if (!verticalMode) {
|
|
15021
15034
|
const t = textAlign;
|
|
15022
|
-
textAlign = null !== (
|
|
15035
|
+
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
15023
15036
|
}
|
|
15024
15037
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
15025
15038
|
this.cache.verticalList.forEach(item => {
|
|
@@ -15067,15 +15080,6 @@
|
|
|
15067
15080
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
15068
15081
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
15069
15082
|
}
|
|
15070
|
-
getMaxWidth(theme) {
|
|
15071
|
-
var _a, _b;
|
|
15072
|
-
const attribute = this.attribute;
|
|
15073
|
-
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
15074
|
-
}
|
|
15075
|
-
getLineHeight(attribute, textTheme, buf) {
|
|
15076
|
-
var _a;
|
|
15077
|
-
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
15078
|
-
}
|
|
15079
15083
|
needUpdateTags(keys) {
|
|
15080
15084
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
15081
15085
|
return super.needUpdateTags(keys, k);
|
|
@@ -15090,12 +15094,6 @@
|
|
|
15090
15094
|
getNoWorkAnimateAttr() {
|
|
15091
15095
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
15092
15096
|
}
|
|
15093
|
-
getBaselineMapAlign() {
|
|
15094
|
-
return Text.baselineMapAlign;
|
|
15095
|
-
}
|
|
15096
|
-
getAlignMapBaseline() {
|
|
15097
|
-
return Text.alignMapBaseline;
|
|
15098
|
-
}
|
|
15099
15097
|
}
|
|
15100
15098
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
15101
15099
|
ellipsis: 1,
|
|
@@ -15174,10 +15172,7 @@
|
|
|
15174
15172
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15175
15173
|
linesLayout.push({
|
|
15176
15174
|
str: clip.str,
|
|
15177
|
-
width: clip.width
|
|
15178
|
-
ascent: 0,
|
|
15179
|
-
descent: 0,
|
|
15180
|
-
keepCenterInLine: !1
|
|
15175
|
+
width: clip.width
|
|
15181
15176
|
});
|
|
15182
15177
|
break;
|
|
15183
15178
|
}
|
|
@@ -15191,10 +15186,7 @@
|
|
|
15191
15186
|
}
|
|
15192
15187
|
if (linesLayout.push({
|
|
15193
15188
|
str: clip.str,
|
|
15194
|
-
width: clip.width
|
|
15195
|
-
ascent: 0,
|
|
15196
|
-
descent: 0,
|
|
15197
|
-
keepCenterInLine: !1
|
|
15189
|
+
width: clip.width
|
|
15198
15190
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
15199
15191
|
const newStr = str.substring(clip.str.length);
|
|
15200
15192
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -15213,19 +15205,13 @@
|
|
|
15213
15205
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15214
15206
|
linesLayout.push({
|
|
15215
15207
|
str: clip.str,
|
|
15216
|
-
width: clip.width
|
|
15217
|
-
ascent: 0,
|
|
15218
|
-
descent: 0,
|
|
15219
|
-
keepCenterInLine: !1
|
|
15208
|
+
width: clip.width
|
|
15220
15209
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
15221
15210
|
break;
|
|
15222
15211
|
}
|
|
15223
15212
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
15224
15213
|
str: text,
|
|
15225
|
-
width: width
|
|
15226
|
-
ascent: 0,
|
|
15227
|
-
descent: 0,
|
|
15228
|
-
keepCenterInLine: !1
|
|
15214
|
+
width: width
|
|
15229
15215
|
});
|
|
15230
15216
|
}
|
|
15231
15217
|
bboxWH[0] = lineWidth;
|
|
@@ -15269,9 +15255,6 @@
|
|
|
15269
15255
|
bounds.x1 = -halfS, bounds.x2 = halfS, bounds.y1 = -halfS, bounds.y2 = halfS;
|
|
15270
15256
|
} else bounds.x1 = -size[0] / 2, bounds.x2 = size[0] / 2, bounds.y1 = -size[1] / 2, bounds.y2 = size[1] / 2;
|
|
15271
15257
|
}
|
|
15272
|
-
parseSize(size) {
|
|
15273
|
-
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15274
|
-
}
|
|
15275
15258
|
}
|
|
15276
15259
|
|
|
15277
15260
|
function circle(ctx, r, x, y, z) {
|
|
@@ -15282,13 +15265,13 @@
|
|
|
15282
15265
|
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";
|
|
15283
15266
|
}
|
|
15284
15267
|
draw(ctx, size, x, y, z) {
|
|
15285
|
-
return circle(ctx,
|
|
15268
|
+
return circle(ctx, size / 2, x, y, z);
|
|
15286
15269
|
}
|
|
15287
15270
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15288
|
-
return circle(ctx,
|
|
15271
|
+
return circle(ctx, size / 2 + offset, x, y, z);
|
|
15289
15272
|
}
|
|
15290
15273
|
drawToSvgPath(size, x, y, z) {
|
|
15291
|
-
const r =
|
|
15274
|
+
const r = size / 2;
|
|
15292
15275
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${2 * r},0 a ${r},${r} 0 1,0 -${2 * r},0`;
|
|
15293
15276
|
}
|
|
15294
15277
|
}
|
|
@@ -15305,10 +15288,10 @@
|
|
|
15305
15288
|
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";
|
|
15306
15289
|
}
|
|
15307
15290
|
draw(ctx, size, x, y, z) {
|
|
15308
|
-
return cross(ctx,
|
|
15291
|
+
return cross(ctx, size / 6, x, y, z);
|
|
15309
15292
|
}
|
|
15310
15293
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15311
|
-
return crossOffset(ctx,
|
|
15294
|
+
return crossOffset(ctx, size / 6, x, y, offset, z);
|
|
15312
15295
|
}
|
|
15313
15296
|
}
|
|
15314
15297
|
var cross$1 = new CrossSymbol();
|
|
@@ -15321,13 +15304,13 @@
|
|
|
15321
15304
|
super(...arguments), this.type = "diamond", this.pathStr = "M-0.5,0L0,-0.5L0.5,0L0,0.5Z";
|
|
15322
15305
|
}
|
|
15323
15306
|
draw(ctx, size, x, y, z) {
|
|
15324
|
-
return diamond(ctx,
|
|
15307
|
+
return diamond(ctx, size / 2, x, y, z);
|
|
15325
15308
|
}
|
|
15326
15309
|
drawFitDir(ctx, size, x, y, z) {
|
|
15327
|
-
return diamond(ctx,
|
|
15310
|
+
return diamond(ctx, size / 2, x, y, z);
|
|
15328
15311
|
}
|
|
15329
15312
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15330
|
-
return diamond(ctx,
|
|
15313
|
+
return diamond(ctx, size / 2 + offset, x, y, z);
|
|
15331
15314
|
}
|
|
15332
15315
|
}
|
|
15333
15316
|
var diamond$1 = new DiamondSymbol();
|
|
@@ -15341,10 +15324,10 @@
|
|
|
15341
15324
|
super(...arguments), this.type = "square", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
|
|
15342
15325
|
}
|
|
15343
15326
|
draw(ctx, size, x, y) {
|
|
15344
|
-
return square(ctx,
|
|
15327
|
+
return square(ctx, size / 2, x, y);
|
|
15345
15328
|
}
|
|
15346
15329
|
drawOffset(ctx, size, x, y, offset) {
|
|
15347
|
-
return square(ctx,
|
|
15330
|
+
return square(ctx, size / 2 + offset, x, y);
|
|
15348
15331
|
}
|
|
15349
15332
|
}
|
|
15350
15333
|
var square$1 = new SquareSymbol();
|
|
@@ -15358,10 +15341,10 @@
|
|
|
15358
15341
|
super(...arguments), this.type = "triangleUp", this.pathStr = "M0.5,0.5 L-0.5,0.5 L0,-0.5 Z";
|
|
15359
15342
|
}
|
|
15360
15343
|
draw(ctx, size, x, y) {
|
|
15361
|
-
return trianglUpOffset(ctx,
|
|
15344
|
+
return trianglUpOffset(ctx, size / 2, x, y);
|
|
15362
15345
|
}
|
|
15363
15346
|
drawOffset(ctx, size, x, y, offset) {
|
|
15364
|
-
return trianglUpOffset(ctx,
|
|
15347
|
+
return trianglUpOffset(ctx, size / 2, x, y, offset);
|
|
15365
15348
|
}
|
|
15366
15349
|
}
|
|
15367
15350
|
var triangleUp = new TriangleUpSymbol();
|
|
@@ -15393,10 +15376,10 @@
|
|
|
15393
15376
|
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";
|
|
15394
15377
|
}
|
|
15395
15378
|
draw(ctx, size, transX, transY) {
|
|
15396
|
-
return star(ctx,
|
|
15379
|
+
return star(ctx, size / 2, transX, transY);
|
|
15397
15380
|
}
|
|
15398
15381
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15399
|
-
return star(ctx,
|
|
15382
|
+
return star(ctx, size / 2 + offset, transX, transY);
|
|
15400
15383
|
}
|
|
15401
15384
|
}
|
|
15402
15385
|
var star$1 = new StarSymbol();
|
|
@@ -15414,10 +15397,10 @@
|
|
|
15414
15397
|
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";
|
|
15415
15398
|
}
|
|
15416
15399
|
draw(ctx, size, transX, transY) {
|
|
15417
|
-
return arrow(ctx,
|
|
15400
|
+
return arrow(ctx, size / 2, transX, transY);
|
|
15418
15401
|
}
|
|
15419
15402
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15420
|
-
return arrow(ctx,
|
|
15403
|
+
return arrow(ctx, size / 2 + offset, transX, transY);
|
|
15421
15404
|
}
|
|
15422
15405
|
}
|
|
15423
15406
|
var arrow$1 = new ArrowSymbol();
|
|
@@ -15431,10 +15414,10 @@
|
|
|
15431
15414
|
super(...arguments), this.type = "wedge", this.pathStr = "M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z";
|
|
15432
15415
|
}
|
|
15433
15416
|
draw(ctx, size, transX, transY) {
|
|
15434
|
-
return wedge(ctx,
|
|
15417
|
+
return wedge(ctx, size / 2, transX, transY);
|
|
15435
15418
|
}
|
|
15436
15419
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15437
|
-
return wedge(ctx,
|
|
15420
|
+
return wedge(ctx, size / 2 + offset, transX, transY);
|
|
15438
15421
|
}
|
|
15439
15422
|
}
|
|
15440
15423
|
var wedge$1 = new WedgeSymbol();
|
|
@@ -15447,10 +15430,10 @@
|
|
|
15447
15430
|
super(...arguments), this.type = "stroke", this.pathStr = "";
|
|
15448
15431
|
}
|
|
15449
15432
|
draw(ctx, size, transX, transY) {
|
|
15450
|
-
return stroke(ctx,
|
|
15433
|
+
return stroke(ctx, size / 2, transX, transY);
|
|
15451
15434
|
}
|
|
15452
15435
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15453
|
-
return stroke(ctx,
|
|
15436
|
+
return stroke(ctx, size / 2 + offset, transX, transY);
|
|
15454
15437
|
}
|
|
15455
15438
|
}
|
|
15456
15439
|
var stroke$1 = new StrokeSymbol();
|
|
@@ -15472,10 +15455,10 @@
|
|
|
15472
15455
|
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";
|
|
15473
15456
|
}
|
|
15474
15457
|
draw(ctx, size, transX, transY) {
|
|
15475
|
-
return wye(ctx,
|
|
15458
|
+
return wye(ctx, size / 2, transX, transY);
|
|
15476
15459
|
}
|
|
15477
15460
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15478
|
-
return wye(ctx,
|
|
15461
|
+
return wye(ctx, size / 2 + offset, transX, transY);
|
|
15479
15462
|
}
|
|
15480
15463
|
}
|
|
15481
15464
|
var wye$1 = new WyeSymbol();
|
|
@@ -15488,10 +15471,10 @@
|
|
|
15488
15471
|
super(...arguments), this.type = "triangleLeft", this.pathStr = "M-0.5,0 L0.5,0.5 L0.5,-0.5 Z";
|
|
15489
15472
|
}
|
|
15490
15473
|
draw(ctx, size, x, y) {
|
|
15491
|
-
return trianglLeftOffset(ctx,
|
|
15474
|
+
return trianglLeftOffset(ctx, size / 2, x, y, 0);
|
|
15492
15475
|
}
|
|
15493
15476
|
drawOffset(ctx, size, x, y, offset) {
|
|
15494
|
-
return trianglLeftOffset(ctx,
|
|
15477
|
+
return trianglLeftOffset(ctx, size / 2, x, y, offset);
|
|
15495
15478
|
}
|
|
15496
15479
|
}
|
|
15497
15480
|
var triangleLeft = new TriangleLeftSymbol();
|
|
@@ -15505,10 +15488,10 @@
|
|
|
15505
15488
|
super(...arguments), this.type = "triangleRight", this.pathStr = "M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z";
|
|
15506
15489
|
}
|
|
15507
15490
|
draw(ctx, size, x, y) {
|
|
15508
|
-
return trianglRightOffset(ctx,
|
|
15491
|
+
return trianglRightOffset(ctx, size / 2, x, y);
|
|
15509
15492
|
}
|
|
15510
15493
|
drawOffset(ctx, size, x, y, offset) {
|
|
15511
|
-
return trianglRightOffset(ctx,
|
|
15494
|
+
return trianglRightOffset(ctx, size / 2, x, y, offset);
|
|
15512
15495
|
}
|
|
15513
15496
|
}
|
|
15514
15497
|
var triangleRight = new TriangleRightSymbol();
|
|
@@ -15522,10 +15505,10 @@
|
|
|
15522
15505
|
super(...arguments), this.type = "triangleDown", this.pathStr = "M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z";
|
|
15523
15506
|
}
|
|
15524
15507
|
draw(ctx, size, x, y) {
|
|
15525
|
-
return trianglDownOffset(ctx,
|
|
15508
|
+
return trianglDownOffset(ctx, size / 2, x, y);
|
|
15526
15509
|
}
|
|
15527
15510
|
drawOffset(ctx, size, x, y, offset) {
|
|
15528
|
-
return trianglDownOffset(ctx,
|
|
15511
|
+
return trianglDownOffset(ctx, size / 2, x, y, offset);
|
|
15529
15512
|
}
|
|
15530
15513
|
}
|
|
15531
15514
|
var triangleDown = new TriangleDownSymbol();
|
|
@@ -15540,10 +15523,10 @@
|
|
|
15540
15523
|
super(...arguments), this.type = "thinTriangle", this.pathStr = "M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z";
|
|
15541
15524
|
}
|
|
15542
15525
|
draw(ctx, size, x, y) {
|
|
15543
|
-
return thinTriangle(ctx,
|
|
15526
|
+
return thinTriangle(ctx, size / 2 / sqrt3, x, y);
|
|
15544
15527
|
}
|
|
15545
15528
|
drawOffset(ctx, size, x, y, offset) {
|
|
15546
|
-
return thinTriangle(ctx,
|
|
15529
|
+
return thinTriangle(ctx, size / 2 / sqrt3 + offset, x, y);
|
|
15547
15530
|
}
|
|
15548
15531
|
}
|
|
15549
15532
|
var thinTriangle$1 = new ThinTriangleSymbol();
|
|
@@ -15557,10 +15540,10 @@
|
|
|
15557
15540
|
super(...arguments), this.type = "arrow2Left", this.pathStr = "M 0.25 -0.5 L -0.25 0 l 0.25 0.5";
|
|
15558
15541
|
}
|
|
15559
15542
|
draw(ctx, size, transX, transY) {
|
|
15560
|
-
return arrow2Left(ctx,
|
|
15543
|
+
return arrow2Left(ctx, size / 4, transX, transY);
|
|
15561
15544
|
}
|
|
15562
15545
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15563
|
-
return arrow2Left(ctx,
|
|
15546
|
+
return arrow2Left(ctx, size / 4 + offset, transX, transY);
|
|
15564
15547
|
}
|
|
15565
15548
|
}
|
|
15566
15549
|
var arrow2Left$1 = new Arrow2LeftSymbol();
|
|
@@ -15574,10 +15557,10 @@
|
|
|
15574
15557
|
super(...arguments), this.type = "arrow2Right", this.pathStr = "M -0.25 -0.5 l 0.25 0 l -0.25 0.5";
|
|
15575
15558
|
}
|
|
15576
15559
|
draw(ctx, size, transX, transY) {
|
|
15577
|
-
return arrow2Right(ctx,
|
|
15560
|
+
return arrow2Right(ctx, size / 4, transX, transY);
|
|
15578
15561
|
}
|
|
15579
15562
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15580
|
-
return arrow2Right(ctx,
|
|
15563
|
+
return arrow2Right(ctx, size / 4 + offset, transX, transY);
|
|
15581
15564
|
}
|
|
15582
15565
|
}
|
|
15583
15566
|
var arrow2Right$1 = new Arrow2RightSymbol();
|
|
@@ -15591,10 +15574,10 @@
|
|
|
15591
15574
|
super(...arguments), this.type = "arrow2Up", this.pathStr = "M -0.5 0.25 L 0 -0.25 l 0.5 0.25";
|
|
15592
15575
|
}
|
|
15593
15576
|
draw(ctx, size, transX, transY) {
|
|
15594
|
-
return arrow2Up(ctx,
|
|
15577
|
+
return arrow2Up(ctx, size / 4, transX, transY);
|
|
15595
15578
|
}
|
|
15596
15579
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15597
|
-
return arrow2Up(ctx,
|
|
15580
|
+
return arrow2Up(ctx, size / 4 + offset, transX, transY);
|
|
15598
15581
|
}
|
|
15599
15582
|
}
|
|
15600
15583
|
var arrow2Up$1 = new Arrow2UpSymbol();
|
|
@@ -15608,10 +15591,10 @@
|
|
|
15608
15591
|
super(...arguments), this.type = "arrow2Down", this.pathStr = "M -0.5 -0.25 L 0 0.25 l 0.5 -0.25";
|
|
15609
15592
|
}
|
|
15610
15593
|
draw(ctx, size, transX, transY) {
|
|
15611
|
-
return arrow2Down(ctx,
|
|
15594
|
+
return arrow2Down(ctx, size / 4, transX, transY);
|
|
15612
15595
|
}
|
|
15613
15596
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
15614
|
-
return arrow2Down(ctx,
|
|
15597
|
+
return arrow2Down(ctx, size / 4 + offset, transX, transY);
|
|
15615
15598
|
}
|
|
15616
15599
|
}
|
|
15617
15600
|
var arrow2Down$1 = new Arrow2DownSymbol();
|
|
@@ -15624,13 +15607,13 @@
|
|
|
15624
15607
|
super(...arguments), this.type = "lineV", this.pathStr = "M0,-0.5L0,0.5";
|
|
15625
15608
|
}
|
|
15626
15609
|
draw(ctx, size, x, y, z) {
|
|
15627
|
-
return lineV(ctx,
|
|
15610
|
+
return lineV(ctx, size / 2, x, y);
|
|
15628
15611
|
}
|
|
15629
15612
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15630
|
-
return lineV(ctx,
|
|
15613
|
+
return lineV(ctx, size / 2 + offset, x, y);
|
|
15631
15614
|
}
|
|
15632
15615
|
drawToSvgPath(size, x, y, z) {
|
|
15633
|
-
const r =
|
|
15616
|
+
const r = size / 2;
|
|
15634
15617
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
15635
15618
|
}
|
|
15636
15619
|
}
|
|
@@ -15644,13 +15627,13 @@
|
|
|
15644
15627
|
super(...arguments), this.type = "lineH", this.pathStr = "M-0.5,0L0.5,0";
|
|
15645
15628
|
}
|
|
15646
15629
|
draw(ctx, size, x, y, z) {
|
|
15647
|
-
return lineH(ctx,
|
|
15630
|
+
return lineH(ctx, size / 2, x, y);
|
|
15648
15631
|
}
|
|
15649
15632
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15650
|
-
return lineH(ctx,
|
|
15633
|
+
return lineH(ctx, size / 2 + offset, x, y);
|
|
15651
15634
|
}
|
|
15652
15635
|
drawToSvgPath(size, x, y, z) {
|
|
15653
|
-
const r =
|
|
15636
|
+
const r = size / 2;
|
|
15654
15637
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
15655
15638
|
}
|
|
15656
15639
|
}
|
|
@@ -15664,13 +15647,13 @@
|
|
|
15664
15647
|
super(...arguments), this.type = "close", this.pathStr = "M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5";
|
|
15665
15648
|
}
|
|
15666
15649
|
draw(ctx, size, x, y, z) {
|
|
15667
|
-
return close(ctx,
|
|
15650
|
+
return close(ctx, size / 2, x, y);
|
|
15668
15651
|
}
|
|
15669
15652
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
15670
|
-
return close(ctx,
|
|
15653
|
+
return close(ctx, size / 2 + offset, x, y);
|
|
15671
15654
|
}
|
|
15672
15655
|
drawToSvgPath(size, x, y, z) {
|
|
15673
|
-
const r =
|
|
15656
|
+
const r = size / 2;
|
|
15674
15657
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
15675
15658
|
}
|
|
15676
15659
|
}
|
|
@@ -15704,18 +15687,15 @@
|
|
|
15704
15687
|
this.pathStr = "", this.type = type, isArray$1(path) ? this.svgCache = path : this.path = path, this.isSvg = isSvg;
|
|
15705
15688
|
}
|
|
15706
15689
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
15707
|
-
return
|
|
15690
|
+
return this.isSvg ? !!this.svgCache && (this.svgCache.forEach(item => {
|
|
15708
15691
|
ctx.beginPath(), renderCommandList(item.path.commandList, ctx, x, y, size, size), cb && cb(item.path, item.attribute);
|
|
15709
15692
|
}), !1) : (renderCommandList(this.path.commandList, ctx, x, y, size + offset, size + offset), !1);
|
|
15710
15693
|
}
|
|
15711
15694
|
draw(ctx, size, x, y, z, cb) {
|
|
15712
|
-
return
|
|
15713
|
-
}
|
|
15714
|
-
parseSize(size) {
|
|
15715
|
-
return isNumber$1(size) ? size : Math.min(size[0], size[1]);
|
|
15695
|
+
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
15716
15696
|
}
|
|
15717
15697
|
bounds(size, bounds) {
|
|
15718
|
-
if (
|
|
15698
|
+
if (this.isSvg) {
|
|
15719
15699
|
if (!this.svgCache) return;
|
|
15720
15700
|
return bounds.clear(), void this.svgCache.forEach(_ref => {
|
|
15721
15701
|
let {
|
|
@@ -16398,11 +16378,7 @@
|
|
|
16398
16378
|
case "sub":
|
|
16399
16379
|
baseline += this.descent / 2;
|
|
16400
16380
|
}
|
|
16401
|
-
"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);
|
|
16402
|
-
const {
|
|
16403
|
-
lineWidth = 1
|
|
16404
|
-
} = this.character;
|
|
16405
|
-
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();
|
|
16381
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
16406
16382
|
}
|
|
16407
16383
|
getWidthWithEllips(direction) {
|
|
16408
16384
|
let text = this.text;
|
|
@@ -18619,7 +18595,7 @@
|
|
|
18619
18595
|
constructor() {
|
|
18620
18596
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18621
18597
|
var _a;
|
|
18622
|
-
super({}), this.
|
|
18598
|
+
super({}), this._onVisibleChange = visible => {
|
|
18623
18599
|
if (!(this._skipRender < 0)) if (visible) {
|
|
18624
18600
|
if (this.dirtyBounds) {
|
|
18625
18601
|
const b = this.window.getViewBox();
|
|
@@ -18630,10 +18606,7 @@
|
|
|
18630
18606
|
}, this.beforeRender = stage => {
|
|
18631
18607
|
this._beforeRender && this._beforeRender(stage);
|
|
18632
18608
|
}, this.afterRender = stage => {
|
|
18633
|
-
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null
|
|
18634
|
-
}, this.afterTickCb = () => {
|
|
18635
|
-
var _a;
|
|
18636
|
-
this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
|
|
18609
|
+
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
|
|
18637
18610
|
}, this.params = params, this.theme = new Theme(), this.hooks = {
|
|
18638
18611
|
beforeRender: new SyncHook(["stage"]),
|
|
18639
18612
|
afterRender: new SyncHook(["stage"])
|
|
@@ -18650,7 +18623,7 @@
|
|
|
18650
18623
|
main: !0
|
|
18651
18624
|
})), 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({
|
|
18652
18625
|
background: this._background
|
|
18653
|
-
})
|
|
18626
|
+
});
|
|
18654
18627
|
}
|
|
18655
18628
|
pauseRender() {
|
|
18656
18629
|
let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
@@ -18879,7 +18852,7 @@
|
|
|
18879
18852
|
if ("released" === this.releaseStatus) return;
|
|
18880
18853
|
this.ticker.start(), this.timeline.resume();
|
|
18881
18854
|
const state = this.state;
|
|
18882
|
-
this.state = "rendering", this.
|
|
18855
|
+
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++;
|
|
18883
18856
|
}
|
|
18884
18857
|
combineLayersToWindow() {
|
|
18885
18858
|
if ("harmony" === this.global.env) {
|
|
@@ -18985,7 +18958,7 @@
|
|
|
18985
18958
|
layer.release();
|
|
18986
18959
|
}), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
|
|
18987
18960
|
item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
|
|
18988
|
-
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.
|
|
18961
|
+
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
|
|
18989
18962
|
}
|
|
18990
18963
|
setStage(stage) {}
|
|
18991
18964
|
dirty(b, matrix) {
|
|
@@ -19063,6 +19036,8 @@
|
|
|
19063
19036
|
return new Stage(params);
|
|
19064
19037
|
}
|
|
19065
19038
|
|
|
19039
|
+
const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
|
|
19040
|
+
|
|
19066
19041
|
var __decorate$1d = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
19067
19042
|
var d,
|
|
19068
19043
|
c = arguments.length,
|
|
@@ -23683,9 +23658,11 @@
|
|
|
23683
23658
|
name: name,
|
|
23684
23659
|
id: id,
|
|
23685
23660
|
attribute: attribute,
|
|
23686
|
-
stateProxy: stateProxy
|
|
23661
|
+
stateProxy: stateProxy,
|
|
23662
|
+
animation: animation,
|
|
23663
|
+
timeline: timeline
|
|
23687
23664
|
} = _a,
|
|
23688
|
-
props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy"]);
|
|
23665
|
+
props = __rest(_a, ["key", "name", "id", "attribute", "stateProxy", "animation", "timeline"]);
|
|
23689
23666
|
let c = type;
|
|
23690
23667
|
isString$1(type) && (c = graphicCreator[type]);
|
|
23691
23668
|
const childrenList = [];
|
|
@@ -23694,7 +23671,13 @@
|
|
|
23694
23671
|
}
|
|
23695
23672
|
children.length && flatten(1 === children.length ? children[0] : children, childrenList);
|
|
23696
23673
|
const g = "Group" === c.name ? new c(attribute) : c(config);
|
|
23697
|
-
|
|
23674
|
+
if (parseToGraphic$1(g, childrenList, props), stateProxy && (g.stateProxy = stateProxy), name && (g.name = name), isArray$1(animation)) {
|
|
23675
|
+
const animate = g.animate();
|
|
23676
|
+
timeline && animate.setTimeline(timeline), animation.forEach(item => {
|
|
23677
|
+
animate[item[0]](...item.slice(1));
|
|
23678
|
+
});
|
|
23679
|
+
}
|
|
23680
|
+
return g;
|
|
23698
23681
|
}
|
|
23699
23682
|
function parseToGraphic$1(g, childrenList, props) {
|
|
23700
23683
|
let out,
|
|
@@ -23962,7 +23945,7 @@
|
|
|
23962
23945
|
startTime: startTime,
|
|
23963
23946
|
startPoints: startPoints
|
|
23964
23947
|
} = this;
|
|
23965
|
-
if (
|
|
23948
|
+
if (eventType) return eventType;
|
|
23966
23949
|
let type;
|
|
23967
23950
|
return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
|
|
23968
23951
|
}
|
|
@@ -24494,10 +24477,9 @@
|
|
|
24494
24477
|
lineJoin = defaultParams.lineJoin,
|
|
24495
24478
|
lineDash = defaultParams.lineDash,
|
|
24496
24479
|
lineCap = defaultParams.lineCap,
|
|
24497
|
-
miterLimit = defaultParams.miterLimit
|
|
24498
|
-
keepStrokeScale = defaultParams.keepStrokeScale
|
|
24480
|
+
miterLimit = defaultParams.miterLimit
|
|
24499
24481
|
} = attribute;
|
|
24500
|
-
_context.lineWidth =
|
|
24482
|
+
_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;
|
|
24501
24483
|
}
|
|
24502
24484
|
}
|
|
24503
24485
|
setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
|
|
@@ -24921,7 +24903,7 @@
|
|
|
24921
24903
|
function createImageElement$1(src) {
|
|
24922
24904
|
let isSvg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
24923
24905
|
const img = document.createElement("img");
|
|
24924
|
-
if (img.crossOrigin = "anonymous", isSvg) {
|
|
24906
|
+
if (application.global.isImageAnonymous && (img.crossOrigin = "anonymous"), isSvg) {
|
|
24925
24907
|
const data = new Blob([src], {
|
|
24926
24908
|
type: "image/svg+xml"
|
|
24927
24909
|
});
|
|
@@ -25397,9 +25379,8 @@
|
|
|
25397
25379
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
25398
25380
|
if (picked) return !0;
|
|
25399
25381
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25400
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25401
|
-
|
|
25402
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25382
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
25383
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25403
25384
|
}), pickContext.highPerformanceRestore(), picked;
|
|
25404
25385
|
}
|
|
25405
25386
|
}
|
|
@@ -25672,9 +25653,8 @@
|
|
|
25672
25653
|
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) => {
|
|
25673
25654
|
if (picked) return !0;
|
|
25674
25655
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25675
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25676
|
-
|
|
25677
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25656
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
25657
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25678
25658
|
});else {
|
|
25679
25659
|
const {
|
|
25680
25660
|
fill = rectAttribute.fill,
|
|
@@ -25988,10 +25968,9 @@
|
|
|
25988
25968
|
lineJoin = defaultParams.lineJoin,
|
|
25989
25969
|
lineDash = defaultParams.lineDash,
|
|
25990
25970
|
lineCap = defaultParams.lineCap,
|
|
25991
|
-
miterLimit = defaultParams.miterLimit
|
|
25992
|
-
keepStrokeScale = defaultParams.keepStrokeScale
|
|
25971
|
+
miterLimit = defaultParams.miterLimit
|
|
25993
25972
|
} = attribute;
|
|
25994
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth =
|
|
25973
|
+
_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;
|
|
25995
25974
|
}
|
|
25996
25975
|
}
|
|
25997
25976
|
measureText(text) {
|
|
@@ -26619,10 +26598,9 @@
|
|
|
26619
26598
|
lineJoin = defaultParams.lineJoin,
|
|
26620
26599
|
lineDash = defaultParams.lineDash,
|
|
26621
26600
|
lineCap = defaultParams.lineCap,
|
|
26622
|
-
miterLimit = defaultParams.miterLimit
|
|
26623
|
-
keepStrokeScale = defaultParams.keepStrokeScale
|
|
26601
|
+
miterLimit = defaultParams.miterLimit
|
|
26624
26602
|
} = attribute;
|
|
26625
|
-
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(
|
|
26603
|
+
_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);
|
|
26626
26604
|
}
|
|
26627
26605
|
}
|
|
26628
26606
|
setTextStyleWithoutAlignBaseline(params, defaultParams) {
|
|
@@ -27662,10 +27640,9 @@
|
|
|
27662
27640
|
lineJoin = defaultParams.lineJoin,
|
|
27663
27641
|
lineDash = defaultParams.lineDash,
|
|
27664
27642
|
lineCap = defaultParams.lineCap,
|
|
27665
|
-
miterLimit = defaultParams.miterLimit
|
|
27666
|
-
keepStrokeScale = defaultParams.keepStrokeScale
|
|
27643
|
+
miterLimit = defaultParams.miterLimit
|
|
27667
27644
|
} = attribute;
|
|
27668
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth =
|
|
27645
|
+
_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;
|
|
27669
27646
|
}
|
|
27670
27647
|
}
|
|
27671
27648
|
measureText(text) {
|
|
@@ -28072,9 +28049,8 @@
|
|
|
28072
28049
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
28073
28050
|
if (picked) return !0;
|
|
28074
28051
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28075
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28076
|
-
|
|
28077
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28052
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
28053
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28078
28054
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28079
28055
|
}
|
|
28080
28056
|
}
|
|
@@ -28209,9 +28185,8 @@
|
|
|
28209
28185
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
28210
28186
|
if (picked) return !0;
|
|
28211
28187
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28212
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28213
|
-
|
|
28214
|
-
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28188
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
|
|
28189
|
+
return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28215
28190
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28216
28191
|
}
|
|
28217
28192
|
};
|
|
@@ -28648,7 +28623,7 @@
|
|
|
28648
28623
|
|
|
28649
28624
|
const roughModule = _roughModule;
|
|
28650
28625
|
|
|
28651
|
-
const version = "0.21.0-alpha.
|
|
28626
|
+
const version = "0.21.0-alpha.13";
|
|
28652
28627
|
preLoadAllModule();
|
|
28653
28628
|
if (isBrowserEnv()) {
|
|
28654
28629
|
loadBrowserEnv(container);
|
|
@@ -28964,7 +28939,6 @@
|
|
|
28964
28939
|
exports.WindowHandlerContribution = WindowHandlerContribution;
|
|
28965
28940
|
exports.WrapText = WrapText;
|
|
28966
28941
|
exports.XMLParser = XMLParser;
|
|
28967
|
-
exports._calculateLineHeight = _calculateLineHeight;
|
|
28968
28942
|
exports._interpolateColor = _interpolateColor;
|
|
28969
28943
|
exports._registerArc = _registerArc;
|
|
28970
28944
|
exports.addArcToBezierPath = addArcToBezierPath$1;
|