@visactor/vrender 0.21.0-vstory.1 → 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/dist/index.es.js CHANGED
@@ -742,6 +742,13 @@ let DefaultGlobal = class {
742
742
  };
743
743
  DefaultGlobal = __decorate$1J([injectable(), __param$U(0, inject(ContributionProvider)), __param$U(0, named(EnvContribution)), __metadata$1i("design:paramtypes", [Object])], DefaultGlobal);
744
744
 
745
+ var MeasureModeEnum;
746
+ !function (MeasureModeEnum) {
747
+ MeasureModeEnum[MeasureModeEnum.estimate = 0] = "estimate", MeasureModeEnum[MeasureModeEnum.actualBounding = 1] = "actualBounding", MeasureModeEnum[MeasureModeEnum.fontBounding = 2] = "fontBounding";
748
+ }(MeasureModeEnum || (MeasureModeEnum = {}));
749
+
750
+ const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
751
+
745
752
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
746
753
 
747
754
  function getDefaultExportFromCjs (x) {
@@ -1698,7 +1705,9 @@ class TextMeasure {
1698
1705
  } = this.textSpec;
1699
1706
  return {
1700
1707
  width: metrics.width,
1701
- height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize
1708
+ height: null !== (_a = lineHeight) && void 0 !== _a ? _a : fontSize,
1709
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
1710
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
1702
1711
  };
1703
1712
  }
1704
1713
  quickMeasure(text) {
@@ -1712,7 +1721,7 @@ class TextMeasure {
1712
1721
  for (let i = 0; i < text.length; i++) {
1713
1722
  const char = text[i];
1714
1723
  let size = this._measureSpecialChar(char);
1715
- 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);
1724
+ 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);
1716
1725
  }
1717
1726
  return totalSize;
1718
1727
  }
@@ -1761,7 +1770,9 @@ class TextMeasure {
1761
1770
  const numberBounds = this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);
1762
1771
  this._numberCharSize = {
1763
1772
  width: numberBounds.width / TextMeasure.NUMBERS_CHAR_SET.length,
1764
- height: numberBounds.height
1773
+ height: numberBounds.height,
1774
+ fontBoundingBoxAscent: numberBounds.fontBoundingBoxAscent,
1775
+ fontBoundingBoxDescent: numberBounds.fontBoundingBoxDescent
1765
1776
  };
1766
1777
  }
1767
1778
  return this._numberCharSize;
@@ -1774,7 +1785,9 @@ class TextMeasure {
1774
1785
  const alphabetBounds = this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);
1775
1786
  this._letterCharSize = {
1776
1787
  width: alphabetBounds.width / TextMeasure.ALPHABET_CHAR_SET.length,
1777
- height: alphabetBounds.height
1788
+ height: alphabetBounds.height,
1789
+ fontBoundingBoxAscent: alphabetBounds.fontBoundingBoxAscent,
1790
+ fontBoundingBoxDescent: alphabetBounds.fontBoundingBoxDescent
1778
1791
  };
1779
1792
  }
1780
1793
  return this._letterCharSize;
@@ -4048,6 +4061,7 @@ const DefaultStrokeStyle = Object.assign({
4048
4061
  const DefaultTextStyle = {
4049
4062
  text: "",
4050
4063
  maxLineWidth: 1 / 0,
4064
+ maxWidth: 1 / 0,
4051
4065
  textAlign: "left",
4052
4066
  textBaseline: "alphabetic",
4053
4067
  fontSize: 16,
@@ -4071,7 +4085,9 @@ const DefaultTextStyle = {
4071
4085
  suffixPosition: "end",
4072
4086
  underlineDash: [],
4073
4087
  underlineOffset: 0,
4074
- disableAutoClipedPoptip: void 0
4088
+ disableAutoClipedPoptip: void 0,
4089
+ measureMode: MeasureModeEnum.fontBounding,
4090
+ keepCenterInLine: !1
4075
4091
  };
4076
4092
  const DefaultPickStyle = {
4077
4093
  pickStrokeBuffer: 0
@@ -4128,7 +4144,8 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
4128
4144
  globalZIndex: 1,
4129
4145
  globalCompositeOperation: "",
4130
4146
  overflow: "hidden",
4131
- shadowPickMode: "graphic"
4147
+ shadowPickMode: "graphic",
4148
+ keepStrokeScale: !1
4132
4149
  }, DefaultDebugAttribute), DefaultStyle), DefaultTransform);
4133
4150
  function addAttributeToPrototype(obj, c, keys) {
4134
4151
  keys.forEach(key => {
@@ -4282,165 +4299,553 @@ const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImag
4282
4299
  class Application {}
4283
4300
  const application = new Application();
4284
4301
 
4285
- const DIRECTION_KEY = {
4286
- horizontal: {
4287
- width: "width",
4288
- height: "height",
4289
- left: "left",
4290
- top: "top",
4291
- x: "x",
4292
- y: "y",
4293
- bottom: "bottom"
4294
- },
4295
- vertical: {
4296
- width: "height",
4297
- height: "width",
4298
- left: "top",
4299
- top: "left",
4300
- x: "y",
4301
- y: "x",
4302
- bottom: "right"
4303
- }
4304
- };
4305
- const defaultFormatting = {
4306
- fontSize: 16,
4307
- fontFamily: "sans-serif",
4308
- fill: !0,
4309
- stroke: !1,
4310
- fontWeight: "normal",
4311
- lineHeight: "normal",
4312
- fontStyle: "normal",
4313
- textDecoration: "none",
4314
- textAlign: "left",
4315
- script: "normal"
4302
+ const parse = function () {
4303
+ const tokens = {
4304
+ linearGradient: /^(linear\-gradient)/i,
4305
+ radialGradient: /^(radial\-gradient)/i,
4306
+ conicGradient: /^(conic\-gradient)/i,
4307
+ sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
4308
+ extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
4309
+ positionKeywords: /^(left|center|right|top|bottom)/i,
4310
+ pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
4311
+ percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
4312
+ emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
4313
+ angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4314
+ fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
4315
+ startCall: /^\(/,
4316
+ endCall: /^\)/,
4317
+ comma: /^,/,
4318
+ hexColor: /(^\#[0-9a-fA-F]+)/,
4319
+ literalColor: /^([a-zA-Z]+)/,
4320
+ rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
4321
+ rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
4322
+ number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
4316
4323
  };
4317
- const regLetter = /\w|\(|\)|-/;
4318
- const regPunctuation = /[.?!,;:/,。?!、;:]/;
4319
- const regFirstSpace = /\S/;
4320
- const setTextStyle = (ctx, character) => {
4321
- let fontSize = character.fontSize || 16;
4322
- switch (character.script) {
4323
- case "super":
4324
- case "sub":
4325
- fontSize *= .8;
4324
+ let input = "";
4325
+ function error(msg) {
4326
+ const err = new Error(input + ": " + msg);
4327
+ throw err.source = input, err;
4326
4328
  }
4327
- ctx.setTextStyle({
4328
- textAlign: "left",
4329
- textBaseline: character.textBaseline || "alphabetic",
4330
- fontStyle: character.fontStyle || "",
4331
- fontWeight: character.fontWeight || "",
4332
- fontSize: fontSize,
4333
- fontFamily: character.fontFamily || "sans-serif"
4334
- });
4335
- };
4336
- function applyFillStyle(ctx, character) {
4337
- const fillStyle = character && character.fill || defaultFormatting.fill;
4338
- if (!fillStyle) return void (ctx.globalAlpha = 0);
4339
- const {
4340
- fillOpacity = 1,
4341
- opacity = 1
4342
- } = character;
4343
- ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = fillStyle, setTextStyle(ctx, character);
4344
- }
4345
- function applyStrokeStyle(ctx, character) {
4346
- const strokeStyle = character && character.stroke || defaultFormatting.stroke;
4347
- if (!strokeStyle) return void (ctx.globalAlpha = 0);
4348
- const {
4349
- strokeOpacity = 1,
4350
- opacity = 1
4351
- } = character;
4352
- ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4353
- }
4354
- function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
4355
- if (!width || width <= 0) return 0;
4356
- const textMeasure = application.graphicUtil.textMeasure;
4357
- let index = guessIndex,
4358
- temp = desc.slice(0, index),
4359
- tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
4360
- tempNext = desc.slice(0, index + 1),
4361
- tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
4362
- for (; tempWidth > width || tempWidthNext <= width;) {
4363
- if (tempWidth > width ? index-- : index++, index > desc.length) {
4364
- index = desc.length;
4365
- break;
4329
+ function getAST() {
4330
+ const ast = matchListing(matchDefinition);
4331
+ return input.length > 0 && error("Invalid input not EOF"), ast;
4332
+ }
4333
+ function matchDefinition() {
4334
+ return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
4335
+ }
4336
+ function matchGradient(gradientType, pattern, orientationMatcher) {
4337
+ return function (pattern, callback) {
4338
+ const captures = scan(pattern);
4339
+ if (captures) {
4340
+ scan(tokens.startCall) || error("Missing (");
4341
+ const result = callback(captures);
4342
+ return scan(tokens.endCall) || error("Missing )"), result;
4343
+ }
4344
+ }(pattern, function (captures) {
4345
+ const orientation = orientationMatcher();
4346
+ return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
4347
+ type: gradientType,
4348
+ orientation: orientation,
4349
+ colorStops: matchListing(matchColorStop)
4350
+ };
4351
+ });
4352
+ }
4353
+ function matchLinearOrientation() {
4354
+ return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
4355
+ }
4356
+ function matchConicalOrientation() {
4357
+ return match("angular", tokens.fromAngleValue, 1);
4358
+ }
4359
+ function matchListRadialOrientations() {
4360
+ let radialOrientations,
4361
+ lookaheadCache,
4362
+ radialOrientation = matchRadialOrientation();
4363
+ return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
4364
+ }
4365
+ function matchRadialOrientation() {
4366
+ let radialType = function () {
4367
+ const circle = match("shape", /^(circle)/i, 0);
4368
+ circle && (circle.style = matchLength() || matchExtentKeyword());
4369
+ return circle;
4370
+ }() || function () {
4371
+ const ellipse = match("shape", /^(ellipse)/i, 0);
4372
+ ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
4373
+ return ellipse;
4374
+ }();
4375
+ if (radialType) radialType.at = matchAtPosition();else {
4376
+ const extent = matchExtentKeyword();
4377
+ if (extent) {
4378
+ radialType = extent;
4379
+ const positionAt = matchAtPosition();
4380
+ positionAt && (radialType.at = positionAt);
4381
+ } else {
4382
+ const defaultPosition = matchPositioning();
4383
+ defaultPosition && (radialType = {
4384
+ type: "default-radial",
4385
+ at: defaultPosition
4386
+ });
4387
+ }
4366
4388
  }
4367
- if (index < 0) {
4368
- index = 0;
4369
- break;
4389
+ return radialType;
4390
+ }
4391
+ function matchExtentKeyword() {
4392
+ return match("extent-keyword", tokens.extentKeywords, 1);
4393
+ }
4394
+ function matchAtPosition() {
4395
+ if (match("position", /^at/, 0)) {
4396
+ const positioning = matchPositioning();
4397
+ return positioning || error("Missing positioning value"), positioning;
4370
4398
  }
4371
- 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);
4372
4399
  }
4373
- return needTestLetter && (index = testLetter(desc, index)), index;
4374
- }
4375
- function testLetter(string, index) {
4376
- let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
4377
- let i = index;
4378
- for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
4379
- return i;
4380
- }
4381
- function testLetter2(string, index) {
4382
- let i = index;
4383
- for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
4384
- return i;
4385
- }
4386
- function measureTextCanvas(text, character) {
4387
- const measurement = application.graphicUtil.textMeasure.measureText(text, character),
4388
- result = {
4389
- ascent: 0,
4390
- height: 0,
4391
- descent: 0,
4392
- width: 0
4400
+ function matchPositioning() {
4401
+ const location = {
4402
+ x: matchDistance(),
4403
+ y: matchDistance()
4404
+ };
4405
+ if (location.x || location.y) return {
4406
+ type: "position",
4407
+ value: location
4393
4408
  };
4394
- 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;
4395
- }
4396
-
4397
- var __decorate$1I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
4398
- var d,
4399
- c = arguments.length,
4400
- r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
4401
- 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);
4402
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4403
- };
4404
- let ATextMeasure = class {
4405
- configure(service, env) {
4406
- this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4407
4409
  }
4408
- measureTextWidth(text, options) {
4409
- if (!this.context) return this.estimate(text, options).width;
4410
- this.context.setTextStyleWithoutAlignBaseline(options);
4411
- return this.context.measureText(text).width;
4410
+ function matchListing(matcher) {
4411
+ let captures = matcher();
4412
+ const result = [];
4413
+ if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
4414
+ return result;
4412
4415
  }
4413
- estimate(text, _ref) {
4414
- let {
4415
- fontSize = DefaultTextAttribute.fontSize
4416
- } = _ref;
4417
- let eCharLen = 0,
4418
- cCharLen = 0;
4419
- for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
4420
- return {
4421
- width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
4422
- height: fontSize
4423
- };
4416
+ function matchColorStop() {
4417
+ const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
4418
+ return color || error("Expected color definition"), color.length = matchDistance(), color;
4424
4419
  }
4425
- measureTextPixelHeight(text, options) {
4426
- var _a;
4427
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4428
- this.context.setTextStyleWithoutAlignBaseline(options);
4429
- const textMeasure = this.context.measureText(text);
4430
- return Math.abs(textMeasure.actualBoundingBoxAscent - textMeasure.actualBoundingBoxDescent);
4420
+ function matchDistance() {
4421
+ return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
4431
4422
  }
4432
- measureTextBoundHieght(text, options) {
4433
- var _a;
4434
- if (!this.context) return null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4435
- this.context.setTextStyleWithoutAlignBaseline(options);
4436
- const textMeasure = this.context.measureText(text);
4437
- return Math.abs(textMeasure.fontBoundingBoxAscent - textMeasure.fontBoundingBoxDescent);
4423
+ function matchLength() {
4424
+ return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
4438
4425
  }
4439
- measureText(text, options) {
4440
- return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
4426
+ function match(type, pattern, captureIndex) {
4427
+ const captures = scan(pattern);
4428
+ if (captures) return {
4429
+ type: type,
4430
+ value: captures[captureIndex]
4431
+ };
4441
4432
  }
4442
- clipTextVertical(verticalList, options, width, wordBreak) {
4443
- if (0 === verticalList.length) return {
4433
+ function scan(regexp) {
4434
+ const blankCaptures = /^[\n\r\t\s]+/.exec(input);
4435
+ blankCaptures && consume(blankCaptures[0].length);
4436
+ const captures = regexp.exec(input);
4437
+ return captures && consume(captures[0].length), captures;
4438
+ }
4439
+ function consume(size) {
4440
+ input = input.substr(size);
4441
+ }
4442
+ return function (code) {
4443
+ return input = code.toString(), getAST();
4444
+ };
4445
+ }();
4446
+ class GradientParser {
4447
+ static IsGradient(c) {
4448
+ return !("string" == typeof c && !c.includes("gradient"));
4449
+ }
4450
+ static IsGradientStr(c) {
4451
+ return "string" == typeof c && c.includes("gradient");
4452
+ }
4453
+ static Parse(c) {
4454
+ if (GradientParser.IsGradientStr(c)) try {
4455
+ const datum = parse(c)[0];
4456
+ if (datum) {
4457
+ if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
4458
+ if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
4459
+ if ("conic" === datum.type) return GradientParser.ParseConic(datum);
4460
+ }
4461
+ } catch (err) {
4462
+ return c;
4463
+ }
4464
+ return c;
4465
+ }
4466
+ static ParseConic(datum) {
4467
+ const {
4468
+ orientation: orientation,
4469
+ colorStops = []
4470
+ } = datum,
4471
+ halfPi = pi / 2,
4472
+ sa = parseFloat(orientation.value) / 180 * pi - halfPi;
4473
+ return {
4474
+ gradient: "conical",
4475
+ x: .5,
4476
+ y: .5,
4477
+ startAngle: sa,
4478
+ endAngle: sa + pi2,
4479
+ stops: colorStops.map(item => ({
4480
+ color: item.value,
4481
+ offset: parseFloat(item.length.value) / 100
4482
+ }))
4483
+ };
4484
+ }
4485
+ static ParseRadial(datum) {
4486
+ const {
4487
+ colorStops = []
4488
+ } = datum;
4489
+ return {
4490
+ gradient: "radial",
4491
+ x0: .5,
4492
+ y0: .5,
4493
+ x1: .5,
4494
+ y1: .5,
4495
+ r0: 0,
4496
+ r1: 1,
4497
+ stops: colorStops.map(item => ({
4498
+ color: item.value,
4499
+ offset: parseFloat(item.length.value) / 100
4500
+ }))
4501
+ };
4502
+ }
4503
+ static ParseLinear(datum) {
4504
+ const {
4505
+ orientation: orientation,
4506
+ colorStops = []
4507
+ } = datum,
4508
+ halfPi = pi / 2;
4509
+ let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
4510
+ for (; angle < 0;) angle += pi2;
4511
+ for (; angle >= pi2;) angle -= pi2;
4512
+ let x0 = 0,
4513
+ y0 = 0,
4514
+ x1 = 0,
4515
+ y1 = 0;
4516
+ 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)), {
4517
+ gradient: "linear",
4518
+ x0: x0,
4519
+ y0: y0,
4520
+ x1: x1,
4521
+ y1: y1,
4522
+ stops: colorStops.map(item => ({
4523
+ color: item.value,
4524
+ offset: parseFloat(item.length.value) / 100
4525
+ }))
4526
+ };
4527
+ }
4528
+ }
4529
+
4530
+ function getScaledStroke(context, width, dpr) {
4531
+ let strokeWidth = width;
4532
+ const {
4533
+ a: a,
4534
+ b: b,
4535
+ c: c,
4536
+ d: d
4537
+ } = context.currentMatrix,
4538
+ scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
4539
+ scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
4540
+ return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
4541
+ }
4542
+ function createColor(context, c, params) {
4543
+ let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
4544
+ let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4545
+ if (!c || !0 === c) return "black";
4546
+ let result, color;
4547
+ if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
4548
+ if (color = GradientParser.Parse(color), "string" == typeof color) return color;
4549
+ if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
4550
+ const bounds = params.AABBBounds;
4551
+ let w = bounds.x2 - bounds.x1,
4552
+ h = bounds.y2 - bounds.y1,
4553
+ x = bounds.x1 - offsetX,
4554
+ y = bounds.y1 - offsetY;
4555
+ if (params.attribute) {
4556
+ const {
4557
+ scaleX = 1,
4558
+ scaleY = 1
4559
+ } = params.attribute;
4560
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
4561
+ }
4562
+ "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));
4563
+ }
4564
+ return result || "orange";
4565
+ }
4566
+ function createLinearGradient(context, color, x, y, w, h) {
4567
+ var _a, _b, _c, _d;
4568
+ 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);
4569
+ return color.stops.forEach(stop => {
4570
+ canvasGradient.addColorStop(stop.offset, stop.color);
4571
+ }), canvasGradient;
4572
+ }
4573
+ function createRadialGradient(context, color, x, y, w, h) {
4574
+ var _a, _b, _c, _d, _e, _f;
4575
+ 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));
4576
+ return color.stops.forEach(stop => {
4577
+ canvasGradient.addColorStop(stop.offset, stop.color);
4578
+ }), canvasGradient;
4579
+ }
4580
+ function createConicGradient(context, color, x, y, w, h) {
4581
+ var _a, _b;
4582
+ 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);
4583
+ return color.stops.forEach(stop => {
4584
+ canvasGradient.addColorStop(stop.offset, stop.color);
4585
+ }), canvasGradient.GetPattern(w + x, h + y, undefined);
4586
+ }
4587
+
4588
+ const DIRECTION_KEY = {
4589
+ horizontal: {
4590
+ width: "width",
4591
+ height: "height",
4592
+ left: "left",
4593
+ top: "top",
4594
+ x: "x",
4595
+ y: "y",
4596
+ bottom: "bottom"
4597
+ },
4598
+ vertical: {
4599
+ width: "height",
4600
+ height: "width",
4601
+ left: "top",
4602
+ top: "left",
4603
+ x: "y",
4604
+ y: "x",
4605
+ bottom: "right"
4606
+ }
4607
+ };
4608
+ const defaultFormatting = {
4609
+ fontSize: 16,
4610
+ fontFamily: "sans-serif",
4611
+ fill: !0,
4612
+ stroke: !1,
4613
+ fontWeight: "normal",
4614
+ lineHeight: "normal",
4615
+ fontStyle: "normal",
4616
+ textDecoration: "none",
4617
+ textAlign: "left",
4618
+ script: "normal"
4619
+ };
4620
+ const regLetter = /\w|\(|\)|-/;
4621
+ const regPunctuation = /[.?!,;:/,。?!、;:]/;
4622
+ const regFirstSpace = /\S/;
4623
+ const setTextStyle = (ctx, character) => {
4624
+ let fontSize = character.fontSize || 16;
4625
+ switch (character.script) {
4626
+ case "super":
4627
+ case "sub":
4628
+ fontSize *= .8;
4629
+ }
4630
+ ctx.setTextStyle({
4631
+ textAlign: "left",
4632
+ textBaseline: character.textBaseline || "alphabetic",
4633
+ fontStyle: character.fontStyle || "",
4634
+ fontWeight: character.fontWeight || "",
4635
+ fontSize: fontSize,
4636
+ fontFamily: character.fontFamily || "sans-serif"
4637
+ });
4638
+ };
4639
+ function applyFillStyle(ctx, character, b) {
4640
+ const fillStyle = character && character.fill || defaultFormatting.fill;
4641
+ if (!fillStyle) return void (ctx.globalAlpha = 0);
4642
+ const {
4643
+ fillOpacity = 1,
4644
+ opacity = 1
4645
+ } = character;
4646
+ ctx.globalAlpha = fillOpacity * opacity, ctx.fillStyle = b ? createColor(ctx, fillStyle, {
4647
+ AABBBounds: b
4648
+ }) : fillStyle, setTextStyle(ctx, character);
4649
+ }
4650
+ function applyStrokeStyle(ctx, character) {
4651
+ const strokeStyle = character && character.stroke || defaultFormatting.stroke;
4652
+ if (!strokeStyle) return void (ctx.globalAlpha = 0);
4653
+ const {
4654
+ strokeOpacity = 1,
4655
+ opacity = 1
4656
+ } = character;
4657
+ ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4658
+ }
4659
+ function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
4660
+ if (!width || width <= 0) return 0;
4661
+ const textMeasure = application.graphicUtil.textMeasure;
4662
+ let index = guessIndex,
4663
+ temp = desc.slice(0, index),
4664
+ tempWidth = Math.floor(textMeasure.measureText(temp, character).width),
4665
+ tempNext = desc.slice(0, index + 1),
4666
+ tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
4667
+ for (; tempWidth > width || tempWidthNext <= width;) {
4668
+ if (tempWidth > width ? index-- : index++, index > desc.length) {
4669
+ index = desc.length;
4670
+ break;
4671
+ }
4672
+ if (index < 0) {
4673
+ index = 0;
4674
+ break;
4675
+ }
4676
+ 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);
4677
+ }
4678
+ return needTestLetter && (index = testLetter(desc, index)), index;
4679
+ }
4680
+ function testLetter(string, index) {
4681
+ let negativeWrongMatch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
4682
+ let i = index;
4683
+ for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i--, i <= 0) return negativeWrongMatch ? testLetter2(string, index) : index;
4684
+ return i;
4685
+ }
4686
+ function testLetter2(string, index) {
4687
+ let i = index;
4688
+ for (; regLetter.test(string[i - 1]) && regLetter.test(string[i]) || regPunctuation.test(string[i]);) if (i++, i >= string.length) return i;
4689
+ return i;
4690
+ }
4691
+ function measureTextCanvas(text, character) {
4692
+ const measurement = application.graphicUtil.textMeasure.measureText(text, character),
4693
+ result = {
4694
+ ascent: 0,
4695
+ height: 0,
4696
+ descent: 0,
4697
+ width: 0
4698
+ };
4699
+ 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;
4700
+ }
4701
+
4702
+ var __decorate$1I = undefined && undefined.__decorate || function (decorators, target, key, desc) {
4703
+ var d,
4704
+ c = arguments.length,
4705
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
4706
+ 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);
4707
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4708
+ };
4709
+ let ATextMeasure = class {
4710
+ configure(service, env) {
4711
+ this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4712
+ }
4713
+ _measureTextWithoutAlignBaseline(text, options, compatible) {
4714
+ this.context.setTextStyleWithoutAlignBaseline(options);
4715
+ const metrics = this.context.measureText(text);
4716
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4717
+ }
4718
+ _measureTextWithAlignBaseline(text, options, compatible) {
4719
+ this.context.setTextStyle(options);
4720
+ const metrics = this.context.measureText(text);
4721
+ return compatible ? this.compatibleMetrics(metrics, options) : metrics;
4722
+ }
4723
+ compatibleMetrics(metrics, options) {
4724
+ if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4725
+ const {
4726
+ ascent: ascent,
4727
+ descent: descent
4728
+ } = this.measureTextBoundADscentEstimate(options);
4729
+ metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4730
+ }
4731
+ if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4732
+ const {
4733
+ left: left,
4734
+ right: right
4735
+ } = this.measureTextBoundLeftRightEstimate(options);
4736
+ metrics.actualBoundingBoxLeft = left, metrics.actualBoundingBoxRight = right;
4737
+ }
4738
+ return metrics;
4739
+ }
4740
+ estimate(text, _ref) {
4741
+ let {
4742
+ fontSize = DefaultTextAttribute.fontSize
4743
+ } = _ref;
4744
+ let eCharLen = 0,
4745
+ cCharLen = 0;
4746
+ for (let i = 0; i < text.length; i++) text.charCodeAt(i) < 128 ? eCharLen++ : cCharLen++;
4747
+ return {
4748
+ width: ~~(.8 * eCharLen * fontSize + cCharLen * fontSize),
4749
+ height: fontSize
4750
+ };
4751
+ }
4752
+ measureTextWidth(text, options, textMeasure) {
4753
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4754
+ }
4755
+ measureTextBoundsWidth(text, options, textMeasure) {
4756
+ return this.context ? (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithoutAlignBaseline(text, options)).width : this.estimate(text, options).width;
4757
+ }
4758
+ measureTextBoundsLeftRight(text, options, textMeasure) {
4759
+ return this.context ? {
4760
+ left: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxLeft,
4761
+ right: textMeasure.actualBoundingBoxRight
4762
+ } : this.measureTextBoundLeftRightEstimate(options);
4763
+ }
4764
+ measureTextPixelHeight(text, options, textMeasure) {
4765
+ var _a;
4766
+ 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;
4767
+ }
4768
+ measureTextPixelADscent(text, options, textMeasure) {
4769
+ return this.context ? {
4770
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).actualBoundingBoxAscent,
4771
+ descent: textMeasure.actualBoundingBoxDescent
4772
+ } : this.measureTextBoundADscentEstimate(options);
4773
+ }
4774
+ measureTextBoundHieght(text, options, textMeasure) {
4775
+ var _a;
4776
+ 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;
4777
+ }
4778
+ measureTextBoundADscent(text, options, textMeasure) {
4779
+ return this.context ? {
4780
+ ascent: (textMeasure = null != textMeasure ? textMeasure : this._measureTextWithAlignBaseline(text, options, !0)).fontBoundingBoxAscent,
4781
+ descent: textMeasure.fontBoundingBoxDescent
4782
+ } : this.measureTextBoundADscentEstimate(options);
4783
+ }
4784
+ measureTextBoundADscentEstimate(options) {
4785
+ var _a;
4786
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize;
4787
+ return {
4788
+ ascent: .79 * fontSize,
4789
+ descent: .21 * fontSize
4790
+ };
4791
+ }
4792
+ measureTextBoundLeftRightEstimate(options) {
4793
+ var _a;
4794
+ const fontSize = null !== (_a = options.fontSize) && void 0 !== _a ? _a : DefaultTextStyle.fontSize,
4795
+ {
4796
+ textAlign: textAlign
4797
+ } = options;
4798
+ return "center" === textAlign ? {
4799
+ left: fontSize / 2,
4800
+ right: fontSize / 2
4801
+ } : "right" === textAlign || "end" === textAlign ? {
4802
+ left: fontSize,
4803
+ right: 0
4804
+ } : {
4805
+ left: 0,
4806
+ right: fontSize
4807
+ };
4808
+ }
4809
+ measureTextPixelADscentAndWidth(text, options, mode) {
4810
+ if (!this.context) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4811
+ width: this.estimate(text, options).width
4812
+ });
4813
+ const out = this._measureTextWithoutAlignBaseline(text, options, !0);
4814
+ if (mode === MeasureModeEnum.actualBounding) return {
4815
+ ascent: out.actualBoundingBoxAscent,
4816
+ descent: out.actualBoundingBoxDescent,
4817
+ width: out.width
4818
+ };
4819
+ if (mode === MeasureModeEnum.estimate) return Object.assign(Object.assign({}, this.measureTextBoundADscentEstimate(options)), {
4820
+ width: out.width
4821
+ });
4822
+ if (mode === MeasureModeEnum.fontBounding) {
4823
+ let ascent = out.fontBoundingBoxAscent,
4824
+ descent = out.fontBoundingBoxDescent;
4825
+ if (out.actualBoundingBoxDescent && descent < out.actualBoundingBoxDescent) {
4826
+ const delta = out.actualBoundingBoxDescent - descent;
4827
+ descent += delta, ascent -= delta;
4828
+ } else if (out.actualBoundingBoxAscent && ascent < out.actualBoundingBoxAscent) {
4829
+ const delta = out.actualBoundingBoxAscent - ascent;
4830
+ ascent += delta, descent -= delta;
4831
+ }
4832
+ return {
4833
+ ascent: ascent,
4834
+ descent: descent,
4835
+ width: out.width
4836
+ };
4837
+ }
4838
+ return {
4839
+ ascent: out.actualBoundingBoxAscent,
4840
+ descent: out.actualBoundingBoxDescent,
4841
+ width: out.width
4842
+ };
4843
+ }
4844
+ measureText(text, options) {
4845
+ return this.context ? (this.context.setTextStyleWithoutAlignBaseline(options), this.context.measureText(text)) : this.estimate(text, options);
4846
+ }
4847
+ clipTextVertical(verticalList, options, width, wordBreak) {
4848
+ if (0 === verticalList.length) return {
4444
4849
  verticalList: verticalList,
4445
4850
  width: 0
4446
4851
  };
@@ -4512,6 +4917,14 @@ let ATextMeasure = class {
4512
4917
  return data;
4513
4918
  }
4514
4919
  _clipTextEnd(text, options, width, leftIdx, rightIdx) {
4920
+ if (leftIdx === rightIdx) {
4921
+ Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
4922
+ const subText = text.substring(0, rightIdx + 1);
4923
+ return {
4924
+ str: subText,
4925
+ width: this.measureTextWidth(subText, options)
4926
+ };
4927
+ }
4515
4928
  const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
4516
4929
  subText = text.substring(0, middleIdx + 1),
4517
4930
  strWidth = this.measureTextWidth(subText, options);
@@ -4545,7 +4958,7 @@ let ATextMeasure = class {
4545
4958
  }
4546
4959
  _clipTextStart(text, options, width, leftIdx, rightIdx) {
4547
4960
  const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
4548
- subText = text.substring(middleIdx - 1, text.length - 1),
4961
+ subText = text.substring(middleIdx - 1, text.length),
4549
4962
  strWidth = this.measureTextWidth(subText, options);
4550
4963
  let length;
4551
4964
  if (strWidth > width) {
@@ -4553,18 +4966,18 @@ let ATextMeasure = class {
4553
4966
  str: "",
4554
4967
  width: 0
4555
4968
  };
4556
- const str = text.substring(middleIdx, text.length - 1);
4969
+ const str = text.substring(middleIdx, text.length);
4557
4970
  return length = this.measureTextWidth(str, options), length <= width ? {
4558
4971
  str: str,
4559
4972
  width: length
4560
- } : this._clipTextStart(text, options, width, middleIdx, text.length - 1);
4973
+ } : this._clipTextStart(text, options, width, middleIdx, text.length);
4561
4974
  }
4562
4975
  if (strWidth < width) {
4563
4976
  if (middleIdx <= 0) return {
4564
4977
  str: text,
4565
4978
  width: this.measureTextWidth(text, options)
4566
4979
  };
4567
- const str = text.substring(middleIdx - 2, text.length - 1);
4980
+ const str = text.substring(middleIdx - 2, text.length);
4568
4981
  return length = this.measureTextWidth(str, options), length >= width ? {
4569
4982
  str: subText,
4570
4983
  width: strWidth
@@ -5619,19 +6032,19 @@ class Node extends EventEmitter {
5619
6032
  }
5620
6033
  insertBefore(newNode, referenceNode) {
5621
6034
  if (!referenceNode) return this.appendChild(newNode);
5622
- if (this._uid === newNode._uid) return null;
6035
+ if (this === newNode || newNode === referenceNode) return null;
5623
6036
  if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
5624
6037
  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);
5625
6038
  }
5626
6039
  insertAfter(newNode, referenceNode) {
5627
6040
  if (!referenceNode) return this.appendChild(newNode);
5628
- if (this._uid === newNode._uid) return null;
6041
+ if (this === newNode || newNode === referenceNode) return null;
5629
6042
  if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertAfter】不能将父辈元素insert为子元素");
5630
6043
  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);
5631
6044
  }
5632
6045
  insertInto(newNode, idx) {
5633
6046
  if (!this._ignoreWarn && this._nodeList && Logger.getInstance().warn("insertIntoKeepIdx和insertInto混用可能会存在错误"), idx >= this.childrenCount) return this.appendChild(newNode);
5634
- if (this._uid === newNode._uid) return null;
6047
+ if (this === newNode) return null;
5635
6048
  if (newNode.isAncestorsOf(this)) throw new Error("【Node::insertBefore】不能将父辈元素insert为子元素");
5636
6049
  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 {
5637
6050
  let child = this._firstChild;
@@ -6149,7 +6562,7 @@ class EventManager {
6149
6562
  timeStamp: now
6150
6563
  });
6151
6564
  const clickHistory = trackingData.clicksByButton[from.button];
6152
- 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);
6565
+ 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);
6153
6566
  }
