@visactor/vrender-core 0.21.0-alpha.4 → 0.21.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate/Ticker/default-ticker.d.ts +4 -2
- package/cjs/animate/Ticker/default-ticker.js +8 -5
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/custom-animate.d.ts +2 -0
- package/cjs/animate/custom-animate.js +11 -2
- package/cjs/animate/custom-animate.js.map +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +92 -13
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/contributions/textMeasure/layout.d.ts +0 -1
- package/cjs/core/contributions/textMeasure/layout.js +20 -30
- package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
- package/cjs/core/stage.d.ts +2 -0
- package/cjs/core/stage.js +9 -5
- package/cjs/core/stage.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow.js +2 -2
- package/cjs/graphic/builtin-symbol/arrow.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-down.js +2 -2
- package/cjs/graphic/builtin-symbol/arrow2-down.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-left.js +2 -2
- package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-right.js +2 -2
- package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-up.js +2 -2
- package/cjs/graphic/builtin-symbol/arrow2-up.js.map +1 -1
- package/cjs/graphic/builtin-symbol/base.d.ts +1 -0
- package/cjs/graphic/builtin-symbol/base.js +3 -0
- package/cjs/graphic/builtin-symbol/base.js.map +1 -1
- package/cjs/graphic/builtin-symbol/circle.js +3 -3
- package/cjs/graphic/builtin-symbol/circle.js.map +1 -1
- package/cjs/graphic/builtin-symbol/close.js +3 -3
- package/cjs/graphic/builtin-symbol/close.js.map +1 -1
- package/cjs/graphic/builtin-symbol/cross.js +2 -2
- package/cjs/graphic/builtin-symbol/cross.js.map +1 -1
- package/cjs/graphic/builtin-symbol/diamond.js +3 -3
- package/cjs/graphic/builtin-symbol/diamond.js.map +1 -1
- package/cjs/graphic/builtin-symbol/line-h.js +3 -3
- package/cjs/graphic/builtin-symbol/line-h.js.map +1 -1
- package/cjs/graphic/builtin-symbol/line-v.js +3 -3
- package/cjs/graphic/builtin-symbol/line-v.js.map +1 -1
- package/cjs/graphic/builtin-symbol/square.js +2 -2
- package/cjs/graphic/builtin-symbol/square.js.map +1 -1
- package/cjs/graphic/builtin-symbol/star.js +2 -2
- package/cjs/graphic/builtin-symbol/star.js.map +1 -1
- package/cjs/graphic/builtin-symbol/stroke.js +2 -2
- package/cjs/graphic/builtin-symbol/stroke.js.map +1 -1
- package/cjs/graphic/builtin-symbol/thin-triangle.js +2 -2
- package/cjs/graphic/builtin-symbol/thin-triangle.js.map +1 -1
- package/cjs/graphic/builtin-symbol/triangle-down.js +2 -2
- package/cjs/graphic/builtin-symbol/triangle-down.js.map +1 -1
- package/cjs/graphic/builtin-symbol/triangle-left.js +2 -2
- package/cjs/graphic/builtin-symbol/triangle-left.js.map +1 -1
- package/cjs/graphic/builtin-symbol/triangle-right.js +2 -2
- package/cjs/graphic/builtin-symbol/triangle-right.js.map +1 -1
- package/cjs/graphic/builtin-symbol/triangle-up.js +2 -2
- package/cjs/graphic/builtin-symbol/triangle-up.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +1 -0
- package/cjs/graphic/builtin-symbol/utils.js +6 -3
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/builtin-symbol/wedge.js +2 -2
- package/cjs/graphic/builtin-symbol/wedge.js.map +1 -1
- package/cjs/graphic/builtin-symbol/wye.js +2 -2
- package/cjs/graphic/builtin-symbol/wye.js.map +1 -1
- package/cjs/graphic/config.js +3 -1
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.js +3 -1
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/text.d.ts +10 -11
- package/cjs/graphic/text.js +88 -168
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/wrap-text.js +12 -4
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/interface/animate.d.ts +3 -1
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/context.d.ts +1 -0
- package/cjs/interface/context.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +3 -3
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/text.d.ts +7 -1
- package/cjs/interface/text.js.map +1 -1
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -3
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +4 -6
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.d.ts +1 -1
- package/cjs/render/contributions/render/text-render.js +24 -46
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/cjs/resource-loader/loader.js +1 -1
- package/cjs/resource-loader/loader.js.map +1 -1
- package/dist/index.es.js +472 -510
- package/es/animate/Ticker/default-ticker.d.ts +4 -2
- package/es/animate/Ticker/default-ticker.js +9 -6
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/custom-animate.d.ts +2 -0
- package/es/animate/custom-animate.js +11 -2
- package/es/animate/custom-animate.js.map +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js +92 -13
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/contributions/textMeasure/layout.d.ts +0 -1
- package/es/core/contributions/textMeasure/layout.js +20 -30
- package/es/core/contributions/textMeasure/layout.js.map +1 -1
- package/es/core/stage.d.ts +2 -0
- package/es/core/stage.js +9 -5
- package/es/core/stage.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow.js +2 -2
- package/es/graphic/builtin-symbol/arrow.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-down.js +2 -2
- package/es/graphic/builtin-symbol/arrow2-down.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-left.js +2 -2
- package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-right.js +2 -2
- package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-up.js +2 -2
- package/es/graphic/builtin-symbol/arrow2-up.js.map +1 -1
- package/es/graphic/builtin-symbol/base.d.ts +1 -0
- package/es/graphic/builtin-symbol/base.js +3 -0
- package/es/graphic/builtin-symbol/base.js.map +1 -1
- package/es/graphic/builtin-symbol/circle.js +3 -3
- package/es/graphic/builtin-symbol/circle.js.map +1 -1
- package/es/graphic/builtin-symbol/close.js +3 -3
- package/es/graphic/builtin-symbol/close.js.map +1 -1
- package/es/graphic/builtin-symbol/cross.js +2 -2
- package/es/graphic/builtin-symbol/cross.js.map +1 -1
- package/es/graphic/builtin-symbol/diamond.js +3 -3
- package/es/graphic/builtin-symbol/diamond.js.map +1 -1
- package/es/graphic/builtin-symbol/line-h.js +3 -3
- package/es/graphic/builtin-symbol/line-h.js.map +1 -1
- package/es/graphic/builtin-symbol/line-v.js +3 -3
- package/es/graphic/builtin-symbol/line-v.js.map +1 -1
- package/es/graphic/builtin-symbol/square.js +2 -2
- package/es/graphic/builtin-symbol/square.js.map +1 -1
- package/es/graphic/builtin-symbol/star.js +2 -2
- package/es/graphic/builtin-symbol/star.js.map +1 -1
- package/es/graphic/builtin-symbol/stroke.js +2 -2
- package/es/graphic/builtin-symbol/stroke.js.map +1 -1
- package/es/graphic/builtin-symbol/thin-triangle.js +2 -2
- package/es/graphic/builtin-symbol/thin-triangle.js.map +1 -1
- package/es/graphic/builtin-symbol/triangle-down.js +2 -2
- package/es/graphic/builtin-symbol/triangle-down.js.map +1 -1
- package/es/graphic/builtin-symbol/triangle-left.js +2 -2
- package/es/graphic/builtin-symbol/triangle-left.js.map +1 -1
- package/es/graphic/builtin-symbol/triangle-right.js +2 -2
- package/es/graphic/builtin-symbol/triangle-right.js.map +1 -1
- package/es/graphic/builtin-symbol/triangle-up.js +2 -2
- package/es/graphic/builtin-symbol/triangle-up.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +1 -0
- package/es/graphic/builtin-symbol/utils.js +7 -4
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/builtin-symbol/wedge.js +2 -2
- package/es/graphic/builtin-symbol/wedge.js.map +1 -1
- package/es/graphic/builtin-symbol/wye.js +2 -2
- package/es/graphic/builtin-symbol/wye.js.map +1 -1
- package/es/graphic/config.js +3 -1
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/richtext/paragraph.js +4 -2
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/text.d.ts +10 -11
- package/es/graphic/text.js +87 -163
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/wrap-text.js +12 -4
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/interface/animate.d.ts +3 -1
- package/es/interface/animate.js.map +1 -1
- package/es/interface/context.d.ts +1 -0
- package/es/interface/context.js.map +1 -1
- package/es/interface/graphic/text.d.ts +3 -3
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/stage.d.ts +1 -0
- package/es/interface/stage.js.map +1 -1
- package/es/interface/text.d.ts +7 -1
- package/es/interface/text.js.map +1 -1
- package/es/render/contributions/render/contributions/arc-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/circle-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -3
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +4 -6
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/text-render.d.ts +1 -1
- package/es/render/contributions/render/text-render.js +23 -45
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/es/resource-loader/loader.js +1 -1
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +4 -3
package/dist/index.es.js
CHANGED
|
@@ -3016,6 +3016,7 @@ const DefaultStrokeStyle = Object.assign({ outerBorder: Object.assign(Object.ass
|
|
|
3016
3016
|
const DefaultTextStyle = {
|
|
3017
3017
|
text: '',
|
|
3018
3018
|
maxLineWidth: Infinity,
|
|
3019
|
+
maxWidth: Infinity,
|
|
3019
3020
|
textAlign: 'left',
|
|
3020
3021
|
textBaseline: 'alphabetic',
|
|
3021
3022
|
fontSize: 16,
|
|
@@ -3055,7 +3056,7 @@ const DefaultConnectAttribute = {
|
|
|
3055
3056
|
const DefaultDebugAttribute = {
|
|
3056
3057
|
_debug_bounds: false
|
|
3057
3058
|
};
|
|
3058
|
-
const DefaultAttribute = Object.assign(Object.assign(Object.assign({ strokeSeg: null, renderable: true, pickable: true, shadowGraphic: undefined, childrenPickable: true, fillPickable: true, strokePickable: true, visible: true, zIndex: 0, layout: null, boundsPadding: 0, fillStrokeOrder: 0, renderStyle: 'default', pickMode: 'accurate', customPickShape: null, boundsMode: 'accurate', keepDirIn3d: true, shadowRootIdx: 1, globalZIndex: 1, globalCompositeOperation: '', overflow: 'hidden', shadowPickMode: 'graphic' }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
3059
|
+
const DefaultAttribute = Object.assign(Object.assign(Object.assign({ strokeSeg: null, renderable: true, pickable: true, shadowGraphic: undefined, childrenPickable: true, fillPickable: true, strokePickable: true, visible: true, zIndex: 0, layout: null, boundsPadding: 0, fillStrokeOrder: 0, renderStyle: 'default', pickMode: 'accurate', customPickShape: null, boundsMode: 'accurate', keepDirIn3d: true, shadowRootIdx: 1, globalZIndex: 1, globalCompositeOperation: '', overflow: 'hidden', shadowPickMode: 'graphic', keepStrokeScale: false }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
3059
3060
|
function addAttributeToPrototype(obj, c, keys) {
|
|
3060
3061
|
keys.forEach(key => {
|
|
3061
3062
|
c.prototype[key] = obj[key];
|
|
@@ -3249,13 +3250,33 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3249
3250
|
this.context = service.context;
|
|
3250
3251
|
service.bindTextMeasure(this);
|
|
3251
3252
|
}
|
|
3252
|
-
|
|
3253
|
-
if (!this.context) {
|
|
3254
|
-
return this.estimate(text, options).width;
|
|
3255
|
-
}
|
|
3253
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
3256
3254
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
3257
|
-
const
|
|
3258
|
-
return
|
|
3255
|
+
const metrics = this.context.measureText(text);
|
|
3256
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
3257
|
+
}
|
|
3258
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
3259
|
+
this.context.setTextStyle(options);
|
|
3260
|
+
const metrics = this.context.measureText(text);
|
|
3261
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
3262
|
+
}
|
|
3263
|
+
compatibleMetrics(metrics, options) {
|
|
3264
|
+
if (metrics.actualBoundingBoxAscent == null ||
|
|
3265
|
+
metrics.actualBoundingBoxDescent == null ||
|
|
3266
|
+
metrics.fontBoundingBoxAscent == null ||
|
|
3267
|
+
metrics.fontBoundingBoxDescent == null) {
|
|
3268
|
+
const { ascent, descent } = this.measureTextBoundADscentEstimate(options);
|
|
3269
|
+
metrics.actualBoundingBoxAscent = ascent;
|
|
3270
|
+
metrics.actualBoundingBoxDescent = descent;
|
|
3271
|
+
metrics.fontBoundingBoxAscent = ascent;
|
|
3272
|
+
metrics.fontBoundingBoxDescent = descent;
|
|
3273
|
+
}
|
|
3274
|
+
if (metrics.actualBoundingBoxLeft == null || metrics.actualBoundingBoxRight == null) {
|
|
3275
|
+
const { left, right } = this.measureTextBoundLeftRightEstimate(options);
|
|
3276
|
+
metrics.actualBoundingBoxLeft = left;
|
|
3277
|
+
metrics.actualBoundingBoxRight = right;
|
|
3278
|
+
}
|
|
3279
|
+
return metrics;
|
|
3259
3280
|
}
|
|
3260
3281
|
estimate(text, { fontSize = DefaultTextAttribute.fontSize }) {
|
|
3261
3282
|
let eCharLen = 0;
|
|
@@ -3268,24 +3289,125 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3268
3289
|
height: fontSize
|
|
3269
3290
|
};
|
|
3270
3291
|
}
|
|
3271
|
-
|
|
3292
|
+
measureTextWidth(text, options, textMeasure) {
|
|
3293
|
+
if (!this.context) {
|
|
3294
|
+
return this.estimate(text, options).width;
|
|
3295
|
+
}
|
|
3296
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options);
|
|
3297
|
+
return textMeasure.width;
|
|
3298
|
+
}
|
|
3299
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
3300
|
+
if (!this.context) {
|
|
3301
|
+
return this.estimate(text, options).width;
|
|
3302
|
+
}
|
|
3303
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options);
|
|
3304
|
+
return textMeasure.width;
|
|
3305
|
+
}
|
|
3306
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
3307
|
+
if (!this.context) {
|
|
3308
|
+
return this.measureTextBoundLeftRightEstimate(options);
|
|
3309
|
+
}
|
|
3310
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithAlignBaseline(text, options, true);
|
|
3311
|
+
return {
|
|
3312
|
+
left: textMeasure.actualBoundingBoxLeft,
|
|
3313
|
+
right: textMeasure.actualBoundingBoxRight
|
|
3314
|
+
};
|
|
3315
|
+
}
|
|
3316
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
3272
3317
|
var _a;
|
|
3273
3318
|
if (!this.context) {
|
|
3274
3319
|
return (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3275
3320
|
}
|
|
3276
|
-
this.
|
|
3277
|
-
const textMeasure = this.context.measureText(text);
|
|
3321
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, true);
|
|
3278
3322
|
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
3279
3323
|
}
|
|
3280
|
-
|
|
3324
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
3325
|
+
if (!this.context) {
|
|
3326
|
+
return this.measureTextBoundADscentEstimate(options);
|
|
3327
|
+
}
|
|
3328
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithAlignBaseline(text, options, true);
|
|
3329
|
+
return {
|
|
3330
|
+
ascent: textMeasure.actualBoundingBoxAscent,
|
|
3331
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
3332
|
+
};
|
|
3333
|
+
}
|
|
3334
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
3281
3335
|
var _a;
|
|
3282
3336
|
if (!this.context) {
|
|
3283
3337
|
return (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3284
3338
|
}
|
|
3285
|
-
this.
|
|
3286
|
-
const textMeasure = this.context.measureText(text);
|
|
3339
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, true);
|
|
3287
3340
|
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
3288
3341
|
}
|
|
3342
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
3343
|
+
if (!this.context) {
|
|
3344
|
+
return this.measureTextBoundADscentEstimate(options);
|
|
3345
|
+
}
|
|
3346
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithAlignBaseline(text, options, true);
|
|
3347
|
+
return {
|
|
3348
|
+
ascent: textMeasure.fontBoundingBoxAscent,
|
|
3349
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
measureTextBoundADscentEstimate(options) {
|
|
3353
|
+
var _a;
|
|
3354
|
+
const fontSize = (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3355
|
+
const { textBaseline } = options;
|
|
3356
|
+
if (textBaseline === 'bottom') {
|
|
3357
|
+
return {
|
|
3358
|
+
ascent: fontSize,
|
|
3359
|
+
descent: 0
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
else if (textBaseline === 'middle') {
|
|
3363
|
+
return {
|
|
3364
|
+
ascent: fontSize / 2,
|
|
3365
|
+
descent: fontSize / 2
|
|
3366
|
+
};
|
|
3367
|
+
}
|
|
3368
|
+
else if (textBaseline === 'alphabetic') {
|
|
3369
|
+
return {
|
|
3370
|
+
ascent: 0.79 * fontSize,
|
|
3371
|
+
descent: 0.21 * fontSize
|
|
3372
|
+
};
|
|
3373
|
+
}
|
|
3374
|
+
return {
|
|
3375
|
+
ascent: 0,
|
|
3376
|
+
descent: fontSize
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
3380
|
+
var _a;
|
|
3381
|
+
const fontSize = (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3382
|
+
const { textAlign } = options;
|
|
3383
|
+
if (textAlign === 'center') {
|
|
3384
|
+
return {
|
|
3385
|
+
left: fontSize / 2,
|
|
3386
|
+
right: fontSize / 2
|
|
3387
|
+
};
|
|
3388
|
+
}
|
|
3389
|
+
else if (textAlign === 'right' || textAlign === 'end') {
|
|
3390
|
+
return {
|
|
3391
|
+
left: fontSize,
|
|
3392
|
+
right: 0
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
return {
|
|
3396
|
+
left: 0,
|
|
3397
|
+
right: fontSize
|
|
3398
|
+
};
|
|
3399
|
+
}
|
|
3400
|
+
measureTextPixelADscentAndWidth(text, options) {
|
|
3401
|
+
if (!this.context) {
|
|
3402
|
+
return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), { width: this.estimate(text, options).width });
|
|
3403
|
+
}
|
|
3404
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, true);
|
|
3405
|
+
return {
|
|
3406
|
+
ascent: out.actualBoundingBoxAscent,
|
|
3407
|
+
descent: out.actualBoundingBoxDescent,
|
|
3408
|
+
width: out.width
|
|
3409
|
+
};
|
|
3410
|
+
}
|
|
3289
3411
|
measureText(text, options) {
|
|
3290
3412
|
if (!this.context) {
|
|
3291
3413
|
return this.estimate(text, options);
|
|
@@ -6841,7 +6963,7 @@ class TimeOutTickHandler {
|
|
|
6841
6963
|
}
|
|
6842
6964
|
}
|
|
6843
6965
|
|
|
6844
|
-
class DefaultTicker {
|
|
6966
|
+
class DefaultTicker extends EventEmitter {
|
|
6845
6967
|
set mode(m) {
|
|
6846
6968
|
if (this._mode === m) {
|
|
6847
6969
|
return;
|
|
@@ -6853,18 +6975,19 @@ class DefaultTicker {
|
|
|
6853
6975
|
return this._mode;
|
|
6854
6976
|
}
|
|
6855
6977
|
constructor(timelines = []) {
|
|
6978
|
+
super();
|
|
6856
6979
|
this.handleTick = (handler, params) => {
|
|
6857
6980
|
const { once = false } = params !== null && params !== void 0 ? params : {};
|
|
6858
6981
|
if (this.ifCanStop()) {
|
|
6859
6982
|
this.stop();
|
|
6860
6983
|
return;
|
|
6861
6984
|
}
|
|
6862
|
-
this._handlerTick(
|
|
6985
|
+
this._handlerTick();
|
|
6863
6986
|
if (!once) {
|
|
6864
6987
|
handler.tick(this.interval, this.handleTick);
|
|
6865
6988
|
}
|
|
6866
6989
|
};
|
|
6867
|
-
this._handlerTick = (
|
|
6990
|
+
this._handlerTick = () => {
|
|
6868
6991
|
const tickerHandler = this.tickerHandler;
|
|
6869
6992
|
const time = tickerHandler.getTime();
|
|
6870
6993
|
let delta = 0;
|
|
@@ -6879,6 +7002,7 @@ class DefaultTicker {
|
|
|
6879
7002
|
this.timelines.forEach(t => {
|
|
6880
7003
|
t.tick(delta);
|
|
6881
7004
|
});
|
|
7005
|
+
this.emit('afterTick');
|
|
6882
7006
|
};
|
|
6883
7007
|
this.init();
|
|
6884
7008
|
this.lastFrameTime = -1;
|
|
@@ -7018,6 +7142,11 @@ class DefaultTicker {
|
|
|
7018
7142
|
this.setupTickHandler();
|
|
7019
7143
|
this.lastFrameTime = -1;
|
|
7020
7144
|
}
|
|
7145
|
+
trySyncTickStatus() {
|
|
7146
|
+
if (this.status === STATUS$1.RUNNING) {
|
|
7147
|
+
this._handlerTick();
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
7021
7150
|
}
|
|
7022
7151
|
|
|
7023
7152
|
class ManualTickHandler {
|
|
@@ -8838,6 +8967,11 @@ class TagPointsUpdate extends ACustomAnimate {
|
|
|
8838
8967
|
this.clipRange =
|
|
8839
8968
|
this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /
|
|
8840
8969
|
this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension];
|
|
8970
|
+
if (this.clipRange === 1) {
|
|
8971
|
+
this.shrinkClipRange =
|
|
8972
|
+
this.toPoints[lastMatchedIndex][this.clipRangeByDimension] /
|
|
8973
|
+
this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension];
|
|
8974
|
+
}
|
|
8841
8975
|
if (!isValidNumber(this.clipRange)) {
|
|
8842
8976
|
this.clipRange = 0;
|
|
8843
8977
|
}
|
|
@@ -8877,6 +9011,12 @@ class TagPointsUpdate extends ACustomAnimate {
|
|
|
8877
9011
|
return newPoint;
|
|
8878
9012
|
});
|
|
8879
9013
|
}
|
|
9014
|
+
onFirstRun() {
|
|
9015
|
+
const lastClipRange = this.target.attribute.clipRange;
|
|
9016
|
+
if (isValidNumber(lastClipRange * this.clipRange)) {
|
|
9017
|
+
this.clipRange *= lastClipRange;
|
|
9018
|
+
}
|
|
9019
|
+
}
|
|
8880
9020
|
onUpdate(end, ratio, out) {
|
|
8881
9021
|
this.points = this.points.map((point, index) => {
|
|
8882
9022
|
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
@@ -8884,6 +9024,17 @@ class TagPointsUpdate extends ACustomAnimate {
|
|
|
8884
9024
|
return newPoint;
|
|
8885
9025
|
});
|
|
8886
9026
|
if (this.clipRange) {
|
|
9027
|
+
if (this.shrinkClipRange) {
|
|
9028
|
+
if (!end) {
|
|
9029
|
+
out.points = this.fromPoints;
|
|
9030
|
+
out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio;
|
|
9031
|
+
}
|
|
9032
|
+
else {
|
|
9033
|
+
out.points = this.toPoints;
|
|
9034
|
+
out.clipRange = 1;
|
|
9035
|
+
}
|
|
9036
|
+
return;
|
|
9037
|
+
}
|
|
8887
9038
|
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
8888
9039
|
}
|
|
8889
9040
|
if (this.segmentsCache && this.to.segments) {
|
|
@@ -10810,10 +10961,10 @@ class ResourceLoader {
|
|
|
10810
10961
|
static GetFile(url, type) {
|
|
10811
10962
|
let data = ResourceLoader.cache.get(url);
|
|
10812
10963
|
if (data) {
|
|
10813
|
-
if (data.loadState === 'fail') {
|
|
10964
|
+
if (data.loadState === 'init' || data.loadState === 'fail') {
|
|
10814
10965
|
return Promise.reject();
|
|
10815
10966
|
}
|
|
10816
|
-
else if (data.loadState === '
|
|
10967
|
+
else if (data.loadState === 'loading') {
|
|
10817
10968
|
return data.dataPromise.then(data => data.data);
|
|
10818
10969
|
}
|
|
10819
10970
|
return Promise.resolve(data.data);
|
|
@@ -15409,14 +15560,14 @@ class DefaultArcRenderContribution {
|
|
|
15409
15560
|
if (!(doOuterBorder || doInnerBorder)) {
|
|
15410
15561
|
return;
|
|
15411
15562
|
}
|
|
15412
|
-
const { innerPadding = arcAttribute.innerPadding, outerPadding = arcAttribute.outerPadding, startAngle = arcAttribute.startAngle, endAngle = arcAttribute.endAngle, opacity = arcAttribute.opacity, x: originX = arcAttribute.x, y: originY = arcAttribute.y, scaleX = arcAttribute.scaleX, scaleY = arcAttribute.scaleY } = arc.attribute;
|
|
15563
|
+
const { innerPadding = arcAttribute.innerPadding, outerPadding = arcAttribute.outerPadding, startAngle = arcAttribute.startAngle, endAngle = arcAttribute.endAngle, opacity = arcAttribute.opacity, x: originX = arcAttribute.x, y: originY = arcAttribute.y, scaleX = arcAttribute.scaleX, scaleY = arcAttribute.scaleY, keepStrokeScale = arcAttribute.keepStrokeScale } = arc.attribute;
|
|
15413
15564
|
let { innerRadius = arcAttribute.innerRadius, outerRadius = arcAttribute.outerRadius } = arc.attribute;
|
|
15414
15565
|
outerRadius += outerPadding;
|
|
15415
15566
|
innerRadius -= innerPadding;
|
|
15416
15567
|
const renderBorder = (borderStyle, key) => {
|
|
15417
15568
|
const doStroke = !!(borderStyle && borderStyle.stroke);
|
|
15418
15569
|
const { distance = arcAttribute[key].distance } = borderStyle;
|
|
15419
|
-
const d = getScaledStroke(context, distance, context.dpr);
|
|
15570
|
+
const d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr);
|
|
15420
15571
|
const deltaAngle = distance / outerRadius;
|
|
15421
15572
|
const sign = key === 'outerBorder' ? 1 : -1;
|
|
15422
15573
|
arc.setAttributes({
|
|
@@ -15461,11 +15612,11 @@ class DefaultCircleRenderContribution {
|
|
|
15461
15612
|
if (!(doOuterBorder || doInnerBorder)) {
|
|
15462
15613
|
return;
|
|
15463
15614
|
}
|
|
15464
|
-
const { radius = circleAttribute.radius, startAngle = circleAttribute.startAngle, endAngle = circleAttribute.endAngle, opacity = circleAttribute.opacity, x: originX = circleAttribute.x, y: originY = circleAttribute.y, scaleX = circleAttribute.scaleX, scaleY = circleAttribute.scaleY } = circle.attribute;
|
|
15615
|
+
const { radius = circleAttribute.radius, startAngle = circleAttribute.startAngle, endAngle = circleAttribute.endAngle, opacity = circleAttribute.opacity, x: originX = circleAttribute.x, y: originY = circleAttribute.y, scaleX = circleAttribute.scaleX, scaleY = circleAttribute.scaleY, keepStrokeScale = circleAttribute.keepStrokeScale } = circle.attribute;
|
|
15465
15616
|
const renderBorder = (borderStyle, key) => {
|
|
15466
15617
|
const doStroke = !!(borderStyle && borderStyle.stroke);
|
|
15467
15618
|
const { distance = circleAttribute[key].distance } = borderStyle;
|
|
15468
|
-
const d = getScaledStroke(context, distance, context.dpr);
|
|
15619
|
+
const d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr);
|
|
15469
15620
|
const sign = key === 'outerBorder' ? 1 : -1;
|
|
15470
15621
|
context.beginPath();
|
|
15471
15622
|
context.arc(x, y, radius + sign * d, startAngle, endAngle);
|
|
@@ -15650,7 +15801,7 @@ class DefaultRectRenderContribution {
|
|
|
15650
15801
|
if (!(doOuterBorder || doInnerBorder)) {
|
|
15651
15802
|
return;
|
|
15652
15803
|
}
|
|
15653
|
-
const { cornerRadius = rectAttribute.cornerRadius, opacity = rectAttribute.opacity, x: originX = rectAttribute.x, y: originY = rectAttribute.y, scaleX = rectAttribute.scaleX, scaleY = rectAttribute.scaleY, x1, y1 } = rect.attribute;
|
|
15804
|
+
const { cornerRadius = rectAttribute.cornerRadius, opacity = rectAttribute.opacity, x: originX = rectAttribute.x, y: originY = rectAttribute.y, scaleX = rectAttribute.scaleX, scaleY = rectAttribute.scaleY, x1, y1, keepStrokeScale = rectAttribute.keepStrokeScale } = rect.attribute;
|
|
15654
15805
|
let { width, height } = rect.attribute;
|
|
15655
15806
|
width = (width !== null && width !== void 0 ? width : x1 - x) || 0;
|
|
15656
15807
|
height = (height !== null && height !== void 0 ? height : y1 - y) || 0;
|
|
@@ -15658,7 +15809,7 @@ class DefaultRectRenderContribution {
|
|
|
15658
15809
|
const doStroke = !!(borderStyle && borderStyle.stroke);
|
|
15659
15810
|
const sign = key === 'outerBorder' ? -1 : 1;
|
|
15660
15811
|
const { distance = rectAttribute[key].distance } = borderStyle;
|
|
15661
|
-
const d = getScaledStroke(context, distance, context.dpr);
|
|
15812
|
+
const d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr);
|
|
15662
15813
|
const nextX = x + sign * d;
|
|
15663
15814
|
const nextY = y + sign * d;
|
|
15664
15815
|
const dw = d * 2;
|
|
@@ -15874,13 +16025,8 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
|
15874
16025
|
this.useStyle = true;
|
|
15875
16026
|
this.order = 0;
|
|
15876
16027
|
}
|
|
15877
|
-
drawShape(
|
|
15878
|
-
|
|
15879
|
-
image.renderFrame(context, x, y);
|
|
15880
|
-
}
|
|
15881
|
-
else {
|
|
15882
|
-
return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
15883
|
-
}
|
|
16028
|
+
drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
|
|
16029
|
+
return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
15884
16030
|
}
|
|
15885
16031
|
}
|
|
15886
16032
|
const defaultImageRenderContribution = new DefaultImageRenderContribution();
|
|
@@ -15903,11 +16049,11 @@ class DefaultSymbolRenderContribution {
|
|
|
15903
16049
|
if (!(doOuterBorder || doInnerBorder)) {
|
|
15904
16050
|
return;
|
|
15905
16051
|
}
|
|
15906
|
-
const { size = symbolAttribute.size, opacity = symbolAttribute.opacity, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX = symbolAttribute.scaleX, scaleY = symbolAttribute.scaleY } = symbol.attribute;
|
|
16052
|
+
const { size = symbolAttribute.size, opacity = symbolAttribute.opacity, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX = symbolAttribute.scaleX, scaleY = symbolAttribute.scaleY, keepStrokeScale = symbolAttribute.keepStrokeScale } = symbol.attribute;
|
|
15907
16053
|
const renderBorder = (borderStyle, key) => {
|
|
15908
16054
|
const doStroke = !!(borderStyle && borderStyle.stroke);
|
|
15909
16055
|
const { distance = symbolAttribute[key].distance } = borderStyle;
|
|
15910
|
-
const d = getScaledStroke(context, distance, context.dpr);
|
|
16056
|
+
const d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr);
|
|
15911
16057
|
const sign = key === 'outerBorder' ? 1 : -1;
|
|
15912
16058
|
context.beginPath();
|
|
15913
16059
|
if (parsedPath.drawOffset(context, size, x, y, sign * d) === false) {
|
|
@@ -17796,13 +17942,7 @@ let DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
|
|
|
17796
17942
|
var _a, _b, _c;
|
|
17797
17943
|
const textAttribute = getTheme(text, params === null || params === void 0 ? void 0 : params.theme).text;
|
|
17798
17944
|
const { text: str, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, keepDirIn3d = textAttribute.keepDirIn3d, direction = textAttribute.direction, fontSize = textAttribute.fontSize, verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
|
|
17799
|
-
|
|
17800
|
-
if (!verticalMode && direction === 'vertical') {
|
|
17801
|
-
const t = textAlign;
|
|
17802
|
-
textAlign = (_a = text.getBaselineMapAlign()[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
|
|
17803
|
-
textBaseline = (_b = text.getAlignMapBaseline()[t]) !== null && _b !== void 0 ? _b : 'top';
|
|
17804
|
-
}
|
|
17805
|
-
const lineHeight = (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) !== null && _c !== void 0 ? _c : fontSize;
|
|
17945
|
+
const lineHeight = (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) !== null && _a !== void 0 ? _a : fontSize;
|
|
17806
17946
|
const data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
17807
17947
|
if (!data) {
|
|
17808
17948
|
return;
|
|
@@ -17841,7 +17981,6 @@ let DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
|
|
|
17841
17981
|
else if (fVisible) {
|
|
17842
17982
|
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17843
17983
|
context.fillText(t, _x, _y, z);
|
|
17844
|
-
this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context);
|
|
17845
17984
|
}
|
|
17846
17985
|
}
|
|
17847
17986
|
if (direction) {
|
|
@@ -17849,132 +17988,88 @@ let DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
|
|
|
17849
17988
|
context.setTransformForCurrent();
|
|
17850
17989
|
}
|
|
17851
17990
|
};
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
|
|
17856
|
-
|
|
17857
|
-
|
|
17858
|
-
return;
|
|
17859
|
-
}
|
|
17860
|
-
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
17861
|
-
if (doStroke) {
|
|
17862
|
-
if (strokeCb) {
|
|
17863
|
-
strokeCb(context, text.attribute, textAttribute);
|
|
17864
|
-
}
|
|
17865
|
-
else if (sVisible) {
|
|
17866
|
-
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17867
|
-
multilineLayout.lines.forEach(line => {
|
|
17868
|
-
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17869
|
-
});
|
|
17870
|
-
}
|
|
17871
|
-
}
|
|
17872
|
-
if (doFill) {
|
|
17873
|
-
if (fillCb) {
|
|
17874
|
-
fillCb(context, text.attribute, textAttribute);
|
|
17875
|
-
}
|
|
17876
|
-
else if (fVisible) {
|
|
17877
|
-
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17878
|
-
multilineLayout.lines.forEach(line => {
|
|
17879
|
-
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17880
|
-
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY('bottom', fontSize) - 0.05 * fontSize, z, textAttribute, context, {
|
|
17881
|
-
width: line.width
|
|
17882
|
-
});
|
|
17883
|
-
});
|
|
17884
|
-
}
|
|
17885
|
-
}
|
|
17991
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
17992
|
+
if (direction === 'horizontal') {
|
|
17993
|
+
const { multilineLayout } = text;
|
|
17994
|
+
if (!multilineLayout) {
|
|
17995
|
+
context.highPerformanceRestore();
|
|
17996
|
+
return;
|
|
17886
17997
|
}
|
|
17887
|
-
|
|
17888
|
-
|
|
17889
|
-
|
|
17890
|
-
|
|
17891
|
-
context.textAlign = 'left';
|
|
17892
|
-
context.textBaseline = 'top';
|
|
17893
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
17894
|
-
let totalW = 0;
|
|
17895
|
-
verticalList.forEach(verticalData => {
|
|
17896
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
17897
|
-
totalW = max(_w, totalW);
|
|
17898
|
-
});
|
|
17899
|
-
let offsetY = 0;
|
|
17900
|
-
let offsetX = 0;
|
|
17901
|
-
if (textBaseline === 'bottom') {
|
|
17902
|
-
offsetX = -totalHeight;
|
|
17998
|
+
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
17999
|
+
if (doStroke) {
|
|
18000
|
+
if (strokeCb) {
|
|
18001
|
+
strokeCb(context, text.attribute, textAttribute);
|
|
17903
18002
|
}
|
|
17904
|
-
else if (
|
|
17905
|
-
|
|
18003
|
+
else if (sVisible) {
|
|
18004
|
+
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
18005
|
+
multilineLayout.lines.forEach(line => {
|
|
18006
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
18007
|
+
});
|
|
17906
18008
|
}
|
|
17907
|
-
|
|
17908
|
-
|
|
18009
|
+
}
|
|
18010
|
+
if (doFill) {
|
|
18011
|
+
if (fillCb) {
|
|
18012
|
+
fillCb(context, text.attribute, textAttribute);
|
|
17909
18013
|
}
|
|
17910
|
-
else if (
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
if (textAlign === 'center') {
|
|
17918
|
-
currentOffsetY += dw / 2;
|
|
17919
|
-
}
|
|
17920
|
-
else if (textAlign === 'right') {
|
|
17921
|
-
currentOffsetY += dw;
|
|
17922
|
-
}
|
|
17923
|
-
verticalData.forEach(item => {
|
|
17924
|
-
const { text, width, direction } = item;
|
|
17925
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);
|
|
17926
|
-
currentOffsetY += width;
|
|
18014
|
+
else if (fVisible) {
|
|
18015
|
+
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
18016
|
+
multilineLayout.lines.forEach(line => {
|
|
18017
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
18018
|
+
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
|
|
18019
|
+
width: line.width
|
|
18020
|
+
});
|
|
17927
18021
|
});
|
|
17928
|
-
}
|
|
18022
|
+
}
|
|
17929
18023
|
}
|
|
17930
18024
|
}
|
|
17931
18025
|
else {
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
const t =
|
|
17935
|
-
|
|
17936
|
-
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
|
|
17944
|
-
|
|
17945
|
-
|
|
17946
|
-
|
|
18026
|
+
let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;
|
|
18027
|
+
if (!verticalMode) {
|
|
18028
|
+
const t = textAlign;
|
|
18029
|
+
textAlign = (_b = text.getBaselineMapAlign()[textBaseline]) !== null && _b !== void 0 ? _b : 'left';
|
|
18030
|
+
textBaseline = (_c = text.getAlignMapBaseline()[t]) !== null && _c !== void 0 ? _c : 'top';
|
|
18031
|
+
}
|
|
18032
|
+
text.tryUpdateAABBBounds();
|
|
18033
|
+
const cache = text.cache;
|
|
18034
|
+
const { verticalList } = cache;
|
|
18035
|
+
context.textAlign = 'left';
|
|
18036
|
+
context.textBaseline = 'top';
|
|
18037
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
18038
|
+
let totalW = 0;
|
|
18039
|
+
verticalList.forEach(verticalData => {
|
|
18040
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
18041
|
+
totalW = max(_w, totalW);
|
|
18042
|
+
});
|
|
18043
|
+
let offsetY = 0;
|
|
18044
|
+
let offsetX = 0;
|
|
18045
|
+
if (textBaseline === 'bottom') {
|
|
18046
|
+
offsetX = -totalHeight;
|
|
17947
18047
|
}
|
|
17948
|
-
else {
|
|
17949
|
-
|
|
17950
|
-
const cache = text.cache;
|
|
17951
|
-
if (cache) {
|
|
17952
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
17953
|
-
const { verticalList } = cache;
|
|
17954
|
-
let offsetY = 0;
|
|
17955
|
-
const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
|
|
17956
|
-
let offsetX = 0;
|
|
17957
|
-
if (textBaseline === 'bottom') {
|
|
17958
|
-
offsetX = -lineHeight;
|
|
17959
|
-
}
|
|
17960
|
-
else if (textBaseline === 'middle') {
|
|
17961
|
-
offsetX = -lineHeight / 2;
|
|
17962
|
-
}
|
|
17963
|
-
if (textAlign === 'center') {
|
|
17964
|
-
offsetY -= totalW / 2;
|
|
17965
|
-
}
|
|
17966
|
-
else if (textAlign === 'right') {
|
|
17967
|
-
offsetY -= totalW;
|
|
17968
|
-
}
|
|
17969
|
-
context.textAlign = 'left';
|
|
17970
|
-
context.textBaseline = 'top';
|
|
17971
|
-
verticalList[0].forEach(item => {
|
|
17972
|
-
const { text, width, direction } = item;
|
|
17973
|
-
drawText(text, offsetX, offsetY, direction);
|
|
17974
|
-
offsetY += width;
|
|
17975
|
-
});
|
|
17976
|
-
}
|
|
18048
|
+
else if (textBaseline === 'middle') {
|
|
18049
|
+
offsetX = -totalHeight / 2;
|
|
17977
18050
|
}
|
|
18051
|
+
if (textAlign === 'center') {
|
|
18052
|
+
offsetY -= totalW / 2;
|
|
18053
|
+
}
|
|
18054
|
+
else if (textAlign === 'right') {
|
|
18055
|
+
offsetY -= totalW;
|
|
18056
|
+
}
|
|
18057
|
+
verticalList.forEach((verticalData, i) => {
|
|
18058
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
18059
|
+
const dw = totalW - currentW;
|
|
18060
|
+
let currentOffsetY = offsetY;
|
|
18061
|
+
if (textAlign === 'center') {
|
|
18062
|
+
currentOffsetY += dw / 2;
|
|
18063
|
+
}
|
|
18064
|
+
else if (textAlign === 'right') {
|
|
18065
|
+
currentOffsetY += dw;
|
|
18066
|
+
}
|
|
18067
|
+
verticalData.forEach(item => {
|
|
18068
|
+
const { text, width, direction } = item;
|
|
18069
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);
|
|
18070
|
+
currentOffsetY += width;
|
|
18071
|
+
});
|
|
18072
|
+
});
|
|
17978
18073
|
}
|
|
17979
18074
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);
|
|
17980
18075
|
this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
@@ -17985,37 +18080,32 @@ let DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
|
|
|
17985
18080
|
const computed3dMatrix = !keepDirIn3d;
|
|
17986
18081
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
17987
18082
|
}
|
|
17988
|
-
drawUnderLine(underline, lineThrough, text,
|
|
18083
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
17989
18084
|
if (lineThrough + underline <= 0) {
|
|
17990
18085
|
return;
|
|
17991
18086
|
}
|
|
17992
|
-
const { textAlign = textAttribute.textAlign,
|
|
18087
|
+
const { textAlign = textAttribute.textAlign, fill = textAttribute.fill, opacity = textAttribute.opacity, underlineOffset = textAttribute.underlineOffset, underlineDash = textAttribute.underlineDash, fillOpacity = textAttribute.fillOpacity } = text.attribute;
|
|
17993
18088
|
const isMulti = !isNil(multiOption);
|
|
17994
18089
|
const w = isMulti ? multiOption.width : text.clipedWidth;
|
|
17995
18090
|
const offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w);
|
|
17996
|
-
const offsetY = textLayoutOffsetY(isMulti ? 'alphabetic' : textBaseline, fontSize, fontSize);
|
|
17997
18091
|
const attribute = { lineWidth: 0, stroke: fill, opacity, strokeOpacity: fillOpacity };
|
|
17998
|
-
let deltaY = isMulti ? -3 : 0;
|
|
17999
18092
|
if (underline) {
|
|
18000
18093
|
attribute.lineWidth = underline;
|
|
18001
|
-
context.setStrokeStyle(text, attribute,
|
|
18094
|
+
context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);
|
|
18002
18095
|
underlineDash && context.setLineDash(underlineDash);
|
|
18003
18096
|
context.beginPath();
|
|
18004
|
-
const dy =
|
|
18005
|
-
context.moveTo(
|
|
18006
|
-
context.lineTo(
|
|
18097
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
18098
|
+
context.moveTo(anchorX + offsetX, dy, z);
|
|
18099
|
+
context.lineTo(anchorX + offsetX + w, dy, z);
|
|
18007
18100
|
context.stroke();
|
|
18008
18101
|
}
|
|
18009
|
-
if (isMulti) {
|
|
18010
|
-
deltaY = -1;
|
|
18011
|
-
}
|
|
18012
18102
|
if (lineThrough) {
|
|
18013
18103
|
attribute.lineWidth = lineThrough;
|
|
18014
|
-
context.setStrokeStyle(text, attribute,
|
|
18104
|
+
context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute);
|
|
18015
18105
|
context.beginPath();
|
|
18016
|
-
const dy =
|
|
18017
|
-
context.moveTo(
|
|
18018
|
-
context.lineTo(
|
|
18106
|
+
const dy = anchorY + offsetThroughLineY;
|
|
18107
|
+
context.moveTo(anchorX + offsetX, dy, z);
|
|
18108
|
+
context.lineTo(anchorX + offsetX + w, dy, z);
|
|
18019
18109
|
context.stroke();
|
|
18020
18110
|
}
|
|
18021
18111
|
}
|
|
@@ -18455,18 +18545,16 @@ let DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender
|
|
|
18455
18545
|
}
|
|
18456
18546
|
draw(image, renderService, drawContext) {
|
|
18457
18547
|
const { image: url } = image.attribute;
|
|
18458
|
-
if (!image.
|
|
18459
|
-
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
return;
|
|
18469
|
-
}
|
|
18548
|
+
if (!url || !image.resources) {
|
|
18549
|
+
return;
|
|
18550
|
+
}
|
|
18551
|
+
const res = image.resources.get(url);
|
|
18552
|
+
if (res.state === 'loading' && isString(url)) {
|
|
18553
|
+
ResourceLoader.improveImageLoading(url);
|
|
18554
|
+
return;
|
|
18555
|
+
}
|
|
18556
|
+
else if (res.state !== 'success') {
|
|
18557
|
+
return;
|
|
18470
18558
|
}
|
|
18471
18559
|
const { context } = renderService.drawParams;
|
|
18472
18560
|
if (!context) {
|
|
@@ -19046,40 +19134,6 @@ class CanvasTextLayout {
|
|
|
19046
19134
|
}
|
|
19047
19135
|
return bbox;
|
|
19048
19136
|
}
|
|
19049
|
-
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
19050
|
-
const linesLayout = [];
|
|
19051
|
-
const bboxWH = [width, height];
|
|
19052
|
-
const bboxOffset = [0, 0];
|
|
19053
|
-
while (str.length > 0) {
|
|
19054
|
-
const { str: clipText } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
19055
|
-
linesLayout.push({
|
|
19056
|
-
str: clipText,
|
|
19057
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
19058
|
-
});
|
|
19059
|
-
str = str.substring(clipText.length);
|
|
19060
|
-
}
|
|
19061
|
-
if (textAlign === 'left' || textAlign === 'start') ;
|
|
19062
|
-
else if (textAlign === 'center') {
|
|
19063
|
-
bboxOffset[0] = bboxWH[0] / -2;
|
|
19064
|
-
}
|
|
19065
|
-
else if (textAlign === 'right' || textAlign === 'end') {
|
|
19066
|
-
bboxOffset[0] = -bboxWH[0];
|
|
19067
|
-
}
|
|
19068
|
-
if (textBaseline === 'top') ;
|
|
19069
|
-
else if (textBaseline === 'middle') {
|
|
19070
|
-
bboxOffset[1] = bboxWH[1] / -2;
|
|
19071
|
-
}
|
|
19072
|
-
else if (textBaseline === 'bottom') {
|
|
19073
|
-
bboxOffset[1] = -bboxWH[1];
|
|
19074
|
-
}
|
|
19075
|
-
const bbox = {
|
|
19076
|
-
xOffset: bboxOffset[0],
|
|
19077
|
-
yOffset: bboxOffset[1],
|
|
19078
|
-
width: bboxWH[0],
|
|
19079
|
-
height: bboxWH[1]
|
|
19080
|
-
};
|
|
19081
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
19082
|
-
}
|
|
19083
19137
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = '', wordBreak, lineWidth, suffixPosition = 'end') {
|
|
19084
19138
|
lines = lines.map(l => l.toString());
|
|
19085
19139
|
const linesLayout = [];
|
|
@@ -19087,10 +19141,15 @@ class CanvasTextLayout {
|
|
|
19087
19141
|
if (typeof lineWidth === 'number' && lineWidth !== Infinity) {
|
|
19088
19142
|
let width;
|
|
19089
19143
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
19090
|
-
|
|
19144
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
19145
|
+
width = Math.min(metrics.width, lineWidth);
|
|
19091
19146
|
linesLayout.push({
|
|
19092
|
-
str:
|
|
19093
|
-
|
|
19147
|
+
str: metrics.width <= lineWidth
|
|
19148
|
+
? lines[i].toString()
|
|
19149
|
+
: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
19150
|
+
width,
|
|
19151
|
+
ascent: metrics.ascent,
|
|
19152
|
+
descent: metrics.descent
|
|
19094
19153
|
});
|
|
19095
19154
|
}
|
|
19096
19155
|
bboxWH[0] = lineWidth;
|
|
@@ -19101,9 +19160,10 @@ class CanvasTextLayout {
|
|
|
19101
19160
|
let text;
|
|
19102
19161
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
19103
19162
|
text = lines[i];
|
|
19104
|
-
|
|
19163
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
19164
|
+
width = metrics.width;
|
|
19105
19165
|
lineWidth = Math.max(lineWidth, width);
|
|
19106
|
-
linesLayout.push({ str: text, width });
|
|
19166
|
+
linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent });
|
|
19107
19167
|
}
|
|
19108
19168
|
bboxWH[0] = lineWidth;
|
|
19109
19169
|
}
|
|
@@ -19152,7 +19212,7 @@ class CanvasTextLayout {
|
|
|
19152
19212
|
else if (textAlign === 'right' || textAlign === 'end') {
|
|
19153
19213
|
line.leftOffset = bbox.width - line.width;
|
|
19154
19214
|
}
|
|
19155
|
-
line.topOffset =
|
|
19215
|
+
line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
|
|
19156
19216
|
origin[1] += lineHeight;
|
|
19157
19217
|
return line;
|
|
19158
19218
|
}
|
|
@@ -19161,6 +19221,7 @@ class CanvasTextLayout {
|
|
|
19161
19221
|
const TEXT_UPDATE_TAG_KEY = [
|
|
19162
19222
|
'text',
|
|
19163
19223
|
'maxLineWidth',
|
|
19224
|
+
'maxWidth',
|
|
19164
19225
|
'textAlign',
|
|
19165
19226
|
'textBaseline',
|
|
19166
19227
|
'heightLimit',
|
|
@@ -19188,20 +19249,14 @@ class Text extends Graphic {
|
|
|
19188
19249
|
var _a;
|
|
19189
19250
|
const attribute = this.attribute;
|
|
19190
19251
|
const textTheme = this.getGraphicTheme();
|
|
19191
|
-
|
|
19192
|
-
|
|
19193
|
-
}
|
|
19194
|
-
const { maxLineWidth = textTheme.maxLineWidth } = attribute;
|
|
19195
|
-
if (!Number.isFinite(maxLineWidth)) {
|
|
19252
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
19253
|
+
if (!Number.isFinite(maxWidth)) {
|
|
19196
19254
|
return ((_a = attribute.text) !== null && _a !== void 0 ? _a : textTheme.text).toString();
|
|
19197
19255
|
}
|
|
19198
19256
|
this.tryUpdateAABBBounds();
|
|
19199
19257
|
return this.cache.clipedText;
|
|
19200
19258
|
}
|
|
19201
19259
|
get clipedWidth() {
|
|
19202
|
-
if (!this.isSimplify()) {
|
|
19203
|
-
return undefined;
|
|
19204
|
-
}
|
|
19205
19260
|
this.tryUpdateAABBBounds();
|
|
19206
19261
|
return this.cache.clipedWidth;
|
|
19207
19262
|
}
|
|
@@ -19209,10 +19264,11 @@ class Text extends Graphic {
|
|
|
19209
19264
|
var _a, _b;
|
|
19210
19265
|
const textTheme = this.getGraphicTheme();
|
|
19211
19266
|
const attribute = this.attribute;
|
|
19212
|
-
const
|
|
19213
|
-
if (!Number.isFinite(
|
|
19267
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
19268
|
+
if (!Number.isFinite(maxWidth)) {
|
|
19214
19269
|
return false;
|
|
19215
19270
|
}
|
|
19271
|
+
const { text } = this.attribute;
|
|
19216
19272
|
this.tryUpdateAABBBounds();
|
|
19217
19273
|
if ((_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData) === null || _b === void 0 ? void 0 : _b.lines) {
|
|
19218
19274
|
let mergedText = '';
|
|
@@ -19231,15 +19287,9 @@ class Text extends Graphic {
|
|
|
19231
19287
|
return this.clipedText !== attribute.text.toString();
|
|
19232
19288
|
}
|
|
19233
19289
|
get multilineLayout() {
|
|
19234
|
-
if (!this.isMultiLine) {
|
|
19235
|
-
return undefined;
|
|
19236
|
-
}
|
|
19237
19290
|
this.tryUpdateAABBBounds();
|
|
19238
19291
|
return this.cache.layoutData;
|
|
19239
19292
|
}
|
|
19240
|
-
isSimplify() {
|
|
19241
|
-
return !this.isMultiLine && this.attribute.direction !== 'vertical';
|
|
19242
|
-
}
|
|
19243
19293
|
get isMultiLine() {
|
|
19244
19294
|
return Array.isArray(this.attribute.text) || this.attribute.whiteSpace === 'normal';
|
|
19245
19295
|
}
|
|
@@ -19307,13 +19357,64 @@ class Text extends Graphic {
|
|
|
19307
19357
|
transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix);
|
|
19308
19358
|
return aabbBounds;
|
|
19309
19359
|
}
|
|
19360
|
+
updateSingallineAABBBounds(text) {
|
|
19361
|
+
this.updateMultilineAABBBounds([text]);
|
|
19362
|
+
const layoutData = this.cache.layoutData;
|
|
19363
|
+
if (layoutData) {
|
|
19364
|
+
const line = layoutData.lines[0];
|
|
19365
|
+
this.cache.clipedText = line.str;
|
|
19366
|
+
this.cache.clipedWidth = line.width;
|
|
19367
|
+
}
|
|
19368
|
+
return this._AABBBounds;
|
|
19369
|
+
}
|
|
19370
|
+
updateMultilineAABBBounds(text) {
|
|
19371
|
+
const textTheme = this.getGraphicTheme();
|
|
19372
|
+
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19373
|
+
const b = direction === 'horizontal'
|
|
19374
|
+
? this.updateHorizontalMultilineAABBBounds(text)
|
|
19375
|
+
: this.updateVerticalMultilineAABBBounds(text);
|
|
19376
|
+
if (direction === 'horizontal') {
|
|
19377
|
+
if (underlineOffset) {
|
|
19378
|
+
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19379
|
+
}
|
|
19380
|
+
}
|
|
19381
|
+
return b;
|
|
19382
|
+
}
|
|
19383
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
19384
|
+
var _a;
|
|
19385
|
+
const textTheme = this.getGraphicTheme();
|
|
19386
|
+
const attribute = this.attribute;
|
|
19387
|
+
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, ignoreBuf = textTheme.ignoreBuf, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition } = attribute;
|
|
19388
|
+
const lineHeight = this.getLineHeight(attribute, textTheme);
|
|
19389
|
+
if (whiteSpace === 'normal' || wrap) {
|
|
19390
|
+
return this.updateWrapAABBBounds(text);
|
|
19391
|
+
}
|
|
19392
|
+
if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
|
|
19393
|
+
const bbox = this.cache.layoutData.bbox;
|
|
19394
|
+
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19395
|
+
if (stroke) {
|
|
19396
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19397
|
+
}
|
|
19398
|
+
return this._AABBBounds;
|
|
19399
|
+
}
|
|
19400
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
19401
|
+
const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
|
|
19402
|
+
const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, maxLineWidth, suffixPosition);
|
|
19403
|
+
const { bbox } = layoutData;
|
|
19404
|
+
this.cache.layoutData = layoutData;
|
|
19405
|
+
this.clearUpdateShapeTag();
|
|
19406
|
+
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19407
|
+
if (stroke) {
|
|
19408
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19409
|
+
}
|
|
19410
|
+
return this._AABBBounds;
|
|
19411
|
+
}
|
|
19310
19412
|
updateWrapAABBBounds(text) {
|
|
19311
|
-
var _a, _b, _c
|
|
19413
|
+
var _a, _b, _c;
|
|
19312
19414
|
const textTheme = this.getGraphicTheme();
|
|
19313
19415
|
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp } = this.attribute;
|
|
19314
|
-
const lineHeight =
|
|
19315
|
-
|
|
19316
|
-
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
19416
|
+
const lineHeight = this.getLineHeight(this.attribute, textTheme);
|
|
19417
|
+
if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
|
|
19317
19418
|
const bbox = this.cache.layoutData.bbox;
|
|
19318
19419
|
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19319
19420
|
if (stroke) {
|
|
@@ -19322,7 +19423,8 @@ class Text extends Graphic {
|
|
|
19322
19423
|
return this._AABBBounds;
|
|
19323
19424
|
}
|
|
19324
19425
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
19325
|
-
const
|
|
19426
|
+
const textOptions = { fontSize, fontWeight, fontFamily };
|
|
19427
|
+
const layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure);
|
|
19326
19428
|
const lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()];
|
|
19327
19429
|
const linesLayout = [];
|
|
19328
19430
|
const bboxWH = [0, 0];
|
|
@@ -19339,19 +19441,22 @@ class Text extends Graphic {
|
|
|
19339
19441
|
const str = lines[i];
|
|
19340
19442
|
let needCut = true;
|
|
19341
19443
|
if (i === lineCountLimit - 1) {
|
|
19342
|
-
const clip =
|
|
19444
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, false, suffixPosition, i !== lines.length - 1);
|
|
19445
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19343
19446
|
linesLayout.push({
|
|
19344
19447
|
str: clip.str,
|
|
19345
|
-
width: clip.width
|
|
19448
|
+
width: clip.width,
|
|
19449
|
+
ascent: matrics.ascent,
|
|
19450
|
+
descent: matrics.descent
|
|
19346
19451
|
});
|
|
19347
19452
|
break;
|
|
19348
19453
|
}
|
|
19349
|
-
const clip =
|
|
19454
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, wordBreak !== 'break-all', wordBreak === 'keep-all');
|
|
19350
19455
|
if ((str !== '' && clip.str === '') || clip.wordBreaked) {
|
|
19351
19456
|
if (ellipsis) {
|
|
19352
|
-
const clipEllipsis =
|
|
19353
|
-
clip.str = (
|
|
19354
|
-
clip.width = (
|
|
19457
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19458
|
+
clip.str = (_b = clipEllipsis.str) !== null && _b !== void 0 ? _b : '';
|
|
19459
|
+
clip.width = (_c = clipEllipsis.width) !== null && _c !== void 0 ? _c : 0;
|
|
19355
19460
|
}
|
|
19356
19461
|
else {
|
|
19357
19462
|
clip.str = '';
|
|
@@ -19359,9 +19464,12 @@ class Text extends Graphic {
|
|
|
19359
19464
|
}
|
|
19360
19465
|
needCut = false;
|
|
19361
19466
|
}
|
|
19467
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19362
19468
|
linesLayout.push({
|
|
19363
19469
|
str: clip.str,
|
|
19364
|
-
width: clip.width
|
|
19470
|
+
width: clip.width,
|
|
19471
|
+
ascent: matrics.ascent,
|
|
19472
|
+
descent: matrics.descent
|
|
19365
19473
|
});
|
|
19366
19474
|
let cutLength = clip.str.length;
|
|
19367
19475
|
if (clip.wordBreaked && !(str !== '' && clip.str === '')) {
|
|
@@ -19370,10 +19478,7 @@ class Text extends Graphic {
|
|
|
19370
19478
|
}
|
|
19371
19479
|
if (clip.str.length === str.length) ;
|
|
19372
19480
|
else if (needCut) {
|
|
19373
|
-
|
|
19374
|
-
if (wordBreak === 'keep-all') {
|
|
19375
|
-
newStr = newStr.replace(/^\s+/g, '');
|
|
19376
|
-
}
|
|
19481
|
+
const newStr = str.substring(cutLength);
|
|
19377
19482
|
lines.splice(i + 1, 0, newStr);
|
|
19378
19483
|
}
|
|
19379
19484
|
}
|
|
@@ -19390,22 +19495,26 @@ class Text extends Graphic {
|
|
|
19390
19495
|
let text;
|
|
19391
19496
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
19392
19497
|
if (i === lineCountLimit - 1) {
|
|
19393
|
-
const clip =
|
|
19498
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19499
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19394
19500
|
linesLayout.push({
|
|
19395
19501
|
str: clip.str,
|
|
19396
|
-
width: clip.width
|
|
19502
|
+
width: clip.width,
|
|
19503
|
+
ascent: matrics.ascent,
|
|
19504
|
+
descent: matrics.descent
|
|
19397
19505
|
});
|
|
19398
19506
|
lineWidth = Math.max(lineWidth, clip.width);
|
|
19399
19507
|
break;
|
|
19400
19508
|
}
|
|
19401
19509
|
text = lines[i];
|
|
19402
|
-
width =
|
|
19510
|
+
width = textMeasure.measureTextWidth(text, textOptions);
|
|
19403
19511
|
lineWidth = Math.max(lineWidth, width);
|
|
19404
|
-
|
|
19512
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
19513
|
+
linesLayout.push({ str: text, width, ascent: matrics.ascent, descent: matrics.descent });
|
|
19405
19514
|
}
|
|
19406
19515
|
bboxWH[0] = lineWidth;
|
|
19407
19516
|
}
|
|
19408
|
-
bboxWH[1] = linesLayout.length *
|
|
19517
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
19409
19518
|
const bbox = {
|
|
19410
19519
|
xOffset: 0,
|
|
19411
19520
|
yOffset: 0,
|
|
@@ -19422,212 +19531,19 @@ class Text extends Graphic {
|
|
|
19422
19531
|
}
|
|
19423
19532
|
return this._AABBBounds;
|
|
19424
19533
|
}
|
|
19425
|
-
updateSingallineAABBBounds(text) {
|
|
19426
|
-
const textTheme = this.getGraphicTheme();
|
|
19427
|
-
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19428
|
-
const b = direction === 'horizontal'
|
|
19429
|
-
? this.updateHorizontalSinglelineAABBBounds(text)
|
|
19430
|
-
: this.updateVerticalSinglelineAABBBounds(text);
|
|
19431
|
-
if (direction === 'horizontal') {
|
|
19432
|
-
if (underlineOffset) {
|
|
19433
|
-
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19434
|
-
}
|
|
19435
|
-
}
|
|
19436
|
-
return b;
|
|
19437
|
-
}
|
|
19438
|
-
updateMultilineAABBBounds(text) {
|
|
19439
|
-
const textTheme = this.getGraphicTheme();
|
|
19440
|
-
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19441
|
-
const b = direction === 'horizontal'
|
|
19442
|
-
? this.updateHorizontalMultilineAABBBounds(text)
|
|
19443
|
-
: this.updateVerticalMultilineAABBBounds(text);
|
|
19444
|
-
if (direction === 'horizontal') {
|
|
19445
|
-
if (underlineOffset) {
|
|
19446
|
-
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19447
|
-
}
|
|
19448
|
-
}
|
|
19449
|
-
return b;
|
|
19450
|
-
}
|
|
19451
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
19452
|
-
var _a, _b;
|
|
19453
|
-
const textTheme = this.getGraphicTheme();
|
|
19454
|
-
const { wrap = textTheme.wrap } = this.attribute;
|
|
19455
|
-
if (wrap) {
|
|
19456
|
-
return this.updateWrapAABBBounds([text]);
|
|
19457
|
-
}
|
|
19458
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19459
|
-
let width;
|
|
19460
|
-
let str;
|
|
19461
|
-
const attribute = this.attribute;
|
|
19462
|
-
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, ignoreBuf = textTheme.ignoreBuf, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition } = attribute;
|
|
19463
|
-
if (whiteSpace === 'normal') {
|
|
19464
|
-
return this.updateWrapAABBBounds(text);
|
|
19465
|
-
}
|
|
19466
|
-
const buf = ignoreBuf ? 0 : Math.max(2, fontSize * 0.075);
|
|
19467
|
-
const textFontSize = attribute.fontSize || textTheme.fontSize;
|
|
19468
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) !== null && _a !== void 0 ? _a : textFontSize + buf;
|
|
19469
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
19470
|
-
width = (_b = this.cache.clipedWidth) !== null && _b !== void 0 ? _b : 0;
|
|
19471
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19472
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19473
|
-
this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight);
|
|
19474
|
-
if (stroke) {
|
|
19475
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19476
|
-
}
|
|
19477
|
-
return this._AABBBounds;
|
|
19478
|
-
}
|
|
19479
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
19480
|
-
if (ellipsis) {
|
|
19481
|
-
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
19482
|
-
const data = textMeasure.clipTextWithSuffix(text.toString(), { fontSize, fontWeight, fontFamily }, maxLineWidth, strEllipsis, false, suffixPosition);
|
|
19483
|
-
str = data.str;
|
|
19484
|
-
width = data.width;
|
|
19485
|
-
}
|
|
19486
|
-
else {
|
|
19487
|
-
const data = textMeasure.clipText(text.toString(), { fontSize, fontWeight, fontFamily }, maxLineWidth, false);
|
|
19488
|
-
str = data.str;
|
|
19489
|
-
width = data.width;
|
|
19490
|
-
}
|
|
19491
|
-
this.cache.clipedText = str;
|
|
19492
|
-
this.cache.clipedWidth = width;
|
|
19493
|
-
}
|
|
19494
|
-
else {
|
|
19495
|
-
width = textMeasure.measureTextWidth(text.toString(), { fontSize, fontWeight, fontFamily });
|
|
19496
|
-
this.cache.clipedText = text.toString();
|
|
19497
|
-
this.cache.clipedWidth = width;
|
|
19498
|
-
}
|
|
19499
|
-
this.clearUpdateShapeTag();
|
|
19500
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19501
|
-
let lh = lineHeight;
|
|
19502
|
-
if (application.global && application.global.isSafari()) {
|
|
19503
|
-
lh += fontSize * 0.2;
|
|
19504
|
-
}
|
|
19505
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
19506
|
-
this._AABBBounds.set(dx, dy, dx + width, dy + lh);
|
|
19507
|
-
if (stroke) {
|
|
19508
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19509
|
-
}
|
|
19510
|
-
return this._AABBBounds;
|
|
19511
|
-
}
|
|
19512
|
-
getBaselineMapAlign() {
|
|
19513
|
-
return Text.baselineMapAlign;
|
|
19514
|
-
}
|
|
19515
|
-
getAlignMapBaseline() {
|
|
19516
|
-
return Text.alignMapBaseline;
|
|
19517
|
-
}
|
|
19518
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
19519
|
-
var _a, _b, _c;
|
|
19520
|
-
const textTheme = this.getGraphicTheme();
|
|
19521
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19522
|
-
let width;
|
|
19523
|
-
const attribute = this.attribute;
|
|
19524
|
-
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
19525
|
-
const buf = ignoreBuf ? 0 : 2;
|
|
19526
|
-
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode, suffixPosition = textTheme.suffixPosition } = attribute;
|
|
19527
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
19528
|
-
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
19529
|
-
if (!verticalMode) {
|
|
19530
|
-
const t = textAlign;
|
|
19531
|
-
textAlign = (_b = Text.baselineMapAlign[textBaseline]) !== null && _b !== void 0 ? _b : 'left';
|
|
19532
|
-
textBaseline = (_c = Text.alignMapBaseline[t]) !== null && _c !== void 0 ? _c : 'top';
|
|
19533
|
-
}
|
|
19534
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
19535
|
-
width = this.cache.clipedWidth;
|
|
19536
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19537
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19538
|
-
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19539
|
-
if (stroke) {
|
|
19540
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19541
|
-
}
|
|
19542
|
-
return this._AABBBounds;
|
|
19543
|
-
}
|
|
19544
|
-
let verticalList = [
|
|
19545
|
-
verticalLayout(text.toString())
|
|
19546
|
-
];
|
|
19547
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
19548
|
-
if (ellipsis) {
|
|
19549
|
-
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
19550
|
-
const data = textMeasure.clipTextWithSuffixVertical(verticalList[0], { fontSize, fontWeight, fontFamily }, maxLineWidth, strEllipsis, false, suffixPosition);
|
|
19551
|
-
verticalList = [data.verticalList];
|
|
19552
|
-
width = data.width;
|
|
19553
|
-
}
|
|
19554
|
-
else {
|
|
19555
|
-
const data = textMeasure.clipTextVertical(verticalList[0], { fontSize, fontWeight, fontFamily }, maxLineWidth, false);
|
|
19556
|
-
verticalList = [data.verticalList];
|
|
19557
|
-
width = data.width;
|
|
19558
|
-
}
|
|
19559
|
-
this.cache.verticalList = verticalList;
|
|
19560
|
-
this.cache.clipedWidth = width;
|
|
19561
|
-
}
|
|
19562
|
-
else {
|
|
19563
|
-
width = 0;
|
|
19564
|
-
verticalList[0].forEach(t => {
|
|
19565
|
-
const w = t.direction === TextDirection.HORIZONTAL
|
|
19566
|
-
? fontSize
|
|
19567
|
-
: textMeasure.measureTextWidth(t.text, { fontSize, fontWeight, fontFamily });
|
|
19568
|
-
width += w;
|
|
19569
|
-
t.width = w;
|
|
19570
|
-
});
|
|
19571
|
-
this.cache.verticalList = verticalList;
|
|
19572
|
-
this.cache.clipedWidth = width;
|
|
19573
|
-
}
|
|
19574
|
-
this.clearUpdateShapeTag();
|
|
19575
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19576
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19577
|
-
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19578
|
-
if (stroke) {
|
|
19579
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19580
|
-
}
|
|
19581
|
-
return this._AABBBounds;
|
|
19582
|
-
}
|
|
19583
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
19584
|
-
var _a, _b;
|
|
19585
|
-
const textTheme = this.getGraphicTheme();
|
|
19586
|
-
const { wrap = textTheme.wrap } = this.attribute;
|
|
19587
|
-
if (wrap) {
|
|
19588
|
-
return this.updateWrapAABBBounds(text);
|
|
19589
|
-
}
|
|
19590
|
-
const attribute = this.attribute;
|
|
19591
|
-
const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition } = attribute;
|
|
19592
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize);
|
|
19593
|
-
if (whiteSpace === 'normal') {
|
|
19594
|
-
return this.updateWrapAABBBounds(text);
|
|
19595
|
-
}
|
|
19596
|
-
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
19597
|
-
const bbox = this.cache.layoutData.bbox;
|
|
19598
|
-
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19599
|
-
if (stroke) {
|
|
19600
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19601
|
-
}
|
|
19602
|
-
return this._AABBBounds;
|
|
19603
|
-
}
|
|
19604
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19605
|
-
const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
|
|
19606
|
-
const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, maxLineWidth, suffixPosition);
|
|
19607
|
-
const { bbox } = layoutData;
|
|
19608
|
-
this.cache.layoutData = layoutData;
|
|
19609
|
-
this.clearUpdateShapeTag();
|
|
19610
|
-
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19611
|
-
if (stroke) {
|
|
19612
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19613
|
-
}
|
|
19614
|
-
return this._AABBBounds;
|
|
19615
|
-
}
|
|
19616
19534
|
updateVerticalMultilineAABBBounds(text) {
|
|
19617
|
-
var _a, _b
|
|
19535
|
+
var _a, _b;
|
|
19618
19536
|
const textTheme = this.getGraphicTheme();
|
|
19619
19537
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
19620
19538
|
let width;
|
|
19621
19539
|
const attribute = this.attribute;
|
|
19622
|
-
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
19623
|
-
const buf = ignoreBuf ? 0 : 2;
|
|
19624
19540
|
const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode, suffixPosition = textTheme.suffixPosition } = attribute;
|
|
19625
|
-
const lineHeight = (
|
|
19541
|
+
const lineHeight = this.getLineHeight(attribute, textTheme);
|
|
19626
19542
|
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
19627
19543
|
if (!verticalMode) {
|
|
19628
19544
|
const t = textAlign;
|
|
19629
|
-
textAlign = (
|
|
19630
|
-
textBaseline = (
|
|
19545
|
+
textAlign = (_a = Text.baselineMapAlign[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
|
|
19546
|
+
textBaseline = (_b = Text.alignMapBaseline[t]) !== null && _b !== void 0 ? _b : 'top';
|
|
19631
19547
|
}
|
|
19632
19548
|
width = 0;
|
|
19633
19549
|
if (!this.shouldUpdateShape() && this.cache) {
|
|
@@ -19687,6 +19603,15 @@ class Text extends Graphic {
|
|
|
19687
19603
|
}
|
|
19688
19604
|
return this._AABBBounds;
|
|
19689
19605
|
}
|
|
19606
|
+
getMaxWidth(theme) {
|
|
19607
|
+
var _a, _b;
|
|
19608
|
+
const attribute = this.attribute;
|
|
19609
|
+
return (_b = (_a = attribute.maxLineWidth) !== null && _a !== void 0 ? _a : attribute.maxWidth) !== null && _b !== void 0 ? _b : theme.maxWidth;
|
|
19610
|
+
}
|
|
19611
|
+
getLineHeight(attribute, textTheme) {
|
|
19612
|
+
var _a;
|
|
19613
|
+
return ((_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize));
|
|
19614
|
+
}
|
|
19690
19615
|
needUpdateTags(keys, k = TEXT_UPDATE_TAG_KEY) {
|
|
19691
19616
|
return super.needUpdateTags(keys, k);
|
|
19692
19617
|
}
|
|
@@ -19699,6 +19624,12 @@ class Text extends Graphic {
|
|
|
19699
19624
|
getNoWorkAnimateAttr() {
|
|
19700
19625
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
19701
19626
|
}
|
|
19627
|
+
getBaselineMapAlign() {
|
|
19628
|
+
return Text.baselineMapAlign;
|
|
19629
|
+
}
|
|
19630
|
+
getAlignMapBaseline() {
|
|
19631
|
+
return Text.alignMapBaseline;
|
|
19632
|
+
}
|
|
19702
19633
|
}
|
|
19703
19634
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({ ellipsis: 1, wordBreak: 1, direction: 1, textAlign: 1, textBaseline: 1, fontFamily: 1, fontWeight: 1 }, NOWORK_ANIMATE_ATTR);
|
|
19704
19635
|
Text.baselineMapAlign = {
|
|
@@ -19762,7 +19693,9 @@ class WrapText extends Text {
|
|
|
19762
19693
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19763
19694
|
linesLayout.push({
|
|
19764
19695
|
str: clip.str,
|
|
19765
|
-
width: clip.width
|
|
19696
|
+
width: clip.width,
|
|
19697
|
+
ascent: 0,
|
|
19698
|
+
descent: 0
|
|
19766
19699
|
});
|
|
19767
19700
|
break;
|
|
19768
19701
|
}
|
|
@@ -19781,7 +19714,9 @@ class WrapText extends Text {
|
|
|
19781
19714
|
}
|
|
19782
19715
|
linesLayout.push({
|
|
19783
19716
|
str: clip.str,
|
|
19784
|
-
width: clip.width
|
|
19717
|
+
width: clip.width,
|
|
19718
|
+
ascent: 0,
|
|
19719
|
+
descent: 0
|
|
19785
19720
|
});
|
|
19786
19721
|
if (clip.str.length === str.length) ;
|
|
19787
19722
|
else if (needCut) {
|
|
@@ -19805,7 +19740,9 @@ class WrapText extends Text {
|
|
|
19805
19740
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19806
19741
|
linesLayout.push({
|
|
19807
19742
|
str: clip.str,
|
|
19808
|
-
width: clip.width
|
|
19743
|
+
width: clip.width,
|
|
19744
|
+
ascent: 0,
|
|
19745
|
+
descent: 0
|
|
19809
19746
|
});
|
|
19810
19747
|
lineWidth = Math.max(lineWidth, clip.width);
|
|
19811
19748
|
break;
|
|
@@ -19813,7 +19750,7 @@ class WrapText extends Text {
|
|
|
19813
19750
|
text = lines[i];
|
|
19814
19751
|
width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');
|
|
19815
19752
|
lineWidth = Math.max(lineWidth, width);
|
|
19816
|
-
linesLayout.push({ str: text, width });
|
|
19753
|
+
linesLayout.push({ str: text, width, ascent: 0, descent: 0 });
|
|
19817
19754
|
}
|
|
19818
19755
|
bboxWH[0] = lineWidth;
|
|
19819
19756
|
}
|
|
@@ -19876,6 +19813,9 @@ class BaseSymbol {
|
|
|
19876
19813
|
bounds.y2 = size[1] / 2;
|
|
19877
19814
|
}
|
|
19878
19815
|
}
|
|
19816
|
+
parseSize(size) {
|
|
19817
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
19818
|
+
}
|
|
19879
19819
|
}
|
|
19880
19820
|
|
|
19881
19821
|
function circle(ctx, r, x, y, z) {
|
|
@@ -19894,15 +19834,15 @@ class CircleSymbol extends BaseSymbol {
|
|
|
19894
19834
|
this.pathStr = 'M0.5,0A0.5,0.5,0,1,1,-0.5,0A0.5,0.5,0,1,1,0.5,0';
|
|
19895
19835
|
}
|
|
19896
19836
|
draw(ctx, size, x, y, z) {
|
|
19897
|
-
const r = size / 2;
|
|
19837
|
+
const r = this.parseSize(size) / 2;
|
|
19898
19838
|
return circle(ctx, r, x, y, z);
|
|
19899
19839
|
}
|
|
19900
19840
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
19901
|
-
const r = size / 2 + offset;
|
|
19841
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
19902
19842
|
return circle(ctx, r, x, y, z);
|
|
19903
19843
|
}
|
|
19904
19844
|
drawToSvgPath(size, x, y, z) {
|
|
19905
|
-
const r = size / 2;
|
|
19845
|
+
const r = this.parseSize(size) / 2;
|
|
19906
19846
|
return `M ${x - r}, ${y} a ${r},${r} 0 1,0 ${r * 2},0 a ${r},${r} 0 1,0 -${r * 2},0`;
|
|
19907
19847
|
}
|
|
19908
19848
|
}
|
|
@@ -19947,11 +19887,11 @@ class CrossSymbol extends BaseSymbol {
|
|
|
19947
19887
|
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';
|
|
19948
19888
|
}
|
|
19949
19889
|
draw(ctx, size, x, y, z) {
|
|
19950
|
-
const r = size / 6;
|
|
19890
|
+
const r = this.parseSize(size) / 6;
|
|
19951
19891
|
return cross(ctx, r, x, y, z);
|
|
19952
19892
|
}
|
|
19953
19893
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
19954
|
-
const r = size / 6;
|
|
19894
|
+
const r = this.parseSize(size) / 6;
|
|
19955
19895
|
return crossOffset(ctx, r, x, y, offset, z);
|
|
19956
19896
|
}
|
|
19957
19897
|
}
|
|
@@ -19972,15 +19912,15 @@ class DiamondSymbol extends BaseSymbol {
|
|
|
19972
19912
|
this.pathStr = 'M-0.5,0L0,-0.5L0.5,0L0,0.5Z';
|
|
19973
19913
|
}
|
|
19974
19914
|
draw(ctx, size, x, y, z) {
|
|
19975
|
-
const r = size / 2;
|
|
19915
|
+
const r = this.parseSize(size) / 2;
|
|
19976
19916
|
return diamond(ctx, r, x, y, z);
|
|
19977
19917
|
}
|
|
19978
19918
|
drawFitDir(ctx, size, x, y, z) {
|
|
19979
|
-
const r = size / 2;
|
|
19919
|
+
const r = this.parseSize(size) / 2;
|
|
19980
19920
|
return diamond(ctx, r, x, y, z);
|
|
19981
19921
|
}
|
|
19982
19922
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
19983
|
-
const r = size / 2 + offset;
|
|
19923
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
19984
19924
|
return diamond(ctx, r, x, y, z);
|
|
19985
19925
|
}
|
|
19986
19926
|
}
|
|
@@ -19998,11 +19938,11 @@ class SquareSymbol extends BaseSymbol {
|
|
|
19998
19938
|
this.pathStr = 'M-0.5,-0.5h1v1h-1Z';
|
|
19999
19939
|
}
|
|
20000
19940
|
draw(ctx, size, x, y) {
|
|
20001
|
-
const r = size / 2;
|
|
19941
|
+
const r = this.parseSize(size) / 2;
|
|
20002
19942
|
return square(ctx, r, x, y);
|
|
20003
19943
|
}
|
|
20004
19944
|
drawOffset(ctx, size, x, y, offset) {
|
|
20005
|
-
const r = size / 2 + offset;
|
|
19945
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20006
19946
|
return square(ctx, r, x, y);
|
|
20007
19947
|
}
|
|
20008
19948
|
}
|
|
@@ -20022,11 +19962,11 @@ class TriangleUpSymbol extends BaseSymbol {
|
|
|
20022
19962
|
this.pathStr = 'M0.5,0.5 L-0.5,0.5 L0,-0.5 Z';
|
|
20023
19963
|
}
|
|
20024
19964
|
draw(ctx, size, x, y) {
|
|
20025
|
-
const r = size / 2;
|
|
19965
|
+
const r = this.parseSize(size) / 2;
|
|
20026
19966
|
return trianglUpOffset(ctx, r, x, y);
|
|
20027
19967
|
}
|
|
20028
19968
|
drawOffset(ctx, size, x, y, offset) {
|
|
20029
|
-
const r = size / 2;
|
|
19969
|
+
const r = this.parseSize(size) / 2;
|
|
20030
19970
|
return trianglUpOffset(ctx, r, x, y, offset);
|
|
20031
19971
|
}
|
|
20032
19972
|
}
|
|
@@ -20065,11 +20005,11 @@ class StarSymbol extends BaseSymbol {
|
|
|
20065
20005
|
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';
|
|
20066
20006
|
}
|
|
20067
20007
|
draw(ctx, size, transX, transY) {
|
|
20068
|
-
const r = size / 2;
|
|
20008
|
+
const r = this.parseSize(size) / 2;
|
|
20069
20009
|
return star(ctx, r, transX, transY);
|
|
20070
20010
|
}
|
|
20071
20011
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20072
|
-
const r = size / 2 + offset;
|
|
20012
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20073
20013
|
return star(ctx, r, transX, transY);
|
|
20074
20014
|
}
|
|
20075
20015
|
}
|
|
@@ -20098,11 +20038,11 @@ class ArrowSymbol extends BaseSymbol {
|
|
|
20098
20038
|
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';
|
|
20099
20039
|
}
|
|
20100
20040
|
draw(ctx, size, transX, transY) {
|
|
20101
|
-
const r = size / 2;
|
|
20041
|
+
const r = this.parseSize(size) / 2;
|
|
20102
20042
|
return arrow(ctx, r, transX, transY);
|
|
20103
20043
|
}
|
|
20104
20044
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20105
|
-
const r = size / 2 + offset;
|
|
20045
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20106
20046
|
return arrow(ctx, r, transX, transY);
|
|
20107
20047
|
}
|
|
20108
20048
|
}
|
|
@@ -20123,11 +20063,11 @@ class WedgeSymbol extends BaseSymbol {
|
|
|
20123
20063
|
this.pathStr = 'M0,-0.5773502691896257L-0.125,0.28867513459481287L0.125,0.28867513459481287Z';
|
|
20124
20064
|
}
|
|
20125
20065
|
draw(ctx, size, transX, transY) {
|
|
20126
|
-
const r = size / 2;
|
|
20066
|
+
const r = this.parseSize(size) / 2;
|
|
20127
20067
|
return wedge(ctx, r, transX, transY);
|
|
20128
20068
|
}
|
|
20129
20069
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20130
|
-
const r = size / 2 + offset;
|
|
20070
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20131
20071
|
return wedge(ctx, r, transX, transY);
|
|
20132
20072
|
}
|
|
20133
20073
|
}
|
|
@@ -20145,11 +20085,11 @@ class StrokeSymbol extends BaseSymbol {
|
|
|
20145
20085
|
this.pathStr = '';
|
|
20146
20086
|
}
|
|
20147
20087
|
draw(ctx, size, transX, transY) {
|
|
20148
|
-
const r = size / 2;
|
|
20088
|
+
const r = this.parseSize(size) / 2;
|
|
20149
20089
|
return stroke(ctx, r, transX, transY);
|
|
20150
20090
|
}
|
|
20151
20091
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20152
|
-
const r = size / 2 + offset;
|
|
20092
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20153
20093
|
return stroke(ctx, r, transX, transY);
|
|
20154
20094
|
}
|
|
20155
20095
|
}
|
|
@@ -20184,11 +20124,11 @@ class WyeSymbol extends BaseSymbol {
|
|
|
20184
20124
|
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';
|
|
20185
20125
|
}
|
|
20186
20126
|
draw(ctx, size, transX, transY) {
|
|
20187
|
-
const r = size / 2;
|
|
20127
|
+
const r = this.parseSize(size) / 2;
|
|
20188
20128
|
return wye(ctx, r, transX, transY);
|
|
20189
20129
|
}
|
|
20190
20130
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20191
|
-
const r = size / 2 + offset;
|
|
20131
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20192
20132
|
return wye(ctx, r, transX, transY);
|
|
20193
20133
|
}
|
|
20194
20134
|
}
|
|
@@ -20208,11 +20148,11 @@ class TriangleLeftSymbol extends BaseSymbol {
|
|
|
20208
20148
|
this.pathStr = 'M-0.5,0 L0.5,0.5 L0.5,-0.5 Z';
|
|
20209
20149
|
}
|
|
20210
20150
|
draw(ctx, size, x, y) {
|
|
20211
|
-
const r = size / 2;
|
|
20151
|
+
const r = this.parseSize(size) / 2;
|
|
20212
20152
|
return trianglLeftOffset(ctx, r, x, y, 0);
|
|
20213
20153
|
}
|
|
20214
20154
|
drawOffset(ctx, size, x, y, offset) {
|
|
20215
|
-
const r = size / 2;
|
|
20155
|
+
const r = this.parseSize(size) / 2;
|
|
20216
20156
|
return trianglLeftOffset(ctx, r, x, y, offset);
|
|
20217
20157
|
}
|
|
20218
20158
|
}
|
|
@@ -20232,11 +20172,11 @@ class TriangleRightSymbol extends BaseSymbol {
|
|
|
20232
20172
|
this.pathStr = 'M-0.5,0.5 L0.5,0 L-0.5,-0.5 Z';
|
|
20233
20173
|
}
|
|
20234
20174
|
draw(ctx, size, x, y) {
|
|
20235
|
-
const r = size / 2;
|
|
20175
|
+
const r = this.parseSize(size) / 2;
|
|
20236
20176
|
return trianglRightOffset(ctx, r, x, y);
|
|
20237
20177
|
}
|
|
20238
20178
|
drawOffset(ctx, size, x, y, offset) {
|
|
20239
|
-
const r = size / 2;
|
|
20179
|
+
const r = this.parseSize(size) / 2;
|
|
20240
20180
|
return trianglRightOffset(ctx, r, x, y, offset);
|
|
20241
20181
|
}
|
|
20242
20182
|
}
|
|
@@ -20256,11 +20196,11 @@ class TriangleDownSymbol extends BaseSymbol {
|
|
|
20256
20196
|
this.pathStr = 'M-0.5,-0.5 L0.5,-0.5 L0,0.5 Z';
|
|
20257
20197
|
}
|
|
20258
20198
|
draw(ctx, size, x, y) {
|
|
20259
|
-
const r = size / 2;
|
|
20199
|
+
const r = this.parseSize(size) / 2;
|
|
20260
20200
|
return trianglDownOffset(ctx, r, x, y);
|
|
20261
20201
|
}
|
|
20262
20202
|
drawOffset(ctx, size, x, y, offset) {
|
|
20263
|
-
const r = size / 2;
|
|
20203
|
+
const r = this.parseSize(size) / 2;
|
|
20264
20204
|
return trianglDownOffset(ctx, r, x, y, offset);
|
|
20265
20205
|
}
|
|
20266
20206
|
}
|
|
@@ -20282,11 +20222,11 @@ class ThinTriangleSymbol extends BaseSymbol {
|
|
|
20282
20222
|
this.pathStr = 'M0,-0.5773502691896257L-0.5,0.28867513459481287L0.5,0.28867513459481287Z';
|
|
20283
20223
|
}
|
|
20284
20224
|
draw(ctx, size, x, y) {
|
|
20285
|
-
const r = size / 2 / sqrt3;
|
|
20225
|
+
const r = this.parseSize(size) / 2 / sqrt3;
|
|
20286
20226
|
return thinTriangle(ctx, r, x, y);
|
|
20287
20227
|
}
|
|
20288
20228
|
drawOffset(ctx, size, x, y, offset) {
|
|
20289
|
-
const r = size / 2 / sqrt3 + offset;
|
|
20229
|
+
const r = this.parseSize(size) / 2 / sqrt3 + offset;
|
|
20290
20230
|
return thinTriangle(ctx, r, x, y);
|
|
20291
20231
|
}
|
|
20292
20232
|
}
|
|
@@ -20306,11 +20246,11 @@ class Arrow2LeftSymbol extends BaseSymbol {
|
|
|
20306
20246
|
this.pathStr = 'M 0.25 -0.5 L -0.25 0 l 0.25 0.5';
|
|
20307
20247
|
}
|
|
20308
20248
|
draw(ctx, size, transX, transY) {
|
|
20309
|
-
const r = size / 4;
|
|
20249
|
+
const r = this.parseSize(size) / 4;
|
|
20310
20250
|
return arrow2Left(ctx, r, transX, transY);
|
|
20311
20251
|
}
|
|
20312
20252
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20313
|
-
const r = size / 4 + offset;
|
|
20253
|
+
const r = this.parseSize(size) / 4 + offset;
|
|
20314
20254
|
return arrow2Left(ctx, r, transX, transY);
|
|
20315
20255
|
}
|
|
20316
20256
|
}
|
|
@@ -20330,11 +20270,11 @@ class Arrow2RightSymbol extends BaseSymbol {
|
|
|
20330
20270
|
this.pathStr = 'M -0.25 -0.5 l 0.25 0 l -0.25 0.5';
|
|
20331
20271
|
}
|
|
20332
20272
|
draw(ctx, size, transX, transY) {
|
|
20333
|
-
const r = size / 4;
|
|
20273
|
+
const r = this.parseSize(size) / 4;
|
|
20334
20274
|
return arrow2Right(ctx, r, transX, transY);
|
|
20335
20275
|
}
|
|
20336
20276
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20337
|
-
const r = size / 4 + offset;
|
|
20277
|
+
const r = this.parseSize(size) / 4 + offset;
|
|
20338
20278
|
return arrow2Right(ctx, r, transX, transY);
|
|
20339
20279
|
}
|
|
20340
20280
|
}
|
|
@@ -20354,11 +20294,11 @@ class Arrow2UpSymbol extends BaseSymbol {
|
|
|
20354
20294
|
this.pathStr = 'M -0.5 0.25 L 0 -0.25 l 0.5 0.25';
|
|
20355
20295
|
}
|
|
20356
20296
|
draw(ctx, size, transX, transY) {
|
|
20357
|
-
const r = size / 4;
|
|
20297
|
+
const r = this.parseSize(size) / 4;
|
|
20358
20298
|
return arrow2Up(ctx, r, transX, transY);
|
|
20359
20299
|
}
|
|
20360
20300
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20361
|
-
const r = size / 4 + offset;
|
|
20301
|
+
const r = this.parseSize(size) / 4 + offset;
|
|
20362
20302
|
return arrow2Up(ctx, r, transX, transY);
|
|
20363
20303
|
}
|
|
20364
20304
|
}
|
|
@@ -20378,11 +20318,11 @@ class Arrow2DownSymbol extends BaseSymbol {
|
|
|
20378
20318
|
this.pathStr = 'M -0.5 -0.25 L 0 0.25 l 0.5 -0.25';
|
|
20379
20319
|
}
|
|
20380
20320
|
draw(ctx, size, transX, transY) {
|
|
20381
|
-
const r = size / 4;
|
|
20321
|
+
const r = this.parseSize(size) / 4;
|
|
20382
20322
|
return arrow2Down(ctx, r, transX, transY);
|
|
20383
20323
|
}
|
|
20384
20324
|
drawOffset(ctx, size, transX, transY, offset) {
|
|
20385
|
-
const r = size / 4 + offset;
|
|
20325
|
+
const r = this.parseSize(size) / 4 + offset;
|
|
20386
20326
|
return arrow2Down(ctx, r, transX, transY);
|
|
20387
20327
|
}
|
|
20388
20328
|
}
|
|
@@ -20400,15 +20340,15 @@ class LineVSymbol extends BaseSymbol {
|
|
|
20400
20340
|
this.pathStr = 'M0,-0.5L0,0.5';
|
|
20401
20341
|
}
|
|
20402
20342
|
draw(ctx, size, x, y, z) {
|
|
20403
|
-
const r = size / 2;
|
|
20343
|
+
const r = this.parseSize(size) / 2;
|
|
20404
20344
|
return lineV(ctx, r, x, y);
|
|
20405
20345
|
}
|
|
20406
20346
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
20407
|
-
const r = size / 2 + offset;
|
|
20347
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20408
20348
|
return lineV(ctx, r, x, y);
|
|
20409
20349
|
}
|
|
20410
20350
|
drawToSvgPath(size, x, y, z) {
|
|
20411
|
-
const r = size / 2;
|
|
20351
|
+
const r = this.parseSize(size) / 2;
|
|
20412
20352
|
return `M ${x}, ${y - r} L ${x},${y + r}`;
|
|
20413
20353
|
}
|
|
20414
20354
|
}
|
|
@@ -20426,15 +20366,15 @@ class LineHSymbol extends BaseSymbol {
|
|
|
20426
20366
|
this.pathStr = 'M-0.5,0L0.5,0';
|
|
20427
20367
|
}
|
|
20428
20368
|
draw(ctx, size, x, y, z) {
|
|
20429
|
-
const r = size / 2;
|
|
20369
|
+
const r = this.parseSize(size) / 2;
|
|
20430
20370
|
return lineH(ctx, r, x, y);
|
|
20431
20371
|
}
|
|
20432
20372
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
20433
|
-
const r = size / 2 + offset;
|
|
20373
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20434
20374
|
return lineH(ctx, r, x, y);
|
|
20435
20375
|
}
|
|
20436
20376
|
drawToSvgPath(size, x, y, z) {
|
|
20437
|
-
const r = size / 2;
|
|
20377
|
+
const r = this.parseSize(size) / 2;
|
|
20438
20378
|
return `M ${x - r}, ${y} L ${x + r},${y}`;
|
|
20439
20379
|
}
|
|
20440
20380
|
}
|
|
@@ -20454,15 +20394,15 @@ class CloseSymbol extends BaseSymbol {
|
|
|
20454
20394
|
this.pathStr = 'M-0.5,-0.5L0.5,0.5,M0.5,-0.5L-0.5,0.5';
|
|
20455
20395
|
}
|
|
20456
20396
|
draw(ctx, size, x, y, z) {
|
|
20457
|
-
const r = size / 2;
|
|
20397
|
+
const r = this.parseSize(size) / 2;
|
|
20458
20398
|
return close(ctx, r, x, y);
|
|
20459
20399
|
}
|
|
20460
20400
|
drawOffset(ctx, size, x, y, offset, z) {
|
|
20461
|
-
const r = size / 2 + offset;
|
|
20401
|
+
const r = this.parseSize(size) / 2 + offset;
|
|
20462
20402
|
return close(ctx, r, x, y);
|
|
20463
20403
|
}
|
|
20464
20404
|
drawToSvgPath(size, x, y, z) {
|
|
20465
|
-
const r = size / 2;
|
|
20405
|
+
const r = this.parseSize(size) / 2;
|
|
20466
20406
|
return `M ${x - r}, ${y - r} L ${x + r},${y + r} M ${x + r}, ${y - r} L ${x - r},${y + r}`;
|
|
20467
20407
|
}
|
|
20468
20408
|
}
|
|
@@ -20513,6 +20453,7 @@ class CustomSymbolClass {
|
|
|
20513
20453
|
this.isSvg = isSvg;
|
|
20514
20454
|
}
|
|
20515
20455
|
drawOffset(ctx, size, x, y, offset, z, cb) {
|
|
20456
|
+
size = this.parseSize(size);
|
|
20516
20457
|
if (this.isSvg) {
|
|
20517
20458
|
if (!this.svgCache) {
|
|
20518
20459
|
return false;
|
|
@@ -20528,9 +20469,14 @@ class CustomSymbolClass {
|
|
|
20528
20469
|
return false;
|
|
20529
20470
|
}
|
|
20530
20471
|
draw(ctx, size, x, y, z, cb) {
|
|
20472
|
+
size = this.parseSize(size);
|
|
20531
20473
|
return this.drawOffset(ctx, size, x, y, 0, z, cb);
|
|
20532
20474
|
}
|
|
20475
|
+
parseSize(size) {
|
|
20476
|
+
return isNumber(size) ? size : Math.min(size[0], size[1]);
|
|
20477
|
+
}
|
|
20533
20478
|
bounds(size, bounds) {
|
|
20479
|
+
size = this.parseSize(size);
|
|
20534
20480
|
if (this.isSvg) {
|
|
20535
20481
|
if (!this.svgCache) {
|
|
20536
20482
|
return;
|
|
@@ -21550,7 +21496,8 @@ class Paragraph {
|
|
|
21550
21496
|
left = 0;
|
|
21551
21497
|
baseline = 0;
|
|
21552
21498
|
}
|
|
21553
|
-
|
|
21499
|
+
const { lineWidth = 1 } = this.character;
|
|
21500
|
+
if (this.character.stroke && lineWidth) {
|
|
21554
21501
|
applyStrokeStyle(ctx, this.character);
|
|
21555
21502
|
ctx.strokeText(text, left, baseline);
|
|
21556
21503
|
}
|
|
@@ -24707,6 +24654,7 @@ class Stage extends Group {
|
|
|
24707
24654
|
constructor(params = {}) {
|
|
24708
24655
|
var _a;
|
|
24709
24656
|
super({});
|
|
24657
|
+
this.tickedBeforeRender = true;
|
|
24710
24658
|
this._onVisibleChange = (visible) => {
|
|
24711
24659
|
if (this._skipRender < 0) {
|
|
24712
24660
|
return;
|
|
@@ -24733,6 +24681,15 @@ class Stage extends Group {
|
|
|
24733
24681
|
this._afterRender && this._afterRender(stage);
|
|
24734
24682
|
this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage));
|
|
24735
24683
|
this._afterNextRenderCbs = null;
|
|
24684
|
+
this.tickedBeforeRender = false;
|
|
24685
|
+
};
|
|
24686
|
+
this.afterTickCb = () => {
|
|
24687
|
+
var _a;
|
|
24688
|
+
this.tickedBeforeRender = true;
|
|
24689
|
+
if (((_a = this.params.optimize) === null || _a === void 0 ? void 0 : _a.tickRenderMode) === 'performance') ;
|
|
24690
|
+
else {
|
|
24691
|
+
this.state !== 'rendering' && this.render();
|
|
24692
|
+
}
|
|
24736
24693
|
};
|
|
24737
24694
|
this.params = params;
|
|
24738
24695
|
this.theme = new Theme();
|
|
@@ -24800,6 +24757,7 @@ class Stage extends Group {
|
|
|
24800
24757
|
if (params.background && isString(this._background) && this._background.includes('/')) {
|
|
24801
24758
|
this.setAttributes({ background: this._background });
|
|
24802
24759
|
}
|
|
24760
|
+
this.ticker.on('afterTick', this.afterTickCb);
|
|
24803
24761
|
}
|
|
24804
24762
|
pauseRender(sr = -1) {
|
|
24805
24763
|
this._skipRender = sr;
|
|
@@ -25113,6 +25071,9 @@ class Stage extends Group {
|
|
|
25113
25071
|
this.timeline.resume();
|
|
25114
25072
|
const state = this.state;
|
|
25115
25073
|
this.state = 'rendering';
|
|
25074
|
+
if (!this.tickedBeforeRender) {
|
|
25075
|
+
this.ticker.trySyncTickStatus();
|
|
25076
|
+
}
|
|
25116
25077
|
this.layerService.prepareStageLayer(this);
|
|
25117
25078
|
if (!this._skipRender) {
|
|
25118
25079
|
this.lastRenderparams = params;
|
|
@@ -25310,6 +25271,7 @@ class Stage extends Group {
|
|
|
25310
25271
|
}
|
|
25311
25272
|
this.window.release();
|
|
25312
25273
|
this.ticker.remTimeline(this.timeline);
|
|
25274
|
+
this.ticker.removeListener('afterTick', this.afterTickCb);
|
|
25313
25275
|
this.renderService.renderTreeRoots = [];
|
|
25314
25276
|
}
|
|
25315
25277
|
setStage(stage) {
|