@visactor/vrender 0.20.16 → 0.21.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +11 -10
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +1041 -1049
- package/dist/index.js +1040 -1048
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -748,6 +748,13 @@
|
|
|
748
748
|
};
|
|
749
749
|
exports.DefaultGlobal = __decorate$1H([injectable(), __param$T(0, inject(ContributionProvider)), __param$T(0, named(EnvContribution)), __metadata$1h("design:paramtypes", [Object])], exports.DefaultGlobal);
|
|
750
750
|
|
|
751
|
+
exports.MeasureModeEnum = void 0;
|
|
752
|
+
!function (MeasureModeEnum) {
|
|
753
|
+
MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
|
|
754
|
+
}(exports.MeasureModeEnum || (exports.MeasureModeEnum = {}));
|
|
755
|
+
|
|
756
|
+
const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
|
|
757
|
+
|
|
751
758
|
function getDefaultExportFromCjs (x) {
|
|
752
759
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
753
760
|
}
|
|
@@ -1702,7 +1709,9 @@
|
|
|
1702
1709
|
} = this.textSpec;
|
|
1703
1710
|
return {
|
|
1704
1711
|
width: metrics.width,
|
|
1705
|
-
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
|
|
1712
|
+
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize,
|
|
1713
|
+
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
|
|
1714
|
+
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
|
|
1706
1715
|
};
|
|
1707
1716
|
}
|
|
1708
1717
|
quickMeasure(text) {
|
|
@@ -1716,7 +1725,7 @@
|
|
|
1716
1725
|
for (let i = 0; i < text.length; i++) {
|
|
1717
1726
|
const char = text[i];
|
|
1718
1727
|
let size = this._measureSpecialChar(char);
|
|
1719
|
-
isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height);
|
|
1728
|
+
isNil$1(size) && TextMeasure.NUMBERS_CHAR_SET.includes(char) && (size = this._measureNumberChar()), isNil$1(size) && ["F", "W"].includes(eastAsianCharacterInfo(char)) && (size = this._measureFullSizeChar()), isNil$1(size) && (size = this._measureLetterChar()), totalSize.width += size.width, totalSize.height = Math.max(totalSize.height, size.height), !isNil$1(size.fontBoundingBoxAscent) && (totalSize.fontBoundingBoxAscent = size.fontBoundingBoxAscent), !isNil$1(size.fontBoundingBoxDescent) && (totalSize.fontBoundingBoxDescent = size.fontBoundingBoxDescent);
|
|
1720
1729
|
}
|
|
1721
1730
|
return totalSize;
|
|
1722
1731
|
}
|
|
@@ -1765,7 +1774,9 @@
|
|
|
1765
1774
|
const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
|
|
1766
1775
|
this._numberCharSize = {
|
|
1767
1776
|
width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
|
|
1768
|
-
height: numberBounds.height
|
|
1777
|
+
height: numberBounds.height,
|
|
1778
|
+
fontBoundingBoxAscent: numberBounds.fontBoundingBoxAscent,
|
|
1779
|
+
fontBoundingBoxDescent: numberBounds.fontBoundingBoxDescent
|
|
1769
1780
|
};
|
|
1770
1781
|
}
|
|
1771
1782
|
return this._numberCharSize;
|
|
@@ -1778,7 +1789,9 @@
|
|
|
1778
1789
|
const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
|
|
1779
1790
|
this._letterCharSize = {
|
|
1780
1791
|
width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
|
|
1781
|
-
height: alphabetBounds.height
|
|
1792
|
+
height: alphabetBounds.height,
|
|
1793
|
+
fontBoundingBoxAscent: alphabetBounds.fontBoundingBoxAscent,
|
|
1794
|
+
fontBoundingBoxDescent: alphabetBounds.fontBoundingBoxDescent
|
|
1782
1795
|
};
|
|
1783
1796
|
}
|
|
1784
1797
|
return this._letterCharSize;
|
|
@@ -3919,6 +3932,7 @@
|
|
|
3919
3932
|
const DefaultTextStyle = {
|
|
3920
3933
|
text: "",
|
|
3921
3934
|
maxLineWidth: 1 / 0,
|
|
3935
|
+
maxWidth: 1 / 0,
|
|
3922
3936
|
textAlign: "left",
|
|
3923
3937
|
textBaseline: "alphabetic",
|
|
3924
3938
|
fontSize: 16,
|
|
@@ -3942,7 +3956,8 @@
|
|
|
3942
3956
|
suffixPosition: "end",
|
|
3943
3957
|
underlineDash: [],
|
|
3944
3958
|
underlineOffset: 0,
|
|
3945
|
-
disableAutoClipedPoptip: void 0
|
|
3959
|
+
disableAutoClipedPoptip: void 0,
|
|
3960
|
+
measureMode: exports.MeasureModeEnum.fontBounding
|
|
3946
3961
|
};
|
|
3947
3962
|
const DefaultPickStyle = {
|
|
3948
3963
|
pickStrokeBuffer: 0
|
|
@@ -4149,448 +4164,260 @@
|
|
|
4149
4164
|
class Application {}
|
|
4150
4165
|
const application = new Application();
|
|
4151
4166
|
|
|
4152
|
-
const
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
4171
|
-
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
4172
|
-
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
4173
|
-
};
|
|
4174
|
-
let input = "";
|
|
4175
|
-
function error(msg) {
|
|
4176
|
-
const err = new Error(input + ": " + msg);
|
|
4177
|
-
throw err.source = input, err;
|
|
4178
|
-
}
|
|
4179
|
-
function getAST() {
|
|
4180
|
-
const ast = matchListing(matchDefinition);
|
|
4181
|
-
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
4167
|
+
const DIRECTION_KEY = {
|
|
4168
|
+
horizontal: {
|
|
4169
|
+
width: "width",
|
|
4170
|
+
height: "height",
|
|
4171
|
+
left: "left",
|
|
4172
|
+
top: "top",
|
|
4173
|
+
x: "x",
|
|
4174
|
+
y: "y",
|
|
4175
|
+
bottom: "bottom"
|
|
4176
|
+
},
|
|
4177
|
+
vertical: {
|
|
4178
|
+
width: "height",
|
|
4179
|
+
height: "width",
|
|
4180
|
+
left: "top",
|
|
4181
|
+
top: "left",
|
|
4182
|
+
x: "y",
|
|
4183
|
+
y: "x",
|
|
4184
|
+
bottom: "right"
|
|
4182
4185
|
}
|
|
4183
|
-
|
|
4184
|
-
|
|
4186
|
+
};
|
|
4187
|
+
const defaultFormatting = {
|
|
4188
|
+
fontSize: 16,
|
|
4189
|
+
fontFamily: "sans-serif",
|
|
4190
|
+
fill: !0,
|
|
4191
|
+
stroke: !1,
|
|
4192
|
+
fontWeight: "normal",
|
|
4193
|
+
lineHeight: "normal",
|
|
4194
|
+
fontStyle: "normal",
|
|
4195
|
+
textDecoration: "none",
|
|
4196
|
+
textAlign: "left",
|
|
4197
|
+
script: "normal"
|
|
4198
|
+
};
|
|
4199
|
+
const regLetter = /\w|\(|\)|-/;
|
|
4200
|
+
const regPunctuation = /[.?!,;:/,。?!、;:]/;
|
|
4201
|
+
const regFirstSpace = /\S/;
|
|
4202
|
+
const setTextStyle = (ctx, character) => {
|
|
4203
|
+
let fontSize = character.fontSize || 16;
|
|
4204
|
+
switch (character.script) {
|
|
4205
|
+
case "super":
|
|
4206
|
+
case "sub":
|
|
4207
|
+
fontSize *= .8;
|
|
4185
4208
|
}
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4209
|
+
ctx.setTextStyle({
|
|
4210
|
+
textAlign: "left",
|
|
4211
|
+
textBaseline: character.textBaseline || "alphabetic",
|
|
4212
|
+
fontStyle: character.fontStyle || "",
|
|
4213
|
+
fontWeight: character.fontWeight || "",
|
|
4214
|
+
fontSize: fontSize,
|
|
4215
|
+
fontFamily: character.fontFamily || "sans-serif"
|
|
4216
|
+
});
|
|
4217
|
+
};
|
|
4218
|
+
function applyFillStyle(ctx, character) {
|
|
4219
|
+
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
4220
|
+
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
4221
|
+
const {
|
|
4222
|
+
fillOpacity = 1,
|
|
4223
|
+
opacity = 1
|
|
4224
|
+
} = character;
|
|
4225
|
+
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
|
|
4226
|
+
}
|
|
4227
|
+
function applyStrokeStyle(ctx, character) {
|
|
4228
|
+
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
4229
|
+
if (!strokeStyle) return void (ctx.globalAlpha = 0);
|
|
4230
|
+
const {
|
|
4231
|
+
strokeOpacity = 1,
|
|
4232
|
+
opacity = 1
|
|
4233
|
+
} = character;
|
|
4234
|
+
ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
|
|
4235
|
+
}
|
|
4236
|
+
function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
|
|
4237
|
+
if (!width || width <= 0) return 0;
|
|
4238
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
4239
|
+
let index = guessIndex,
|
|
4240
|
+
temp = desc.slice(0, index),
|
|
4241
|
+
tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
|
|
4242
|
+
tempNext = desc.slice(0, index + 1),
|
|
4243
|
+
tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
4244
|
+
for (; tempWidth > width || tempWidthNext <= width;) {
|
|
4245
|
+
if (tempWidth > width ? index-- : index++, index > desc.length) {
|
|
4246
|
+
index = desc.length;
|
|
4247
|
+
break;
|
|
4248
|
+
}
|
|
4249
|
+
if (index < 0) {
|
|
4250
|
+
index = 0;
|
|
4251
|
+
break;
|
|
4252
|
+
}
|
|
4253
|
+
temp = desc.slice(0, index), tempWidth = Math.floor(textMeasure.measureText(temp, character).width), tempNext = desc.slice(0, index + 1), tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
4202
4254
|
}
|
|
4203
|
-
|
|
4204
|
-
|
|
4255
|
+
return needTestLetter && (index = testLetter(desc, index)), index;
|
|
4256
|
+
}
|
|
4257
|
+
function testLetter(string, index) {
|
|
4258
|
+
let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
4259
|
+
let i = index;
|
|
4260
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
|
|
4261
|
+
return i;
|
|
4262
|
+
}
|
|
4263
|
+
function testLetter2(string, index) {
|
|
4264
|
+
let i = index;
|
|
4265
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
4266
|
+
return i;
|
|
4267
|
+
}
|
|
4268
|
+
function measureTextCanvas(text, character) {
|
|
4269
|
+
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
4270
|
+
result = {
|
|
4271
|
+
ascent: 0,
|
|
4272
|
+
height: 0,
|
|
4273
|
+
descent: 0,
|
|
4274
|
+
width: 0
|
|
4275
|
+
};
|
|
4276
|
+
return "number" != typeof measurement.actualBoundingBoxAscent || "number" != typeof measurement.actualBoundingBoxDescent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent), result.ascent = Math.floor(measurement.actualBoundingBoxAscent), result.descent = result.height - result.ascent), result;
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
var __decorate$1G = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
4280
|
+
var d,
|
|
4281
|
+
c = arguments.length,
|
|
4282
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
4283
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4284
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4285
|
+
};
|
|
4286
|
+
let ATextMeasure = class {
|
|
4287
|
+
configure(service, env) {
|
|
4288
|
+
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4205
4289
|
}
|
|
4206
|
-
|
|
4207
|
-
|
|
4290
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
4291
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4292
|
+
const metrics = this.context.measureText(text);
|
|
4293
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4208
4294
|
}
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
4295
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
4296
|
+
this.context.setTextStyle(options);
|
|
4297
|
+
const metrics = this.context.measureText(text);
|
|
4298
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4214
4299
|
}
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
const
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
4223
|
-
return ellipse;
|
|
4224
|
-
}();
|
|
4225
|
-
if (radialType) radialType.at = matchAtPosition();else {
|
|
4226
|
-
const extent = matchExtentKeyword();
|
|
4227
|
-
if (extent) {
|
|
4228
|
-
radialType = extent;
|
|
4229
|
-
const positionAt = matchAtPosition();
|
|
4230
|
-
positionAt && (radialType.at = positionAt);
|
|
4231
|
-
} else {
|
|
4232
|
-
const defaultPosition = matchPositioning();
|
|
4233
|
-
defaultPosition && (radialType = {
|
|
4234
|
-
type: "default-radial",
|
|
4235
|
-
at: defaultPosition
|
|
4236
|
-
});
|
|
4237
|
-
}
|
|
4300
|
+
compatibleMetrics(metrics, options) {
|
|
4301
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
4302
|
+
const {
|
|
4303
|
+
ascent: ascent,
|
|
4304
|
+
descent: descent
|
|
4305
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
4306
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
4238
4307
|
}
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
if (match("position", /^at/, 0)) {
|
|
4246
|
-
const positioning = matchPositioning();
|
|
4247
|
-
return positioning || error("Missing positioning value"), positioning;
|
|
4308
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
4309
|
+
const {
|
|
4310
|
+
left: left,
|
|
4311
|
+
right: right
|
|
4312
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
4313
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
4248
4314
|
}
|
|
4315
|
+
return metrics;
|
|
4249
4316
|
}
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4317
|
+
estimate(text, _ref) {
|
|
4318
|
+
let {
|
|
4319
|
+
fontSize = DefaultTextAttribute.fontSize
|
|
4320
|
+
} = _ref;
|
|
4321
|
+
let eCharLen = 0,
|
|
4322
|
+
cCharLen = 0;
|
|
4323
|
+
for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
|
|
4324
|
+
return {
|
|
4325
|
+
width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
|
|
4326
|
+
height: fontSize
|
|
4258
4327
|
};
|
|
4259
4328
|
}
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
const result = [];
|
|
4263
|
-
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
4264
|
-
return result;
|
|
4329
|
+
measureTextWidth(text, options, textMeasure) {
|
|
4330
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4265
4331
|
}
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
4332
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
4333
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4269
4334
|
}
|
|
4270
|
-
|
|
4271
|
-
return
|
|
4335
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
4336
|
+
return this.context ? {
|
|
4337
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
4338
|
+
right: textMeasure.actualBoundingBoxRight
|
|
4339
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
4272
4340
|
}
|
|
4273
|
-
|
|
4274
|
-
|
|
4341
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
4342
|
+
var _a;
|
|
4343
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4275
4344
|
}
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
};
|
|
4345
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
4346
|
+
return this.context ? {
|
|
4347
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
4348
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
4349
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4282
4350
|
}
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
const captures = regexp.exec(input);
|
|
4287
|
-
return captures && consume(captures[0].length), captures;
|
|
4351
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
4352
|
+
var _a;
|
|
4353
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options, !0), Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent)) : null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4288
4354
|
}
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
};
|
|
4295
|
-
}();
|
|
4296
|
-
class GradientParser {
|
|
4297
|
-
static IsGradient(c) {
|
|
4298
|
-
return !("string" == typeof c && !c.includes("gradient"));
|
|
4355
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
4356
|
+
return this.context ? {
|
|
4357
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
4358
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
4359
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4299
4360
|
}
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
static Parse(c) {
|
|
4304
|
-
if (GradientParser.IsGradientStr(c)) try {
|
|
4305
|
-
const datum = parse(c)[0];
|
|
4306
|
-
if (datum) {
|
|
4307
|
-
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
4308
|
-
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
4309
|
-
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
4310
|
-
}
|
|
4311
|
-
} catch (err) {
|
|
4312
|
-
return c;
|
|
4313
|
-
}
|
|
4314
|
-
return c;
|
|
4315
|
-
}
|
|
4316
|
-
static ParseConic(datum) {
|
|
4317
|
-
const {
|
|
4318
|
-
orientation: orientation,
|
|
4319
|
-
colorStops = []
|
|
4320
|
-
} = datum,
|
|
4321
|
-
halfPi = pi / 2,
|
|
4322
|
-
sa = parseFloat(orientation.value) / 180 * pi - halfPi;
|
|
4361
|
+
measureTextBoundADscentEstimate(options) {
|
|
4362
|
+
var _a;
|
|
4363
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4323
4364
|
return {
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
y: .5,
|
|
4327
|
-
startAngle: sa,
|
|
4328
|
-
endAngle: sa + pi2,
|
|
4329
|
-
stops: colorStops.map(item => ({
|
|
4330
|
-
color: item.value,
|
|
4331
|
-
offset: parseFloat(item.length.value) / 100
|
|
4332
|
-
}))
|
|
4365
|
+
ascent: .79 * fontSize,
|
|
4366
|
+
descent: .21 * fontSize
|
|
4333
4367
|
};
|
|
4334
4368
|
}
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
}))
|
|
4369
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
4370
|
+
var _a;
|
|
4371
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
4372
|
+
{
|
|
4373
|
+
textAlign: textAlign
|
|
4374
|
+
} = options;
|
|
4375
|
+
return "center" === textAlign ? {
|
|
4376
|
+
left: fontSize / 2,
|
|
4377
|
+
right: fontSize / 2
|
|
4378
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
4379
|
+
left: fontSize,
|
|
4380
|
+
right: 0
|
|
4381
|
+
} : {
|
|
4382
|
+
left: 0,
|
|
4383
|
+
right: fontSize
|
|
4351
4384
|
};
|
|
4352
4385
|
}
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
let x0 = 0,
|
|
4363
|
-
y0 = 0,
|
|
4364
|
-
x1 = 0,
|
|
4365
|
-
y1 = 0;
|
|
4366
|
-
return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = y0 - Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
|
|
4367
|
-
gradient: "linear",
|
|
4368
|
-
x0: x0,
|
|
4369
|
-
y0: y0,
|
|
4370
|
-
x1: x1,
|
|
4371
|
-
y1: y1,
|
|
4372
|
-
stops: colorStops.map(item => ({
|
|
4373
|
-
color: item.value,
|
|
4374
|
-
offset: parseFloat(item.length.value) / 100
|
|
4375
|
-
}))
|
|
4386
|
+
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
4387
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4388
|
+
width: this.estimate(text, options).width
|
|
4389
|
+
});
|
|
4390
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
4391
|
+
if (mode === exports.MeasureModeEnum.actualBounding) return {
|
|
4392
|
+
ascent: out.actualBoundingBoxAscent,
|
|
4393
|
+
descent: out.actualBoundingBoxDescent,
|
|
4394
|
+
width: out.width
|
|
4376
4395
|
};
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
if (!c || !0 === c) return "black";
|
|
4396
|
-
let result, color;
|
|
4397
|
-
if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
4398
|
-
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
4399
|
-
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
4400
|
-
const bounds = params.AABBBounds;
|
|
4401
|
-
let w = bounds.x2 - bounds.x1,
|
|
4402
|
-
h = bounds.y2 - bounds.y1,
|
|
4403
|
-
x = bounds.x1 - offsetX,
|
|
4404
|
-
y = bounds.y1 - offsetY;
|
|
4405
|
-
if (params.attribute) {
|
|
4406
|
-
const {
|
|
4407
|
-
scaleX = 1,
|
|
4408
|
-
scaleY = 1
|
|
4409
|
-
} = params.attribute;
|
|
4410
|
-
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
4411
|
-
}
|
|
4412
|
-
"linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
|
|
4413
|
-
}
|
|
4414
|
-
return result || "orange";
|
|
4415
|
-
}
|
|
4416
|
-
function createLinearGradient(context, color, x, y, w, h) {
|
|
4417
|
-
var _a, _b, _c, _d;
|
|
4418
|
-
const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
|
|
4419
|
-
return color.stops.forEach(stop => {
|
|
4420
|
-
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4421
|
-
}), canvasGradient;
|
|
4422
|
-
}
|
|
4423
|
-
function createRadialGradient(context, color, x, y, w, h) {
|
|
4424
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4425
|
-
const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
|
|
4426
|
-
return color.stops.forEach(stop => {
|
|
4427
|
-
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4428
|
-
}), canvasGradient;
|
|
4429
|
-
}
|
|
4430
|
-
function createConicGradient(context, color, x, y, w, h) {
|
|
4431
|
-
var _a, _b;
|
|
4432
|
-
const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
|
|
4433
|
-
return color.stops.forEach(stop => {
|
|
4434
|
-
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4435
|
-
}), canvasGradient.GetPattern(w + x, h + y, undefined);
|
|
4436
|
-
}
|
|
4437
|
-
|
|
4438
|
-
const DIRECTION_KEY = {
|
|
4439
|
-
horizontal: {
|
|
4440
|
-
width: "width",
|
|
4441
|
-
height: "height",
|
|
4442
|
-
left: "left",
|
|
4443
|
-
top: "top",
|
|
4444
|
-
x: "x",
|
|
4445
|
-
y: "y",
|
|
4446
|
-
bottom: "bottom"
|
|
4447
|
-
},
|
|
4448
|
-
vertical: {
|
|
4449
|
-
width: "height",
|
|
4450
|
-
height: "width",
|
|
4451
|
-
left: "top",
|
|
4452
|
-
top: "left",
|
|
4453
|
-
x: "y",
|
|
4454
|
-
y: "x",
|
|
4455
|
-
bottom: "right"
|
|
4456
|
-
}
|
|
4457
|
-
};
|
|
4458
|
-
const defaultFormatting = {
|
|
4459
|
-
fontSize: 16,
|
|
4460
|
-
fontFamily: "sans-serif",
|
|
4461
|
-
fill: !0,
|
|
4462
|
-
stroke: !1,
|
|
4463
|
-
fontWeight: "normal",
|
|
4464
|
-
lineHeight: "normal",
|
|
4465
|
-
fontStyle: "normal",
|
|
4466
|
-
textDecoration: "none",
|
|
4467
|
-
textAlign: "left",
|
|
4468
|
-
script: "normal"
|
|
4469
|
-
};
|
|
4470
|
-
const regLetter = /\w|\(|\)|-/;
|
|
4471
|
-
const regPunctuation = /[.?!,;:/,。?!、;:]/;
|
|
4472
|
-
const regFirstSpace = /\S/;
|
|
4473
|
-
const setTextStyle = (ctx, character) => {
|
|
4474
|
-
let fontSize = character.fontSize || 16;
|
|
4475
|
-
switch (character.script) {
|
|
4476
|
-
case "super":
|
|
4477
|
-
case "sub":
|
|
4478
|
-
fontSize *= .8;
|
|
4479
|
-
}
|
|
4480
|
-
ctx.setTextStyle({
|
|
4481
|
-
textAlign: "left",
|
|
4482
|
-
textBaseline: character.textBaseline || "alphabetic",
|
|
4483
|
-
fontStyle: character.fontStyle || "",
|
|
4484
|
-
fontWeight: character.fontWeight || "",
|
|
4485
|
-
fontSize: fontSize,
|
|
4486
|
-
fontFamily: character.fontFamily || "sans-serif"
|
|
4487
|
-
});
|
|
4488
|
-
};
|
|
4489
|
-
function applyFillStyle(ctx, character, b) {
|
|
4490
|
-
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
4491
|
-
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
4492
|
-
const {
|
|
4493
|
-
fillOpacity = 1,
|
|
4494
|
-
opacity = 1
|
|
4495
|
-
} = character;
|
|
4496
|
-
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
|
|
4497
|
-
AABBBounds: b
|
|
4498
|
-
}) : fillStyle, setTextStyle(ctx, character);
|
|
4499
|
-
}
|
|
4500
|
-
function applyStrokeStyle(ctx, character) {
|
|
4501
|
-
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
4502
|
-
if (!strokeStyle) return void (ctx.globalAlpha = 0);
|
|
4503
|
-
const {
|
|
4504
|
-
strokeOpacity = 1,
|
|
4505
|
-
opacity = 1
|
|
4506
|
-
} = character;
|
|
4507
|
-
ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
|
|
4508
|
-
}
|
|
4509
|
-
function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
|
|
4510
|
-
if (!width || width <= 0) return 0;
|
|
4511
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
4512
|
-
let index = guessIndex,
|
|
4513
|
-
temp = desc.slice(0, index),
|
|
4514
|
-
tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
|
|
4515
|
-
tempNext = desc.slice(0, index + 1),
|
|
4516
|
-
tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
4517
|
-
for (; tempWidth > width || tempWidthNext <= width;) {
|
|
4518
|
-
if (tempWidth > width ? index-- : index++, index > desc.length) {
|
|
4519
|
-
index = desc.length;
|
|
4520
|
-
break;
|
|
4521
|
-
}
|
|
4522
|
-
if (index < 0) {
|
|
4523
|
-
index = 0;
|
|
4524
|
-
break;
|
|
4396
|
+
if (mode === exports.MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4397
|
+
width: out.width
|
|
4398
|
+
});
|
|
4399
|
+
if (mode === exports.MeasureModeEnum.fontBounding) {
|
|
4400
|
+
let ascent = out.fontBoundingBoxAscent,
|
|
4401
|
+
descent = out.fontBoundingBoxDescent;
|
|
4402
|
+
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
4403
|
+
const delta = out.actualBoundingBoxDescent - descent;
|
|
4404
|
+
descent += delta, ascent -= delta;
|
|
4405
|
+
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
4406
|
+
const delta = out.actualBoundingBoxAscent - ascent;
|
|
4407
|
+
ascent += delta, descent -= delta;
|
|
4408
|
+
}
|
|
4409
|
+
return {
|
|
4410
|
+
ascent: ascent,
|
|
4411
|
+
descent: descent,
|
|
4412
|
+
width: out.width
|
|
4413
|
+
};
|
|
4525
4414
|
}
|
|
4526
|
-
temp = desc.slice(0, index), tempWidth = Math.floor(textMeasure.measureText(temp, character).width), tempNext = desc.slice(0, index + 1), tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
4527
|
-
}
|
|
4528
|
-
return needTestLetter && (index = testLetter(desc, index)), index;
|
|
4529
|
-
}
|
|
4530
|
-
function testLetter(string, index) {
|
|
4531
|
-
let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
4532
|
-
let i = index;
|
|
4533
|
-
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
|
|
4534
|
-
return i;
|
|
4535
|
-
}
|
|
4536
|
-
function testLetter2(string, index) {
|
|
4537
|
-
let i = index;
|
|
4538
|
-
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
4539
|
-
return i;
|
|
4540
|
-
}
|
|
4541
|
-
function measureTextCanvas(text, character) {
|
|
4542
|
-
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
4543
|
-
result = {
|
|
4544
|
-
ascent: 0,
|
|
4545
|
-
height: 0,
|
|
4546
|
-
descent: 0,
|
|
4547
|
-
width: 0
|
|
4548
|
-
};
|
|
4549
|
-
return "number" != typeof measurement.actualBoundingBoxAscent || "number" != typeof measurement.actualBoundingBoxDescent ? (result.width = Math.floor(measurement.width), result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width), result.height = Math.floor(measurement.actualBoundingBoxAscent + measurement.actualBoundingBoxDescent), result.ascent = Math.floor(measurement.actualBoundingBoxAscent), result.descent = result.height - result.ascent), result;
|
|
4550
|
-
}
|
|
4551
|
-
|
|
4552
|
-
var __decorate$1G = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
4553
|
-
var d,
|
|
4554
|
-
c = arguments.length,
|
|
4555
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
4556
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4557
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4558
|
-
};
|
|
4559
|
-
let ATextMeasure = class {
|
|
4560
|
-
configure(service, env) {
|
|
4561
|
-
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4562
|
-
}
|
|
4563
|
-
measureTextWidth(text, options) {
|
|
4564
|
-
if (!this.context) return this.estimate(text, options).width;
|
|
4565
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4566
|
-
return this.context.measureText(text).width;
|
|
4567
|
-
}
|
|
4568
|
-
estimate(text, _ref) {
|
|
4569
|
-
let {
|
|
4570
|
-
fontSize = DefaultTextAttribute.fontSize
|
|
4571
|
-
} = _ref;
|
|
4572
|
-
let eCharLen = 0,
|
|
4573
|
-
cCharLen = 0;
|
|
4574
|
-
for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
|
|
4575
4415
|
return {
|
|
4576
|
-
|
|
4577
|
-
|
|
4416
|
+
ascent: out.actualBoundingBoxAscent,
|
|
4417
|
+
descent: out.actualBoundingBoxDescent,
|
|
4418
|
+
width: out.width
|
|
4578
4419
|
};
|
|
4579
4420
|
}
|
|
4580
|
-
measureTextPixelHeight(text, options) {
|
|
4581
|
-
var _a;
|
|
4582
|
-
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4583
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4584
|
-
const textMeasure = this.context.measureText(text);
|
|
4585
|
-
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
4586
|
-
}
|
|
4587
|
-
measureTextBoundHieght(text, options) {
|
|
4588
|
-
var _a;
|
|
4589
|
-
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4590
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4591
|
-
const textMeasure = this.context.measureText(text);
|
|
4592
|
-
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
4593
|
-
}
|
|
4594
4421
|
measureText(text, options) {
|
|
4595
4422
|
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
4596
4423
|
}
|
|
@@ -6701,7 +6528,7 @@
|
|
|
6701
6528
|
}
|
|
6702
6529
|
}
|
|
6703
6530
|
|
|
6704
|
-
class DefaultTicker {
|
|
6531
|
+
class DefaultTicker extends EventEmitter {
|
|
6705
6532
|
set mode(m) {
|
|
6706
6533
|
this._mode !== m && (this._mode = m, this.setupTickHandler());
|
|
6707
6534
|
}
|
|
@@ -6710,17 +6537,17 @@
|
|
|
6710
6537
|
}
|
|
6711
6538
|
constructor() {
|
|
6712
6539
|
let timelines = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
6713
|
-
this.handleTick = (handler, params) => {
|
|
6540
|
+
super(), this.handleTick = (handler, params) => {
|
|
6714
6541
|
const {
|
|
6715
6542
|
once = !1
|
|
6716
6543
|
} = null != params ? params : {};
|
|
6717
|
-
this.ifCanStop() ? this.stop() : (this._handlerTick(
|
|
6718
|
-
}, this._handlerTick =
|
|
6544
|
+
this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
|
|
6545
|
+
}, this._handlerTick = () => {
|
|
6719
6546
|
const time = this.tickerHandler.getTime();
|
|
6720
6547
|
let delta = 0;
|
|
6721
6548
|
this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
|
|
6722
6549
|
t.tick(delta);
|
|
6723
|
-
}));
|
|
6550
|
+
}), this.emit("afterTick"));
|
|
6724
6551
|
}, this.init(), this.lastFrameTime = -1, this.tickCounts = 0, this.timelines = timelines, this.autoStop = !0;
|
|
6725
6552
|
}
|
|
6726
6553
|
init() {
|
|
@@ -6816,6 +6643,9 @@
|
|
|
6816
6643
|
stop() {
|
|
6817
6644
|
this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
|
|
6818
6645
|
}
|
|
6646
|
+
trySyncTickStatus() {
|
|
6647
|
+
this.status === STATUS$1.RUNNING && this._handlerTick();
|
|
6648
|
+
}
|
|
6819
6649
|
}
|
|
6820
6650
|
|
|
6821
6651
|
class ManualTickHandler {
|
|
@@ -7957,7 +7787,7 @@
|
|
|
7957
7787
|
lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
7958
7788
|
break;
|
|
7959
7789
|
}
|
|
7960
|
-
"clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
|
|
7790
|
+
"clip" === this.newPointAnimateType && 0 !== this.toPoints.length && (Number.isFinite(lastMatchedIndex) ? (this.clipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.toPoints[this.toPoints.length - 1][this.clipRangeByDimension], 1 === this.clipRange && (this.shrinkClipRange = this.toPoints[lastMatchedIndex][this.clipRangeByDimension] / this.fromPoints[this.fromPoints.length - 1][this.clipRangeByDimension]), isValidNumber$1(this.clipRange) ? this.clipRange = clamp$1(this.clipRange, 0, 1) : this.clipRange = 0) : this.clipRange = 0);
|
|
7961
7791
|
let prevMatchedPoint = this.toPoints[0];
|
|
7962
7792
|
this.interpolatePoints = this.toPoints.map((point, index) => {
|
|
7963
7793
|
const matchedPoint = tagMap.get(point.context);
|
|
@@ -7969,11 +7799,19 @@
|
|
|
7969
7799
|
return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
|
|
7970
7800
|
});
|
|
7971
7801
|
}
|
|
7802
|
+
onFirstRun() {
|
|
7803
|
+
const lastClipRange = this.target.attribute.clipRange;
|
|
7804
|
+
isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
|
|
7805
|
+
}
|
|
7972
7806
|
onUpdate(end, ratio, out) {
|
|
7973
7807
|
if (this.points = this.points.map((point, index) => {
|
|
7974
7808
|
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
7975
7809
|
return newPoint.context = point.context, newPoint;
|
|
7976
|
-
}), this.clipRange
|
|
7810
|
+
}), this.clipRange) {
|
|
7811
|
+
if (this.shrinkClipRange) return void (end ? (out.points = this.toPoints, out.clipRange = 1) : (out.points = this.fromPoints, out.clipRange = this.clipRange - (this.clipRange - this.shrinkClipRange) * ratio));
|
|
7812
|
+
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
7813
|
+
}
|
|
7814
|
+
if (this.segmentsCache && this.to.segments) {
|
|
7977
7815
|
let start = 0;
|
|
7978
7816
|
out.segments = this.to.segments.map((segment, index) => {
|
|
7979
7817
|
const end = start + this.segmentsCache[index],
|
|
@@ -11552,266 +11390,555 @@
|
|
|
11552
11390
|
translate(m, m, [_anchor[0], _anchor[1], 0]), rotateZ(m, m, angle), translate(m, m, [-_anchor[0], -_anchor[1], 0]), multiplyMat4Mat4(out, out, m);
|
|
11553
11391
|
}
|
|
11554
11392
|
}
|
|
11555
|
-
function shouldUseMat4(graphic) {
|
|
11556
|
-
const {
|
|
11557
|
-
alpha: alpha,
|
|
11558
|
-
beta: beta
|
|
11559
|
-
} = graphic.attribute;
|
|
11560
|
-
return alpha || beta;
|
|
11561
|
-
}
|
|
11562
|
-
exports.DefaultGraphicService = class DefaultGraphicService {
|
|
11563
|
-
constructor(creator) {
|
|
11564
|
-
this.creator = creator, this.hooks = {
|
|
11565
|
-
onAttributeUpdate: new SyncHook(["graphic"]),
|
|
11566
|
-
onSetStage: new SyncHook(["graphic", "stage"]),
|
|
11567
|
-
onRemove: new SyncHook(["graphic"]),
|
|
11568
|
-
onRelease: new SyncHook(["graphic"]),
|
|
11569
|
-
onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11570
|
-
onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11571
|
-
beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
|
|
11572
|
-
afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11393
|
+
function shouldUseMat4(graphic) {
|
|
11394
|
+
const {
|
|
11395
|
+
alpha: alpha,
|
|
11396
|
+
beta: beta
|
|
11397
|
+
} = graphic.attribute;
|
|
11398
|
+
return alpha || beta;
|
|
11399
|
+
}
|
|
11400
|
+
exports.DefaultGraphicService = class DefaultGraphicService {
|
|
11401
|
+
constructor(creator) {
|
|
11402
|
+
this.creator = creator, this.hooks = {
|
|
11403
|
+
onAttributeUpdate: new SyncHook(["graphic"]),
|
|
11404
|
+
onSetStage: new SyncHook(["graphic", "stage"]),
|
|
11405
|
+
onRemove: new SyncHook(["graphic"]),
|
|
11406
|
+
onRelease: new SyncHook(["graphic"]),
|
|
11407
|
+
onAddIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11408
|
+
onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
|
|
11409
|
+
beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
|
|
11410
|
+
afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"]),
|
|
11411
|
+
clearAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds"])
|
|
11412
|
+
}, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds();
|
|
11413
|
+
}
|
|
11414
|
+
onAttributeUpdate(graphic) {
|
|
11415
|
+
this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
|
|
11416
|
+
}
|
|
11417
|
+
onSetStage(graphic, stage) {
|
|
11418
|
+
this.hooks.onSetStage.taps.length && this.hooks.onSetStage.call(graphic, stage);
|
|
11419
|
+
}
|
|
11420
|
+
onRemove(graphic) {
|
|
11421
|
+
this.hooks.onRemove.taps.length && this.hooks.onRemove.call(graphic);
|
|
11422
|
+
}
|
|
11423
|
+
onRelease(graphic) {
|
|
11424
|
+
this.hooks.onRelease.taps.length && this.hooks.onRelease.call(graphic);
|
|
11425
|
+
}
|
|
11426
|
+
onAddIncremental(graphic, group, stage) {
|
|
11427
|
+
this.hooks.onAddIncremental.taps.length && this.hooks.onAddIncremental.call(graphic, group, stage);
|
|
11428
|
+
}
|
|
11429
|
+
onClearIncremental(group, stage) {
|
|
11430
|
+
this.hooks.onClearIncremental.taps.length && this.hooks.onClearIncremental.call(group, stage);
|
|
11431
|
+
}
|
|
11432
|
+
beforeUpdateAABBBounds(graphic, stage, willUpdate, bounds) {
|
|
11433
|
+
this.hooks.beforeUpdateAABBBounds.taps.length && this.hooks.beforeUpdateAABBBounds.call(graphic, stage, willUpdate, bounds);
|
|
11434
|
+
}
|
|
11435
|
+
afterUpdateAABBBounds(graphic, stage, bounds, params, selfChange) {
|
|
11436
|
+
this.hooks.afterUpdateAABBBounds.taps.length && this.hooks.afterUpdateAABBBounds.call(graphic, stage, bounds, params, selfChange);
|
|
11437
|
+
}
|
|
11438
|
+
clearAABBBounds(graphic, stage, b) {
|
|
11439
|
+
this.hooks.clearAABBBounds.taps.length && this.hooks.clearAABBBounds.call(graphic, stage, b);
|
|
11440
|
+
}
|
|
11441
|
+
updatePathProxyAABBBounds(aabbBounds, graphic) {
|
|
11442
|
+
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
11443
|
+
if (!path) return !1;
|
|
11444
|
+
const boundsContext = new BoundsContext(aabbBounds);
|
|
11445
|
+
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
11446
|
+
}
|
|
11447
|
+
updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
|
|
11448
|
+
const {
|
|
11449
|
+
textAlign: textAlign,
|
|
11450
|
+
textBaseline: textBaseline
|
|
11451
|
+
} = attribute;
|
|
11452
|
+
if (null != attribute.forceBoundsHeight) {
|
|
11453
|
+
const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
11454
|
+
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
11455
|
+
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
11456
|
+
}
|
|
11457
|
+
if (null != attribute.forceBoundsWidth) {
|
|
11458
|
+
const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
11459
|
+
dx = textDrawOffsetX(textAlign, w);
|
|
11460
|
+
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
11461
|
+
}
|
|
11462
|
+
}
|
|
11463
|
+
combindShadowAABBBounds(bounds, graphic) {
|
|
11464
|
+
if (graphic && graphic.shadowRoot) {
|
|
11465
|
+
const b = graphic.shadowRoot.AABBBounds;
|
|
11466
|
+
bounds.union(b);
|
|
11467
|
+
}
|
|
11468
|
+
}
|
|
11469
|
+
transformAABBBounds(attribute, aabbBounds, theme, miter, graphic) {
|
|
11470
|
+
if (!aabbBounds.empty()) {
|
|
11471
|
+
const {
|
|
11472
|
+
scaleX = theme.scaleX,
|
|
11473
|
+
scaleY = theme.scaleY,
|
|
11474
|
+
stroke = theme.stroke,
|
|
11475
|
+
shadowBlur = theme.shadowBlur,
|
|
11476
|
+
lineWidth = theme.lineWidth,
|
|
11477
|
+
pickStrokeBuffer = theme.pickStrokeBuffer,
|
|
11478
|
+
strokeBoundsBuffer = theme.strokeBoundsBuffer
|
|
11479
|
+
} = attribute,
|
|
11480
|
+
tb1 = this.tempAABBBounds1,
|
|
11481
|
+
tb2 = this.tempAABBBounds2;
|
|
11482
|
+
if (stroke && lineWidth) {
|
|
11483
|
+
const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
|
|
11484
|
+
boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
11485
|
+
}
|
|
11486
|
+
if (shadowBlur) {
|
|
11487
|
+
const {
|
|
11488
|
+
shadowOffsetX = theme.shadowOffsetX,
|
|
11489
|
+
shadowOffsetY = theme.shadowOffsetY
|
|
11490
|
+
} = attribute,
|
|
11491
|
+
shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
|
|
11492
|
+
boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
|
|
11493
|
+
}
|
|
11494
|
+
}
|
|
11495
|
+
if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
|
|
11496
|
+
let updateMatrix = !0;
|
|
11497
|
+
const m = graphic.transMatrix;
|
|
11498
|
+
graphic && graphic.isContainer && (updateMatrix = !(1 === m.a && 0 === m.b && 0 === m.c && 1 === m.d && 0 === m.e && 0 === m.f)), updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);
|
|
11499
|
+
}
|
|
11500
|
+
validCheck(attribute, theme, aabbBounds, graphic) {
|
|
11501
|
+
if (!graphic) return !0;
|
|
11502
|
+
if (null != attribute.forceBoundsHeight || null != attribute.forceBoundsWidth) return !0;
|
|
11503
|
+
if (graphic.shadowRoot || graphic.isContainer) return !0;
|
|
11504
|
+
const {
|
|
11505
|
+
visible = theme.visible
|
|
11506
|
+
} = attribute;
|
|
11507
|
+
return !(!graphic.valid || !visible) || (aabbBounds.empty() || (graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix), application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds), aabbBounds.clear()), !1);
|
|
11508
|
+
}
|
|
11509
|
+
updateTempAABBBounds(aabbBounds) {
|
|
11510
|
+
const tb1 = this.tempAABBBounds1,
|
|
11511
|
+
tb2 = this.tempAABBBounds2;
|
|
11512
|
+
return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), {
|
|
11513
|
+
tb1: tb1,
|
|
11514
|
+
tb2: tb2
|
|
11515
|
+
};
|
|
11516
|
+
}
|
|
11517
|
+
};
|
|
11518
|
+
exports.DefaultGraphicService = __decorate$1B([injectable(), __param$R(0, inject(GraphicCreator$1)), __metadata$1d("design:paramtypes", [Object])], exports.DefaultGraphicService);
|
|
11519
|
+
|
|
11520
|
+
const result = {
|
|
11521
|
+
x: 0,
|
|
11522
|
+
y: 0,
|
|
11523
|
+
z: 0,
|
|
11524
|
+
lastModelMatrix: null
|
|
11525
|
+
};
|
|
11526
|
+
class BaseRender {
|
|
11527
|
+
init(contributions) {
|
|
11528
|
+
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
|
|
11529
|
+
}
|
|
11530
|
+
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
11531
|
+
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
11532
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
11533
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
11534
|
+
}
|
|
11535
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11536
|
+
});
|
|
11537
|
+
}
|
|
11538
|
+
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
11539
|
+
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
11540
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
11541
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
11542
|
+
}
|
|
11543
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
11544
|
+
});
|
|
11545
|
+
}
|
|
11546
|
+
valid(graphic, defaultAttribute, fillCb, strokeCb) {
|
|
11547
|
+
const {
|
|
11548
|
+
fill = defaultAttribute.fill,
|
|
11549
|
+
background: background,
|
|
11550
|
+
stroke = defaultAttribute.stroke,
|
|
11551
|
+
opacity = defaultAttribute.opacity,
|
|
11552
|
+
fillOpacity = defaultAttribute.fillOpacity,
|
|
11553
|
+
lineWidth = defaultAttribute.lineWidth,
|
|
11554
|
+
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
11555
|
+
visible = defaultAttribute.visible
|
|
11556
|
+
} = graphic.attribute,
|
|
11557
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
11558
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
11559
|
+
doFill = runFill(fill, background),
|
|
11560
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
11561
|
+
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
11562
|
+
fVisible: fVisible,
|
|
11563
|
+
sVisible: sVisible,
|
|
11564
|
+
doFill: doFill,
|
|
11565
|
+
doStroke: doStroke
|
|
11566
|
+
};
|
|
11567
|
+
}
|
|
11568
|
+
transform(graphic, graphicAttribute, context) {
|
|
11569
|
+
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
11570
|
+
const {
|
|
11571
|
+
x = graphicAttribute.x,
|
|
11572
|
+
y = graphicAttribute.y,
|
|
11573
|
+
z = graphicAttribute.z,
|
|
11574
|
+
scaleX = graphicAttribute.scaleX,
|
|
11575
|
+
scaleY = graphicAttribute.scaleY,
|
|
11576
|
+
angle = graphicAttribute.angle,
|
|
11577
|
+
postMatrix: postMatrix
|
|
11578
|
+
} = graphic.attribute,
|
|
11579
|
+
lastModelMatrix = context.modelMatrix,
|
|
11580
|
+
camera = context.camera;
|
|
11581
|
+
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
11582
|
+
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
11583
|
+
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
11584
|
+
if (shouldTransform3d) {
|
|
11585
|
+
const nextModelMatrix = mat4Allocate.allocate(),
|
|
11586
|
+
modelMatrix = mat4Allocate.allocate();
|
|
11587
|
+
getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
|
|
11588
|
+
}
|
|
11589
|
+
if (onlyTranslate && !lastModelMatrix) {
|
|
11590
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11591
|
+
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
11592
|
+
} else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
|
|
11593
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11594
|
+
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
11595
|
+
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
11596
|
+
return result;
|
|
11597
|
+
}
|
|
11598
|
+
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11599
|
+
const camera = context.camera;
|
|
11600
|
+
if (this.camera = camera, camera) {
|
|
11601
|
+
const bounds = graphic.AABBBounds,
|
|
11602
|
+
width = bounds.x2 - bounds.x1,
|
|
11603
|
+
height = bounds.y2 - bounds.y1,
|
|
11604
|
+
p1 = context.project(0, 0, z),
|
|
11605
|
+
p2 = context.project(width, 0, z),
|
|
11606
|
+
p3 = context.project(width, height, z),
|
|
11607
|
+
_p1 = {
|
|
11608
|
+
x: 0,
|
|
11609
|
+
y: 0
|
|
11610
|
+
},
|
|
11611
|
+
_p2 = {
|
|
11612
|
+
x: width,
|
|
11613
|
+
y: 0
|
|
11614
|
+
},
|
|
11615
|
+
_p3 = {
|
|
11616
|
+
x: width,
|
|
11617
|
+
y: height
|
|
11618
|
+
};
|
|
11619
|
+
context.camera = null;
|
|
11620
|
+
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
11621
|
+
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
11622
|
+
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
11623
|
+
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
11624
|
+
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
11625
|
+
dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
|
|
11626
|
+
dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
|
|
11627
|
+
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
11628
|
+
}
|
|
11629
|
+
}
|
|
11630
|
+
restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11631
|
+
this.camera && (context.camera = this.camera);
|
|
11632
|
+
}
|
|
11633
|
+
transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
|
|
11634
|
+
const p = context.project(x, y, z);
|
|
11635
|
+
context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
|
|
11636
|
+
}
|
|
11637
|
+
_draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
|
|
11638
|
+
const {
|
|
11639
|
+
context: context
|
|
11640
|
+
} = drawContext;
|
|
11641
|
+
if (!context) return;
|
|
11642
|
+
const {
|
|
11643
|
+
renderable: renderable
|
|
11644
|
+
} = graphic.attribute;
|
|
11645
|
+
if (!1 === renderable) return;
|
|
11646
|
+
context.highPerformanceSave();
|
|
11647
|
+
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
11648
|
+
{
|
|
11649
|
+
x: x,
|
|
11650
|
+
y: y,
|
|
11651
|
+
z: z,
|
|
11652
|
+
lastModelMatrix: lastModelMatrix
|
|
11653
|
+
} = data;
|
|
11654
|
+
this.z = z, drawPathProxy(graphic, context, x, y, drawContext, params) || (this.drawShape(graphic, context, x, y, drawContext, params), this.z = 0, context.modelMatrix !== lastModelMatrix && mat4Allocate.free(context.modelMatrix), context.modelMatrix = lastModelMatrix), context.highPerformanceRestore();
|
|
11655
|
+
}
|
|
11656
|
+
}
|
|
11657
|
+
|
|
11658
|
+
const parse = function () {
|
|
11659
|
+
const tokens = {
|
|
11660
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
11661
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
11662
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
11663
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
11664
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
11665
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
11666
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
11667
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
11668
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
11669
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
11670
|
+
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
11671
|
+
startCall: /^\(/,
|
|
11672
|
+
endCall: /^\)/,
|
|
11673
|
+
comma: /^,/,
|
|
11674
|
+
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
11675
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
11676
|
+
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
11677
|
+
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
11678
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
11679
|
+
};
|
|
11680
|
+
let input = "";
|
|
11681
|
+
function error(msg) {
|
|
11682
|
+
const err = new Error(input + ": " + msg);
|
|
11683
|
+
throw err.source = input, err;
|
|
11577
11684
|
}
|
|
11578
|
-
|
|
11579
|
-
|
|
11685
|
+
function getAST() {
|
|
11686
|
+
const ast = matchListing(matchDefinition);
|
|
11687
|
+
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
11580
11688
|
}
|
|
11581
|
-
|
|
11582
|
-
|
|
11689
|
+
function matchDefinition() {
|
|
11690
|
+
return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
|
|
11583
11691
|
}
|
|
11584
|
-
|
|
11585
|
-
|
|
11692
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
11693
|
+
return function (pattern, callback) {
|
|
11694
|
+
const captures = scan(pattern);
|
|
11695
|
+
if (captures) {
|
|
11696
|
+
scan(tokens.startCall) || error("Missing (");
|
|
11697
|
+
const result = callback(captures);
|
|
11698
|
+
return scan(tokens.endCall) || error("Missing )"), result;
|
|
11699
|
+
}
|
|
11700
|
+
}(pattern, function (captures) {
|
|
11701
|
+
const orientation = orientationMatcher();
|
|
11702
|
+
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
|
|
11703
|
+
type: gradientType,
|
|
11704
|
+
orientation: orientation,
|
|
11705
|
+
colorStops: matchListing(matchColorStop)
|
|
11706
|
+
};
|
|
11707
|
+
});
|
|
11586
11708
|
}
|
|
11587
|
-
|
|
11588
|
-
|
|
11709
|
+
function matchLinearOrientation() {
|
|
11710
|
+
return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
|
|
11589
11711
|
}
|
|
11590
|
-
|
|
11591
|
-
|
|
11712
|
+
function matchConicalOrientation() {
|
|
11713
|
+
return match("angular", tokens.fromAngleValue, 1);
|
|
11592
11714
|
}
|
|
11593
|
-
|
|
11594
|
-
|
|
11715
|
+
function matchListRadialOrientations() {
|
|
11716
|
+
let radialOrientations,
|
|
11717
|
+
lookaheadCache,
|
|
11718
|
+
radialOrientation = matchRadialOrientation();
|
|
11719
|
+
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
11595
11720
|
}
|
|
11596
|
-
|
|
11597
|
-
|
|
11721
|
+
function matchRadialOrientation() {
|
|
11722
|
+
let radialType = function () {
|
|
11723
|
+
const circle = match("shape", /^(circle)/i, 0);
|
|
11724
|
+
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
11725
|
+
return circle;
|
|
11726
|
+
}() || function () {
|
|
11727
|
+
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
11728
|
+
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
11729
|
+
return ellipse;
|
|
11730
|
+
}();
|
|
11731
|
+
if (radialType) radialType.at = matchAtPosition();else {
|
|
11732
|
+
const extent = matchExtentKeyword();
|
|
11733
|
+
if (extent) {
|
|
11734
|
+
radialType = extent;
|
|
11735
|
+
const positionAt = matchAtPosition();
|
|
11736
|
+
positionAt && (radialType.at = positionAt);
|
|
11737
|
+
} else {
|
|
11738
|
+
const defaultPosition = matchPositioning();
|
|
11739
|
+
defaultPosition && (radialType = {
|
|
11740
|
+
type: "default-radial",
|
|
11741
|
+
at: defaultPosition
|
|
11742
|
+
});
|
|
11743
|
+
}
|
|
11744
|
+
}
|
|
11745
|
+
return radialType;
|
|
11598
11746
|
}
|
|
11599
|
-
|
|
11600
|
-
|
|
11601
|
-
if (!path) return !1;
|
|
11602
|
-
const boundsContext = new BoundsContext(aabbBounds);
|
|
11603
|
-
return renderCommandList(path.commandList, boundsContext, 0, 0), !0;
|
|
11747
|
+
function matchExtentKeyword() {
|
|
11748
|
+
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
11604
11749
|
}
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
} = attribute;
|
|
11610
|
-
if (null != attribute.forceBoundsHeight) {
|
|
11611
|
-
const h = isNumber$1(attribute.forceBoundsHeight) ? attribute.forceBoundsHeight : attribute.forceBoundsHeight(),
|
|
11612
|
-
dy = textLayoutOffsetY(textBaseline, h, h);
|
|
11613
|
-
aabbBounds.set(aabbBounds.x1, dy, aabbBounds.x2, dy + h);
|
|
11614
|
-
}
|
|
11615
|
-
if (null != attribute.forceBoundsWidth) {
|
|
11616
|
-
const w = isNumber$1(attribute.forceBoundsWidth) ? attribute.forceBoundsWidth : attribute.forceBoundsWidth(),
|
|
11617
|
-
dx = textDrawOffsetX(textAlign, w);
|
|
11618
|
-
aabbBounds.set(dx, aabbBounds.y1, dx + w, aabbBounds.y2);
|
|
11750
|
+
function matchAtPosition() {
|
|
11751
|
+
if (match("position", /^at/, 0)) {
|
|
11752
|
+
const positioning = matchPositioning();
|
|
11753
|
+
return positioning || error("Missing positioning value"), positioning;
|
|
11619
11754
|
}
|
|
11620
11755
|
}
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
}
|
|
11756
|
+
function matchPositioning() {
|
|
11757
|
+
const location = {
|
|
11758
|
+
x: matchDistance(),
|
|
11759
|
+
y: matchDistance()
|
|
11760
|
+
};
|
|
11761
|
+
if (location.x || location.y) return {
|
|
11762
|
+
type: "position",
|
|
11763
|
+
value: location
|
|
11764
|
+
};
|
|
11626
11765
|
}
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
stroke = theme.stroke,
|
|
11633
|
-
shadowBlur = theme.shadowBlur,
|
|
11634
|
-
lineWidth = theme.lineWidth,
|
|
11635
|
-
pickStrokeBuffer = theme.pickStrokeBuffer,
|
|
11636
|
-
strokeBoundsBuffer = theme.strokeBoundsBuffer
|
|
11637
|
-
} = attribute,
|
|
11638
|
-
tb1 = this.tempAABBBounds1,
|
|
11639
|
-
tb2 = this.tempAABBBounds2;
|
|
11640
|
-
if (stroke && lineWidth) {
|
|
11641
|
-
const scaledHalfLineWidth = (lineWidth + pickStrokeBuffer) / Math.abs(scaleX + scaleY);
|
|
11642
|
-
boundStroke(tb1, scaledHalfLineWidth, miter, strokeBoundsBuffer), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
11643
|
-
}
|
|
11644
|
-
if (shadowBlur) {
|
|
11645
|
-
const {
|
|
11646
|
-
shadowOffsetX = theme.shadowOffsetX,
|
|
11647
|
-
shadowOffsetY = theme.shadowOffsetY
|
|
11648
|
-
} = attribute,
|
|
11649
|
-
shadowBlurWidth = shadowBlur / Math.abs(scaleX + scaleY) * 2;
|
|
11650
|
-
boundStroke(tb1, shadowBlurWidth, !1, strokeBoundsBuffer + 1), tb1.translate(shadowOffsetX, shadowOffsetY), aabbBounds.union(tb1);
|
|
11651
|
-
}
|
|
11652
|
-
}
|
|
11653
|
-
if (this.combindShadowAABBBounds(aabbBounds, graphic), aabbBounds.empty()) return;
|
|
11654
|
-
let updateMatrix = !0;
|
|
11655
|
-
const m = graphic.transMatrix;
|
|
11656
|
-
graphic && graphic.isContainer && (updateMatrix = !(1 === m.a && 0 === m.b && 0 === m.c && 1 === m.d && 0 === m.e && 0 === m.f)), updateMatrix && transformBoundsWithMatrix(aabbBounds, aabbBounds, m);
|
|
11766
|
+
function matchListing(matcher) {
|
|
11767
|
+
let captures = matcher();
|
|
11768
|
+
const result = [];
|
|
11769
|
+
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
11770
|
+
return result;
|
|
11657
11771
|
}
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
if (graphic.shadowRoot) return !0;
|
|
11662
|
-
if (!graphic.valid) return aabbBounds.clear(), !1;
|
|
11663
|
-
const {
|
|
11664
|
-
visible = theme.visible
|
|
11665
|
-
} = attribute;
|
|
11666
|
-
return !!visible || (aabbBounds.clear(), !1);
|
|
11772
|
+
function matchColorStop() {
|
|
11773
|
+
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
11774
|
+
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
11667
11775
|
}
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11776
|
+
function matchDistance() {
|
|
11777
|
+
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
11778
|
+
}
|
|
11779
|
+
function matchLength() {
|
|
11780
|
+
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
11781
|
+
}
|
|
11782
|
+
function match(type, pattern, captureIndex) {
|
|
11783
|
+
const captures = scan(pattern);
|
|
11784
|
+
if (captures) return {
|
|
11785
|
+
type: type,
|
|
11786
|
+
value: captures[captureIndex]
|
|
11674
11787
|
};
|
|
11675
11788
|
}
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
y: 0,
|
|
11682
|
-
z: 0,
|
|
11683
|
-
lastModelMatrix: null
|
|
11684
|
-
};
|
|
11685
|
-
class BaseRender {
|
|
11686
|
-
init(contributions) {
|
|
11687
|
-
contributions && (this._renderContribitions = contributions.getContributions()), this._renderContribitions || (this._renderContribitions = []), this.builtinContributions && this.builtinContributions.forEach(item => this._renderContribitions.push(item)), this._renderContribitions.length && (this._renderContribitions.sort((a, b) => b.order - a.order), this._beforeRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === exports.BaseRenderContributionTime.afterFillStroke));
|
|
11789
|
+
function scan(regexp) {
|
|
11790
|
+
const blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
11791
|
+
blankCaptures && consume(blankCaptures[0].length);
|
|
11792
|
+
const captures = regexp.exec(input);
|
|
11793
|
+
return captures && consume(captures[0].length), captures;
|
|
11688
11794
|
}
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11795
|
+
function consume(size) {
|
|
11796
|
+
input = input.substr(size);
|
|
11797
|
+
}
|
|
11798
|
+
return function (code) {
|
|
11799
|
+
return input = code.toString(), getAST();
|
|
11800
|
+
};
|
|
11801
|
+
}();
|
|
11802
|
+
class GradientParser {
|
|
11803
|
+
static IsGradient(c) {
|
|
11804
|
+
return !("string" == typeof c && !c.includes("gradient"));
|
|
11805
|
+
}
|
|
11806
|
+
static IsGradientStr(c) {
|
|
11807
|
+
return "string" == typeof c && c.includes("gradient");
|
|
11696
11808
|
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11809
|
+
static Parse(c) {
|
|
11810
|
+
if (GradientParser.IsGradientStr(c)) try {
|
|
11811
|
+
const datum = parse(c)[0];
|
|
11812
|
+
if (datum) {
|
|
11813
|
+
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
11814
|
+
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
11815
|
+
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
11701
11816
|
}
|
|
11702
|
-
|
|
11703
|
-
|
|
11817
|
+
} catch (err) {
|
|
11818
|
+
return c;
|
|
11819
|
+
}
|
|
11820
|
+
return c;
|
|
11704
11821
|
}
|
|
11705
|
-
|
|
11822
|
+
static ParseConic(datum) {
|
|
11706
11823
|
const {
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
sVisible: sVisible,
|
|
11723
|
-
doFill: doFill,
|
|
11724
|
-
doStroke: doStroke
|
|
11824
|
+
orientation: orientation,
|
|
11825
|
+
colorStops = []
|
|
11826
|
+
} = datum,
|
|
11827
|
+
halfPi = pi / 2,
|
|
11828
|
+
sa = parseFloat(orientation.value) / 180 * pi - halfPi;
|
|
11829
|
+
return {
|
|
11830
|
+
gradient: "conical",
|
|
11831
|
+
x: .5,
|
|
11832
|
+
y: .5,
|
|
11833
|
+
startAngle: sa,
|
|
11834
|
+
endAngle: sa + pi2,
|
|
11835
|
+
stops: colorStops.map(item => ({
|
|
11836
|
+
color: item.value,
|
|
11837
|
+
offset: parseFloat(item.length.value) / 100
|
|
11838
|
+
}))
|
|
11725
11839
|
};
|
|
11726
11840
|
}
|
|
11727
|
-
|
|
11728
|
-
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
11841
|
+
static ParseRadial(datum) {
|
|
11729
11842
|
const {
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
modelMatrix = mat4Allocate.allocate();
|
|
11746
|
-
getModelMatrix(modelMatrix, graphic, graphicAttribute), multiplyMat4Mat4(nextModelMatrix, lastModelMatrix || nextModelMatrix, modelMatrix), result.x = 0, result.y = 0, result.z = 0, context.modelMatrix = nextModelMatrix, context.setTransform(1, 0, 0, 1, 0, 0, !0), mat4Allocate.free(modelMatrix);
|
|
11747
|
-
}
|
|
11748
|
-
if (onlyTranslate && !lastModelMatrix) {
|
|
11749
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11750
|
-
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
11751
|
-
} else if (shouldTransform3d) result.x = 0, result.y = 0, result.z = 0, context.setTransform(1, 0, 0, 1, 0, 0, !0);else if (camera && context.project) {
|
|
11752
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
11753
|
-
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
11754
|
-
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
11755
|
-
return result;
|
|
11756
|
-
}
|
|
11757
|
-
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11758
|
-
const camera = context.camera;
|
|
11759
|
-
if (this.camera = camera, camera) {
|
|
11760
|
-
const bounds = graphic.AABBBounds,
|
|
11761
|
-
width = bounds.x2 - bounds.x1,
|
|
11762
|
-
height = bounds.y2 - bounds.y1,
|
|
11763
|
-
p1 = context.project(0, 0, z),
|
|
11764
|
-
p2 = context.project(width, 0, z),
|
|
11765
|
-
p3 = context.project(width, height, z),
|
|
11766
|
-
_p1 = {
|
|
11767
|
-
x: 0,
|
|
11768
|
-
y: 0
|
|
11769
|
-
},
|
|
11770
|
-
_p2 = {
|
|
11771
|
-
x: width,
|
|
11772
|
-
y: 0
|
|
11773
|
-
},
|
|
11774
|
-
_p3 = {
|
|
11775
|
-
x: width,
|
|
11776
|
-
y: height
|
|
11777
|
-
};
|
|
11778
|
-
context.camera = null;
|
|
11779
|
-
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
11780
|
-
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
11781
|
-
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
11782
|
-
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
11783
|
-
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
11784
|
-
dx = (_p1.x * (_p3.y * p2.x - _p2.y * p3.x) + _p1.y * (_p2.x * p3.x - _p3.x * p2.x) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.x) * denom,
|
|
11785
|
-
dy = (_p1.x * (_p3.y * p2.y - _p2.y * p3.y) + _p1.y * (_p2.x * p3.y - _p3.x * p2.y) + (_p3.x * _p2.y - _p2.x * _p3.y) * p1.y) * denom;
|
|
11786
|
-
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
11787
|
-
}
|
|
11788
|
-
}
|
|
11789
|
-
restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
11790
|
-
this.camera && (context.camera = this.camera);
|
|
11791
|
-
}
|
|
11792
|
-
transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
|
|
11793
|
-
const p = context.project(x, y, z);
|
|
11794
|
-
context.translate(p.x, p.y, !1), context.scale(scaleX, scaleY, !1), context.rotate(angle, !1), context.translate(-p.x, -p.y, !1), context.setTransformForCurrent();
|
|
11843
|
+
colorStops = []
|
|
11844
|
+
} = datum;
|
|
11845
|
+
return {
|
|
11846
|
+
gradient: "radial",
|
|
11847
|
+
x0: .5,
|
|
11848
|
+
y0: .5,
|
|
11849
|
+
x1: .5,
|
|
11850
|
+
y1: .5,
|
|
11851
|
+
r0: 0,
|
|
11852
|
+
r1: 1,
|
|
11853
|
+
stops: colorStops.map(item => ({
|
|
11854
|
+
color: item.value,
|
|
11855
|
+
offset: parseFloat(item.length.value) / 100
|
|
11856
|
+
}))
|
|
11857
|
+
};
|
|
11795
11858
|
}
|
|
11796
|
-
|
|
11797
|
-
const {
|
|
11798
|
-
context: context
|
|
11799
|
-
} = drawContext;
|
|
11800
|
-
if (!context) return;
|
|
11859
|
+
static ParseLinear(datum) {
|
|
11801
11860
|
const {
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
|
|
11861
|
+
orientation: orientation,
|
|
11862
|
+
colorStops = []
|
|
11863
|
+
} = datum,
|
|
11864
|
+
halfPi = pi / 2;
|
|
11865
|
+
let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
|
|
11866
|
+
for (; angle < 0;) angle += pi2;
|
|
11867
|
+
for (; angle > pi2;) angle -= pi2;
|
|
11868
|
+
let x0 = 0,
|
|
11869
|
+
y0 = 0,
|
|
11870
|
+
x1 = 0,
|
|
11871
|
+
y1 = 0;
|
|
11872
|
+
return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
|
|
11873
|
+
gradient: "linear",
|
|
11874
|
+
x0: x0,
|
|
11875
|
+
y0: y0,
|
|
11876
|
+
x1: x1,
|
|
11877
|
+
y1: y1,
|
|
11878
|
+
stops: colorStops.map(item => ({
|
|
11879
|
+
color: item.value,
|
|
11880
|
+
offset: parseFloat(item.length.value) / 100
|
|
11881
|
+
}))
|
|
11882
|
+
};
|
|
11883
|
+
}
|
|
11884
|
+
}
|
|
11885
|
+
|
|
11886
|
+
function getScaledStroke(context, width, dpr) {
|
|
11887
|
+
let strokeWidth = width;
|
|
11888
|
+
const {
|
|
11889
|
+
a: a,
|
|
11890
|
+
b: b,
|
|
11891
|
+
c: c,
|
|
11892
|
+
d: d
|
|
11893
|
+
} = context.currentMatrix,
|
|
11894
|
+
scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
|
|
11895
|
+
scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
11896
|
+
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
|
|
11897
|
+
}
|
|
11898
|
+
function createColor(context, c, params) {
|
|
11899
|
+
let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
11900
|
+
let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
11901
|
+
if (!c || !0 === c) return "black";
|
|
11902
|
+
let result, color;
|
|
11903
|
+
if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
11904
|
+
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
11905
|
+
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
11906
|
+
const bounds = params.AABBBounds;
|
|
11907
|
+
let w = bounds.x2 - bounds.x1,
|
|
11908
|
+
h = bounds.y2 - bounds.y1,
|
|
11909
|
+
x = bounds.x1 - offsetX,
|
|
11910
|
+
y = bounds.y1 - offsetY;
|
|
11911
|
+
if (params.attribute) {
|
|
11912
|
+
const {
|
|
11913
|
+
scaleX = 1,
|
|
11914
|
+
scaleY = 1
|
|
11915
|
+
} = params.attribute;
|
|
11916
|
+
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
11917
|
+
}
|
|
11918
|
+
"linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
|
|
11814
11919
|
}
|
|
11920
|
+
return result || "orange";
|
|
11921
|
+
}
|
|
11922
|
+
function createLinearGradient(context, color, x, y, w, h) {
|
|
11923
|
+
var _a, _b, _c, _d;
|
|
11924
|
+
const canvasGradient = context.createLinearGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : 0) * h, x + (null !== (_c = color.x1) && void 0 !== _c ? _c : 1) * w, y + (null !== (_d = color.y1) && void 0 !== _d ? _d : 0) * h);
|
|
11925
|
+
return color.stops.forEach(stop => {
|
|
11926
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
11927
|
+
}), canvasGradient;
|
|
11928
|
+
}
|
|
11929
|
+
function createRadialGradient(context, color, x, y, w, h) {
|
|
11930
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11931
|
+
const canvasGradient = context.createRadialGradient(x + (null !== (_a = color.x0) && void 0 !== _a ? _a : .5) * w, y + (null !== (_b = color.y0) && void 0 !== _b ? _b : .5) * h, Math.max(w, h) * (null !== (_c = color.r0) && void 0 !== _c ? _c : 0), x + (null !== (_d = color.x1) && void 0 !== _d ? _d : .5) * w, y + (null !== (_e = color.y1) && void 0 !== _e ? _e : .5) * h, Math.max(w, h) * (null !== (_f = color.r1) && void 0 !== _f ? _f : .5));
|
|
11932
|
+
return color.stops.forEach(stop => {
|
|
11933
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
11934
|
+
}), canvasGradient;
|
|
11935
|
+
}
|
|
11936
|
+
function createConicGradient(context, color, x, y, w, h) {
|
|
11937
|
+
var _a, _b;
|
|
11938
|
+
const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
|
|
11939
|
+
return color.stops.forEach(stop => {
|
|
11940
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
11941
|
+
}), canvasGradient.GetPattern(w + x, h + y, undefined);
|
|
11815
11942
|
}
|
|
11816
11943
|
|
|
11817
11944
|
var __decorate$1A = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
@@ -13680,16 +13807,8 @@
|
|
|
13680
13807
|
verticalMode = textAttribute.verticalMode,
|
|
13681
13808
|
x: originX = textAttribute.x,
|
|
13682
13809
|
y: originY = textAttribute.y
|
|
13683
|
-
} = text.attribute
|
|
13684
|
-
|
|
13685
|
-
textAlign = textAttribute.textAlign,
|
|
13686
|
-
textBaseline = textAttribute.textBaseline
|
|
13687
|
-
} = text.attribute;
|
|
13688
|
-
if (!verticalMode && "vertical" === direction) {
|
|
13689
|
-
const t = textAlign;
|
|
13690
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
13691
|
-
}
|
|
13692
|
-
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
13810
|
+
} = text.attribute,
|
|
13811
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
13693
13812
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
13694
13813
|
if (!data) return;
|
|
13695
13814
|
const {
|
|
@@ -13709,79 +13828,60 @@
|
|
|
13709
13828
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
13710
13829
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
13711
13830
|
}
|
|
13712
|
-
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z)
|
|
13831
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
|
|
13713
13832
|
};
|
|
13714
|
-
if (text.
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
width: line.width
|
|
13729
|
-
});
|
|
13730
|
-
})));
|
|
13731
|
-
} else {
|
|
13732
|
-
text.tryUpdateAABBBounds();
|
|
13733
|
-
const cache = text.cache,
|
|
13734
|
-
{
|
|
13735
|
-
verticalList: verticalList
|
|
13736
|
-
} = cache;
|
|
13737
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
13738
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
13739
|
-
let totalW = 0;
|
|
13740
|
-
verticalList.forEach(verticalData => {
|
|
13741
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13742
|
-
totalW = max(_w, totalW);
|
|
13743
|
-
});
|
|
13744
|
-
let offsetY = 0,
|
|
13745
|
-
offsetX = 0;
|
|
13746
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13747
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13748
|
-
dw = totalW - currentW;
|
|
13749
|
-
let currentOffsetY = offsetY;
|
|
13750
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13751
|
-
const {
|
|
13752
|
-
text: text,
|
|
13753
|
-
width: width,
|
|
13754
|
-
direction: direction
|
|
13755
|
-
} = item;
|
|
13756
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13757
|
-
});
|
|
13833
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
13834
|
+
const {
|
|
13835
|
+
multilineLayout: multilineLayout
|
|
13836
|
+
} = text;
|
|
13837
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
13838
|
+
const {
|
|
13839
|
+
xOffset: xOffset,
|
|
13840
|
+
yOffset: yOffset
|
|
13841
|
+
} = multilineLayout.bbox;
|
|
13842
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13843
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
13844
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
13845
|
+
context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, line.descent, (line.descent - line.ascent) / 2, z, textAttribute, context, {
|
|
13846
|
+
width: line.width
|
|
13758
13847
|
});
|
|
13759
|
-
}
|
|
13760
|
-
} else if ("horizontal" === direction) {
|
|
13761
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
13762
|
-
const t = text.clipedText;
|
|
13763
|
-
let dy = 0;
|
|
13764
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
13848
|
+
})));
|
|
13765
13849
|
} else {
|
|
13850
|
+
let {
|
|
13851
|
+
textAlign = textAttribute.textAlign,
|
|
13852
|
+
textBaseline = textAttribute.textBaseline
|
|
13853
|
+
} = text.attribute;
|
|
13854
|
+
if (!verticalMode) {
|
|
13855
|
+
const t = textAlign;
|
|
13856
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
13857
|
+
}
|
|
13766
13858
|
text.tryUpdateAABBBounds();
|
|
13767
|
-
const cache = text.cache
|
|
13768
|
-
|
|
13769
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
13770
|
-
const {
|
|
13859
|
+
const cache = text.cache,
|
|
13860
|
+
{
|
|
13771
13861
|
verticalList: verticalList
|
|
13772
13862
|
} = cache;
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13863
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
13864
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
13865
|
+
let totalW = 0;
|
|
13866
|
+
verticalList.forEach(verticalData => {
|
|
13867
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
13868
|
+
totalW = max(_w, totalW);
|
|
13869
|
+
});
|
|
13870
|
+
let offsetY = 0,
|
|
13871
|
+
offsetX = 0;
|
|
13872
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
13873
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
13874
|
+
dw = totalW - currentW;
|
|
13875
|
+
let currentOffsetY = offsetY;
|
|
13876
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
13777
13877
|
const {
|
|
13778
13878
|
text: text,
|
|
13779
13879
|
width: width,
|
|
13780
13880
|
direction: direction
|
|
13781
13881
|
} = item;
|
|
13782
|
-
drawText(text, offsetX,
|
|
13882
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
13783
13883
|
});
|
|
13784
|
-
}
|
|
13884
|
+
});
|
|
13785
13885
|
}
|
|
13786
13886
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
13787
13887
|
}
|
|
@@ -13793,12 +13893,10 @@
|
|
|
13793
13893
|
computed3dMatrix = !keepDirIn3d;
|
|
13794
13894
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
13795
13895
|
}
|
|
13796
|
-
drawUnderLine(underline, lineThrough, text,
|
|
13896
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
13797
13897
|
if (lineThrough + underline <= 0) return;
|
|
13798
13898
|
const {
|
|
13799
13899
|
textAlign = textAttribute.textAlign,
|
|
13800
|
-
textBaseline = textAttribute.textBaseline,
|
|
13801
|
-
fontSize = textAttribute.fontSize,
|
|
13802
13900
|
fill = textAttribute.fill,
|
|
13803
13901
|
opacity = textAttribute.opacity,
|
|
13804
13902
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -13808,23 +13906,21 @@
|
|
|
13808
13906
|
isMulti = !isNil$1(multiOption),
|
|
13809
13907
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
13810
13908
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
13811
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
13812
13909
|
attribute = {
|
|
13813
13910
|
lineWidth: 0,
|
|
13814
13911
|
stroke: fill,
|
|
13815
13912
|
opacity: opacity,
|
|
13816
13913
|
strokeOpacity: fillOpacity
|
|
13817
13914
|
};
|
|
13818
|
-
let deltaY = isMulti ? -3 : 0;
|
|
13819
13915
|
if (underline) {
|
|
13820
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
13821
|
-
const dy =
|
|
13822
|
-
context.moveTo(
|
|
13916
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
13917
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
13918
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
13823
13919
|
}
|
|
13824
|
-
if (
|
|
13825
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
13826
|
-
const dy =
|
|
13827
|
-
context.moveTo(
|
|
13920
|
+
if (lineThrough) {
|
|
13921
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
13922
|
+
const dy = anchorY + offsetThroughLineY;
|
|
13923
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
13828
13924
|
}
|
|
13829
13925
|
}
|
|
13830
13926
|
};
|
|
@@ -14227,10 +14323,7 @@
|
|
|
14227
14323
|
const {
|
|
14228
14324
|
context: context
|
|
14229
14325
|
} = drawContext;
|
|
14230
|
-
context.highPerformanceSave()
|
|
14231
|
-
const t1 = graphic.parent.globalTransMatrix,
|
|
14232
|
-
t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
|
|
14233
|
-
if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
14326
|
+
if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
14234
14327
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
14235
14328
|
const m = graphic.globalTransMatrix.getInverse();
|
|
14236
14329
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
|
|
@@ -14510,58 +14603,60 @@
|
|
|
14510
14603
|
constructor(fontFamily, options, textMeasure) {
|
|
14511
14604
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
14512
14605
|
}
|
|
14513
|
-
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
14606
|
+
LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
|
|
14514
14607
|
if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
|
|
14515
14608
|
if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
|
|
14516
14609
|
bbox.xOffset = -bbox.width;
|
|
14517
14610
|
}
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
14528
|
-
linesLayout.push({
|
|
14529
|
-
str: clipText,
|
|
14530
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
14531
|
-
}), str = str.substring(clipText.length);
|
|
14532
|
-
}
|
|
14533
|
-
"left" === textAlign || "start" === textAlign || ("center" === textAlign ? bboxOffset[0] = bboxWH[0] / -2 : "right" !== textAlign && "end" !== textAlign || (bboxOffset[0] = -bboxWH[0])), "top" === textBaseline || ("middle" === textBaseline ? bboxOffset[1] = bboxWH[1] / -2 : "bottom" === textBaseline && (bboxOffset[1] = -bboxWH[1]));
|
|
14534
|
-
const bbox = {
|
|
14535
|
-
xOffset: bboxOffset[0],
|
|
14536
|
-
yOffset: bboxOffset[1],
|
|
14537
|
-
width: bboxWH[0],
|
|
14538
|
-
height: bboxWH[1]
|
|
14539
|
-
};
|
|
14540
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14611
|
+
if ("top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
|
|
14612
|
+
let percent = .79;
|
|
14613
|
+
if (1 === linesLayout.length) {
|
|
14614
|
+
const lineInfo = linesLayout[0];
|
|
14615
|
+
percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
|
|
14616
|
+
}
|
|
14617
|
+
bbox.yOffset = bbox.height * -percent;
|
|
14618
|
+
} else bbox.yOffset = -bbox.height;
|
|
14619
|
+
return bbox;
|
|
14541
14620
|
}
|
|
14542
14621
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
14543
14622
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
14544
14623
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
14545
|
-
let
|
|
14546
|
-
|
|
14624
|
+
let params = arguments.length > 6 ? arguments[6] : undefined;
|
|
14625
|
+
const {
|
|
14626
|
+
lineWidth: lineWidth,
|
|
14627
|
+
suffixPosition = "end",
|
|
14628
|
+
measureMode = exports.MeasureModeEnum.actualBounding
|
|
14629
|
+
} = null != params ? params : {};
|
|
14547
14630
|
lines = lines.map(l => l.toString());
|
|
14548
14631
|
const linesLayout = [],
|
|
14549
14632
|
bboxWH = [0, 0];
|
|
14550
14633
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
14551
14634
|
let width;
|
|
14552
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
14553
|
-
|
|
14554
|
-
width
|
|
14555
|
-
|
|
14635
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14636
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
14637
|
+
width = Math.min(metrics.width, lineWidth), linesLayout.push({
|
|
14638
|
+
str: metrics.width <= lineWidth ? lines[i].toString() : this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
|
|
14639
|
+
width: width,
|
|
14640
|
+
ascent: metrics.ascent,
|
|
14641
|
+
descent: metrics.descent
|
|
14642
|
+
});
|
|
14643
|
+
}
|
|
14556
14644
|
bboxWH[0] = lineWidth;
|
|
14557
14645
|
} else {
|
|
14558
|
-
let width,
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14646
|
+
let width,
|
|
14647
|
+
text,
|
|
14648
|
+
_lineWidth = 0;
|
|
14649
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14650
|
+
text = lines[i];
|
|
14651
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
14652
|
+
width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
|
|
14653
|
+
str: text,
|
|
14654
|
+
width: width,
|
|
14655
|
+
ascent: metrics.ascent,
|
|
14656
|
+
descent: metrics.descent
|
|
14657
|
+
});
|
|
14658
|
+
}
|
|
14659
|
+
bboxWH[0] = _lineWidth;
|
|
14565
14660
|
}
|
|
14566
14661
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
14567
14662
|
const bbox = {
|
|
@@ -14570,7 +14665,7 @@
|
|
|
14570
14665
|
width: bboxWH[0],
|
|
14571
14666
|
height: bboxWH[1]
|
|
14572
14667
|
};
|
|
14573
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14668
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14574
14669
|
}
|
|
14575
14670
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
14576
14671
|
const origin = [0, 0],
|
|
@@ -14589,11 +14684,13 @@
|
|
|
14589
14684
|
};
|
|
14590
14685
|
}
|
|
14591
14686
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
14592
|
-
|
|
14687
|
+
"left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 + origin[1];
|
|
14688
|
+
const actualHeightWithBuf = line.ascent + line.descent + 0;
|
|
14689
|
+
return actualHeightWithBuf < lineHeight - 0 && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), origin[1] += lineHeight, line;
|
|
14593
14690
|
}
|
|
14594
14691
|
}
|
|
14595
14692
|
|
|
14596
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14693
|
+
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14597
14694
|
class Text extends Graphic {
|
|
14598
14695
|
get font() {
|
|
14599
14696
|
const textTheme = this.getGraphicTheme();
|
|
@@ -14602,26 +14699,22 @@
|
|
|
14602
14699
|
get clipedText() {
|
|
14603
14700
|
var _a;
|
|
14604
14701
|
const attribute = this.attribute,
|
|
14605
|
-
textTheme = this.getGraphicTheme()
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
14609
|
-
} = attribute;
|
|
14610
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14702
|
+
textTheme = this.getGraphicTheme(),
|
|
14703
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
14704
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
14611
14705
|
}
|
|
14612
14706
|
get clipedWidth() {
|
|
14613
|
-
|
|
14707
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
14614
14708
|
}
|
|
14615
14709
|
get cliped() {
|
|
14616
14710
|
var _a, _b;
|
|
14617
14711
|
const textTheme = this.getGraphicTheme(),
|
|
14618
14712
|
attribute = this.attribute,
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
14713
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
14714
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
14715
|
+
const {
|
|
14716
|
+
text: text
|
|
14717
|
+
} = this.attribute;
|
|
14625
14718
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
14626
14719
|
let mergedText = "";
|
|
14627
14720
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -14632,10 +14725,7 @@
|
|
|
14632
14725
|
return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
|
|
14633
14726
|
}
|
|
14634
14727
|
get multilineLayout() {
|
|
14635
|
-
|
|
14636
|
-
}
|
|
14637
|
-
isSimplify() {
|
|
14638
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
14728
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
14639
14729
|
}
|
|
14640
14730
|
get isMultiLine() {
|
|
14641
14731
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -14708,8 +14798,72 @@
|
|
|
14708
14798
|
}
|
|
14709
14799
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
14710
14800
|
}
|
|
14801
|
+
updateSingallineAABBBounds(text) {
|
|
14802
|
+
this.updateMultilineAABBBounds([text]);
|
|
14803
|
+
const layoutData = this.cache.layoutData;
|
|
14804
|
+
if (layoutData) {
|
|
14805
|
+
const line = layoutData.lines[0];
|
|
14806
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
14807
|
+
}
|
|
14808
|
+
return this._AABBBounds;
|
|
14809
|
+
}
|
|
14810
|
+
updateMultilineAABBBounds(text) {
|
|
14811
|
+
const textTheme = this.getGraphicTheme(),
|
|
14812
|
+
{
|
|
14813
|
+
direction = textTheme.direction,
|
|
14814
|
+
underlineOffset = textTheme.underlineOffset
|
|
14815
|
+
} = this.attribute,
|
|
14816
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14817
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14818
|
+
}
|
|
14819
|
+
guessLineHeightBuf(fontSize) {
|
|
14820
|
+
return fontSize ? .1 * fontSize : 0;
|
|
14821
|
+
}
|
|
14822
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
14823
|
+
var _a;
|
|
14824
|
+
const textTheme = this.getGraphicTheme(),
|
|
14825
|
+
attribute = this.attribute,
|
|
14826
|
+
{
|
|
14827
|
+
fontFamily = textTheme.fontFamily,
|
|
14828
|
+
textAlign = textTheme.textAlign,
|
|
14829
|
+
textBaseline = textTheme.textBaseline,
|
|
14830
|
+
fontSize = textTheme.fontSize,
|
|
14831
|
+
fontWeight = textTheme.fontWeight,
|
|
14832
|
+
ellipsis = textTheme.ellipsis,
|
|
14833
|
+
maxLineWidth: maxLineWidth,
|
|
14834
|
+
stroke = textTheme.stroke,
|
|
14835
|
+
wrap = textTheme.wrap,
|
|
14836
|
+
measureMode = textTheme.measureMode,
|
|
14837
|
+
lineWidth = textTheme.lineWidth,
|
|
14838
|
+
whiteSpace = textTheme.whiteSpace,
|
|
14839
|
+
suffixPosition = textTheme.suffixPosition,
|
|
14840
|
+
ignoreBuf = textTheme.ignoreBuf
|
|
14841
|
+
} = attribute,
|
|
14842
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
14843
|
+
lineHeight = this.getLineHeight(attribute, textTheme) + buf;
|
|
14844
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
14845
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
14846
|
+
const bbox = this.cache.layoutData.bbox;
|
|
14847
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14848
|
+
}
|
|
14849
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
14850
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14851
|
+
fontSize: fontSize,
|
|
14852
|
+
fontWeight: fontWeight,
|
|
14853
|
+
fontFamily: fontFamily,
|
|
14854
|
+
lineHeight: lineHeight
|
|
14855
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
14856
|
+
lineWidth: maxLineWidth,
|
|
14857
|
+
suffixPosition: suffixPosition,
|
|
14858
|
+
measureMode: measureMode
|
|
14859
|
+
}),
|
|
14860
|
+
{
|
|
14861
|
+
bbox: bbox
|
|
14862
|
+
} = layoutData;
|
|
14863
|
+
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14864
|
+
}
|
|
14711
14865
|
updateWrapAABBBounds(text) {
|
|
14712
|
-
var _a, _b, _c
|
|
14866
|
+
var _a, _b, _c;
|
|
14713
14867
|
const textTheme = this.getGraphicTheme(),
|
|
14714
14868
|
{
|
|
14715
14869
|
fontFamily = textTheme.fontFamily,
|
|
@@ -14723,22 +14877,25 @@
|
|
|
14723
14877
|
wordBreak = textTheme.wordBreak,
|
|
14724
14878
|
fontWeight = textTheme.fontWeight,
|
|
14725
14879
|
ignoreBuf = textTheme.ignoreBuf,
|
|
14880
|
+
measureMode = textTheme.measureMode,
|
|
14726
14881
|
suffixPosition = textTheme.suffixPosition,
|
|
14727
14882
|
heightLimit = 0,
|
|
14728
14883
|
lineClamp: lineClamp
|
|
14729
14884
|
} = this.attribute,
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
14885
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
14886
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme) + buf;
|
|
14887
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
14733
14888
|
const bbox = this.cache.layoutData.bbox;
|
|
14734
14889
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14735
14890
|
}
|
|
14736
14891
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
14737
|
-
|
|
14892
|
+
textOptions = {
|
|
14738
14893
|
fontSize: fontSize,
|
|
14739
14894
|
fontWeight: fontWeight,
|
|
14740
|
-
fontFamily: fontFamily
|
|
14741
|
-
|
|
14895
|
+
fontFamily: fontFamily,
|
|
14896
|
+
lineHeight: lineHeight
|
|
14897
|
+
},
|
|
14898
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
14742
14899
|
lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
14743
14900
|
linesLayout = [],
|
|
14744
14901
|
bboxWH = [0, 0];
|
|
@@ -14748,29 +14905,35 @@
|
|
|
14748
14905
|
const str = lines[i];
|
|
14749
14906
|
let needCut = !0;
|
|
14750
14907
|
if (i === lineCountLimit - 1) {
|
|
14751
|
-
const clip =
|
|
14908
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
14909
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14752
14910
|
linesLayout.push({
|
|
14753
14911
|
str: clip.str,
|
|
14754
|
-
width: clip.width
|
|
14912
|
+
width: clip.width,
|
|
14913
|
+
ascent: matrics.ascent,
|
|
14914
|
+
descent: matrics.descent
|
|
14755
14915
|
});
|
|
14756
14916
|
break;
|
|
14757
14917
|
}
|
|
14758
|
-
const clip =
|
|
14918
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
14759
14919
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
14760
14920
|
if (ellipsis) {
|
|
14761
|
-
const clipEllipsis =
|
|
14762
|
-
clip.str = null !== (
|
|
14921
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
14922
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
14763
14923
|
} else clip.str = "", clip.width = 0;
|
|
14764
14924
|
needCut = !1;
|
|
14765
14925
|
}
|
|
14926
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14766
14927
|
linesLayout.push({
|
|
14767
14928
|
str: clip.str,
|
|
14768
|
-
width: clip.width
|
|
14929
|
+
width: clip.width,
|
|
14930
|
+
ascent: matrics.ascent,
|
|
14931
|
+
descent: matrics.descent
|
|
14769
14932
|
});
|
|
14770
14933
|
let cutLength = clip.str.length;
|
|
14771
14934
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
14772
|
-
|
|
14773
|
-
|
|
14935
|
+
const newStr = str.substring(cutLength);
|
|
14936
|
+
lines.splice(i + 1, 0, newStr);
|
|
14774
14937
|
}
|
|
14775
14938
|
}
|
|
14776
14939
|
let maxWidth = 0;
|
|
@@ -14783,235 +14946,44 @@
|
|
|
14783
14946
|
lineWidth = 0;
|
|
14784
14947
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
14785
14948
|
if (i === lineCountLimit - 1) {
|
|
14786
|
-
const clip =
|
|
14949
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
14950
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
14787
14951
|
linesLayout.push({
|
|
14788
14952
|
str: clip.str,
|
|
14789
|
-
width: clip.width
|
|
14953
|
+
width: clip.width,
|
|
14954
|
+
ascent: matrics.ascent,
|
|
14955
|
+
descent: matrics.descent
|
|
14790
14956
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
14791
14957
|
break;
|
|
14792
14958
|
}
|
|
14793
|
-
text = lines[i], width =
|
|
14959
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
14960
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
14961
|
+
linesLayout.push({
|
|
14794
14962
|
str: text,
|
|
14795
|
-
width: width
|
|
14963
|
+
width: width,
|
|
14964
|
+
ascent: matrics.ascent,
|
|
14965
|
+
descent: matrics.descent
|
|
14796
14966
|
});
|
|
14797
14967
|
}
|
|
14798
14968
|
bboxWH[0] = lineWidth;
|
|
14799
14969
|
}
|
|
14800
|
-
bboxWH[1] = linesLayout.length *
|
|
14970
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
14801
14971
|
const bbox = {
|
|
14802
14972
|
xOffset: 0,
|
|
14803
14973
|
yOffset: 0,
|
|
14804
14974
|
width: bboxWH[0],
|
|
14805
14975
|
height: bboxWH[1]
|
|
14806
14976
|
};
|
|
14807
|
-
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
14977
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
|
|
14808
14978
|
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
14809
14979
|
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14810
14980
|
}
|
|
14811
|
-
updateSingallineAABBBounds(text) {
|
|
14812
|
-
const textTheme = this.getGraphicTheme(),
|
|
14813
|
-
{
|
|
14814
|
-
direction = textTheme.direction,
|
|
14815
|
-
underlineOffset = textTheme.underlineOffset
|
|
14816
|
-
} = this.attribute,
|
|
14817
|
-
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
14818
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14819
|
-
}
|
|
14820
|
-
updateMultilineAABBBounds(text) {
|
|
14821
|
-
const textTheme = this.getGraphicTheme(),
|
|
14822
|
-
{
|
|
14823
|
-
direction = textTheme.direction,
|
|
14824
|
-
underlineOffset = textTheme.underlineOffset
|
|
14825
|
-
} = this.attribute,
|
|
14826
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
14827
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
14828
|
-
}
|
|
14829
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
14830
|
-
var _a, _b;
|
|
14831
|
-
const textTheme = this.getGraphicTheme(),
|
|
14832
|
-
{
|
|
14833
|
-
wrap = textTheme.wrap
|
|
14834
|
-
} = this.attribute;
|
|
14835
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
14836
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
14837
|
-
let width, str;
|
|
14838
|
-
const attribute = this.attribute,
|
|
14839
|
-
{
|
|
14840
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
14841
|
-
ellipsis = textTheme.ellipsis,
|
|
14842
|
-
textAlign = textTheme.textAlign,
|
|
14843
|
-
textBaseline = textTheme.textBaseline,
|
|
14844
|
-
fontFamily = textTheme.fontFamily,
|
|
14845
|
-
fontSize = textTheme.fontSize,
|
|
14846
|
-
fontWeight = textTheme.fontWeight,
|
|
14847
|
-
stroke = textTheme.stroke,
|
|
14848
|
-
lineWidth = textTheme.lineWidth,
|
|
14849
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
14850
|
-
whiteSpace = textTheme.whiteSpace,
|
|
14851
|
-
suffixPosition = textTheme.suffixPosition
|
|
14852
|
-
} = attribute;
|
|
14853
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14854
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
14855
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
14856
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
14857
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
14858
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
14859
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14860
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14861
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14862
|
-
}
|
|
14863
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
14864
|
-
if (ellipsis) {
|
|
14865
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14866
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
14867
|
-
fontSize: fontSize,
|
|
14868
|
-
fontWeight: fontWeight,
|
|
14869
|
-
fontFamily: fontFamily
|
|
14870
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14871
|
-
str = data.str, width = data.width;
|
|
14872
|
-
} else {
|
|
14873
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
14874
|
-
fontSize: fontSize,
|
|
14875
|
-
fontWeight: fontWeight,
|
|
14876
|
-
fontFamily: fontFamily
|
|
14877
|
-
}, maxLineWidth, !1);
|
|
14878
|
-
str = data.str, width = data.width;
|
|
14879
|
-
}
|
|
14880
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
14881
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
14882
|
-
fontSize: fontSize,
|
|
14883
|
-
fontWeight: fontWeight,
|
|
14884
|
-
fontFamily: fontFamily
|
|
14885
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
14886
|
-
this.clearUpdateShapeTag();
|
|
14887
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
14888
|
-
let lh = lineHeight;
|
|
14889
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
14890
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
14891
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14892
|
-
}
|
|
14893
|
-
getBaselineMapAlign() {
|
|
14894
|
-
return Text.baselineMapAlign;
|
|
14895
|
-
}
|
|
14896
|
-
getAlignMapBaseline() {
|
|
14897
|
-
return Text.alignMapBaseline;
|
|
14898
|
-
}
|
|
14899
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
14900
|
-
var _a, _b, _c;
|
|
14901
|
-
const textTheme = this.getGraphicTheme(),
|
|
14902
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
14903
|
-
let width;
|
|
14904
|
-
const attribute = this.attribute,
|
|
14905
|
-
{
|
|
14906
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
14907
|
-
} = attribute,
|
|
14908
|
-
buf = ignoreBuf ? 0 : 2,
|
|
14909
|
-
{
|
|
14910
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
14911
|
-
ellipsis = textTheme.ellipsis,
|
|
14912
|
-
fontSize = textTheme.fontSize,
|
|
14913
|
-
fontWeight = textTheme.fontWeight,
|
|
14914
|
-
fontFamily = textTheme.fontFamily,
|
|
14915
|
-
stroke = textTheme.stroke,
|
|
14916
|
-
lineWidth = textTheme.lineWidth,
|
|
14917
|
-
verticalMode = textTheme.verticalMode,
|
|
14918
|
-
suffixPosition = textTheme.suffixPosition
|
|
14919
|
-
} = attribute,
|
|
14920
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
14921
|
-
let {
|
|
14922
|
-
textAlign = textTheme.textAlign,
|
|
14923
|
-
textBaseline = textTheme.textBaseline
|
|
14924
|
-
} = attribute;
|
|
14925
|
-
if (!verticalMode) {
|
|
14926
|
-
const t = textAlign;
|
|
14927
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
14928
|
-
}
|
|
14929
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
14930
|
-
width = this.cache.clipedWidth;
|
|
14931
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14932
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14933
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14934
|
-
}
|
|
14935
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
14936
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
14937
|
-
if (ellipsis) {
|
|
14938
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
14939
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
14940
|
-
fontSize: fontSize,
|
|
14941
|
-
fontWeight: fontWeight,
|
|
14942
|
-
fontFamily: fontFamily
|
|
14943
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
14944
|
-
verticalList = [data.verticalList], width = data.width;
|
|
14945
|
-
} else {
|
|
14946
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
14947
|
-
fontSize: fontSize,
|
|
14948
|
-
fontWeight: fontWeight,
|
|
14949
|
-
fontFamily: fontFamily
|
|
14950
|
-
}, maxLineWidth, !1);
|
|
14951
|
-
verticalList = [data.verticalList], width = data.width;
|
|
14952
|
-
}
|
|
14953
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14954
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
14955
|
-
const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
14956
|
-
fontSize: fontSize,
|
|
14957
|
-
fontWeight: fontWeight,
|
|
14958
|
-
fontFamily: fontFamily
|
|
14959
|
-
});
|
|
14960
|
-
width += w, t.width = w;
|
|
14961
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
14962
|
-
this.clearUpdateShapeTag();
|
|
14963
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
14964
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
14965
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14966
|
-
}
|
|
14967
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
14968
|
-
var _a, _b;
|
|
14969
|
-
const textTheme = this.getGraphicTheme(),
|
|
14970
|
-
{
|
|
14971
|
-
wrap = textTheme.wrap
|
|
14972
|
-
} = this.attribute;
|
|
14973
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
14974
|
-
const attribute = this.attribute,
|
|
14975
|
-
{
|
|
14976
|
-
fontFamily = textTheme.fontFamily,
|
|
14977
|
-
textAlign = textTheme.textAlign,
|
|
14978
|
-
textBaseline = textTheme.textBaseline,
|
|
14979
|
-
fontSize = textTheme.fontSize,
|
|
14980
|
-
fontWeight = textTheme.fontWeight,
|
|
14981
|
-
ellipsis = textTheme.ellipsis,
|
|
14982
|
-
maxLineWidth: maxLineWidth,
|
|
14983
|
-
stroke = textTheme.stroke,
|
|
14984
|
-
lineWidth = textTheme.lineWidth,
|
|
14985
|
-
whiteSpace = textTheme.whiteSpace,
|
|
14986
|
-
suffixPosition = textTheme.suffixPosition
|
|
14987
|
-
} = attribute,
|
|
14988
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
14989
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
14990
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
14991
|
-
const bbox = this.cache.layoutData.bbox;
|
|
14992
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
14993
|
-
}
|
|
14994
|
-
const textMeasure = application.graphicUtil.textMeasure,
|
|
14995
|
-
layoutData = new CanvasTextLayout(fontFamily, {
|
|
14996
|
-
fontSize: fontSize,
|
|
14997
|
-
fontWeight: fontWeight,
|
|
14998
|
-
fontFamily: fontFamily
|
|
14999
|
-
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
|
|
15000
|
-
{
|
|
15001
|
-
bbox: bbox
|
|
15002
|
-
} = layoutData;
|
|
15003
|
-
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
15004
|
-
}
|
|
15005
14981
|
updateVerticalMultilineAABBBounds(text) {
|
|
15006
|
-
var _a, _b
|
|
14982
|
+
var _a, _b;
|
|
15007
14983
|
const textTheme = this.getGraphicTheme(),
|
|
15008
14984
|
textMeasure = application.graphicUtil.textMeasure;
|
|
15009
14985
|
let width;
|
|
15010
14986
|
const attribute = this.attribute,
|
|
15011
|
-
{
|
|
15012
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
15013
|
-
} = attribute,
|
|
15014
|
-
buf = ignoreBuf ? 0 : 2,
|
|
15015
14987
|
{
|
|
15016
14988
|
maxLineWidth = textTheme.maxLineWidth,
|
|
15017
14989
|
ellipsis = textTheme.ellipsis,
|
|
@@ -15023,14 +14995,14 @@
|
|
|
15023
14995
|
verticalMode = textTheme.verticalMode,
|
|
15024
14996
|
suffixPosition = textTheme.suffixPosition
|
|
15025
14997
|
} = attribute,
|
|
15026
|
-
lineHeight =
|
|
14998
|
+
lineHeight = this.getLineHeight(attribute, textTheme);
|
|
15027
14999
|
let {
|
|
15028
15000
|
textAlign = textTheme.textAlign,
|
|
15029
15001
|
textBaseline = textTheme.textBaseline
|
|
15030
15002
|
} = attribute;
|
|
15031
15003
|
if (!verticalMode) {
|
|
15032
15004
|
const t = textAlign;
|
|
15033
|
-
textAlign = null !== (
|
|
15005
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
15034
15006
|
}
|
|
15035
15007
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
15036
15008
|
this.cache.verticalList.forEach(item => {
|
|
@@ -15078,6 +15050,15 @@
|
|
|
15078
15050
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
15079
15051
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
15080
15052
|
}
|
|
15053
|
+
getMaxWidth(theme) {
|
|
15054
|
+
var _a, _b;
|
|
15055
|
+
const attribute = this.attribute;
|
|
15056
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
15057
|
+
}
|
|
15058
|
+
getLineHeight(attribute, textTheme) {
|
|
15059
|
+
var _a;
|
|
15060
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
15061
|
+
}
|
|
15081
15062
|
needUpdateTags(keys) {
|
|
15082
15063
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
15083
15064
|
return super.needUpdateTags(keys, k);
|
|
@@ -15092,6 +15073,12 @@
|
|
|
15092
15073
|
getNoWorkAnimateAttr() {
|
|
15093
15074
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
15094
15075
|
}
|
|
15076
|
+
getBaselineMapAlign() {
|
|
15077
|
+
return Text.baselineMapAlign;
|
|
15078
|
+
}
|
|
15079
|
+
getAlignMapBaseline() {
|
|
15080
|
+
return Text.alignMapBaseline;
|
|
15081
|
+
}
|
|
15095
15082
|
}
|
|
15096
15083
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
15097
15084
|
ellipsis: 1,
|
|
@@ -15170,7 +15157,9 @@
|
|
|
15170
15157
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15171
15158
|
linesLayout.push({
|
|
15172
15159
|
str: clip.str,
|
|
15173
|
-
width: clip.width
|
|
15160
|
+
width: clip.width,
|
|
15161
|
+
ascent: 0,
|
|
15162
|
+
descent: 0
|
|
15174
15163
|
});
|
|
15175
15164
|
break;
|
|
15176
15165
|
}
|
|
@@ -15184,7 +15173,9 @@
|
|
|
15184
15173
|
}
|
|
15185
15174
|
if (linesLayout.push({
|
|
15186
15175
|
str: clip.str,
|
|
15187
|
-
width: clip.width
|
|
15176
|
+
width: clip.width,
|
|
15177
|
+
ascent: 0,
|
|
15178
|
+
descent: 0
|
|
15188
15179
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
15189
15180
|
const newStr = str.substring(clip.str.length);
|
|
15190
15181
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -15203,13 +15194,17 @@
|
|
|
15203
15194
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
15204
15195
|
linesLayout.push({
|
|
15205
15196
|
str: clip.str,
|
|
15206
|
-
width: clip.width
|
|
15197
|
+
width: clip.width,
|
|
15198
|
+
ascent: 0,
|
|
15199
|
+
descent: 0
|
|
15207
15200
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
15208
15201
|
break;
|
|
15209
15202
|
}
|
|
15210
15203
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
15211
15204
|
str: text,
|
|
15212
|
-
width: width
|
|
15205
|
+
width: width,
|
|
15206
|
+
ascent: 0,
|
|
15207
|
+
descent: 0
|
|
15213
15208
|
});
|
|
15214
15209
|
}
|
|
15215
15210
|
bboxWH[0] = lineWidth;
|
|
@@ -16386,7 +16381,7 @@
|
|
|
16386
16381
|
const {
|
|
16387
16382
|
lineWidth = 1
|
|
16388
16383
|
} = this.character;
|
|
16389
|
-
this.character.stroke && lineWidth && ctx.strokeText(text, left, baseline), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
16384
|
+
this.character.stroke && lineWidth && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
|
|
16390
16385
|
}
|
|
16391
16386
|
getWidthWithEllips(direction) {
|
|
16392
16387
|
let text = this.text;
|
|
@@ -16609,18 +16604,12 @@
|
|
|
16609
16604
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
16610
16605
|
}
|
|
16611
16606
|
}
|
|
16612
|
-
this.paragraphs.
|
|
16607
|
+
this.paragraphs.map((paragraph, index) => {
|
|
16613
16608
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
16614
16609
|
x: x + paragraph._x,
|
|
16615
16610
|
y: y + paragraph._y
|
|
16616
16611
|
}), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
|
|
16617
|
-
|
|
16618
|
-
x1: this.left,
|
|
16619
|
-
y1: this.top,
|
|
16620
|
-
x2: this.left + this.actualWidth,
|
|
16621
|
-
y2: this.top + this.height
|
|
16622
|
-
};
|
|
16623
|
-
applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
|
|
16612
|
+
paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
|
|
16624
16613
|
});
|
|
16625
16614
|
}
|
|
16626
16615
|
getWidthWithEllips(ellipsis) {
|
|
@@ -16643,7 +16632,7 @@
|
|
|
16643
16632
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
16644
16633
|
}
|
|
16645
16634
|
let width = 0;
|
|
16646
|
-
return this.paragraphs.
|
|
16635
|
+
return this.paragraphs.map((paragraph, index) => {
|
|
16647
16636
|
width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
|
|
16648
16637
|
}), width;
|
|
16649
16638
|
}
|
|
@@ -18485,13 +18474,15 @@
|
|
|
18485
18474
|
graphic.glyphHost && (graphic = graphic.glyphHost), stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !graphic.shouldSelfChangeUpdateAABBBounds() || willUpdate && (globalBounds.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2), stage.dirty(globalBounds, graphic.parent && graphic.parent.globalTransMatrix)));
|
|
18486
18475
|
}), application.graphicService.hooks.afterUpdateAABBBounds.tap(this.key, (graphic, stage, bounds, params, selfChange) => {
|
|
18487
18476
|
stage && stage === this.pluginService.stage && stage.renderCount && (graphic.isContainer && !selfChange || stage.dirty(params.globalAABBBounds));
|
|
18477
|
+
}), application.graphicService.hooks.clearAABBBounds.tap(this.key, (graphic, stage, bounds) => {
|
|
18478
|
+
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(bounds);
|
|
18488
18479
|
}), application.graphicService.hooks.onRemove.tap(this.key, graphic => {
|
|
18489
18480
|
const stage = graphic.stage;
|
|
18490
18481
|
stage && stage === this.pluginService.stage && stage.renderCount && stage && stage.dirty(graphic.globalAABBBounds);
|
|
18491
18482
|
});
|
|
18492
18483
|
}
|
|
18493
18484
|
deactivate(context) {
|
|
18494
|
-
application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => item.name !== this.key), application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => item.name !== this.key), context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => item.name !== this.key), application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => item.name !== this.key);
|
|
18485
|
+
application.graphicService.hooks.beforeUpdateAABBBounds.taps = application.graphicService.hooks.beforeUpdateAABBBounds.taps.filter(item => item.name !== this.key), application.graphicService.hooks.afterUpdateAABBBounds.taps = application.graphicService.hooks.afterUpdateAABBBounds.taps.filter(item => item.name !== this.key), application.graphicService.hooks.clearAABBBounds.taps = application.graphicService.hooks.clearAABBBounds.taps.filter(item => item.name !== this.key), context.stage.hooks.afterRender.taps = context.stage.hooks.afterRender.taps.filter(item => item.name !== this.key), application.graphicService.hooks.onRemove.taps = application.graphicService.hooks.onRemove.taps.filter(item => item.name !== this.key);
|
|
18495
18486
|
}
|
|
18496
18487
|
}
|
|
18497
18488
|
|
|
@@ -18607,7 +18598,7 @@
|
|
|
18607
18598
|
constructor() {
|
|
18608
18599
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18609
18600
|
var _a;
|
|
18610
|
-
super({}), this._onVisibleChange = visible => {
|
|
18601
|
+
super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
|
|
18611
18602
|
if (!(this._skipRender < 0)) if (visible) {
|
|
18612
18603
|
if (this.dirtyBounds) {
|
|
18613
18604
|
const b = this.window.getViewBox();
|
|
@@ -18618,7 +18609,10 @@
|
|
|
18618
18609
|
}, this.beforeRender = stage => {
|
|
18619
18610
|
this._beforeRender && this._beforeRender(stage);
|
|
18620
18611
|
}, this.afterRender = stage => {
|
|
18621
|
-
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
|
|
18612
|
+
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
|
|
18613
|
+
}, this.afterTickCb = () => {
|
|
18614
|
+
var _a;
|
|
18615
|
+
this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
|
|
18622
18616
|
}, this.params = params, this.theme = new Theme(), this.hooks = {
|
|
18623
18617
|
beforeRender: new SyncHook(["stage"]),
|
|
18624
18618
|
afterRender: new SyncHook(["stage"])
|
|
@@ -18635,7 +18629,7 @@
|
|
|
18635
18629
|
main: !0
|
|
18636
18630
|
})), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this.ticker = params.ticker || defaultTicker, this.supportInteractiveLayer = !1 !== params.interactiveLayer, this.timeline = new DefaultTimeline(), this.ticker.addTimeline(this.timeline), this.timeline.pause(), params.optimize || (params.optimize = {}), this.optmize(params.optimize), params.background && isString$1(this._background) && this._background.includes("/") && this.setAttributes({
|
|
18637
18631
|
background: this._background
|
|
18638
|
-
});
|
|
18632
|
+
}), this.ticker.on("afterTick", this.afterTickCb);
|
|
18639
18633
|
}
|
|
18640
18634
|
pauseRender() {
|
|
18641
18635
|
let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
@@ -18864,7 +18858,7 @@
|
|
|
18864
18858
|
if ("released" === this.releaseStatus) return;
|
|
18865
18859
|
this.ticker.start(), this.timeline.resume();
|
|
18866
18860
|
const state = this.state;
|
|
18867
|
-
this.state = "rendering", this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
|
|
18861
|
+
this.state = "rendering", this.tickedBeforeRender || this.ticker.trySyncTickStatus(), this.layerService.prepareStageLayer(this), this._skipRender || (this.lastRenderparams = params, this.hooks.beforeRender.call(this), this._skipRender || (this.renderLayerList(this.children), this.combineLayersToWindow(), this.nextFrameRenderLayerSet.clear()), this.hooks.afterRender.call(this)), this.state = state, this._skipRender && this._skipRender++;
|
|
18868
18862
|
}
|
|
18869
18863
|
combineLayersToWindow() {
|
|
18870
18864
|
if ("harmony" === this.global.env) {
|
|
@@ -18970,7 +18964,7 @@
|
|
|
18970
18964
|
layer.release();
|
|
18971
18965
|
}), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
|
|
18972
18966
|
item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
|
|
18973
|
-
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
|
|
18967
|
+
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
|
|
18974
18968
|
}
|
|
18975
18969
|
setStage(stage) {}
|
|
18976
18970
|
dirty(b, matrix) {
|
|
@@ -19048,8 +19042,6 @@
|
|
|
19048
19042
|
return new Stage(params);
|
|
19049
19043
|
}
|
|
19050
19044
|
|
|
19051
|
-
const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
|
|
19052
|
-
|
|
19053
19045
|
var __decorate$1d = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
19054
19046
|
var d,
|
|
19055
19047
|
c = arguments.length,
|
|
@@ -28635,7 +28627,7 @@
|
|
|
28635
28627
|
|
|
28636
28628
|
const roughModule = _roughModule;
|
|
28637
28629
|
|
|
28638
|
-
const version = "0.
|
|
28630
|
+
const version = "0.21.0-alpha.10";
|
|
28639
28631
|
preLoadAllModule();
|
|
28640
28632
|
if (isBrowserEnv()) {
|
|
28641
28633
|
loadBrowserEnv(container);
|