6154
6567
  this.freeEvent(e);
6155
6568
  }, this.onPointerUpOutside = (from, target) => {
@@ -6366,7 +6779,8 @@ class EventSystem {
6366
6779
  supportsPointerEvents = global.supportsPointerEvents
6367
6780
  } = params;
6368
6781
  this.manager = new EventManager(rootNode, {
6369
- clickInterval: clickInterval
6782
+ clickInterval: clickInterval,
6783
+ supportsTouchEvents: supportsTouchEvents
6370
6784
  }), 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 = {
6371
6785
  default: "inherit",
6372
6786
  pointer: "pointer"
@@ -6550,8 +6964,8 @@ class DefaultTicker extends EventEmitter {
6550
6964
  const {
6551
6965
  once = !1
6552
6966
  } = null != params ? params : {};
6553
- this.ifCanStop() ? this.stop() : (this._handlerTick(handler), once || handler.tick(this.interval, this.handleTick));
6554
- }, this._handlerTick = handler => {
6967
+ this.ifCanStop() ? this.stop() : (this._handlerTick(), once || handler.tick(this.interval, this.handleTick));
6968
+ }, this._handlerTick = () => {
6555
6969
  const time = this.tickerHandler.getTime();
6556
6970
  let delta = 0;
6557
6971
  this.lastFrameTime >= 0 && (delta = time - this.lastFrameTime), this.lastFrameTime = time, this.status === STATUS$1.RUNNING && (this.tickCounts++, this.timelines.forEach(t => {
@@ -6656,7 +7070,10 @@ class DefaultTicker extends EventEmitter {
6656
7070
  this.status = STATUS$1.INITIAL, this.setupTickHandler(), this.lastFrameTime = -1;
6657
7071
  }
6658
7072
  release() {
6659
- this.stop(), this.timelines = [], this.tickerHandler.release();
7073
+ this.stop(), this.timelines = [], this.tickerHandler.release(), this.emit("afterTick");
7074
+ }
7075
+ trySyncTickStatus() {
7076
+ this.status === STATUS$1.RUNNING && this._handlerTick();
6660
7077
  }
6661
7078
  }
6662
7079
 
@@ -6813,6 +7230,9 @@ class Easing {
6813
7230
  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;
6814
7231
  };
6815
7232
  }
7233
+ static registerFunc(name, func) {
7234
+ Easing[name] = func;
7235
+ }
6816
7236
  }
6817
7237
  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 => {
6818
7238
  const c4 = 2 * Math.PI / 3;
@@ -7363,12 +7783,16 @@ class RafBasedSTO {
7363
7783
  }
7364
7784
  RafBasedSTO.TimeOut = 1e3 / 60;
7365
7785
  const rafBasedSto = new RafBasedSTO();
7366
- const calculateLineHeight = (lineHeight, fontSize) => {
7786
+ const _calculateLineHeight = (lineHeight, fontSize) => {
7367
7787
  if (isString$1(lineHeight) && "%" === lineHeight[lineHeight.length - 1]) {
7368
7788
  return fontSize * (Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100);
7369
7789
  }
7370
7790
  return lineHeight;
7371
7791
  };
7792
+ const calculateLineHeight = (lineHeight, fontSize) => {
7793
+ const _lh = _calculateLineHeight(lineHeight, fontSize);
7794
+ return isNaN(_lh) ? _lh : Math.max(fontSize, _lh);
7795
+ };
7372
7796
 
7373
7797
  class IncreaseCount extends ACustomAnimate {
7374
7798
  constructor(from, to, duration, easing, params) {
@@ -7805,7 +8229,7 @@ class TagPointsUpdate extends ACustomAnimate {
7805
8229
  lastMatchedIndex = i, lastMatchedPoint = tagMap.get(this.toPoints[i].context);
7806
8230
  break;
7807
8231
  }
7808
- "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);
8232
+ "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);
7809
8233
  let prevMatchedPoint = this.toPoints[0];
7810
8234
  this.interpolatePoints = this.toPoints.map((point, index) => {
7811
8235
  const matchedPoint = tagMap.get(point.context);
@@ -7817,11 +8241,19 @@ class TagPointsUpdate extends ACustomAnimate {
7817
8241
  return newPoint.defined = toPoint.defined, newPoint.context = toPoint.context, newPoint;
7818
8242
  });
7819
8243
  }
8244
+ onFirstRun() {
8245
+ const lastClipRange = this.target.attribute.clipRange;
8246
+ isValidNumber$1(lastClipRange * this.clipRange) && (this.clipRange *= lastClipRange);
8247
+ }
7820
8248
  onUpdate(end, ratio, out) {
7821
8249
  if (this.points = this.points.map((point, index) => {
7822
8250
  const newPoint = pointInterpolation(this.interpolatePoints[index][0], this.interpolatePoints[index][1], ratio);
7823
8251
  return newPoint.context = point.context, newPoint;
7824
- }), this.clipRange && (out.clipRange = this.clipRange + (1 - this.clipRange) * ratio), this.segmentsCache && this.to.segments) {
8252
+ }), this.clipRange) {
8253
+ 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));
8254
+ out.clipRange = this.clipRange + (1 - this.clipRange) * ratio;
8255
+ }
8256
+ if (this.segmentsCache && this.to.segments) {
7825
8257
  let start = 0;
7826
8258
  out.segments = this.to.segments.map((segment, index) => {
7827
8259
  const end = start + this.segmentsCache[index],
@@ -11594,58 +12026,64 @@ class CanvasTextLayout {
11594
12026
  constructor(fontFamily, options, textMeasure) {
11595
12027
  this.fontFamily = fontFamily, this.textOptions = options, this.textMeasure = textMeasure;
11596
12028
  }
11597
- LayoutBBox(bbox, textAlign, textBaseline) {
11598
- if ("left" === textAlign || "start" === textAlign) bbox.xOffset = 0;else if ("center" === textAlign) bbox.xOffset = bbox.width / -2;else {
11599
- if ("right" !== textAlign && "end" !== textAlign) throw new Error("非法的textAlign");
11600
- bbox.xOffset = -bbox.width;
11601
- }
11602
- return bbox.yOffset = "top" === textBaseline ? 0 : "middle" === textBaseline ? bbox.height / -2 : "alphabetic" === textBaseline ? -.79 * bbox.height : -bbox.height, bbox;
11603
- }
11604
- GetLayout(str, width, height, textAlign, textBaseline, lineHeight, suffix, wordBreak, suffixPosition) {
11605
- const linesLayout = [],
11606
- bboxWH = [width, height],
11607
- bboxOffset = [0, 0];
11608
- for (; str.length > 0;) {
11609
- const {
11610
- str: clipText
11611
- } = this.textMeasure.clipTextWithSuffix(str, this.textOptions, width, suffix, wordBreak, suffixPosition);
11612
- linesLayout.push({
11613
- str: clipText,
11614
- width: this.textMeasure.measureTextWidth(clipText, this.textOptions)
11615
- }), str = str.substring(clipText.length);
11616
- }
11617
- "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]));
11618
- const bbox = {
11619
- xOffset: bboxOffset[0],
11620
- yOffset: bboxOffset[1],
11621
- width: bboxWH[0],
11622
- height: bboxWH[1]
11623
- };
11624
- return this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
12029
+ LayoutBBox(bbox, textAlign, textBaseline, linesLayout) {
12030
+ 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) {
12031
+ let percent = .79;
12032
+ if (1 === linesLayout.length) {
12033
+ const lineInfo = linesLayout[0];
12034
+ percent = lineInfo.ascent / (lineInfo.ascent + lineInfo.descent);
12035
+ }
12036
+ bbox.yOffset = bbox.height * -percent;
12037
+ } else bbox.yOffset = -bbox.height;
12038
+ return bbox;
11625
12039
  }
11626
12040
  GetLayoutByLines(lines, textAlign, textBaseline, lineHeight) {
11627
12041
  let suffix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
11628
12042
  let wordBreak = arguments.length > 5 ? arguments[5] : undefined;
11629
- let lineWidth = arguments.length > 6 ? arguments[6] : undefined;
11630
- let suffixPosition = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "end";
12043
+ let params = arguments.length > 6 ? arguments[6] : undefined;
12044
+ const {
12045
+ lineWidth: lineWidth,
12046
+ suffixPosition = "end",
12047
+ measureMode = MeasureModeEnum.actualBounding,
12048
+ keepCenterInLine = !1
12049
+ } = null != params ? params : {};
11631
12050
  lines = lines.map(l => l.toString());
11632
12051
  const linesLayout = [],
11633
12052
  bboxWH = [0, 0];
11634
12053
  if ("number" == typeof lineWidth && lineWidth !== 1 / 0) {
11635
12054
  let width;
11636
- for (let i = 0, len = lines.length; i < len; i++) width = Math.min(this.textMeasure.measureTextWidth(lines[i], this.textOptions), lineWidth), linesLayout.push({
11637
- str: this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, width, suffix, wordBreak, suffixPosition).str,
11638
- width: width
11639
- });
12055
+ for (let i = 0, len = lines.length; i < len; i++) {
12056
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
12057
+ let str = lines[i].toString();
12058
+ if (metrics.width > lineWidth) {
12059
+ const data = this.textMeasure.clipTextWithSuffix(lines[i], this.textOptions, lineWidth, suffix, wordBreak, suffixPosition);
12060
+ str = data.str, width = data.width;
12061
+ } else width = metrics.width;
12062
+ linesLayout.push({
12063
+ str: str,
12064
+ width: width,
12065
+ ascent: metrics.ascent,
12066
+ descent: metrics.descent,
12067
+ keepCenterInLine: keepCenterInLine
12068
+ });
12069
+ }
11640
12070
  bboxWH[0] = lineWidth;
11641
12071
  } else {
11642
- let width, text;
11643
- lineWidth = 0;
11644
- for (let i = 0, len = lines.length; i < len; i++) text = lines[i], width = this.textMeasure.measureTextWidth(text, this.textOptions), lineWidth = Math.max(lineWidth, width), linesLayout.push({
11645
- str: text,
11646
- width: width
11647
- });
11648
- bboxWH[0] = lineWidth;
12072
+ let width,
12073
+ text,
12074
+ _lineWidth = 0;
12075
+ for (let i = 0, len = lines.length; i < len; i++) {
12076
+ text = lines[i];
12077
+ const metrics = this.textMeasure.measureTextPixelADscentAndWidth(lines[i], this.textOptions, measureMode);
12078
+ width = metrics.width, _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
12079
+ str: text,
12080
+ width: width,
12081
+ ascent: metrics.ascent,
12082
+ descent: metrics.descent,
12083
+ keepCenterInLine: keepCenterInLine
12084
+ });
12085
+ }
12086
+ bboxWH[0] = _lineWidth;
11649
12087
  }
11650
12088
  bboxWH[1] = linesLayout.length * lineHeight, bboxWH[0] = linesLayout.reduce((a, b) => Math.max(a, b.width), 0);
11651
12089
  const bbox = {
@@ -11654,7 +12092,7 @@ class CanvasTextLayout {
11654
12092
  width: bboxWH[0],
11655
12093
  height: bboxWH[1]
11656
12094
  };
11657
- return this.LayoutBBox(bbox, textAlign, textBaseline), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
12095
+ return this.LayoutBBox(bbox, textAlign, textBaseline, linesLayout), this.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
11658
12096
  }
11659
12097
  layoutWithBBox(bbox, lines, textAlign, textBaseline, lineHeight) {
11660
12098
  const origin = [0, 0],
@@ -11673,11 +12111,19 @@ class CanvasTextLayout {
11673
12111
  };
11674
12112
  }
11675
12113
  lineOffset(bbox, line, textAlign, textBaseline, lineHeight, origin) {
11676
- return "left" === textAlign || "start" === textAlign ? line.leftOffset = 0 : "center" === textAlign ? line.leftOffset = (bbox.width - line.width) / 2 : "right" !== textAlign && "end" !== textAlign || (line.leftOffset = bbox.width - line.width), line.topOffset = (lineHeight - this.textOptions.fontSize) / 2 + .79 * this.textOptions.fontSize + origin[1], origin[1] += lineHeight, line;
12114
+ 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) {
12115
+ const buf = 0,
12116
+ actualHeightWithBuf = line.ascent + line.descent + buf;
12117
+ if (actualHeightWithBuf < lineHeight - buf && ("bottom" === textBaseline ? line.topOffset += (lineHeight - actualHeightWithBuf) / 2 : "top" === textBaseline && (line.topOffset -= (lineHeight - actualHeightWithBuf) / 2)), "alphabetic" === textBaseline) {
12118
+ const ratio = lineHeight / (line.ascent + line.descent);
12119
+ line.topOffset = lineHeight / 2 + (line.ascent - line.descent) / 2 * ratio + origin[1];
12120
+ }
12121
+ }
12122
+ return origin[1] += lineHeight, line;
11677
12123
  }
11678
12124
  }
11679
12125
 
11680
- const TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY];
12126
+ 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];
11681
12127
  class Text extends Graphic {
11682
12128
  get font() {
11683
12129
  const textTheme = this.getGraphicTheme();
@@ -11686,26 +12132,22 @@ class Text extends Graphic {
11686
12132
  get clipedText() {
11687
12133
  var _a;
11688
12134
  const attribute = this.attribute,
11689
- textTheme = this.getGraphicTheme();
11690
- if (!this.isSimplify()) return;
11691
- const {
11692
- maxLineWidth = textTheme.maxLineWidth
11693
- } = attribute;
11694
- return Number.isFinite(maxLineWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
12135
+ textTheme = this.getGraphicTheme(),
12136
+ maxWidth = this.getMaxWidth(textTheme);
12137
+ return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
11695
12138
  }
11696
12139
  get clipedWidth() {
11697
- if (this.isSimplify()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
12140
+ return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
11698
12141
  }
11699
12142
  get cliped() {
11700
12143
  var _a, _b;
11701
12144
  const textTheme = this.getGraphicTheme(),
11702
12145
  attribute = this.attribute,
11703
- {
11704
- maxLineWidth = textTheme.maxLineWidth,
11705
- text: text,
11706
- whiteSpace = textTheme.whiteSpace
11707
- } = attribute;
11708
- if (!Number.isFinite(maxLineWidth)) return !1;
12146
+ maxWidth = this.getMaxWidth(textTheme);
12147
+ if (!Number.isFinite(maxWidth)) return !1;
12148
+ const {
12149
+ text: text
12150
+ } = this.attribute;
11709
12151
  if (this.tryUpdateAABBBounds(), null === (_b = null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData) || void 0 === _b ? void 0 : _b.lines) {
11710
12152
  let mergedText = "";
11711
12153
  this.cache.layoutData.lines.forEach(item => {
@@ -11716,10 +12158,7 @@ class Text extends Graphic {
11716
12158
  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();
11717
12159
  }
11718
12160
  get multilineLayout() {
11719
- if (this.isMultiLine) return this.tryUpdateAABBBounds(), this.cache.layoutData;
11720
- }
11721
- isSimplify() {
11722
- return !this.isMultiLine && "vertical" !== this.attribute.direction;
12161
+ return this.tryUpdateAABBBounds(), this.cache.layoutData;
11723
12162
  }
11724
12163
  get isMultiLine() {
11725
12164
  return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
@@ -11792,8 +12231,74 @@ class Text extends Graphic {
11792
12231
  }
11793
12232
  return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds), transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
11794
12233
  }
12234
+ updateSingallineAABBBounds(text) {
12235
+ this.updateMultilineAABBBounds([text]);
12236
+ const layoutData = this.cache.layoutData;
12237
+ if (layoutData && layoutData.lines && layoutData.lines.length) {
12238
+ const line = layoutData.lines[0];
12239
+ this.cache.clipedText = line.str, this.cache.clipedWidth = line.width;
12240
+ }
12241
+ return this._AABBBounds;
12242
+ }
12243
+ updateMultilineAABBBounds(text) {
12244
+ const textTheme = this.getGraphicTheme(),
12245
+ {
12246
+ direction = textTheme.direction,
12247
+ underlineOffset = textTheme.underlineOffset
12248
+ } = this.attribute,
12249
+ b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
12250
+ return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
12251
+ }
12252
+ guessLineHeightBuf(fontSize) {
12253
+ return fontSize ? .1 * fontSize : 0;
12254
+ }
12255
+ updateHorizontalMultilineAABBBounds(text) {
12256
+ var _a;
12257
+ const textTheme = this.getGraphicTheme(),
12258
+ attribute = this.attribute,
12259
+ {
12260
+ fontFamily = textTheme.fontFamily,
12261
+ textAlign = textTheme.textAlign,
12262
+ textBaseline = textTheme.textBaseline,
12263
+ fontSize = textTheme.fontSize,
12264
+ fontWeight = textTheme.fontWeight,
12265
+ ellipsis = textTheme.ellipsis,
12266
+ maxLineWidth: maxLineWidth,
12267
+ stroke = textTheme.stroke,
12268
+ wrap = textTheme.wrap,
12269
+ measureMode = textTheme.measureMode,
12270
+ lineWidth = textTheme.lineWidth,
12271
+ whiteSpace = textTheme.whiteSpace,
12272
+ suffixPosition = textTheme.suffixPosition,
12273
+ ignoreBuf = textTheme.ignoreBuf,
12274
+ keepCenterInLine = textTheme.keepCenterInLine
12275
+ } = attribute,
12276
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
12277
+ lineHeight = this.getLineHeight(attribute, textTheme, buf);
12278
+ if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
12279
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
12280
+ const bbox = this.cache.layoutData.bbox;
12281
+ return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
12282
+ }
12283
+ const textMeasure = application.graphicUtil.textMeasure,
12284
+ layoutData = new CanvasTextLayout(fontFamily, {
12285
+ fontSize: fontSize,
12286
+ fontWeight: fontWeight,
12287
+ fontFamily: fontFamily,
12288
+ lineHeight: lineHeight
12289
+ }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, {
12290
+ lineWidth: maxLineWidth,
12291
+ suffixPosition: suffixPosition,
12292
+ measureMode: measureMode,
12293
+ keepCenterInLine: keepCenterInLine
12294
+ }),
12295
+ {
12296
+ bbox: bbox
12297
+ } = layoutData;
12298
+ 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;
12299
+ }
11795
12300
  updateWrapAABBBounds(text) {
11796
- var _a, _b, _c, _d;
12301
+ var _a, _b, _c;
11797
12302
  const textTheme = this.getGraphicTheme(),
11798
12303
  {
11799
12304
  fontFamily = textTheme.fontFamily,
@@ -11807,22 +12312,26 @@ class Text extends Graphic {
11807
12312
  wordBreak = textTheme.wordBreak,
11808
12313
  fontWeight = textTheme.fontWeight,
11809
12314
  ignoreBuf = textTheme.ignoreBuf,
12315
+ measureMode = textTheme.measureMode,
11810
12316
  suffixPosition = textTheme.suffixPosition,
11811
12317
  heightLimit = 0,
11812
- lineClamp: lineClamp
12318
+ lineClamp: lineClamp,
12319
+ keepCenterInLine = textTheme.keepCenterInLine
11813
12320
  } = this.attribute,
11814
- lineHeight = null !== (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : this.attribute.fontSize || textTheme.fontSize,
11815
- buf = ignoreBuf ? 0 : 2;
11816
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
12321
+ buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize),
12322
+ lineHeight = this.getLineHeight(this.attribute, textTheme, buf);
12323
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
11817
12324
  const bbox = this.cache.layoutData.bbox;
11818
12325
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11819
12326
  }
11820
12327
  const textMeasure = application.graphicUtil.textMeasure,
11821
- layoutObj = new CanvasTextLayout(fontFamily, {
12328
+ textOptions = {
11822
12329
  fontSize: fontSize,
11823
12330
  fontWeight: fontWeight,
11824
- fontFamily: fontFamily
11825
- }, textMeasure),
12331
+ fontFamily: fontFamily,
12332
+ lineHeight: lineHeight
12333
+ },
12334
+ layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure),
11826
12335
  lines = isArray$1(text) ? text.map(l => l.toString()) : [text.toString()],
11827
12336
  linesLayout = [],
11828
12337
  bboxWH = [0, 0];
@@ -11832,24 +12341,32 @@ class Text extends Graphic {
11832
12341
  const str = lines[i];
11833
12342
  let needCut = !0;
11834
12343
  if (i === lineCountLimit - 1) {
11835
- const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1);
12344
+ const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1),
12345
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
11836
12346
  linesLayout.push({
11837
12347
  str: clip.str,
11838
- width: clip.width
12348
+ width: clip.width,
12349
+ ascent: matrics.ascent,
12350
+ descent: matrics.descent,
12351
+ keepCenterInLine: keepCenterInLine
11839
12352
  });
11840
12353
  break;
11841
12354
  }
11842
- const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
12355
+ const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-all" !== wordBreak, "keep-all" === wordBreak);
11843
12356
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
11844
12357
  if (ellipsis) {
11845
- const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
11846
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
12358
+ const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
12359
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
11847
12360
  } else clip.str = "", clip.width = 0;
11848
12361
  needCut = !1;
11849
12362
  }
12363
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
11850
12364
  linesLayout.push({
11851
12365
  str: clip.str,
11852
- width: clip.width
12366
+ width: clip.width,
12367
+ ascent: matrics.ascent,
12368
+ descent: matrics.descent,
12369
+ keepCenterInLine: keepCenterInLine
11853
12370
  });
11854
12371
  let cutLength = clip.str.length;
11855
12372
  if (!clip.wordBreaked || "" !== str && "" === clip.str || (needCut = !0, cutLength = clip.wordBreaked), clip.str.length === str.length) ;else if (needCut) {
@@ -11864,238 +12381,49 @@ class Text extends Graphic {
11864
12381
  } else {
11865
12382
  let width,
11866
12383
  text,
11867
- lineWidth = 0;
11868
- for (let i = 0, len = lines.length; i < len; i++) {
11869
- if (i === lineCountLimit - 1) {
11870
- const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
11871
- linesLayout.push({
11872
- str: clip.str,
11873
- width: clip.width
11874
- }), lineWidth = Math.max(lineWidth, clip.width);
11875
- break;
11876
- }
11877
- text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
11878
- str: text,
11879
- width: width
11880
- });
11881
- }
11882
- bboxWH[0] = lineWidth;
11883
- }
11884
- bboxWH[1] = linesLayout.length * (lineHeight + buf);
11885
- const bbox = {
11886
- xOffset: 0,
11887
- yOffset: 0,
11888
- width: bboxWH[0],
11889
- height: bboxWH[1]
11890
- };
11891
- layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
11892
- const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
11893
- 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;
11894
- }
11895
- updateSingallineAABBBounds(text) {
11896
- const textTheme = this.getGraphicTheme(),
11897
- {
11898
- direction = textTheme.direction,
11899
- underlineOffset = textTheme.underlineOffset
11900
- } = this.attribute,
11901
- b = "horizontal" === direction ? this.updateHorizontalSinglelineAABBBounds(text) : this.updateVerticalSinglelineAABBBounds(text);
11902
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
11903
- }
11904
- updateMultilineAABBBounds(text) {
11905
- const textTheme = this.getGraphicTheme(),
11906
- {
11907
- direction = textTheme.direction,
11908
- underlineOffset = textTheme.underlineOffset
11909
- } = this.attribute,
11910
- b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
11911
- return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset), b;
11912
- }
11913
- updateHorizontalSinglelineAABBBounds(text) {
11914
- var _a, _b;
11915
- const textTheme = this.getGraphicTheme(),
11916
- {
11917
- wrap = textTheme.wrap
11918
- } = this.attribute;
11919
- if (wrap) return this.updateWrapAABBBounds([text]);
11920
- const textMeasure = application.graphicUtil.textMeasure;
11921
- let width, str;
11922
- const attribute = this.attribute,
11923
- {
11924
- maxLineWidth = textTheme.maxLineWidth,
11925
- ellipsis = textTheme.ellipsis,
11926
- textAlign = textTheme.textAlign,
11927
- textBaseline = textTheme.textBaseline,
11928
- fontFamily = textTheme.fontFamily,
11929
- fontSize = textTheme.fontSize,
11930
- fontWeight = textTheme.fontWeight,
11931
- stroke = textTheme.stroke,
11932
- lineWidth = textTheme.lineWidth,
11933
- ignoreBuf = textTheme.ignoreBuf,
11934
- whiteSpace = textTheme.whiteSpace,
11935
- suffixPosition = textTheme.suffixPosition
11936
- } = attribute;
11937
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
11938
- const buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
11939
- textFontSize = attribute.fontSize || textTheme.fontSize,
11940
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) && void 0 !== _a ? _a : textFontSize + buf;
11941
- if (!this.shouldUpdateShape() && this.cache) {
11942
- width = null !== (_b = this.cache.clipedWidth) && void 0 !== _b ? _b : 0;
11943
- const dx = textDrawOffsetX(textAlign, width),
11944
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
11945
- return this._AABBBounds.set(dx, dy, dx + width, dy + lineHeight), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11946
- }
11947
- if (Number.isFinite(maxLineWidth)) {
11948
- if (ellipsis) {
11949
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
11950
- data = textMeasure.clipTextWithSuffix(text.toString(), {
11951
- fontSize: fontSize,
11952
- fontWeight: fontWeight,
11953
- fontFamily: fontFamily
11954
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
11955
- str = data.str, width = data.width;
11956
- } else {
11957
- const data = textMeasure.clipText(text.toString(), {
11958
- fontSize: fontSize,
11959
- fontWeight: fontWeight,
11960
- fontFamily: fontFamily
11961
- }, maxLineWidth, !1);
11962
- str = data.str, width = data.width;
11963
- }
11964
- this.cache.clipedText = str, this.cache.clipedWidth = width;
11965
- } else width = textMeasure.measureTextWidth(text.toString(), {
11966
- fontSize: fontSize,
11967
- fontWeight: fontWeight,
11968
- fontFamily: fontFamily
11969
- }), this.cache.clipedText = text.toString(), this.cache.clipedWidth = width;
11970
- this.clearUpdateShapeTag();
11971
- const dx = textDrawOffsetX(textAlign, width);
11972
- let lh = lineHeight;
11973
- application.global && application.global.isSafari() && (lh += .2 * fontSize);
11974
- const dy = textLayoutOffsetY(textBaseline, lh, fontSize, buf);
11975
- return this._AABBBounds.set(dx, dy, dx + width, dy + lh), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
11976
- }
11977
- getBaselineMapAlign() {
11978
- return Text.baselineMapAlign;
11979
- }
11980
- getAlignMapBaseline() {
11981
- return Text.alignMapBaseline;
11982
- }
11983
- updateVerticalSinglelineAABBBounds(text) {
11984
- var _a, _b, _c;
11985
- const textTheme = this.getGraphicTheme(),
11986
- textMeasure = application.graphicUtil.textMeasure;
11987
- let width;
11988
- const attribute = this.attribute,
11989
- {
11990
- ignoreBuf = textTheme.ignoreBuf
11991
- } = attribute,
11992
- buf = ignoreBuf ? 0 : 2,
11993
- {
11994
- maxLineWidth = textTheme.maxLineWidth,
11995
- ellipsis = textTheme.ellipsis,
11996
- fontSize = textTheme.fontSize,
11997
- fontWeight = textTheme.fontWeight,
11998
- fontFamily = textTheme.fontFamily,
11999
- stroke = textTheme.stroke,
12000
- lineWidth = textTheme.lineWidth,
12001
- verticalMode = textTheme.verticalMode,
12002
- suffixPosition = textTheme.suffixPosition
12003
- } = attribute,
12004
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
12005
- let {
12006
- textAlign = textTheme.textAlign,
12007
- textBaseline = textTheme.textBaseline
12008
- } = attribute;
12009
- if (!verticalMode) {
12010
- const t = textAlign;
12011
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
12012
- }
12013
- if (!this.shouldUpdateShape() && this.cache) {
12014
- width = this.cache.clipedWidth;
12015
- const dx = textDrawOffsetX(textAlign, width),
12016
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
12017
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
12018
- }
12019
- let verticalList = [verticalLayout(text.toString())];
12020
- if (Number.isFinite(maxLineWidth)) {
12021
- if (ellipsis) {
12022
- const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis,
12023
- data = textMeasure.clipTextWithSuffixVertical(verticalList[0], {
12024
- fontSize: fontSize,
12025
- fontWeight: fontWeight,
12026
- fontFamily: fontFamily
12027
- }, maxLineWidth, strEllipsis, !1, suffixPosition);
12028
- verticalList = [data.verticalList], width = data.width;
12029
- } else {
12030
- const data = textMeasure.clipTextVertical(verticalList[0], {
12031
- fontSize: fontSize,
12032
- fontWeight: fontWeight,
12033
- fontFamily: fontFamily
12034
- }, maxLineWidth, !1);
12035
- verticalList = [data.verticalList], width = data.width;
12036
- }
12037
- this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
12038
- } else width = 0, verticalList[0].forEach(t => {
12039
- const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
12040
- fontSize: fontSize,
12041
- fontWeight: fontWeight,
12042
- fontFamily: fontFamily
12043
- });
12044
- width += w, t.width = w;
12045
- }), this.cache.verticalList = verticalList, this.cache.clipedWidth = width;
12046
- this.clearUpdateShapeTag();
12047
- const dx = textDrawOffsetX(textAlign, width),
12048
- dy = textLayoutOffsetY(textBaseline, lineHeight, fontSize);
12049
- return this._AABBBounds.set(dy, dx, dy + lineHeight, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
12050
- }
12051
- updateHorizontalMultilineAABBBounds(text) {
12052
- var _a, _b;
12053
- const textTheme = this.getGraphicTheme(),
12054
- {
12055
- wrap = textTheme.wrap
12056
- } = this.attribute;
12057
- if (wrap) return this.updateWrapAABBBounds(text);
12058
- const attribute = this.attribute,
12059
- {
12060
- fontFamily = textTheme.fontFamily,
12061
- textAlign = textTheme.textAlign,
12062
- textBaseline = textTheme.textBaseline,
12063
- fontSize = textTheme.fontSize,
12064
- fontWeight = textTheme.fontWeight,
12065
- ellipsis = textTheme.ellipsis,
12066
- maxLineWidth: maxLineWidth,
12067
- stroke = textTheme.stroke,
12068
- lineWidth = textTheme.lineWidth,
12069
- whiteSpace = textTheme.whiteSpace,
12070
- suffixPosition = textTheme.suffixPosition
12071
- } = attribute,
12072
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
12073
- if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
12074
- if (!this.shouldUpdateShape() && (null === (_b = this.cache) || void 0 === _b ? void 0 : _b.layoutData)) {
12075
- const bbox = this.cache.layoutData.bbox;
12076
- return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
12384
+ lineWidth = 0;
12385
+ for (let i = 0, len = lines.length; i < len; i++) {
12386
+ if (i === lineCountLimit - 1) {
12387
+ const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition),
12388
+ matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions, measureMode);
12389
+ linesLayout.push({
12390
+ str: clip.str,
12391
+ width: clip.width,
12392
+ ascent: matrics.ascent,
12393
+ descent: matrics.descent,
12394
+ keepCenterInLine: keepCenterInLine
12395
+ }), lineWidth = Math.max(lineWidth, clip.width);
12396
+ break;
12397
+ }
12398
+ text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
12399
+ const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions, measureMode);
12400
+ linesLayout.push({
12401
+ str: text,
12402
+ width: width,
12403
+ ascent: matrics.ascent,
12404
+ descent: matrics.descent,
12405
+ keepCenterInLine: keepCenterInLine
12406
+ });
12407
+ }
12408
+ bboxWH[0] = lineWidth;
12077
12409
  }
12078
- const textMeasure = application.graphicUtil.textMeasure,
12079
- layoutData = new CanvasTextLayout(fontFamily, {
12080
- fontSize: fontSize,
12081
- fontWeight: fontWeight,
12082
- fontFamily: fontFamily
12083
- }, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition),
12084
- {
12085
- bbox: bbox
12086
- } = layoutData;
12410
+ bboxWH[1] = linesLayout.length * lineHeight;
12411
+ const bbox = {
12412
+ xOffset: 0,
12413
+ yOffset: 0,
12414
+ width: bboxWH[0],
12415
+ height: bboxWH[1]
12416
+ };
12417
+ layoutObj.LayoutBBox(bbox, textAlign, textBaseline, linesLayout);
12418
+ const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
12087
12419
  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;
12088
12420
  }
12089
12421
  updateVerticalMultilineAABBBounds(text) {
12090
- var _a, _b, _c;
12422
+ var _a, _b;
12091
12423
  const textTheme = this.getGraphicTheme(),
12092
12424
  textMeasure = application.graphicUtil.textMeasure;
12093
12425
  let width;
12094
12426
  const attribute = this.attribute,
12095
- {
12096
- ignoreBuf = textTheme.ignoreBuf
12097
- } = attribute,
12098
- buf = ignoreBuf ? 0 : 2,
12099
12427
  {
12100
12428
  maxLineWidth = textTheme.maxLineWidth,
12101
12429
  ellipsis = textTheme.ellipsis,
@@ -12107,14 +12435,14 @@ class Text extends Graphic {
12107
12435
  verticalMode = textTheme.verticalMode,
12108
12436
  suffixPosition = textTheme.suffixPosition
12109
12437
  } = attribute,
12110
- lineHeight = null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
12438
+ lineHeight = this.getLineHeight(attribute, textTheme, 0);
12111
12439
  let {
12112
12440
  textAlign = textTheme.textAlign,
12113
12441
  textBaseline = textTheme.textBaseline
12114
12442
  } = attribute;
12115
12443
  if (!verticalMode) {
12116
12444
  const t = textAlign;
12117
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
12445
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
12118
12446
  }
12119
12447
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
12120
12448
  this.cache.verticalList.forEach(item => {
@@ -12162,6 +12490,15 @@ class Text extends Graphic {
12162
12490
  dy = textLayoutOffsetY(textBaseline, height, fontSize);
12163
12491
  return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
12164
12492
  }
12493
+ getMaxWidth(theme) {
12494
+ var _a, _b;
12495
+ const attribute = this.attribute;
12496
+ return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
12497
+ }
12498
+ getLineHeight(attribute, textTheme, buf) {
12499
+ var _a;
12500
+ return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
12501
+ }
12165
12502
  needUpdateTags(keys) {
12166
12503
  let k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_UPDATE_TAG_KEY;
12167
12504
  return super.needUpdateTags(keys, k);
@@ -12176,6 +12513,12 @@ class Text extends Graphic {
12176
12513
  getNoWorkAnimateAttr() {
12177
12514
  return Text.NOWORK_ANIMATE_ATTR;
12178
12515
  }
12516
+ getBaselineMapAlign() {
12517
+ return Text.baselineMapAlign;
12518
+ }
12519
+ getAlignMapBaseline() {
12520
+ return Text.alignMapBaseline;
12521
+ }
12179
12522
  }
12180
12523
  Text.NOWORK_ANIMATE_ATTR = Object.assign({
12181
12524
  ellipsis: 1,
@@ -12254,7 +12597,10 @@ class WrapText extends Text {
12254
12597
  const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
12255
12598
  linesLayout.push({
12256
12599
  str: clip.str,
12257
- width: clip.width
12600
+ width: clip.width,
12601
+ ascent: 0,
12602
+ descent: 0,
12603
+ keepCenterInLine: !1
12258
12604
  });
12259
12605
  break;
12260
12606
  }
@@ -12268,7 +12614,10 @@ class WrapText extends Text {
12268
12614
  }
12269
12615
  if (linesLayout.push({
12270
12616
  str: clip.str,
12271
- width: clip.width
12617
+ width: clip.width,
12618
+ ascent: 0,
12619
+ descent: 0,
12620
+ keepCenterInLine: !1
12272
12621
  }), clip.str.length === str.length) ;else if (needCut) {
12273
12622
  const newStr = str.substring(clip.str.length);
12274
12623
  lines.splice(i + 1, 0, newStr);
@@ -12287,13 +12636,19 @@ class WrapText extends Text {
12287
12636
  const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
12288
12637
  linesLayout.push({
12289
12638
  str: clip.str,
12290
- width: clip.width
12639
+ width: clip.width,
12640
+ ascent: 0,
12641
+ descent: 0,
12642
+ keepCenterInLine: !1
12291
12643
  }), lineWidth = Math.max(lineWidth, clip.width);
12292
12644
  break;
12293
12645
  }
12294
12646
  text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak), lineWidth = Math.max(lineWidth, width), linesLayout.push({
12295
12647
  str: text,
12296
- width: width
12648
+ width: width,
12649
+ ascent: 0,
12650
+ descent: 0,
12651
+ keepCenterInLine: !1
12297
12652
  });
12298
12653
  }
12299
12654
  bboxWH[0] = lineWidth;
@@ -13503,7 +13858,11 @@ class Paragraph {
13503
13858
  case "sub":
13504
13859
  baseline += this.descent / 2;
13505
13860
  }
13506
- "vertical" === direction && (ctx.save(), ctx.rotateAbout(Math.PI / 2, left, baseline), ctx.translate(-this.heightOrigin || -this.lineHeight / 2, -this.descent / 2), ctx.translate(left, baseline), left = 0, baseline = 0), this.character.stroke && (applyStrokeStyle(ctx, this.character), ctx.strokeText(text, left, baseline)), applyFillStyle(ctx, this.character), this.character.fill && ctx.fillText(text, left, baseline), this.character.fill && ("boolean" == typeof this.character.lineThrough || "boolean" == typeof this.character.underline ? (this.character.underline && ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1), this.character.lineThrough && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)) : "underline" === this.character.textDecoration ? ctx.fillRect(left, 1 + baseline, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1) : "line-through" === this.character.textDecoration && ctx.fillRect(left, 1 + baseline - this.ascent / 2, this.widthOrigin || this.width, this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1)), "vertical" === direction && ctx.restore();
13861
+ "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);
13862
+ const {
13863
+ lineWidth = 1
13864
+ } = this.character;
13865
+ 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();
13507
13866
  }
13508
13867
  getWidthWithEllips(direction) {
13509
13868
  let text = this.text;
@@ -13726,12 +14085,18 @@ class Line {
13726
14085
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
13727
14086
  }
13728
14087
  }
13729
- this.paragraphs.map((paragraph, index) => {
14088
+ this.paragraphs.forEach((paragraph, index) => {
13730
14089
  if (paragraph instanceof RichTextIcon) return paragraph.setAttributes({
13731
14090
  x: x + paragraph._x,
13732
14091
  y: y + paragraph._y
13733
14092
  }), void drawIcon(paragraph, ctx, x + paragraph._x, y + paragraph._y, this.ascent);
13734
- paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
14093
+ const b = {
14094
+ x1: this.left,
14095
+ y1: this.top,
14096
+ x2: this.left + this.actualWidth,
14097
+ y2: this.top + this.height
14098
+ };
14099
+ applyStrokeStyle(ctx, paragraph.character), applyFillStyle(ctx, paragraph.character, b), paragraph.draw(ctx, y + this.ascent, x, 0 === index, this.textAlign);
13735
14100
  });
13736
14101
  }
13737
14102
  getWidthWithEllips(ellipsis) {
@@ -13754,7 +14119,7 @@ class Line {
13754
14119
  paragraph.ellipsis = "hide", otherParagraphWidth += paragraph.width;
13755
14120
  }
13756
14121
  let width = 0;
13757
- return this.paragraphs.map((paragraph, index) => {
14122
+ return this.paragraphs.forEach((paragraph, index) => {
13758
14123
  width += paragraph instanceof RichTextIcon ? paragraph.width : paragraph.getWidthWithEllips(this.direction);
13759
14124
  }), width;
13760
14125
  }
@@ -14028,1127 +14393,841 @@ class RichText extends Graphic {
14028
14393
  l.calcOffset(offsetSize, !1);
14029
14394
  });
14030
14395
  }
14031
- this._frameCache = frame;
14032
- }
14033
- clone() {
14034
- return new RichText(Object.assign({}, this.attribute));
14035
- }
14036
- setStage(stage, layer) {
14037
- super.setStage(stage, layer);
14038
- this.getFrameCache().icons.forEach(icon => {
14039
- icon.setStage(stage, layer);
14040
- });
14041
- }
14042
- bindIconEvent() {
14043
- this.addEventListener("pointermove", e => {
14044
- const pickedIcon = this.pickIcon(e.global);
14045
- pickedIcon && pickedIcon === this._currentHoverIcon || (pickedIcon ? this.setAttribute("hoverIconId", pickedIcon.richtextId) : !pickedIcon && this._currentHoverIcon && this.setAttribute("hoverIconId", void 0));
14046
- }), this.addEventListener("pointerleave", e => {
14047
- this._currentHoverIcon && this.setAttribute("hoverIconId", void 0);
14048
- });
14049
- }
14050
- updateHoverIconState(pickedIcon) {
14051
- var _a, _b, _c, _d, _e;
14052
- 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());
14053
- }
14054
- pickIcon(point) {
14055
- const frameCache = this.getFrameCache(),
14056
- {
14057
- e: x,
14058
- f: y
14059
- } = this.globalTransMatrix;
14060
- let pickIcon;
14061
- return frameCache.icons.forEach((icon, key) => {
14062
- var _a, _b;
14063
- const bounds = icon.AABBBounds.clone();
14064
- bounds.translate(icon._marginArray[3], icon._marginArray[0]), bounds.containsPoint({
14065
- x: point.x - x,
14066
- y: point.y - y
14067
- }) && (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]);
14068
- }), pickIcon;
14069
- }
14070
- getNoWorkAnimateAttr() {
14071
- return RichText.NOWORK_ANIMATE_ATTR;
14072
- }
14073
- }
14074
- RichText.NOWORK_ANIMATE_ATTR = Object.assign({
14075
- ellipsis: 1,
14076
- wordBreak: 1,
14077
- verticalDirection: 1,
14078
- textAlign: 1,
14079
- textBaseline: 1,
14080
- textConfig: 1,
14081
- layoutDirection: 1
14082
- }, NOWORK_ANIMATE_ATTR);
14083
- function createRichText(attributes) {
14084
- return new RichText(attributes);
14085
- }
14086
-
14087
- const PATH_UPDATE_TAG_KEY = ["path", "customPath", ...GRAPHIC_UPDATE_TAG_KEY];
14088
- class Path extends Graphic {
14089
- constructor(params) {
14090
- super(params), this.type = "path", this.numberType = PATH_NUMBER_TYPE;
14091
- }
14092
- get pathShape() {
14093
- return this.tryUpdateAABBBounds(), this.getParsedPathShape();
14094
- }
14095
- isValid() {
14096
- return super.isValid() && this._isValid();
14097
- }
14098
- _isValid() {
14099
- const {
14100
- path: path
14101
- } = this.attribute;
14102
- return null != path && "" !== path;
14103
- }
14104
- getParsedPathShape() {
14105
- const pathTheme = this.getGraphicTheme();
14106
- if (!this.valid) return pathTheme.path;
14107
- const attribute = this.attribute;
14108
- return attribute.path instanceof CustomPath2D ? attribute.path : (isNil$1(this.cache) && this.doUpdatePathShape(), this.cache instanceof CustomPath2D ? this.cache : pathTheme.path);
14109
- }
14110
- getGraphicTheme() {
14111
- return getTheme(this).path;
14112
- }
14113
- updateAABBBounds(attribute, pathTheme, aabbBounds) {
14114
- if (!this.updatePathProxyAABBBounds(aabbBounds)) {
14115
- const pathShape = this.getParsedPathShape();
14116
- aabbBounds.union(pathShape.getBounds());
14117
- }
14118
- const {
14119
- tb1: tb1,
14120
- tb2: tb2
14121
- } = application.graphicService.updateTempAABBBounds(aabbBounds);
14122
- updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
14123
- const {
14124
- lineJoin = pathTheme.lineJoin
14125
- } = attribute;
14126
- return application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this), aabbBounds;
14127
- }
14128
- doUpdateAABBBounds(full) {
14129
- return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
14130
- }
14131
- doUpdatePathShape() {
14132
- const attribute = this.attribute;
14133
- isString$1(attribute.path, !0) ? this.cache = new CustomPath2D().fromString(attribute.path) : attribute.customPath && (this.cache = new CustomPath2D(), attribute.customPath(this.cache, this));
14134
- }
14135
- needUpdateTags(keys) {
14136
- return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);
14137
- }
14138
- needUpdateTag(key) {
14139
- return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);
14140
- }
14141
- toCustomPath() {
14142
- return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), 0, 0);
14143
- }
14144
- clone() {
14145
- return new Path(Object.assign({}, this.attribute));
14146
- }
14147
- getNoWorkAnimateAttr() {
14148
- return Path.NOWORK_ANIMATE_ATTR;
14149
- }
14150
- }
14151
- Path.NOWORK_ANIMATE_ATTR = Object.assign({
14152
- path: 1,
14153
- customPath: 1
14154
- }, NOWORK_ANIMATE_ATTR);
14155
- function createPath(attributes) {
14156
- return new Path(attributes);
14157
- }
14158
-
14159
- const AREA_UPDATE_TAG_KEY = ["segments", "points", "curveType", "curveTension", ...GRAPHIC_UPDATE_TAG_KEY];
14160
- class Area extends Graphic {
14161
- constructor(params) {
14162
- super(params), this.type = "area", this.numberType = AREA_NUMBER_TYPE;
14163
- }
14164
- isValid() {
14165
- return super.isValid() && this._isValid();
14166
- }
14167
- _isValid() {
14168
- if (this.pathProxy) return !0;
14169
- const {
14170
- points: points,
14171
- segments: segments
14172
- } = this.attribute;
14173
- return segments ? 0 !== segments.length : !!points && 0 !== points.length;
14174
- }
14175
- getGraphicTheme() {
14176
- return getTheme(this).area;
14177
- }
14178
- updateAABBBounds(attribute, areaTheme, aabbBounds) {
14179
- this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
14180
- const {
14181
- lineJoin = areaTheme.lineJoin
14182
- } = attribute;
14183
- return application.graphicService.transformAABBBounds(attribute, aabbBounds, areaTheme, "miter" === lineJoin, this), aabbBounds;
14184
- }
14185
- updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds, graphic) {
14186
- const {
14187
- points = areaTheme.points
14188
- } = attribute,
14189
- b = aabbBounds;
14190
- return points.forEach(p => {
14191
- var _a, _b;
14192
- 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);
14193
- }), b;
14194
- }
14195
- updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic) {
14196
- const {
14197
- segments = areaTheme.segments
14198
- } = attribute,
14199
- b = aabbBounds;
14200
- return segments.forEach(s => {
14201
- s.points.forEach(p => {
14202
- var _a, _b;
14203
- 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);
14204
- });
14205
- }), b;
14206
- }
14207
- _interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
14208
- "points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
14209
- }
14210
- needUpdateTags(keys) {
14211
- return super.needUpdateTags(keys, AREA_UPDATE_TAG_KEY);
14212
- }
14213
- needUpdateTag(key) {
14214
- return super.needUpdateTag(key, AREA_UPDATE_TAG_KEY);
14215
- }
14216
- toCustomPath() {
14217
- const path = new CustomPath2D(),
14218
- attribute = this.attribute,
14219
- segments = attribute.segments,
14220
- parsePoints = points => {
14221
- if (points && points.length) {
14222
- let isFirst = !0;
14223
- const basePoints = [];
14224
- if (points.forEach(point => {
14225
- var _a, _b;
14226
- !1 !== point.defined && (isFirst ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y), basePoints.push({
14227
- x: null !== (_a = point.x1) && void 0 !== _a ? _a : point.x,
14228
- y: null !== (_b = point.y1) && void 0 !== _b ? _b : point.y
14229
- }), isFirst = !1);
14230
- }), basePoints.length) {
14231
- for (let i = basePoints.length - 1; i >= 0; i--) path.lineTo(basePoints[i].x, basePoints[i].y);
14232
- path.closePath();
14233
- }
14234
- }
14235
- };
14236
- return attribute.points ? parsePoints(attribute.points) : segments && segments.length && segments.forEach(seg => {
14237
- parsePoints(seg.points);
14238
- }), path;
14396
+ this._frameCache = frame;
14239
14397
  }
