@visactor/vrender-core 0.21.0-alpha.1 → 0.21.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/common/3d-interceptor.js +2 -1
- package/cjs/common/bounds-context.js +1 -2
- package/cjs/common/morphing-utils.js +1 -1
- package/cjs/common/path-svg.js +4 -4
- package/cjs/common/path-svg.js.map +1 -1
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +2 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/common/simplify.js +3 -4
- package/cjs/common/simplify.js.map +1 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.js.map +1 -1
- package/cjs/core/application.js +1 -2
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +105 -18
- 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/core-modules.js +1 -1
- package/cjs/core/global-module.js +0 -2
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.d.ts +3 -0
- package/cjs/core/stage.js +12 -3
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +4 -3
- package/cjs/core/window.js.map +1 -1
- package/cjs/event/event-manager.d.ts +1 -0
- package/cjs/event/event-manager.js +1 -1
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/event/event-system.js +2 -1
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/graphic/config.js +3 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/text.d.ts +10 -11
- package/cjs/graphic/text.js +91 -174
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/text2.d.ts +81 -0
- package/cjs/graphic/text2.js +288 -0
- package/cjs/graphic/text2.js.map +1 -0
- package/cjs/graphic/wrap-text.js +12 -4
- package/cjs/graphic/wrap-text.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 +6 -1
- package/cjs/interface/text.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js +48 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/cjs/render/contributions/render/arc-render.js +30 -18
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +40 -36
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/circle-render.js +10 -5
- package/cjs/render/contributions/render/circle-render.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +10 -5
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +26 -22
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js +10 -5
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js +10 -5
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.js +10 -5
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +18 -8
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +1 -23
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/dist/index.es.js +804 -710
- package/es/common/3d-interceptor.js +2 -1
- package/es/common/bounds-context.js +1 -2
- package/es/common/morphing-utils.js +1 -1
- package/es/common/path-svg.js +4 -4
- package/es/common/path-svg.js.map +1 -1
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +2 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/common/simplify.js +3 -4
- package/es/common/simplify.js.map +1 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.js.map +1 -1
- package/es/core/application.js +1 -2
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js +106 -17
- 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/core-modules.js +1 -1
- package/es/core/global-module.js +0 -2
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.d.ts +3 -0
- package/es/core/stage.js +13 -2
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +4 -2
- package/es/core/window.js.map +1 -1
- package/es/event/event-manager.d.ts +1 -0
- package/es/event/event-manager.js +1 -1
- package/es/event/event-manager.js.map +1 -1
- package/es/event/event-system.js +2 -1
- package/es/event/event-system.js.map +1 -1
- package/es/graphic/config.js +3 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/text.d.ts +10 -11
- package/es/graphic/text.js +90 -169
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/text2.d.ts +81 -0
- package/es/graphic/text2.js +293 -0
- package/es/graphic/text2.js.map +1 -0
- package/es/graphic/wrap-text.js +12 -4
- package/es/graphic/wrap-text.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 +6 -1
- package/es/interface/text.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js +41 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/es/render/contributions/render/arc-render.js +30 -18
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/area-render.js +40 -36
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/circle-render.js +10 -5
- package/es/render/contributions/render/circle-render.js.map +1 -1
- package/es/render/contributions/render/group-render.js +10 -5
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +26 -22
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js +10 -5
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js +10 -5
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.js +10 -5
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +18 -8
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/text-render.js +1 -23
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isPointInLine, pi, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, isArray, cos, sin, pointAt, isNumber, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint,
|
|
1
|
+
import { tau, halfPi as halfPi$1, AABBBounds, degreeToRadian, PointService, Point, abs, max, min, atan2, epsilon, Matrix, pi2, Logger, isPointInLine, pi, isNumberClose, TextMeasure, EventEmitter, isBoolean, isObject, isFunction, isString, has, isUndefined, isArray, cos, sin, pointAt, isNumber, getDecimalPlaces, isValidNumber, clamp, getAngleByPoint, isNil, Bounds, getIntersectPoint, Color, DEFAULT_COLORS, OBBBounds, normalTransform, isValidUrl, isBase64, acos, sqrt, LRU, lowerCamelCaseToMiddle, isValid, transformBoundsWithMatrix, arrayEqual, getContextFont, rotatePoint, clampAngleByRadian, asin, getRectIntersect, isRectIntersect, merge, calculateAnchorOfBounds, styleStringToObject } from '@visactor/vutils';
|
|
2
2
|
|
|
3
3
|
class Generator {
|
|
4
4
|
static GenAutoIncrementId() {
|
|
@@ -1351,12 +1351,19 @@ function parseSvgPath(str) {
|
|
|
1351
1351
|
standardCommandLen = commandLengths[commandChar];
|
|
1352
1352
|
if (currCommandData.length - 1 > standardCommandLen) {
|
|
1353
1353
|
let subCommand;
|
|
1354
|
+
let bestCommandChar = commandChar;
|
|
1354
1355
|
for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
|
|
1355
|
-
subCommand = [
|
|
1356
|
+
subCommand = [bestCommandChar];
|
|
1356
1357
|
for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) {
|
|
1357
1358
|
subCommand.push(currCommandData[j]);
|
|
1358
1359
|
}
|
|
1359
1360
|
result.push(subCommand);
|
|
1361
|
+
if (bestCommandChar === 'm') {
|
|
1362
|
+
bestCommandChar = 'l';
|
|
1363
|
+
}
|
|
1364
|
+
else if (bestCommandChar === 'M') {
|
|
1365
|
+
bestCommandChar = 'L';
|
|
1366
|
+
}
|
|
1360
1367
|
}
|
|
1361
1368
|
}
|
|
1362
1369
|
else {
|
|
@@ -3009,6 +3016,7 @@ const DefaultStrokeStyle = Object.assign({ outerBorder: Object.assign(Object.ass
|
|
|
3009
3016
|
const DefaultTextStyle = {
|
|
3010
3017
|
text: '',
|
|
3011
3018
|
maxLineWidth: Infinity,
|
|
3019
|
+
maxWidth: Infinity,
|
|
3012
3020
|
textAlign: 'left',
|
|
3013
3021
|
textBaseline: 'alphabetic',
|
|
3014
3022
|
fontSize: 16,
|
|
@@ -3048,7 +3056,7 @@ const DefaultConnectAttribute = {
|
|
|
3048
3056
|
const DefaultDebugAttribute = {
|
|
3049
3057
|
_debug_bounds: false
|
|
3050
3058
|
};
|
|
3051
|
-
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, 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' }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
3052
3060
|
function addAttributeToPrototype(obj, c, keys) {
|
|
3053
3061
|
keys.forEach(key => {
|
|
3054
3062
|
c.prototype[key] = obj[key];
|
|
@@ -3063,7 +3071,7 @@ const DefaultCircleAttribute = Object.assign(Object.assign({}, DefaultAttribute)
|
|
|
3063
3071
|
const DefaultGroupAttribute = Object.assign(Object.assign({}, DefaultAttribute), { width: 0, height: 0, cornerRadius: 0, path: [], clip: false, visibleAll: true, display: 'relative', flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'flex-start', alignItems: 'flex-start', alignContent: 'flex-start', baseOpacity: 1 });
|
|
3064
3072
|
const DefaultGlyphAttribute = Object.assign(Object.assign({}, DefaultAttribute), { path: '', width: 0, height: 0, cornerRadius: 0, clip: false });
|
|
3065
3073
|
const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, DefaultAttribute), DefaultConnectAttribute), { points: [], segments: [], curveType: 'linear', clipRange: 1, clipRangeByDimension: 'default', closePath: false, curveTension: 1 });
|
|
3066
|
-
const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), { path: new CustomPath2D(), customPath: () => {
|
|
3074
|
+
const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), { path: new CustomPath2D(), fillStrokeOrder: 1, customPath: () => {
|
|
3067
3075
|
Logger.getInstance().warn('空函数');
|
|
3068
3076
|
} });
|
|
3069
3077
|
const DefaultPolygonAttribute = Object.assign(Object.assign({}, DefaultAttribute), { points: [], cornerRadius: 0, closePath: true });
|
|
@@ -3242,13 +3250,33 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3242
3250
|
this.context = service.context;
|
|
3243
3251
|
service.bindTextMeasure(this);
|
|
3244
3252
|
}
|
|
3245
|
-
|
|
3246
|
-
if (!this.context) {
|
|
3247
|
-
return this.estimate(text, options).width;
|
|
3248
|
-
}
|
|
3253
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
3249
3254
|
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
3250
|
-
const
|
|
3251
|
-
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;
|
|
3252
3280
|
}
|
|
3253
3281
|
estimate(text, { fontSize = DefaultTextAttribute.fontSize }) {
|
|
3254
3282
|
let eCharLen = 0;
|
|
@@ -3261,24 +3289,125 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3261
3289
|
height: fontSize
|
|
3262
3290
|
};
|
|
3263
3291
|
}
|
|
3264
|
-
|
|
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) {
|
|
3265
3317
|
var _a;
|
|
3266
3318
|
if (!this.context) {
|
|
3267
3319
|
return (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3268
3320
|
}
|
|
3269
|
-
this.
|
|
3270
|
-
const textMeasure = this.context.measureText(text);
|
|
3321
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, true);
|
|
3271
3322
|
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
3272
3323
|
}
|
|
3273
|
-
|
|
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) {
|
|
3274
3335
|
var _a;
|
|
3275
3336
|
if (!this.context) {
|
|
3276
3337
|
return (_a = options.fontSize) !== null && _a !== void 0 ? _a : DefaultTextStyle.fontSize;
|
|
3277
3338
|
}
|
|
3278
|
-
this.
|
|
3279
|
-
const textMeasure = this.context.measureText(text);
|
|
3339
|
+
textMeasure = textMeasure !== null && textMeasure !== void 0 ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, true);
|
|
3280
3340
|
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
3281
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
|
+
}
|
|
3282
3411
|
measureText(text, options) {
|
|
3283
3412
|
if (!this.context) {
|
|
3284
3413
|
return this.estimate(text, options);
|
|
@@ -3376,6 +3505,11 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3376
3505
|
return data;
|
|
3377
3506
|
}
|
|
3378
3507
|
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
3508
|
+
if (leftIdx === rightIdx) {
|
|
3509
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
3510
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
3511
|
+
return { str: subText, width: this.measureTextWidth(subText, options) };
|
|
3512
|
+
}
|
|
3379
3513
|
const middleIdx = Math.floor((leftIdx + rightIdx) / 2);
|
|
3380
3514
|
const subText = text.substring(0, middleIdx + 1);
|
|
3381
3515
|
const strWidth = this.measureTextWidth(subText, options);
|
|
@@ -3406,25 +3540,25 @@ let ATextMeasure = class ATextMeasure {
|
|
|
3406
3540
|
}
|
|
3407
3541
|
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
3408
3542
|
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2);
|
|
3409
|
-
const subText = text.substring(middleIdx - 1, text.length
|
|
3543
|
+
const subText = text.substring(middleIdx - 1, text.length);
|
|
3410
3544
|
const strWidth = this.measureTextWidth(subText, options);
|
|
3411
3545
|
let length;
|
|
3412
3546
|
if (strWidth > width) {
|
|
3413
3547
|
if (subText.length <= 1) {
|
|
3414
3548
|
return { str: '', width: 0 };
|
|
3415
3549
|
}
|
|
3416
|
-
const str = text.substring(middleIdx, text.length
|
|
3550
|
+
const str = text.substring(middleIdx, text.length);
|
|
3417
3551
|
length = this.measureTextWidth(str, options);
|
|
3418
3552
|
if (length <= width) {
|
|
3419
3553
|
return { str, width: length };
|
|
3420
3554
|
}
|
|
3421
|
-
return this._clipTextStart(text, options, width, middleIdx, text.length
|
|
3555
|
+
return this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
3422
3556
|
}
|
|
3423
3557
|
else if (strWidth < width) {
|
|
3424
3558
|
if (middleIdx <= 0) {
|
|
3425
3559
|
return { str: text, width: this.measureTextWidth(text, options) };
|
|
3426
3560
|
}
|
|
3427
|
-
const str = text.substring(middleIdx - 2, text.length
|
|
3561
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
3428
3562
|
length = this.measureTextWidth(str, options);
|
|
3429
3563
|
if (length >= width) {
|
|
3430
3564
|
return { str: subText, width: strWidth };
|
|
@@ -4446,8 +4580,8 @@ let DefaultWindow = class DefaultWindow {
|
|
|
4446
4580
|
const viewBox = this._handler.getViewBox();
|
|
4447
4581
|
return !(viewBox.x1 === 0 &&
|
|
4448
4582
|
viewBox.y1 === 0 &&
|
|
4449
|
-
this.width
|
|
4450
|
-
this.height
|
|
4583
|
+
isNumberClose(this.width, viewBox.width()) &&
|
|
4584
|
+
isNumberClose(this.height, viewBox.height()));
|
|
4451
4585
|
}
|
|
4452
4586
|
isVisible(bbox) {
|
|
4453
4587
|
return this._handler.isVisible(bbox);
|
|
@@ -5944,7 +6078,7 @@ class EventManager {
|
|
|
5944
6078
|
this.dispatchEvent(clickEvent, 'dblclick');
|
|
5945
6079
|
}
|
|
5946
6080
|
}
|
|
5947
|
-
else if (clickEvent.pointerType === 'touch') {
|
|
6081
|
+
else if (clickEvent.pointerType === 'touch' && this._config.supportsTouchEvents) {
|
|
5948
6082
|
this.dispatchEvent(clickEvent, 'tap');
|
|
5949
6083
|
if (clickHistory.clickCount === 2) {
|
|
5950
6084
|
this.dispatchEvent(clickEvent, 'dbltap');
|
|
@@ -6403,7 +6537,8 @@ class EventSystem {
|
|
|
6403
6537
|
};
|
|
6404
6538
|
const { targetElement, resolution, rootNode, global, autoPreventDefault = false, clickInterval, supportsTouchEvents = global.supportsTouchEvents, supportsPointerEvents = global.supportsPointerEvents } = params;
|
|
6405
6539
|
this.manager = new EventManager(rootNode, {
|
|
6406
|
-
clickInterval
|
|
6540
|
+
clickInterval,
|
|
6541
|
+
supportsTouchEvents: supportsTouchEvents
|
|
6407
6542
|
});
|
|
6408
6543
|
this.globalObj = global;
|
|
6409
6544
|
this.supportsPointerEvents = supportsPointerEvents;
|
|
@@ -16010,7 +16145,7 @@ let DefaultCanvasArcRender = class DefaultCanvasArcRender extends BaseRender {
|
|
|
16010
16145
|
}
|
|
16011
16146
|
drawShape(arc, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
16012
16147
|
const arcAttribute = getTheme(arc, params === null || params === void 0 ? void 0 : params.theme).arc;
|
|
16013
|
-
const { fill = arcAttribute.fill, stroke = arcAttribute.stroke, x: originX = arcAttribute.x, y: originY = arcAttribute.y } = arc.attribute;
|
|
16148
|
+
const { fill = arcAttribute.fill, stroke = arcAttribute.stroke, x: originX = arcAttribute.x, y: originY = arcAttribute.y, fillStrokeOrder = arcAttribute.fillStrokeOrder } = arc.attribute;
|
|
16014
16149
|
const data = this.valid(arc, arcAttribute, fillCb, strokeCb);
|
|
16015
16150
|
if (!data) {
|
|
16016
16151
|
return;
|
|
@@ -16038,23 +16173,35 @@ let DefaultCanvasArcRender = class DefaultCanvasArcRender extends BaseRender {
|
|
|
16038
16173
|
beforeRenderContribitionsRuned = true;
|
|
16039
16174
|
context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute);
|
|
16040
16175
|
this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
16041
|
-
|
|
16042
|
-
if (
|
|
16043
|
-
fillCb
|
|
16176
|
+
const _runFill = () => {
|
|
16177
|
+
if (doFill) {
|
|
16178
|
+
if (fillCb) {
|
|
16179
|
+
fillCb(context, arc.attribute, arcAttribute);
|
|
16180
|
+
}
|
|
16181
|
+
else if (fVisible) {
|
|
16182
|
+
context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute);
|
|
16183
|
+
context.fill();
|
|
16184
|
+
}
|
|
16044
16185
|
}
|
|
16045
|
-
|
|
16046
|
-
|
|
16047
|
-
|
|
16186
|
+
};
|
|
16187
|
+
const _runStroke = () => {
|
|
16188
|
+
if (doStroke && isFullStroke) {
|
|
16189
|
+
if (strokeCb) {
|
|
16190
|
+
strokeCb(context, arc.attribute, arcAttribute);
|
|
16191
|
+
}
|
|
16192
|
+
else if (sVisible) {
|
|
16193
|
+
context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute);
|
|
16194
|
+
context.stroke();
|
|
16195
|
+
}
|
|
16048
16196
|
}
|
|
16197
|
+
};
|
|
16198
|
+
if (!fillStrokeOrder) {
|
|
16199
|
+
_runFill();
|
|
16200
|
+
_runStroke();
|
|
16049
16201
|
}
|
|
16050
|
-
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
}
|
|
16054
|
-
else if (sVisible) {
|
|
16055
|
-
context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute);
|
|
16056
|
-
context.stroke();
|
|
16057
|
-
}
|
|
16202
|
+
else {
|
|
16203
|
+
_runStroke();
|
|
16204
|
+
_runFill();
|
|
16058
16205
|
}
|
|
16059
16206
|
}
|
|
16060
16207
|
if (!isFullStroke && doStroke) {
|
|
@@ -16084,24 +16231,36 @@ let DefaultCanvasArcRender = class DefaultCanvasArcRender extends BaseRender {
|
|
|
16084
16231
|
if (!beforeRenderContribitionsRuned) {
|
|
16085
16232
|
this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
|
|
16086
16233
|
}
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
16093
|
-
|
|
16094
|
-
|
|
16095
|
-
|
|
16234
|
+
const _runFill = () => {
|
|
16235
|
+
if (doFill) {
|
|
16236
|
+
const color = fill;
|
|
16237
|
+
if (color.gradient === 'conical') {
|
|
16238
|
+
const lastColor = getConicGradientAt(0, 0, endAngle, color);
|
|
16239
|
+
if (fillCb) ;
|
|
16240
|
+
else if (fillVisible) {
|
|
16241
|
+
context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute);
|
|
16242
|
+
context.fillStyle = lastColor;
|
|
16243
|
+
context.fill();
|
|
16244
|
+
}
|
|
16096
16245
|
}
|
|
16097
16246
|
}
|
|
16098
|
-
}
|
|
16099
|
-
|
|
16100
|
-
if (
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16247
|
+
};
|
|
16248
|
+
const _runStroke = () => {
|
|
16249
|
+
if (doStroke) {
|
|
16250
|
+
if (strokeCb) ;
|
|
16251
|
+
else if (sVisible) {
|
|
16252
|
+
context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute);
|
|
16253
|
+
context.stroke();
|
|
16254
|
+
}
|
|
16104
16255
|
}
|
|
16256
|
+
};
|
|
16257
|
+
if (!fillStrokeOrder) {
|
|
16258
|
+
_runFill();
|
|
16259
|
+
_runStroke();
|
|
16260
|
+
}
|
|
16261
|
+
else {
|
|
16262
|
+
_runFill();
|
|
16263
|
+
_runStroke();
|
|
16105
16264
|
}
|
|
16106
16265
|
}
|
|
16107
16266
|
}
|
|
@@ -16137,7 +16296,7 @@ let DefaultCanvasCircleRender = class DefaultCanvasCircleRender extends BaseRend
|
|
|
16137
16296
|
}
|
|
16138
16297
|
drawShape(circle, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
16139
16298
|
const circleAttribute = getTheme(circle, params === null || params === void 0 ? void 0 : params.theme).circle;
|
|
16140
|
-
const { radius = circleAttribute.radius, startAngle = circleAttribute.startAngle, endAngle = circleAttribute.endAngle, x: originX = circleAttribute.x, y: originY = circleAttribute.y } = circle.attribute;
|
|
16299
|
+
const { radius = circleAttribute.radius, startAngle = circleAttribute.startAngle, endAngle = circleAttribute.endAngle, x: originX = circleAttribute.x, y: originY = circleAttribute.y, fillStrokeOrder = circleAttribute.fillStrokeOrder } = circle.attribute;
|
|
16141
16300
|
const data = this.valid(circle, circleAttribute, fillCb, strokeCb);
|
|
16142
16301
|
if (!data) {
|
|
16143
16302
|
return;
|
|
@@ -16148,23 +16307,35 @@ let DefaultCanvasCircleRender = class DefaultCanvasCircleRender extends BaseRend
|
|
|
16148
16307
|
context.closePath();
|
|
16149
16308
|
context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute);
|
|
16150
16309
|
this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
16151
|
-
|
|
16152
|
-
if (
|
|
16153
|
-
fillCb
|
|
16310
|
+
const _runFill = () => {
|
|
16311
|
+
if (doFill) {
|
|
16312
|
+
if (fillCb) {
|
|
16313
|
+
fillCb(context, circle.attribute, circleAttribute);
|
|
16314
|
+
}
|
|
16315
|
+
else if (fVisible) {
|
|
16316
|
+
context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute);
|
|
16317
|
+
context.fill();
|
|
16318
|
+
}
|
|
16154
16319
|
}
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16320
|
+
};
|
|
16321
|
+
const _runStroke = () => {
|
|
16322
|
+
if (doStroke) {
|
|
16323
|
+
if (strokeCb) {
|
|
16324
|
+
strokeCb(context, circle.attribute, circleAttribute);
|
|
16325
|
+
}
|
|
16326
|
+
else if (sVisible) {
|
|
16327
|
+
context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute);
|
|
16328
|
+
context.stroke();
|
|
16329
|
+
}
|
|
16158
16330
|
}
|
|
16331
|
+
};
|
|
16332
|
+
if (!fillStrokeOrder) {
|
|
16333
|
+
_runFill();
|
|
16334
|
+
_runStroke();
|
|
16159
16335
|
}
|
|
16160
|
-
|
|
16161
|
-
|
|
16162
|
-
|
|
16163
|
-
}
|
|
16164
|
-
else if (sVisible) {
|
|
16165
|
-
context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute);
|
|
16166
|
-
context.stroke();
|
|
16167
|
-
}
|
|
16336
|
+
else {
|
|
16337
|
+
_runStroke();
|
|
16338
|
+
_runFill();
|
|
16168
16339
|
}
|
|
16169
16340
|
this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
|
|
16170
16341
|
}
|
|
@@ -16922,7 +17093,7 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
16922
17093
|
this.init(areaRenderContribitions);
|
|
16923
17094
|
}
|
|
16924
17095
|
drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
|
|
16925
|
-
var _a, _b, _c
|
|
17096
|
+
var _a, _b, _c;
|
|
16926
17097
|
const { points } = area.attribute;
|
|
16927
17098
|
if (points.length < 2) {
|
|
16928
17099
|
return;
|
|
@@ -16943,44 +17114,51 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
16943
17114
|
context.setShadowBlendStyle && context.setShadowBlendStyle(area, area.attribute, areaAttribute);
|
|
16944
17115
|
this.beforeRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, areaAttribute, drawContext, fillCb, null, { attribute: area.attribute });
|
|
16945
17116
|
const { x: originX = 0, x: originY = 0 } = area.attribute;
|
|
16946
|
-
|
|
16947
|
-
if (
|
|
16948
|
-
fillCb
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
17117
|
+
const _runFill = () => {
|
|
17118
|
+
if (fill !== false) {
|
|
17119
|
+
if (fillCb) {
|
|
17120
|
+
fillCb(context, area.attribute, areaAttribute);
|
|
17121
|
+
}
|
|
17122
|
+
else if (fillOpacity) {
|
|
17123
|
+
context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute);
|
|
17124
|
+
context.fill();
|
|
17125
|
+
}
|
|
16953
17126
|
}
|
|
16954
|
-
}
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
17127
|
+
};
|
|
17128
|
+
const _runStroke = () => {
|
|
17129
|
+
var _a, _b;
|
|
17130
|
+
if (stroke) {
|
|
17131
|
+
const { stroke = areaAttribute && areaAttribute.stroke } = area.attribute;
|
|
17132
|
+
if (isArray(stroke) && (stroke[0] || stroke[2]) && stroke[1] === false) {
|
|
17133
|
+
context.beginPath();
|
|
17134
|
+
if (stroke[0]) {
|
|
17135
|
+
context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
|
|
17136
|
+
for (let i = 1; i < points.length; i++) {
|
|
17137
|
+
const p = points[i];
|
|
17138
|
+
context.lineTo(p.x + offsetX, p.y + offsetY, z);
|
|
17139
|
+
}
|
|
16965
17140
|
}
|
|
16966
|
-
|
|
16967
|
-
|
|
16968
|
-
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
17141
|
+
else if (stroke[2]) {
|
|
17142
|
+
const endP = points[points.length - 1];
|
|
17143
|
+
context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
|
|
17144
|
+
for (let i = points.length - 2; i >= 0; i--) {
|
|
17145
|
+
const p = points[i];
|
|
17146
|
+
context.lineTo(((_a = p.x1) !== null && _a !== void 0 ? _a : p.x) + offsetX, ((_b = p.y1) !== null && _b !== void 0 ? _b : p.y) + offsetY, z);
|
|
17147
|
+
}
|
|
16973
17148
|
}
|
|
16974
17149
|
}
|
|
17150
|
+
if (strokeCb) {
|
|
17151
|
+
strokeCb(context, area.attribute, areaAttribute);
|
|
17152
|
+
}
|
|
17153
|
+
else {
|
|
17154
|
+
context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute);
|
|
17155
|
+
context.stroke();
|
|
17156
|
+
}
|
|
16975
17157
|
}
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute);
|
|
16981
|
-
context.stroke();
|
|
16982
|
-
}
|
|
16983
|
-
}
|
|
17158
|
+
};
|
|
17159
|
+
_runFill();
|
|
17160
|
+
this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, areaAttribute, drawContext, fillCb, null, { attribute: area.attribute });
|
|
17161
|
+
_runStroke();
|
|
16984
17162
|
}
|
|
16985
17163
|
drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
16986
17164
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -17210,38 +17388,44 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
|
|
|
17210
17388
|
this.beforeRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
|
|
17211
17389
|
context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
|
|
17212
17390
|
const { x: originX = 0, x: originY = 0 } = attribute;
|
|
17213
|
-
|
|
17214
|
-
if (
|
|
17215
|
-
fillCb
|
|
17216
|
-
|
|
17217
|
-
|
|
17218
|
-
|
|
17219
|
-
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
|
|
17223
|
-
if (stroke !== false) {
|
|
17224
|
-
if (strokeCb) {
|
|
17225
|
-
strokeCb(context, attribute, defaultAttribute);
|
|
17391
|
+
const _runFill = () => {
|
|
17392
|
+
if (fill !== false) {
|
|
17393
|
+
if (fillCb) {
|
|
17394
|
+
fillCb(context, attribute, defaultAttribute);
|
|
17395
|
+
}
|
|
17396
|
+
else if (fillOpacity) {
|
|
17397
|
+
context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
|
|
17398
|
+
context.fill();
|
|
17399
|
+
}
|
|
17226
17400
|
}
|
|
17227
|
-
|
|
17228
|
-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
|
|
17236
|
-
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17401
|
+
};
|
|
17402
|
+
const _runStroke = () => {
|
|
17403
|
+
if (stroke !== false) {
|
|
17404
|
+
if (strokeCb) {
|
|
17405
|
+
strokeCb(context, attribute, defaultAttribute);
|
|
17406
|
+
}
|
|
17407
|
+
else {
|
|
17408
|
+
const { stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke } = attribute;
|
|
17409
|
+
if (isArray(stroke) && (stroke[0] || stroke[2]) && stroke[1] === false) {
|
|
17410
|
+
context.beginPath();
|
|
17411
|
+
drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? 'x' : 'y', {
|
|
17412
|
+
offsetX,
|
|
17413
|
+
offsetY,
|
|
17414
|
+
offsetZ,
|
|
17415
|
+
drawConnect: connect,
|
|
17416
|
+
mode: connectedType,
|
|
17417
|
+
zeroX: connectedX,
|
|
17418
|
+
zeroY: connectedY
|
|
17419
|
+
});
|
|
17420
|
+
}
|
|
17421
|
+
context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
|
|
17422
|
+
context.stroke();
|
|
17240
17423
|
}
|
|
17241
|
-
context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute);
|
|
17242
|
-
context.stroke();
|
|
17243
17424
|
}
|
|
17244
|
-
}
|
|
17425
|
+
};
|
|
17426
|
+
_runFill();
|
|
17427
|
+
this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, false, fill, false, defaultAttribute, drawContext, fillCb, null, { attribute });
|
|
17428
|
+
_runStroke();
|
|
17245
17429
|
return ret;
|
|
17246
17430
|
}
|
|
17247
17431
|
};
|
|
@@ -17266,7 +17450,7 @@ let DefaultCanvasPathRender = class DefaultCanvasPathRender extends BaseRender {
|
|
|
17266
17450
|
drawShape(path, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
17267
17451
|
var _a, _b, _c;
|
|
17268
17452
|
const pathAttribute = (_a = this.tempTheme) !== null && _a !== void 0 ? _a : getTheme(path, params === null || params === void 0 ? void 0 : params.theme).path;
|
|
17269
|
-
const { x: originX = pathAttribute.x, y: originY = pathAttribute.y } = path.attribute;
|
|
17453
|
+
const { x: originX = pathAttribute.x, y: originY = pathAttribute.y, fillStrokeOrder = pathAttribute.fillStrokeOrder } = path.attribute;
|
|
17270
17454
|
const z = (_b = this.z) !== null && _b !== void 0 ? _b : 0;
|
|
17271
17455
|
const data = this.valid(path, pathAttribute, fillCb, strokeCb);
|
|
17272
17456
|
if (!data) {
|
|
@@ -17283,23 +17467,35 @@ let DefaultCanvasPathRender = class DefaultCanvasPathRender extends BaseRender {
|
|
|
17283
17467
|
}
|
|
17284
17468
|
context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute);
|
|
17285
17469
|
this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
17286
|
-
|
|
17287
|
-
if (
|
|
17288
|
-
strokeCb
|
|
17470
|
+
const _runStroke = () => {
|
|
17471
|
+
if (doStroke) {
|
|
17472
|
+
if (strokeCb) {
|
|
17473
|
+
strokeCb(context, path.attribute, pathAttribute);
|
|
17474
|
+
}
|
|
17475
|
+
else if (sVisible) {
|
|
17476
|
+
context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute);
|
|
17477
|
+
context.stroke();
|
|
17478
|
+
}
|
|
17289
17479
|
}
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17480
|
+
};
|
|
17481
|
+
const _runFill = () => {
|
|
17482
|
+
if (doFill) {
|
|
17483
|
+
if (fillCb) {
|
|
17484
|
+
fillCb(context, path.attribute, pathAttribute);
|
|
17485
|
+
}
|
|
17486
|
+
else if (fVisible) {
|
|
17487
|
+
context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute);
|
|
17488
|
+
context.fill();
|
|
17489
|
+
}
|
|
17293
17490
|
}
|
|
17491
|
+
};
|
|
17492
|
+
if (!fillStrokeOrder) {
|
|
17493
|
+
_runFill();
|
|
17494
|
+
_runStroke();
|
|
17294
17495
|
}
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
}
|
|
17299
|
-
else if (fVisible) {
|
|
17300
|
-
context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute);
|
|
17301
|
-
context.fill();
|
|
17302
|
-
}
|
|
17496
|
+
else {
|
|
17497
|
+
_runStroke();
|
|
17498
|
+
_runFill();
|
|
17303
17499
|
}
|
|
17304
17500
|
this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
|
|
17305
17501
|
}
|
|
@@ -17333,7 +17529,7 @@ let DefaultCanvasRectRender = class DefaultCanvasRectRender extends BaseRender {
|
|
|
17333
17529
|
drawShape(rect, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
17334
17530
|
var _a;
|
|
17335
17531
|
const rectAttribute = (_a = this.tempTheme) !== null && _a !== void 0 ? _a : getTheme(rect, params === null || params === void 0 ? void 0 : params.theme).rect;
|
|
17336
|
-
const { fill = rectAttribute.fill, background, stroke = rectAttribute.stroke, cornerRadius = rectAttribute.cornerRadius, opacity = rectAttribute.opacity, fillOpacity = rectAttribute.fillOpacity, lineWidth = rectAttribute.lineWidth, strokeOpacity = rectAttribute.strokeOpacity, visible = rectAttribute.visible, x1, y1, x: originX = rectAttribute.x, y: originY = rectAttribute.y } = rect.attribute;
|
|
17532
|
+
const { fill = rectAttribute.fill, background, stroke = rectAttribute.stroke, cornerRadius = rectAttribute.cornerRadius, opacity = rectAttribute.opacity, fillOpacity = rectAttribute.fillOpacity, lineWidth = rectAttribute.lineWidth, strokeOpacity = rectAttribute.strokeOpacity, visible = rectAttribute.visible, x1, y1, x: originX = rectAttribute.x, y: originY = rectAttribute.y, fillStrokeOrder = rectAttribute.fillStrokeOrder } = rect.attribute;
|
|
17337
17533
|
let { width, height } = rect.attribute;
|
|
17338
17534
|
width = (width !== null && width !== void 0 ? width : x1 - originX) || 0;
|
|
17339
17535
|
height = (height !== null && height !== void 0 ? height : y1 - originY) || 0;
|
|
@@ -17364,23 +17560,35 @@ let DefaultCanvasRectRender = class DefaultCanvasRectRender extends BaseRender {
|
|
|
17364
17560
|
};
|
|
17365
17561
|
context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);
|
|
17366
17562
|
this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
|
|
17367
|
-
|
|
17368
|
-
if (
|
|
17369
|
-
fillCb
|
|
17563
|
+
const _runFill = () => {
|
|
17564
|
+
if (doFillOrStroke.doFill) {
|
|
17565
|
+
if (fillCb) {
|
|
17566
|
+
fillCb(context, rect.attribute, rectAttribute);
|
|
17567
|
+
}
|
|
17568
|
+
else if (fVisible) {
|
|
17569
|
+
context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);
|
|
17570
|
+
context.fill();
|
|
17571
|
+
}
|
|
17370
17572
|
}
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17573
|
+
};
|
|
17574
|
+
const _runStroke = () => {
|
|
17575
|
+
if (doFillOrStroke.doStroke) {
|
|
17576
|
+
if (strokeCb) {
|
|
17577
|
+
strokeCb(context, rect.attribute, rectAttribute);
|
|
17578
|
+
}
|
|
17579
|
+
else if (sVisible) {
|
|
17580
|
+
context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);
|
|
17581
|
+
context.stroke();
|
|
17582
|
+
}
|
|
17374
17583
|
}
|
|
17584
|
+
};
|
|
17585
|
+
if (!fillStrokeOrder) {
|
|
17586
|
+
_runFill();
|
|
17587
|
+
_runStroke();
|
|
17375
17588
|
}
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
}
|
|
17380
|
-
else if (sVisible) {
|
|
17381
|
-
context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute);
|
|
17382
|
-
context.stroke();
|
|
17383
|
-
}
|
|
17589
|
+
else {
|
|
17590
|
+
_runStroke();
|
|
17591
|
+
_runFill();
|
|
17384
17592
|
}
|
|
17385
17593
|
this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
|
|
17386
17594
|
}
|
|
@@ -17413,7 +17621,7 @@ let DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends BaseRend
|
|
|
17413
17621
|
drawShape(symbol, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
17414
17622
|
var _a;
|
|
17415
17623
|
const symbolAttribute = getTheme(symbol, params === null || params === void 0 ? void 0 : params.theme).symbol;
|
|
17416
|
-
const { size = symbolAttribute.size, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX = symbolAttribute.scaleX, scaleY = symbolAttribute.scaleY } = symbol.attribute;
|
|
17624
|
+
const { size = symbolAttribute.size, x: originX = symbolAttribute.x, y: originY = symbolAttribute.y, scaleX = symbolAttribute.scaleX, scaleY = symbolAttribute.scaleY, fillStrokeOrder = symbolAttribute.fillStrokeOrder } = symbol.attribute;
|
|
17417
17625
|
const data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
|
|
17418
17626
|
if (!data) {
|
|
17419
17627
|
return;
|
|
@@ -17436,23 +17644,35 @@ let DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends BaseRend
|
|
|
17436
17644
|
obj.stroke = (_c = a.stroke) !== null && _c !== void 0 ? _c : symbol.attribute.stroke;
|
|
17437
17645
|
a = obj;
|
|
17438
17646
|
}
|
|
17439
|
-
|
|
17440
|
-
if (
|
|
17441
|
-
fillCb
|
|
17647
|
+
const _runFill = () => {
|
|
17648
|
+
if (a.fill) {
|
|
17649
|
+
if (fillCb) {
|
|
17650
|
+
fillCb(context, symbol.attribute, symbolAttribute);
|
|
17651
|
+
}
|
|
17652
|
+
else {
|
|
17653
|
+
context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);
|
|
17654
|
+
context.fill();
|
|
17655
|
+
}
|
|
17442
17656
|
}
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17657
|
+
};
|
|
17658
|
+
const _runStroke = () => {
|
|
17659
|
+
if (a.stroke) {
|
|
17660
|
+
if (strokeCb) {
|
|
17661
|
+
strokeCb(context, symbol.attribute, symbolAttribute);
|
|
17662
|
+
}
|
|
17663
|
+
else {
|
|
17664
|
+
context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
|
|
17665
|
+
context.stroke();
|
|
17666
|
+
}
|
|
17446
17667
|
}
|
|
17668
|
+
};
|
|
17669
|
+
if (!fillStrokeOrder) {
|
|
17670
|
+
_runFill();
|
|
17671
|
+
_runStroke();
|
|
17447
17672
|
}
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
}
|
|
17452
|
-
else {
|
|
17453
|
-
context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
|
|
17454
|
-
context.stroke();
|
|
17455
|
-
}
|
|
17673
|
+
else {
|
|
17674
|
+
_runStroke();
|
|
17675
|
+
_runFill();
|
|
17456
17676
|
}
|
|
17457
17677
|
};
|
|
17458
17678
|
if (keepDirIn3d && context.camera && context.project) {
|
|
@@ -17471,23 +17691,35 @@ let DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends BaseRend
|
|
|
17471
17691
|
}
|
|
17472
17692
|
context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);
|
|
17473
17693
|
this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
17474
|
-
|
|
17475
|
-
if (
|
|
17476
|
-
fillCb
|
|
17694
|
+
const _runFill = () => {
|
|
17695
|
+
if (doFill && !parsedPath.isSvg) {
|
|
17696
|
+
if (fillCb) {
|
|
17697
|
+
fillCb(context, symbol.attribute, symbolAttribute);
|
|
17698
|
+
}
|
|
17699
|
+
else if (fVisible) {
|
|
17700
|
+
context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute);
|
|
17701
|
+
context.fill();
|
|
17702
|
+
}
|
|
17477
17703
|
}
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17704
|
+
};
|
|
17705
|
+
const _runStroke = () => {
|
|
17706
|
+
if (doStroke && !parsedPath.isSvg) {
|
|
17707
|
+
if (strokeCb) {
|
|
17708
|
+
strokeCb(context, symbol.attribute, symbolAttribute);
|
|
17709
|
+
}
|
|
17710
|
+
else if (sVisible) {
|
|
17711
|
+
context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
|
|
17712
|
+
context.stroke();
|
|
17713
|
+
}
|
|
17481
17714
|
}
|
|
17715
|
+
};
|
|
17716
|
+
if (!fillStrokeOrder) {
|
|
17717
|
+
_runFill();
|
|
17718
|
+
_runStroke();
|
|
17482
17719
|
}
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
}
|
|
17487
|
-
else if (sVisible) {
|
|
17488
|
-
context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
|
|
17489
|
-
context.stroke();
|
|
17490
|
-
}
|
|
17720
|
+
else {
|
|
17721
|
+
_runStroke();
|
|
17722
|
+
_runFill();
|
|
17491
17723
|
}
|
|
17492
17724
|
this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
|
|
17493
17725
|
}
|
|
@@ -17734,132 +17966,82 @@ let DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
|
|
|
17734
17966
|
context.setTransformForCurrent();
|
|
17735
17967
|
}
|
|
17736
17968
|
};
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17741
|
-
|
|
17742
|
-
|
|
17743
|
-
return;
|
|
17744
|
-
}
|
|
17745
|
-
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
17746
|
-
if (doStroke) {
|
|
17747
|
-
if (strokeCb) {
|
|
17748
|
-
strokeCb(context, text.attribute, textAttribute);
|
|
17749
|
-
}
|
|
17750
|
-
else if (sVisible) {
|
|
17751
|
-
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17752
|
-
multilineLayout.lines.forEach(line => {
|
|
17753
|
-
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17754
|
-
});
|
|
17755
|
-
}
|
|
17756
|
-
}
|
|
17757
|
-
if (doFill) {
|
|
17758
|
-
if (fillCb) {
|
|
17759
|
-
fillCb(context, text.attribute, textAttribute);
|
|
17760
|
-
}
|
|
17761
|
-
else if (fVisible) {
|
|
17762
|
-
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17763
|
-
multilineLayout.lines.forEach(line => {
|
|
17764
|
-
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17765
|
-
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY('bottom', fontSize) - 0.05 * fontSize, z, textAttribute, context, {
|
|
17766
|
-
width: line.width
|
|
17767
|
-
});
|
|
17768
|
-
});
|
|
17769
|
-
}
|
|
17770
|
-
}
|
|
17969
|
+
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
17970
|
+
if (direction === 'horizontal') {
|
|
17971
|
+
const { multilineLayout } = text;
|
|
17972
|
+
if (!multilineLayout) {
|
|
17973
|
+
context.highPerformanceRestore();
|
|
17974
|
+
return;
|
|
17771
17975
|
}
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
context.textAlign = 'left';
|
|
17777
|
-
context.textBaseline = 'top';
|
|
17778
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
17779
|
-
let totalW = 0;
|
|
17780
|
-
verticalList.forEach(verticalData => {
|
|
17781
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
17782
|
-
totalW = max(_w, totalW);
|
|
17783
|
-
});
|
|
17784
|
-
let offsetY = 0;
|
|
17785
|
-
let offsetX = 0;
|
|
17786
|
-
if (textBaseline === 'bottom') {
|
|
17787
|
-
offsetX = -totalHeight;
|
|
17976
|
+
const { xOffset, yOffset } = multilineLayout.bbox;
|
|
17977
|
+
if (doStroke) {
|
|
17978
|
+
if (strokeCb) {
|
|
17979
|
+
strokeCb(context, text.attribute, textAttribute);
|
|
17788
17980
|
}
|
|
17789
|
-
else if (
|
|
17790
|
-
|
|
17981
|
+
else if (sVisible) {
|
|
17982
|
+
context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17983
|
+
multilineLayout.lines.forEach(line => {
|
|
17984
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17985
|
+
});
|
|
17791
17986
|
}
|
|
17792
|
-
|
|
17793
|
-
|
|
17987
|
+
}
|
|
17988
|
+
if (doFill) {
|
|
17989
|
+
if (fillCb) {
|
|
17990
|
+
fillCb(context, text.attribute, textAttribute);
|
|
17794
17991
|
}
|
|
17795
|
-
else if (
|
|
17796
|
-
|
|
17797
|
-
|
|
17798
|
-
|
|
17799
|
-
|
|
17800
|
-
|
|
17801
|
-
|
|
17802
|
-
if (textAlign === 'center') {
|
|
17803
|
-
currentOffsetY += dw / 2;
|
|
17804
|
-
}
|
|
17805
|
-
else if (textAlign === 'right') {
|
|
17806
|
-
currentOffsetY += dw;
|
|
17807
|
-
}
|
|
17808
|
-
verticalData.forEach(item => {
|
|
17809
|
-
const { text, width, direction } = item;
|
|
17810
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);
|
|
17811
|
-
currentOffsetY += width;
|
|
17992
|
+
else if (fVisible) {
|
|
17993
|
+
context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute);
|
|
17994
|
+
multilineLayout.lines.forEach(line => {
|
|
17995
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17996
|
+
this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY('bottom', fontSize) - 0.05 * fontSize, z, textAttribute, context, {
|
|
17997
|
+
width: line.width
|
|
17998
|
+
});
|
|
17812
17999
|
});
|
|
17813
|
-
}
|
|
18000
|
+
}
|
|
17814
18001
|
}
|
|
17815
18002
|
}
|
|
17816
18003
|
else {
|
|
17817
|
-
|
|
17818
|
-
|
|
17819
|
-
|
|
17820
|
-
|
|
17821
|
-
|
|
17822
|
-
|
|
17823
|
-
|
|
17824
|
-
|
|
17825
|
-
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
17830
|
-
|
|
17831
|
-
|
|
18004
|
+
text.tryUpdateAABBBounds();
|
|
18005
|
+
const cache = text.cache;
|
|
18006
|
+
const { verticalList } = cache;
|
|
18007
|
+
context.textAlign = 'left';
|
|
18008
|
+
context.textBaseline = 'top';
|
|
18009
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
18010
|
+
let totalW = 0;
|
|
18011
|
+
verticalList.forEach(verticalData => {
|
|
18012
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
18013
|
+
totalW = max(_w, totalW);
|
|
18014
|
+
});
|
|
18015
|
+
let offsetY = 0;
|
|
18016
|
+
let offsetX = 0;
|
|
18017
|
+
if (textBaseline === 'bottom') {
|
|
18018
|
+
offsetX = -totalHeight;
|
|
17832
18019
|
}
|
|
17833
|
-
else {
|
|
17834
|
-
|
|
17835
|
-
|
|
17836
|
-
|
|
17837
|
-
|
|
17838
|
-
|
|
17839
|
-
|
|
17840
|
-
|
|
17841
|
-
let offsetX = 0;
|
|
17842
|
-
if (textBaseline === 'bottom') {
|
|
17843
|
-
offsetX = -lineHeight;
|
|
17844
|
-
}
|
|
17845
|
-
else if (textBaseline === 'middle') {
|
|
17846
|
-
offsetX = -lineHeight / 2;
|
|
17847
|
-
}
|
|
17848
|
-
if (textAlign === 'center') {
|
|
17849
|
-
offsetY -= totalW / 2;
|
|
17850
|
-
}
|
|
17851
|
-
else if (textAlign === 'right') {
|
|
17852
|
-
offsetY -= totalW;
|
|
17853
|
-
}
|
|
17854
|
-
context.textAlign = 'left';
|
|
17855
|
-
context.textBaseline = 'top';
|
|
17856
|
-
verticalList[0].forEach(item => {
|
|
17857
|
-
const { text, width, direction } = item;
|
|
17858
|
-
drawText(text, offsetX, offsetY, direction);
|
|
17859
|
-
offsetY += width;
|
|
17860
|
-
});
|
|
17861
|
-
}
|
|
18020
|
+
else if (textBaseline === 'middle') {
|
|
18021
|
+
offsetX = -totalHeight / 2;
|
|
18022
|
+
}
|
|
18023
|
+
if (textAlign === 'center') {
|
|
18024
|
+
offsetY -= totalW / 2;
|
|
18025
|
+
}
|
|
18026
|
+
else if (textAlign === 'right') {
|
|
18027
|
+
offsetY -= totalW;
|
|
17862
18028
|
}
|
|
18029
|
+
verticalList.forEach((verticalData, i) => {
|
|
18030
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
18031
|
+
const dw = totalW - currentW;
|
|
18032
|
+
let currentOffsetY = offsetY;
|
|
18033
|
+
if (textAlign === 'center') {
|
|
18034
|
+
currentOffsetY += dw / 2;
|
|
18035
|
+
}
|
|
18036
|
+
else if (textAlign === 'right') {
|
|
18037
|
+
currentOffsetY += dw;
|
|
18038
|
+
}
|
|
18039
|
+
verticalData.forEach(item => {
|
|
18040
|
+
const { text, width, direction } = item;
|
|
18041
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction);
|
|
18042
|
+
currentOffsetY += width;
|
|
18043
|
+
});
|
|
18044
|
+
});
|
|
17863
18045
|
}
|
|
17864
18046
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);
|
|
17865
18047
|
this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
@@ -18012,7 +18194,7 @@ let DefaultCanvasPolygonRender = class DefaultCanvasPolygonRender extends BaseRe
|
|
|
18012
18194
|
}
|
|
18013
18195
|
drawShape(polygon, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
18014
18196
|
const polygonAttribute = getTheme(polygon, params === null || params === void 0 ? void 0 : params.theme).polygon;
|
|
18015
|
-
const { points = polygonAttribute.points, cornerRadius = polygonAttribute.cornerRadius, x: originX = polygonAttribute.x, y: originY = polygonAttribute.y, closePath = polygonAttribute.closePath } = polygon.attribute;
|
|
18197
|
+
const { points = polygonAttribute.points, cornerRadius = polygonAttribute.cornerRadius, x: originX = polygonAttribute.x, y: originY = polygonAttribute.y, closePath = polygonAttribute.closePath, fillStrokeOrder = polygonAttribute.fillStrokeOrder } = polygon.attribute;
|
|
18016
18198
|
const data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
|
|
18017
18199
|
if (!data) {
|
|
18018
18200
|
return;
|
|
@@ -18028,23 +18210,35 @@ let DefaultCanvasPolygonRender = class DefaultCanvasPolygonRender extends BaseRe
|
|
|
18028
18210
|
closePath && context.closePath();
|
|
18029
18211
|
context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute);
|
|
18030
18212
|
this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
18031
|
-
|
|
18032
|
-
if (
|
|
18033
|
-
fillCb
|
|
18213
|
+
const _runFill = () => {
|
|
18214
|
+
if (doFill) {
|
|
18215
|
+
if (fillCb) {
|
|
18216
|
+
fillCb(context, polygon.attribute, polygonAttribute);
|
|
18217
|
+
}
|
|
18218
|
+
else if (fVisible) {
|
|
18219
|
+
context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);
|
|
18220
|
+
context.fill();
|
|
18221
|
+
}
|
|
18034
18222
|
}
|
|
18035
|
-
|
|
18036
|
-
|
|
18037
|
-
|
|
18223
|
+
};
|
|
18224
|
+
const _runStroke = () => {
|
|
18225
|
+
if (doStroke) {
|
|
18226
|
+
if (strokeCb) {
|
|
18227
|
+
strokeCb(context, polygon.attribute, polygonAttribute);
|
|
18228
|
+
}
|
|
18229
|
+
else if (sVisible) {
|
|
18230
|
+
context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);
|
|
18231
|
+
context.stroke();
|
|
18232
|
+
}
|
|
18038
18233
|
}
|
|
18234
|
+
};
|
|
18235
|
+
if (!fillStrokeOrder) {
|
|
18236
|
+
_runFill();
|
|
18237
|
+
_runStroke();
|
|
18039
18238
|
}
|
|
18040
|
-
|
|
18041
|
-
|
|
18042
|
-
|
|
18043
|
-
}
|
|
18044
|
-
else if (sVisible) {
|
|
18045
|
-
context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);
|
|
18046
|
-
context.stroke();
|
|
18047
|
-
}
|
|
18239
|
+
else {
|
|
18240
|
+
_runStroke();
|
|
18241
|
+
_runFill();
|
|
18048
18242
|
}
|
|
18049
18243
|
this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
|
|
18050
18244
|
}
|
|
@@ -18067,7 +18261,7 @@ let DefaultCanvasGroupRender = class DefaultCanvasGroupRender {
|
|
|
18067
18261
|
}
|
|
18068
18262
|
drawShape(group, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
18069
18263
|
const groupAttribute = getTheme(group, params === null || params === void 0 ? void 0 : params.theme).group;
|
|
18070
|
-
const { fill = groupAttribute.fill, background, stroke = groupAttribute.stroke, opacity = groupAttribute.opacity, width = groupAttribute.width, height = groupAttribute.height, clip = groupAttribute.clip, fillOpacity = groupAttribute.fillOpacity, strokeOpacity = groupAttribute.strokeOpacity, cornerRadius = groupAttribute.cornerRadius, path = groupAttribute.path, lineWidth = groupAttribute.lineWidth, visible = groupAttribute.visible } = group.attribute;
|
|
18264
|
+
const { fill = groupAttribute.fill, background, stroke = groupAttribute.stroke, opacity = groupAttribute.opacity, width = groupAttribute.width, height = groupAttribute.height, clip = groupAttribute.clip, fillOpacity = groupAttribute.fillOpacity, strokeOpacity = groupAttribute.strokeOpacity, cornerRadius = groupAttribute.cornerRadius, path = groupAttribute.path, lineWidth = groupAttribute.lineWidth, visible = groupAttribute.visible, fillStrokeOrder = groupAttribute.fillStrokeOrder, x: originX = groupAttribute.x, y: originY = groupAttribute.y } = group.attribute;
|
|
18071
18265
|
const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);
|
|
18072
18266
|
const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);
|
|
18073
18267
|
const doFill = runFill(fill, background);
|
|
@@ -18123,23 +18317,35 @@ let DefaultCanvasGroupRender = class DefaultCanvasGroupRender {
|
|
|
18123
18317
|
context.clip();
|
|
18124
18318
|
}
|
|
18125
18319
|
context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
|
|
18126
|
-
|
|
18127
|
-
if (
|
|
18128
|
-
fillCb
|
|
18320
|
+
const _runFill = () => {
|
|
18321
|
+
if (doFillOrStroke.doFill) {
|
|
18322
|
+
if (fillCb) {
|
|
18323
|
+
fillCb(context, group.attribute, groupAttribute);
|
|
18324
|
+
}
|
|
18325
|
+
else if (fVisible) {
|
|
18326
|
+
context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);
|
|
18327
|
+
context.fill();
|
|
18328
|
+
}
|
|
18129
18329
|
}
|
|
18130
|
-
|
|
18131
|
-
|
|
18132
|
-
|
|
18330
|
+
};
|
|
18331
|
+
const _runStroke = () => {
|
|
18332
|
+
if (doFillOrStroke.doStroke) {
|
|
18333
|
+
if (strokeCb) {
|
|
18334
|
+
strokeCb(context, group.attribute, groupAttribute);
|
|
18335
|
+
}
|
|
18336
|
+
else if (sVisible) {
|
|
18337
|
+
context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);
|
|
18338
|
+
context.stroke();
|
|
18339
|
+
}
|
|
18133
18340
|
}
|
|
18341
|
+
};
|
|
18342
|
+
if (!fillStrokeOrder) {
|
|
18343
|
+
_runFill();
|
|
18344
|
+
_runStroke();
|
|
18134
18345
|
}
|
|
18135
|
-
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
}
|
|
18139
|
-
else if (sVisible) {
|
|
18140
|
-
context.setStrokeStyle(group, group.attribute, x, y, groupAttribute);
|
|
18141
|
-
context.stroke();
|
|
18142
|
-
}
|
|
18346
|
+
else {
|
|
18347
|
+
_runStroke();
|
|
18348
|
+
_runFill();
|
|
18143
18349
|
}
|
|
18144
18350
|
this._groupRenderContribitions.forEach(c => {
|
|
18145
18351
|
if (c.time === BaseRenderContributionTime.afterFillStroke) {
|
|
@@ -18239,7 +18445,7 @@ let DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender
|
|
|
18239
18445
|
}
|
|
18240
18446
|
drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
18241
18447
|
const imageAttribute = getTheme(image).image;
|
|
18242
|
-
const { width = imageAttribute.width, height = imageAttribute.height, repeatX = imageAttribute.repeatX, repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius = imageAttribute.cornerRadius, image: url } = image.attribute;
|
|
18448
|
+
const { width = imageAttribute.width, height = imageAttribute.height, repeatX = imageAttribute.repeatX, repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius = imageAttribute.cornerRadius, fillStrokeOrder = imageAttribute.fillStrokeOrder, image: url } = image.attribute;
|
|
18243
18449
|
const data = this.valid(image, imageAttribute, fillCb);
|
|
18244
18450
|
if (!data) {
|
|
18245
18451
|
return;
|
|
@@ -18247,58 +18453,70 @@ let DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender
|
|
|
18247
18453
|
const { fVisible, sVisible, doFill, doStroke } = data;
|
|
18248
18454
|
context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute);
|
|
18249
18455
|
this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);
|
|
18250
|
-
|
|
18251
|
-
if (
|
|
18252
|
-
fillCb
|
|
18253
|
-
|
|
18254
|
-
else if (fVisible) {
|
|
18255
|
-
if (!url || !image.resources) {
|
|
18256
|
-
return;
|
|
18257
|
-
}
|
|
18258
|
-
const res = image.resources.get(url);
|
|
18259
|
-
if (res.state !== 'success') {
|
|
18260
|
-
return;
|
|
18456
|
+
const _runFill = () => {
|
|
18457
|
+
if (doFill) {
|
|
18458
|
+
if (fillCb) {
|
|
18459
|
+
fillCb(context, image.attribute, imageAttribute);
|
|
18261
18460
|
}
|
|
18262
|
-
|
|
18263
|
-
|
|
18264
|
-
|
|
18265
|
-
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18273
|
-
|
|
18274
|
-
|
|
18275
|
-
|
|
18276
|
-
|
|
18277
|
-
|
|
18278
|
-
|
|
18279
|
-
|
|
18280
|
-
|
|
18281
|
-
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
|
|
18461
|
+
else if (fVisible) {
|
|
18462
|
+
if (!url || !image.resources) {
|
|
18463
|
+
return;
|
|
18464
|
+
}
|
|
18465
|
+
const res = image.resources.get(url);
|
|
18466
|
+
if (res.state !== 'success') {
|
|
18467
|
+
return;
|
|
18468
|
+
}
|
|
18469
|
+
let needRestore = false;
|
|
18470
|
+
if (cornerRadius === 0 || (isArray(cornerRadius) && cornerRadius.every(num => num === 0))) ;
|
|
18471
|
+
else {
|
|
18472
|
+
context.beginPath();
|
|
18473
|
+
createRectPath(context, x, y, width, height, cornerRadius);
|
|
18474
|
+
context.save();
|
|
18475
|
+
context.clip();
|
|
18476
|
+
needRestore = true;
|
|
18477
|
+
}
|
|
18478
|
+
context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
18479
|
+
let repeat = 0;
|
|
18480
|
+
if (repeatX === 'repeat') {
|
|
18481
|
+
repeat |= 0b0001;
|
|
18482
|
+
}
|
|
18483
|
+
if (repeatY === 'repeat') {
|
|
18484
|
+
repeat |= 0b0010;
|
|
18485
|
+
}
|
|
18486
|
+
if (repeat) {
|
|
18487
|
+
const pattern = context.createPattern(res.data, repeatStr[repeat]);
|
|
18488
|
+
context.fillStyle = pattern;
|
|
18489
|
+
context.translate(x, y, true);
|
|
18490
|
+
context.fillRect(0, 0, width, height);
|
|
18491
|
+
context.translate(-x, -y, true);
|
|
18492
|
+
}
|
|
18493
|
+
else {
|
|
18494
|
+
context.drawImage(res.data, x, y, width, height);
|
|
18495
|
+
}
|
|
18496
|
+
if (needRestore) {
|
|
18497
|
+
context.restore();
|
|
18498
|
+
}
|
|
18285
18499
|
}
|
|
18286
|
-
|
|
18287
|
-
|
|
18500
|
+
}
|
|
18501
|
+
};
|
|
18502
|
+
const _runStroke = () => {
|
|
18503
|
+
if (doStroke) {
|
|
18504
|
+
if (strokeCb) {
|
|
18505
|
+
strokeCb(context, image.attribute, imageAttribute);
|
|
18288
18506
|
}
|
|
18289
|
-
if (
|
|
18290
|
-
context.
|
|
18507
|
+
else if (sVisible) {
|
|
18508
|
+
context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);
|
|
18509
|
+
context.stroke();
|
|
18291
18510
|
}
|
|
18292
18511
|
}
|
|
18512
|
+
};
|
|
18513
|
+
if (!fillStrokeOrder) {
|
|
18514
|
+
_runFill();
|
|
18515
|
+
_runStroke();
|
|
18293
18516
|
}
|
|
18294
|
-
|
|
18295
|
-
|
|
18296
|
-
|
|
18297
|
-
}
|
|
18298
|
-
else if (sVisible) {
|
|
18299
|
-
context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);
|
|
18300
|
-
context.stroke();
|
|
18301
|
-
}
|
|
18517
|
+
else {
|
|
18518
|
+
_runStroke();
|
|
18519
|
+
_runFill();
|
|
18302
18520
|
}
|
|
18303
18521
|
this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);
|
|
18304
18522
|
}
|
|
@@ -18893,40 +19111,6 @@ class CanvasTextLayout {
|
|
|
18893
19111
|
}
|
|
18894
19112
|
return bbox;
|
|
18895
19113
|
}
|
|
18896
|
-
GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
|
|
18897
|
-
const linesLayout = [];
|
|
18898
|
-
const bboxWH = [width, height];
|
|
18899
|
-
const bboxOffset = [0, 0];
|
|
18900
|
-
while (str.length > 0) {
|
|
18901
|
-
const { str: clipText } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
18902
|
-
linesLayout.push({
|
|
18903
|
-
str: clipText,
|
|
18904
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
18905
|
-
});
|
|
18906
|
-
str = str.substring(clipText.length);
|
|
18907
|
-
}
|
|
18908
|
-
if (textAlign === 'left' || textAlign === 'start') ;
|
|
18909
|
-
else if (textAlign === 'center') {
|
|
18910
|
-
bboxOffset[0] = bboxWH[0] / -2;
|
|
18911
|
-
}
|
|
18912
|
-
else if (textAlign === 'right' || textAlign === 'end') {
|
|
18913
|
-
bboxOffset[0] = -bboxWH[0];
|
|
18914
|
-
}
|
|
18915
|
-
if (textBaseline === 'top') ;
|
|
18916
|
-
else if (textBaseline === 'middle') {
|
|
18917
|
-
bboxOffset[1] = bboxWH[1] / -2;
|
|
18918
|
-
}
|
|
18919
|
-
else if (textBaseline === 'bottom') {
|
|
18920
|
-
bboxOffset[1] = -bboxWH[1];
|
|
18921
|
-
}
|
|
18922
|
-
const bbox = {
|
|
18923
|
-
xOffset: bboxOffset[0],
|
|
18924
|
-
yOffset: bboxOffset[1],
|
|
18925
|
-
width: bboxWH[0],
|
|
18926
|
-
height: bboxWH[1]
|
|
18927
|
-
};
|
|
18928
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
18929
|
-
}
|
|
18930
19114
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight, suffix = '', wordBreak, lineWidth, suffixPosition = 'end') {
|
|
18931
19115
|
lines = lines.map(l => l.toString());
|
|
18932
19116
|
const linesLayout = [];
|
|
@@ -18934,10 +19118,13 @@ class CanvasTextLayout {
|
|
|
18934
19118
|
if (typeof lineWidth === 'number' && lineWidth !== Infinity) {
|
|
18935
19119
|
let width;
|
|
18936
19120
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
18937
|
-
|
|
19121
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
19122
|
+
width = Math.min(metrics.width, lineWidth);
|
|
18938
19123
|
linesLayout.push({
|
|
18939
19124
|
str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
18940
|
-
width
|
|
19125
|
+
width,
|
|
19126
|
+
ascent: metrics.ascent,
|
|
19127
|
+
descent: metrics.descent
|
|
18941
19128
|
});
|
|
18942
19129
|
}
|
|
18943
19130
|
bboxWH[0] = lineWidth;
|
|
@@ -18948,9 +19135,10 @@ class CanvasTextLayout {
|
|
|
18948
19135
|
let text;
|
|
18949
19136
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
18950
19137
|
text = lines[i];
|
|
18951
|
-
|
|
19138
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions);
|
|
19139
|
+
width = metrics.width;
|
|
18952
19140
|
lineWidth = Math.max(lineWidth, width);
|
|
18953
|
-
linesLayout.push({ str: text, width });
|
|
19141
|
+
linesLayout.push({ str: text, width, ascent: metrics.ascent, descent: metrics.descent });
|
|
18954
19142
|
}
|
|
18955
19143
|
bboxWH[0] = lineWidth;
|
|
18956
19144
|
}
|
|
@@ -18999,7 +19187,7 @@ class CanvasTextLayout {
|
|
|
18999
19187
|
else if (textAlign === 'right' || textAlign === 'end') {
|
|
19000
19188
|
line.leftOffset = bbox.width - line.width;
|
|
19001
19189
|
}
|
|
19002
|
-
line.topOffset =
|
|
19190
|
+
line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
|
|
19003
19191
|
origin[1] += lineHeight;
|
|
19004
19192
|
return line;
|
|
19005
19193
|
}
|
|
@@ -19008,6 +19196,7 @@ class CanvasTextLayout {
|
|
|
19008
19196
|
const TEXT_UPDATE_TAG_KEY = [
|
|
19009
19197
|
'text',
|
|
19010
19198
|
'maxLineWidth',
|
|
19199
|
+
'maxWidth',
|
|
19011
19200
|
'textAlign',
|
|
19012
19201
|
'textBaseline',
|
|
19013
19202
|
'heightLimit',
|
|
@@ -19035,20 +19224,14 @@ class Text extends Graphic {
|
|
|
19035
19224
|
var _a;
|
|
19036
19225
|
const attribute = this.attribute;
|
|
19037
19226
|
const textTheme = this.getGraphicTheme();
|
|
19038
|
-
|
|
19039
|
-
|
|
19040
|
-
}
|
|
19041
|
-
const { maxLineWidth = textTheme.maxLineWidth } = attribute;
|
|
19042
|
-
if (!Number.isFinite(maxLineWidth)) {
|
|
19227
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
19228
|
+
if (!Number.isFinite(maxWidth)) {
|
|
19043
19229
|
return ((_a = attribute.text) !== null && _a !== void 0 ? _a : textTheme.text).toString();
|
|
19044
19230
|
}
|
|
19045
19231
|
this.tryUpdateAABBBounds();
|
|
19046
19232
|
return this.cache.clipedText;
|
|
19047
19233
|
}
|
|
19048
19234
|
get clipedWidth() {
|
|
19049
|
-
if (!this.isSimplify()) {
|
|
19050
|
-
return undefined;
|
|
19051
|
-
}
|
|
19052
19235
|
this.tryUpdateAABBBounds();
|
|
19053
19236
|
return this.cache.clipedWidth;
|
|
19054
19237
|
}
|
|
@@ -19056,10 +19239,11 @@ class Text extends Graphic {
|
|
|
19056
19239
|
var _a, _b;
|
|
19057
19240
|
const textTheme = this.getGraphicTheme();
|
|
19058
19241
|
const attribute = this.attribute;
|
|
19059
|
-
const
|
|
19060
|
-
if (!Number.isFinite(
|
|
19242
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
19243
|
+
if (!Number.isFinite(maxWidth)) {
|
|
19061
19244
|
return false;
|
|
19062
19245
|
}
|
|
19246
|
+
const { text } = this.attribute;
|
|
19063
19247
|
this.tryUpdateAABBBounds();
|
|
19064
19248
|
if ((_b = (_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData) === null || _b === void 0 ? void 0 : _b.lines) {
|
|
19065
19249
|
let mergedText = '';
|
|
@@ -19078,15 +19262,9 @@ class Text extends Graphic {
|
|
|
19078
19262
|
return this.clipedText !== attribute.text.toString();
|
|
19079
19263
|
}
|
|
19080
19264
|
get multilineLayout() {
|
|
19081
|
-
if (!this.isMultiLine) {
|
|
19082
|
-
return undefined;
|
|
19083
|
-
}
|
|
19084
19265
|
this.tryUpdateAABBBounds();
|
|
19085
19266
|
return this.cache.layoutData;
|
|
19086
19267
|
}
|
|
19087
|
-
isSimplify() {
|
|
19088
|
-
return !this.isMultiLine && this.attribute.direction !== 'vertical';
|
|
19089
|
-
}
|
|
19090
19268
|
get isMultiLine() {
|
|
19091
19269
|
return Array.isArray(this.attribute.text) || this.attribute.whiteSpace === 'normal';
|
|
19092
19270
|
}
|
|
@@ -19154,13 +19332,66 @@ class Text extends Graphic {
|
|
|
19154
19332
|
transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix);
|
|
19155
19333
|
return aabbBounds;
|
|
19156
19334
|
}
|
|
19335
|
+
updateSingallineAABBBounds(text) {
|
|
19336
|
+
this.updateMultilineAABBBounds([text]);
|
|
19337
|
+
const layoutData = this.cache.layoutData;
|
|
19338
|
+
if (layoutData) {
|
|
19339
|
+
const line = layoutData.lines[0];
|
|
19340
|
+
this.cache.clipedText = line.str;
|
|
19341
|
+
this.cache.clipedWidth = line.width;
|
|
19342
|
+
}
|
|
19343
|
+
return this._AABBBounds;
|
|
19344
|
+
}
|
|
19345
|
+
updateMultilineAABBBounds(text) {
|
|
19346
|
+
const textTheme = this.getGraphicTheme();
|
|
19347
|
+
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19348
|
+
const b = direction === 'horizontal'
|
|
19349
|
+
? this.updateHorizontalMultilineAABBBounds(text)
|
|
19350
|
+
: this.updateVerticalMultilineAABBBounds(text);
|
|
19351
|
+
if (direction === 'horizontal') {
|
|
19352
|
+
if (underlineOffset) {
|
|
19353
|
+
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19354
|
+
}
|
|
19355
|
+
}
|
|
19356
|
+
return b;
|
|
19357
|
+
}
|
|
19358
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
19359
|
+
var _a;
|
|
19360
|
+
const textTheme = this.getGraphicTheme();
|
|
19361
|
+
const attribute = this.attribute;
|
|
19362
|
+
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;
|
|
19363
|
+
const buf = ignoreBuf ? 0 : 2;
|
|
19364
|
+
const lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
19365
|
+
if (whiteSpace === 'normal' || wrap) {
|
|
19366
|
+
return this.updateWrapAABBBounds(text);
|
|
19367
|
+
}
|
|
19368
|
+
if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
|
|
19369
|
+
const bbox = this.cache.layoutData.bbox;
|
|
19370
|
+
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19371
|
+
if (stroke) {
|
|
19372
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19373
|
+
}
|
|
19374
|
+
return this._AABBBounds;
|
|
19375
|
+
}
|
|
19376
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
19377
|
+
const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
|
|
19378
|
+
const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, maxLineWidth, suffixPosition);
|
|
19379
|
+
const { bbox } = layoutData;
|
|
19380
|
+
this.cache.layoutData = layoutData;
|
|
19381
|
+
this.clearUpdateShapeTag();
|
|
19382
|
+
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19383
|
+
if (stroke) {
|
|
19384
|
+
this._AABBBounds.expand(lineWidth / 2);
|
|
19385
|
+
}
|
|
19386
|
+
return this._AABBBounds;
|
|
19387
|
+
}
|
|
19157
19388
|
updateWrapAABBBounds(text) {
|
|
19158
|
-
var _a, _b, _c
|
|
19389
|
+
var _a, _b, _c;
|
|
19159
19390
|
const textTheme = this.getGraphicTheme();
|
|
19160
19391
|
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;
|
|
19161
|
-
const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
|
|
19162
19392
|
const buf = ignoreBuf ? 0 : 2;
|
|
19163
|
-
|
|
19393
|
+
const lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
|
|
19394
|
+
if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
|
|
19164
19395
|
const bbox = this.cache.layoutData.bbox;
|
|
19165
19396
|
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19166
19397
|
if (stroke) {
|
|
@@ -19169,7 +19400,8 @@ class Text extends Graphic {
|
|
|
19169
19400
|
return this._AABBBounds;
|
|
19170
19401
|
}
|
|
19171
19402
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
19172
|
-
const
|
|
19403
|
+
const textOptions = { fontSize, fontWeight, fontFamily };
|
|
19404
|
+
const layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure);
|
|
19173
19405
|
const lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()];
|
|
19174
19406
|
const linesLayout = [];
|
|
19175
19407
|
const bboxWH = [0, 0];
|
|
@@ -19186,19 +19418,22 @@ class Text extends Graphic {
|
|
|
19186
19418
|
const str = lines[i];
|
|
19187
19419
|
let needCut = true;
|
|
19188
19420
|
if (i === lineCountLimit - 1) {
|
|
19189
|
-
const clip =
|
|
19421
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, false, suffixPosition, i !== lines.length - 1);
|
|
19422
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19190
19423
|
linesLayout.push({
|
|
19191
19424
|
str: clip.str,
|
|
19192
|
-
width: clip.width
|
|
19425
|
+
width: clip.width,
|
|
19426
|
+
ascent: matrics.ascent,
|
|
19427
|
+
descent: matrics.descent
|
|
19193
19428
|
});
|
|
19194
19429
|
break;
|
|
19195
19430
|
}
|
|
19196
|
-
const clip =
|
|
19197
|
-
if (
|
|
19431
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, wordBreak === 'break-word');
|
|
19432
|
+
if (str !== '' && clip.str === '') {
|
|
19198
19433
|
if (ellipsis) {
|
|
19199
|
-
const clipEllipsis =
|
|
19200
|
-
clip.str = (
|
|
19201
|
-
clip.width = (
|
|
19434
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19435
|
+
clip.str = (_b = clipEllipsis.str) !== null && _b !== void 0 ? _b : '';
|
|
19436
|
+
clip.width = (_c = clipEllipsis.width) !== null && _c !== void 0 ? _c : 0;
|
|
19202
19437
|
}
|
|
19203
19438
|
else {
|
|
19204
19439
|
clip.str = '';
|
|
@@ -19206,21 +19441,16 @@ class Text extends Graphic {
|
|
|
19206
19441
|
}
|
|
19207
19442
|
needCut = false;
|
|
19208
19443
|
}
|
|
19444
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19209
19445
|
linesLayout.push({
|
|
19210
19446
|
str: clip.str,
|
|
19211
|
-
width: clip.width
|
|
19447
|
+
width: clip.width,
|
|
19448
|
+
ascent: matrics.ascent,
|
|
19449
|
+
descent: matrics.descent
|
|
19212
19450
|
});
|
|
19213
|
-
let cutLength = clip.str.length;
|
|
19214
|
-
if (clip.wordBreaked && !(str !== '' && clip.str === '')) {
|
|
19215
|
-
needCut = true;
|
|
19216
|
-
cutLength = clip.wordBreaked;
|
|
19217
|
-
}
|
|
19218
19451
|
if (clip.str.length === str.length) ;
|
|
19219
19452
|
else if (needCut) {
|
|
19220
|
-
|
|
19221
|
-
if (wordBreak === 'keep-all') {
|
|
19222
|
-
newStr = newStr.replace(/^\s+/g, '');
|
|
19223
|
-
}
|
|
19453
|
+
const newStr = str.substring(clip.str.length);
|
|
19224
19454
|
lines.splice(i + 1, 0, newStr);
|
|
19225
19455
|
}
|
|
19226
19456
|
}
|
|
@@ -19237,22 +19467,26 @@ class Text extends Graphic {
|
|
|
19237
19467
|
let text;
|
|
19238
19468
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
19239
19469
|
if (i === lineCountLimit - 1) {
|
|
19240
|
-
const clip =
|
|
19470
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19471
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
19241
19472
|
linesLayout.push({
|
|
19242
19473
|
str: clip.str,
|
|
19243
|
-
width: clip.width
|
|
19474
|
+
width: clip.width,
|
|
19475
|
+
ascent: matrics.ascent,
|
|
19476
|
+
descent: matrics.descent
|
|
19244
19477
|
});
|
|
19245
19478
|
lineWidth = Math.max(lineWidth, clip.width);
|
|
19246
19479
|
break;
|
|
19247
19480
|
}
|
|
19248
19481
|
text = lines[i];
|
|
19249
|
-
width =
|
|
19482
|
+
width = textMeasure.measureTextWidth(text, textOptions);
|
|
19250
19483
|
lineWidth = Math.max(lineWidth, width);
|
|
19251
|
-
|
|
19484
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
19485
|
+
linesLayout.push({ str: text, width, ascent: matrics.ascent, descent: matrics.descent });
|
|
19252
19486
|
}
|
|
19253
19487
|
bboxWH[0] = lineWidth;
|
|
19254
19488
|
}
|
|
19255
|
-
bboxWH[1] = linesLayout.length *
|
|
19489
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
19256
19490
|
const bbox = {
|
|
19257
19491
|
xOffset: 0,
|
|
19258
19492
|
yOffset: 0,
|
|
@@ -19269,212 +19503,19 @@ class Text extends Graphic {
|
|
|
19269
19503
|
}
|
|
19270
19504
|
return this._AABBBounds;
|
|
19271
19505
|
}
|
|
19272
|
-
updateSingallineAABBBounds(text) {
|
|
19273
|
-
const textTheme = this.getGraphicTheme();
|
|
19274
|
-
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19275
|
-
const b = direction === 'horizontal'
|
|
19276
|
-
? this.updateHorizontalSinglelineAABBBounds(text)
|
|
19277
|
-
: this.updateVerticalSinglelineAABBBounds(text);
|
|
19278
|
-
if (direction === 'horizontal') {
|
|
19279
|
-
if (underlineOffset) {
|
|
19280
|
-
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19281
|
-
}
|
|
19282
|
-
}
|
|
19283
|
-
return b;
|
|
19284
|
-
}
|
|
19285
|
-
updateMultilineAABBBounds(text) {
|
|
19286
|
-
const textTheme = this.getGraphicTheme();
|
|
19287
|
-
const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;
|
|
19288
|
-
const b = direction === 'horizontal'
|
|
19289
|
-
? this.updateHorizontalMultilineAABBBounds(text)
|
|
19290
|
-
: this.updateVerticalMultilineAABBBounds(text);
|
|
19291
|
-
if (direction === 'horizontal') {
|
|
19292
|
-
if (underlineOffset) {
|
|
19293
|
-
this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);
|
|
19294
|
-
}
|
|
19295
|
-
}
|
|
19296
|
-
return b;
|
|
19297
|
-
}
|
|
19298
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
19299
|
-
var _a, _b;
|
|
19300
|
-
const textTheme = this.getGraphicTheme();
|
|
19301
|
-
const { wrap = textTheme.wrap } = this.attribute;
|
|
19302
|
-
if (wrap) {
|
|
19303
|
-
return this.updateWrapAABBBounds([text]);
|
|
19304
|
-
}
|
|
19305
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19306
|
-
let width;
|
|
19307
|
-
let str;
|
|
19308
|
-
const attribute = this.attribute;
|
|
19309
|
-
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;
|
|
19310
|
-
if (whiteSpace === 'normal') {
|
|
19311
|
-
return this.updateWrapAABBBounds(text);
|
|
19312
|
-
}
|
|
19313
|
-
const buf = ignoreBuf ? 0 : Math.max(2, fontSize * 0.075);
|
|
19314
|
-
const textFontSize = attribute.fontSize || textTheme.fontSize;
|
|
19315
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) !== null && _a !== void 0 ? _a : textFontSize + buf;
|
|
19316
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
19317
|
-
width = (_b = this.cache.clipedWidth) !== null && _b !== void 0 ? _b : 0;
|
|
19318
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19319
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19320
|
-
this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight);
|
|
19321
|
-
if (stroke) {
|
|
19322
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19323
|
-
}
|
|
19324
|
-
return this._AABBBounds;
|
|
19325
|
-
}
|
|
19326
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
19327
|
-
if (ellipsis) {
|
|
19328
|
-
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
19329
|
-
const data = textMeasure.clipTextWithSuffix(text.toString(), { fontSize, fontWeight, fontFamily }, maxLineWidth, strEllipsis, false, suffixPosition);
|
|
19330
|
-
str = data.str;
|
|
19331
|
-
width = data.width;
|
|
19332
|
-
}
|
|
19333
|
-
else {
|
|
19334
|
-
const data = textMeasure.clipText(text.toString(), { fontSize, fontWeight, fontFamily }, maxLineWidth, false);
|
|
19335
|
-
str = data.str;
|
|
19336
|
-
width = data.width;
|
|
19337
|
-
}
|
|
19338
|
-
this.cache.clipedText = str;
|
|
19339
|
-
this.cache.clipedWidth = width;
|
|
19340
|
-
}
|
|
19341
|
-
else {
|
|
19342
|
-
width = textMeasure.measureTextWidth(text.toString(), { fontSize, fontWeight, fontFamily });
|
|
19343
|
-
this.cache.clipedText = text.toString();
|
|
19344
|
-
this.cache.clipedWidth = width;
|
|
19345
|
-
}
|
|
19346
|
-
this.clearUpdateShapeTag();
|
|
19347
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19348
|
-
let lh = lineHeight;
|
|
19349
|
-
if (application.global && application.global.isSafari()) {
|
|
19350
|
-
lh += fontSize * 0.2;
|
|
19351
|
-
}
|
|
19352
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
19353
|
-
this._AABBBounds.set(dx, dy, dx + width, dy + lh);
|
|
19354
|
-
if (stroke) {
|
|
19355
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19356
|
-
}
|
|
19357
|
-
return this._AABBBounds;
|
|
19358
|
-
}
|
|
19359
|
-
getBaselineMapAlign() {
|
|
19360
|
-
return Text.baselineMapAlign;
|
|
19361
|
-
}
|
|
19362
|
-
getAlignMapBaseline() {
|
|
19363
|
-
return Text.alignMapBaseline;
|
|
19364
|
-
}
|
|
19365
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
19366
|
-
var _a, _b, _c;
|
|
19367
|
-
const textTheme = this.getGraphicTheme();
|
|
19368
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19369
|
-
let width;
|
|
19370
|
-
const attribute = this.attribute;
|
|
19371
|
-
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
19372
|
-
const buf = ignoreBuf ? 0 : 2;
|
|
19373
|
-
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;
|
|
19374
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
19375
|
-
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
19376
|
-
if (!verticalMode) {
|
|
19377
|
-
const t = textAlign;
|
|
19378
|
-
textAlign = (_b = Text.baselineMapAlign[textBaseline]) !== null && _b !== void 0 ? _b : 'left';
|
|
19379
|
-
textBaseline = (_c = Text.alignMapBaseline[t]) !== null && _c !== void 0 ? _c : 'top';
|
|
19380
|
-
}
|
|
19381
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
19382
|
-
width = this.cache.clipedWidth;
|
|
19383
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19384
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19385
|
-
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19386
|
-
if (stroke) {
|
|
19387
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19388
|
-
}
|
|
19389
|
-
return this._AABBBounds;
|
|
19390
|
-
}
|
|
19391
|
-
let verticalList = [
|
|
19392
|
-
verticalLayout(text.toString())
|
|
19393
|
-
];
|
|
19394
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
19395
|
-
if (ellipsis) {
|
|
19396
|
-
const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
|
|
19397
|
-
const data = textMeasure.clipTextWithSuffixVertical(verticalList[0], { fontSize, fontWeight, fontFamily }, maxLineWidth, strEllipsis, false, suffixPosition);
|
|
19398
|
-
verticalList = [data.verticalList];
|
|
19399
|
-
width = data.width;
|
|
19400
|
-
}
|
|
19401
|
-
else {
|
|
19402
|
-
const data = textMeasure.clipTextVertical(verticalList[0], { fontSize, fontWeight, fontFamily }, maxLineWidth, false);
|
|
19403
|
-
verticalList = [data.verticalList];
|
|
19404
|
-
width = data.width;
|
|
19405
|
-
}
|
|
19406
|
-
this.cache.verticalList = verticalList;
|
|
19407
|
-
this.cache.clipedWidth = width;
|
|
19408
|
-
}
|
|
19409
|
-
else {
|
|
19410
|
-
width = 0;
|
|
19411
|
-
verticalList[0].forEach(t => {
|
|
19412
|
-
const w = t.direction === TextDirection.HORIZONTAL
|
|
19413
|
-
? fontSize
|
|
19414
|
-
: textMeasure.measureTextWidth(t.text, { fontSize, fontWeight, fontFamily });
|
|
19415
|
-
width += w;
|
|
19416
|
-
t.width = w;
|
|
19417
|
-
});
|
|
19418
|
-
this.cache.verticalList = verticalList;
|
|
19419
|
-
this.cache.clipedWidth = width;
|
|
19420
|
-
}
|
|
19421
|
-
this.clearUpdateShapeTag();
|
|
19422
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
19423
|
-
const dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
19424
|
-
this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width);
|
|
19425
|
-
if (stroke) {
|
|
19426
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19427
|
-
}
|
|
19428
|
-
return this._AABBBounds;
|
|
19429
|
-
}
|
|
19430
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
19431
|
-
var _a, _b;
|
|
19432
|
-
const textTheme = this.getGraphicTheme();
|
|
19433
|
-
const { wrap = textTheme.wrap } = this.attribute;
|
|
19434
|
-
if (wrap) {
|
|
19435
|
-
return this.updateWrapAABBBounds(text);
|
|
19436
|
-
}
|
|
19437
|
-
const attribute = this.attribute;
|
|
19438
|
-
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;
|
|
19439
|
-
const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize);
|
|
19440
|
-
if (whiteSpace === 'normal') {
|
|
19441
|
-
return this.updateWrapAABBBounds(text);
|
|
19442
|
-
}
|
|
19443
|
-
if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
|
|
19444
|
-
const bbox = this.cache.layoutData.bbox;
|
|
19445
|
-
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19446
|
-
if (stroke) {
|
|
19447
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19448
|
-
}
|
|
19449
|
-
return this._AABBBounds;
|
|
19450
|
-
}
|
|
19451
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
19452
|
-
const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
|
|
19453
|
-
const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, maxLineWidth, suffixPosition);
|
|
19454
|
-
const { bbox } = layoutData;
|
|
19455
|
-
this.cache.layoutData = layoutData;
|
|
19456
|
-
this.clearUpdateShapeTag();
|
|
19457
|
-
this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
|
|
19458
|
-
if (stroke) {
|
|
19459
|
-
this._AABBBounds.expand(lineWidth / 2);
|
|
19460
|
-
}
|
|
19461
|
-
return this._AABBBounds;
|
|
19462
|
-
}
|
|
19463
19506
|
updateVerticalMultilineAABBBounds(text) {
|
|
19464
|
-
var _a, _b
|
|
19507
|
+
var _a, _b;
|
|
19465
19508
|
const textTheme = this.getGraphicTheme();
|
|
19466
19509
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
19467
19510
|
let width;
|
|
19468
19511
|
const attribute = this.attribute;
|
|
19469
|
-
const { ignoreBuf = textTheme.ignoreBuf } = attribute;
|
|
19470
|
-
const buf = ignoreBuf ? 0 : 2;
|
|
19471
19512
|
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;
|
|
19472
|
-
const lineHeight = (
|
|
19513
|
+
const lineHeight = this.getLineHeight(attribute, textTheme);
|
|
19473
19514
|
let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
|
|
19474
19515
|
if (!verticalMode) {
|
|
19475
19516
|
const t = textAlign;
|
|
19476
|
-
textAlign = (
|
|
19477
|
-
textBaseline = (
|
|
19517
|
+
textAlign = (_a = Text.baselineMapAlign[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
|
|
19518
|
+
textBaseline = (_b = Text.alignMapBaseline[t]) !== null && _b !== void 0 ? _b : 'top';
|
|
19478
19519
|
}
|
|
19479
19520
|
width = 0;
|
|
19480
19521
|
if (!this.shouldUpdateShape() && this.cache) {
|
|
@@ -19534,6 +19575,15 @@ class Text extends Graphic {
|
|
|
19534
19575
|
}
|
|
19535
19576
|
return this._AABBBounds;
|
|
19536
19577
|
}
|
|
19578
|
+
getMaxWidth(theme) {
|
|
19579
|
+
var _a, _b;
|
|
19580
|
+
const attribute = this.attribute;
|
|
19581
|
+
return (_b = (_a = attribute.maxLineWidth) !== null && _a !== void 0 ? _a : attribute.maxWidth) !== null && _b !== void 0 ? _b : theme.maxWidth;
|
|
19582
|
+
}
|
|
19583
|
+
getLineHeight(attribute, textTheme) {
|
|
19584
|
+
var _a;
|
|
19585
|
+
return ((_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize));
|
|
19586
|
+
}
|
|
19537
19587
|
needUpdateTags(keys, k = TEXT_UPDATE_TAG_KEY) {
|
|
19538
19588
|
return super.needUpdateTags(keys, k);
|
|
19539
19589
|
}
|
|
@@ -19546,6 +19596,12 @@ class Text extends Graphic {
|
|
|
19546
19596
|
getNoWorkAnimateAttr() {
|
|
19547
19597
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
19548
19598
|
}
|
|
19599
|
+
getBaselineMapAlign() {
|
|
19600
|
+
return Text.baselineMapAlign;
|
|
19601
|
+
}
|
|
19602
|
+
getAlignMapBaseline() {
|
|
19603
|
+
return Text.alignMapBaseline;
|
|
19604
|
+
}
|
|
19549
19605
|
}
|
|
19550
19606
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({ ellipsis: 1, wordBreak: 1, direction: 1, textAlign: 1, textBaseline: 1, fontFamily: 1, fontWeight: 1 }, NOWORK_ANIMATE_ATTR);
|
|
19551
19607
|
Text.baselineMapAlign = {
|
|
@@ -19609,7 +19665,9 @@ class WrapText extends Text {
|
|
|
19609
19665
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19610
19666
|
linesLayout.push({
|
|
19611
19667
|
str: clip.str,
|
|
19612
|
-
width: clip.width
|
|
19668
|
+
width: clip.width,
|
|
19669
|
+
ascent: 0,
|
|
19670
|
+
descent: 0
|
|
19613
19671
|
});
|
|
19614
19672
|
break;
|
|
19615
19673
|
}
|
|
@@ -19628,7 +19686,9 @@ class WrapText extends Text {
|
|
|
19628
19686
|
}
|
|
19629
19687
|
linesLayout.push({
|
|
19630
19688
|
str: clip.str,
|
|
19631
|
-
width: clip.width
|
|
19689
|
+
width: clip.width,
|
|
19690
|
+
ascent: 0,
|
|
19691
|
+
descent: 0
|
|
19632
19692
|
});
|
|
19633
19693
|
if (clip.str.length === str.length) ;
|
|
19634
19694
|
else if (needCut) {
|
|
@@ -19652,7 +19712,9 @@ class WrapText extends Text {
|
|
|
19652
19712
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, false, suffixPosition);
|
|
19653
19713
|
linesLayout.push({
|
|
19654
19714
|
str: clip.str,
|
|
19655
|
-
width: clip.width
|
|
19715
|
+
width: clip.width,
|
|
19716
|
+
ascent: 0,
|
|
19717
|
+
descent: 0
|
|
19656
19718
|
});
|
|
19657
19719
|
lineWidth = Math.max(lineWidth, clip.width);
|
|
19658
19720
|
break;
|
|
@@ -19660,7 +19722,7 @@ class WrapText extends Text {
|
|
|
19660
19722
|
text = lines[i];
|
|
19661
19723
|
width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');
|
|
19662
19724
|
lineWidth = Math.max(lineWidth, width);
|
|
19663
|
-
linesLayout.push({ str: text, width });
|
|
19725
|
+
linesLayout.push({ str: text, width, ascent: 0, descent: 0 });
|
|
19664
19726
|
}
|
|
19665
19727
|
bboxWH[0] = lineWidth;
|
|
19666
19728
|
}
|
|
@@ -24219,6 +24281,63 @@ class AutoRenderPlugin {
|
|
|
24219
24281
|
}
|
|
24220
24282
|
}
|
|
24221
24283
|
|
|
24284
|
+
class AutoRefreshPlugin {
|
|
24285
|
+
constructor() {
|
|
24286
|
+
this.name = 'AutoRefreshPlugin';
|
|
24287
|
+
this.activeEvent = 'onRegister';
|
|
24288
|
+
this._uid = Generator.GenAutoIncrementId();
|
|
24289
|
+
this.key = this.name + this._uid;
|
|
24290
|
+
this.handleChange = (graphic) => {
|
|
24291
|
+
if (graphic.glyphHost) {
|
|
24292
|
+
graphic = graphic.glyphHost;
|
|
24293
|
+
}
|
|
24294
|
+
if (graphic.stage === this.pluginService.stage && graphic.stage != null) {
|
|
24295
|
+
graphic.stage.renderNextFrame();
|
|
24296
|
+
}
|
|
24297
|
+
};
|
|
24298
|
+
}
|
|
24299
|
+
activate(context) {
|
|
24300
|
+
this.pluginService = context;
|
|
24301
|
+
this.dpr = application.global.devicePixelRatio;
|
|
24302
|
+
this.refresh();
|
|
24303
|
+
}
|
|
24304
|
+
refresh() {
|
|
24305
|
+
if (!this._refreshByMediaQuery()) {
|
|
24306
|
+
this._refreshByRaf();
|
|
24307
|
+
}
|
|
24308
|
+
}
|
|
24309
|
+
_refreshByRaf() {
|
|
24310
|
+
const raf = application.global.getRequestAnimationFrame();
|
|
24311
|
+
this.rafId = raf(() => {
|
|
24312
|
+
if (application.global.devicePixelRatio !== this.dpr) {
|
|
24313
|
+
this.dpr = application.global.devicePixelRatio;
|
|
24314
|
+
this.pluginService.stage.setDpr(this.dpr, true);
|
|
24315
|
+
}
|
|
24316
|
+
this.refresh();
|
|
24317
|
+
});
|
|
24318
|
+
}
|
|
24319
|
+
_refreshByMediaQuery() {
|
|
24320
|
+
try {
|
|
24321
|
+
const mqString = `(resolution: ${window.devicePixelRatio}dppx)`;
|
|
24322
|
+
const updatePixelRatio = () => {
|
|
24323
|
+
if (window.devicePixelRatio !== this.dpr) {
|
|
24324
|
+
this.dpr = window.devicePixelRatio;
|
|
24325
|
+
this.pluginService.stage.setDpr(this.dpr, true);
|
|
24326
|
+
}
|
|
24327
|
+
};
|
|
24328
|
+
matchMedia(mqString).addEventListener('change', updatePixelRatio);
|
|
24329
|
+
}
|
|
24330
|
+
catch (err) {
|
|
24331
|
+
return false;
|
|
24332
|
+
}
|
|
24333
|
+
return true;
|
|
24334
|
+
}
|
|
24335
|
+
deactivate(context) {
|
|
24336
|
+
const craf = application.global.getCancelAnimationFrame();
|
|
24337
|
+
craf && this.rafId && craf(this.rafId);
|
|
24338
|
+
}
|
|
24339
|
+
}
|
|
24340
|
+
|
|
24222
24341
|
class IncrementalAutoRenderPlugin {
|
|
24223
24342
|
constructor() {
|
|
24224
24343
|
this.name = 'IncrementalAutoRenderPlugin';
|
|
@@ -24561,6 +24680,9 @@ class Stage extends Group {
|
|
|
24561
24680
|
if (params.autoRender) {
|
|
24562
24681
|
this.enableAutoRender();
|
|
24563
24682
|
}
|
|
24683
|
+
if (params.autoRefresh) {
|
|
24684
|
+
this.enableAutoRefresh();
|
|
24685
|
+
}
|
|
24564
24686
|
if (params.disableDirtyBounds === false) {
|
|
24565
24687
|
this.enableDirtyBounds();
|
|
24566
24688
|
}
|
|
@@ -24732,6 +24854,22 @@ class Stage extends Group {
|
|
|
24732
24854
|
this.pluginService.unRegister(plugin);
|
|
24733
24855
|
});
|
|
24734
24856
|
}
|
|
24857
|
+
enableAutoRefresh() {
|
|
24858
|
+
if (this.autoRefresh) {
|
|
24859
|
+
return;
|
|
24860
|
+
}
|
|
24861
|
+
this.autoRefresh = true;
|
|
24862
|
+
this.pluginService.register(new AutoRefreshPlugin());
|
|
24863
|
+
}
|
|
24864
|
+
disableAutoRefresh() {
|
|
24865
|
+
if (!this.autoRefresh) {
|
|
24866
|
+
return;
|
|
24867
|
+
}
|
|
24868
|
+
this.autoRefresh = false;
|
|
24869
|
+
this.pluginService.findPluginsByName('AutoRefreshPlugin').forEach(plugin => {
|
|
24870
|
+
this.pluginService.unRegister(plugin);
|
|
24871
|
+
});
|
|
24872
|
+
}
|
|
24735
24873
|
enableIncrementalAutoRender() {
|
|
24736
24874
|
if (this.increaseAutoRender) {
|
|
24737
24875
|
return;
|
|
@@ -26143,56 +26281,12 @@ function simplifyRadialDist(points, sqTolerance) {
|
|
|
26143
26281
|
}
|
|
26144
26282
|
return newPoints;
|
|
26145
26283
|
}
|
|
26146
|
-
function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
|
|
26147
|
-
let maxSqDist = sqTolerance;
|
|
26148
|
-
let nextIdx = startIdx;
|
|
26149
|
-
const startX = points[startIdx].x;
|
|
26150
|
-
const startY = points[startIdx].y;
|
|
26151
|
-
const endX = points[endIdx].x;
|
|
26152
|
-
const endY = points[endIdx].y;
|
|
26153
|
-
const vecX2 = endX - startX;
|
|
26154
|
-
const vecY2 = endY - startY;
|
|
26155
|
-
const sqLength = vecX2 * vecX2 + vecY2 * vecY2;
|
|
26156
|
-
let area;
|
|
26157
|
-
let sqArea;
|
|
26158
|
-
let sqDistance;
|
|
26159
|
-
let vecX1;
|
|
26160
|
-
let vecY1;
|
|
26161
|
-
for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) {
|
|
26162
|
-
vecX1 = points[i].x - startX;
|
|
26163
|
-
vecY1 = points[i].y - startY;
|
|
26164
|
-
area = vecX1 * vecY2 - vecX2 * vecY1;
|
|
26165
|
-
sqArea = area * area;
|
|
26166
|
-
sqDistance = sqArea / sqLength;
|
|
26167
|
-
if (sqDistance > maxSqDist) {
|
|
26168
|
-
maxSqDist = sqDistance;
|
|
26169
|
-
nextIdx = i;
|
|
26170
|
-
}
|
|
26171
|
-
}
|
|
26172
|
-
if (maxSqDist > sqTolerance) {
|
|
26173
|
-
if (nextIdx - startIdx > 2) {
|
|
26174
|
-
simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified);
|
|
26175
|
-
}
|
|
26176
|
-
simplified.push(points[nextIdx], points[nextIdx + 1]);
|
|
26177
|
-
if (endIdx - nextIdx > 2) {
|
|
26178
|
-
simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified);
|
|
26179
|
-
}
|
|
26180
|
-
}
|
|
26181
|
-
}
|
|
26182
|
-
function simplifyDouglasPeucker(points, sqTolerance) {
|
|
26183
|
-
const lastIdx = points.length - 1;
|
|
26184
|
-
const simplified = [points[0]];
|
|
26185
|
-
simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified);
|
|
26186
|
-
simplified.push(points[lastIdx]);
|
|
26187
|
-
return simplified;
|
|
26188
|
-
}
|
|
26189
26284
|
function flatten_simplify(points, tolerance, highestQuality) {
|
|
26190
26285
|
if (points.length <= 10) {
|
|
26191
26286
|
return points;
|
|
26192
26287
|
}
|
|
26193
26288
|
const sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
|
|
26194
26289
|
points = highestQuality ? points : simplifyRadialDist(points, sqTolerance);
|
|
26195
|
-
points = simplifyDouglasPeucker(points, sqTolerance);
|
|
26196
26290
|
return points;
|
|
26197
26291
|
}
|
|
26198
26292
|
|