@visactor/vrender 0.21.0-vstory.2 → 0.21.0-vstory.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/index.es.js +1698 -1589
- package/dist/index.js +1699 -1588
- package/dist/index.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -748,6 +748,13 @@
|
|
|
748
748
|
};
|
|
749
749
|
exports.DefaultGlobal = __decorate$1J([injectable(), __param$U(0, inject(ContributionProvider)), __param$U(0, named(EnvContribution)), __metadata$1i("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
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
752
759
|
|
|
753
760
|
function getDefaultExportFromCjs (x) {
|
|
@@ -1704,7 +1711,9 @@
|
|
|
1704
1711
|
} = this.textSpec;
|
|
1705
1712
|
return {
|
|
1706
1713
|
width: metrics.width,
|
|
1707
|
-
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
|
|
1714
|
+
height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize,
|
|
1715
|
+
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
|
|
1716
|
+
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
|
|
1708
1717
|
};
|
|
1709
1718
|
}
|
|
1710
1719
|
quickMeasure(text) {
|
|
@@ -1718,7 +1727,7 @@
|
|
|
1718
1727
|
for (let i = 0; i < text.length; i++) {
|
|
1719
1728
|
const char = text[i];
|
|
1720
1729
|
let size = this._measureSpecialChar(char);
|
|
1721
|
-
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);
|
|
1730
|
+
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);
|
|
1722
1731
|
}
|
|
1723
1732
|
return totalSize;
|
|
1724
1733
|
}
|
|
@@ -1767,7 +1776,9 @@
|
|
|
1767
1776
|
const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
|
|
1768
1777
|
this._numberCharSize = {
|
|
1769
1778
|
width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
|
|
1770
|
-
height: numberBounds.height
|
|
1779
|
+
height: numberBounds.height,
|
|
1780
|
+
fontBoundingBoxAscent: numberBounds.fontBoundingBoxAscent,
|
|
1781
|
+
fontBoundingBoxDescent: numberBounds.fontBoundingBoxDescent
|
|
1771
1782
|
};
|
|
1772
1783
|
}
|
|
1773
1784
|
return this._numberCharSize;
|
|
@@ -1780,7 +1791,9 @@
|
|
|
1780
1791
|
const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
|
|
1781
1792
|
this._letterCharSize = {
|
|
1782
1793
|
width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
|
|
1783
|
-
height: alphabetBounds.height
|
|
1794
|
+
height: alphabetBounds.height,
|
|
1795
|
+
fontBoundingBoxAscent: alphabetBounds.fontBoundingBoxAscent,
|
|
1796
|
+
fontBoundingBoxDescent: alphabetBounds.fontBoundingBoxDescent
|
|
1784
1797
|
};
|
|
1785
1798
|
}
|
|
1786
1799
|
return this._letterCharSize;
|
|
@@ -4054,6 +4067,7 @@
|
|
|
4054
4067
|
const DefaultTextStyle = {
|
|
4055
4068
|
text: "",
|
|
4056
4069
|
maxLineWidth: 1 / 0,
|
|
4070
|
+
maxWidth: 1 / 0,
|
|
4057
4071
|
textAlign: "left",
|
|
4058
4072
|
textBaseline: "alphabetic",
|
|
4059
4073
|
fontSize: 16,
|
|
@@ -4077,7 +4091,9 @@
|
|
|
4077
4091
|
suffixPosition: "end",
|
|
4078
4092
|
underlineDash: [],
|
|
4079
4093
|
underlineOffset: 0,
|
|
4080
|
-
disableAutoClipedPoptip: void 0
|
|
4094
|
+
disableAutoClipedPoptip: void 0,
|
|
4095
|
+
measureMode: exports.MeasureModeEnum.fontBounding,
|
|
4096
|
+
keepCenterInLine: !1
|
|
4081
4097
|
};
|
|
4082
4098
|
const DefaultPickStyle = {
|
|
4083
4099
|
pickStrokeBuffer: 0
|
|
@@ -4134,7 +4150,8 @@
|
|
|
4134
4150
|
globalZIndex: 1,
|
|
4135
4151
|
globalCompositeOperation: "",
|
|
4136
4152
|
overflow: "hidden",
|
|
4137
|
-
shadowPickMode: "graphic"
|
|
4153
|
+
shadowPickMode: "graphic",
|
|
4154
|
+
keepStrokeScale: !1
|
|
4138
4155
|
}, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
|
|
4139
4156
|
function addAttributeToPrototype(obj, c, keys) {
|
|
4140
4157
|
keys.forEach(key => {
|
|
@@ -4288,165 +4305,553 @@
|
|
|
4288
4305
|
class Application {}
|
|
4289
4306
|
const application = new Application();
|
|
4290
4307
|
|
|
4291
|
-
const
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
fontSize: 16,
|
|
4313
|
-
fontFamily: "sans-serif",
|
|
4314
|
-
fill: !0,
|
|
4315
|
-
stroke: !1,
|
|
4316
|
-
fontWeight: "normal",
|
|
4317
|
-
lineHeight: "normal",
|
|
4318
|
-
fontStyle: "normal",
|
|
4319
|
-
textDecoration: "none",
|
|
4320
|
-
textAlign: "left",
|
|
4321
|
-
script: "normal"
|
|
4308
|
+
const parse = function () {
|
|
4309
|
+
const tokens = {
|
|
4310
|
+
linearGradient: /^(linear\-gradient)/i,
|
|
4311
|
+
radialGradient: /^(radial\-gradient)/i,
|
|
4312
|
+
conicGradient: /^(conic\-gradient)/i,
|
|
4313
|
+
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
4314
|
+
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
4315
|
+
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
4316
|
+
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
4317
|
+
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
4318
|
+
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
4319
|
+
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
4320
|
+
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
4321
|
+
startCall: /^\(/,
|
|
4322
|
+
endCall: /^\)/,
|
|
4323
|
+
comma: /^,/,
|
|
4324
|
+
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
4325
|
+
literalColor: /^([a-zA-Z]+)/,
|
|
4326
|
+
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
4327
|
+
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
4328
|
+
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
4322
4329
|
};
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
let fontSize = character.fontSize || 16;
|
|
4328
|
-
switch (character.script) {
|
|
4329
|
-
case "super":
|
|
4330
|
-
case "sub":
|
|
4331
|
-
fontSize *= .8;
|
|
4330
|
+
let input = "";
|
|
4331
|
+
function error(msg) {
|
|
4332
|
+
const err = new Error(input + ": " + msg);
|
|
4333
|
+
throw err.source = input, err;
|
|
4332
4334
|
}
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4335
|
+
function getAST() {
|
|
4336
|
+
const ast = matchListing(matchDefinition);
|
|
4337
|
+
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
4338
|
+
}
|
|
4339
|
+
function matchDefinition() {
|
|
4340
|
+
return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
|
|
4341
|
+
}
|
|
4342
|
+
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
4343
|
+
return function (pattern, callback) {
|
|
4344
|
+
const captures = scan(pattern);
|
|
4345
|
+
if (captures) {
|
|
4346
|
+
scan(tokens.startCall) || error("Missing (");
|
|
4347
|
+
const result = callback(captures);
|
|
4348
|
+
return scan(tokens.endCall) || error("Missing )"), result;
|
|
4349
|
+
}
|
|
4350
|
+
}(pattern, function (captures) {
|
|
4351
|
+
const orientation = orientationMatcher();
|
|
4352
|
+
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
|
|
4353
|
+
type: gradientType,
|
|
4354
|
+
orientation: orientation,
|
|
4355
|
+
colorStops: matchListing(matchColorStop)
|
|
4356
|
+
};
|
|
4357
|
+
});
|
|
4358
|
+
}
|
|
4359
|
+
function matchLinearOrientation() {
|
|
4360
|
+
return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
|
|
4361
|
+
}
|
|
4362
|
+
function matchConicalOrientation() {
|
|
4363
|
+
return match("angular", tokens.fromAngleValue, 1);
|
|
4364
|
+
}
|
|
4365
|
+
function matchListRadialOrientations() {
|
|
4366
|
+
let radialOrientations,
|
|
4367
|
+
lookaheadCache,
|
|
4368
|
+
radialOrientation = matchRadialOrientation();
|
|
4369
|
+
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
4370
|
+
}
|
|
4371
|
+
function matchRadialOrientation() {
|
|
4372
|
+
let radialType = function () {
|
|
4373
|
+
const circle = match("shape", /^(circle)/i, 0);
|
|
4374
|
+
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
4375
|
+
return circle;
|
|
4376
|
+
}() || function () {
|
|
4377
|
+
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
4378
|
+
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
4379
|
+
return ellipse;
|
|
4380
|
+
}();
|
|
4381
|
+
if (radialType) radialType.at = matchAtPosition();else {
|
|
4382
|
+
const extent = matchExtentKeyword();
|
|
4383
|
+
if (extent) {
|
|
4384
|
+
radialType = extent;
|
|
4385
|
+
const positionAt = matchAtPosition();
|
|
4386
|
+
positionAt && (radialType.at = positionAt);
|
|
4387
|
+
} else {
|
|
4388
|
+
const defaultPosition = matchPositioning();
|
|
4389
|
+
defaultPosition && (radialType = {
|
|
4390
|
+
type: "default-radial",
|
|
4391
|
+
at: defaultPosition
|
|
4392
|
+
});
|
|
4393
|
+
}
|
|
4372
4394
|
}
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4395
|
+
return radialType;
|
|
4396
|
+
}
|
|
4397
|
+
function matchExtentKeyword() {
|
|
4398
|
+
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
4399
|
+
}
|
|
4400
|
+
function matchAtPosition() {
|
|
4401
|
+
if (match("position", /^at/, 0)) {
|
|
4402
|
+
const positioning = matchPositioning();
|
|
4403
|
+
return positioning || error("Missing positioning value"), positioning;
|
|
4376
4404
|
}
|
|
4377
|
-
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);
|
|
4378
4405
|
}
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
function testLetter2(string, index) {
|
|
4388
|
-
let i = index;
|
|
4389
|
-
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
4390
|
-
return i;
|
|
4391
|
-
}
|
|
4392
|
-
function measureTextCanvas(text, character) {
|
|
4393
|
-
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
4394
|
-
result = {
|
|
4395
|
-
ascent: 0,
|
|
4396
|
-
height: 0,
|
|
4397
|
-
descent: 0,
|
|
4398
|
-
width: 0
|
|
4406
|
+
function matchPositioning() {
|
|
4407
|
+
const location = {
|
|
4408
|
+
x: matchDistance(),
|
|
4409
|
+
y: matchDistance()
|
|
4410
|
+
};
|
|
4411
|
+
if (location.x || location.y) return {
|
|
4412
|
+
type: "position",
|
|
4413
|
+
value: location
|
|
4399
4414
|
};
|
|
4400
|
-
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;
|
|
4401
|
-
}
|
|
4402
|
-
|
|
4403
|
-
var __decorate$1I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
4404
|
-
var d,
|
|
4405
|
-
c = arguments.length,
|
|
4406
|
-
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
4407
|
-
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);
|
|
4408
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4409
|
-
};
|
|
4410
|
-
let ATextMeasure = class {
|
|
4411
|
-
configure(service, env) {
|
|
4412
|
-
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4413
4415
|
}
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4416
|
+
function matchListing(matcher) {
|
|
4417
|
+
let captures = matcher();
|
|
4418
|
+
const result = [];
|
|
4419
|
+
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
4420
|
+
return result;
|
|
4418
4421
|
}
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
} = _ref;
|
|
4423
|
-
let eCharLen = 0,
|
|
4424
|
-
cCharLen = 0;
|
|
4425
|
-
for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
|
|
4426
|
-
return {
|
|
4427
|
-
width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
|
|
4428
|
-
height: fontSize
|
|
4429
|
-
};
|
|
4422
|
+
function matchColorStop() {
|
|
4423
|
+
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
4424
|
+
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
4430
4425
|
}
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4434
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4435
|
-
const textMeasure = this.context.measureText(text);
|
|
4436
|
-
return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
|
|
4426
|
+
function matchDistance() {
|
|
4427
|
+
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
4437
4428
|
}
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4441
|
-
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4442
|
-
const textMeasure = this.context.measureText(text);
|
|
4443
|
-
return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
|
|
4429
|
+
function matchLength() {
|
|
4430
|
+
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
4444
4431
|
}
|
|
4445
|
-
|
|
4446
|
-
|
|
4432
|
+
function match(type, pattern, captureIndex) {
|
|
4433
|
+
const captures = scan(pattern);
|
|
4434
|
+
if (captures) return {
|
|
4435
|
+
type: type,
|
|
4436
|
+
value: captures[captureIndex]
|
|
4437
|
+
};
|
|
4447
4438
|
}
|
|
4448
|
-
|
|
4449
|
-
|
|
4439
|
+
function scan(regexp) {
|
|
4440
|
+
const blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
4441
|
+
blankCaptures && consume(blankCaptures[0].length);
|
|
4442
|
+
const captures = regexp.exec(input);
|
|
4443
|
+
return captures && consume(captures[0].length), captures;
|
|
4444
|
+
}
|
|
4445
|
+
function consume(size) {
|
|
4446
|
+
input = input.substr(size);
|
|
4447
|
+
}
|
|
4448
|
+
return function (code) {
|
|
4449
|
+
return input = code.toString(), getAST();
|
|
4450
|
+
};
|
|
4451
|
+
}();
|
|
4452
|
+
class GradientParser {
|
|
4453
|
+
static IsGradient(c) {
|
|
4454
|
+
return !("string" == typeof c && !c.includes("gradient"));
|
|
4455
|
+
}
|
|
4456
|
+
static IsGradientStr(c) {
|
|
4457
|
+
return "string" == typeof c && c.includes("gradient");
|
|
4458
|
+
}
|
|
4459
|
+
static Parse(c) {
|
|
4460
|
+
if (GradientParser.IsGradientStr(c)) try {
|
|
4461
|
+
const datum = parse(c)[0];
|
|
4462
|
+
if (datum) {
|
|
4463
|
+
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
4464
|
+
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
4465
|
+
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
4466
|
+
}
|
|
4467
|
+
} catch (err) {
|
|
4468
|
+
return c;
|
|
4469
|
+
}
|
|
4470
|
+
return c;
|
|
4471
|
+
}
|
|
4472
|
+
static ParseConic(datum) {
|
|
4473
|
+
const {
|
|
4474
|
+
orientation: orientation,
|
|
4475
|
+
colorStops = []
|
|
4476
|
+
} = datum,
|
|
4477
|
+
halfPi = pi / 2,
|
|
4478
|
+
sa = parseFloat(orientation.value) / 180 * pi - halfPi;
|
|
4479
|
+
return {
|
|
4480
|
+
gradient: "conical",
|
|
4481
|
+
x: .5,
|
|
4482
|
+
y: .5,
|
|
4483
|
+
startAngle: sa,
|
|
4484
|
+
endAngle: sa + pi2,
|
|
4485
|
+
stops: colorStops.map(item => ({
|
|
4486
|
+
color: item.value,
|
|
4487
|
+
offset: parseFloat(item.length.value) / 100
|
|
4488
|
+
}))
|
|
4489
|
+
};
|
|
4490
|
+
}
|
|
4491
|
+
static ParseRadial(datum) {
|
|
4492
|
+
const {
|
|
4493
|
+
colorStops = []
|
|
4494
|
+
} = datum;
|
|
4495
|
+
return {
|
|
4496
|
+
gradient: "radial",
|
|
4497
|
+
x0: .5,
|
|
4498
|
+
y0: .5,
|
|
4499
|
+
x1: .5,
|
|
4500
|
+
y1: .5,
|
|
4501
|
+
r0: 0,
|
|
4502
|
+
r1: 1,
|
|
4503
|
+
stops: colorStops.map(item => ({
|
|
4504
|
+
color: item.value,
|
|
4505
|
+
offset: parseFloat(item.length.value) / 100
|
|
4506
|
+
}))
|
|
4507
|
+
};
|
|
4508
|
+
}
|
|
4509
|
+
static ParseLinear(datum) {
|
|
4510
|
+
const {
|
|
4511
|
+
orientation: orientation,
|
|
4512
|
+
colorStops = []
|
|
4513
|
+
} = datum,
|
|
4514
|
+
halfPi = pi / 2;
|
|
4515
|
+
let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
|
|
4516
|
+
for (; angle < 0;) angle += pi2;
|
|
4517
|
+
for (; angle >= pi2;) angle -= pi2;
|
|
4518
|
+
let x0 = 0,
|
|
4519
|
+
y0 = 0,
|
|
4520
|
+
x1 = 0,
|
|
4521
|
+
y1 = 0;
|
|
4522
|
+
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)), {
|
|
4523
|
+
gradient: "linear",
|
|
4524
|
+
x0: x0,
|
|
4525
|
+
y0: y0,
|
|
4526
|
+
x1: x1,
|
|
4527
|
+
y1: y1,
|
|
4528
|
+
stops: colorStops.map(item => ({
|
|
4529
|
+
color: item.value,
|
|
4530
|
+
offset: parseFloat(item.length.value) / 100
|
|
4531
|
+
}))
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
}
|
|
4535
|
+
|
|
4536
|
+
function getScaledStroke(context, width, dpr) {
|
|
4537
|
+
let strokeWidth = width;
|
|
4538
|
+
const {
|
|
4539
|
+
a: a,
|
|
4540
|
+
b: b,
|
|
4541
|
+
c: c,
|
|
4542
|
+
d: d
|
|
4543
|
+
} = context.currentMatrix,
|
|
4544
|
+
scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
|
|
4545
|
+
scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
4546
|
+
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
|
|
4547
|
+
}
|
|
4548
|
+
function createColor(context, c, params) {
|
|
4549
|
+
let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
4550
|
+
let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
4551
|
+
if (!c || !0 === c) return "black";
|
|
4552
|
+
let result, color;
|
|
4553
|
+
if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
|
|
4554
|
+
if (color = GradientParser.Parse(color), "string" == typeof color) return color;
|
|
4555
|
+
if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
|
|
4556
|
+
const bounds = params.AABBBounds;
|
|
4557
|
+
let w = bounds.x2 - bounds.x1,
|
|
4558
|
+
h = bounds.y2 - bounds.y1,
|
|
4559
|
+
x = bounds.x1 - offsetX,
|
|
4560
|
+
y = bounds.y1 - offsetY;
|
|
4561
|
+
if (params.attribute) {
|
|
4562
|
+
const {
|
|
4563
|
+
scaleX = 1,
|
|
4564
|
+
scaleY = 1
|
|
4565
|
+
} = params.attribute;
|
|
4566
|
+
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
4567
|
+
}
|
|
4568
|
+
"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));
|
|
4569
|
+
}
|
|
4570
|
+
return result || "orange";
|
|
4571
|
+
}
|
|
4572
|
+
function createLinearGradient(context, color, x, y, w, h) {
|
|
4573
|
+
var _a, _b, _c, _d;
|
|
4574
|
+
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);
|
|
4575
|
+
return color.stops.forEach(stop => {
|
|
4576
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4577
|
+
}), canvasGradient;
|
|
4578
|
+
}
|
|
4579
|
+
function createRadialGradient(context, color, x, y, w, h) {
|
|
4580
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4581
|
+
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));
|
|
4582
|
+
return color.stops.forEach(stop => {
|
|
4583
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4584
|
+
}), canvasGradient;
|
|
4585
|
+
}
|
|
4586
|
+
function createConicGradient(context, color, x, y, w, h) {
|
|
4587
|
+
var _a, _b;
|
|
4588
|
+
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);
|
|
4589
|
+
return color.stops.forEach(stop => {
|
|
4590
|
+
canvasGradient.addColorStop(stop.offset, stop.color);
|
|
4591
|
+
}), canvasGradient.GetPattern(w + x, h + y, undefined);
|
|
4592
|
+
}
|
|
4593
|
+
|
|
4594
|
+
const DIRECTION_KEY = {
|
|
4595
|
+
horizontal: {
|
|
4596
|
+
width: "width",
|
|
4597
|
+
height: "height",
|
|
4598
|
+
left: "left",
|
|
4599
|
+
top: "top",
|
|
4600
|
+
x: "x",
|
|
4601
|
+
y: "y",
|
|
4602
|
+
bottom: "bottom"
|
|
4603
|
+
},
|
|
4604
|
+
vertical: {
|
|
4605
|
+
width: "height",
|
|
4606
|
+
height: "width",
|
|
4607
|
+
left: "top",
|
|
4608
|
+
top: "left",
|
|
4609
|
+
x: "y",
|
|
4610
|
+
y: "x",
|
|
4611
|
+
bottom: "right"
|
|
4612
|
+
}
|
|
4613
|
+
};
|
|
4614
|
+
const defaultFormatting = {
|
|
4615
|
+
fontSize: 16,
|
|
4616
|
+
fontFamily: "sans-serif",
|
|
4617
|
+
fill: !0,
|
|
4618
|
+
stroke: !1,
|
|
4619
|
+
fontWeight: "normal",
|
|
4620
|
+
lineHeight: "normal",
|
|
4621
|
+
fontStyle: "normal",
|
|
4622
|
+
textDecoration: "none",
|
|
4623
|
+
textAlign: "left",
|
|
4624
|
+
script: "normal"
|
|
4625
|
+
};
|
|
4626
|
+
const regLetter = /\w|\(|\)|-/;
|
|
4627
|
+
const regPunctuation = /[.?!,;:/,。?!、;:]/;
|
|
4628
|
+
const regFirstSpace = /\S/;
|
|
4629
|
+
const setTextStyle = (ctx, character) => {
|
|
4630
|
+
let fontSize = character.fontSize || 16;
|
|
4631
|
+
switch (character.script) {
|
|
4632
|
+
case "super":
|
|
4633
|
+
case "sub":
|
|
4634
|
+
fontSize *= .8;
|
|
4635
|
+
}
|
|
4636
|
+
ctx.setTextStyle({
|
|
4637
|
+
textAlign: "left",
|
|
4638
|
+
textBaseline: character.textBaseline || "alphabetic",
|
|
4639
|
+
fontStyle: character.fontStyle || "",
|
|
4640
|
+
fontWeight: character.fontWeight || "",
|
|
4641
|
+
fontSize: fontSize,
|
|
4642
|
+
fontFamily: character.fontFamily || "sans-serif"
|
|
4643
|
+
});
|
|
4644
|
+
};
|
|
4645
|
+
function applyFillStyle(ctx, character, b) {
|
|
4646
|
+
const fillStyle = character && character.fill || defaultFormatting.fill;
|
|
4647
|
+
if (!fillStyle) return void (ctx.globalAlpha = 0);
|
|
4648
|
+
const {
|
|
4649
|
+
fillOpacity = 1,
|
|
4650
|
+
opacity = 1
|
|
4651
|
+
} = character;
|
|
4652
|
+
ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
|
|
4653
|
+
AABBBounds: b
|
|
4654
|
+
}) : fillStyle, setTextStyle(ctx, character);
|
|
4655
|
+
}
|
|
4656
|
+
function applyStrokeStyle(ctx, character) {
|
|
4657
|
+
const strokeStyle = character && character.stroke || defaultFormatting.stroke;
|
|
4658
|
+
if (!strokeStyle) return void (ctx.globalAlpha = 0);
|
|
4659
|
+
const {
|
|
4660
|
+
strokeOpacity = 1,
|
|
4661
|
+
opacity = 1
|
|
4662
|
+
} = character;
|
|
4663
|
+
ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
|
|
4664
|
+
}
|
|
4665
|
+
function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
|
|
4666
|
+
if (!width || width <= 0) return 0;
|
|
4667
|
+
const textMeasure = application.graphicUtil.textMeasure;
|
|
4668
|
+
let index = guessIndex,
|
|
4669
|
+
temp = desc.slice(0, index),
|
|
4670
|
+
tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
|
|
4671
|
+
tempNext = desc.slice(0, index + 1),
|
|
4672
|
+
tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
4673
|
+
for (; tempWidth > width || tempWidthNext <= width;) {
|
|
4674
|
+
if (tempWidth > width ? index-- : index++, index > desc.length) {
|
|
4675
|
+
index = desc.length;
|
|
4676
|
+
break;
|
|
4677
|
+
}
|
|
4678
|
+
if (index < 0) {
|
|
4679
|
+
index = 0;
|
|
4680
|
+
break;
|
|
4681
|
+
}
|
|
4682
|
+
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);
|
|
4683
|
+
}
|
|
4684
|
+
return needTestLetter && (index = testLetter(desc, index)), index;
|
|
4685
|
+
}
|
|
4686
|
+
function testLetter(string, index) {
|
|
4687
|
+
let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
|
|
4688
|
+
let i = index;
|
|
4689
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
|
|
4690
|
+
return i;
|
|
4691
|
+
}
|
|
4692
|
+
function testLetter2(string, index) {
|
|
4693
|
+
let i = index;
|
|
4694
|
+
for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
|
|
4695
|
+
return i;
|
|
4696
|
+
}
|
|
4697
|
+
function measureTextCanvas(text, character) {
|
|
4698
|
+
const measurement = application.graphicUtil.textMeasure.measureText(text, character),
|
|
4699
|
+
result = {
|
|
4700
|
+
ascent: 0,
|
|
4701
|
+
height: 0,
|
|
4702
|
+
descent: 0,
|
|
4703
|
+
width: 0
|
|
4704
|
+
};
|
|
4705
|
+
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;
|
|
4706
|
+
}
|
|
4707
|
+
|
|
4708
|
+
var __decorate$1I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
4709
|
+
var d,
|
|
4710
|
+
c = arguments.length,
|
|
4711
|
+
r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
4712
|
+
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);
|
|
4713
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4714
|
+
};
|
|
4715
|
+
let ATextMeasure = class {
|
|
4716
|
+
configure(service, env) {
|
|
4717
|
+
this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
|
|
4718
|
+
}
|
|
4719
|
+
_measureTextWithoutAlignBaseline(text, options, compatible) {
|
|
4720
|
+
this.context.setTextStyleWithoutAlignBaseline(options);
|
|
4721
|
+
const metrics = this.context.measureText(text);
|
|
4722
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4723
|
+
}
|
|
4724
|
+
_measureTextWithAlignBaseline(text, options, compatible) {
|
|
4725
|
+
this.context.setTextStyle(options);
|
|
4726
|
+
const metrics = this.context.measureText(text);
|
|
4727
|
+
return compatible ? this.compatibleMetrics(metrics, options) : metrics;
|
|
4728
|
+
}
|
|
4729
|
+
compatibleMetrics(metrics, options) {
|
|
4730
|
+
if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
|
|
4731
|
+
const {
|
|
4732
|
+
ascent: ascent,
|
|
4733
|
+
descent: descent
|
|
4734
|
+
} = this.measureTextBoundADscentEstimate(options);
|
|
4735
|
+
metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
|
|
4736
|
+
}
|
|
4737
|
+
if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
|
|
4738
|
+
const {
|
|
4739
|
+
left: left,
|
|
4740
|
+
right: right
|
|
4741
|
+
} = this.measureTextBoundLeftRightEstimate(options);
|
|
4742
|
+
metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
|
|
4743
|
+
}
|
|
4744
|
+
return metrics;
|
|
4745
|
+
}
|
|
4746
|
+
estimate(text, _ref) {
|
|
4747
|
+
let {
|
|
4748
|
+
fontSize = DefaultTextAttribute.fontSize
|
|
4749
|
+
} = _ref;
|
|
4750
|
+
let eCharLen = 0,
|
|
4751
|
+
cCharLen = 0;
|
|
4752
|
+
for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
|
|
4753
|
+
return {
|
|
4754
|
+
width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
|
|
4755
|
+
height: fontSize
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
measureTextWidth(text, options, textMeasure) {
|
|
4759
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4760
|
+
}
|
|
4761
|
+
measureTextBoundsWidth(text, options, textMeasure) {
|
|
4762
|
+
return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
|
|
4763
|
+
}
|
|
4764
|
+
measureTextBoundsLeftRight(text, options, textMeasure) {
|
|
4765
|
+
return this.context ? {
|
|
4766
|
+
left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
|
|
4767
|
+
right: textMeasure.actualBoundingBoxRight
|
|
4768
|
+
} : this.measureTextBoundLeftRightEstimate(options);
|
|
4769
|
+
}
|
|
4770
|
+
measureTextPixelHeight(text, options, textMeasure) {
|
|
4771
|
+
var _a;
|
|
4772
|
+
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;
|
|
4773
|
+
}
|
|
4774
|
+
measureTextPixelADscent(text, options, textMeasure) {
|
|
4775
|
+
return this.context ? {
|
|
4776
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
|
|
4777
|
+
descent: textMeasure.actualBoundingBoxDescent
|
|
4778
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4779
|
+
}
|
|
4780
|
+
measureTextBoundHieght(text, options, textMeasure) {
|
|
4781
|
+
var _a;
|
|
4782
|
+
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;
|
|
4783
|
+
}
|
|
4784
|
+
measureTextBoundADscent(text, options, textMeasure) {
|
|
4785
|
+
return this.context ? {
|
|
4786
|
+
ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
|
|
4787
|
+
descent: textMeasure.fontBoundingBoxDescent
|
|
4788
|
+
} : this.measureTextBoundADscentEstimate(options);
|
|
4789
|
+
}
|
|
4790
|
+
measureTextBoundADscentEstimate(options) {
|
|
4791
|
+
var _a;
|
|
4792
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
|
|
4793
|
+
return {
|
|
4794
|
+
ascent: .79 * fontSize,
|
|
4795
|
+
descent: .21 * fontSize
|
|
4796
|
+
};
|
|
4797
|
+
}
|
|
4798
|
+
measureTextBoundLeftRightEstimate(options) {
|
|
4799
|
+
var _a;
|
|
4800
|
+
const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
|
|
4801
|
+
{
|
|
4802
|
+
textAlign: textAlign
|
|
4803
|
+
} = options;
|
|
4804
|
+
return "center" === textAlign ? {
|
|
4805
|
+
left: fontSize / 2,
|
|
4806
|
+
right: fontSize / 2
|
|
4807
|
+
} : "right" === textAlign || "end" === textAlign ? {
|
|
4808
|
+
left: fontSize,
|
|
4809
|
+
right: 0
|
|
4810
|
+
} : {
|
|
4811
|
+
left: 0,
|
|
4812
|
+
right: fontSize
|
|
4813
|
+
};
|
|
4814
|
+
}
|
|
4815
|
+
measureTextPixelADscentAndWidth(text, options, mode) {
|
|
4816
|
+
if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4817
|
+
width: this.estimate(text, options).width
|
|
4818
|
+
});
|
|
4819
|
+
const out = this._measureTextWithoutAlignBaseline(text, options, !0);
|
|
4820
|
+
if (mode === exports.MeasureModeEnum.actualBounding) return {
|
|
4821
|
+
ascent: out.actualBoundingBoxAscent,
|
|
4822
|
+
descent: out.actualBoundingBoxDescent,
|
|
4823
|
+
width: out.width
|
|
4824
|
+
};
|
|
4825
|
+
if (mode === exports.MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
|
|
4826
|
+
width: out.width
|
|
4827
|
+
});
|
|
4828
|
+
if (mode === exports.MeasureModeEnum.fontBounding) {
|
|
4829
|
+
let ascent = out.fontBoundingBoxAscent,
|
|
4830
|
+
descent = out.fontBoundingBoxDescent;
|
|
4831
|
+
if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
|
|
4832
|
+
const delta = out.actualBoundingBoxDescent - descent;
|
|
4833
|
+
descent += delta, ascent -= delta;
|
|
4834
|
+
} else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
|
|
4835
|
+
const delta = out.actualBoundingBoxAscent - ascent;
|
|
4836
|
+
ascent += delta, descent -= delta;
|
|
4837
|
+
}
|
|
4838
|
+
return {
|
|
4839
|
+
ascent: ascent,
|
|
4840
|
+
descent: descent,
|
|
4841
|
+
width: out.width
|
|
4842
|
+
};
|
|
4843
|
+
}
|
|
4844
|
+
return {
|
|
4845
|
+
ascent: out.actualBoundingBoxAscent,
|
|
4846
|
+
descent: out.actualBoundingBoxDescent,
|
|
4847
|
+
width: out.width
|
|
4848
|
+
};
|
|
4849
|
+
}
|
|
4850
|
+
measureText(text, options) {
|
|
4851
|
+
return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
|
|
4852
|
+
}
|
|
4853
|
+
clipTextVertical(verticalList, options, width, wordBreak) {
|
|
4854
|
+
if (0 === verticalList.length) return {
|
|
4450
4855
|
verticalList: verticalList,
|
|
4451
4856
|
width: 0
|
|
4452
4857
|
};
|
|
@@ -4518,6 +4923,14 @@
|
|
|
4518
4923
|
return data;
|
|
4519
4924
|
}
|
|
4520
4925
|
_clipTextEnd(text, options, width, leftIdx, rightIdx) {
|
|
4926
|
+
if (leftIdx === rightIdx) {
|
|
4927
|
+
Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
|
|
4928
|
+
const subText = text.substring(0, rightIdx + 1);
|
|
4929
|
+
return {
|
|
4930
|
+
str: subText,
|
|
4931
|
+
width: this.measureTextWidth(subText, options)
|
|
4932
|
+
};
|
|
4933
|
+
}
|
|
4521
4934
|
const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
|
|
4522
4935
|
subText = text.substring(0, middleIdx + 1),
|
|
4523
4936
|
strWidth = this.measureTextWidth(subText, options);
|
|
@@ -4551,7 +4964,7 @@
|
|
|
4551
4964
|
}
|
|
4552
4965
|
_clipTextStart(text, options, width, leftIdx, rightIdx) {
|
|
4553
4966
|
const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
|
|
4554
|
-
subText = text.substring(middleIdx - 1, text.length
|
|
4967
|
+
subText = text.substring(middleIdx - 1, text.length),
|
|
4555
4968
|
strWidth = this.measureTextWidth(subText, options);
|
|
4556
4969
|
let length;
|
|
4557
4970
|
if (strWidth > width) {
|
|
@@ -4559,18 +4972,18 @@
|
|
|
4559
4972
|
str: "",
|
|
4560
4973
|
width: 0
|
|
4561
4974
|
};
|
|
4562
|
-
const str = text.substring(middleIdx, text.length
|
|
4975
|
+
const str = text.substring(middleIdx, text.length);
|
|
4563
4976
|
return length = this.measureTextWidth(str, options), length <= width ? {
|
|
4564
4977
|
str: str,
|
|
4565
4978
|
width: length
|
|
4566
|
-
} : this._clipTextStart(text, options, width, middleIdx, text.length
|
|
4979
|
+
} : this._clipTextStart(text, options, width, middleIdx, text.length);
|
|
4567
4980
|
}
|
|
4568
4981
|
if (strWidth < width) {
|
|
4569
4982
|
if (middleIdx <= 0) return {
|
|
4570
4983
|
str: text,
|
|
4571
4984
|
width: this.measureTextWidth(text, options)
|
|
4572
4985
|
};
|
|
4573
|
-
const str = text.substring(middleIdx - 2, text.length
|
|
4986
|
+
const str = text.substring(middleIdx - 2, text.length);
|
|
4574
4987
|
return length = this.measureTextWidth(str, options), length >= width ? {
|
|
4575
4988
|
str: subText,
|
|
4576
4989
|
width: strWidth
|
|
@@ -5625,19 +6038,19 @@
|
|
|
5625
6038
|
}
|
|
5626
6039
|
insertBefore(newNode, referenceNode) {
|
|
5627
6040
|
if (!referenceNode) return this.appendChild(newNode);
|
|
5628
|
-
if (this
|
|
6041
|
+
if (this === newNode || newNode === referenceNode) return null;
|
|
5629
6042
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
|
|
5630
6043
|
return referenceNode.parent !== this ? null : (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, newNode._prev = referenceNode._prev, referenceNode._prev ? referenceNode._prev._next = newNode : this._firstChild = newNode, referenceNode._prev = newNode, newNode._next = referenceNode, this._idMap || (this._idMap = new Map()), this._idMap.set(newNode._uid, newNode), this._structEdit = !0, this.setCount(newNode.count), newNode);
|
|
5631
6044
|
}
|
|
5632
6045
|
insertAfter(newNode, referenceNode) {
|
|
5633
6046
|
if (!referenceNode) return this.appendChild(newNode);
|
|
5634
|
-
if (this
|
|
6047
|
+
if (this === newNode || newNode === referenceNode) return null;
|
|
5635
6048
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertAfter】不能将父辈元素insert为子元素");
|
|
5636
6049
|
return referenceNode.parent !== this ? null : (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, referenceNode._next ? (referenceNode._next._prev = newNode, newNode._next = referenceNode._next) : this._lastChild = newNode, referenceNode._next = newNode, newNode._prev = referenceNode, this._idMap || (this._idMap = new Map()), this._idMap.set(newNode._uid, newNode), this._structEdit = !0, this.setCount(newNode.count), newNode);
|
|
5637
6050
|
}
|
|
5638
6051
|
insertInto(newNode, idx) {
|
|
5639
6052
|
if (!this._ignoreWarn && this._nodeList && Logger.getInstance().warn("insertIntoKeepIdx和insertInto混用可能会存在错误"), idx >= this.childrenCount) return this.appendChild(newNode);
|
|
5640
|
-
if (this
|
|
6053
|
+
if (this === newNode) return null;
|
|
5641
6054
|
if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
|
|
5642
6055
|
if (newNode.parent && newNode.parent.removeChild(newNode), newNode.parent = this, 0 === idx) newNode._next = this._firstChild, this._firstChild && (this._firstChild._prev = newNode), newNode._prev = null, this._firstChild = newNode;else {
|
|
5643
6056
|
let child = this._firstChild;
|
|
@@ -6155,7 +6568,7 @@
|
|
|
6155
6568
|
timeStamp: now
|
|
6156
6569
|
});
|
|
6157
6570
|
const clickHistory = trackingData.clicksByButton[from.button];
|
|
6158
|
-
clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
|
|
6571
|
+
clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < (null !== (_a = this._config.clickInterval) && void 0 !== _a ? _a : 200) ? ++clickHistory.clickCount : clickHistory.clickCount = 1, clickHistory.target = clickEvent.target, clickHistory.timeStamp = now, clickEvent.detail = clickHistory.clickCount, isMouseLike(clickEvent.pointerType) ? (this.dispatchEvent(clickEvent, "click"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dblclick")) : "touch" === clickEvent.pointerType && this._config.supportsTouchEvents && (this.dispatchEvent(clickEvent, "tap"), 2 === clickHistory.clickCount && this.dispatchEvent(clickEvent, "dbltap")), this.dispatchEvent(clickEvent, "pointertap"), this.freeEvent(clickEvent);
|
|
6159
6572
|
}
|
|
6160
6573
|
this.freeEvent(e);
|
|
6161
6574
|
}, this.onPointerUpOutside = (from, target) => {
|
|
@@ -6372,7 +6785,8 @@
|
|
|
6372
6785
|
supportsPointerEvents = global.supportsPointerEvents
|
|
6373
6786
|
} = params;
|
|
6374
6787
|
this.manager = new EventManager(rootNode, {
|
|
6375
|
-
clickInterval: clickInterval
|
|
6788
|
+
clickInterval: clickInterval,
|
|
6789
|
+
supportsTouchEvents: supportsTouchEvents
|
|
6376
6790
|
}), this.globalObj = global, this.supportsPointerEvents = supportsPointerEvents, this.supportsTouchEvents = supportsTouchEvents, this.supportsMouseEvents = global.supportsMouseEvents, this.applyStyles = global.applyStyles, this.autoPreventDefault = autoPreventDefault, this.eventsAdded = !1, this.rootPointerEvent = new FederatedPointerEvent(), this.rootWheelEvent = new FederatedWheelEvent(), this.cursorStyles = {
|
|
6377
6791
|
default: "inherit",
|
|
6378
6792
|
pointer: "pointer"
|
|
@@ -6556,8 +6970,8 @@
|
|
|
6556
6970
|
const {
|
|
6557
6971
|
once = !1
|
|
6558
6972
|
} = null != params ? params : {};
|
|
6559
|
-
this.ifCanStop() ? this.stop() : (this._handlerTick(
|
|
6560
|
-
}, this._handlerTick =
|
|
6973
|
+
this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
|
|
6974
|
+
}, this._handlerTick = () => {
|
|
6561
6975
|
const time = this.tickerHandler.getTime();
|
|
6562
6976
|
let delta = 0;
|
|
6563
6977
|
this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
|
|
@@ -6662,7 +7076,10 @@
|
|
|
6662
7076
|
this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
|
|
6663
7077
|
}
|
|
6664
7078
|
release() {
|
|
6665
|
-
this.stop(), this.timelines = [], this.tickerHandler.release();
|
|
7079
|
+
this.stop(), this.timelines = [], this.tickerHandler.release(), this.emit("afterTick");
|
|
7080
|
+
}
|
|
7081
|
+
trySyncTickStatus() {
|
|
7082
|
+
this.status === STATUS$1.RUNNING && this._handlerTick();
|
|
6666
7083
|
}
|
|
6667
7084
|
}
|
|
6668
7085
|
|
|
@@ -6819,6 +7236,9 @@
|
|
|
6819
7236
|
return (t *= 2) < 1 ? amplitude * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * -.5 : amplitude * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - s) * pi2 / period) * .5 + 1;
|
|
6820
7237
|
};
|
|
6821
7238
|
}
|
|
7239
|
+
static registerFunc(name, func) {
|
|
7240
|
+
Easing[name] = func;
|
|
7241
|
+
}
|
|
6822
7242
|
}
|
|
6823
7243
|
Easing.quadIn = Easing.getPowIn(2), Easing.quadOut = Easing.getPowOut(2), Easing.quadInOut = Easing.getPowInOut(2), Easing.cubicIn = Easing.getPowIn(3), Easing.cubicOut = Easing.getPowOut(3), Easing.cubicInOut = Easing.getPowInOut(3), Easing.quartIn = Easing.getPowIn(4), Easing.quartOut = Easing.getPowOut(4), Easing.quartInOut = Easing.getPowInOut(4), Easing.quintIn = Easing.getPowIn(5), Easing.quintOut = Easing.getPowOut(5), Easing.quintInOut = Easing.getPowInOut(5), Easing.backIn = Easing.getBackIn(1.7), Easing.backOut = Easing.getBackOut(1.7), Easing.backInOut = Easing.getBackInOut(1.7), Easing.elasticIn = Easing.getElasticIn(1, .3), Easing.elasticOut = Easing.getElasticOut(1, .3), Easing.elasticInOut = Easing.getElasticInOut(1, .3 * 1.5), Easing.easeInOutQuad = t => (t /= .5) < 1 ? .5 * Math.pow(t, 2) : -.5 * ((t -= 2) * t - 2), Easing.easeOutElastic = x => {
|
|
6824
7244
|
const c4 = 2 * Math.PI / 3;
|
|
@@ -7369,12 +7789,16 @@
|
|
|
7369
7789
|
}
|
|
7370
7790
|
RafBasedSTO.TimeOut = 1e3 / 60;
|
|
7371
7791
|
const rafBasedSto = new RafBasedSTO();
|
|
7372
|
-
const
|
|
7792
|
+
const _calculateLineHeight = (lineHeight, fontSize) => {
|
|
7373
7793
|
if (isString$1(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
|
|
7374
7794
|
return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
|
|
7375
7795
|
}
|
|
7376
7796
|
return lineHeight;
|
|
7377
7797
|
};
|
|
7798
|
+
const calculateLineHeight = (lineHeight, fontSize) => {
|
|
7799
|
+
const _lh = _calculateLineHeight(lineHeight, fontSize);
|
|
7800
|
+
return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
|
|
7801
|
+
};
|
|
7378
7802
|
|
|
7379
7803
|
class IncreaseCount extends ACustomAnimate {
|
|
7380
7804
|
constructor(from, to, duration, easing, params) {
|
|
@@ -7811,7 +8235,7 @@
|
|
|
7811
8235
|
lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
|
|
7812
8236
|
break;
|
|
7813
8237
|
}
|
|
7814
|
-
"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);
|
|
8238
|
+
"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);
|
|
7815
8239
|
let prevMatchedPoint = this.toPoints[0];
|
|
7816
8240
|
this.interpolatePoints = this.toPoints.map((point, index) => {
|
|
7817
8241
|
const matchedPoint = tagMap.get(point.context);
|
|
@@ -7823,11 +8247,19 @@
|
|
|
7823
8247
|
return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
|
|
7824
8248
|
});
|
|
7825
8249
|
}
|
|
8250
|
+
onFirstRun() {
|
|
8251
|
+
const lastClipRange = this.target.attribute.clipRange;
|
|
8252
|
+
isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
|
|
8253
|
+
}
|
|
7826
8254
|
onUpdate(end, ratio, out) {
|
|
7827
8255
|
if (this.points = this.points.map((point, index) => {
|
|
7828
8256
|
const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
|
|
7829
8257
|
return newPoint.context = point.context, newPoint;
|
|
7830
|
-
}), this.clipRange
|
|
8258
|
+
}), this.clipRange) {
|
|
8259
|
+
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));
|
|
8260
|
+
out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
|
|
8261
|
+
}
|
|
8262
|
+
if (this.segmentsCache && this.to.segments) {
|
|
7831
8263
|
let start = 0;
|
|
7832
8264
|
out.segments = this.to.segments.map((segment, index) => {
|
|
7833
8265
|
const end = start + this.segmentsCache[index],
|
|
@@ -11600,58 +12032,64 @@
|
|
|
11600
12032
|
constructor(fontFamily, options, textMeasure) {
|
|
11601
12033
|
this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
|
|
11602
12034
|
}
|
|
11603
|
-
LayoutBBox(bbox, textAlign, textBaseline) {
|
|
11604
|
-
if ("left" === textAlign || "start" === textAlign) bbox.
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
bboxOffset = [0, 0];
|
|
11614
|
-
for (; str.length > 0;) {
|
|
11615
|
-
const {
|
|
11616
|
-
str: clipText
|
|
11617
|
-
} = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
|
|
11618
|
-
linesLayout.push({
|
|
11619
|
-
str: clipText,
|
|
11620
|
-
width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
|
|
11621
|
-
}), str = str.substring(clipText.length);
|
|
11622
|
-
}
|
|
11623
|
-
"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]));
|
|
11624
|
-
const bbox = {
|
|
11625
|
-
xOffset: bboxOffset[0],
|
|
11626
|
-
yOffset: bboxOffset[1],
|
|
11627
|
-
width: bboxWH[0],
|
|
11628
|
-
height: bboxWH[1]
|
|
11629
|
-
};
|
|
11630
|
-
return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
12035
|
+
LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
|
|
12036
|
+
if (bbox.xOffset = "left" === textAlign || "start" === textAlign ? 0 : "center" === textAlign ? bbox.width / -2 : "right" === textAlign || "end" === textAlign ? -bbox.width : 0, "top" === textBaseline) bbox.yOffset = 0;else if ("middle" === textBaseline) bbox.yOffset = bbox.height / -2;else if ("alphabetic" === textBaseline) {
|
|
12037
|
+
let percent = .79;
|
|
12038
|
+
if (1 === linesLayout.length) {
|
|
12039
|
+
const lineInfo = linesLayout[0];
|
|
12040
|
+
percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
|
|
12041
|
+
}
|
|
12042
|
+
bbox.yOffset = bbox.height * -percent;
|
|
12043
|
+
} else bbox.yOffset = -bbox.height;
|
|
12044
|
+
return bbox;
|
|
11631
12045
|
}
|
|
11632
12046
|
GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
|
|
11633
12047
|
let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
11634
12048
|
let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
|
|
11635
|
-
let
|
|
11636
|
-
|
|
12049
|
+
let params = arguments.length > 6 ? arguments[6] : undefined;
|
|
12050
|
+
const {
|
|
12051
|
+
lineWidth: lineWidth,
|
|
12052
|
+
suffixPosition = "end",
|
|
12053
|
+
measureMode = exports.MeasureModeEnum.actualBounding,
|
|
12054
|
+
keepCenterInLine = !1
|
|
12055
|
+
} = null != params ? params : {};
|
|
11637
12056
|
lines = lines.map(l => l.toString());
|
|
11638
12057
|
const linesLayout = [],
|
|
11639
12058
|
bboxWH = [0, 0];
|
|
11640
12059
|
if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
|
|
11641
12060
|
let width;
|
|
11642
|
-
for (let i = 0, len = lines.length; i < len; i++)
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
12061
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
12062
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
12063
|
+
let str = lines[i].toString();
|
|
12064
|
+
if (metrics.width > lineWidth) {
|
|
12065
|
+
const data = this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, lineWidth, suffix, wordBreak, suffixPosition);
|
|
12066
|
+
str = data.str, width = data.width;
|
|
12067
|
+
} else width = metrics.width;
|
|
12068
|
+
linesLayout.push({
|
|
12069
|
+
str: str,
|
|
12070
|
+
width: width,
|
|
12071
|
+
ascent: metrics.ascent,
|
|
12072
|
+
descent: metrics.descent,
|
|
12073
|
+
keepCenterInLine: keepCenterInLine
|
|
12074
|
+
});
|
|
12075
|
+
}
|
|
11646
12076
|
bboxWH[0] = lineWidth;
|
|
11647
12077
|
} else {
|
|
11648
|
-
let width,
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
12078
|
+
let width,
|
|
12079
|
+
text,
|
|
12080
|
+
_lineWidth = 0;
|
|
12081
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
12082
|
+
text = lines[i];
|
|
12083
|
+
const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
|
|
12084
|
+
width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
|
|
12085
|
+
str: text,
|
|
12086
|
+
width: width,
|
|
12087
|
+
ascent: metrics.ascent,
|
|
12088
|
+
descent: metrics.descent,
|
|
12089
|
+
keepCenterInLine: keepCenterInLine
|
|
12090
|
+
});
|
|
12091
|
+
}
|
|
12092
|
+
bboxWH[0] = _lineWidth;
|
|
11655
12093
|
}
|
|
11656
12094
|
bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
|
|
11657
12095
|
const bbox = {
|
|
@@ -11660,7 +12098,7 @@
|
|
|
11660
12098
|
width: bboxWH[0],
|
|
11661
12099
|
height: bboxWH[1]
|
|
11662
12100
|
};
|
|
11663
|
-
return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
12101
|
+
return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
11664
12102
|
}
|
|
11665
12103
|
layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
|
|
11666
12104
|
const origin = [0, 0],
|
|
@@ -11679,11 +12117,19 @@
|
|
|
11679
12117
|
};
|
|
11680
12118
|
}
|
|
11681
12119
|
lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
|
|
11682
|
-
|
|
12120
|
+
if ("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], !line.keepCenterInLine) {
|
|
12121
|
+
const buf = 0,
|
|
12122
|
+
actualHeightWithBuf = line.ascent + line.descent + buf;
|
|
12123
|
+
if (actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), "alphabetic" === textBaseline) {
|
|
12124
|
+
const ratio = lineHeight / (line.ascent + line.descent);
|
|
12125
|
+
line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 * ratio + origin[1];
|
|
12126
|
+
}
|
|
12127
|
+
}
|
|
12128
|
+
return origin[1] += lineHeight, line;
|
|
11683
12129
|
}
|
|
11684
12130
|
}
|
|
11685
12131
|
|
|
11686
|
-
const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
12132
|
+
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];
|
|
11687
12133
|
class Text extends Graphic {
|
|
11688
12134
|
get font() {
|
|
11689
12135
|
const textTheme = this.getGraphicTheme();
|
|
@@ -11692,26 +12138,22 @@
|
|
|
11692
12138
|
get clipedText() {
|
|
11693
12139
|
var _a;
|
|
11694
12140
|
const attribute = this.attribute,
|
|
11695
|
-
textTheme = this.getGraphicTheme()
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
maxLineWidth = textTheme.maxLineWidth
|
|
11699
|
-
} = attribute;
|
|
11700
|
-
return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
12141
|
+
textTheme = this.getGraphicTheme(),
|
|
12142
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
12143
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
11701
12144
|
}
|
|
11702
12145
|
get clipedWidth() {
|
|
11703
|
-
|
|
12146
|
+
return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
11704
12147
|
}
|
|
11705
12148
|
get cliped() {
|
|
11706
12149
|
var _a, _b;
|
|
11707
12150
|
const textTheme = this.getGraphicTheme(),
|
|
11708
12151
|
attribute = this.attribute,
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
if (!Number.isFinite(maxLineWidth)) return !1;
|
|
12152
|
+
maxWidth = this.getMaxWidth(textTheme);
|
|
12153
|
+
if (!Number.isFinite(maxWidth)) return !1;
|
|
12154
|
+
const {
|
|
12155
|
+
text: text
|
|
12156
|
+
} = this.attribute;
|
|
11715
12157
|
if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
|
|
11716
12158
|
let mergedText = "";
|
|
11717
12159
|
this.cache.layoutData.lines.forEach(item => {
|
|
@@ -11722,10 +12164,7 @@
|
|
|
11722
12164
|
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();
|
|
11723
12165
|
}
|
|
11724
12166
|
get multilineLayout() {
|
|
11725
|
-
|
|
11726
|
-
}
|
|
11727
|
-
isSimplify() {
|
|
11728
|
-
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
12167
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
11729
12168
|
}
|
|
11730
12169
|
get isMultiLine() {
|
|
11731
12170
|
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
@@ -11798,8 +12237,74 @@
|
|
|
11798
12237
|
}
|
|
11799
12238
|
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
11800
12239
|
}
|
|
12240
|
+
updateSingallineAABBBounds(text) {
|
|
12241
|
+
this.updateMultilineAABBBounds([text]);
|
|
12242
|
+
const layoutData = this.cache.layoutData;
|
|
12243
|
+
if (layoutData && layoutData.lines && layoutData.lines.length) {
|
|
12244
|
+
const line = layoutData.lines[0];
|
|
12245
|
+
this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
|
|
12246
|
+
}
|
|
12247
|
+
return this._AABBBounds;
|
|
12248
|
+
}
|
|
12249
|
+
updateMultilineAABBBounds(text) {
|
|
12250
|
+
const textTheme = this.getGraphicTheme(),
|
|
12251
|
+
{
|
|
12252
|
+
direction = textTheme.direction,
|
|
12253
|
+
underlineOffset = textTheme.underlineOffset
|
|
12254
|
+
} = this.attribute,
|
|
12255
|
+
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
12256
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
12257
|
+
}
|
|
12258
|
+
guessLineHeightBuf(fontSize) {
|
|
12259
|
+
return fontSize ? .1 * fontSize : 0;
|
|
12260
|
+
}
|
|
12261
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
12262
|
+
var _a;
|
|
12263
|
+
const textTheme = this.getGraphicTheme(),
|
|
12264
|
+
attribute = this.attribute,
|
|
12265
|
+
{
|
|
12266
|
+
fontFamily = textTheme.fontFamily,
|
|
12267
|
+
textAlign = textTheme.textAlign,
|
|
12268
|
+
textBaseline = textTheme.textBaseline,
|
|
12269
|
+
fontSize = textTheme.fontSize,
|
|
12270
|
+
fontWeight = textTheme.fontWeight,
|
|
12271
|
+
ellipsis = textTheme.ellipsis,
|
|
12272
|
+
maxLineWidth: maxLineWidth,
|
|
12273
|
+
stroke = textTheme.stroke,
|
|
12274
|
+
wrap = textTheme.wrap,
|
|
12275
|
+
measureMode = textTheme.measureMode,
|
|
12276
|
+
lineWidth = textTheme.lineWidth,
|
|
12277
|
+
whiteSpace = textTheme.whiteSpace,
|
|
12278
|
+
suffixPosition = textTheme.suffixPosition,
|
|
12279
|
+
ignoreBuf = textTheme.ignoreBuf,
|
|
12280
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
12281
|
+
} = attribute,
|
|
12282
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
12283
|
+
lineHeight = this.getLineHeight(attribute, textTheme, buf);
|
|
12284
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
12285
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
12286
|
+
const bbox = this.cache.layoutData.bbox;
|
|
12287
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
12288
|
+
}
|
|
12289
|
+
const textMeasure = application.graphicUtil.textMeasure,
|
|
12290
|
+
layoutData = new CanvasTextLayout(fontFamily, {
|
|
12291
|
+
fontSize: fontSize,
|
|
12292
|
+
fontWeight: fontWeight,
|
|
12293
|
+
fontFamily: fontFamily,
|
|
12294
|
+
lineHeight: lineHeight
|
|
12295
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
|
|
12296
|
+
lineWidth: maxLineWidth,
|
|
12297
|
+
suffixPosition: suffixPosition,
|
|
12298
|
+
measureMode: measureMode,
|
|
12299
|
+
keepCenterInLine: keepCenterInLine
|
|
12300
|
+
}),
|
|
12301
|
+
{
|
|
12302
|
+
bbox: bbox
|
|
12303
|
+
} = layoutData;
|
|
12304
|
+
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;
|
|
12305
|
+
}
|
|
11801
12306
|
updateWrapAABBBounds(text) {
|
|
11802
|
-
var _a, _b, _c
|
|
12307
|
+
var _a, _b, _c;
|
|
11803
12308
|
const textTheme = this.getGraphicTheme(),
|
|
11804
12309
|
{
|
|
11805
12310
|
fontFamily = textTheme.fontFamily,
|
|
@@ -11813,22 +12318,26 @@
|
|
|
11813
12318
|
wordBreak = textTheme.wordBreak,
|
|
11814
12319
|
fontWeight = textTheme.fontWeight,
|
|
11815
12320
|
ignoreBuf = textTheme.ignoreBuf,
|
|
12321
|
+
measureMode = textTheme.measureMode,
|
|
11816
12322
|
suffixPosition = textTheme.suffixPosition,
|
|
11817
12323
|
heightLimit = 0,
|
|
11818
|
-
lineClamp: lineClamp
|
|
12324
|
+
lineClamp: lineClamp,
|
|
12325
|
+
keepCenterInLine = textTheme.keepCenterInLine
|
|
11819
12326
|
} = this.attribute,
|
|
11820
|
-
|
|
11821
|
-
|
|
11822
|
-
if (!this.shouldUpdateShape() && (null === (
|
|
12327
|
+
buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
|
|
12328
|
+
lineHeight = this.getLineHeight(this.attribute, textTheme, buf);
|
|
12329
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
11823
12330
|
const bbox = this.cache.layoutData.bbox;
|
|
11824
12331
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
11825
12332
|
}
|
|
11826
12333
|
const textMeasure = application.graphicUtil.textMeasure,
|
|
11827
|
-
|
|
12334
|
+
textOptions = {
|
|
11828
12335
|
fontSize: fontSize,
|
|
11829
12336
|
fontWeight: fontWeight,
|
|
11830
|
-
fontFamily: fontFamily
|
|
11831
|
-
|
|
12337
|
+
fontFamily: fontFamily,
|
|
12338
|
+
lineHeight: lineHeight
|
|
12339
|
+
},
|
|
12340
|
+
layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
|
|
11832
12341
|
lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
|
|
11833
12342
|
linesLayout = [],
|
|
11834
12343
|
bboxWH = [0, 0];
|
|
@@ -11838,24 +12347,32 @@
|
|
|
11838
12347
|
const str = lines[i];
|
|
11839
12348
|
let needCut = !0;
|
|
11840
12349
|
if (i === lineCountLimit - 1) {
|
|
11841
|
-
const clip =
|
|
12350
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
|
|
12351
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
11842
12352
|
linesLayout.push({
|
|
11843
12353
|
str: clip.str,
|
|
11844
|
-
width: clip.width
|
|
12354
|
+
width: clip.width,
|
|
12355
|
+
ascent: matrics.ascent,
|
|
12356
|
+
descent: matrics.descent,
|
|
12357
|
+
keepCenterInLine: keepCenterInLine
|
|
11845
12358
|
});
|
|
11846
12359
|
break;
|
|
11847
12360
|
}
|
|
11848
|
-
const clip =
|
|
12361
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
|
|
11849
12362
|
if ("" !== str && "" === clip.str || clip.wordBreaked) {
|
|
11850
12363
|
if (ellipsis) {
|
|
11851
|
-
const clipEllipsis =
|
|
11852
|
-
clip.str = null !== (
|
|
12364
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
12365
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
11853
12366
|
} else clip.str = "", clip.width = 0;
|
|
11854
12367
|
needCut = !1;
|
|
11855
12368
|
}
|
|
12369
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
11856
12370
|
linesLayout.push({
|
|
11857
12371
|
str: clip.str,
|
|
11858
|
-
width: clip.width
|
|
12372
|
+
width: clip.width,
|
|
12373
|
+
ascent: matrics.ascent,
|
|
12374
|
+
descent: matrics.descent,
|
|
12375
|
+
keepCenterInLine: keepCenterInLine
|
|
11859
12376
|
});
|
|
11860
12377
|
let cutLength = clip.str.length;
|
|
11861
12378
|
if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
|
|
@@ -11870,238 +12387,49 @@
|
|
|
11870
12387
|
} else {
|
|
11871
12388
|
let width,
|
|
11872
12389
|
text,
|
|
11873
|
-
lineWidth = 0;
|
|
11874
|
-
for (let i = 0, len = lines.length; i < len; i++) {
|
|
11875
|
-
if (i === lineCountLimit - 1) {
|
|
11876
|
-
const clip =
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
}
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
11899
|
-
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;
|
|
11900
|
-
}
|
|
11901
|
-
updateSingallineAABBBounds(text) {
|
|
11902
|
-
const textTheme = this.getGraphicTheme(),
|
|
11903
|
-
{
|
|
11904
|
-
direction = textTheme.direction,
|
|
11905
|
-
underlineOffset = textTheme.underlineOffset
|
|
11906
|
-
} = this.attribute,
|
|
11907
|
-
b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
|
|
11908
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
11909
|
-
}
|
|
11910
|
-
updateMultilineAABBBounds(text) {
|
|
11911
|
-
const textTheme = this.getGraphicTheme(),
|
|
11912
|
-
{
|
|
11913
|
-
direction = textTheme.direction,
|
|
11914
|
-
underlineOffset = textTheme.underlineOffset
|
|
11915
|
-
} = this.attribute,
|
|
11916
|
-
b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
11917
|
-
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
|
|
11918
|
-
}
|
|
11919
|
-
updateHorizontalSinglelineAABBBounds(text) {
|
|
11920
|
-
var _a, _b;
|
|
11921
|
-
const textTheme = this.getGraphicTheme(),
|
|
11922
|
-
{
|
|
11923
|
-
wrap = textTheme.wrap
|
|
11924
|
-
} = this.attribute;
|
|
11925
|
-
if (wrap) return this.updateWrapAABBBounds([text]);
|
|
11926
|
-
const textMeasure = application.graphicUtil.textMeasure;
|
|
11927
|
-
let width, str;
|
|
11928
|
-
const attribute = this.attribute,
|
|
11929
|
-
{
|
|
11930
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
11931
|
-
ellipsis = textTheme.ellipsis,
|
|
11932
|
-
textAlign = textTheme.textAlign,
|
|
11933
|
-
textBaseline = textTheme.textBaseline,
|
|
11934
|
-
fontFamily = textTheme.fontFamily,
|
|
11935
|
-
fontSize = textTheme.fontSize,
|
|
11936
|
-
fontWeight = textTheme.fontWeight,
|
|
11937
|
-
stroke = textTheme.stroke,
|
|
11938
|
-
lineWidth = textTheme.lineWidth,
|
|
11939
|
-
ignoreBuf = textTheme.ignoreBuf,
|
|
11940
|
-
whiteSpace = textTheme.whiteSpace,
|
|
11941
|
-
suffixPosition = textTheme.suffixPosition
|
|
11942
|
-
} = attribute;
|
|
11943
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
11944
|
-
const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
|
|
11945
|
-
textFontSize = attribute.fontSize || textTheme.fontSize,
|
|
11946
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
|
|
11947
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
11948
|
-
width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
|
|
11949
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
11950
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
11951
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
11952
|
-
}
|
|
11953
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
11954
|
-
if (ellipsis) {
|
|
11955
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
11956
|
-
data = textMeasure.clipTextWithSuffix(text.toString(), {
|
|
11957
|
-
fontSize: fontSize,
|
|
11958
|
-
fontWeight: fontWeight,
|
|
11959
|
-
fontFamily: fontFamily
|
|
11960
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
11961
|
-
str = data.str, width = data.width;
|
|
11962
|
-
} else {
|
|
11963
|
-
const data = textMeasure.clipText(text.toString(), {
|
|
11964
|
-
fontSize: fontSize,
|
|
11965
|
-
fontWeight: fontWeight,
|
|
11966
|
-
fontFamily: fontFamily
|
|
11967
|
-
}, maxLineWidth, !1);
|
|
11968
|
-
str = data.str, width = data.width;
|
|
11969
|
-
}
|
|
11970
|
-
this.cache.clipedText = str, this.cache.clipedWidth = width;
|
|
11971
|
-
} else width = textMeasure.measureTextWidth(text.toString(), {
|
|
11972
|
-
fontSize: fontSize,
|
|
11973
|
-
fontWeight: fontWeight,
|
|
11974
|
-
fontFamily: fontFamily
|
|
11975
|
-
}), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
|
|
11976
|
-
this.clearUpdateShapeTag();
|
|
11977
|
-
const dx = textDrawOffsetX(textAlign, width);
|
|
11978
|
-
let lh = lineHeight;
|
|
11979
|
-
application.global && application.global.isSafari() && (lh += .2 * fontSize);
|
|
11980
|
-
const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
|
|
11981
|
-
return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
11982
|
-
}
|
|
11983
|
-
getBaselineMapAlign() {
|
|
11984
|
-
return Text.baselineMapAlign;
|
|
11985
|
-
}
|
|
11986
|
-
getAlignMapBaseline() {
|
|
11987
|
-
return Text.alignMapBaseline;
|
|
11988
|
-
}
|
|
11989
|
-
updateVerticalSinglelineAABBBounds(text) {
|
|
11990
|
-
var _a, _b, _c;
|
|
11991
|
-
const textTheme = this.getGraphicTheme(),
|
|
11992
|
-
textMeasure = application.graphicUtil.textMeasure;
|
|
11993
|
-
let width;
|
|
11994
|
-
const attribute = this.attribute,
|
|
11995
|
-
{
|
|
11996
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
11997
|
-
} = attribute,
|
|
11998
|
-
buf = ignoreBuf ? 0 : 2,
|
|
11999
|
-
{
|
|
12000
|
-
maxLineWidth = textTheme.maxLineWidth,
|
|
12001
|
-
ellipsis = textTheme.ellipsis,
|
|
12002
|
-
fontSize = textTheme.fontSize,
|
|
12003
|
-
fontWeight = textTheme.fontWeight,
|
|
12004
|
-
fontFamily = textTheme.fontFamily,
|
|
12005
|
-
stroke = textTheme.stroke,
|
|
12006
|
-
lineWidth = textTheme.lineWidth,
|
|
12007
|
-
verticalMode = textTheme.verticalMode,
|
|
12008
|
-
suffixPosition = textTheme.suffixPosition
|
|
12009
|
-
} = attribute,
|
|
12010
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
12011
|
-
let {
|
|
12012
|
-
textAlign = textTheme.textAlign,
|
|
12013
|
-
textBaseline = textTheme.textBaseline
|
|
12014
|
-
} = attribute;
|
|
12015
|
-
if (!verticalMode) {
|
|
12016
|
-
const t = textAlign;
|
|
12017
|
-
textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
|
|
12018
|
-
}
|
|
12019
|
-
if (!this.shouldUpdateShape() && this.cache) {
|
|
12020
|
-
width = this.cache.clipedWidth;
|
|
12021
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
12022
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
12023
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
12024
|
-
}
|
|
12025
|
-
let verticalList = [verticalLayout(text.toString())];
|
|
12026
|
-
if (Number.isFinite(maxLineWidth)) {
|
|
12027
|
-
if (ellipsis) {
|
|
12028
|
-
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
|
|
12029
|
-
data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
|
|
12030
|
-
fontSize: fontSize,
|
|
12031
|
-
fontWeight: fontWeight,
|
|
12032
|
-
fontFamily: fontFamily
|
|
12033
|
-
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
12034
|
-
verticalList = [data.verticalList], width = data.width;
|
|
12035
|
-
} else {
|
|
12036
|
-
const data = textMeasure.clipTextVertical(verticalList[0], {
|
|
12037
|
-
fontSize: fontSize,
|
|
12038
|
-
fontWeight: fontWeight,
|
|
12039
|
-
fontFamily: fontFamily
|
|
12040
|
-
}, maxLineWidth, !1);
|
|
12041
|
-
verticalList = [data.verticalList], width = data.width;
|
|
12042
|
-
}
|
|
12043
|
-
this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
12044
|
-
} else width = 0, verticalList[0].forEach(t => {
|
|
12045
|
-
const w = t.direction === exports.TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
12046
|
-
fontSize: fontSize,
|
|
12047
|
-
fontWeight: fontWeight,
|
|
12048
|
-
fontFamily: fontFamily
|
|
12049
|
-
});
|
|
12050
|
-
width += w, t.width = w;
|
|
12051
|
-
}), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
|
|
12052
|
-
this.clearUpdateShapeTag();
|
|
12053
|
-
const dx = textDrawOffsetX(textAlign, width),
|
|
12054
|
-
dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
|
|
12055
|
-
return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
12056
|
-
}
|
|
12057
|
-
updateHorizontalMultilineAABBBounds(text) {
|
|
12058
|
-
var _a, _b;
|
|
12059
|
-
const textTheme = this.getGraphicTheme(),
|
|
12060
|
-
{
|
|
12061
|
-
wrap = textTheme.wrap
|
|
12062
|
-
} = this.attribute;
|
|
12063
|
-
if (wrap) return this.updateWrapAABBBounds(text);
|
|
12064
|
-
const attribute = this.attribute,
|
|
12065
|
-
{
|
|
12066
|
-
fontFamily = textTheme.fontFamily,
|
|
12067
|
-
textAlign = textTheme.textAlign,
|
|
12068
|
-
textBaseline = textTheme.textBaseline,
|
|
12069
|
-
fontSize = textTheme.fontSize,
|
|
12070
|
-
fontWeight = textTheme.fontWeight,
|
|
12071
|
-
ellipsis = textTheme.ellipsis,
|
|
12072
|
-
maxLineWidth: maxLineWidth,
|
|
12073
|
-
stroke = textTheme.stroke,
|
|
12074
|
-
lineWidth = textTheme.lineWidth,
|
|
12075
|
-
whiteSpace = textTheme.whiteSpace,
|
|
12076
|
-
suffixPosition = textTheme.suffixPosition
|
|
12077
|
-
} = attribute,
|
|
12078
|
-
lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
12079
|
-
if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
|
|
12080
|
-
if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
|
|
12081
|
-
const bbox = this.cache.layoutData.bbox;
|
|
12082
|
-
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
12390
|
+
lineWidth = 0;
|
|
12391
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
12392
|
+
if (i === lineCountLimit - 1) {
|
|
12393
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
|
|
12394
|
+
matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
|
|
12395
|
+
linesLayout.push({
|
|
12396
|
+
str: clip.str,
|
|
12397
|
+
width: clip.width,
|
|
12398
|
+
ascent: matrics.ascent,
|
|
12399
|
+
descent: matrics.descent,
|
|
12400
|
+
keepCenterInLine: keepCenterInLine
|
|
12401
|
+
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
12402
|
+
break;
|
|
12403
|
+
}
|
|
12404
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
12405
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
|
|
12406
|
+
linesLayout.push({
|
|
12407
|
+
str: text,
|
|
12408
|
+
width: width,
|
|
12409
|
+
ascent: matrics.ascent,
|
|
12410
|
+
descent: matrics.descent,
|
|
12411
|
+
keepCenterInLine: keepCenterInLine
|
|
12412
|
+
});
|
|
12413
|
+
}
|
|
12414
|
+
bboxWH[0] = lineWidth;
|
|
12083
12415
|
}
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12416
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
12417
|
+
const bbox = {
|
|
12418
|
+
xOffset: 0,
|
|
12419
|
+
yOffset: 0,
|
|
12420
|
+
width: bboxWH[0],
|
|
12421
|
+
height: bboxWH[1]
|
|
12422
|
+
};
|
|
12423
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
|
|
12424
|
+
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
12093
12425
|
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;
|
|
12094
12426
|
}
|
|
12095
12427
|
updateVerticalMultilineAABBBounds(text) {
|
|
12096
|
-
var _a, _b
|
|
12428
|
+
var _a, _b;
|
|
12097
12429
|
const textTheme = this.getGraphicTheme(),
|
|
12098
12430
|
textMeasure = application.graphicUtil.textMeasure;
|
|
12099
12431
|
let width;
|
|
12100
12432
|
const attribute = this.attribute,
|
|
12101
|
-
{
|
|
12102
|
-
ignoreBuf = textTheme.ignoreBuf
|
|
12103
|
-
} = attribute,
|
|
12104
|
-
buf = ignoreBuf ? 0 : 2,
|
|
12105
12433
|
{
|
|
12106
12434
|
maxLineWidth = textTheme.maxLineWidth,
|
|
12107
12435
|
ellipsis = textTheme.ellipsis,
|
|
@@ -12113,14 +12441,14 @@
|
|
|
12113
12441
|
verticalMode = textTheme.verticalMode,
|
|
12114
12442
|
suffixPosition = textTheme.suffixPosition
|
|
12115
12443
|
} = attribute,
|
|
12116
|
-
lineHeight =
|
|
12444
|
+
lineHeight = this.getLineHeight(attribute, textTheme, 0);
|
|
12117
12445
|
let {
|
|
12118
12446
|
textAlign = textTheme.textAlign,
|
|
12119
12447
|
textBaseline = textTheme.textBaseline
|
|
12120
12448
|
} = attribute;
|
|
12121
12449
|
if (!verticalMode) {
|
|
12122
12450
|
const t = textAlign;
|
|
12123
|
-
textAlign = null !== (
|
|
12451
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
12124
12452
|
}
|
|
12125
12453
|
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
12126
12454
|
this.cache.verticalList.forEach(item => {
|
|
@@ -12168,6 +12496,15 @@
|
|
|
12168
12496
|
dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
12169
12497
|
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
12170
12498
|
}
|
|
12499
|
+
getMaxWidth(theme) {
|
|
12500
|
+
var _a, _b;
|
|
12501
|
+
const attribute = this.attribute;
|
|
12502
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
12503
|
+
}
|
|
12504
|
+
getLineHeight(attribute, textTheme, buf) {
|
|
12505
|
+
var _a;
|
|
12506
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
|
|
12507
|
+
}
|
|
12171
12508
|
needUpdateTags(keys) {
|
|
12172
12509
|
let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
|
|
12173
12510
|
return super.needUpdateTags(keys, k);
|
|
@@ -12182,6 +12519,12 @@
|
|
|
12182
12519
|
getNoWorkAnimateAttr() {
|
|
12183
12520
|
return Text.NOWORK_ANIMATE_ATTR;
|
|
12184
12521
|
}
|
|
12522
|
+
getBaselineMapAlign() {
|
|
12523
|
+
return Text.baselineMapAlign;
|
|
12524
|
+
}
|
|
12525
|
+
getAlignMapBaseline() {
|
|
12526
|
+
return Text.alignMapBaseline;
|
|
12527
|
+
}
|
|
12185
12528
|
}
|
|
12186
12529
|
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
12187
12530
|
ellipsis: 1,
|
|
@@ -12260,7 +12603,10 @@
|
|
|
12260
12603
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
12261
12604
|
linesLayout.push({
|
|
12262
12605
|
str: clip.str,
|
|
12263
|
-
width: clip.width
|
|
12606
|
+
width: clip.width,
|
|
12607
|
+
ascent: 0,
|
|
12608
|
+
descent: 0,
|
|
12609
|
+
keepCenterInLine: !1
|
|
12264
12610
|
});
|
|
12265
12611
|
break;
|
|
12266
12612
|
}
|
|
@@ -12274,7 +12620,10 @@
|
|
|
12274
12620
|
}
|
|
12275
12621
|
if (linesLayout.push({
|
|
12276
12622
|
str: clip.str,
|
|
12277
|
-
width: clip.width
|
|
12623
|
+
width: clip.width,
|
|
12624
|
+
ascent: 0,
|
|
12625
|
+
descent: 0,
|
|
12626
|
+
keepCenterInLine: !1
|
|
12278
12627
|
}), clip.str.length === str.length) ;else if (needCut) {
|
|
12279
12628
|
const newStr = str.substring(clip.str.length);
|
|
12280
12629
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -12293,13 +12642,19 @@
|
|
|
12293
12642
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
12294
12643
|
linesLayout.push({
|
|
12295
12644
|
str: clip.str,
|
|
12296
|
-
width: clip.width
|
|
12645
|
+
width: clip.width,
|
|
12646
|
+
ascent: 0,
|
|
12647
|
+
descent: 0,
|
|
12648
|
+
keepCenterInLine: !1
|
|
12297
12649
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
12298
12650
|
break;
|
|
12299
12651
|
}
|
|
12300
12652
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
12301
12653
|
str: text,
|
|
12302
|
-
width: width
|
|
12654
|
+
width: width,
|
|
12655
|
+
ascent: 0,
|
|
12656
|
+
descent: 0,
|
|
12657
|
+
keepCenterInLine: !1
|
|
12303
12658
|
});
|
|
12304
12659
|
}
|
|
12305
12660
|
bboxWH[0] = lineWidth;
|
|
@@ -13509,7 +13864,11 @@
|
|
|
13509
13864
|
case "sub":
|
|
13510
13865
|
baseline += this.descent / 2;
|
|
13511
13866
|
}
|
|
13512
|
-
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0)
|
|
13867
|
+
"vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0);
|
|
13868
|
+
const {
|
|
13869
|
+
lineWidth = 1
|
|
13870
|
+
} = this.character;
|
|
13871
|
+
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();
|
|
13513
13872
|
}
|
|
13514
13873
|
getWidthWithEllips(direction) {
|
|
13515
13874
|
let text = this.text;
|
|
@@ -13732,12 +14091,18 @@
|
|
|
13732
14091
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
13733
14092
|
}
|
|
13734
14093
|
}
|
|
13735
|
-
this.paragraphs.
|
|
14094
|
+
this.paragraphs.forEach((paragraph, index) => {
|
|
13736
14095
|
if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
|
|
13737
14096
|
x: x + paragraph._x,
|
|
13738
14097
|
y: y + paragraph._y
|
|
13739
14098
|
}), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
|
|
13740
|
-
|
|
14099
|
+
const b = {
|
|
14100
|
+
x1: this.left,
|
|
14101
|
+
y1: this.top,
|
|
14102
|
+
x2: this.left + this.actualWidth,
|
|
14103
|
+
y2: this.top + this.height
|
|
14104
|
+
};
|
|
14105
|
+
applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
|
|
13741
14106
|
});
|
|
13742
14107
|
}
|
|
13743
14108
|
getWidthWithEllips(ellipsis) {
|
|
@@ -13760,7 +14125,7 @@
|
|
|
13760
14125
|
paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
|
|
13761
14126
|
}
|
|
13762
14127
|
let width = 0;
|
|
13763
|
-
return this.paragraphs.
|
|
14128
|
+
return this.paragraphs.forEach((paragraph, index) => {
|
|
13764
14129
|
width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
|
|
13765
14130
|
}), width;
|
|
13766
14131
|
}
|
|
@@ -14034,1127 +14399,841 @@
|
|
|
14034
14399
|
l.calcOffset(offsetSize, !1);
|
|
14035
14400
|
});
|
|
14036
14401
|
}
|
|
14037
|
-
this._frameCache = frame;
|
|
14038
|
-
}
|
|
14039
|
-
clone() {
|
|
14040
|
-
return new RichText(Object.assign({}, this.attribute));
|
|
14041
|
-
}
|
|
14042
|
-
setStage(stage, layer) {
|
|
14043
|
-
super.setStage(stage, layer);
|
|
14044
|
-
this.getFrameCache().icons.forEach(icon => {
|
|
14045
|
-
icon.setStage(stage, layer);
|
|
14046
|
-
});
|
|
14047
|
-
}
|
|
14048
|
-
bindIconEvent() {
|
|
14049
|
-
this.addEventListener("pointermove", e => {
|
|
14050
|
-
const pickedIcon = this.pickIcon(e.global);
|
|
14051
|
-
pickedIcon && pickedIcon === this._currentHoverIcon || (pickedIcon ? this.setAttribute("hoverIconId", pickedIcon.richtextId) : !pickedIcon && this._currentHoverIcon && this.setAttribute("hoverIconId", void 0));
|
|
14052
|
-
}), this.addEventListener("pointerleave", e => {
|
|
14053
|
-
this._currentHoverIcon && this.setAttribute("hoverIconId", void 0);
|
|
14054
|
-
});
|
|
14055
|
-
}
|
|
14056
|
-
updateHoverIconState(pickedIcon) {
|
|
14057
|
-
var _a, _b, _c, _d, _e;
|
|
14058
|
-
pickedIcon ? (null === (_a = this._currentHoverIcon) || void 0 === _a || _a.setHoverState(!1), this._currentHoverIcon = pickedIcon, this._currentHoverIcon.setHoverState(!0), null === (_b = this.stage) || void 0 === _b || _b.setCursor(pickedIcon.attribute.cursor), null === (_c = this.stage) || void 0 === _c || _c.renderNextFrame()) : (this._currentHoverIcon.setHoverState(!1), this._currentHoverIcon = null, null === (_d = this.stage) || void 0 === _d || _d.setCursor(), null === (_e = this.stage) || void 0 === _e || _e.renderNextFrame());
|
|
14059
|
-
}
|
|
14060
|
-
pickIcon(point) {
|
|
14061
|
-
const frameCache = this.getFrameCache(),
|
|
14062
|
-
{
|
|
14063
|
-
e: x,
|
|
14064
|
-
f: y
|
|
14065
|
-
} = this.globalTransMatrix;
|
|
14066
|
-
let pickIcon;
|
|
14067
|
-
return frameCache.icons.forEach((icon, key) => {
|
|
14068
|
-
var _a, _b;
|
|
14069
|
-
const bounds = icon.AABBBounds.clone();
|
|
14070
|
-
bounds.translate(icon._marginArray[3], icon._marginArray[0]), bounds.containsPoint({
|
|
14071
|
-
x: point.x - x,
|
|
14072
|
-
y: point.y - y
|
|
14073
|
-
}) && (pickIcon = icon, pickIcon.globalX = (null !== (_a = pickIcon.attribute.x) && void 0 !== _a ? _a : 0) + x + icon._marginArray[3], pickIcon.globalY = (null !== (_b = pickIcon.attribute.y) && void 0 !== _b ? _b : 0) + y + icon._marginArray[0]);
|
|
14074
|
-
}), pickIcon;
|
|
14075
|
-
}
|
|
14076
|
-
getNoWorkAnimateAttr() {
|
|
14077
|
-
return RichText.NOWORK_ANIMATE_ATTR;
|
|
14078
|
-
}
|
|
14079
|
-
}
|
|
14080
|
-
RichText.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14081
|
-
ellipsis: 1,
|
|
14082
|
-
wordBreak: 1,
|
|
14083
|
-
verticalDirection: 1,
|
|
14084
|
-
textAlign: 1,
|
|
14085
|
-
textBaseline: 1,
|
|
14086
|
-
textConfig: 1,
|
|
14087
|
-
layoutDirection: 1
|
|
14088
|
-
}, NOWORK_ANIMATE_ATTR);
|
|
14089
|
-
function createRichText(attributes) {
|
|
14090
|
-
return new RichText(attributes);
|
|
14091
|
-
}
|
|
14092
|
-
|
|
14093
|
-
const PATH_UPDATE_TAG_KEY = ["path", "customPath", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14094
|
-
class Path extends Graphic {
|
|
14095
|
-
constructor(params) {
|
|
14096
|
-
super(params), this.type = "path", this.numberType = PATH_NUMBER_TYPE;
|
|
14097
|
-
}
|
|
14098
|
-
get pathShape() {
|
|
14099
|
-
return this.tryUpdateAABBBounds(), this.getParsedPathShape();
|
|
14100
|
-
}
|
|
14101
|
-
isValid() {
|
|
14102
|
-
return super.isValid() && this._isValid();
|
|
14103
|
-
}
|
|
14104
|
-
_isValid() {
|
|
14105
|
-
const {
|
|
14106
|
-
path: path
|
|
14107
|
-
} = this.attribute;
|
|
14108
|
-
return null != path && "" !== path;
|
|
14109
|
-
}
|
|
14110
|
-
getParsedPathShape() {
|
|
14111
|
-
const pathTheme = this.getGraphicTheme();
|
|
14112
|
-
if (!this.valid) return pathTheme.path;
|
|
14113
|
-
const attribute = this.attribute;
|
|
14114
|
-
return attribute.path instanceof CustomPath2D ? attribute.path : (isNil$1(this.cache) && this.doUpdatePathShape(), this.cache instanceof CustomPath2D ? this.cache : pathTheme.path);
|
|
14115
|
-
}
|
|
14116
|
-
getGraphicTheme() {
|
|
14117
|
-
return getTheme(this).path;
|
|
14118
|
-
}
|
|
14119
|
-
updateAABBBounds(attribute, pathTheme, aabbBounds) {
|
|
14120
|
-
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
14121
|
-
const pathShape = this.getParsedPathShape();
|
|
14122
|
-
aabbBounds.union(pathShape.getBounds());
|
|
14123
|
-
}
|
|
14124
|
-
const {
|
|
14125
|
-
tb1: tb1,
|
|
14126
|
-
tb2: tb2
|
|
14127
|
-
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14128
|
-
updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
14129
|
-
const {
|
|
14130
|
-
lineJoin = pathTheme.lineJoin
|
|
14131
|
-
} = attribute;
|
|
14132
|
-
return application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14133
|
-
}
|
|
14134
|
-
doUpdateAABBBounds(full) {
|
|
14135
|
-
return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
|
|
14136
|
-
}
|
|
14137
|
-
doUpdatePathShape() {
|
|
14138
|
-
const attribute = this.attribute;
|
|
14139
|
-
isString$1(attribute.path, !0) ? this.cache = new CustomPath2D().fromString(attribute.path) : attribute.customPath && (this.cache = new CustomPath2D(), attribute.customPath(this.cache, this));
|
|
14140
|
-
}
|
|
14141
|
-
needUpdateTags(keys) {
|
|
14142
|
-
return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);
|
|
14143
|
-
}
|
|
14144
|
-
needUpdateTag(key) {
|
|
14145
|
-
return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);
|
|
14146
|
-
}
|
|
14147
|
-
toCustomPath() {
|
|
14148
|
-
return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), 0, 0);
|
|
14149
|
-
}
|
|
14150
|
-
clone() {
|
|
14151
|
-
return new Path(Object.assign({}, this.attribute));
|
|
14152
|
-
}
|
|
14153
|
-
getNoWorkAnimateAttr() {
|
|
14154
|
-
return Path.NOWORK_ANIMATE_ATTR;
|
|
14155
|
-
}
|
|
14156
|
-
}
|
|
14157
|
-
Path.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14158
|
-
path: 1,
|
|
14159
|
-
customPath: 1
|
|
14160
|
-
}, NOWORK_ANIMATE_ATTR);
|
|
14161
|
-
function createPath(attributes) {
|
|
14162
|
-
return new Path(attributes);
|
|
14163
|
-
}
|
|
14164
|
-
|
|
14165
|
-
const AREA_UPDATE_TAG_KEY = ["segments", "points", "curveType", "curveTension", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14166
|
-
class Area extends Graphic {
|
|
14167
|
-
constructor(params) {
|
|
14168
|
-
super(params), this.type = "area", this.numberType = AREA_NUMBER_TYPE;
|
|
14169
|
-
}
|
|
14170
|
-
isValid() {
|
|
14171
|
-
return super.isValid() && this._isValid();
|
|
14172
|
-
}
|
|
14173
|
-
_isValid() {
|
|
14174
|
-
if (this.pathProxy) return !0;
|
|
14175
|
-
const {
|
|
14176
|
-
points: points,
|
|
14177
|
-
segments: segments
|
|
14178
|
-
} = this.attribute;
|
|
14179
|
-
return segments ? 0 !== segments.length : !!points && 0 !== points.length;
|
|
14180
|
-
}
|
|
14181
|
-
getGraphicTheme() {
|
|
14182
|
-
return getTheme(this).area;
|
|
14183
|
-
}
|
|
14184
|
-
updateAABBBounds(attribute, areaTheme, aabbBounds) {
|
|
14185
|
-
this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14186
|
-
const {
|
|
14187
|
-
lineJoin = areaTheme.lineJoin
|
|
14188
|
-
} = attribute;
|
|
14189
|
-
return application.graphicService.transformAABBBounds(attribute, aabbBounds, areaTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14190
|
-
}
|
|
14191
|
-
updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds, graphic) {
|
|
14192
|
-
const {
|
|
14193
|
-
points = areaTheme.points
|
|
14194
|
-
} = attribute,
|
|
14195
|
-
b = aabbBounds;
|
|
14196
|
-
return points.forEach(p => {
|
|
14197
|
-
var _a, _b;
|
|
14198
|
-
b.add(p.x, p.y), b.add(null !== (_a = p.x1) && void 0 !== _a ? _a : p.x, null !== (_b = p.y1) && void 0 !== _b ? _b : p.y);
|
|
14199
|
-
}), b;
|
|
14200
|
-
}
|
|
14201
|
-
updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic) {
|
|
14202
|
-
const {
|
|
14203
|
-
segments = areaTheme.segments
|
|
14204
|
-
} = attribute,
|
|
14205
|
-
b = aabbBounds;
|
|
14206
|
-
return segments.forEach(s => {
|
|
14207
|
-
s.points.forEach(p => {
|
|
14208
|
-
var _a, _b;
|
|
14209
|
-
b.add(p.x, p.y), b.add(null !== (_a = p.x1) && void 0 !== _a ? _a : p.x, null !== (_b = p.y1) && void 0 !== _b ? _b : p.y);
|
|
14210
|
-
});
|
|
14211
|
-
}), b;
|
|
14212
|
-
}
|
|
14213
|
-
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
14214
|
-
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
14215
|
-
}
|
|
14216
|
-
needUpdateTags(keys) {
|
|
14217
|
-
return super.needUpdateTags(keys, AREA_UPDATE_TAG_KEY);
|
|
14218
|
-
}
|
|
14219
|
-
needUpdateTag(key) {
|
|
14220
|
-
return super.needUpdateTag(key, AREA_UPDATE_TAG_KEY);
|
|
14221
|
-
}
|
|
14222
|
-
toCustomPath() {
|
|
14223
|
-
const path = new CustomPath2D(),
|
|
14224
|
-
attribute = this.attribute,
|
|
14225
|
-
segments = attribute.segments,
|
|
14226
|
-
parsePoints = points => {
|
|
14227
|
-
if (points && points.length) {
|
|
14228
|
-
let isFirst = !0;
|
|
14229
|
-
const basePoints = [];
|
|
14230
|
-
if (points.forEach(point => {
|
|
14231
|
-
var _a, _b;
|
|
14232
|
-
!1 !== point.defined && (isFirst ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y), basePoints.push({
|
|
14233
|
-
x: null !== (_a = point.x1) && void 0 !== _a ? _a : point.x,
|
|
14234
|
-
y: null !== (_b = point.y1) && void 0 !== _b ? _b : point.y
|
|
14235
|
-
}), isFirst = !1);
|
|
14236
|
-
}), basePoints.length) {
|
|
14237
|
-
for (let i = basePoints.length - 1; i >= 0; i--) path.lineTo(basePoints[i].x, basePoints[i].y);
|
|
14238
|
-
path.closePath();
|
|
14239
|
-
}
|
|
14240
|
-
}
|
|
14241
|
-
};
|
|
14242
|
-
return attribute.points ? parsePoints(attribute.points) : segments && segments.length && segments.forEach(seg => {
|
|
14243
|
-
parsePoints(seg.points);
|
|
14244
|
-
}), path;
|
|
14402
|
+
this._frameCache = frame;
|
|
14245
14403
|
}
|
|
14246
14404
|
clone() {
|
|
14247
|
-
return new
|
|
14405
|
+
return new RichText(Object.assign({}, this.attribute));
|
|
14406
|
+
}
|
|
14407
|
+
setStage(stage, layer) {
|
|
14408
|
+
super.setStage(stage, layer);
|
|
14409
|
+
this.getFrameCache().icons.forEach(icon => {
|
|
14410
|
+
icon.setStage(stage, layer);
|
|
14411
|
+
});
|
|
14412
|
+
}
|
|
14413
|
+
bindIconEvent() {
|
|
14414
|
+
this.addEventListener("pointermove", e => {
|
|
14415
|
+
const pickedIcon = this.pickIcon(e.global);
|
|
14416
|
+
pickedIcon && pickedIcon === this._currentHoverIcon || (pickedIcon ? this.setAttribute("hoverIconId", pickedIcon.richtextId) : !pickedIcon && this._currentHoverIcon && this.setAttribute("hoverIconId", void 0));
|
|
14417
|
+
}), this.addEventListener("pointerleave", e => {
|
|
14418
|
+
this._currentHoverIcon && this.setAttribute("hoverIconId", void 0);
|
|
14419
|
+
});
|
|
14420
|
+
}
|
|
14421
|
+
updateHoverIconState(pickedIcon) {
|
|
14422
|
+
var _a, _b, _c, _d, _e;
|
|
14423
|
+
pickedIcon ? (null === (_a = this._currentHoverIcon) || void 0 === _a || _a.setHoverState(!1), this._currentHoverIcon = pickedIcon, this._currentHoverIcon.setHoverState(!0), null === (_b = this.stage) || void 0 === _b || _b.setCursor(pickedIcon.attribute.cursor), null === (_c = this.stage) || void 0 === _c || _c.renderNextFrame()) : (this._currentHoverIcon.setHoverState(!1), this._currentHoverIcon = null, null === (_d = this.stage) || void 0 === _d || _d.setCursor(), null === (_e = this.stage) || void 0 === _e || _e.renderNextFrame());
|
|
14424
|
+
}
|
|
14425
|
+
pickIcon(point) {
|
|
14426
|
+
const frameCache = this.getFrameCache(),
|
|
14427
|
+
{
|
|
14428
|
+
e: x,
|
|
14429
|
+
f: y
|
|
14430
|
+
} = this.globalTransMatrix;
|
|
14431
|
+
let pickIcon;
|
|
14432
|
+
return frameCache.icons.forEach((icon, key) => {
|
|
14433
|
+
var _a, _b;
|
|
14434
|
+
const bounds = icon.AABBBounds.clone();
|
|
14435
|
+
bounds.translate(icon._marginArray[3], icon._marginArray[0]), bounds.containsPoint({
|
|
14436
|
+
x: point.x - x,
|
|
14437
|
+
y: point.y - y
|
|
14438
|
+
}) && (pickIcon = icon, pickIcon.globalX = (null !== (_a = pickIcon.attribute.x) && void 0 !== _a ? _a : 0) + x + icon._marginArray[3], pickIcon.globalY = (null !== (_b = pickIcon.attribute.y) && void 0 !== _b ? _b : 0) + y + icon._marginArray[0]);
|
|
14439
|
+
}), pickIcon;
|
|
14248
14440
|
}
|
|
14249
14441
|
getNoWorkAnimateAttr() {
|
|
14250
|
-
return
|
|
14442
|
+
return RichText.NOWORK_ANIMATE_ATTR;
|
|
14251
14443
|
}
|
|
14252
14444
|
}
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14445
|
+
RichText.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14446
|
+
ellipsis: 1,
|
|
14447
|
+
wordBreak: 1,
|
|
14448
|
+
verticalDirection: 1,
|
|
14449
|
+
textAlign: 1,
|
|
14450
|
+
textBaseline: 1,
|
|
14451
|
+
textConfig: 1,
|
|
14452
|
+
layoutDirection: 1
|
|
14256
14453
|
}, NOWORK_ANIMATE_ATTR);
|
|
14257
|
-
function
|
|
14258
|
-
return new
|
|
14454
|
+
function createRichText(attributes) {
|
|
14455
|
+
return new RichText(attributes);
|
|
14259
14456
|
}
|
|
14260
14457
|
|
|
14261
|
-
const
|
|
14262
|
-
class
|
|
14458
|
+
const PATH_UPDATE_TAG_KEY = ["path", "customPath", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14459
|
+
class Path extends Graphic {
|
|
14263
14460
|
constructor(params) {
|
|
14264
|
-
super(params), this.type = "
|
|
14461
|
+
super(params), this.type = "path", this.numberType = PATH_NUMBER_TYPE;
|
|
14462
|
+
}
|
|
14463
|
+
get pathShape() {
|
|
14464
|
+
return this.tryUpdateAABBBounds(), this.getParsedPathShape();
|
|
14265
14465
|
}
|
|
14266
14466
|
isValid() {
|
|
14267
14467
|
return super.isValid() && this._isValid();
|
|
14268
14468
|
}
|
|
14269
14469
|
_isValid() {
|
|
14270
14470
|
const {
|
|
14271
|
-
|
|
14272
|
-
endAngle: endAngle,
|
|
14273
|
-
outerRadius: outerRadius,
|
|
14274
|
-
innerRadius: innerRadius
|
|
14275
|
-
} = this.attribute;
|
|
14276
|
-
return this._validNumber(startAngle) && this._validNumber(endAngle) && this._validNumber(outerRadius) && this._validNumber(innerRadius);
|
|
14277
|
-
}
|
|
14278
|
-
getParsedCornerRadius() {
|
|
14279
|
-
const arcTheme = this.getGraphicTheme(),
|
|
14280
|
-
{
|
|
14281
|
-
cornerRadius = arcTheme.cornerRadius,
|
|
14282
|
-
innerPadding = arcTheme.innerPadding,
|
|
14283
|
-
outerPadding = arcTheme.outerPadding
|
|
14284
|
-
} = this.attribute;
|
|
14285
|
-
let {
|
|
14286
|
-
outerRadius = arcTheme.outerRadius,
|
|
14287
|
-
innerRadius = arcTheme.innerRadius
|
|
14288
|
-
} = this.attribute;
|
|
14289
|
-
if (outerRadius += outerPadding, innerRadius -= innerPadding, 0 === cornerRadius || "0%" === cornerRadius) return 0;
|
|
14290
|
-
const deltaRadius = Math.abs(outerRadius - innerRadius),
|
|
14291
|
-
parseCR = cornerRadius => Math.min(isNumber$1(cornerRadius, !0) ? cornerRadius : deltaRadius * parseFloat(cornerRadius) / 100, deltaRadius / 2);
|
|
14292
|
-
if (isArray$1(cornerRadius)) {
|
|
14293
|
-
const crList = cornerRadius.map(cr => parseCR(cr) || 0);
|
|
14294
|
-
return 0 === crList.length ? [crList[0], crList[0], crList[0], crList[0]] : 2 === crList.length ? [crList[0], crList[1], crList[0], crList[1]] : (3 === crList.length && crList.push(0), crList);
|
|
14295
|
-
}
|
|
14296
|
-
return parseCR(cornerRadius);
|
|
14297
|
-
}
|
|
14298
|
-
getParsedAngle() {
|
|
14299
|
-
const arcTheme = this.getGraphicTheme();
|
|
14300
|
-
let {
|
|
14301
|
-
startAngle = arcTheme.startAngle,
|
|
14302
|
-
endAngle = arcTheme.endAngle
|
|
14471
|
+
path: path
|
|
14303
14472
|
} = this.attribute;
|
|
14304
|
-
|
|
14305
|
-
cap = arcTheme.cap
|
|
14306
|
-
} = this.attribute,
|
|
14307
|
-
sign = endAngle - startAngle >= 0 ? 1 : -1,
|
|
14308
|
-
deltaAngle = endAngle - startAngle;
|
|
14309
|
-
if (startAngle = clampAngleByRadian(startAngle), endAngle = startAngle + deltaAngle, cap && abs(deltaAngle) < pi2 - epsilon) {
|
|
14310
|
-
let startCap = 1,
|
|
14311
|
-
endCap = 1;
|
|
14312
|
-
cap.length && (startCap = Number(cap[0]), endCap = Number(cap[1]));
|
|
14313
|
-
let {
|
|
14314
|
-
outerRadius = arcTheme.outerRadius,
|
|
14315
|
-
innerRadius = arcTheme.innerRadius
|
|
14316
|
-
} = this.attribute;
|
|
14317
|
-
const {
|
|
14318
|
-
outerPadding = arcTheme.outerPadding,
|
|
14319
|
-
innerPadding = arcTheme.innerPadding
|
|
14320
|
-
} = this.attribute;
|
|
14321
|
-
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
14322
|
-
const capWidth = Math.abs(outerRadius - innerRadius) / 2,
|
|
14323
|
-
capAngle = capWidth / outerRadius;
|
|
14324
|
-
if (capWidth > epsilon && outerRadius > epsilon) return {
|
|
14325
|
-
startAngle: startAngle - sign * capAngle * startCap,
|
|
14326
|
-
endAngle: endAngle + sign * capAngle * endCap,
|
|
14327
|
-
sc: sign * capAngle * startCap,
|
|
14328
|
-
ec: sign * capAngle * endCap
|
|
14329
|
-
};
|
|
14330
|
-
}
|
|
14331
|
-
return {
|
|
14332
|
-
startAngle: startAngle,
|
|
14333
|
-
endAngle: endAngle
|
|
14334
|
-
};
|
|
14473
|
+
return null != path && "" !== path;
|
|
14335
14474
|
}
|
|
14336
|
-
|
|
14337
|
-
const
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
padAngle = arcTheme.padAngle
|
|
14342
|
-
} = this.attribute;
|
|
14343
|
-
let {
|
|
14344
|
-
outerRadius = arcTheme.outerRadius,
|
|
14345
|
-
innerRadius = arcTheme.innerRadius
|
|
14346
|
-
} = this.attribute;
|
|
14347
|
-
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
14348
|
-
const {
|
|
14349
|
-
padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
|
|
14350
|
-
} = this.attribute,
|
|
14351
|
-
deltaAngle = abs(endAngle - startAngle);
|
|
14352
|
-
let outerStartAngle = startAngle,
|
|
14353
|
-
outerEndAngle = endAngle,
|
|
14354
|
-
innerStartAngle = startAngle,
|
|
14355
|
-
innerEndAngle = endAngle;
|
|
14356
|
-
const halfPadAngle = padAngle / 2;
|
|
14357
|
-
let innerDeltaAngle = deltaAngle,
|
|
14358
|
-
outerDeltaAngle = deltaAngle;
|
|
14359
|
-
if (halfPadAngle > epsilon && padRadius > epsilon) {
|
|
14360
|
-
const sign = endAngle > startAngle ? 1 : -1;
|
|
14361
|
-
let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
|
|
14362
|
-
p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
|
|
14363
|
-
return (innerDeltaAngle -= 2 * p0) > epsilon ? (p0 *= sign, innerStartAngle += p0, innerEndAngle -= p0) : (innerDeltaAngle = 0, innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2), (outerDeltaAngle -= 2 * p1) > epsilon ? (p1 *= sign, outerStartAngle += p1, outerEndAngle -= p1) : (outerDeltaAngle = 0, outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2), {
|
|
14364
|
-
outerStartAngle: outerStartAngle,
|
|
14365
|
-
outerEndAngle: outerEndAngle,
|
|
14366
|
-
innerStartAngle: innerStartAngle,
|
|
14367
|
-
innerEndAngle: innerEndAngle,
|
|
14368
|
-
innerDeltaAngle: innerDeltaAngle,
|
|
14369
|
-
outerDeltaAngle: outerDeltaAngle
|
|
14370
|
-
};
|
|
14371
|
-
}
|
|
14372
|
-
return {
|
|
14373
|
-
outerStartAngle: outerStartAngle,
|
|
14374
|
-
outerEndAngle: outerEndAngle,
|
|
14375
|
-
innerStartAngle: innerStartAngle,
|
|
14376
|
-
innerEndAngle: innerEndAngle,
|
|
14377
|
-
innerDeltaAngle: innerDeltaAngle,
|
|
14378
|
-
outerDeltaAngle: outerDeltaAngle
|
|
14379
|
-
};
|
|
14475
|
+
getParsedPathShape() {
|
|
14476
|
+
const pathTheme = this.getGraphicTheme();
|
|
14477
|
+
if (!this.valid) return pathTheme.path;
|
|
14478
|
+
const attribute = this.attribute;
|
|
14479
|
+
return attribute.path instanceof CustomPath2D ? attribute.path : (isNil$1(this.cache) && this.doUpdatePathShape(), this.cache instanceof CustomPath2D ? this.cache : pathTheme.path);
|
|
14380
14480
|
}
|
|
14381
14481
|
getGraphicTheme() {
|
|
14382
|
-
return getTheme(this).
|
|
14482
|
+
return getTheme(this).path;
|
|
14383
14483
|
}
|
|
14384
|
-
updateAABBBounds(attribute,
|
|
14385
|
-
|
|
14484
|
+
updateAABBBounds(attribute, pathTheme, aabbBounds) {
|
|
14485
|
+
if (!this.updatePathProxyAABBBounds(aabbBounds)) {
|
|
14486
|
+
const pathShape = this.getParsedPathShape();
|
|
14487
|
+
aabbBounds.union(pathShape.getBounds());
|
|
14488
|
+
}
|
|
14386
14489
|
const {
|
|
14387
14490
|
tb1: tb1,
|
|
14388
14491
|
tb2: tb2
|
|
14389
14492
|
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14390
|
-
updateBoundsOfCommonOuterBorder(attribute,
|
|
14391
|
-
const {
|
|
14392
|
-
lineJoin = arcTheme.lineJoin
|
|
14393
|
-
} = attribute;
|
|
14394
|
-
return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14395
|
-
}
|
|
14396
|
-
updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
|
|
14397
|
-
let {
|
|
14398
|
-
outerRadius = arcTheme.outerRadius,
|
|
14399
|
-
innerRadius = arcTheme.innerRadius
|
|
14400
|
-
} = attribute;
|
|
14401
|
-
const {
|
|
14402
|
-
outerPadding = arcTheme.outerPadding,
|
|
14403
|
-
innerPadding = arcTheme.innerPadding
|
|
14404
|
-
} = attribute;
|
|
14405
|
-
return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
|
|
14406
|
-
}
|
|
14407
|
-
updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
|
|
14408
|
-
let {
|
|
14409
|
-
outerRadius = arcTheme.outerRadius,
|
|
14410
|
-
innerRadius = arcTheme.innerRadius
|
|
14411
|
-
} = attribute;
|
|
14493
|
+
updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
14412
14494
|
const {
|
|
14413
|
-
|
|
14414
|
-
innerPadding = arcTheme.innerPadding
|
|
14415
|
-
} = attribute;
|
|
14416
|
-
if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
|
|
14417
|
-
const temp = outerRadius;
|
|
14418
|
-
outerRadius = innerRadius, innerRadius = temp;
|
|
14419
|
-
}
|
|
14420
|
-
let {
|
|
14421
|
-
endAngle = arcTheme.endAngle,
|
|
14422
|
-
startAngle = arcTheme.startAngle
|
|
14495
|
+
lineJoin = pathTheme.lineJoin
|
|
14423
14496
|
} = attribute;
|
|
14424
|
-
|
|
14425
|
-
const temp = startAngle;
|
|
14426
|
-
startAngle = endAngle, endAngle = temp;
|
|
14427
|
-
}
|
|
14428
|
-
return outerRadius <= epsilon ? aabbBounds.set(0, 0, 0, 0) : Math.abs(endAngle - startAngle) > pi2 - epsilon ? aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius) : (circleBounds(startAngle, endAngle, outerRadius, aabbBounds), circleBounds(startAngle, endAngle, innerRadius, aabbBounds)), aabbBounds;
|
|
14429
|
-
}
|
|
14430
|
-
needUpdateTags(keys) {
|
|
14431
|
-
return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
|
|
14432
|
-
}
|
|
14433
|
-
needUpdateTag(key) {
|
|
14434
|
-
return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
|
|
14435
|
-
}
|
|
14436
|
-
toCustomPath() {
|
|
14437
|
-
var _a, _b, _c, _d;
|
|
14438
|
-
const attribute = this.attribute,
|
|
14439
|
-
{
|
|
14440
|
-
startAngle: startAngle,
|
|
14441
|
-
endAngle: endAngle
|
|
14442
|
-
} = this.getParsedAngle();
|
|
14443
|
-
let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
|
|
14444
|
-
outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
|
|
14445
|
-
const deltaAngle = abs(endAngle - startAngle),
|
|
14446
|
-
clockwise = endAngle > startAngle;
|
|
14447
|
-
if (outerRadius < innerRadius) {
|
|
14448
|
-
const temp = outerRadius;
|
|
14449
|
-
outerRadius = innerRadius, innerRadius = temp;
|
|
14450
|
-
}
|
|
14451
|
-
const path = new CustomPath2D();
|
|
14452
|
-
if (outerRadius <= epsilon) path.moveTo(0, 0);else if (deltaAngle >= pi2 - epsilon) path.moveTo(0 + outerRadius * cos(startAngle), 0 + outerRadius * sin(startAngle)), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), innerRadius > epsilon && (path.moveTo(0 + innerRadius * cos(endAngle), 0 + innerRadius * sin(endAngle)), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise));else {
|
|
14453
|
-
const xors = outerRadius * cos(startAngle),
|
|
14454
|
-
yors = outerRadius * sin(startAngle),
|
|
14455
|
-
xire = innerRadius * cos(endAngle),
|
|
14456
|
-
yire = innerRadius * sin(endAngle);
|
|
14457
|
-
path.moveTo(0 + xors, 0 + yors), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), path.lineTo(0 + xire, 0 + yire), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise), path.closePath();
|
|
14458
|
-
}
|
|
14459
|
-
return path;
|
|
14497
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14460
14498
|
}
|
|
14461
|
-
|
|
14462
|
-
return
|
|
14499
|
+
doUpdateAABBBounds(full) {
|
|
14500
|
+
return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
|
|
14463
14501
|
}
|
|
14464
|
-
|
|
14465
|
-
|
|
14502
|
+
doUpdatePathShape() {
|
|
14503
|
+
const attribute = this.attribute;
|
|
14504
|
+
isString$1(attribute.path, !0) ? this.cache = new CustomPath2D().fromString(attribute.path) : attribute.customPath && (this.cache = new CustomPath2D(), attribute.customPath(this.cache, this));
|
|
14466
14505
|
}
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
cap: 1
|
|
14470
|
-
}, NOWORK_ANIMATE_ATTR);
|
|
14471
|
-
function createArc(attributes) {
|
|
14472
|
-
return new Arc(attributes);
|
|
14473
|
-
}
|
|
14474
|
-
|
|
14475
|
-
class Arc3d extends Arc {
|
|
14476
|
-
constructor(params) {
|
|
14477
|
-
super(params), this.type = "arc3d", this.numberType = ARC3D_NUMBER_TYPE;
|
|
14506
|
+
needUpdateTags(keys) {
|
|
14507
|
+
return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);
|
|
14478
14508
|
}
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
return aabbBounds.setValue(-r, -r, r, r), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, !1, this), aabbBounds;
|
|
14509
|
+
needUpdateTag(key) {
|
|
14510
|
+
return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);
|
|
14511
|
+
}
|
|
14512
|
+
toCustomPath() {
|
|
14513
|
+
return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), 0, 0);
|
|
14514
|
+
}
|
|
14515
|
+
clone() {
|
|
14516
|
+
return new Path(Object.assign({}, this.attribute));
|
|
14488
14517
|
}
|
|
14489
14518
|
getNoWorkAnimateAttr() {
|
|
14490
|
-
return
|
|
14519
|
+
return Path.NOWORK_ANIMATE_ATTR;
|
|
14491
14520
|
}
|
|
14492
14521
|
}
|
|
14493
|
-
|
|
14494
|
-
|
|
14522
|
+
Path.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14523
|
+
path: 1,
|
|
14524
|
+
customPath: 1
|
|
14495
14525
|
}, NOWORK_ANIMATE_ATTR);
|
|
14496
|
-
function
|
|
14497
|
-
return new
|
|
14526
|
+
function createPath(attributes) {
|
|
14527
|
+
return new Path(attributes);
|
|
14498
14528
|
}
|
|
14499
14529
|
|
|
14500
|
-
const
|
|
14501
|
-
class
|
|
14530
|
+
const AREA_UPDATE_TAG_KEY = ["segments", "points", "curveType", "curveTension", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14531
|
+
class Area extends Graphic {
|
|
14502
14532
|
constructor(params) {
|
|
14503
|
-
super(params), this.type = "
|
|
14533
|
+
super(params), this.type = "area", this.numberType = AREA_NUMBER_TYPE;
|
|
14504
14534
|
}
|
|
14505
14535
|
isValid() {
|
|
14506
14536
|
return super.isValid() && this._isValid();
|
|
14507
14537
|
}
|
|
14508
14538
|
_isValid() {
|
|
14539
|
+
if (this.pathProxy) return !0;
|
|
14509
14540
|
const {
|
|
14510
|
-
points: points
|
|
14541
|
+
points: points,
|
|
14542
|
+
segments: segments
|
|
14511
14543
|
} = this.attribute;
|
|
14512
|
-
return points && points.length
|
|
14544
|
+
return segments ? 0 !== segments.length : !!points && 0 !== points.length;
|
|
14513
14545
|
}
|
|
14514
14546
|
getGraphicTheme() {
|
|
14515
|
-
return getTheme(this).
|
|
14547
|
+
return getTheme(this).area;
|
|
14516
14548
|
}
|
|
14517
|
-
updateAABBBounds(attribute,
|
|
14518
|
-
this.updatePathProxyAABBBounds(aabbBounds) || this.
|
|
14549
|
+
updateAABBBounds(attribute, areaTheme, aabbBounds) {
|
|
14550
|
+
this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14519
14551
|
const {
|
|
14520
|
-
lineJoin =
|
|
14552
|
+
lineJoin = areaTheme.lineJoin
|
|
14521
14553
|
} = attribute;
|
|
14522
|
-
return application.graphicService.transformAABBBounds(attribute, aabbBounds,
|
|
14554
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, areaTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14523
14555
|
}
|
|
14524
|
-
|
|
14556
|
+
updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds, graphic) {
|
|
14525
14557
|
const {
|
|
14526
|
-
|
|
14527
|
-
|
|
14558
|
+
points = areaTheme.points
|
|
14559
|
+
} = attribute,
|
|
14560
|
+
b = aabbBounds;
|
|
14528
14561
|
return points.forEach(p => {
|
|
14529
|
-
|
|
14530
|
-
|
|
14562
|
+
var _a, _b;
|
|
14563
|
+
b.add(p.x, p.y), b.add(null !== (_a = p.x1) && void 0 !== _a ? _a : p.x, null !== (_b = p.y1) && void 0 !== _b ? _b : p.y);
|
|
14564
|
+
}), b;
|
|
14565
|
+
}
|
|
14566
|
+
updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic) {
|
|
14567
|
+
const {
|
|
14568
|
+
segments = areaTheme.segments
|
|
14569
|
+
} = attribute,
|
|
14570
|
+
b = aabbBounds;
|
|
14571
|
+
return segments.forEach(s => {
|
|
14572
|
+
s.points.forEach(p => {
|
|
14573
|
+
var _a, _b;
|
|
14574
|
+
b.add(p.x, p.y), b.add(null !== (_a = p.x1) && void 0 !== _a ? _a : p.x, null !== (_b = p.y1) && void 0 !== _b ? _b : p.y);
|
|
14575
|
+
});
|
|
14576
|
+
}), b;
|
|
14531
14577
|
}
|
|
14532
14578
|
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
14533
14579
|
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
14534
14580
|
}
|
|
14535
14581
|
needUpdateTags(keys) {
|
|
14536
|
-
return super.needUpdateTags(keys,
|
|
14582
|
+
return super.needUpdateTags(keys, AREA_UPDATE_TAG_KEY);
|
|
14537
14583
|
}
|
|
14538
14584
|
needUpdateTag(key) {
|
|
14539
|
-
return super.needUpdateTag(key,
|
|
14585
|
+
return super.needUpdateTag(key, AREA_UPDATE_TAG_KEY);
|
|
14540
14586
|
}
|
|
14541
14587
|
toCustomPath() {
|
|
14542
|
-
const
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14588
|
+
const path = new CustomPath2D(),
|
|
14589
|
+
attribute = this.attribute,
|
|
14590
|
+
segments = attribute.segments,
|
|
14591
|
+
parsePoints = points => {
|
|
14592
|
+
if (points && points.length) {
|
|
14593
|
+
let isFirst = !0;
|
|
14594
|
+
const basePoints = [];
|
|
14595
|
+
if (points.forEach(point => {
|
|
14596
|
+
var _a, _b;
|
|
14597
|
+
!1 !== point.defined && (isFirst ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y), basePoints.push({
|
|
14598
|
+
x: null !== (_a = point.x1) && void 0 !== _a ? _a : point.x,
|
|
14599
|
+
y: null !== (_b = point.y1) && void 0 !== _b ? _b : point.y
|
|
14600
|
+
}), isFirst = !1);
|
|
14601
|
+
}), basePoints.length) {
|
|
14602
|
+
for (let i = basePoints.length - 1; i >= 0; i--) path.lineTo(basePoints[i].x, basePoints[i].y);
|
|
14603
|
+
path.closePath();
|
|
14604
|
+
}
|
|
14605
|
+
}
|
|
14606
|
+
};
|
|
14607
|
+
return attribute.points ? parsePoints(attribute.points) : segments && segments.length && segments.forEach(seg => {
|
|
14608
|
+
parsePoints(seg.points);
|
|
14609
|
+
}), path;
|
|
14547
14610
|
}
|
|
14548
14611
|
clone() {
|
|
14549
|
-
return new
|
|
14612
|
+
return new Area(Object.assign({}, this.attribute));
|
|
14550
14613
|
}
|
|
14551
14614
|
getNoWorkAnimateAttr() {
|
|
14552
|
-
return
|
|
14615
|
+
return Area.NOWORK_ANIMATE_ATTR;
|
|
14553
14616
|
}
|
|
14554
14617
|
}
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14618
|
+
Area.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14619
|
+
segments: 1,
|
|
14620
|
+
curveType: 1
|
|
14621
|
+
}, NOWORK_ANIMATE_ATTR);
|
|
14622
|
+
function createArea(attributes) {
|
|
14623
|
+
return new Area(attributes);
|
|
14558
14624
|
}
|
|
14559
14625
|
|
|
14560
|
-
|
|
14626
|
+
const ARC_UPDATE_TAG_KEY = ["innerRadius", "outerRadius", "startAngle", "endAngle", "cornerRadius", "padAngle", "padRadius", "cap", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14627
|
+
class Arc extends Graphic {
|
|
14561
14628
|
constructor(params) {
|
|
14562
|
-
super(params), this.type = "
|
|
14629
|
+
super(params), this.type = "arc", this.numberType = ARC_NUMBER_TYPE;
|
|
14563
14630
|
}
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
if (!stage || !stage.camera) return aabbBounds;
|
|
14567
|
-
return this.findFace().vertices.forEach(v => {
|
|
14568
|
-
const x = v[0],
|
|
14569
|
-
y = v[1];
|
|
14570
|
-
aabbBounds.add(x, y);
|
|
14571
|
-
}), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, !1, this), aabbBounds;
|
|
14631
|
+
isValid() {
|
|
14632
|
+
return super.isValid() && this._isValid();
|
|
14572
14633
|
}
|
|
14573
|
-
|
|
14634
|
+
_isValid() {
|
|
14574
14635
|
const {
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
if (find) break;
|
|
14636
|
+
startAngle: startAngle,
|
|
14637
|
+
endAngle: endAngle,
|
|
14638
|
+
outerRadius: outerRadius,
|
|
14639
|
+
innerRadius: innerRadius
|
|
14640
|
+
} = this.attribute;
|
|
14641
|
+
return this._validNumber(startAngle) && this._validNumber(endAngle) && this._validNumber(outerRadius) && this._validNumber(innerRadius);
|
|
14642
|
+
}
|
|
14643
|
+
getParsedCornerRadius() {
|
|
14644
|
+
const arcTheme = this.getGraphicTheme(),
|
|
14645
|
+
{
|
|
14646
|
+
cornerRadius = arcTheme.cornerRadius,
|
|
14647
|
+
innerPadding = arcTheme.innerPadding,
|
|
14648
|
+
outerPadding = arcTheme.outerPadding
|
|
14649
|
+
} = this.attribute;
|
|
14650
|
+
let {
|
|
14651
|
+
outerRadius = arcTheme.outerRadius,
|
|
14652
|
+
innerRadius = arcTheme.innerRadius
|
|
14653
|
+
} = this.attribute;
|
|
14654
|
+
if (outerRadius += outerPadding, innerRadius -= innerPadding, 0 === cornerRadius || "0%" === cornerRadius) return 0;
|
|
14655
|
+
const deltaRadius = Math.abs(outerRadius - innerRadius),
|
|
14656
|
+
parseCR = cornerRadius => Math.min(isNumber$1(cornerRadius, !0) ? cornerRadius : deltaRadius * parseFloat(cornerRadius) / 100, deltaRadius / 2);
|
|
14657
|
+
if (isArray$1(cornerRadius)) {
|
|
14658
|
+
const crList = cornerRadius.map(cr => parseCR(cr) || 0);
|
|
14659
|
+
return 0 === crList.length ? [crList[0], crList[0], crList[0], crList[0]] : 2 === crList.length ? [crList[0], crList[1], crList[0], crList[1]] : (3 === crList.length && crList.push(0), crList);
|
|
14600
14660
|
}
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
|
|
14661
|
+
return parseCR(cornerRadius);
|
|
14662
|
+
}
|
|
14663
|
+
getParsedAngle() {
|
|
14664
|
+
const arcTheme = this.getGraphicTheme();
|
|
14665
|
+
let {
|
|
14666
|
+
startAngle = arcTheme.startAngle,
|
|
14667
|
+
endAngle = arcTheme.endAngle
|
|
14668
|
+
} = this.attribute;
|
|
14669
|
+
const {
|
|
14670
|
+
cap = arcTheme.cap
|
|
14671
|
+
} = this.attribute,
|
|
14672
|
+
sign = endAngle - startAngle >= 0 ? 1 : -1,
|
|
14673
|
+
deltaAngle = endAngle - startAngle;
|
|
14674
|
+
if (startAngle = clampAngleByRadian(startAngle), endAngle = startAngle + deltaAngle, cap && abs(deltaAngle) < pi2 - epsilon) {
|
|
14675
|
+
let startCap = 1,
|
|
14676
|
+
endCap = 1;
|
|
14677
|
+
cap.length && (startCap = Number(cap[0]), endCap = Number(cap[1]));
|
|
14678
|
+
let {
|
|
14679
|
+
outerRadius = arcTheme.outerRadius,
|
|
14680
|
+
innerRadius = arcTheme.innerRadius
|
|
14681
|
+
} = this.attribute;
|
|
14682
|
+
const {
|
|
14683
|
+
outerPadding = arcTheme.outerPadding,
|
|
14684
|
+
innerPadding = arcTheme.innerPadding
|
|
14685
|
+
} = this.attribute;
|
|
14686
|
+
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
14687
|
+
const capWidth = Math.abs(outerRadius - innerRadius) / 2,
|
|
14688
|
+
capAngle = capWidth / outerRadius;
|
|
14689
|
+
if (capWidth > epsilon && outerRadius > epsilon) return {
|
|
14690
|
+
startAngle: startAngle - sign * capAngle * startCap,
|
|
14691
|
+
endAngle: endAngle + sign * capAngle * endCap,
|
|
14692
|
+
sc: sign * capAngle * startCap,
|
|
14693
|
+
ec: sign * capAngle * endCap
|
|
14694
|
+
};
|
|
14607
14695
|
}
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14696
|
+
return {
|
|
14697
|
+
startAngle: startAngle,
|
|
14698
|
+
endAngle: endAngle
|
|
14699
|
+
};
|
|
14700
|
+
}
|
|
14701
|
+
getParsePadAngle(startAngle, endAngle) {
|
|
14702
|
+
const arcTheme = this.getGraphicTheme(),
|
|
14703
|
+
{
|
|
14704
|
+
innerPadding = arcTheme.innerPadding,
|
|
14705
|
+
outerPadding = arcTheme.outerPadding,
|
|
14706
|
+
padAngle = arcTheme.padAngle
|
|
14707
|
+
} = this.attribute;
|
|
14708
|
+
let {
|
|
14709
|
+
outerRadius = arcTheme.outerRadius,
|
|
14710
|
+
innerRadius = arcTheme.innerRadius
|
|
14711
|
+
} = this.attribute;
|
|
14712
|
+
outerRadius += outerPadding, innerRadius -= innerPadding;
|
|
14713
|
+
const {
|
|
14714
|
+
padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
|
|
14715
|
+
} = this.attribute,
|
|
14716
|
+
deltaAngle = abs(endAngle - startAngle);
|
|
14717
|
+
let outerStartAngle = startAngle,
|
|
14718
|
+
outerEndAngle = endAngle,
|
|
14719
|
+
innerStartAngle = startAngle,
|
|
14720
|
+
innerEndAngle = endAngle;
|
|
14721
|
+
const halfPadAngle = padAngle / 2;
|
|
14722
|
+
let innerDeltaAngle = deltaAngle,
|
|
14723
|
+
outerDeltaAngle = deltaAngle;
|
|
14724
|
+
if (halfPadAngle > epsilon && padRadius > epsilon) {
|
|
14725
|
+
const sign = endAngle > startAngle ? 1 : -1;
|
|
14726
|
+
let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
|
|
14727
|
+
p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
|
|
14728
|
+
return (innerDeltaAngle -= 2 * p0) > epsilon ? (p0 *= sign, innerStartAngle += p0, innerEndAngle -= p0) : (innerDeltaAngle = 0, innerStartAngle = innerEndAngle = (startAngle + endAngle) / 2), (outerDeltaAngle -= 2 * p1) > epsilon ? (p1 *= sign, outerStartAngle += p1, outerEndAngle -= p1) : (outerDeltaAngle = 0, outerStartAngle = outerEndAngle = (startAngle + endAngle) / 2), {
|
|
14729
|
+
outerStartAngle: outerStartAngle,
|
|
14730
|
+
outerEndAngle: outerEndAngle,
|
|
14731
|
+
innerStartAngle: innerStartAngle,
|
|
14732
|
+
innerEndAngle: innerEndAngle,
|
|
14733
|
+
innerDeltaAngle: innerDeltaAngle,
|
|
14734
|
+
outerDeltaAngle: outerDeltaAngle
|
|
14735
|
+
};
|
|
14611
14736
|
}
|
|
14612
|
-
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14737
|
+
return {
|
|
14738
|
+
outerStartAngle: outerStartAngle,
|
|
14739
|
+
outerEndAngle: outerEndAngle,
|
|
14740
|
+
innerStartAngle: innerStartAngle,
|
|
14741
|
+
innerEndAngle: innerEndAngle,
|
|
14742
|
+
innerDeltaAngle: innerDeltaAngle,
|
|
14743
|
+
outerDeltaAngle: outerDeltaAngle
|
|
14616
14744
|
};
|
|
14617
|
-
return pointsMap.forEach(p => {
|
|
14618
|
-
faces.vertices.push([p.p.x, p.p.y, p.d]);
|
|
14619
|
-
}), faces.polygons.push({
|
|
14620
|
-
polygon: [0, 4, 5, 1],
|
|
14621
|
-
normal: [0, -1, 0]
|
|
14622
|
-
}), faces.polygons.push({
|
|
14623
|
-
polygon: [7, 6, 2, 3],
|
|
14624
|
-
normal: [0, 1, 0]
|
|
14625
|
-
}), faces.polygons.push({
|
|
14626
|
-
polygon: [0, 4, 7, 3],
|
|
14627
|
-
normal: [-1, 0, 0]
|
|
14628
|
-
}), faces.polygons.push({
|
|
14629
|
-
polygon: [1, 5, 6, 2],
|
|
14630
|
-
normal: [1, 0, 0]
|
|
14631
|
-
}), faces.polygons.push({
|
|
14632
|
-
polygon: [0, 1, 2, 3],
|
|
14633
|
-
normal: [0, 0, -1]
|
|
14634
|
-
}), faces.polygons.push({
|
|
14635
|
-
polygon: [4, 5, 6, 7],
|
|
14636
|
-
normal: [0, 0, 1]
|
|
14637
|
-
}), faces.edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [3, 7], [1, 5], [2, 6]], faces;
|
|
14638
14745
|
}
|
|
14639
|
-
|
|
14640
|
-
return
|
|
14746
|
+
getGraphicTheme() {
|
|
14747
|
+
return getTheme(this).arc;
|
|
14641
14748
|
}
|
|
14642
|
-
|
|
14643
|
-
|
|
14749
|
+
updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
|
|
14750
|
+
this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
|
|
14751
|
+
const {
|
|
14752
|
+
tb1: tb1,
|
|
14753
|
+
tb2: tb2
|
|
14754
|
+
} = application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14755
|
+
updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
|
|
14756
|
+
const {
|
|
14757
|
+
lineJoin = arcTheme.lineJoin
|
|
14758
|
+
} = attribute;
|
|
14759
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14644
14760
|
}
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
y: 0
|
|
14656
|
-
}), this.type = "shadowroot", this.shadowHost = graphic;
|
|
14761
|
+
updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
|
|
14762
|
+
let {
|
|
14763
|
+
outerRadius = arcTheme.outerRadius,
|
|
14764
|
+
innerRadius = arcTheme.innerRadius
|
|
14765
|
+
} = attribute;
|
|
14766
|
+
const {
|
|
14767
|
+
outerPadding = arcTheme.outerPadding,
|
|
14768
|
+
innerPadding = arcTheme.innerPadding
|
|
14769
|
+
} = attribute;
|
|
14770
|
+
return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
|
|
14657
14771
|
}
|
|
14658
|
-
|
|
14659
|
-
|
|
14772
|
+
updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
|
|
14773
|
+
let {
|
|
14774
|
+
outerRadius = arcTheme.outerRadius,
|
|
14775
|
+
innerRadius = arcTheme.innerRadius
|
|
14776
|
+
} = attribute;
|
|
14777
|
+
const {
|
|
14778
|
+
outerPadding = arcTheme.outerPadding,
|
|
14779
|
+
innerPadding = arcTheme.innerPadding
|
|
14780
|
+
} = attribute;
|
|
14781
|
+
if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
|
|
14782
|
+
const temp = outerRadius;
|
|
14783
|
+
outerRadius = innerRadius, innerRadius = temp;
|
|
14784
|
+
}
|
|
14785
|
+
let {
|
|
14786
|
+
endAngle = arcTheme.endAngle,
|
|
14787
|
+
startAngle = arcTheme.startAngle
|
|
14788
|
+
} = attribute;
|
|
14789
|
+
if (startAngle > endAngle) {
|
|
14790
|
+
const temp = startAngle;
|
|
14791
|
+
startAngle = endAngle, endAngle = temp;
|
|
14792
|
+
}
|
|
14793
|
+
return outerRadius <= epsilon ? aabbBounds.set(0, 0, 0, 0) : Math.abs(endAngle - startAngle) > pi2 - epsilon ? aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius) : (circleBounds(startAngle, endAngle, outerRadius, aabbBounds), circleBounds(startAngle, endAngle, innerRadius, aabbBounds)), aabbBounds;
|
|
14660
14794
|
}
|
|
14661
|
-
|
|
14662
|
-
super.
|
|
14795
|
+
needUpdateTags(keys) {
|
|
14796
|
+
return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
|
|
14663
14797
|
}
|
|
14664
|
-
|
|
14665
|
-
super.
|
|
14798
|
+
needUpdateTag(key) {
|
|
14799
|
+
return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
|
|
14666
14800
|
}
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14801
|
+
toCustomPath() {
|
|
14802
|
+
var _a, _b, _c, _d;
|
|
14803
|
+
const attribute = this.attribute,
|
|
14804
|
+
{
|
|
14805
|
+
startAngle: startAngle,
|
|
14806
|
+
endAngle: endAngle
|
|
14807
|
+
} = this.getParsedAngle();
|
|
14808
|
+
let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
|
|
14809
|
+
outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
|
|
14810
|
+
const deltaAngle = abs(endAngle - startAngle),
|
|
14811
|
+
clockwise = endAngle > startAngle;
|
|
14812
|
+
if (outerRadius < innerRadius) {
|
|
14813
|
+
const temp = outerRadius;
|
|
14814
|
+
outerRadius = innerRadius, innerRadius = temp;
|
|
14672
14815
|
}
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14816
|
+
const path = new CustomPath2D();
|
|
14817
|
+
if (outerRadius <= epsilon) path.moveTo(0, 0);else if (deltaAngle >= pi2 - epsilon) path.moveTo(0 + outerRadius * cos(startAngle), 0 + outerRadius * sin(startAngle)), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), innerRadius > epsilon && (path.moveTo(0 + innerRadius * cos(endAngle), 0 + innerRadius * sin(endAngle)), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise));else {
|
|
14818
|
+
const xors = outerRadius * cos(startAngle),
|
|
14819
|
+
yors = outerRadius * sin(startAngle),
|
|
14820
|
+
xire = innerRadius * cos(endAngle),
|
|
14821
|
+
yire = innerRadius * sin(endAngle);
|
|
14822
|
+
path.moveTo(0 + xors, 0 + yors), path.arc(0, 0, outerRadius, startAngle, endAngle, !clockwise), path.lineTo(0 + xire, 0 + yire), path.arc(0, 0, innerRadius, endAngle, startAngle, clockwise), path.closePath();
|
|
14679
14823
|
}
|
|
14824
|
+
return path;
|
|
14680
14825
|
}
|
|
14681
|
-
|
|
14682
|
-
return
|
|
14683
|
-
}
|
|
14684
|
-
}
|
|
14685
|
-
function createShadowRoot(graphic) {
|
|
14686
|
-
return new ShadowRoot(graphic);
|
|
14687
|
-
}
|
|
14688
|
-
|
|
14689
|
-
class GraphicCreator {
|
|
14690
|
-
constructor() {
|
|
14691
|
-
this.store = new Map();
|
|
14692
|
-
}
|
|
14693
|
-
RegisterGraphicCreator(name, cb) {
|
|
14694
|
-
this.store.set(name, cb), this[name] = cb;
|
|
14826
|
+
clone() {
|
|
14827
|
+
return new Arc(Object.assign({}, this.attribute));
|
|
14695
14828
|
}
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
return cb ? cb(params) : null;
|
|
14829
|
+
getNoWorkAnimateAttr() {
|
|
14830
|
+
return Arc.NOWORK_ANIMATE_ATTR;
|
|
14699
14831
|
}
|
|
14700
14832
|
}
|
|
14701
|
-
|
|
14702
|
-
|
|
14703
|
-
|
|
14704
|
-
function
|
|
14705
|
-
return
|
|
14706
|
-
}
|
|
14707
|
-
function getRichTextBounds(params) {
|
|
14708
|
-
return richText || (richText = graphicCreator.CreateGraphic("richtext", {})), richText.setAttributes(params), richText.AABBBounds;
|
|
14833
|
+
Arc.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14834
|
+
cap: 1
|
|
14835
|
+
}, NOWORK_ANIMATE_ATTR);
|
|
14836
|
+
function createArc(attributes) {
|
|
14837
|
+
return new Arc(attributes);
|
|
14709
14838
|
}
|
|
14710
14839
|
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
z: 0,
|
|
14715
|
-
lastModelMatrix: null
|
|
14716
|
-
};
|
|
14717
|
-
class BaseRender {
|
|
14718
|
-
init(contributions) {
|
|
14719
|
-
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));
|
|
14720
|
-
}
|
|
14721
|
-
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
14722
|
-
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
14723
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
14724
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
14725
|
-
}
|
|
14726
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
14727
|
-
});
|
|
14728
|
-
}
|
|
14729
|
-
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
14730
|
-
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
14731
|
-
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
14732
|
-
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
14733
|
-
}
|
|
14734
|
-
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
14735
|
-
});
|
|
14736
|
-
}
|
|
14737
|
-
drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
14738
|
-
if (!graphic.pathProxy) return !1;
|
|
14739
|
-
const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
|
|
14740
|
-
{
|
|
14741
|
-
fill = themeAttributes.fill,
|
|
14742
|
-
stroke = themeAttributes.stroke,
|
|
14743
|
-
opacity = themeAttributes.opacity,
|
|
14744
|
-
fillOpacity = themeAttributes.fillOpacity,
|
|
14745
|
-
lineWidth = themeAttributes.lineWidth,
|
|
14746
|
-
strokeOpacity = themeAttributes.strokeOpacity,
|
|
14747
|
-
visible = themeAttributes.visible,
|
|
14748
|
-
x: originX = themeAttributes.x,
|
|
14749
|
-
y: originY = themeAttributes.y
|
|
14750
|
-
} = graphic.attribute,
|
|
14751
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
14752
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
14753
|
-
doFill = runFill(fill),
|
|
14754
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
14755
|
-
if (!visible) return !0;
|
|
14756
|
-
if (!doFill && !doStroke) return !0;
|
|
14757
|
-
if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
|
|
14758
|
-
context.beginPath();
|
|
14759
|
-
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
14760
|
-
return renderCommandList(path.commandList, context, x, y), context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes), this.beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, graphic.attribute, themeAttributes) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.stroke())), doFill && (fillCb ? fillCb(context, graphic.attribute, themeAttributes) : fVisible && (context.setCommonStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.fill())), this.afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), !0;
|
|
14840
|
+
class Arc3d extends Arc {
|
|
14841
|
+
constructor(params) {
|
|
14842
|
+
super(params), this.type = "arc3d", this.numberType = ARC3D_NUMBER_TYPE;
|
|
14761
14843
|
}
|
|
14762
|
-
|
|
14844
|
+
updateAABBBounds(attribute, arcTheme, aabbBounds) {
|
|
14845
|
+
const stage = this.stage;
|
|
14846
|
+
if (!stage || !stage.camera) return aabbBounds;
|
|
14763
14847
|
const {
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
lineWidth = defaultAttribute.lineWidth,
|
|
14770
|
-
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
14771
|
-
visible = defaultAttribute.visible
|
|
14772
|
-
} = graphic.attribute,
|
|
14773
|
-
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
14774
|
-
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
14775
|
-
doFill = runFill(fill, background),
|
|
14776
|
-
doStroke = runStroke(stroke, lineWidth);
|
|
14777
|
-
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
14778
|
-
fVisible: fVisible,
|
|
14779
|
-
sVisible: sVisible,
|
|
14780
|
-
doFill: doFill,
|
|
14781
|
-
doStroke: doStroke
|
|
14782
|
-
};
|
|
14848
|
+
outerRadius = arcTheme.outerRadius,
|
|
14849
|
+
height = 0
|
|
14850
|
+
} = attribute,
|
|
14851
|
+
r = outerRadius + height;
|
|
14852
|
+
return aabbBounds.setValue(-r, -r, r, r), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, !1, this), aabbBounds;
|
|
14783
14853
|
}
|
|
14784
|
-
|
|
14785
|
-
|
|
14786
|
-
const {
|
|
14787
|
-
x = graphicAttribute.x,
|
|
14788
|
-
y = graphicAttribute.y,
|
|
14789
|
-
z = graphicAttribute.z,
|
|
14790
|
-
scaleX = graphicAttribute.scaleX,
|
|
14791
|
-
scaleY = graphicAttribute.scaleY,
|
|
14792
|
-
angle = graphicAttribute.angle,
|
|
14793
|
-
postMatrix: postMatrix
|
|
14794
|
-
} = graphic.attribute,
|
|
14795
|
-
lastModelMatrix = context.modelMatrix,
|
|
14796
|
-
camera = context.camera;
|
|
14797
|
-
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
14798
|
-
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
14799
|
-
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
14800
|
-
if (shouldTransform3d) {
|
|
14801
|
-
const nextModelMatrix = mat4Allocate.allocate(),
|
|
14802
|
-
modelMatrix = mat4Allocate.allocate();
|
|
14803
|
-
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);
|
|
14804
|
-
}
|
|
14805
|
-
if (onlyTranslate && !lastModelMatrix) {
|
|
14806
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
14807
|
-
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
14808
|
-
} 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) {
|
|
14809
|
-
const point = graphic.getOffsetXY(graphicAttribute);
|
|
14810
|
-
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
14811
|
-
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
14812
|
-
return result;
|
|
14854
|
+
getNoWorkAnimateAttr() {
|
|
14855
|
+
return Arc3d.NOWORK_ANIMATE_ATTR;
|
|
14813
14856
|
}
|
|
14814
|
-
|
|
14815
|
-
|
|
14816
|
-
|
|
14817
|
-
|
|
14818
|
-
|
|
14819
|
-
|
|
14820
|
-
|
|
14821
|
-
|
|
14822
|
-
|
|
14823
|
-
|
|
14824
|
-
|
|
14825
|
-
|
|
14826
|
-
},
|
|
14827
|
-
_p2 = {
|
|
14828
|
-
x: width,
|
|
14829
|
-
y: 0
|
|
14830
|
-
},
|
|
14831
|
-
_p3 = {
|
|
14832
|
-
x: width,
|
|
14833
|
-
y: height
|
|
14834
|
-
};
|
|
14835
|
-
context.camera = null;
|
|
14836
|
-
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
14837
|
-
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
14838
|
-
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
14839
|
-
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
14840
|
-
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
14841
|
-
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,
|
|
14842
|
-
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;
|
|
14843
|
-
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
14844
|
-
}
|
|
14857
|
+
}
|
|
14858
|
+
Arc3d.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
14859
|
+
cap: 1
|
|
14860
|
+
}, NOWORK_ANIMATE_ATTR);
|
|
14861
|
+
function createArc3d(attributes) {
|
|
14862
|
+
return new Arc3d(attributes);
|
|
14863
|
+
}
|
|
14864
|
+
|
|
14865
|
+
const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14866
|
+
class Polygon extends Graphic {
|
|
14867
|
+
constructor(params) {
|
|
14868
|
+
super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
|
|
14845
14869
|
}
|
|
14846
|
-
|
|
14847
|
-
|
|
14870
|
+
isValid() {
|
|
14871
|
+
return super.isValid() && this._isValid();
|
|
14848
14872
|
}
|
|
14849
|
-
|
|
14850
|
-
const
|
|
14851
|
-
|
|
14873
|
+
_isValid() {
|
|
14874
|
+
const {
|
|
14875
|
+
points: points
|
|
14876
|
+
} = this.attribute;
|
|
14877
|
+
return points && points.length >= 2;
|
|
14852
14878
|
}
|
|
14853
|
-
|
|
14879
|
+
getGraphicTheme() {
|
|
14880
|
+
return getTheme(this).polygon;
|
|
14881
|
+
}
|
|
14882
|
+
updateAABBBounds(attribute, polygonTheme, aabbBounds) {
|
|
14883
|
+
this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds);
|
|
14854
14884
|
const {
|
|
14855
|
-
|
|
14856
|
-
} =
|
|
14857
|
-
|
|
14885
|
+
lineJoin = polygonTheme.lineJoin
|
|
14886
|
+
} = attribute;
|
|
14887
|
+
return application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, "miter" === lineJoin, this), aabbBounds;
|
|
14888
|
+
}
|
|
14889
|
+
updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds) {
|
|
14858
14890
|
const {
|
|
14859
|
-
|
|
14860
|
-
} =
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
|
|
14869
|
-
|
|
14870
|
-
|
|
14891
|
+
points = polygonTheme.points
|
|
14892
|
+
} = attribute;
|
|
14893
|
+
return points.forEach(p => {
|
|
14894
|
+
aabbBounds.add(p.x, p.y);
|
|
14895
|
+
}), aabbBounds;
|
|
14896
|
+
}
|
|
14897
|
+
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
14898
|
+
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
14899
|
+
}
|
|
14900
|
+
needUpdateTags(keys) {
|
|
14901
|
+
return super.needUpdateTags(keys, POLYGON_UPDATE_TAG_KEY);
|
|
14902
|
+
}
|
|
14903
|
+
needUpdateTag(key) {
|
|
14904
|
+
return super.needUpdateTag(key, POLYGON_UPDATE_TAG_KEY);
|
|
14905
|
+
}
|
|
14906
|
+
toCustomPath() {
|
|
14907
|
+
const points = this.attribute.points,
|
|
14908
|
+
path = new CustomPath2D();
|
|
14909
|
+
return points.forEach((point, index) => {
|
|
14910
|
+
0 === index ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y);
|
|
14911
|
+
}), path.closePath(), path;
|
|
14912
|
+
}
|
|
14913
|
+
clone() {
|
|
14914
|
+
return new Polygon(Object.assign({}, this.attribute));
|
|
14915
|
+
}
|
|
14916
|
+
getNoWorkAnimateAttr() {
|
|
14917
|
+
return Polygon.NOWORK_ANIMATE_ATTR;
|
|
14871
14918
|
}
|
|
14872
14919
|
}
|
|
14920
|
+
Polygon.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
14921
|
+
function createPolygon(attributes) {
|
|
14922
|
+
return new Polygon(attributes);
|
|
14923
|
+
}
|
|
14873
14924
|
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
|
|
14881
|
-
|
|
14882
|
-
|
|
14883
|
-
|
|
14884
|
-
|
|
14885
|
-
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14889
|
-
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
14897
|
-
|
|
14898
|
-
|
|
14899
|
-
|
|
14925
|
+
class Pyramid3d extends Polygon {
|
|
14926
|
+
constructor(params) {
|
|
14927
|
+
super(params), this.type = "pyramid3d", this.numberType = PYRAMID3D_NUMBER_TYPE;
|
|
14928
|
+
}
|
|
14929
|
+
updateAABBBounds(attribute, polygonTheme, aabbBounds) {
|
|
14930
|
+
const stage = this.stage;
|
|
14931
|
+
if (!stage || !stage.camera) return aabbBounds;
|
|
14932
|
+
return this.findFace().vertices.forEach(v => {
|
|
14933
|
+
const x = v[0],
|
|
14934
|
+
y = v[1];
|
|
14935
|
+
aabbBounds.add(x, y);
|
|
14936
|
+
}), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, !1, this), aabbBounds;
|
|
14937
|
+
}
|
|
14938
|
+
findFace() {
|
|
14939
|
+
const {
|
|
14940
|
+
points: points
|
|
14941
|
+
} = this.attribute,
|
|
14942
|
+
kList = points.map((p, i) => {
|
|
14943
|
+
const p1 = 3 === i ? points[0] : points[i + 1],
|
|
14944
|
+
dx = p.x - p1.x;
|
|
14945
|
+
return 0 === dx ? 0 : (p.y - p1.y) / dx;
|
|
14946
|
+
}),
|
|
14947
|
+
pointsMap = points.map(p => ({
|
|
14948
|
+
p: p,
|
|
14949
|
+
d: 0
|
|
14950
|
+
}));
|
|
14951
|
+
let find = !1,
|
|
14952
|
+
maxD = 0;
|
|
14953
|
+
for (let i = 0; i < kList.length - 1; i++) {
|
|
14954
|
+
for (let j = i + 1; j < kList.length; j++) {
|
|
14955
|
+
if (kList[i] === kList[j]) {
|
|
14956
|
+
find = !0;
|
|
14957
|
+
const d1 = PointService.distancePP(pointsMap[i].p, pointsMap[i + 1].p);
|
|
14958
|
+
pointsMap[i].d = d1, pointsMap[i + 1].d = d1, maxD = max(maxD, d1);
|
|
14959
|
+
const d2 = PointService.distancePP(pointsMap[j].p, pointsMap[j + 1].p);
|
|
14960
|
+
pointsMap[j].d = d2, pointsMap[j + 1].d = d2, maxD = max(maxD, d2);
|
|
14961
|
+
}
|
|
14962
|
+
if (find) break;
|
|
14963
|
+
}
|
|
14964
|
+
if (find) break;
|
|
14965
|
+
}
|
|
14966
|
+
for (let i = points.length - 1; i >= 0; i--) {
|
|
14967
|
+
const p = points[i];
|
|
14968
|
+
pointsMap.unshift({
|
|
14969
|
+
p: p,
|
|
14970
|
+
d: 0
|
|
14971
|
+
});
|
|
14972
|
+
}
|
|
14973
|
+
for (let i = 0; i < points.length; i++) {
|
|
14974
|
+
const delta = (maxD - pointsMap[i + points.length].d) / 2;
|
|
14975
|
+
pointsMap[i].d += delta, pointsMap[i + points.length].d += delta;
|
|
14976
|
+
}
|
|
14977
|
+
const faces = {
|
|
14978
|
+
polygons: [],
|
|
14979
|
+
vertices: [],
|
|
14980
|
+
edges: []
|
|
14981
|
+
};
|
|
14982
|
+
return pointsMap.forEach(p => {
|
|
14983
|
+
faces.vertices.push([p.p.x, p.p.y, p.d]);
|
|
14984
|
+
}), faces.polygons.push({
|
|
14985
|
+
polygon: [0, 4, 5, 1],
|
|
14986
|
+
normal: [0, -1, 0]
|
|
14987
|
+
}), faces.polygons.push({
|
|
14988
|
+
polygon: [7, 6, 2, 3],
|
|
14989
|
+
normal: [0, 1, 0]
|
|
14990
|
+
}), faces.polygons.push({
|
|
14991
|
+
polygon: [0, 4, 7, 3],
|
|
14992
|
+
normal: [-1, 0, 0]
|
|
14993
|
+
}), faces.polygons.push({
|
|
14994
|
+
polygon: [1, 5, 6, 2],
|
|
14995
|
+
normal: [1, 0, 0]
|
|
14996
|
+
}), faces.polygons.push({
|
|
14997
|
+
polygon: [0, 1, 2, 3],
|
|
14998
|
+
normal: [0, 0, -1]
|
|
14999
|
+
}), faces.polygons.push({
|
|
15000
|
+
polygon: [4, 5, 6, 7],
|
|
15001
|
+
normal: [0, 0, 1]
|
|
15002
|
+
}), faces.edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [3, 7], [1, 5], [2, 6]], faces;
|
|
14900
15003
|
}
|
|
14901
|
-
|
|
14902
|
-
|
|
14903
|
-
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
15004
|
+
_isValid() {
|
|
15005
|
+
return super._isValid() && 4 === this.attribute.points.length;
|
|
14904
15006
|
}
|
|
14905
|
-
|
|
14906
|
-
return
|
|
15007
|
+
getNoWorkAnimateAttr() {
|
|
15008
|
+
return Pyramid3d.NOWORK_ANIMATE_ATTR;
|
|
14907
15009
|
}
|
|
14908
|
-
|
|
14909
|
-
|
|
14910
|
-
|
|
14911
|
-
|
|
14912
|
-
|
|
14913
|
-
|
|
14914
|
-
|
|
14915
|
-
|
|
14916
|
-
|
|
14917
|
-
|
|
14918
|
-
|
|
14919
|
-
|
|
14920
|
-
orientation: orientation,
|
|
14921
|
-
colorStops: matchListing(matchColorStop)
|
|
14922
|
-
};
|
|
14923
|
-
});
|
|
15010
|
+
}
|
|
15011
|
+
Pyramid3d.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
15012
|
+
function createPyramid3d(attributes) {
|
|
15013
|
+
return new Pyramid3d(attributes);
|
|
15014
|
+
}
|
|
15015
|
+
|
|
15016
|
+
class ShadowRoot extends Group {
|
|
15017
|
+
constructor(graphic) {
|
|
15018
|
+
super({
|
|
15019
|
+
x: 0,
|
|
15020
|
+
y: 0
|
|
15021
|
+
}), this.type = "shadowroot", this.shadowHost = graphic;
|
|
14924
15022
|
}
|
|
14925
|
-
|
|
14926
|
-
|
|
15023
|
+
clearUpdateBoundTag() {
|
|
15024
|
+
super.clearUpdateBoundTag(), this.shadowHost && this.shadowHost.clearUpdateBoundTag();
|
|
14927
15025
|
}
|
|
14928
|
-
|
|
14929
|
-
|
|
15026
|
+
addUpdateBoundTag() {
|
|
15027
|
+
super.addUpdateBoundTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
|
|
14930
15028
|
}
|
|
14931
|
-
|
|
14932
|
-
|
|
14933
|
-
lookaheadCache,
|
|
14934
|
-
radialOrientation = matchRadialOrientation();
|
|
14935
|
-
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
|
|
15029
|
+
addUpdateShapeAndBoundsTag() {
|
|
15030
|
+
super.addUpdateShapeAndBoundsTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
|
|
14936
15031
|
}
|
|
14937
|
-
|
|
14938
|
-
let
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
}() || function () {
|
|
14943
|
-
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
14944
|
-
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
14945
|
-
return ellipse;
|
|
14946
|
-
}();
|
|
14947
|
-
if (radialType) radialType.at = matchAtPosition();else {
|
|
14948
|
-
const extent = matchExtentKeyword();
|
|
14949
|
-
if (extent) {
|
|
14950
|
-
radialType = extent;
|
|
14951
|
-
const positionAt = matchAtPosition();
|
|
14952
|
-
positionAt && (radialType.at = positionAt);
|
|
14953
|
-
} else {
|
|
14954
|
-
const defaultPosition = matchPositioning();
|
|
14955
|
-
defaultPosition && (radialType = {
|
|
14956
|
-
type: "default-radial",
|
|
14957
|
-
at: defaultPosition
|
|
14958
|
-
});
|
|
14959
|
-
}
|
|
15032
|
+
tryUpdateGlobalTransMatrix() {
|
|
15033
|
+
let clearTag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
|
|
15034
|
+
if (this.shouldUpdateGlobalMatrix()) {
|
|
15035
|
+
const m = this.transMatrix;
|
|
15036
|
+
this._globalTransMatrix ? this._globalTransMatrix.setValue(m.a, m.b, m.c, m.d, m.e, m.f) : this._globalTransMatrix = m.clone(), this.doUpdateGlobalMatrix(), clearTag && this.clearUpdateGlobalPositionTag();
|
|
14960
15037
|
}
|
|
14961
|
-
return
|
|
14962
|
-
}
|
|
14963
|
-
function matchExtentKeyword() {
|
|
14964
|
-
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
15038
|
+
return this._globalTransMatrix;
|
|
14965
15039
|
}
|
|
14966
|
-
|
|
14967
|
-
if (
|
|
14968
|
-
const
|
|
14969
|
-
|
|
15040
|
+
doUpdateGlobalMatrix() {
|
|
15041
|
+
if (this.shadowHost) {
|
|
15042
|
+
const parentMatrix = this.shadowHost.globalTransMatrix;
|
|
15043
|
+
this._globalTransMatrix.multiply(parentMatrix.a, parentMatrix.b, parentMatrix.c, parentMatrix.d, parentMatrix.e, parentMatrix.f);
|
|
14970
15044
|
}
|
|
14971
15045
|
}
|
|
14972
|
-
|
|
14973
|
-
|
|
14974
|
-
x: matchDistance(),
|
|
14975
|
-
y: matchDistance()
|
|
14976
|
-
};
|
|
14977
|
-
if (location.x || location.y) return {
|
|
14978
|
-
type: "position",
|
|
14979
|
-
value: location
|
|
14980
|
-
};
|
|
14981
|
-
}
|
|
14982
|
-
function matchListing(matcher) {
|
|
14983
|
-
let captures = matcher();
|
|
14984
|
-
const result = [];
|
|
14985
|
-
if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
|
|
14986
|
-
return result;
|
|
14987
|
-
}
|
|
14988
|
-
function matchColorStop() {
|
|
14989
|
-
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
14990
|
-
return color || error("Expected color definition"), color.length = matchDistance(), color;
|
|
14991
|
-
}
|
|
14992
|
-
function matchDistance() {
|
|
14993
|
-
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
14994
|
-
}
|
|
14995
|
-
function matchLength() {
|
|
14996
|
-
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
15046
|
+
tryUpdateGlobalAABBBounds() {
|
|
15047
|
+
return this._globalAABBBounds ? this._globalAABBBounds.setValue(this._AABBBounds.x1, this._AABBBounds.y1, this._AABBBounds.x2, this._AABBBounds.y2) : this._globalAABBBounds = this._AABBBounds.clone(), this.shadowHost && this._globalAABBBounds.transformWithMatrix(this.shadowHost.globalTransMatrix), this._globalAABBBounds;
|
|
14997
15048
|
}
|
|
14998
|
-
|
|
14999
|
-
|
|
15000
|
-
|
|
15001
|
-
|
|
15002
|
-
|
|
15003
|
-
|
|
15049
|
+
}
|
|
15050
|
+
function createShadowRoot(graphic) {
|
|
15051
|
+
return new ShadowRoot(graphic);
|
|
15052
|
+
}
|
|
15053
|
+
|
|
15054
|
+
class GraphicCreator {
|
|
15055
|
+
constructor() {
|
|
15056
|
+
this.store = new Map();
|
|
15004
15057
|
}
|
|
15005
|
-
|
|
15006
|
-
|
|
15007
|
-
blankCaptures && consume(blankCaptures[0].length);
|
|
15008
|
-
const captures = regexp.exec(input);
|
|
15009
|
-
return captures && consume(captures[0].length), captures;
|
|
15058
|
+
RegisterGraphicCreator(name, cb) {
|
|
15059
|
+
this.store.set(name, cb), this[name] = cb;
|
|
15010
15060
|
}
|
|
15011
|
-
|
|
15012
|
-
|
|
15061
|
+
CreateGraphic(name, params) {
|
|
15062
|
+
const cb = this.store.get(name);
|
|
15063
|
+
return cb ? cb(params) : null;
|
|
15013
15064
|
}
|
|
15014
|
-
|
|
15015
|
-
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15065
|
+
}
|
|
15066
|
+
const graphicCreator = new GraphicCreator();
|
|
15067
|
+
|
|
15068
|
+
let text, richText;
|
|
15069
|
+
function getTextBounds(params) {
|
|
15070
|
+
return text || (text = graphicCreator.CreateGraphic("text", {})), text.initAttributes(params), text.AABBBounds;
|
|
15071
|
+
}
|
|
15072
|
+
function getRichTextBounds(params) {
|
|
15073
|
+
return richText || (richText = graphicCreator.CreateGraphic("richtext", {})), richText.setAttributes(params), richText.AABBBounds;
|
|
15074
|
+
}
|
|
15075
|
+
|
|
15076
|
+
const result = {
|
|
15077
|
+
x: 0,
|
|
15078
|
+
y: 0,
|
|
15079
|
+
z: 0,
|
|
15080
|
+
lastModelMatrix: null
|
|
15081
|
+
};
|
|
15082
|
+
class BaseRender {
|
|
15083
|
+
init(contributions) {
|
|
15084
|
+
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));
|
|
15021
15085
|
}
|
|
15022
|
-
|
|
15023
|
-
|
|
15086
|
+
beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
15087
|
+
this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
|
|
15088
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
15089
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
15090
|
+
}
|
|
15091
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
15092
|
+
});
|
|
15024
15093
|
}
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
15030
|
-
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
15031
|
-
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
15094
|
+
afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
|
|
15095
|
+
this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
|
|
15096
|
+
if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
|
|
15097
|
+
if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
|
|
15032
15098
|
}
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
}
|
|
15036
|
-
return c;
|
|
15099
|
+
c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
|
|
15100
|
+
});
|
|
15037
15101
|
}
|
|
15038
|
-
|
|
15039
|
-
|
|
15040
|
-
|
|
15041
|
-
|
|
15042
|
-
|
|
15043
|
-
|
|
15044
|
-
|
|
15045
|
-
|
|
15046
|
-
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15102
|
+
drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
15103
|
+
if (!graphic.pathProxy) return !1;
|
|
15104
|
+
const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
|
|
15105
|
+
{
|
|
15106
|
+
fill = themeAttributes.fill,
|
|
15107
|
+
stroke = themeAttributes.stroke,
|
|
15108
|
+
opacity = themeAttributes.opacity,
|
|
15109
|
+
fillOpacity = themeAttributes.fillOpacity,
|
|
15110
|
+
lineWidth = themeAttributes.lineWidth,
|
|
15111
|
+
strokeOpacity = themeAttributes.strokeOpacity,
|
|
15112
|
+
visible = themeAttributes.visible,
|
|
15113
|
+
x: originX = themeAttributes.x,
|
|
15114
|
+
y: originY = themeAttributes.y
|
|
15115
|
+
} = graphic.attribute,
|
|
15116
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
15117
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
15118
|
+
doFill = runFill(fill),
|
|
15119
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
15120
|
+
if (!visible) return !0;
|
|
15121
|
+
if (!doFill && !doStroke) return !0;
|
|
15122
|
+
if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
|
|
15123
|
+
context.beginPath();
|
|
15124
|
+
const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
|
|
15125
|
+
return renderCommandList(path.commandList, context, x, y), context.setShadowBlendStyle && context.setShadowBlendStyle(graphic, graphic.attribute, themeAttributes), this.beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, graphic.attribute, themeAttributes) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.stroke())), doFill && (fillCb ? fillCb(context, graphic.attribute, themeAttributes) : fVisible && (context.setCommonStyle(graphic, graphic.attribute, x - originX, y - originY, themeAttributes), context.fill())), this.afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, themeAttributes, drawContext, fillCb, strokeCb), !0;
|
|
15056
15126
|
}
|
|
15057
|
-
|
|
15127
|
+
valid(graphic, defaultAttribute, fillCb, strokeCb) {
|
|
15058
15128
|
const {
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15066
|
-
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15129
|
+
fill = defaultAttribute.fill,
|
|
15130
|
+
background: background,
|
|
15131
|
+
stroke = defaultAttribute.stroke,
|
|
15132
|
+
opacity = defaultAttribute.opacity,
|
|
15133
|
+
fillOpacity = defaultAttribute.fillOpacity,
|
|
15134
|
+
lineWidth = defaultAttribute.lineWidth,
|
|
15135
|
+
strokeOpacity = defaultAttribute.strokeOpacity,
|
|
15136
|
+
visible = defaultAttribute.visible
|
|
15137
|
+
} = graphic.attribute,
|
|
15138
|
+
fVisible = fillVisible(opacity, fillOpacity, fill),
|
|
15139
|
+
sVisible = strokeVisible(opacity, strokeOpacity),
|
|
15140
|
+
doFill = runFill(fill, background),
|
|
15141
|
+
doStroke = runStroke(stroke, lineWidth);
|
|
15142
|
+
return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
|
|
15143
|
+
fVisible: fVisible,
|
|
15144
|
+
sVisible: sVisible,
|
|
15145
|
+
doFill: doFill,
|
|
15146
|
+
doStroke: doStroke
|
|
15073
15147
|
};
|
|
15074
15148
|
}
|
|
15075
|
-
|
|
15149
|
+
transform(graphic, graphicAttribute, context) {
|
|
15150
|
+
let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
|
|
15076
15151
|
const {
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
};
|
|
15152
|
+
x = graphicAttribute.x,
|
|
15153
|
+
y = graphicAttribute.y,
|
|
15154
|
+
z = graphicAttribute.z,
|
|
15155
|
+
scaleX = graphicAttribute.scaleX,
|
|
15156
|
+
scaleY = graphicAttribute.scaleY,
|
|
15157
|
+
angle = graphicAttribute.angle,
|
|
15158
|
+
postMatrix: postMatrix
|
|
15159
|
+
} = graphic.attribute,
|
|
15160
|
+
lastModelMatrix = context.modelMatrix,
|
|
15161
|
+
camera = context.camera;
|
|
15162
|
+
result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
|
|
15163
|
+
const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
|
|
15164
|
+
onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
|
|
15165
|
+
if (shouldTransform3d) {
|
|
15166
|
+
const nextModelMatrix = mat4Allocate.allocate(),
|
|
15167
|
+
modelMatrix = mat4Allocate.allocate();
|
|
15168
|
+
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);
|
|
15169
|
+
}
|
|
15170
|
+
if (onlyTranslate && !lastModelMatrix) {
|
|
15171
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
15172
|
+
result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
|
|
15173
|
+
} 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) {
|
|
15174
|
+
const point = graphic.getOffsetXY(graphicAttribute);
|
|
15175
|
+
result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
|
|
15176
|
+
} else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
|
|
15177
|
+
return result;
|
|
15099
15178
|
}
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
scaleY = 1
|
|
15131
|
-
} = params.attribute;
|
|
15132
|
-
w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
|
|
15179
|
+
transformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
15180
|
+
const camera = context.camera;
|
|
15181
|
+
if (this.camera = camera, camera) {
|
|
15182
|
+
const bounds = graphic.AABBBounds,
|
|
15183
|
+
width = bounds.x2 - bounds.x1,
|
|
15184
|
+
height = bounds.y2 - bounds.y1,
|
|
15185
|
+
p1 = context.project(0, 0, z),
|
|
15186
|
+
p2 = context.project(width, 0, z),
|
|
15187
|
+
p3 = context.project(width, height, z),
|
|
15188
|
+
_p1 = {
|
|
15189
|
+
x: 0,
|
|
15190
|
+
y: 0
|
|
15191
|
+
},
|
|
15192
|
+
_p2 = {
|
|
15193
|
+
x: width,
|
|
15194
|
+
y: 0
|
|
15195
|
+
},
|
|
15196
|
+
_p3 = {
|
|
15197
|
+
x: width,
|
|
15198
|
+
y: height
|
|
15199
|
+
};
|
|
15200
|
+
context.camera = null;
|
|
15201
|
+
const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
|
|
15202
|
+
m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
|
|
15203
|
+
m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
|
|
15204
|
+
m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
|
|
15205
|
+
m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
|
|
15206
|
+
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,
|
|
15207
|
+
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;
|
|
15208
|
+
context.setTransform(m11, m12, m21, m22, dx, dy, !0);
|
|
15133
15209
|
}
|
|
15134
|
-
"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));
|
|
15135
15210
|
}
|
|
15136
|
-
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
|
|
15145
|
-
|
|
15146
|
-
|
|
15147
|
-
|
|
15148
|
-
|
|
15149
|
-
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15211
|
+
restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
|
|
15212
|
+
this.camera && (context.camera = this.camera);
|
|
15213
|
+
}
|
|
15214
|
+
transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
|
|
15215
|
+
const p = context.project(x, y, z);
|
|
15216
|
+
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();
|
|
15217
|
+
}
|
|
15218
|
+
_draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
|
|
15219
|
+
const {
|
|
15220
|
+
context: context
|
|
15221
|
+
} = drawContext;
|
|
15222
|
+
if (!context) return;
|
|
15223
|
+
const {
|
|
15224
|
+
renderable: renderable
|
|
15225
|
+
} = graphic.attribute;
|
|
15226
|
+
if (!1 === renderable) return;
|
|
15227
|
+
context.highPerformanceSave();
|
|
15228
|
+
const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
|
|
15229
|
+
{
|
|
15230
|
+
x: x,
|
|
15231
|
+
y: y,
|
|
15232
|
+
z: z,
|
|
15233
|
+
lastModelMatrix: lastModelMatrix
|
|
15234
|
+
} = data;
|
|
15235
|
+
this.z = z, this.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();
|
|
15236
|
+
}
|
|
15158
15237
|
}
|
|
15159
15238
|
|
|
15160
15239
|
var __decorate$1C = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
@@ -15418,7 +15497,8 @@
|
|
|
15418
15497
|
x: originX = arcAttribute.x,
|
|
15419
15498
|
y: originY = arcAttribute.y,
|
|
15420
15499
|
scaleX = arcAttribute.scaleX,
|
|
15421
|
-
scaleY = arcAttribute.scaleY
|
|
15500
|
+
scaleY = arcAttribute.scaleY,
|
|
15501
|
+
keepStrokeScale = arcAttribute.keepStrokeScale
|
|
15422
15502
|
} = arc.attribute;
|
|
15423
15503
|
let {
|
|
15424
15504
|
innerRadius = arcAttribute.innerRadius,
|
|
@@ -15430,7 +15510,7 @@
|
|
|
15430
15510
|
{
|
|
15431
15511
|
distance = arcAttribute[key].distance
|
|
15432
15512
|
} = borderStyle,
|
|
15433
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
15513
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
15434
15514
|
deltaAngle = distance / outerRadius,
|
|
15435
15515
|
sign = "outerBorder" === key ? 1 : -1;
|
|
15436
15516
|
if (arc.setAttributes({
|
|
@@ -15475,14 +15555,15 @@
|
|
|
15475
15555
|
x: originX = circleAttribute.x,
|
|
15476
15556
|
y: originY = circleAttribute.y,
|
|
15477
15557
|
scaleX = circleAttribute.scaleX,
|
|
15478
|
-
scaleY = circleAttribute.scaleY
|
|
15558
|
+
scaleY = circleAttribute.scaleY,
|
|
15559
|
+
keepStrokeScale = circleAttribute.keepStrokeScale
|
|
15479
15560
|
} = circle.attribute,
|
|
15480
15561
|
renderBorder = (borderStyle, key) => {
|
|
15481
15562
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
15482
15563
|
{
|
|
15483
15564
|
distance = circleAttribute[key].distance
|
|
15484
15565
|
} = borderStyle,
|
|
15485
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
15566
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
15486
15567
|
sign = "outerBorder" === key ? 1 : -1;
|
|
15487
15568
|
if (context.beginPath(), context.arc(x, y, radius + sign * d, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), strokeCb) strokeCb(context, borderStyle, circleAttribute[key]);else if (doStroke) {
|
|
15488
15569
|
const lastOpacity = circleAttribute[key].opacity;
|
|
@@ -15601,7 +15682,8 @@
|
|
|
15601
15682
|
scaleX = rectAttribute.scaleX,
|
|
15602
15683
|
scaleY = rectAttribute.scaleY,
|
|
15603
15684
|
x1: x1,
|
|
15604
|
-
y1: y1
|
|
15685
|
+
y1: y1,
|
|
15686
|
+
keepStrokeScale = rectAttribute.keepStrokeScale
|
|
15605
15687
|
} = rect.attribute;
|
|
15606
15688
|
let {
|
|
15607
15689
|
width: width,
|
|
@@ -15614,7 +15696,7 @@
|
|
|
15614
15696
|
{
|
|
15615
15697
|
distance = rectAttribute[key].distance
|
|
15616
15698
|
} = borderStyle,
|
|
15617
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
15699
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
15618
15700
|
nextX = x + sign * d,
|
|
15619
15701
|
nextY = y + sign * d,
|
|
15620
15702
|
dw = 2 * d;
|
|
@@ -15771,14 +15853,15 @@
|
|
|
15771
15853
|
x: originX = symbolAttribute.x,
|
|
15772
15854
|
y: originY = symbolAttribute.y,
|
|
15773
15855
|
scaleX = symbolAttribute.scaleX,
|
|
15774
|
-
scaleY = symbolAttribute.scaleY
|
|
15856
|
+
scaleY = symbolAttribute.scaleY,
|
|
15857
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale
|
|
15775
15858
|
} = symbol.attribute,
|
|
15776
15859
|
renderBorder = (borderStyle, key) => {
|
|
15777
15860
|
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
15778
15861
|
{
|
|
15779
15862
|
distance = symbolAttribute[key].distance
|
|
15780
15863
|
} = borderStyle,
|
|
15781
|
-
d = getScaledStroke(context, distance, context.dpr),
|
|
15864
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
15782
15865
|
sign = "outerBorder" === key ? 1 : -1;
|
|
15783
15866
|
if (context.beginPath(), !1 === parsedPath.drawOffset(context, size, x, y, sign * d) && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), strokeCb) strokeCb(context, borderStyle, symbolAttribute[key]);else if (doStroke) {
|
|
15784
15867
|
const lastOpacity = symbolAttribute[key].opacity;
|
|
@@ -17061,16 +17144,8 @@
|
|
|
17061
17144
|
verticalMode = textAttribute.verticalMode,
|
|
17062
17145
|
x: originX = textAttribute.x,
|
|
17063
17146
|
y: originY = textAttribute.y
|
|
17064
|
-
} = text.attribute
|
|
17065
|
-
|
|
17066
|
-
textAlign = textAttribute.textAlign,
|
|
17067
|
-
textBaseline = textAttribute.textBaseline
|
|
17068
|
-
} = text.attribute;
|
|
17069
|
-
if (!verticalMode && "vertical" === direction) {
|
|
17070
|
-
const t = textAlign;
|
|
17071
|
-
textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
|
|
17072
|
-
}
|
|
17073
|
-
const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
|
|
17147
|
+
} = text.attribute,
|
|
17148
|
+
lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
|
|
17074
17149
|
data = this.valid(text, textAttribute, fillCb, strokeCb);
|
|
17075
17150
|
if (!data) return;
|
|
17076
17151
|
const {
|
|
@@ -17090,79 +17165,60 @@
|
|
|
17090
17165
|
const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
|
|
17091
17166
|
matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
|
|
17092
17167
|
}
|
|
17093
|
-
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)
|
|
17168
|
+
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());
|
|
17094
17169
|
};
|
|
17095
|
-
if (text.
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
width: line.width
|
|
17110
|
-
});
|
|
17111
|
-
})));
|
|
17112
|
-
} else {
|
|
17113
|
-
text.tryUpdateAABBBounds();
|
|
17114
|
-
const cache = text.cache,
|
|
17115
|
-
{
|
|
17116
|
-
verticalList: verticalList
|
|
17117
|
-
} = cache;
|
|
17118
|
-
context.textAlign = "left", context.textBaseline = "top";
|
|
17119
|
-
const totalHeight = lineHeight * verticalList.length;
|
|
17120
|
-
let totalW = 0;
|
|
17121
|
-
verticalList.forEach(verticalData => {
|
|
17122
|
-
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
17123
|
-
totalW = max(_w, totalW);
|
|
17124
|
-
});
|
|
17125
|
-
let offsetY = 0,
|
|
17126
|
-
offsetX = 0;
|
|
17127
|
-
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
17128
|
-
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
17129
|
-
dw = totalW - currentW;
|
|
17130
|
-
let currentOffsetY = offsetY;
|
|
17131
|
-
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
17132
|
-
const {
|
|
17133
|
-
text: text,
|
|
17134
|
-
width: width,
|
|
17135
|
-
direction: direction
|
|
17136
|
-
} = item;
|
|
17137
|
-
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
17138
|
-
});
|
|
17170
|
+
if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
|
|
17171
|
+
const {
|
|
17172
|
+
multilineLayout: multilineLayout
|
|
17173
|
+
} = text;
|
|
17174
|
+
if (!multilineLayout) return void context.highPerformanceRestore();
|
|
17175
|
+
const {
|
|
17176
|
+
xOffset: xOffset,
|
|
17177
|
+
yOffset: yOffset
|
|
17178
|
+
} = multilineLayout.bbox;
|
|
17179
|
+
doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
17180
|
+
context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
|
|
17181
|
+
}))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
|
|
17182
|
+
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, {
|
|
17183
|
+
width: line.width
|
|
17139
17184
|
});
|
|
17140
|
-
}
|
|
17141
|
-
} else if ("horizontal" === direction) {
|
|
17142
|
-
context.setTextStyle(text.attribute, textAttribute, z);
|
|
17143
|
-
const t = text.clipedText;
|
|
17144
|
-
let dy = 0;
|
|
17145
|
-
lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
|
|
17185
|
+
})));
|
|
17146
17186
|
} else {
|
|
17187
|
+
let {
|
|
17188
|
+
textAlign = textAttribute.textAlign,
|
|
17189
|
+
textBaseline = textAttribute.textBaseline
|
|
17190
|
+
} = text.attribute;
|
|
17191
|
+
if (!verticalMode) {
|
|
17192
|
+
const t = textAlign;
|
|
17193
|
+
textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
|
|
17194
|
+
}
|
|
17147
17195
|
text.tryUpdateAABBBounds();
|
|
17148
|
-
const cache = text.cache
|
|
17149
|
-
|
|
17150
|
-
context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
|
|
17151
|
-
const {
|
|
17196
|
+
const cache = text.cache,
|
|
17197
|
+
{
|
|
17152
17198
|
verticalList: verticalList
|
|
17153
17199
|
} = cache;
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
17157
|
-
|
|
17200
|
+
context.textAlign = "left", context.textBaseline = "top";
|
|
17201
|
+
const totalHeight = lineHeight * verticalList.length;
|
|
17202
|
+
let totalW = 0;
|
|
17203
|
+
verticalList.forEach(verticalData => {
|
|
17204
|
+
const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
|
|
17205
|
+
totalW = max(_w, totalW);
|
|
17206
|
+
});
|
|
17207
|
+
let offsetY = 0,
|
|
17208
|
+
offsetX = 0;
|
|
17209
|
+
"bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
|
|
17210
|
+
const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
|
|
17211
|
+
dw = totalW - currentW;
|
|
17212
|
+
let currentOffsetY = offsetY;
|
|
17213
|
+
"center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
|
|
17158
17214
|
const {
|
|
17159
17215
|
text: text,
|
|
17160
17216
|
width: width,
|
|
17161
17217
|
direction: direction
|
|
17162
17218
|
} = item;
|
|
17163
|
-
drawText(text, offsetX,
|
|
17219
|
+
drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
|
|
17164
17220
|
});
|
|
17165
|
-
}
|
|
17221
|
+
});
|
|
17166
17222
|
}
|
|
17167
17223
|
transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
|
|
17168
17224
|
}
|
|
@@ -17174,12 +17230,10 @@
|
|
|
17174
17230
|
computed3dMatrix = !keepDirIn3d;
|
|
17175
17231
|
this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
|
|
17176
17232
|
}
|
|
17177
|
-
drawUnderLine(underline, lineThrough, text,
|
|
17233
|
+
drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
|
|
17178
17234
|
if (lineThrough + underline <= 0) return;
|
|
17179
17235
|
const {
|
|
17180
17236
|
textAlign = textAttribute.textAlign,
|
|
17181
|
-
textBaseline = textAttribute.textBaseline,
|
|
17182
|
-
fontSize = textAttribute.fontSize,
|
|
17183
17237
|
fill = textAttribute.fill,
|
|
17184
17238
|
opacity = textAttribute.opacity,
|
|
17185
17239
|
underlineOffset = textAttribute.underlineOffset,
|
|
@@ -17189,23 +17243,21 @@
|
|
|
17189
17243
|
isMulti = !isNil$1(multiOption),
|
|
17190
17244
|
w = isMulti ? multiOption.width : text.clipedWidth,
|
|
17191
17245
|
offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
|
|
17192
|
-
offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
|
|
17193
17246
|
attribute = {
|
|
17194
17247
|
lineWidth: 0,
|
|
17195
17248
|
stroke: fill,
|
|
17196
17249
|
opacity: opacity,
|
|
17197
17250
|
strokeOpacity: fillOpacity
|
|
17198
17251
|
};
|
|
17199
|
-
let deltaY = isMulti ? -3 : 0;
|
|
17200
17252
|
if (underline) {
|
|
17201
|
-
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute,
|
|
17202
|
-
const dy =
|
|
17203
|
-
context.moveTo(
|
|
17253
|
+
attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
|
|
17254
|
+
const dy = anchorY + offsetUnderLineY + underlineOffset;
|
|
17255
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
17204
17256
|
}
|
|
17205
|
-
if (
|
|
17206
|
-
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute,
|
|
17207
|
-
const dy =
|
|
17208
|
-
context.moveTo(
|
|
17257
|
+
if (lineThrough) {
|
|
17258
|
+
attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
|
|
17259
|
+
const dy = anchorY + offsetThroughLineY;
|
|
17260
|
+
context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
|
|
17209
17261
|
}
|
|
17210
17262
|
}
|
|
17211
17263
|
};
|
|
@@ -17608,7 +17660,10 @@
|
|
|
17608
17660
|
const {
|
|
17609
17661
|
context: context
|
|
17610
17662
|
} = drawContext;
|
|
17611
|
-
|
|
17663
|
+
context.highPerformanceSave();
|
|
17664
|
+
const t1 = graphic.parent.globalTransMatrix,
|
|
17665
|
+
t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
|
|
17666
|
+
if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
|
|
17612
17667
|
tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
|
|
17613
17668
|
const m = graphic.globalTransMatrix.getInverse();
|
|
17614
17669
|
drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
|
|
@@ -18642,6 +18697,42 @@
|
|
|
18642
18697
|
}
|
|
18643
18698
|
}
|
|
18644
18699
|
|
|
18700
|
+
class AutoRefreshPlugin {
|
|
18701
|
+
constructor() {
|
|
18702
|
+
this.name = "AutoRefreshPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handleChange = graphic => {
|
|
18703
|
+
graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
|
|
18704
|
+
};
|
|
18705
|
+
}
|
|
18706
|
+
activate(context) {
|
|
18707
|
+
this.pluginService = context, this.dpr = application.global.devicePixelRatio, this.refresh();
|
|
18708
|
+
}
|
|
18709
|
+
refresh() {
|
|
18710
|
+
this._refreshByMediaQuery() || this._refreshByRaf();
|
|
18711
|
+
}
|
|
18712
|
+
_refreshByRaf() {
|
|
18713
|
+
const raf = application.global.getRequestAnimationFrame();
|
|
18714
|
+
this.rafId = raf(() => {
|
|
18715
|
+
application.global.devicePixelRatio !== this.dpr && (this.dpr = application.global.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0)), this.refresh();
|
|
18716
|
+
});
|
|
18717
|
+
}
|
|
18718
|
+
_refreshByMediaQuery() {
|
|
18719
|
+
try {
|
|
18720
|
+
const mqString = `(resolution: ${window.devicePixelRatio}dppx)`,
|
|
18721
|
+
updatePixelRatio = () => {
|
|
18722
|
+
window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
|
|
18723
|
+
};
|
|
18724
|
+
matchMedia(mqString).addEventListener("change", updatePixelRatio);
|
|
18725
|
+
} catch (err) {
|
|
18726
|
+
return !1;
|
|
18727
|
+
}
|
|
18728
|
+
return !0;
|
|
18729
|
+
}
|
|
18730
|
+
deactivate(context) {
|
|
18731
|
+
const craf = application.global.getCancelAnimationFrame();
|
|
18732
|
+
craf && this.rafId && craf(this.rafId);
|
|
18733
|
+
}
|
|
18734
|
+
}
|
|
18735
|
+
|
|
18645
18736
|
class IncrementalAutoRenderPlugin {
|
|
18646
18737
|
constructor() {
|
|
18647
18738
|
this.name = "IncrementalAutoRenderPlugin", this.activeEvent = "onRegister", this.nextFrameRenderGroupSet = new Set(), this.willNextFrameRender = !1, this.nextUserParams = {}, this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid;
|
|
@@ -18818,7 +18909,7 @@
|
|
|
18818
18909
|
constructor() {
|
|
18819
18910
|
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18820
18911
|
var _a;
|
|
18821
|
-
super({}), this._onVisibleChange = visible => {
|
|
18912
|
+
super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
|
|
18822
18913
|
if (!(this._skipRender < 0)) if (visible) {
|
|
18823
18914
|
if (this.dirtyBounds) {
|
|
18824
18915
|
const b = this.window.getViewBox();
|
|
@@ -18829,7 +18920,10 @@
|
|
|
18829
18920
|
}, this.beforeRender = stage => {
|
|
18830
18921
|
this._beforeRender && this._beforeRender(stage);
|
|
18831
18922
|
}, this.afterRender = stage => {
|
|
18832
|
-
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
|
|
18923
|
+
this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
|
|
18924
|
+
}, this.afterTickCb = () => {
|
|
18925
|
+
var _a;
|
|
18926
|
+
this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
|
|
18833
18927
|
}, this.params = params, this.theme = new Theme(), this.hooks = {
|
|
18834
18928
|
beforeRender: new SyncHook(["stage"]),
|
|
18835
18929
|
afterRender: new SyncHook(["stage"])
|
|
@@ -18844,9 +18938,9 @@
|
|
|
18844
18938
|
canvas: params.canvas
|
|
18845
18939
|
}), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig$1.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
|
|
18846
18940
|
main: !0
|
|
18847
|
-
})), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), !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({
|
|
18941
|
+
})), 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({
|
|
18848
18942
|
background: this._background
|
|
18849
|
-
});
|
|
18943
|
+
}), this.ticker.on("afterTick", this.afterTickCb);
|
|
18850
18944
|
}
|
|
18851
18945
|
pauseRender() {
|
|
18852
18946
|
let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
|
|
@@ -18979,6 +19073,14 @@
|
|
|
18979
19073
|
this.pluginService.unRegister(plugin);
|
|
18980
19074
|
}));
|
|
18981
19075
|
}
|
|
19076
|
+
enableAutoRefresh() {
|
|
19077
|
+
this.autoRefresh || (this.autoRefresh = !0, this.pluginService.register(new AutoRefreshPlugin()));
|
|
19078
|
+
}
|
|
19079
|
+
disableAutoRefresh() {
|
|
19080
|
+
this.autoRefresh && (this.autoRefresh = !1, this.pluginService.findPluginsByName("AutoRefreshPlugin").forEach(plugin => {
|
|
19081
|
+
this.pluginService.unRegister(plugin);
|
|
19082
|
+
}));
|
|
19083
|
+
}
|
|
18982
19084
|
enableIncrementalAutoRender() {
|
|
18983
19085
|
this.increaseAutoRender || (this.increaseAutoRender = !0, this.pluginService.register(new IncrementalAutoRenderPlugin()));
|
|
18984
19086
|
}
|
|
@@ -19067,7 +19169,7 @@
|
|
|
19067
19169
|
if ("released" === this.releaseStatus) return;
|
|
19068
19170
|
this.ticker.start(), this.timeline.resume();
|
|
19069
19171
|
const state = this.state;
|
|
19070
|
-
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++;
|
|
19172
|
+
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++;
|
|
19071
19173
|
}
|
|
19072
19174
|
combineLayersToWindow() {
|
|
19073
19175
|
if ("harmony" === this.global.env) {
|
|
@@ -19173,7 +19275,7 @@
|
|
|
19173
19275
|
layer.release();
|
|
19174
19276
|
}), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
|
|
19175
19277
|
item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
|
|
19176
|
-
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
|
|
19278
|
+
}), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
|
|
19177
19279
|
}
|
|
19178
19280
|
setStage(stage) {}
|
|
19179
19281
|
dirty(b, matrix) {
|
|
@@ -19251,8 +19353,6 @@
|
|
|
19251
19353
|
return new Stage(params);
|
|
19252
19354
|
}
|
|
19253
19355
|
|
|
19254
|
-
const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
|
|
19255
|
-
|
|
19256
19356
|
var __decorate$1f = undefined && undefined.__decorate || function (decorators, target, key, desc) {
|
|
19257
19357
|
var d,
|
|
19258
19358
|
c = arguments.length,
|
|
@@ -24165,7 +24265,7 @@
|
|
|
24165
24265
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
24166
24266
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
24167
24267
|
super(), this.cachedEvents = [], this.startPoints = [], this.processEvent = {}, this.throttleTimer = 0, this.emitThrottles = [], this.lastTapTarget = null, this.onStart = ev => {
|
|
24168
|
-
this.reset(), this.startTime = clock.now();
|
|
24268
|
+
this.cachedEvents = [], this.startPoints = [], this.reset(), this.startTime = clock.now();
|
|
24169
24269
|
const {
|
|
24170
24270
|
cachedEvents: cachedEvents,
|
|
24171
24271
|
startPoints: startPoints
|
|
@@ -24185,7 +24285,7 @@
|
|
|
24185
24285
|
if (1 !== startPoints.length) this.startDistance = calcDistance(startPoints[0], startPoints[1]), this.center = getCenter([startPoints[0], startPoints[1]]);else {
|
|
24186
24286
|
const event = cachedEvents[0];
|
|
24187
24287
|
this.pressTimeout = setTimeout(() => {
|
|
24188
|
-
event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none";
|
|
24288
|
+
event.direction = "none", event.deltaX = 0, event.deltaY = 0, event.points = startPoints, this.triggerStartEvent("press", event), this.triggerEvent("press", event), this.eventType = "press", this.direction = "none", this.pressTimeout = null;
|
|
24189
24289
|
}, this.config.press.time);
|
|
24190
24290
|
}
|
|
24191
24291
|
}, this.onMove = ev => {
|
|
@@ -24248,10 +24348,10 @@
|
|
|
24248
24348
|
lastMovePoint = this.lastMovePoint || startPoints[0],
|
|
24249
24349
|
distance = calcDistance(prevMovePoint, lastMovePoint),
|
|
24250
24350
|
velocity = distance / intervalTime;
|
|
24251
|
-
velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold
|
|
24351
|
+
if (velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold) return endEvent.velocity = velocity, endEvent.direction = calcDirection(prevMovePoint, lastMovePoint), this.triggerEvent("swipe", endEvent), this.cachedEvents = [], this.startPoints = [], void this.reset();
|
|
24252
24352
|
}
|
|
24253
24353
|
}
|
|
24254
|
-
now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0);
|
|
24354
|
+
now - this.startTime < this.config.press.time && (now - this.lastTapTime < this.config.tap.interval && ev.target === this.lastTapTarget ? this.tapCount++ : this.tapCount = 1, this.lastTapTime = now, this.lastTapTarget = ev.target, 1 === this.tapCount ? this.triggerEvent("tap", endEvent) : 2 === this.tapCount && (this.triggerEvent("doubletap", endEvent), this.tapCount = 0));
|
|
24255
24355
|
}
|
|
24256
24356
|
for (let i = 0, len = cachedEvents.length; i < len; i++) if (cachedEvents[i].pointerId === endEvent.pointerId) {
|
|
24257
24357
|
cachedEvents.splice(i, 1), startPoints.splice(i, 1);
|
|
@@ -24293,7 +24393,7 @@
|
|
|
24293
24393
|
startTime: startTime,
|
|
24294
24394
|
startPoints: startPoints
|
|
24295
24395
|
} = this;
|
|
24296
|
-
if (eventType) return eventType;
|
|
24396
|
+
if ("press" === eventType) return eventType;
|
|
24297
24397
|
let type;
|
|
24298
24398
|
return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
|
|
24299
24399
|
}
|
|
@@ -24327,6 +24427,7 @@
|
|
|
24327
24427
|
emitThrottles: emitThrottles
|
|
24328
24428
|
} = this;
|
|
24329
24429
|
throttleTimer || (this.throttleTimer = application.global.getRequestAnimationFrame()(() => {
|
|
24430
|
+
application.global.getCancelAnimationFrame()(this.throttleTimer), this.throttleTimer = null;
|
|
24330
24431
|
for (let i = 0, len = emitThrottles.length; i < len; i++) {
|
|
24331
24432
|
const {
|
|
24332
24433
|
type: type,
|
|
@@ -24334,7 +24435,7 @@
|
|
|
24334
24435
|
} = emitThrottles[i];
|
|
24335
24436
|
this.emitEvent(type, ev);
|
|
24336
24437
|
}
|
|
24337
|
-
this.
|
|
24438
|
+
this.emitThrottles.length = 0;
|
|
24338
24439
|
}));
|
|
24339
24440
|
}
|
|
24340
24441
|
triggerStartEvent(type, ev) {
|
|
@@ -24824,9 +24925,10 @@
|
|
|
24824
24925
|
lineJoin = defaultParams.lineJoin,
|
|
24825
24926
|
lineDash = defaultParams.lineDash,
|
|
24826
24927
|
lineCap = defaultParams.lineCap,
|
|
24827
|
-
miterLimit = defaultParams.miterLimit
|
|
24928
|
+
miterLimit = defaultParams.miterLimit,
|
|
24929
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
24828
24930
|
} = attribute;
|
|
24829
|
-
_context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24931
|
+
_context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
24830
24932
|
}
|
|
24831
24933
|
}
|
|
24832
24934
|
setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
|
|
@@ -25726,8 +25828,9 @@
|
|
|
25726
25828
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
|
|
25727
25829
|
if (picked) return !0;
|
|
25728
25830
|
const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
|
|
25729
|
-
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
25730
|
-
|
|
25831
|
+
pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
25832
|
+
keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
25833
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
25731
25834
|
}), pickContext.highPerformanceRestore(), picked;
|
|
25732
25835
|
}
|
|
25733
25836
|
}
|
|
@@ -26000,8 +26103,9 @@
|
|
|
26000
26103
|
if (!onlyTranslate || rect.shadowRoot || isNumber$1(cornerRadius, !0) && 0 !== cornerRadius || isArray$1(cornerRadius) && cornerRadius.some(num => 0 !== num)) picked = !1, this.canvasRenderer.drawShape(rect, pickContext, x, y, {}, null, (context, rectAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, rectAttribute, themeAttribute) => {
|
|
26001
26104
|
if (picked) return !0;
|
|
26002
26105
|
const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
|
|
26003
|
-
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
26004
|
-
|
|
26106
|
+
pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
26107
|
+
keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
26108
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
|
|
26005
26109
|
});else {
|
|
26006
26110
|
const {
|
|
26007
26111
|
fill = rectAttribute.fill,
|
|
@@ -26315,9 +26419,10 @@
|
|
|
26315
26419
|
lineJoin = defaultParams.lineJoin,
|
|
26316
26420
|
lineDash = defaultParams.lineDash,
|
|
26317
26421
|
lineCap = defaultParams.lineCap,
|
|
26318
|
-
miterLimit = defaultParams.miterLimit
|
|
26422
|
+
miterLimit = defaultParams.miterLimit,
|
|
26423
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
26319
26424
|
} = attribute;
|
|
26320
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
26425
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
26321
26426
|
}
|
|
26322
26427
|
}
|
|
26323
26428
|
measureText(text) {
|
|
@@ -26945,9 +27050,10 @@
|
|
|
26945
27050
|
lineJoin = defaultParams.lineJoin,
|
|
26946
27051
|
lineDash = defaultParams.lineDash,
|
|
26947
27052
|
lineCap = defaultParams.lineCap,
|
|
26948
|
-
miterLimit = defaultParams.miterLimit
|
|
27053
|
+
miterLimit = defaultParams.miterLimit,
|
|
27054
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
26949
27055
|
} = attribute;
|
|
26950
|
-
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
27056
|
+
_context.setGlobalAlpha(strokeOpacity * opacity), _context.setLineWidth(keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr)), _context.setStrokeStyle(createColor(this, stroke, params, offsetX, offsetY)), _context.setLineJoin(lineJoin), lineDash && _context.setLineDash(lineDash), _context.setLineCap(lineCap), _context.setMiterLimit(miterLimit);
|
|
26951
27057
|
}
|
|
26952
27058
|
}
|
|
26953
27059
|
setTextStyleWithoutAlignBaseline(params, defaultParams) {
|
|
@@ -27987,9 +28093,10 @@
|
|
|
27987
28093
|
lineJoin = defaultParams.lineJoin,
|
|
27988
28094
|
lineDash = defaultParams.lineDash,
|
|
27989
28095
|
lineCap = defaultParams.lineCap,
|
|
27990
|
-
miterLimit = defaultParams.miterLimit
|
|
28096
|
+
miterLimit = defaultParams.miterLimit,
|
|
28097
|
+
keepStrokeScale = defaultParams.keepStrokeScale
|
|
27991
28098
|
} = attribute;
|
|
27992
|
-
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
28099
|
+
_context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha, _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || lineDash && _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
|
|
27993
28100
|
}
|
|
27994
28101
|
}
|
|
27995
28102
|
measureText(text) {
|
|
@@ -28396,8 +28503,9 @@
|
|
|
28396
28503
|
return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
|
|
28397
28504
|
if (picked) return !0;
|
|
28398
28505
|
const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28399
|
-
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28400
|
-
|
|
28506
|
+
pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28507
|
+
keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28508
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28401
28509
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28402
28510
|
}
|
|
28403
28511
|
}
|
|
@@ -28532,8 +28640,9 @@
|
|
|
28532
28640
|
return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
|
|
28533
28641
|
if (picked) return !0;
|
|
28534
28642
|
const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
|
|
28535
|
-
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer
|
|
28536
|
-
|
|
28643
|
+
pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
|
|
28644
|
+
keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
|
|
28645
|
+
return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
|
|
28537
28646
|
}), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
|
|
28538
28647
|
}
|
|
28539
28648
|
};
|
|
@@ -29761,7 +29870,7 @@
|
|
|
29761
29870
|
|
|
29762
29871
|
const roughModule = _roughModule;
|
|
29763
29872
|
|
|
29764
|
-
const version = "0.21.0-vstory.
|
|
29873
|
+
const version = "0.21.0-vstory.3";
|
|
29765
29874
|
preLoadAllModule();
|
|
29766
29875
|
if (isBrowserEnv()) {
|
|
29767
29876
|
loadBrowserEnv(container);
|
|
@@ -29918,6 +30027,7 @@
|
|
|
29918
30027
|
exports.DrawContribution = DrawContribution;
|
|
29919
30028
|
exports.DrawItemInterceptor = DrawItemInterceptor;
|
|
29920
30029
|
exports.DynamicLayerHandlerContribution = DynamicLayerHandlerContribution;
|
|
30030
|
+
exports.Easing = Easing;
|
|
29921
30031
|
exports.EnvContribution = EnvContribution;
|
|
29922
30032
|
exports.EventManager = EventManager;
|
|
29923
30033
|
exports.EventSystem = EventSystem;
|
|
@@ -30081,6 +30191,7 @@
|
|
|
30081
30191
|
exports.WindowHandlerContribution = WindowHandlerContribution;
|
|
30082
30192
|
exports.WrapText = WrapText;
|
|
30083
30193
|
exports.XMLParser = XMLParser;
|
|
30194
|
+
exports._calculateLineHeight = _calculateLineHeight;
|
|
30084
30195
|
exports._interpolateColor = _interpolateColor;
|
|
30085
30196
|
exports._registerArc = _registerArc;
|
|
30086
30197
|
exports.addArcToBezierPath = addArcToBezierPath$1;
|