14240
14398
  clone() {
14241
- return new Area(Object.assign({}, this.attribute));
14399
+ return new RichText(Object.assign({}, this.attribute));
14400
+ }
14401
+ setStage(stage, layer) {
14402
+ super.setStage(stage, layer);
14403
+ this.getFrameCache().icons.forEach(icon => {
14404
+ icon.setStage(stage, layer);
14405
+ });
14406
+ }
14407
+ bindIconEvent() {
14408
+ this.addEventListener("pointermove", e => {
14409
+ const pickedIcon = this.pickIcon(e.global);
14410
+ pickedIcon && pickedIcon === this._currentHoverIcon || (pickedIcon ? this.setAttribute("hoverIconId", pickedIcon.richtextId) : !pickedIcon && this._currentHoverIcon && this.setAttribute("hoverIconId", void 0));
14411
+ }), this.addEventListener("pointerleave", e => {
14412
+ this._currentHoverIcon && this.setAttribute("hoverIconId", void 0);
14413
+ });
14414
+ }
14415
+ updateHoverIconState(pickedIcon) {
14416
+ var _a, _b, _c, _d, _e;
14417
+ 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());
14418
+ }
14419
+ pickIcon(point) {
14420
+ const frameCache = this.getFrameCache(),
14421
+ {
14422
+ e: x,
14423
+ f: y
14424
+ } = this.globalTransMatrix;
14425
+ let pickIcon;
14426
+ return frameCache.icons.forEach((icon, key) => {
14427
+ var _a, _b;
14428
+ const bounds = icon.AABBBounds.clone();
14429
+ bounds.translate(icon._marginArray[3], icon._marginArray[0]), bounds.containsPoint({
14430
+ x: point.x - x,
14431
+ y: point.y - y
14432
+ }) && (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]);
14433
+ }), pickIcon;
14242
14434
  }
14243
14435
  getNoWorkAnimateAttr() {
14244
- return Area.NOWORK_ANIMATE_ATTR;
14436
+ return RichText.NOWORK_ANIMATE_ATTR;
14245
14437
  }
14246
14438
  }
14247
- Area.NOWORK_ANIMATE_ATTR = Object.assign({
14248
- segments: 1,
14249
- curveType: 1
14439
+ RichText.NOWORK_ANIMATE_ATTR = Object.assign({
14440
+ ellipsis: 1,
14441
+ wordBreak: 1,
14442
+ verticalDirection: 1,
14443
+ textAlign: 1,
14444
+ textBaseline: 1,
14445
+ textConfig: 1,
14446
+ layoutDirection: 1
14250
14447
  }, NOWORK_ANIMATE_ATTR);
14251
- function createArea(attributes) {
14252
- return new Area(attributes);
14448
+ function createRichText(attributes) {
14449
+ return new RichText(attributes);
14253
14450
  }
14254
14451
 
14255
- const ARC_UPDATE_TAG_KEY = ["innerRadius", "outerRadius", "startAngle", "endAngle", "cornerRadius", "padAngle", "padRadius", "cap", ...GRAPHIC_UPDATE_TAG_KEY];
14256
- class Arc extends Graphic {
14452
+ const PATH_UPDATE_TAG_KEY = ["path", "customPath", ...GRAPHIC_UPDATE_TAG_KEY];
14453
+ class Path extends Graphic {
14257
14454
  constructor(params) {
14258
- super(params), this.type = "arc", this.numberType = ARC_NUMBER_TYPE;
14455
+ super(params), this.type = "path", this.numberType = PATH_NUMBER_TYPE;
14456
+ }
14457
+ get pathShape() {
14458
+ return this.tryUpdateAABBBounds(), this.getParsedPathShape();
14259
14459
  }
14260
14460
  isValid() {
14261
14461
  return super.isValid() && this._isValid();
14262
14462
  }
14263
14463
  _isValid() {
14264
14464
  const {
14265
- startAngle: startAngle,
14266
- endAngle: endAngle,
14267
- outerRadius: outerRadius,
14268
- innerRadius: innerRadius
14269
- } = this.attribute;
14270
- return this._validNumber(startAngle) && this._validNumber(endAngle) && this._validNumber(outerRadius) && this._validNumber(innerRadius);
14271
- }
14272
- getParsedCornerRadius() {
14273
- const arcTheme = this.getGraphicTheme(),
14274
- {
14275
- cornerRadius = arcTheme.cornerRadius,
14276
- innerPadding = arcTheme.innerPadding,
14277
- outerPadding = arcTheme.outerPadding
14278
- } = this.attribute;
14279
- let {
14280
- outerRadius = arcTheme.outerRadius,
14281
- innerRadius = arcTheme.innerRadius
14282
- } = this.attribute;
14283
- if (outerRadius += outerPadding, innerRadius -= innerPadding, 0 === cornerRadius || "0%" === cornerRadius) return 0;
14284
- const deltaRadius = Math.abs(outerRadius - innerRadius),
14285
- parseCR = cornerRadius => Math.min(isNumber$1(cornerRadius, !0) ? cornerRadius : deltaRadius * parseFloat(cornerRadius) / 100, deltaRadius / 2);
14286
- if (isArray$1(cornerRadius)) {
14287
- const crList = cornerRadius.map(cr => parseCR(cr) || 0);
14288
- 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);
14289
- }
14290
- return parseCR(cornerRadius);
14291
- }
14292
- getParsedAngle() {
14293
- const arcTheme = this.getGraphicTheme();
14294
- let {
14295
- startAngle = arcTheme.startAngle,
14296
- endAngle = arcTheme.endAngle
14465
+ path: path
14297
14466
  } = this.attribute;
14298
- const {
14299
- cap = arcTheme.cap
14300
- } = this.attribute,
14301
- sign = endAngle - startAngle >= 0 ? 1 : -1,
14302
- deltaAngle = endAngle - startAngle;
14303
- if (startAngle = clampAngleByRadian(startAngle), endAngle = startAngle + deltaAngle, cap && abs(deltaAngle) < pi2 - epsilon) {
14304
- let startCap = 1,
14305
- endCap = 1;
14306
- cap.length && (startCap = Number(cap[0]), endCap = Number(cap[1]));
14307
- let {
14308
- outerRadius = arcTheme.outerRadius,
14309
- innerRadius = arcTheme.innerRadius
14310
- } = this.attribute;
14311
- const {
14312
- outerPadding = arcTheme.outerPadding,
14313
- innerPadding = arcTheme.innerPadding
14314
- } = this.attribute;
14315
- outerRadius += outerPadding, innerRadius -= innerPadding;
14316
- const capWidth = Math.abs(outerRadius - innerRadius) / 2,
14317
- capAngle = capWidth / outerRadius;
14318
- if (capWidth > epsilon && outerRadius > epsilon) return {
14319
- startAngle: startAngle - sign * capAngle * startCap,
14320
- endAngle: endAngle + sign * capAngle * endCap,
14321
- sc: sign * capAngle * startCap,
14322
- ec: sign * capAngle * endCap
14323
- };
14324
- }
14325
- return {
14326
- startAngle: startAngle,
14327
- endAngle: endAngle
14328
- };
14467
+ return null != path && "" !== path;
14329
14468
  }
14330
- getParsePadAngle(startAngle, endAngle) {
14331
- const arcTheme = this.getGraphicTheme(),
14332
- {
14333
- innerPadding = arcTheme.innerPadding,
14334
- outerPadding = arcTheme.outerPadding,
14335
- padAngle = arcTheme.padAngle
14336
- } = this.attribute;
14337
- let {
14338
- outerRadius = arcTheme.outerRadius,
14339
- innerRadius = arcTheme.innerRadius
14340
- } = this.attribute;
14341
- outerRadius += outerPadding, innerRadius -= innerPadding;
14342
- const {
14343
- padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
14344
- } = this.attribute,
14345
- deltaAngle = abs(endAngle - startAngle);
14346
- let outerStartAngle = startAngle,
14347
- outerEndAngle = endAngle,
14348
- innerStartAngle = startAngle,
14349
- innerEndAngle = endAngle;
14350
- const halfPadAngle = padAngle / 2;
14351
- let innerDeltaAngle = deltaAngle,
14352
- outerDeltaAngle = deltaAngle;
14353
- if (halfPadAngle > epsilon && padRadius > epsilon) {
14354
- const sign = endAngle > startAngle ? 1 : -1;
14355
- let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
14356
- p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
14357
- 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), {
14358
- outerStartAngle: outerStartAngle,
14359
- outerEndAngle: outerEndAngle,
14360
- innerStartAngle: innerStartAngle,
14361
- innerEndAngle: innerEndAngle,
14362
- innerDeltaAngle: innerDeltaAngle,
14363
- outerDeltaAngle: outerDeltaAngle
14364
- };
14365
- }
14366
- return {
14367
- outerStartAngle: outerStartAngle,
14368
- outerEndAngle: outerEndAngle,
14369
- innerStartAngle: innerStartAngle,
14370
- innerEndAngle: innerEndAngle,
14371
- innerDeltaAngle: innerDeltaAngle,
14372
- outerDeltaAngle: outerDeltaAngle
14373
- };
14469
+ getParsedPathShape() {
14470
+ const pathTheme = this.getGraphicTheme();
14471
+ if (!this.valid) return pathTheme.path;
14472
+ const attribute = this.attribute;
14473
+ return attribute.path instanceof CustomPath2D ? attribute.path : (isNil$1(this.cache) && this.doUpdatePathShape(), this.cache instanceof CustomPath2D ? this.cache : pathTheme.path);
14374
14474
  }
14375
14475
  getGraphicTheme() {
14376
- return getTheme(this).arc;
14476
+ return getTheme(this).path;
14377
14477
  }
14378
- updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
14379
- this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
14478
+ updateAABBBounds(attribute, pathTheme, aabbBounds) {
14479
+ if (!this.updatePathProxyAABBBounds(aabbBounds)) {
14480
+ const pathShape = this.getParsedPathShape();
14481
+ aabbBounds.union(pathShape.getBounds());
14482
+ }
14380
14483
  const {
14381
14484
  tb1: tb1,
14382
14485
  tb2: tb2
14383
14486
  } = application.graphicService.updateTempAABBBounds(aabbBounds);
14384
- updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
14385
- const {
14386
- lineJoin = arcTheme.lineJoin
14387
- } = attribute;
14388
- return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
14389
- }
14390
- updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
14391
- let {
14392
- outerRadius = arcTheme.outerRadius,
14393
- innerRadius = arcTheme.innerRadius
14394
- } = attribute;
14395
- const {
14396
- outerPadding = arcTheme.outerPadding,
14397
- innerPadding = arcTheme.innerPadding
14398
- } = attribute;
14399
- return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
14400
- }
14401
- updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
14402
- let {
14403
- outerRadius = arcTheme.outerRadius,
14404
- innerRadius = arcTheme.innerRadius
14405
- } = attribute;
14487
+ updateBoundsOfCommonOuterBorder(attribute, pathTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
14406
14488
  const {
14407
- outerPadding = arcTheme.outerPadding,
14408
- innerPadding = arcTheme.innerPadding
14409
- } = attribute;
14410
- if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
14411
- const temp = outerRadius;
14412
- outerRadius = innerRadius, innerRadius = temp;
14413
- }
14414
- let {
14415
- endAngle = arcTheme.endAngle,
14416
- startAngle = arcTheme.startAngle
14489
+ lineJoin = pathTheme.lineJoin
14417
14490
  } = attribute;
14418
- if (startAngle > endAngle) {
14419
- const temp = startAngle;
14420
- startAngle = endAngle, endAngle = temp;
14421
- }
14422
- 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;
14423
- }
14424
- needUpdateTags(keys) {
14425
- return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
14426
- }
14427
- needUpdateTag(key) {
14428
- return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
14429
- }
14430
- toCustomPath() {
14431
- var _a, _b, _c, _d;
14432
- const attribute = this.attribute,
14433
- {
14434
- startAngle: startAngle,
14435
- endAngle: endAngle
14436
- } = this.getParsedAngle();
14437
- let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
14438
- outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
14439
- const deltaAngle = abs(endAngle - startAngle),
14440
- clockwise = endAngle > startAngle;
14441
- if (outerRadius < innerRadius) {
14442
- const temp = outerRadius;
14443
- outerRadius = innerRadius, innerRadius = temp;
14444
- }
14445
- const path = new CustomPath2D();
14446
- 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 {
14447
- const xors = outerRadius * cos(startAngle),
14448
- yors = outerRadius * sin(startAngle),
14449
- xire = innerRadius * cos(endAngle),
14450
- yire = innerRadius * sin(endAngle);
14451
- 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();
14452
- }
14453
- return path;
14491
+ return application.graphicService.transformAABBBounds(attribute, aabbBounds, pathTheme, "miter" === lineJoin, this), aabbBounds;
14454
14492
  }
14455
- clone() {
14456
- return new Arc(Object.assign({}, this.attribute));
14493
+ doUpdateAABBBounds(full) {
14494
+ return this.doUpdatePathShape(), super.doUpdateAABBBounds(full);
14457
14495
  }
14458
- getNoWorkAnimateAttr() {
14459
- return Arc.NOWORK_ANIMATE_ATTR;
14496
+ doUpdatePathShape() {
14497
+ const attribute = this.attribute;
14498
+ isString$1(attribute.path, !0) ? this.cache = new CustomPath2D().fromString(attribute.path) : attribute.customPath && (this.cache = new CustomPath2D(), attribute.customPath(this.cache, this));
14460
14499
  }
14461
- }
14462
- Arc.NOWORK_ANIMATE_ATTR = Object.assign({
14463
- cap: 1
14464
- }, NOWORK_ANIMATE_ATTR);
14465
- function createArc(attributes) {
14466
- return new Arc(attributes);
14467
- }
14468
-
14469
- class Arc3d extends Arc {
14470
- constructor(params) {
14471
- super(params), this.type = "arc3d", this.numberType = ARC3D_NUMBER_TYPE;
14500
+ needUpdateTags(keys) {
14501
+ return super.needUpdateTags(keys, PATH_UPDATE_TAG_KEY);
14472
14502
  }
14473
- updateAABBBounds(attribute, arcTheme, aabbBounds) {
14474
- const stage = this.stage;
14475
- if (!stage || !stage.camera) return aabbBounds;
14476
- const {
14477
- outerRadius = arcTheme.outerRadius,
14478
- height = 0
14479
- } = attribute,
14480
- r = outerRadius + height;
14481
- return aabbBounds.setValue(-r, -r, r, r), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, !1, this), aabbBounds;
14503
+ needUpdateTag(key) {
14504
+ return super.needUpdateTag(key, PATH_UPDATE_TAG_KEY);
14505
+ }
14506
+ toCustomPath() {
14507
+ return new CustomPath2D().fromCustomPath2D(this.getParsedPathShape(), 0, 0);
14508
+ }
14509
+ clone() {
14510
+ return new Path(Object.assign({}, this.attribute));
14482
14511
  }
14483
14512
  getNoWorkAnimateAttr() {
14484
- return Arc3d.NOWORK_ANIMATE_ATTR;
14513
+ return Path.NOWORK_ANIMATE_ATTR;
14485
14514
  }
14486
14515
  }
14487
- Arc3d.NOWORK_ANIMATE_ATTR = Object.assign({
14488
- cap: 1
14516
+ Path.NOWORK_ANIMATE_ATTR = Object.assign({
14517
+ path: 1,
14518
+ customPath: 1
14489
14519
  }, NOWORK_ANIMATE_ATTR);
14490
- function createArc3d(attributes) {
14491
- return new Arc3d(attributes);
14520
+ function createPath(attributes) {
14521
+ return new Path(attributes);
14492
14522
  }
14493
14523
 
14494
- const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
14495
- class Polygon extends Graphic {
14524
+ const AREA_UPDATE_TAG_KEY = ["segments", "points", "curveType", "curveTension", ...GRAPHIC_UPDATE_TAG_KEY];
14525
+ class Area extends Graphic {
14496
14526
  constructor(params) {
14497
- super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
14527
+ super(params), this.type = "area", this.numberType = AREA_NUMBER_TYPE;
14498
14528
  }
14499
14529
  isValid() {
14500
14530
  return super.isValid() && this._isValid();
14501
14531
  }
14502
14532
  _isValid() {
14533
+ if (this.pathProxy) return !0;
14503
14534
  const {
14504
- points: points
14535
+ points: points,
14536
+ segments: segments
14505
14537
  } = this.attribute;
14506
- return points && points.length >= 2;
14538
+ return segments ? 0 !== segments.length : !!points && 0 !== points.length;
14507
14539
  }
14508
14540
  getGraphicTheme() {
14509
- return getTheme(this).polygon;
14541
+ return getTheme(this).area;
14510
14542
  }
14511
- updateAABBBounds(attribute, polygonTheme, aabbBounds) {
14512
- this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds);
14543
+ updateAABBBounds(attribute, areaTheme, aabbBounds) {
14544
+ this.updatePathProxyAABBBounds(aabbBounds) || (attribute.segments ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds) : this.updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds)), application.graphicService.updateTempAABBBounds(aabbBounds);
14513
14545
  const {
14514
- lineJoin = polygonTheme.lineJoin
14546
+ lineJoin = areaTheme.lineJoin
14515
14547
  } = attribute;
14516
- return application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, "miter" === lineJoin, this), aabbBounds;
14548
+ return application.graphicService.transformAABBBounds(attribute, aabbBounds, areaTheme, "miter" === lineJoin, this), aabbBounds;
14517
14549
  }
14518
- updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds) {
14550
+ updateAreaAABBBoundsByPoints(attribute, areaTheme, aabbBounds, graphic) {
14519
14551
  const {
14520
- points = polygonTheme.points
14521
- } = attribute;
14552
+ points = areaTheme.points
14553
+ } = attribute,
14554
+ b = aabbBounds;
14522
14555
  return points.forEach(p => {
14523
- aabbBounds.add(p.x, p.y);
14524
- }), aabbBounds;
14556
+ var _a, _b;
14557
+ 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);
14558
+ }), b;
14559
+ }
14560
+ updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic) {
14561
+ const {
14562
+ segments = areaTheme.segments
14563
+ } = attribute,
14564
+ b = aabbBounds;
14565
+ return segments.forEach(s => {
14566
+ s.points.forEach(p => {
14567
+ var _a, _b;
14568
+ 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);
14569
+ });
14570
+ }), b;
14525
14571
  }
14526
14572
  _interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
14527
14573
  "points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
14528
14574
  }
14529
14575
  needUpdateTags(keys) {
14530
- return super.needUpdateTags(keys, POLYGON_UPDATE_TAG_KEY);
14576
+ return super.needUpdateTags(keys, AREA_UPDATE_TAG_KEY);
14531
14577
  }
14532
14578
  needUpdateTag(key) {
14533
- return super.needUpdateTag(key, POLYGON_UPDATE_TAG_KEY);
14579
+ return super.needUpdateTag(key, AREA_UPDATE_TAG_KEY);
14534
14580
  }
14535
14581
  toCustomPath() {
14536
- const points = this.attribute.points,
14537
- path = new CustomPath2D();
14538
- return points.forEach((point, index) => {
14539
- 0 === index ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y);
14540
- }), path.closePath(), path;
14582
+ const path = new CustomPath2D(),
14583
+ attribute = this.attribute,
14584
+ segments = attribute.segments,
14585
+ parsePoints = points => {
14586
+ if (points && points.length) {
14587
+ let isFirst = !0;
14588
+ const basePoints = [];
14589
+ if (points.forEach(point => {
14590
+ var _a, _b;
14591
+ !1 !== point.defined && (isFirst ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y), basePoints.push({
14592
+ x: null !== (_a = point.x1) && void 0 !== _a ? _a : point.x,
14593
+ y: null !== (_b = point.y1) && void 0 !== _b ? _b : point.y
14594
+ }), isFirst = !1);
14595
+ }), basePoints.length) {
14596
+ for (let i = basePoints.length - 1; i >= 0; i--) path.lineTo(basePoints[i].x, basePoints[i].y);
14597
+ path.closePath();
14598
+ }
14599
+ }
14600
+ };
14601
+ return attribute.points ? parsePoints(attribute.points) : segments && segments.length && segments.forEach(seg => {
14602
+ parsePoints(seg.points);
14603
+ }), path;
14541
14604
  }
14542
14605
  clone() {
14543
- return new Polygon(Object.assign({}, this.attribute));
14606
+ return new Area(Object.assign({}, this.attribute));
14544
14607
  }
14545
14608
  getNoWorkAnimateAttr() {
14546
- return Polygon.NOWORK_ANIMATE_ATTR;
14609
+ return Area.NOWORK_ANIMATE_ATTR;
14547
14610
  }
14548
14611
  }
14549
- Polygon.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
14550
- function createPolygon(attributes) {
14551
- return new Polygon(attributes);
14612
+ Area.NOWORK_ANIMATE_ATTR = Object.assign({
14613
+ segments: 1,
14614
+ curveType: 1
14615
+ }, NOWORK_ANIMATE_ATTR);
14616
+ function createArea(attributes) {
14617
+ return new Area(attributes);
14552
14618
  }
14553
14619
 
14554
- class Pyramid3d extends Polygon {
14620
+ const ARC_UPDATE_TAG_KEY = ["innerRadius", "outerRadius", "startAngle", "endAngle", "cornerRadius", "padAngle", "padRadius", "cap", ...GRAPHIC_UPDATE_TAG_KEY];
14621
+ class Arc extends Graphic {
14555
14622
  constructor(params) {
14556
- super(params), this.type = "pyramid3d", this.numberType = PYRAMID3D_NUMBER_TYPE;
14623
+ super(params), this.type = "arc", this.numberType = ARC_NUMBER_TYPE;
14557
14624
  }
14558
- updateAABBBounds(attribute, polygonTheme, aabbBounds) {
14559
- const stage = this.stage;
14560
- if (!stage || !stage.camera) return aabbBounds;
14561
- return this.findFace().vertices.forEach(v => {
14562
- const x = v[0],
14563
- y = v[1];
14564
- aabbBounds.add(x, y);
14565
- }), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, !1, this), aabbBounds;
14625
+ isValid() {
14626
+ return super.isValid() && this._isValid();
14566
14627
  }
14567
- findFace() {
14628
+ _isValid() {
14568
14629
  const {
14569
- points: points
14570
- } = this.attribute,
14571
- kList = points.map((p, i) => {
14572
- const p1 = 3 === i ? points[0] : points[i + 1],
14573
- dx = p.x - p1.x;
14574
- return 0 === dx ? 0 : (p.y - p1.y) / dx;
14575
- }),
14576
- pointsMap = points.map(p => ({
14577
- p: p,
14578
- d: 0
14579
- }));
14580
- let find = !1,
14581
- maxD = 0;
14582
- for (let i = 0; i < kList.length - 1; i++) {
14583
- for (let j = i + 1; j < kList.length; j++) {
14584
- if (kList[i] === kList[j]) {
14585
- find = !0;
14586
- const d1 = PointService.distancePP(pointsMap[i].p, pointsMap[i + 1].p);
14587
- pointsMap[i].d = d1, pointsMap[i + 1].d = d1, maxD = max(maxD, d1);
14588
- const d2 = PointService.distancePP(pointsMap[j].p, pointsMap[j + 1].p);
14589
- pointsMap[j].d = d2, pointsMap[j + 1].d = d2, maxD = max(maxD, d2);
14590
- }
14591
- if (find) break;
14592
- }
14593
- if (find) break;
14630
+ startAngle: startAngle,
14631
+ endAngle: endAngle,
14632
+ outerRadius: outerRadius,
14633
+ innerRadius: innerRadius
14634
+ } = this.attribute;
14635
+ return this._validNumber(startAngle) && this._validNumber(endAngle) && this._validNumber(outerRadius) && this._validNumber(innerRadius);
14636
+ }
14637
+ getParsedCornerRadius() {
14638
+ const arcTheme = this.getGraphicTheme(),
14639
+ {
14640
+ cornerRadius = arcTheme.cornerRadius,
14641
+ innerPadding = arcTheme.innerPadding,
14642
+ outerPadding = arcTheme.outerPadding
14643
+ } = this.attribute;
14644
+ let {
14645
+ outerRadius = arcTheme.outerRadius,
14646
+ innerRadius = arcTheme.innerRadius
14647
+ } = this.attribute;
14648
+ if (outerRadius += outerPadding, innerRadius -= innerPadding, 0 === cornerRadius || "0%" === cornerRadius) return 0;
14649
+ const deltaRadius = Math.abs(outerRadius - innerRadius),
14650
+ parseCR = cornerRadius => Math.min(isNumber$1(cornerRadius, !0) ? cornerRadius : deltaRadius * parseFloat(cornerRadius) / 100, deltaRadius / 2);
14651
+ if (isArray$1(cornerRadius)) {
14652
+ const crList = cornerRadius.map(cr => parseCR(cr) || 0);
14653
+ 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);
14594
14654
  }
14595
- for (let i = points.length - 1; i >= 0; i--) {
14596
- const p = points[i];
14597
- pointsMap.unshift({
14598
- p: p,
14599
- d: 0
14600
- });
14655
+ return parseCR(cornerRadius);
14656
+ }
14657
+ getParsedAngle() {
14658
+ const arcTheme = this.getGraphicTheme();
14659
+ let {
14660
+ startAngle = arcTheme.startAngle,
14661
+ endAngle = arcTheme.endAngle
14662
+ } = this.attribute;
14663
+ const {
14664
+ cap = arcTheme.cap
14665
+ } = this.attribute,
14666
+ sign = endAngle - startAngle >= 0 ? 1 : -1,
14667
+ deltaAngle = endAngle - startAngle;
14668
+ if (startAngle = clampAngleByRadian(startAngle), endAngle = startAngle + deltaAngle, cap && abs(deltaAngle) < pi2 - epsilon) {
14669
+ let startCap = 1,
14670
+ endCap = 1;
14671
+ cap.length && (startCap = Number(cap[0]), endCap = Number(cap[1]));
14672
+ let {
14673
+ outerRadius = arcTheme.outerRadius,
14674
+ innerRadius = arcTheme.innerRadius
14675
+ } = this.attribute;
14676
+ const {
14677
+ outerPadding = arcTheme.outerPadding,
14678
+ innerPadding = arcTheme.innerPadding
14679
+ } = this.attribute;
14680
+ outerRadius += outerPadding, innerRadius -= innerPadding;
14681
+ const capWidth = Math.abs(outerRadius - innerRadius) / 2,
14682
+ capAngle = capWidth / outerRadius;
14683
+ if (capWidth > epsilon && outerRadius > epsilon) return {
14684
+ startAngle: startAngle - sign * capAngle * startCap,
14685
+ endAngle: endAngle + sign * capAngle * endCap,
14686
+ sc: sign * capAngle * startCap,
14687
+ ec: sign * capAngle * endCap
14688
+ };
14601
14689
  }
14602
- for (let i = 0; i < points.length; i++) {
14603
- const delta = (maxD - pointsMap[i + points.length].d) / 2;
14604
- pointsMap[i].d += delta, pointsMap[i + points.length].d += delta;
14690
+ return {
14691
+ startAngle: startAngle,
14692
+ endAngle: endAngle
14693
+ };
14694
+ }
14695
+ getParsePadAngle(startAngle, endAngle) {
14696
+ const arcTheme = this.getGraphicTheme(),
14697
+ {
14698
+ innerPadding = arcTheme.innerPadding,
14699
+ outerPadding = arcTheme.outerPadding,
14700
+ padAngle = arcTheme.padAngle
14701
+ } = this.attribute;
14702
+ let {
14703
+ outerRadius = arcTheme.outerRadius,
14704
+ innerRadius = arcTheme.innerRadius
14705
+ } = this.attribute;
14706
+ outerRadius += outerPadding, innerRadius -= innerPadding;
14707
+ const {
14708
+ padRadius = sqrt(outerRadius * outerRadius + innerRadius * innerRadius)
14709
+ } = this.attribute,
14710
+ deltaAngle = abs(endAngle - startAngle);
14711
+ let outerStartAngle = startAngle,
14712
+ outerEndAngle = endAngle,
14713
+ innerStartAngle = startAngle,
14714
+ innerEndAngle = endAngle;
14715
+ const halfPadAngle = padAngle / 2;
14716
+ let innerDeltaAngle = deltaAngle,
14717
+ outerDeltaAngle = deltaAngle;
14718
+ if (halfPadAngle > epsilon && padRadius > epsilon) {
14719
+ const sign = endAngle > startAngle ? 1 : -1;
14720
+ let p0 = asin(Number(padRadius) / innerRadius * sin(halfPadAngle)),
14721
+ p1 = asin(Number(padRadius) / outerRadius * sin(halfPadAngle));
14722
+ 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), {
14723
+ outerStartAngle: outerStartAngle,
14724
+ outerEndAngle: outerEndAngle,
14725
+ innerStartAngle: innerStartAngle,
14726
+ innerEndAngle: innerEndAngle,
14727
+ innerDeltaAngle: innerDeltaAngle,
14728
+ outerDeltaAngle: outerDeltaAngle
14729
+ };
14605
14730
  }
14606
- const faces = {
14607
- polygons: [],
14608
- vertices: [],
14609
- edges: []
14731
+ return {
14732
+ outerStartAngle: outerStartAngle,
14733
+ outerEndAngle: outerEndAngle,
14734
+ innerStartAngle: innerStartAngle,
14735
+ innerEndAngle: innerEndAngle,
14736
+ innerDeltaAngle: innerDeltaAngle,
14737
+ outerDeltaAngle: outerDeltaAngle
14610
14738
  };
14611
- return pointsMap.forEach(p => {
14612
- faces.vertices.push([p.p.x, p.p.y, p.d]);
14613
- }), faces.polygons.push({
14614
- polygon: [0, 4, 5, 1],
14615
- normal: [0, -1, 0]
14616
- }), faces.polygons.push({
14617
- polygon: [7, 6, 2, 3],
14618
- normal: [0, 1, 0]
14619
- }), faces.polygons.push({
14620
- polygon: [0, 4, 7, 3],
14621
- normal: [-1, 0, 0]
14622
- }), faces.polygons.push({
14623
- polygon: [1, 5, 6, 2],
14624
- normal: [1, 0, 0]
14625
- }), faces.polygons.push({
14626
- polygon: [0, 1, 2, 3],
14627
- normal: [0, 0, -1]
14628
- }), faces.polygons.push({
14629
- polygon: [4, 5, 6, 7],
14630
- normal: [0, 0, 1]
14631
- }), 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;
14632
14739
  }
14633
- _isValid() {
14634
- return super._isValid() && 4 === this.attribute.points.length;
14740
+ getGraphicTheme() {
14741
+ return getTheme(this).arc;
14635
14742
  }
14636
- getNoWorkAnimateAttr() {
14637
- return Pyramid3d.NOWORK_ANIMATE_ATTR;
14743
+ updateAABBBounds(attribute, arcTheme, aabbBounds, full) {
14744
+ this.updatePathProxyAABBBounds(aabbBounds) || (full ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) : this.updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds));
14745
+ const {
14746
+ tb1: tb1,
14747
+ tb2: tb2
14748
+ } = application.graphicService.updateTempAABBBounds(aabbBounds);
14749
+ updateBoundsOfCommonOuterBorder(attribute, arcTheme, tb1), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
14750
+ const {
14751
+ lineJoin = arcTheme.lineJoin
14752
+ } = attribute;
14753
+ return application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, "miter" === lineJoin, this), aabbBounds;
14638
14754
  }
14639
- }
14640
- Pyramid3d.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
14641
- function createPyramid3d(attributes) {
14642
- return new Pyramid3d(attributes);
14643
- }
14644
-
14645
- class ShadowRoot extends Group {
14646
- constructor(graphic) {
14647
- super({
14648
- x: 0,
14649
- y: 0
14650
- }), this.type = "shadowroot", this.shadowHost = graphic;
14755
+ updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds) {
14756
+ let {
14757
+ outerRadius = arcTheme.outerRadius,
14758
+ innerRadius = arcTheme.innerRadius
14759
+ } = attribute;
14760
+ const {
14761
+ outerPadding = arcTheme.outerPadding,
14762
+ innerPadding = arcTheme.innerPadding
14763
+ } = attribute;
14764
+ return outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius && (outerRadius = innerRadius), aabbBounds.set(-outerRadius, -outerRadius, outerRadius, outerRadius), aabbBounds;
14651
14765
  }
14652
- clearUpdateBoundTag() {
14653
- super.clearUpdateBoundTag(), this.shadowHost && this.shadowHost.clearUpdateBoundTag();
14766
+ updateArcAABBBoundsAccurate(attribute, arcTheme, aabbBounds) {
14767
+ let {
14768
+ outerRadius = arcTheme.outerRadius,
14769
+ innerRadius = arcTheme.innerRadius
14770
+ } = attribute;
14771
+ const {
14772
+ outerPadding = arcTheme.outerPadding,
14773
+ innerPadding = arcTheme.innerPadding
14774
+ } = attribute;
14775
+ if (outerRadius += outerPadding, innerRadius -= innerPadding, outerRadius < innerRadius) {
14776
+ const temp = outerRadius;
14777
+ outerRadius = innerRadius, innerRadius = temp;
14778
+ }
14779
+ let {
14780
+ endAngle = arcTheme.endAngle,
14781
+ startAngle = arcTheme.startAngle
14782
+ } = attribute;
14783
+ if (startAngle > endAngle) {
14784
+ const temp = startAngle;
14785
+ startAngle = endAngle, endAngle = temp;
14786
+ }
14787
+ 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;
14654
14788
  }
14655
- addUpdateBoundTag() {
14656
- super.addUpdateBoundTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
14789
+ needUpdateTags(keys) {
14790
+ return super.needUpdateTags(keys, ARC_UPDATE_TAG_KEY);
14657
14791
  }
14658
- addUpdateShapeAndBoundsTag() {
14659
- super.addUpdateShapeAndBoundsTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
14792
+ needUpdateTag(key) {
14793
+ return super.needUpdateTag(key, ARC_UPDATE_TAG_KEY);
14660
14794
  }
14661
- tryUpdateGlobalTransMatrix() {
14662
- let clearTag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
14663
- if (this.shouldUpdateGlobalMatrix()) {
14664
- const m = this.transMatrix;
14665
- 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();
14795
+ toCustomPath() {
14796
+ var _a, _b, _c, _d;
14797
+ const attribute = this.attribute,
14798
+ {
14799
+ startAngle: startAngle,
14800
+ endAngle: endAngle
14801
+ } = this.getParsedAngle();
14802
+ let innerRadius = (null !== (_a = attribute.innerRadius) && void 0 !== _a ? _a : 0) - (null !== (_b = attribute.innerPadding) && void 0 !== _b ? _b : 0),
14803
+ outerRadius = (null !== (_c = attribute.outerRadius) && void 0 !== _c ? _c : 0) - (null !== (_d = attribute.outerPadding) && void 0 !== _d ? _d : 0);
14804
+ const deltaAngle = abs(endAngle - startAngle),
14805
+ clockwise = endAngle > startAngle;
14806
+ if (outerRadius < innerRadius) {
14807
+ const temp = outerRadius;
14808
+ outerRadius = innerRadius, innerRadius = temp;
14666
14809
  }
14667
- return this._globalTransMatrix;
14668
- }
14669
- doUpdateGlobalMatrix() {
14670
- if (this.shadowHost) {
14671
- const parentMatrix = this.shadowHost.globalTransMatrix;
14672
- this._globalTransMatrix.multiply(parentMatrix.a, parentMatrix.b, parentMatrix.c, parentMatrix.d, parentMatrix.e, parentMatrix.f);
14810
+ const path = new CustomPath2D();
14811
+ 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 {
14812
+ const xors = outerRadius * cos(startAngle),
14813
+ yors = outerRadius * sin(startAngle),
14814
+ xire = innerRadius * cos(endAngle),
14815
+ yire = innerRadius * sin(endAngle);
14816
+ 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();
14673
14817
  }
14818
+ return path;
14674
14819
  }
14675
- tryUpdateGlobalAABBBounds() {
14676
- 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;
14677
- }
14678
- }
14679
- function createShadowRoot(graphic) {
14680
- return new ShadowRoot(graphic);
14681
- }
14682
-
14683
- class GraphicCreator {
14684
- constructor() {
14685
- this.store = new Map();
14686
- }
14687
- RegisterGraphicCreator(name, cb) {
14688
- this.store.set(name, cb), this[name] = cb;
14820
+ clone() {
14821
+ return new Arc(Object.assign({}, this.attribute));
14689
14822
  }
14690
- CreateGraphic(name, params) {
14691
- const cb = this.store.get(name);
14692
- return cb ? cb(params) : null;
14823
+ getNoWorkAnimateAttr() {
14824
+ return Arc.NOWORK_ANIMATE_ATTR;
14693
14825
  }
14694
14826
  }
14695
- const graphicCreator = new GraphicCreator();
14696
-
14697
- let text, richText;
14698
- function getTextBounds(params) {
14699
- return text || (text = graphicCreator.CreateGraphic("text", {})), text.initAttributes(params), text.AABBBounds;
14700
- }
14701
- function getRichTextBounds(params) {
14702
- return richText || (richText = graphicCreator.CreateGraphic("richtext", {})), richText.setAttributes(params), richText.AABBBounds;
14827
+ Arc.NOWORK_ANIMATE_ATTR = Object.assign({
14828
+ cap: 1
14829
+ }, NOWORK_ANIMATE_ATTR);
14830
+ function createArc(attributes) {
14831
+ return new Arc(attributes);
14703
14832
  }
14704
14833
 
14705
- const result = {
14706
- x: 0,
14707
- y: 0,
14708
- z: 0,
14709
- lastModelMatrix: null
14710
- };
14711
- class BaseRender {
14712
- init(contributions) {
14713
- 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 === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
14714
- }
14715
- beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
14716
- this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
14717
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
14718
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
14719
- }
14720
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
14721
- });
14722
- }
14723
- afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
14724
- this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
14725
- if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
14726
- if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
14727
- }
14728
- c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
14729
- });
14730
- }
14731
- drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
14732
- if (!graphic.pathProxy) return !1;
14733
- const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
14734
- {
14735
- fill = themeAttributes.fill,
14736
- stroke = themeAttributes.stroke,
14737
- opacity = themeAttributes.opacity,
14738
- fillOpacity = themeAttributes.fillOpacity,
14739
- lineWidth = themeAttributes.lineWidth,
14740
- strokeOpacity = themeAttributes.strokeOpacity,
14741
- visible = themeAttributes.visible,
14742
- x: originX = themeAttributes.x,
14743
- y: originY = themeAttributes.y
14744
- } = graphic.attribute,
14745
- fVisible = fillVisible(opacity, fillOpacity, fill),
14746
- sVisible = strokeVisible(opacity, strokeOpacity),
14747
- doFill = runFill(fill),
14748
- doStroke = runStroke(stroke, lineWidth);
14749
- if (!visible) return !0;
14750
- if (!doFill && !doStroke) return !0;
14751
- if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
14752
- context.beginPath();
14753
- const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
14754
- 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;
14834
+ class Arc3d extends Arc {
14835
+ constructor(params) {
14836
+ super(params), this.type = "arc3d", this.numberType = ARC3D_NUMBER_TYPE;
14755
14837
  }
14756
- valid(graphic, defaultAttribute, fillCb, strokeCb) {
14838
+ updateAABBBounds(attribute, arcTheme, aabbBounds) {
14839
+ const stage = this.stage;
14840
+ if (!stage || !stage.camera) return aabbBounds;
14757
14841
  const {
14758
- fill = defaultAttribute.fill,
14759
- background: background,
14760
- stroke = defaultAttribute.stroke,
14761
- opacity = defaultAttribute.opacity,
14762
- fillOpacity = defaultAttribute.fillOpacity,
14763
- lineWidth = defaultAttribute.lineWidth,
14764
- strokeOpacity = defaultAttribute.strokeOpacity,
14765
- visible = defaultAttribute.visible
14766
- } = graphic.attribute,
14767
- fVisible = fillVisible(opacity, fillOpacity, fill),
14768
- sVisible = strokeVisible(opacity, strokeOpacity),
14769
- doFill = runFill(fill, background),
14770
- doStroke = runStroke(stroke, lineWidth);
14771
- return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
14772
- fVisible: fVisible,
14773
- sVisible: sVisible,
14774
- doFill: doFill,
14775
- doStroke: doStroke
14776
- };
14842
+ outerRadius = arcTheme.outerRadius,
14843
+ height = 0
14844
+ } = attribute,
14845
+ r = outerRadius + height;
14846
+ return aabbBounds.setValue(-r, -r, r, r), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, arcTheme, !1, this), aabbBounds;
14777
14847
  }
14778
- transform(graphic, graphicAttribute, context) {
14779
- let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
14780
- const {
14781
- x = graphicAttribute.x,
14782
- y = graphicAttribute.y,
14783
- z = graphicAttribute.z,
14784
- scaleX = graphicAttribute.scaleX,
14785
- scaleY = graphicAttribute.scaleY,
14786
- angle = graphicAttribute.angle,
14787
- postMatrix: postMatrix
14788
- } = graphic.attribute,
14789
- lastModelMatrix = context.modelMatrix,
14790
- camera = context.camera;
14791
- result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
14792
- const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
14793
- onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
14794
- if (shouldTransform3d) {
14795
- const nextModelMatrix = mat4Allocate.allocate(),
14796
- modelMatrix = mat4Allocate.allocate();
14797
- 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);
14798
- }
14799
- if (onlyTranslate && !lastModelMatrix) {
14800
- const point = graphic.getOffsetXY(graphicAttribute);
14801
- result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
14802
- } 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) {
14803
- const point = graphic.getOffsetXY(graphicAttribute);
14804
- result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
14805
- } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
14806
- return result;
14848
+ getNoWorkAnimateAttr() {
14849
+ return Arc3d.NOWORK_ANIMATE_ATTR;
14807
14850
  }
14808
- transformUseContext2d(graphic, graphicAttribute, z, context) {
14809
- const camera = context.camera;
14810
- if (this.camera = camera, camera) {
14811
- const bounds = graphic.AABBBounds,
14812
- width = bounds.x2 - bounds.x1,
14813
- height = bounds.y2 - bounds.y1,
14814
- p1 = context.project(0, 0, z),
14815
- p2 = context.project(width, 0, z),
14816
- p3 = context.project(width, height, z),
14817
- _p1 = {
14818
- x: 0,
14819
- y: 0
14820
- },
14821
- _p2 = {
14822
- x: width,
14823
- y: 0
14824
- },
14825
- _p3 = {
14826
- x: width,
14827
- y: height
14828
- };
14829
- context.camera = null;
14830
- const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
14831
- m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
14832
- m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
14833
- m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
14834
- m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
14835
- 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,
14836
- 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;
14837
- context.setTransform(m11, m12, m21, m22, dx, dy, !0);
14838
- }
14851
+ }
14852
+ Arc3d.NOWORK_ANIMATE_ATTR = Object.assign({
14853
+ cap: 1
14854
+ }, NOWORK_ANIMATE_ATTR);
14855
+ function createArc3d(attributes) {
14856
+ return new Arc3d(attributes);
14857
+ }
14858
+
14859
+ const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", ...GRAPHIC_UPDATE_TAG_KEY];
14860
+ class Polygon extends Graphic {
14861
+ constructor(params) {
14862
+ super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
14839
14863
  }
14840
- restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
14841
- this.camera && (context.camera = this.camera);
14864
+ isValid() {
14865
+ return super.isValid() && this._isValid();
14842
14866
  }
14843
- transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
14844
- const p = context.project(x, y, z);
14845
- 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();
14867
+ _isValid() {
14868
+ const {
14869
+ points: points
14870
+ } = this.attribute;
14871
+ return points && points.length >= 2;
14846
14872
  }
14847
- _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
14873
+ getGraphicTheme() {
14874
+ return getTheme(this).polygon;
14875
+ }
14876
+ updateAABBBounds(attribute, polygonTheme, aabbBounds) {
14877
+ this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds);
14848
14878
  const {
14849
- context: context
14850
- } = drawContext;
14851
- if (!context) return;
14879
+ lineJoin = polygonTheme.lineJoin
14880
+ } = attribute;
14881
+ return application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, "miter" === lineJoin, this), aabbBounds;
14882
+ }
14883
+ updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds) {
14852
14884
  const {
14853
- renderable: renderable
14854
- } = graphic.attribute;
14855
- if (!1 === renderable) return;
14856
- context.highPerformanceSave();
14857
- const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
14858
- {
14859
- x: x,
14860
- y: y,
14861
- z: z,
14862
- lastModelMatrix: lastModelMatrix
14863
- } = data;
14864
- 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();
14885
+ points = polygonTheme.points
14886
+ } = attribute;
14887
+ return points.forEach(p => {
14888
+ aabbBounds.add(p.x, p.y);
14889
+ }), aabbBounds;
14890
+ }
14891
+ _interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
14892
+ "points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
14893
+ }
14894
+ needUpdateTags(keys) {
14895
+ return super.needUpdateTags(keys, POLYGON_UPDATE_TAG_KEY);
14896
+ }
14897
+ needUpdateTag(key) {
14898
+ return super.needUpdateTag(key, POLYGON_UPDATE_TAG_KEY);
14899
+ }
14900
+ toCustomPath() {
14901
+ const points = this.attribute.points,
14902
+ path = new CustomPath2D();
14903
+ return points.forEach((point, index) => {
14904
+ 0 === index ? path.moveTo(point.x, point.y) : path.lineTo(point.x, point.y);
14905
+ }), path.closePath(), path;
14906
+ }
14907
+ clone() {
14908
+ return new Polygon(Object.assign({}, this.attribute));
14909
+ }
14910
+ getNoWorkAnimateAttr() {
14911
+ return Polygon.NOWORK_ANIMATE_ATTR;
14865
14912
  }
14866
14913
  }
14914
+ Polygon.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
14915
+ function createPolygon(attributes) {
14916
+ return new Polygon(attributes);
14917
+ }
14867
14918
 
14868
- const parse = function () {
14869
- const tokens = {
14870
- linearGradient: /^(linear\-gradient)/i,
14871
- radialGradient: /^(radial\-gradient)/i,
14872
- conicGradient: /^(conic\-gradient)/i,
14873
- sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
14874
- extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
14875
- positionKeywords: /^(left|center|right|top|bottom)/i,
14876
- pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
14877
- percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
14878
- emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
14879
- angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
14880
- fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
14881
- startCall: /^\(/,
14882
- endCall: /^\)/,
14883
- comma: /^,/,
14884
- hexColor: /(^\#[0-9a-fA-F]+)/,
14885
- literalColor: /^([a-zA-Z]+)/,
14886
- rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
14887
- rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
14888
- number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
14889
- };
14890
- let input = "";
14891
- function error(msg) {
14892
- const err = new Error(input + ": " + msg);
14893
- throw err.source = input, err;
14919
+ class Pyramid3d extends Polygon {
14920
+ constructor(params) {
14921
+ super(params), this.type = "pyramid3d", this.numberType = PYRAMID3D_NUMBER_TYPE;
14922
+ }
14923
+ updateAABBBounds(attribute, polygonTheme, aabbBounds) {
14924
+ const stage = this.stage;
14925
+ if (!stage || !stage.camera) return aabbBounds;
14926
+ return this.findFace().vertices.forEach(v => {
14927
+ const x = v[0],
14928
+ y = v[1];
14929
+ aabbBounds.add(x, y);
14930
+ }), application.graphicService.updateTempAABBBounds(aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, polygonTheme, !1, this), aabbBounds;
14931
+ }
14932
+ findFace() {
14933
+ const {
14934
+ points: points
14935
+ } = this.attribute,
14936
+ kList = points.map((p, i) => {
14937
+ const p1 = 3 === i ? points[0] : points[i + 1],
14938
+ dx = p.x - p1.x;
14939
+ return 0 === dx ? 0 : (p.y - p1.y) / dx;
14940
+ }),
14941
+ pointsMap = points.map(p => ({
14942
+ p: p,
14943
+ d: 0
14944
+ }));
14945
+ let find = !1,
14946
+ maxD = 0;
14947
+ for (let i = 0; i < kList.length - 1; i++) {
14948
+ for (let j = i + 1; j < kList.length; j++) {
14949
+ if (kList[i] === kList[j]) {
14950
+ find = !0;
14951
+ const d1 = PointService.distancePP(pointsMap[i].p, pointsMap[i + 1].p);
14952
+ pointsMap[i].d = d1, pointsMap[i + 1].d = d1, maxD = max(maxD, d1);
14953
+ const d2 = PointService.distancePP(pointsMap[j].p, pointsMap[j + 1].p);
14954
+ pointsMap[j].d = d2, pointsMap[j + 1].d = d2, maxD = max(maxD, d2);
14955
+ }
14956
+ if (find) break;
14957
+ }
14958
+ if (find) break;
14959
+ }
14960
+ for (let i = points.length - 1; i >= 0; i--) {
14961
+ const p = points[i];
14962
+ pointsMap.unshift({
14963
+ p: p,
14964
+ d: 0
14965
+ });
14966
+ }
14967
+ for (let i = 0; i < points.length; i++) {
14968
+ const delta = (maxD - pointsMap[i + points.length].d) / 2;
14969
+ pointsMap[i].d += delta, pointsMap[i + points.length].d += delta;
14970
+ }
14971
+ const faces = {
14972
+ polygons: [],
14973
+ vertices: [],
14974
+ edges: []
14975
+ };
14976
+ return pointsMap.forEach(p => {
14977
+ faces.vertices.push([p.p.x, p.p.y, p.d]);
14978
+ }), faces.polygons.push({
14979
+ polygon: [0, 4, 5, 1],
14980
+ normal: [0, -1, 0]
14981
+ }), faces.polygons.push({
14982
+ polygon: [7, 6, 2, 3],
14983
+ normal: [0, 1, 0]
14984
+ }), faces.polygons.push({
14985
+ polygon: [0, 4, 7, 3],
14986
+ normal: [-1, 0, 0]
14987
+ }), faces.polygons.push({
14988
+ polygon: [1, 5, 6, 2],
14989
+ normal: [1, 0, 0]
14990
+ }), faces.polygons.push({
14991
+ polygon: [0, 1, 2, 3],
14992
+ normal: [0, 0, -1]
14993
+ }), faces.polygons.push({
14994
+ polygon: [4, 5, 6, 7],
14995
+ normal: [0, 0, 1]
14996
+ }), 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;
14894
14997
  }
14895
- function getAST() {
14896
- const ast = matchListing(matchDefinition);
14897
- return input.length > 0 && error("Invalid input not EOF"), ast;
14998
+ _isValid() {
14999
+ return super._isValid() && 4 === this.attribute.points.length;
14898
15000
  }
14899
- function matchDefinition() {
14900
- return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
15001
+ getNoWorkAnimateAttr() {
15002
+ return Pyramid3d.NOWORK_ANIMATE_ATTR;
14901
15003
  }
14902
- function matchGradient(gradientType, pattern, orientationMatcher) {
14903
- return function (pattern, callback) {
14904
- const captures = scan(pattern);
14905
- if (captures) {
14906
- scan(tokens.startCall) || error("Missing (");
14907
- const result = callback(captures);
14908
- return scan(tokens.endCall) || error("Missing )"), result;
14909
- }
14910
- }(pattern, function (captures) {
14911
- const orientation = orientationMatcher();
14912
- return orientation && (scan(tokens.comma) || error("Missing comma before color stops")), {
14913
- type: gradientType,
14914
- orientation: orientation,
14915
- colorStops: matchListing(matchColorStop)
14916
- };
14917
- });
15004
+ }
15005
+ Pyramid3d.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
15006
+ function createPyramid3d(attributes) {
15007
+ return new Pyramid3d(attributes);
15008
+ }
15009
+
15010
+ class ShadowRoot extends Group {
15011
+ constructor(graphic) {
15012
+ super({
15013
+ x: 0,
15014
+ y: 0
15015
+ }), this.type = "shadowroot", this.shadowHost = graphic;
14918
15016
  }
14919
- function matchLinearOrientation() {
14920
- return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
15017
+ clearUpdateBoundTag() {
15018
+ super.clearUpdateBoundTag(), this.shadowHost && this.shadowHost.clearUpdateBoundTag();
14921
15019
  }
14922
- function matchConicalOrientation() {
14923
- return match("angular", tokens.fromAngleValue, 1);
15020
+ addUpdateBoundTag() {
15021
+ super.addUpdateBoundTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
14924
15022
  }
14925
- function matchListRadialOrientations() {
14926
- let radialOrientations,
14927
- lookaheadCache,
14928
- radialOrientation = matchRadialOrientation();
14929
- return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation), lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(), radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)), radialOrientations;
15023
+ addUpdateShapeAndBoundsTag() {
15024
+ super.addUpdateShapeAndBoundsTag(), this.shadowHost && this.shadowHost.addUpdateBoundTag();
14930
15025
  }
14931
- function matchRadialOrientation() {
14932
- let radialType = function () {
14933
- const circle = match("shape", /^(circle)/i, 0);
14934
- circle && (circle.style = matchLength() || matchExtentKeyword());
14935
- return circle;
14936
- }() || function () {
14937
- const ellipse = match("shape", /^(ellipse)/i, 0);
14938
- ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
14939
- return ellipse;
14940
- }();
14941
- if (radialType) radialType.at = matchAtPosition();else {
14942
- const extent = matchExtentKeyword();
14943
- if (extent) {
14944
- radialType = extent;
14945
- const positionAt = matchAtPosition();
14946
- positionAt && (radialType.at = positionAt);
14947
- } else {
14948
- const defaultPosition = matchPositioning();
14949
- defaultPosition && (radialType = {
14950
- type: "default-radial",
14951
- at: defaultPosition
14952
- });
14953
- }
15026
+ tryUpdateGlobalTransMatrix() {
15027
+ let clearTag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
15028
+ if (this.shouldUpdateGlobalMatrix()) {
15029
+ const m = this.transMatrix;
15030
+ 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();
14954
15031
  }
14955
- return radialType;
14956
- }
14957
- function matchExtentKeyword() {
14958
- return match("extent-keyword", tokens.extentKeywords, 1);
15032
+ return this._globalTransMatrix;
14959
15033
  }
14960
- function matchAtPosition() {
14961
- if (match("position", /^at/, 0)) {
14962
- const positioning = matchPositioning();
14963
- return positioning || error("Missing positioning value"), positioning;
15034
+ doUpdateGlobalMatrix() {
15035
+ if (this.shadowHost) {
15036
+ const parentMatrix = this.shadowHost.globalTransMatrix;
15037
+ this._globalTransMatrix.multiply(parentMatrix.a, parentMatrix.b, parentMatrix.c, parentMatrix.d, parentMatrix.e, parentMatrix.f);
14964
15038
  }
14965
15039
  }
14966
- function matchPositioning() {
14967
- const location = {
14968
- x: matchDistance(),
14969
- y: matchDistance()
14970
- };
14971
- if (location.x || location.y) return {
14972
- type: "position",
14973
- value: location
14974
- };
14975
- }
14976
- function matchListing(matcher) {
14977
- let captures = matcher();
14978
- const result = [];
14979
- if (captures) for (result.push(captures); scan(tokens.comma);) captures = matcher(), captures ? result.push(captures) : error("One extra comma");
14980
- return result;
14981
- }
14982
- function matchColorStop() {
14983
- const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
14984
- return color || error("Expected color definition"), color.length = matchDistance(), color;
14985
- }
14986
- function matchDistance() {
14987
- return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
14988
- }
14989
- function matchLength() {
14990
- return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
15040
+ tryUpdateGlobalAABBBounds() {
15041
+ 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;
14991
15042
  }
14992
- function match(type, pattern, captureIndex) {
14993
- const captures = scan(pattern);
14994
- if (captures) return {
14995
- type: type,
14996
- value: captures[captureIndex]
14997
- };
15043
+ }
15044
+ function createShadowRoot(graphic) {
15045
+ return new ShadowRoot(graphic);
15046
+ }
15047
+
15048
+ class GraphicCreator {
15049
+ constructor() {
15050
+ this.store = new Map();
14998
15051
  }
14999
- function scan(regexp) {
15000
- const blankCaptures = /^[\n\r\t\s]+/.exec(input);
15001
- blankCaptures && consume(blankCaptures[0].length);
15002
- const captures = regexp.exec(input);
15003
- return captures && consume(captures[0].length), captures;
15052
+ RegisterGraphicCreator(name, cb) {
15053
+ this.store.set(name, cb), this[name] = cb;
15004
15054
  }
15005
- function consume(size) {
15006
- input = input.substr(size);
15055
+ CreateGraphic(name, params) {
15056
+ const cb = this.store.get(name);
15057
+ return cb ? cb(params) : null;
15007
15058
  }
15008
- return function (code) {
15009
- return input = code.toString(), getAST();
15010
- };
15011
- }();
15012
- class GradientParser {
15013
- static IsGradient(c) {
15014
- return !("string" == typeof c && !c.includes("gradient"));
15059
+ }
15060
+ const graphicCreator = new GraphicCreator();
15061
+
15062
+ let text, richText;
15063
+ function getTextBounds(params) {
15064
+ return text || (text = graphicCreator.CreateGraphic("text", {})), text.initAttributes(params), text.AABBBounds;
15065
+ }
15066
+ function getRichTextBounds(params) {
15067
+ return richText || (richText = graphicCreator.CreateGraphic("richtext", {})), richText.setAttributes(params), richText.AABBBounds;
15068
+ }
15069
+
15070
+ const result = {
15071
+ x: 0,
15072
+ y: 0,
15073
+ z: 0,
15074
+ lastModelMatrix: null
15075
+ };
15076
+ class BaseRender {
15077
+ init(contributions) {
15078
+ 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 === BaseRenderContributionTime.beforeFillStroke), this._afterRenderContribitions = this._renderContribitions.filter(c => c.time === BaseRenderContributionTime.afterFillStroke));
15015
15079
  }
15016
- static IsGradientStr(c) {
15017
- return "string" == typeof c && c.includes("gradient");
15080
+ beforeRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
15081
+ this._beforeRenderContribitions && this._beforeRenderContribitions.forEach(c => {
15082
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
15083
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
15084
+ }
15085
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
15086
+ });
15018
15087
  }
15019
- static Parse(c) {
15020
- if (GradientParser.IsGradientStr(c)) try {
15021
- const datum = parse(c)[0];
15022
- if (datum) {
15023
- if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
15024
- if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
15025
- if ("conic" === datum.type) return GradientParser.ParseConic(datum);
15088
+ afterRenderStep(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params) {
15089
+ this._afterRenderContribitions && this._afterRenderContribitions.forEach(c => {
15090
+ if (c.supportedAppName && graphic.stage && graphic.stage.params && graphic.stage.params.context && graphic.stage.params.context.appName) {
15091
+ if (!(Array.isArray(c.supportedAppName) ? c.supportedAppName : [c.supportedAppName]).includes(graphic.stage.params.context.appName)) return;
15026
15092
  }
15027
- } catch (err) {
15028
- return c;
15029
- }
15030
- return c;
15093
+ c.drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, params);
15094
+ });
15031
15095
  }
15032
- static ParseConic(datum) {
15033
- const {
15034
- orientation: orientation,
15035
- colorStops = []
15036
- } = datum,
15037
- halfPi = pi / 2,
15038
- sa = parseFloat(orientation.value) / 180 * pi - halfPi;
15039
- return {
15040
- gradient: "conical",
15041
- x: .5,
15042
- y: .5,
15043
- startAngle: sa,
15044
- endAngle: sa + pi2,
15045
- stops: colorStops.map(item => ({
15046
- color: item.value,
15047
- offset: parseFloat(item.length.value) / 100
15048
- }))
15049
- };
15096
+ drawPathProxy(graphic, context, x, y, drawContext, params, fillCb, strokeCb) {
15097
+ if (!graphic.pathProxy) return !1;
15098
+ const themeAttributes = getTheme(graphic, null == params ? void 0 : params.theme)[graphic.type.replace("3d", "")],
15099
+ {
15100
+ fill = themeAttributes.fill,
15101
+ stroke = themeAttributes.stroke,
15102
+ opacity = themeAttributes.opacity,
15103
+ fillOpacity = themeAttributes.fillOpacity,
15104
+ lineWidth = themeAttributes.lineWidth,
15105
+ strokeOpacity = themeAttributes.strokeOpacity,
15106
+ visible = themeAttributes.visible,
15107
+ x: originX = themeAttributes.x,
15108
+ y: originY = themeAttributes.y
15109
+ } = graphic.attribute,
15110
+ fVisible = fillVisible(opacity, fillOpacity, fill),
15111
+ sVisible = strokeVisible(opacity, strokeOpacity),
15112
+ doFill = runFill(fill),
15113
+ doStroke = runStroke(stroke, lineWidth);
15114
+ if (!visible) return !0;
15115
+ if (!doFill && !doStroke) return !0;
15116
+ if (!(fVisible || sVisible || fillCb || strokeCb)) return !0;
15117
+ context.beginPath();
15118
+ const path = "function" == typeof graphic.pathProxy ? graphic.pathProxy(graphic.attribute) : graphic.pathProxy;
15119
+ 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;
15050
15120
  }
15051
- static ParseRadial(datum) {
15121
+ valid(graphic, defaultAttribute, fillCb, strokeCb) {
15052
15122
  const {
15053
- colorStops = []
15054
- } = datum;
15055
- return {
15056
- gradient: "radial",
15057
- x0: .5,
15058
- y0: .5,
15059
- x1: .5,
15060
- y1: .5,
15061
- r0: 0,
15062
- r1: 1,
15063
- stops: colorStops.map(item => ({
15064
- color: item.value,
15065
- offset: parseFloat(item.length.value) / 100
15066
- }))
15123
+ fill = defaultAttribute.fill,
15124
+ background: background,
15125
+ stroke = defaultAttribute.stroke,
15126
+ opacity = defaultAttribute.opacity,
15127
+ fillOpacity = defaultAttribute.fillOpacity,
15128
+ lineWidth = defaultAttribute.lineWidth,
15129
+ strokeOpacity = defaultAttribute.strokeOpacity,
15130
+ visible = defaultAttribute.visible
15131
+ } = graphic.attribute,
15132
+ fVisible = fillVisible(opacity, fillOpacity, fill),
15133
+ sVisible = strokeVisible(opacity, strokeOpacity),
15134
+ doFill = runFill(fill, background),
15135
+ doStroke = runStroke(stroke, lineWidth);
15136
+ return !(!graphic.valid || !visible) && !(!doFill && !doStroke) && !!(fVisible || sVisible || fillCb || strokeCb || background) && {
15137
+ fVisible: fVisible,
15138
+ sVisible: sVisible,
15139
+ doFill: doFill,
15140
+ doStroke: doStroke
15067
15141
  };
15068
15142
  }
15069
- static ParseLinear(datum) {
15143
+ transform(graphic, graphicAttribute, context) {
15144
+ let use3dMatrixIn3dMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
15070
15145
  const {
15071
- orientation: orientation,
15072
- colorStops = []
15073
- } = datum,
15074
- halfPi = pi / 2;
15075
- let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * pi : 0;
15076
- for (; angle < 0;) angle += pi2;
15077
- for (; angle > pi2;) angle -= pi2;
15078
- let x0 = 0,
15079
- y0 = 0,
15080
- x1 = 0,
15081
- y1 = 0;
15082
- return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = Math.cos(angle)) : angle < pi ? (x0 = 0, y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < pi + halfPi ? (x0 = 1, y0 = 0, x1 = x0 - Math.sin(angle - pi), y1 = Math.cos(angle - pi)) : (x0 = 1, x1 = x0 - Math.cos(angle - halfPi - pi), y1 -= Math.sin(angle - halfPi - pi)), {
15083
- gradient: "linear",
15084
- x0: x0,
15085
- y0: y0,
15086
- x1: x1,
15087
- y1: y1,
15088
- stops: colorStops.map(item => ({
15089
- color: item.value,
15090
- offset: parseFloat(item.length.value) / 100
15091
- }))
15092
- };
15146
+ x = graphicAttribute.x,
15147
+ y = graphicAttribute.y,
15148
+ z = graphicAttribute.z,
15149
+ scaleX = graphicAttribute.scaleX,
15150
+ scaleY = graphicAttribute.scaleY,
15151
+ angle = graphicAttribute.angle,
15152
+ postMatrix: postMatrix
15153
+ } = graphic.attribute,
15154
+ lastModelMatrix = context.modelMatrix,
15155
+ camera = context.camera;
15156
+ result.x = x, result.y = y, result.z = z, result.lastModelMatrix = lastModelMatrix;
15157
+ const shouldTransform3d = camera && (use3dMatrixIn3dMode || shouldUseMat4(graphic)),
15158
+ onlyTranslate = shouldTransform3d ? graphic.transMatrix.onlyTranslate() && !postMatrix : 1 === scaleX && 1 === scaleY && 0 === angle && !postMatrix;
15159
+ if (shouldTransform3d) {
15160
+ const nextModelMatrix = mat4Allocate.allocate(),
15161
+ modelMatrix = mat4Allocate.allocate();
15162
+ 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);
15163
+ }
15164
+ if (onlyTranslate && !lastModelMatrix) {
15165
+ const point = graphic.getOffsetXY(graphicAttribute);
15166
+ result.x += point.x, result.y += point.y, result.z = z, context.setTransformForCurrent();
15167
+ } 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) {
15168
+ const point = graphic.getOffsetXY(graphicAttribute);
15169
+ result.x += point.x, result.y += point.y, this.transformWithoutTranslate(context, result.x, result.y, result.z, scaleX, scaleY, angle);
15170
+ } else context.transformFromMatrix(graphic.transMatrix, !0), result.x = 0, result.y = 0, result.z = 0;
15171
+ return result;
15093
15172
  }
15094
- }
15095
-
15096
- function getScaledStroke(context, width, dpr) {
15097
- let strokeWidth = width;
15098
- const {
15099
- a: a,
15100
- b: b,
15101
- c: c,
15102
- d: d
15103
- } = context.currentMatrix,
15104
- scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
15105
- scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
15106
- return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
15107
- }
15108
- function createColor(context, c, params) {
15109
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
15110
- let offsetY = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
15111
- if (!c || !0 === c) return "black";
15112
- let result, color;
15113
- if (isArray$1(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++);else color = c;
15114
- if (color = GradientParser.Parse(color), "string" == typeof color) return color;
15115
- if (params.AABBBounds && (!params.attribute || 0 !== params.attribute.scaleX || 0 !== params.attribute.scaleY)) {
15116
- const bounds = params.AABBBounds;
15117
- let w = bounds.x2 - bounds.x1,
15118
- h = bounds.y2 - bounds.y1,
15119
- x = bounds.x1 - offsetX,
15120
- y = bounds.y1 - offsetY;
15121
- if (params.attribute) {
15122
- const {
15123
- scaleX = 1,
15124
- scaleY = 1
15125
- } = params.attribute;
15126
- w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY;
15173
+ transformUseContext2d(graphic, graphicAttribute, z, context) {
15174
+ const camera = context.camera;
15175
+ if (this.camera = camera, camera) {
15176
+ const bounds = graphic.AABBBounds,
15177
+ width = bounds.x2 - bounds.x1,
15178
+ height = bounds.y2 - bounds.y1,
15179
+ p1 = context.project(0, 0, z),
15180
+ p2 = context.project(width, 0, z),
15181
+ p3 = context.project(width, height, z),
15182
+ _p1 = {
15183
+ x: 0,
15184
+ y: 0
15185
+ },
15186
+ _p2 = {
15187
+ x: width,
15188
+ y: 0
15189
+ },
15190
+ _p3 = {
15191
+ x: width,
15192
+ y: height
15193
+ };
15194
+ context.camera = null;
15195
+ const denom = 1 / (_p1.x * (_p3.y - _p2.y) - _p2.x * _p3.y + _p3.x * _p2.y + (_p2.x - _p3.x) * _p1.y),
15196
+ m11 = -(_p1.y * (p3.x - p2.x) - _p2.y * p3.x + _p3.y * p2.x + (_p2.y - _p3.y) * p1.x) * denom,
15197
+ m12 = (_p2.y * p3.y + _p1.y * (p2.y - p3.y) - _p3.y * p2.y + (_p3.y - _p2.y) * p1.y) * denom,
15198
+ m21 = (_p1.x * (p3.x - p2.x) - _p2.x * p3.x + _p3.x * p2.x + (_p2.x - _p3.x) * p1.x) * denom,
15199
+ m22 = -(_p2.x * p3.y + _p1.x * (p2.y - p3.y) - _p3.x * p2.y + (_p3.x - _p2.x) * p1.y) * denom,
15200
+ 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,
15201
+ 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;
15202
+ context.setTransform(m11, m12, m21, m22, dx, dy, !0);
15127
15203
  }
15128
- "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));
15129
15204
  }
15130
- return result || "orange";
15131
- }
15132
- function createLinearGradient(context, color, x, y, w, h) {
15133
- var _a, _b, _c, _d;
15134
- 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);
15135
- return color.stops.forEach(stop => {
15136
- canvasGradient.addColorStop(stop.offset, stop.color);
15137
- }), canvasGradient;
15138
- }
15139
- function createRadialGradient(context, color, x, y, w, h) {
15140
- var _a, _b, _c, _d, _e, _f;
15141
- 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));
15142
- return color.stops.forEach(stop => {
15143
- canvasGradient.addColorStop(stop.offset, stop.color);
15144
- }), canvasGradient;
15145
- }
15146
- function createConicGradient(context, color, x, y, w, h) {
15147
- var _a, _b;
15148
- 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);
15149
- return color.stops.forEach(stop => {
15150
- canvasGradient.addColorStop(stop.offset, stop.color);
15151
- }), canvasGradient.GetPattern(w + x, h + y, undefined);
15205
+ restoreTransformUseContext2d(graphic, graphicAttribute, z, context) {
15206
+ this.camera && (context.camera = this.camera);
15207
+ }
15208
+ transformWithoutTranslate(context, x, y, z, scaleX, scaleY, angle) {
15209
+ const p = context.project(x, y, z);
15210
+ 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();
15211
+ }
15212
+ _draw(graphic, defaultAttr, computed3dMatrix, drawContext, params) {
15213
+ const {
15214
+ context: context
15215
+ } = drawContext;
15216
+ if (!context) return;
15217
+ const {
15218
+ renderable: renderable
15219
+ } = graphic.attribute;
15220
+ if (!1 === renderable) return;
15221
+ context.highPerformanceSave();
15222
+ const data = this.transform(graphic, defaultAttr, context, computed3dMatrix),
15223
+ {
15224
+ x: x,
15225
+ y: y,
15226
+ z: z,
15227
+ lastModelMatrix: lastModelMatrix
15228
+ } = data;
15229
+ 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();
15230
+ }
15152
15231
  }
15153
15232
 
15154
15233
  var __decorate$1C = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -15412,7 +15491,8 @@ class DefaultArcRenderContribution {
15412
15491
  x: originX = arcAttribute.x,
15413
15492
  y: originY = arcAttribute.y,
15414
15493
  scaleX = arcAttribute.scaleX,
15415
- scaleY = arcAttribute.scaleY
15494
+ scaleY = arcAttribute.scaleY,
15495
+ keepStrokeScale = arcAttribute.keepStrokeScale
15416
15496
  } = arc.attribute;
15417
15497
  let {
15418
15498
  innerRadius = arcAttribute.innerRadius,
@@ -15424,7 +15504,7 @@ class DefaultArcRenderContribution {
15424
15504
  {
15425
15505
  distance = arcAttribute[key].distance
15426
15506
  } = borderStyle,
15427
- d = getScaledStroke(context, distance, context.dpr),
15507
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15428
15508
  deltaAngle = distance / outerRadius,
15429
15509
  sign = "outerBorder" === key ? 1 : -1;
15430
15510
  if (arc.setAttributes({
@@ -15469,14 +15549,15 @@ class DefaultCircleRenderContribution {
15469
15549
  x: originX = circleAttribute.x,
15470
15550
  y: originY = circleAttribute.y,
15471
15551
  scaleX = circleAttribute.scaleX,
15472
- scaleY = circleAttribute.scaleY
15552
+ scaleY = circleAttribute.scaleY,
15553
+ keepStrokeScale = circleAttribute.keepStrokeScale
15473
15554
  } = circle.attribute,
15474
15555
  renderBorder = (borderStyle, key) => {
15475
15556
  const doStroke = !(!borderStyle || !borderStyle.stroke),
15476
15557
  {
15477
15558
  distance = circleAttribute[key].distance
15478
15559
  } = borderStyle,
15479
- d = getScaledStroke(context, distance, context.dpr),
15560
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15480
15561
  sign = "outerBorder" === key ? 1 : -1;
15481
15562
  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) {
15482
15563
  const lastOpacity = circleAttribute[key].opacity;
@@ -15595,7 +15676,8 @@ class DefaultRectRenderContribution {
15595
15676
  scaleX = rectAttribute.scaleX,
15596
15677
  scaleY = rectAttribute.scaleY,
15597
15678
  x1: x1,
15598
- y1: y1
15679
+ y1: y1,
15680
+ keepStrokeScale = rectAttribute.keepStrokeScale
15599
15681
  } = rect.attribute;
15600
15682
  let {
15601
15683
  width: width,
@@ -15608,7 +15690,7 @@ class DefaultRectRenderContribution {
15608
15690
  {
15609
15691
  distance = rectAttribute[key].distance
15610
15692
  } = borderStyle,
15611
- d = getScaledStroke(context, distance, context.dpr),
15693
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15612
15694
  nextX = x + sign * d,
15613
15695
  nextY = y + sign * d,
15614
15696
  dw = 2 * d;
@@ -15765,14 +15847,15 @@ class DefaultSymbolRenderContribution {
15765
15847
  x: originX = symbolAttribute.x,
15766
15848
  y: originY = symbolAttribute.y,
15767
15849
  scaleX = symbolAttribute.scaleX,
15768
- scaleY = symbolAttribute.scaleY
15850
+ scaleY = symbolAttribute.scaleY,
15851
+ keepStrokeScale = symbolAttribute.keepStrokeScale
15769
15852
  } = symbol.attribute,
15770
15853
  renderBorder = (borderStyle, key) => {
15771
15854
  const doStroke = !(!borderStyle || !borderStyle.stroke),
15772
15855
  {
15773
15856
  distance = symbolAttribute[key].distance
15774
15857
  } = borderStyle,
15775
- d = getScaledStroke(context, distance, context.dpr),
15858
+ d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
15776
15859
  sign = "outerBorder" === key ? 1 : -1;
15777
15860
  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) {
15778
15861
  const lastOpacity = symbolAttribute[key].opacity;
@@ -17055,16 +17138,8 @@ let DefaultCanvasTextRender = class extends BaseRender {
17055
17138
  verticalMode = textAttribute.verticalMode,
17056
17139
  x: originX = textAttribute.x,
17057
17140
  y: originY = textAttribute.y
17058
- } = text.attribute;
17059
- let {
17060
- textAlign = textAttribute.textAlign,
17061
- textBaseline = textAttribute.textBaseline
17062
- } = text.attribute;
17063
- if (!verticalMode && "vertical" === direction) {
17064
- const t = textAlign;
17065
- textAlign = null !== (_a = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = text.getAlignMapBaseline()[t]) && void 0 !== _b ? _b : "top";
17066
- }
17067
- const lineHeight = null !== (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _c ? _c : fontSize,
17141
+ } = text.attribute,
17142
+ lineHeight = null !== (_a = calculateLineHeight(text.attribute.lineHeight, fontSize)) && void 0 !== _a ? _a : fontSize,
17068
17143
  data = this.valid(text, textAttribute, fillCb, strokeCb);
17069
17144
  if (!data) return;
17070
17145
  const {
@@ -17084,79 +17159,60 @@ let DefaultCanvasTextRender = class extends BaseRender {
17084
17159
  const matrix = matrixAllocate.allocate(1, 0, 0, 1, 0, 0);
17085
17160
  matrix.rotateByCenter(Math.PI / 2, _x, _y), context.transformFromMatrix(matrix, !0), matrixAllocate.free(matrix);
17086
17161
  }
17087
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.strokeText(t, _x, _y, z))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), context.fillText(t, _x, _y, z), this.drawUnderLine(underline, lineThrough, text, _x, _y, z, textAttribute, context))), direction && (context.highPerformanceRestore(), context.setTransformForCurrent());
17162
+ 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());
17088
17163
  };
17089
- if (text.isMultiLine) {
17090
- if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
17091
- const {
17092
- multilineLayout: multilineLayout
17093
- } = text;
17094
- if (!multilineLayout) return void context.highPerformanceRestore();
17095
- const {
17096
- xOffset: xOffset,
17097
- yOffset: yOffset
17098
- } = multilineLayout.bbox;
17099
- doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
17100
- context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
17101
- }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
17102
- context.fillText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z), this.drawUnderLine(underline, lineThrough, text, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y - textDrawOffsetY("bottom", fontSize) - .05 * fontSize, z, textAttribute, context, {
17103
- width: line.width
17104
- });
17105
- })));
17106
- } else {
17107
- text.tryUpdateAABBBounds();
17108
- const cache = text.cache,
17109
- {
17110
- verticalList: verticalList
17111
- } = cache;
17112
- context.textAlign = "left", context.textBaseline = "top";
17113
- const totalHeight = lineHeight * verticalList.length;
17114
- let totalW = 0;
17115
- verticalList.forEach(verticalData => {
17116
- const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
17117
- totalW = max(_w, totalW);
17118
- });
17119
- let offsetY = 0,
17120
- offsetX = 0;
17121
- "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
17122
- const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
17123
- dw = totalW - currentW;
17124
- let currentOffsetY = offsetY;
17125
- "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
17126
- const {
17127
- text: text,
17128
- width: width,
17129
- direction: direction
17130
- } = item;
17131
- drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
17132
- });
17164
+ if (context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z), "horizontal" === direction) {
17165
+ const {
17166
+ multilineLayout: multilineLayout
17167
+ } = text;
17168
+ if (!multilineLayout) return void context.highPerformanceRestore();
17169
+ const {
17170
+ xOffset: xOffset,
17171
+ yOffset: yOffset
17172
+ } = multilineLayout.bbox;
17173
+ doStroke && (strokeCb ? strokeCb(context, text.attribute, textAttribute) : sVisible && (context.setStrokeStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
17174
+ context.strokeText(line.str, (line.leftOffset || 0) + xOffset + x, (line.topOffset || 0) + yOffset + y, z);
17175
+ }))), doFill && (fillCb ? fillCb(context, text.attribute, textAttribute) : fVisible && (context.setCommonStyle(text, text.attribute, originX - x, originY - y, textAttribute), multilineLayout.lines.forEach(line => {
17176
+ 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, {
17177
+ width: line.width
17133
17178
  });
17134
- }
17135
- } else if ("horizontal" === direction) {
17136
- context.setTextStyle(text.attribute, textAttribute, z);
17137
- const t = text.clipedText;
17138
- let dy = 0;
17139
- lineHeight !== fontSize && ("top" === textBaseline ? dy = (lineHeight - fontSize) / 2 : "middle" === textBaseline || "bottom" === textBaseline && (dy = -(lineHeight - fontSize) / 2)), drawText(t, 0, dy, 0);
17179
+ })));
17140
17180
  } else {
17181
+ let {
17182
+ textAlign = textAttribute.textAlign,
17183
+ textBaseline = textAttribute.textBaseline
17184
+ } = text.attribute;
17185
+ if (!verticalMode) {
17186
+ const t = textAlign;
17187
+ textAlign = null !== (_b = text.getBaselineMapAlign()[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = text.getAlignMapBaseline()[t]) && void 0 !== _c ? _c : "top";
17188
+ }
17141
17189
  text.tryUpdateAABBBounds();
17142
- const cache = text.cache;
17143
- if (cache) {
17144
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
17145
- const {
17190
+ const cache = text.cache,
17191
+ {
17146
17192
  verticalList: verticalList
17147
17193
  } = cache;
17148
- let offsetY = 0;
17149
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
17150
- let offsetX = 0;
17151
- "bottom" === textBaseline ? offsetX = -lineHeight : "middle" === textBaseline && (offsetX = -lineHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), context.textAlign = "left", context.textBaseline = "top", verticalList[0].forEach(item => {
17194
+ context.textAlign = "left", context.textBaseline = "top";
17195
+ const totalHeight = lineHeight * verticalList.length;
17196
+ let totalW = 0;
17197
+ verticalList.forEach(verticalData => {
17198
+ const _w = verticalData.reduce((a, b) => a + (b.width || 0), 0);
17199
+ totalW = max(_w, totalW);
17200
+ });
17201
+ let offsetY = 0,
17202
+ offsetX = 0;
17203
+ "bottom" === textBaseline ? offsetX = -totalHeight : "middle" === textBaseline && (offsetX = -totalHeight / 2), "center" === textAlign ? offsetY -= totalW / 2 : "right" === textAlign && (offsetY -= totalW), verticalList.forEach((verticalData, i) => {
17204
+ const currentW = verticalData.reduce((a, b) => a + (b.width || 0), 0),
17205
+ dw = totalW - currentW;
17206
+ let currentOffsetY = offsetY;
17207
+ "center" === textAlign ? currentOffsetY += dw / 2 : "right" === textAlign && (currentOffsetY += dw), verticalData.forEach(item => {
17152
17208
  const {
17153
17209
  text: text,
17154
17210
  width: width,
17155
17211
  direction: direction
17156
17212
  } = item;
17157
- drawText(text, offsetX, offsetY, direction), offsetY += width;
17213
+ drawText(text, totalHeight - (i + 1) * lineHeight + offsetX, currentOffsetY, direction), currentOffsetY += width;
17158
17214
  });
17159
- }
17215
+ });
17160
17216
  }
17161
17217
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context), this.afterRenderStep(text, context, x, y, doFill, doStroke, fVisible, sVisible, textAttribute, drawContext, fillCb, strokeCb);
17162
17218
  }
@@ -17168,12 +17224,10 @@ let DefaultCanvasTextRender = class extends BaseRender {
17168
17224
  computed3dMatrix = !keepDirIn3d;
17169
17225
  this._draw(text, textAttribute, computed3dMatrix, drawContext, params);
17170
17226
  }
17171
- drawUnderLine(underline, lineThrough, text, x, y, z, textAttribute, context, multiOption) {
17227
+ drawUnderLine(underline, lineThrough, text, anchorX, anchorY, offsetUnderLineY, offsetThroughLineY, z, textAttribute, context, multiOption) {
17172
17228
  if (lineThrough + underline <= 0) return;
17173
17229
  const {
17174
17230
  textAlign = textAttribute.textAlign,
17175
- textBaseline = textAttribute.textBaseline,
17176
- fontSize = textAttribute.fontSize,
17177
17231
  fill = textAttribute.fill,
17178
17232
  opacity = textAttribute.opacity,
17179
17233
  underlineOffset = textAttribute.underlineOffset,
@@ -17183,23 +17237,21 @@ let DefaultCanvasTextRender = class extends BaseRender {
17183
17237
  isMulti = !isNil$1(multiOption),
17184
17238
  w = isMulti ? multiOption.width : text.clipedWidth,
17185
17239
  offsetX = isMulti ? 0 : textDrawOffsetX(textAlign, w),
17186
- offsetY = textLayoutOffsetY(isMulti ? "alphabetic" : textBaseline, fontSize, fontSize),
17187
17240
  attribute = {
17188
17241
  lineWidth: 0,
17189
17242
  stroke: fill,
17190
17243
  opacity: opacity,
17191
17244
  strokeOpacity: fillOpacity
17192
17245
  };
17193
- let deltaY = isMulti ? -3 : 0;
17194
17246
  if (underline) {
17195
- attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, x, y, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
17196
- const dy = y + offsetY + fontSize + underlineOffset + deltaY;
17197
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
17247
+ attribute.lineWidth = underline, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), underlineDash && context.setLineDash(underlineDash), context.beginPath();
17248
+ const dy = anchorY + offsetUnderLineY + underlineOffset;
17249
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
17198
17250
  }
17199
- if (isMulti && (deltaY = -1), lineThrough) {
17200
- attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, x, y, textAttribute), context.beginPath();
17201
- const dy = y + offsetY + fontSize / 2 + deltaY;
17202
- context.moveTo(x + offsetX, dy, z), context.lineTo(x + offsetX + w, dy, z), context.stroke();
17251
+ if (lineThrough) {
17252
+ attribute.lineWidth = lineThrough, context.setStrokeStyle(text, attribute, anchorX, anchorY, textAttribute), context.beginPath();
17253
+ const dy = anchorY + offsetThroughLineY;
17254
+ context.moveTo(anchorX + offsetX, dy, z), context.lineTo(anchorX + offsetX + w, dy, z), context.stroke();
17203
17255
  }
17204
17256
  }
17205
17257
  };
@@ -17602,7 +17654,10 @@ class ShadowRootDrawItemInterceptorContribution {
17602
17654
  const {
17603
17655
  context: context
17604
17656
  } = drawContext;
17605
- if (context.highPerformanceSave(), context.transformFromMatrix(graphic.transMatrix, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
17657
+ context.highPerformanceSave();
17658
+ const t1 = graphic.parent.globalTransMatrix,
17659
+ t2 = graphic.stage.window.getViewBoxTransform().clone().multiply(t1.a, t1.b, t1.c, t1.d, t1.e, t1.f);
17660
+ if (graphic.parent && context.setTransformFromMatrix(t2, !0), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
17606
17661
  tempDirtyBounds.copy(drawContribution.dirtyBounds), tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);
17607
17662
  const m = graphic.globalTransMatrix.getInverse();
17608
17663
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m), drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
@@ -18636,6 +18691,42 @@ class AutoRenderPlugin {
18636
18691
  }
18637
18692
  }
18638
18693
 
18694
+ class AutoRefreshPlugin {
18695
+ constructor() {
18696
+ this.name = "AutoRefreshPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(), this.key = this.name + this._uid, this.handleChange = graphic => {
18697
+ graphic.glyphHost && (graphic = graphic.glyphHost), graphic.stage === this.pluginService.stage && null != graphic.stage && graphic.stage.renderNextFrame();
18698
+ };
18699
+ }
18700
+ activate(context) {
18701
+ this.pluginService = context, this.dpr = application.global.devicePixelRatio, this.refresh();
18702
+ }
18703
+ refresh() {
18704
+ this._refreshByMediaQuery() || this._refreshByRaf();
18705
+ }
18706
+ _refreshByRaf() {
18707
+ const raf = application.global.getRequestAnimationFrame();
18708
+ this.rafId = raf(() => {
18709
+ application.global.devicePixelRatio !== this.dpr && (this.dpr = application.global.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0)), this.refresh();
18710
+ });
18711
+ }
18712
+ _refreshByMediaQuery() {
18713
+ try {
18714
+ const mqString = `(resolution: ${window.devicePixelRatio}dppx)`,
18715
+ updatePixelRatio = () => {
18716
+ window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
18717
+ };
18718
+ matchMedia(mqString).addEventListener("change", updatePixelRatio);
18719
+ } catch (err) {
18720
+ return !1;
18721
+ }
18722
+ return !0;
18723
+ }
18724
+ deactivate(context) {
18725
+ const craf = application.global.getCancelAnimationFrame();
18726
+ craf && this.rafId && craf(this.rafId);
18727
+ }
18728
+ }
18729
+
18639
18730
  class IncrementalAutoRenderPlugin {
18640
18731
  constructor() {
18641
18732
  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;
@@ -18812,7 +18903,7 @@ class Stage extends Group {
18812
18903
  constructor() {
18813
18904
  let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18814
18905
  var _a;
18815
- super({}), this._onVisibleChange = visible => {
18906
+ super({}), this.tickedBeforeRender = !0, this._onVisibleChange = visible => {
18816
18907
  if (!(this._skipRender < 0)) if (visible) {
18817
18908
  if (this.dirtyBounds) {
18818
18909
  const b = this.window.getViewBox();
@@ -18823,7 +18914,10 @@ class Stage extends Group {
18823
18914
  }, this.beforeRender = stage => {
18824
18915
  this._beforeRender && this._beforeRender(stage);
18825
18916
  }, this.afterRender = stage => {
18826
- this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null;
18917
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
18918
+ }, this.afterTickCb = () => {
18919
+ var _a;
18920
+ this.tickedBeforeRender = !0, "performance" === (null === (_a = this.params.optimize) || void 0 === _a ? void 0 : _a.tickRenderMode) || "rendering" !== this.state && this.render();
18827
18921
  }, this.params = params, this.theme = new Theme(), this.hooks = {
18828
18922
  beforeRender: new SyncHook(["stage"]),
18829
18923
  afterRender: new SyncHook(["stage"])
@@ -18838,9 +18932,9 @@ class Stage extends Group {
18838
18932
  canvas: params.canvas
18839
18933
  }), 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, {
18840
18934
  main: !0
18841
- })), 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({
18935
+ })), 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({
18842
18936
  background: this._background
18843
- });
18937
+ }), this.ticker.on("afterTick", this.afterTickCb);
18844
18938
  }
18845
18939
  pauseRender() {
18846
18940
  let sr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
@@ -18973,6 +19067,14 @@ class Stage extends Group {
18973
19067
  this.pluginService.unRegister(plugin);
18974
19068
  }));
18975
19069
  }
19070
+ enableAutoRefresh() {
19071
+ this.autoRefresh || (this.autoRefresh = !0, this.pluginService.register(new AutoRefreshPlugin()));
19072
+ }
19073
+ disableAutoRefresh() {
19074
+ this.autoRefresh && (this.autoRefresh = !1, this.pluginService.findPluginsByName("AutoRefreshPlugin").forEach(plugin => {
19075
+ this.pluginService.unRegister(plugin);
19076
+ }));
19077
+ }
18976
19078
  enableIncrementalAutoRender() {
18977
19079
  this.increaseAutoRender || (this.increaseAutoRender = !0, this.pluginService.register(new IncrementalAutoRenderPlugin()));
18978
19080
  }
@@ -19061,7 +19163,7 @@ class Stage extends Group {
19061
19163
  if ("released" === this.releaseStatus) return;
19062
19164
  this.ticker.start(), this.timeline.resume();
19063
19165
  const state = this.state;
19064
- 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++;
19166
+ 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++;
19065
19167
  }
19066
19168
  combineLayersToWindow() {
19067
19169
  if ("harmony" === this.global.env) {
@@ -19167,7 +19269,7 @@ class Stage extends Group {
19167
19269
  layer.release();
19168
19270
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
19169
19271
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
19170
- }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.renderService.renderTreeRoots = [];
19272
+ }), this.interactiveLayer.release()), this.window.release(), this.ticker.remTimeline(this.timeline), this.ticker.removeListener("afterTick", this.afterTickCb), this.renderService.renderTreeRoots = [];
19171
19273
  }
19172
19274
  setStage(stage) {}
19173
19275
  dirty(b, matrix) {
@@ -19245,8 +19347,6 @@ function createStage(params) {
19245
19347
  return new Stage(params);
19246
19348
  }
19247
19349
 
19248
- const strCommandMap = ["arc", "arcTo", "bezierCurveTo", "closePath", "ellipse", "lineTo", "moveTo", "quadraticCurveTo", "rect"];
19249
-
19250
19350
  var __decorate$1f = undefined && undefined.__decorate || function (decorators, target, key, desc) {
19251
19351
  var d,
19252
19352
  c = arguments.length,
@@ -24159,7 +24259,7 @@ class Gesture extends EventEmitter {
24159
24259
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24160
24260
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
24161
24261
  super(), this.cachedEvents = [], this.startPoints = [], this.processEvent = {}, this.throttleTimer = 0, this.emitThrottles = [], this.lastTapTarget = null, this.onStart = ev => {
24162
- this.reset(), this.startTime = clock.now();
24262
+ this.cachedEvents = [], this.startPoints = [], this.reset(), this.startTime = clock.now();
24163
24263
  const {
24164
24264
  cachedEvents: cachedEvents,
24165
24265
  startPoints: startPoints
@@ -24179,7 +24279,7 @@ class Gesture extends EventEmitter {
24179
24279
  if (1 !== startPoints.length) this.startDistance = calcDistance(startPoints[0], startPoints[1]), this.center = getCenter([startPoints[0], startPoints[1]]);else {
24180
24280
  const event = cachedEvents[0];
24181
24281
  this.pressTimeout = setTimeout(() => {
24182
- 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";
24282
+ 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;
24183
24283
  }, this.config.press.time);
24184
24284
  }
24185
24285
  }, this.onMove = ev => {
@@ -24242,10 +24342,10 @@ class Gesture extends EventEmitter {
24242
24342
  lastMovePoint = this.lastMovePoint || startPoints[0],
24243
24343
  distance = calcDistance(prevMovePoint, lastMovePoint),
24244
24344
  velocity = distance / intervalTime;
24245
- velocity > this.config.swipe.velocity && distance > this.config.swipe.threshold && (endEvent.velocity = velocity, endEvent.direction = calcDirection(prevMovePoint, lastMovePoint), this.triggerEvent("swipe", endEvent));
24345
+ 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();
24246
24346
  }
24247
24347
  }
24248
- 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);
24348
+ 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));
24249
24349
  }
24250
24350
  for (let i = 0, len = cachedEvents.length; i < len; i++) if (cachedEvents[i].pointerId === endEvent.pointerId) {
24251
24351
  cachedEvents.splice(i, 1), startPoints.splice(i, 1);
@@ -24287,7 +24387,7 @@ class Gesture extends EventEmitter {
24287
24387
  startTime: startTime,
24288
24388
  startPoints: startPoints
24289
24389
  } = this;
24290
- if (eventType) return eventType;
24390
+ if ("press" === eventType) return eventType;
24291
24391
  let type;
24292
24392
  return type = clock.now() - startTime > this.config.press.time && calcDistance(startPoints[0], point) < this.config.press.threshold ? "press" : "pan", this.eventType = type, type;
24293
24393
  }
@@ -24321,6 +24421,7 @@ class Gesture extends EventEmitter {
24321
24421
  emitThrottles: emitThrottles
24322
24422
  } = this;
24323
24423
  throttleTimer || (this.throttleTimer = application.global.getRequestAnimationFrame()(() => {
24424
+ application.global.getCancelAnimationFrame()(this.throttleTimer), this.throttleTimer = null;
24324
24425
  for (let i = 0, len = emitThrottles.length; i < len; i++) {
24325
24426
  const {
24326
24427
  type: type,
@@ -24328,7 +24429,7 @@ class Gesture extends EventEmitter {
24328
24429
  } = emitThrottles[i];
24329
24430
  this.emitEvent(type, ev);
24330
24431
  }
24331
- this.throttleTimer = 0, this.emitThrottles.length = 0;
24432
+ this.emitThrottles.length = 0;
24332
24433
  }));
24333
24434
  }
24334
24435
  triggerStartEvent(type, ev) {
@@ -24818,9 +24919,10 @@ let BrowserContext2d = class {
24818
24919
  lineJoin = defaultParams.lineJoin,
24819
24920
  lineDash = defaultParams.lineDash,
24820
24921
  lineCap = defaultParams.lineCap,
24821
- miterLimit = defaultParams.miterLimit
24922
+ miterLimit = defaultParams.miterLimit,
24923
+ keepStrokeScale = defaultParams.keepStrokeScale
24822
24924
  } = attribute;
24823
- _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;
24925
+ _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;
24824
24926
  }
24825
24927
  }
24826
24928
  setTextStyleWithoutAlignBaseline(params, defaultParams, z) {
@@ -25720,8 +25822,9 @@ class PickerBase {
25720
25822
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, (context, arcAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(point.x, point.y), picked), (context, arcAttribute, themeAttribute) => {
25721
25823
  if (picked) return !0;
25722
25824
  const lineWidth = arcAttribute.lineWidth || themeAttribute.lineWidth,
25723
- pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25724
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25825
+ pickStrokeBuffer = arcAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
25826
+ keepStrokeScale = arcAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
25827
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25725
25828
  }), pickContext.highPerformanceRestore(), picked;
25726
25829
  }
25727
25830
  }
@@ -25994,8 +26097,9 @@ class RectPickerBase {
25994
26097
  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) => {
25995
26098
  if (picked) return !0;
25996
26099
  const lineWidth = rectAttribute.lineWidth || themeAttribute.lineWidth,
25997
- pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
25998
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
26100
+ pickStrokeBuffer = rectAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
26101
+ keepStrokeScale = rectAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
26102
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(point.x, point.y), picked;
25999
26103
  });else {
26000
26104
  const {
26001
26105
  fill = rectAttribute.fill,
@@ -26309,9 +26413,10 @@ let LynxContext2d = class extends BrowserContext2d {
26309
26413
  lineJoin = defaultParams.lineJoin,
26310
26414
  lineDash = defaultParams.lineDash,
26311
26415
  lineCap = defaultParams.lineCap,
26312
- miterLimit = defaultParams.miterLimit
26416
+ miterLimit = defaultParams.miterLimit,
26417
+ keepStrokeScale = defaultParams.keepStrokeScale
26313
26418
  } = attribute;
26314
- _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;
26419
+ _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;
26315
26420
  }
26316
26421
  }
26317
26422
  measureText(text) {
@@ -26939,9 +27044,10 @@ let TaroContext2d = class extends BrowserContext2d {
26939
27044
  lineJoin = defaultParams.lineJoin,
26940
27045
  lineDash = defaultParams.lineDash,
26941
27046
  lineCap = defaultParams.lineCap,
26942
- miterLimit = defaultParams.miterLimit
27047
+ miterLimit = defaultParams.miterLimit,
27048
+ keepStrokeScale = defaultParams.keepStrokeScale
26943
27049
  } = attribute;
26944
- _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);
27050
+ _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);
26945
27051
  }
26946
27052
  }
26947
27053
  setTextStyleWithoutAlignBaseline(params, defaultParams) {
@@ -27981,9 +28087,10 @@ let HarmonyContext2d = class extends BrowserContext2d {
27981
28087
  lineJoin = defaultParams.lineJoin,
27982
28088
  lineDash = defaultParams.lineDash,
27983
28089
  lineCap = defaultParams.lineCap,
27984
- miterLimit = defaultParams.miterLimit
28090
+ miterLimit = defaultParams.miterLimit,
28091
+ keepStrokeScale = defaultParams.keepStrokeScale
27985
28092
  } = attribute;
27986
- _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;
28093
+ _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;
27987
28094
  }
27988
28095
  }
27989
28096
  measureText(text) {
@@ -28390,8 +28497,9 @@ class BaseLinePicker extends BaseRender {
28390
28497
  return this.canvasRenderer.drawShape(graphic, pickContext, x, y, {}, null, context => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, lineAttribute, themeAttribute) => {
28391
28498
  if (picked) return !0;
28392
28499
  const lineWidth = lineAttribute.lineWidth || themeAttribute.lineWidth,
28393
- pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28394
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28500
+ pickStrokeBuffer = lineAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28501
+ keepStrokeScale = lineAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28502
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28395
28503
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28396
28504
  }
28397
28505
  }
@@ -28526,8 +28634,9 @@ let DefaultCanvasSymbolPicker = class extends Base3dPicker {
28526
28634
  return this.canvasRenderer.drawShape(symbol, pickContext, x, y, {}, null, (context, symbolAttribute, themeAttribute) => !!picked || (picked = context.isPointInPath(pickPoint.x, pickPoint.y), picked), (context, symbolAttribute, themeAttribute) => {
28527
28635
  if (picked) return !0;
28528
28636
  const lineWidth = symbolAttribute.lineWidth || themeAttribute.lineWidth,
28529
- pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer;
28530
- return pickContext.lineWidth = getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28637
+ pickStrokeBuffer = symbolAttribute.pickStrokeBuffer || themeAttribute.pickStrokeBuffer,
28638
+ keepStrokeScale = symbolAttribute.keepStrokeScale || themeAttribute.keepStrokeScale;
28639
+ return pickContext.lineWidth = keepStrokeScale ? lineWidth + pickStrokeBuffer : getScaledStroke(pickContext, lineWidth + pickStrokeBuffer, pickContext.dpr), picked = context.isPointInStroke(pickPoint.x, pickPoint.y), picked;
28531
28640
  }), this.canvasRenderer.z = 0, pickContext.modelMatrix !== lastModelMatrix && mat4Allocate.free(pickContext.modelMatrix), pickContext.modelMatrix = lastModelMatrix, pickContext.highPerformanceRestore(), picked;
28532
28641
  }
28533
28642
  };
@@ -29755,7 +29864,7 @@ const registerWrapText = _registerWrapText;
29755
29864
 
29756
29865
  const roughModule = _roughModule;
29757
29866
 
29758
- const version = "0.21.0-vstory.1";
29867
+ const version = "0.21.0-vstory.3";
29759
29868
  preLoadAllModule();
29760
29869
  if (isBrowserEnv()) {
29761
29870
  loadBrowserEnv(container);
@@ -29788,4 +29897,4 @@ registerReactAttributePlugin();
29788
29897
  registerDirectionalLight();
29789
29898
  registerOrthoCamera();
29790
29899
 
29791
- export { ACustomAnimate, ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, Animate, AnimateGroup, AnimateGroup1, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeAnimate, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, BrowserEnvContribution, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasArc3dPicker, CanvasArcPicker, CanvasAreaPicker, CanvasCirclePicker, CanvasFactory, CanvasGlyphPicker, CanvasGroupPicker, CanvasImagePicker, CanvasLinePicker, CanvasLottiePicker, CanvasPathPicker, CanvasPickerContribution, CanvasPolygonPicker, CanvasPyramid3dPicker, CanvasRect3dPicker, CanvasRectPicker, CanvasRichTextPicker, CanvasSymbolPicker, CanvasTextLayout, CanvasTextPicker, CbAnimate, Circle, CircleRender, CircleRenderContribution, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipRadiusAnimate, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageBackgroundRenderContribution, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultMorphingAnimateConfig, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStateAnimateConfig, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTicker, DefaultTimeline, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction$1 as Direction, DirectionalLight, DragNDrop, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Edge, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FadeInPlus, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, Fragment, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, Gesture, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicAnimate, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupFadeIn, GroupFadeOut, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image$1 as Image, ImageRender, ImageRenderContribution, IncreaseCount, IncrementalDrawContribution, InputText, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Lottie, ManualTickHandler, ManualTicker, Mat4Allocate, MathArcPicker, MathAreaPicker, MathCirclePicker, MathGlyphPicker, MathImagePicker, MathLinePicker, MathPathPicker, MathPickerContribution, MathPolygonPicker, MathRectPicker, MathSymbolPicker, MathTextPicker, MatrixAllocate, Meteor, MonotoneX, MonotoneY, MorphingPath, MotionPath, MultiToOneMorphingPath, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RAFTickHandler, REACT_TO_CANOPUS_EVENTS, REACT_TO_CANOPUS_EVENTS_LIST, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, RotateBySphereAnimate, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, StaticLayerHandlerContribution, Step$1 as Step, StreamLight, SubAnimate, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, TagPointsUpdate, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TimeOutTickHandler, TransformUtil, UpdateTag, VArc, VArc3d, VArea, VCircle, VGlobal, VGlyph, VGroup, VImage, VLine, VPath, VPolygon, VPyramid3d, VRect, VRect3d, VRichText, VSymbol, VText, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _interpolateColor, _registerArc, addArcToBezierPath$1 as addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dCanvasPickModule, arc3dModule, arcCanvasPickModule, arcMathPickModule, arcModule, areaCanvasPickModule, areaMathPickModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, browserEnvModule, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleCanvasPickModule, circleMathPickModule, circleModule, clock, cloneGraphic, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCircle, createColor, createConicalGradient, createGlyph, createGroup, createImage, createImageElement$1 as createImageElement, createLine, createLottie, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, decodeReactDom, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, defaultTicker, defaultTimeline, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, feishuEnvModule, fillVisible, findBestMorphingRotation, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepSegments, genStepTypeSegments, generatorPathEasingFunc, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphCanvasPickModule, glyphMathPickModule, glyphModule, graphicCreator, graphicService, graphicUtil, harmonyEnvModule, identityMat4, imageCanvasPickModule, imageMathPickModule, imageModule, incrementalAddTo, initAllEnv, initBrowserEnv, initFeishuEnv, initHarmonyEnv, initLynxEnv, initNodeEnv, initTTEnv, initTaroEnv, initWxEnv, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, intersect, isBrowserEnv, isNodeEnv, isSvg, isTransformKey, isXML, jsx, layerService, lineCanvasPickModule, lineMathPickModule, lineModule, loadAllEnv, loadAllModule, loadBrowserEnv, loadFeishuEnv, loadHarmonyEnv, loadLynxEnv, loadNodeEnv, loadTTEnv, loadTaroEnv, loadWxEnv, lookAt, lottieCanvasPickModule, lottieModule, lynxEnvModule, mat3Tomat4, mat4Allocate, matrixAllocate, morphPath, multiInject, multiToOneMorph, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, nodeEnvModule, oneToMultiMorph, ortho, parsePadding, parseStroke, parseSvgPath, pathCanvasPickModule, pathMathPickModule, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonCanvasPickModule, polygonMathPickModule, polygonModule, preLoadAllModule, pyramid3dCanvasPickModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dCanvasPickModule, rect3dModule, rectCanvasPickModule, rectFillVisible, rectMathPickModule, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc, registerArc3d, registerArc3dGraphic, registerArcGraphic, registerArea, registerAreaGraphic, registerCircle, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlyph, registerGlyphGraphic, registerGroup, registerGroupGraphic, registerHtmlAttributePlugin, registerImage, registerImageGraphic, registerLine, registerLineGraphic, registerOrthoCamera, registerPath, registerPathGraphic, registerPolygon, registerPolygonGraphic, registerPyramid3d, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect, registerRect3d, registerRect3dGraphic, registerRectGraphic, registerRichtext, registerRichtextGraphic, registerShadowRoot, registerShadowRootGraphic, registerSymbol, registerSymbolGraphic, registerText, registerTextGraphic, registerViewTransform3dPlugin, registerWrapText, registerWrapTextGraphic, renderCommandList, rewriteProto, richTextMathPickModule, richtextCanvasPickModule, richtextModule, rotateX, rotateY, rotateZ, roughModule, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitGraphic, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, strCommandMap, strokeVisible, symbolCanvasPickModule, symbolMathPickModule, symbolModule, taroEnvModule, textAttributesToStyle, textCanvasPickModule, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textMathPickModule, textModule, transformKeys, transformMat4, transformUtil, translate, ttEnvModule, version, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, wxEnvModule, xul };
29900
+ export { ACustomAnimate, ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, Animate, AnimateGroup, AnimateGroup1, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeAnimate, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, BrowserEnvContribution, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasArc3dPicker, CanvasArcPicker, CanvasAreaPicker, CanvasCirclePicker, CanvasFactory, CanvasGlyphPicker, CanvasGroupPicker, CanvasImagePicker, CanvasLinePicker, CanvasLottiePicker, CanvasPathPicker, CanvasPickerContribution, CanvasPolygonPicker, CanvasPyramid3dPicker, CanvasRect3dPicker, CanvasRectPicker, CanvasRichTextPicker, CanvasSymbolPicker, CanvasTextLayout, CanvasTextPicker, CbAnimate, Circle, CircleRender, CircleRenderContribution, ClipAngleAnimate, ClipDirectionAnimate, ClipGraphicAnimate, ClipRadiusAnimate, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageBackgroundRenderContribution, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultMorphingAnimateConfig, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStateAnimateConfig, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTicker, DefaultTimeline, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction$1 as Direction, DirectionalLight, DragNDrop, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Easing, Edge, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FadeInPlus, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, Fragment, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, Gesture, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicAnimate, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupFadeIn, GroupFadeOut, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image$1 as Image, ImageRender, ImageRenderContribution, IncreaseCount, IncrementalDrawContribution, InputText, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Lottie, ManualTickHandler, ManualTicker, Mat4Allocate, MathArcPicker, MathAreaPicker, MathCirclePicker, MathGlyphPicker, MathImagePicker, MathLinePicker, MathPathPicker, MathPickerContribution, MathPolygonPicker, MathRectPicker, MathSymbolPicker, MathTextPicker, MatrixAllocate, MeasureModeEnum, Meteor, MonotoneX, MonotoneY, MorphingPath, MotionPath, MultiToOneMorphingPath, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RAFTickHandler, REACT_TO_CANOPUS_EVENTS, REACT_TO_CANOPUS_EVENTS_LIST, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, RotateBySphereAnimate, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, StaticLayerHandlerContribution, Step$1 as Step, StreamLight, SubAnimate, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, TagPointsUpdate, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TimeOutTickHandler, TransformUtil, UpdateTag, VArc, VArc3d, VArea, VCircle, VGlobal, VGlyph, VGroup, VImage, VLine, VPath, VPolygon, VPyramid3d, VRect, VRect3d, VRichText, VSymbol, VText, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, _registerArc, addArcToBezierPath$1 as addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dCanvasPickModule, arc3dModule, arcCanvasPickModule, arcMathPickModule, arcModule, areaCanvasPickModule, areaMathPickModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, browserEnvModule, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleCanvasPickModule, circleMathPickModule, circleModule, clock, cloneGraphic, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCircle, createColor, createConicalGradient, createGlyph, createGroup, createImage, createImageElement$1 as createImageElement, createLine, createLottie, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, decodeReactDom, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, defaultTicker, defaultTimeline, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, feishuEnvModule, fillVisible, findBestMorphingRotation, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepSegments, genStepTypeSegments, generatorPathEasingFunc, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphCanvasPickModule, glyphMathPickModule, glyphModule, graphicCreator, graphicService, graphicUtil, harmonyEnvModule, identityMat4, imageCanvasPickModule, imageMathPickModule, imageModule, incrementalAddTo, initAllEnv, initBrowserEnv, initFeishuEnv, initHarmonyEnv, initLynxEnv, initNodeEnv, initTTEnv, initTaroEnv, initWxEnv, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, intersect, isBrowserEnv, isNodeEnv, isSvg, isTransformKey, isXML, jsx, layerService, lineCanvasPickModule, lineMathPickModule, lineModule, loadAllEnv, loadAllModule, loadBrowserEnv, loadFeishuEnv, loadHarmonyEnv, loadLynxEnv, loadNodeEnv, loadTTEnv, loadTaroEnv, loadWxEnv, lookAt, lottieCanvasPickModule, lottieModule, lynxEnvModule, mat3Tomat4, mat4Allocate, matrixAllocate, morphPath, multiInject, multiToOneMorph, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, nodeEnvModule, oneToMultiMorph, ortho, parsePadding, parseStroke, parseSvgPath, pathCanvasPickModule, pathMathPickModule, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonCanvasPickModule, polygonMathPickModule, polygonModule, preLoadAllModule, pyramid3dCanvasPickModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dCanvasPickModule, rect3dModule, rectCanvasPickModule, rectFillVisible, rectMathPickModule, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc, registerArc3d, registerArc3dGraphic, registerArcGraphic, registerArea, registerAreaGraphic, registerCircle, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlyph, registerGlyphGraphic, registerGroup, registerGroupGraphic, registerHtmlAttributePlugin, registerImage, registerImageGraphic, registerLine, registerLineGraphic, registerOrthoCamera, registerPath, registerPathGraphic, registerPolygon, registerPolygonGraphic, registerPyramid3d, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect, registerRect3d, registerRect3dGraphic, registerRectGraphic, registerRichtext, registerRichtextGraphic, registerShadowRoot, registerShadowRootGraphic, registerSymbol, registerSymbolGraphic, registerText, registerTextGraphic, registerViewTransform3dPlugin, registerWrapText, registerWrapTextGraphic, renderCommandList, rewriteProto, richTextMathPickModule, richtextCanvasPickModule, richtextModule, rotateX, rotateY, rotateZ, roughModule, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitGraphic, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, strCommandMap, strokeVisible, symbolCanvasPickModule, symbolMathPickModule, symbolModule, taroEnvModule, textAttributesToStyle, textCanvasPickModule, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textMathPickModule, textModule, transformKeys, transformMat4, transformUtil, translate, ttEnvModule, version, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, wxEnvModule, xul };