@antv/g-lite 1.2.20 → 1.3.0-next.0

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.
Files changed (39) hide show
  1. package/dist/css/CSSProperty.d.ts +7 -0
  2. package/dist/css/StyleValueRegistry.d.ts +2 -2
  3. package/dist/css/interfaces.d.ts +3 -2
  4. package/dist/css/parser/color.d.ts +2 -2
  5. package/dist/css/parser/dimension.d.ts +9 -1
  6. package/dist/css/parser/numeric.d.ts +3 -0
  7. package/dist/css/parser/transform-origin.d.ts +2 -0
  8. package/dist/css/parser/transform.d.ts +1 -0
  9. package/dist/css/properties/CSSPropertyAngle.d.ts +1 -0
  10. package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +5 -1
  11. package/dist/css/properties/CSSPropertyNumber.d.ts +1 -0
  12. package/dist/css/properties/CSSPropertyOffsetDistance.d.ts +2 -1
  13. package/dist/css/properties/CSSPropertyOpacity.d.ts +1 -0
  14. package/dist/css/properties/CSSPropertyPath.d.ts +1 -5
  15. package/dist/css/properties/CSSPropertyPoints.d.ts +0 -5
  16. package/dist/css/properties/CSSPropertyTransform.d.ts +3 -2
  17. package/dist/css/properties/CSSPropertyTransformOrigin.d.ts +1 -0
  18. package/dist/css/properties/CSSPropertyZIndex.d.ts +1 -0
  19. package/dist/css/properties/index.d.ts +0 -1
  20. package/dist/display-objects/DisplayObject.d.ts +1 -1
  21. package/dist/display-objects/Line.d.ts +0 -2
  22. package/dist/index.esm.js +389 -444
  23. package/dist/index.esm.js.map +1 -1
  24. package/dist/index.js +389 -444
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.umd.min.js +1 -1
  27. package/dist/index.umd.min.js.map +1 -1
  28. package/dist/services/aabb/CircleUpdater.d.ts +4 -2
  29. package/dist/services/aabb/EllipseUpdater.d.ts +4 -2
  30. package/dist/services/aabb/LineUpdater.d.ts +4 -2
  31. package/dist/services/aabb/PathUpdater.d.ts +4 -2
  32. package/dist/services/aabb/PolylineUpdater.d.ts +4 -2
  33. package/dist/services/aabb/RectUpdater.d.ts +4 -2
  34. package/dist/services/aabb/TextUpdater.d.ts +4 -13
  35. package/dist/services/aabb/interfaces.d.ts +6 -6
  36. package/dist/types.d.ts +0 -5
  37. package/dist/utils/gradient.d.ts +2 -2
  38. package/dist/utils/path.d.ts +1 -1
  39. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -3548,7 +3548,7 @@ var parseGradient$1 = (function () {
3548
3548
  return getAST();
3549
3549
  };
3550
3550
  })();
3551
- function computeLinearGradient(width, height, angle) {
3551
+ function computeLinearGradient(min, width, height, angle) {
3552
3552
  var rad = deg2rad(angle.value);
3553
3553
  var rx = 0;
3554
3554
  var ry = 0;
@@ -3557,13 +3557,13 @@ function computeLinearGradient(width, height, angle) {
3557
3557
  // get the length of gradient line
3558
3558
  // @see https://observablehq.com/@danburzo/css-gradient-line
3559
3559
  var length = Math.abs(width * Math.cos(rad)) + Math.abs(height * Math.sin(rad));
3560
- var x1 = rcx - (Math.cos(rad) * length) / 2;
3561
- var y1 = rcy - (Math.sin(rad) * length) / 2;
3562
- var x2 = rcx + (Math.cos(rad) * length) / 2;
3563
- var y2 = rcy + (Math.sin(rad) * length) / 2;
3560
+ var x1 = min[0] + rcx - (Math.cos(rad) * length) / 2;
3561
+ var y1 = min[1] + rcy - (Math.sin(rad) * length) / 2;
3562
+ var x2 = min[0] + rcx + (Math.cos(rad) * length) / 2;
3563
+ var y2 = min[1] + rcy + (Math.sin(rad) * length) / 2;
3564
3564
  return { x1: x1, y1: y1, x2: x2, y2: y2 };
3565
3565
  }
3566
- function computeRadialGradient(width, height, cx, cy, size) {
3566
+ function computeRadialGradient(min, width, height, cx, cy, size) {
3567
3567
  // 'px'
3568
3568
  var x = cx.value;
3569
3569
  var y = cy.value;
@@ -3594,7 +3594,7 @@ function computeRadialGradient(width, height, cx, cy, size) {
3594
3594
  }
3595
3595
  }
3596
3596
  }
3597
- return { x: x, y: y, r: r };
3597
+ return { x: x + min[0], y: y + min[1], r: r };
3598
3598
  }
3599
3599
 
3600
3600
  var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
@@ -3955,29 +3955,25 @@ function parseDimension(unitRegExp, string) {
3955
3955
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
3956
3956
  * length with only absolute unit, eg. 1px
3957
3957
  */
3958
- var parseLength = memoize(function (css) {
3958
+ var parseLengthUnmemoize = function (css) {
3959
3959
  return parseDimension(new RegExp('px', 'g'), css);
3960
- });
3960
+ };
3961
+ var parseLength = memoize(parseLengthUnmemoize);
3961
3962
  /**
3962
3963
  * <percentage>
3963
3964
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
3964
3965
  */
3965
- memoize(function (css) {
3966
+ var parserPercentageUnmemoize = function (css) {
3966
3967
  return parseDimension(new RegExp('%', 'g'), css);
3967
- });
3968
+ };
3969
+ memoize(parserPercentageUnmemoize);
3968
3970
  /**
3969
3971
  * length with absolute or relative unit,
3970
3972
  * eg. 1px, 0.7em, 50%, calc(100% - 200px);
3971
3973
  *
3972
3974
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
3973
3975
  */
3974
- // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
3975
- // if (isNumber(css) || isFinite(Number(css))) {
3976
- // return getOrCreateUnitValue(Number(css), 'px');
3977
- // }
3978
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
3979
- // });
3980
- var parseLengthOrPercentage = function (css) {
3976
+ var parseLengthOrPercentageUnmemoize = function (css) {
3981
3977
  if (isNumber(css) || isFinite(Number(css))) {
3982
3978
  // Number(css) is NaN
3983
3979
  return getOrCreateUnitValue(Number(css) || 0, 'px');
@@ -3985,9 +3981,11 @@ var parseLengthOrPercentage = function (css) {
3985
3981
  }
3986
3982
  return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
3987
3983
  };
3988
- var parseAngle = memoize(function (css) {
3984
+ var parseLengthOrPercentage = memoize(parseLengthOrPercentageUnmemoize);
3985
+ var parseAngleUnmemoize = function (css) {
3989
3986
  return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
3990
- });
3987
+ };
3988
+ var parseAngle = memoize(parseAngleUnmemoize);
3991
3989
  /**
3992
3990
  * merge CSSUnitValue
3993
3991
  *
@@ -4180,7 +4178,7 @@ function numberToString(x) {
4180
4178
  * * 0 -> CSSUnitValue(0)
4181
4179
  * * '2' -> CSSUnitValue(2)
4182
4180
  */
4183
- var parseNumber = memoize(function (string) {
4181
+ var parseNumberUnmemoize = function (string) {
4184
4182
  if (typeof string === 'number') {
4185
4183
  return getOrCreateUnitValue(string);
4186
4184
  }
@@ -4190,12 +4188,8 @@ var parseNumber = memoize(function (string) {
4190
4188
  else {
4191
4189
  return getOrCreateUnitValue(0);
4192
4190
  }
4193
- });
4194
- /**
4195
- * separate string to array
4196
- * eg.
4197
- * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
4198
- */
4191
+ };
4192
+ var parseNumber = memoize(parseNumberUnmemoize);
4199
4193
  memoize(function (string) {
4200
4194
  if (isString(string)) {
4201
4195
  return string.split(' ').map(parseNumber);
@@ -4797,11 +4791,10 @@ function getArcParams(startPoint, params) {
4797
4791
  };
4798
4792
  }
4799
4793
  function commandsToPathString(commands, object, transform) {
4800
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
4801
4794
  return commands.reduce(function (prev, cur) {
4802
4795
  var path = '';
4803
4796
  if (cur[0] === 'M' || cur[0] === 'L') {
4804
- var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4797
+ var p = vec3.fromValues(cur[1], cur[2], 0);
4805
4798
  if (transform) {
4806
4799
  vec3.transformMat4(p, p, transform);
4807
4800
  }
@@ -4811,9 +4804,9 @@ function commandsToPathString(commands, object, transform) {
4811
4804
  path = cur[0];
4812
4805
  }
4813
4806
  else if (cur[0] === 'C') {
4814
- var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4815
- var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4816
- var p3 = vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
4807
+ var p1 = vec3.fromValues(cur[1], cur[2], 0);
4808
+ var p2 = vec3.fromValues(cur[3], cur[4], 0);
4809
+ var p3 = vec3.fromValues(cur[5], cur[6], 0);
4817
4810
  if (transform) {
4818
4811
  vec3.transformMat4(p1, p1, transform);
4819
4812
  vec3.transformMat4(p2, p2, transform);
@@ -4822,15 +4815,15 @@ function commandsToPathString(commands, object, transform) {
4822
4815
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
4823
4816
  }
4824
4817
  else if (cur[0] === 'A') {
4825
- var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
4818
+ var c = vec3.fromValues(cur[6], cur[7], 0);
4826
4819
  if (transform) {
4827
4820
  vec3.transformMat4(c, c, transform);
4828
4821
  }
4829
4822
  path = "".concat(cur[0]).concat(cur[1], ",").concat(cur[2], ",").concat(cur[3], ",").concat(cur[4], ",").concat(cur[5], ",").concat(c[0], ",").concat(c[1]);
4830
4823
  }
4831
4824
  else if (cur[0] === 'Q') {
4832
- var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4833
- var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4825
+ var p1 = vec3.fromValues(cur[1], cur[2], 0);
4826
+ var p2 = vec3.fromValues(cur[3], cur[4], 0);
4834
4827
  if (transform) {
4835
4828
  vec3.transformMat4(p1, p1, transform);
4836
4829
  vec3.transformMat4(p2, p2, transform);
@@ -4951,7 +4944,7 @@ function convertToPath(object, transform) {
4951
4944
  return commandsToPathString(commands, object, transform);
4952
4945
  }
4953
4946
  }
4954
- function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4947
+ function translatePathToString(absolutePath, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4955
4948
  if (startOffsetX === void 0) { startOffsetX = 0; }
4956
4949
  if (startOffsetY === void 0) { startOffsetY = 0; }
4957
4950
  if (endOffsetX === void 0) { endOffsetX = 0; }
@@ -4970,27 +4963,27 @@ function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffs
4970
4963
  case 'M':
4971
4964
  // Use start marker offset
4972
4965
  if (useStartOffset) {
4973
- return "M ".concat(params[1] - defX + startOffsetX, ",").concat(params[2] - defY + startOffsetY, " L ").concat(params[1] - defX, ",").concat(params[2] - defY);
4966
+ return "M ".concat(params[1] + startOffsetX, ",").concat(params[2] + startOffsetY, " L ").concat(params[1], ",").concat(params[2]);
4974
4967
  }
4975
4968
  else {
4976
- return "M ".concat(params[1] - defX, ",").concat(params[2] - defY);
4969
+ return "M ".concat(params[1], ",").concat(params[2]);
4977
4970
  }
4978
4971
  case 'L':
4979
- return "L ".concat(params[1] - defX + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] - defY + (useEndOffset ? endOffsetY : 0));
4972
+ return "L ".concat(params[1] + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] + (useEndOffset ? endOffsetY : 0));
4980
4973
  case 'Q':
4981
- return ("Q ".concat(params[1] - defX, " ").concat(params[2] - defY, ",").concat(params[3] - defX, " ").concat(params[4] - defY) +
4974
+ return ("Q ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4]) +
4982
4975
  (useEndOffset
4983
- ? " L ".concat(params[3] - defX + endOffsetX, ",").concat(params[4] - defY + endOffsetY)
4976
+ ? " L ".concat(params[3] + endOffsetX, ",").concat(params[4] + endOffsetY)
4984
4977
  : ''));
4985
4978
  case 'C':
4986
- return ("C ".concat(params[1] - defX, " ").concat(params[2] - defY, ",").concat(params[3] - defX, " ").concat(params[4] - defY, ",").concat(params[5] - defX, " ").concat(params[6] - defY) +
4979
+ return ("C ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4], ",").concat(params[5], " ").concat(params[6]) +
4987
4980
  (useEndOffset
4988
- ? " L ".concat(params[5] - defX + endOffsetX, ",").concat(params[6] - defY + endOffsetY)
4981
+ ? " L ".concat(params[5] + endOffsetX, ",").concat(params[6] + endOffsetY)
4989
4982
  : ''));
4990
4983
  case 'A':
4991
- return ("A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6] - defX, " ").concat(params[7] - defY) +
4984
+ return ("A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6], " ").concat(params[7]) +
4992
4985
  (useEndOffset
4993
- ? " L ".concat(params[6] - defX + endOffsetX, ",").concat(params[7] - defY + endOffsetY)
4986
+ ? " L ".concat(params[6] + endOffsetX, ",").concat(params[7] + endOffsetY)
4994
4987
  : ''));
4995
4988
  case 'Z':
4996
4989
  return 'Z';
@@ -5120,12 +5113,8 @@ function parsePoints(pointsOrStr, object) {
5120
5113
  segments.push(segmentT);
5121
5114
  }
5122
5115
  });
5123
- var minX = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[0]; })), false));
5124
- var minY = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[1]; })), false));
5125
- if (object) {
5126
- object.parsedStyle.defX = minX;
5127
- object.parsedStyle.defY = minY;
5128
- }
5116
+ // const minX = Math.min(...points.map((point) => point[0]));
5117
+ // const minY = Math.min(...points.map((point) => point[1]));
5129
5118
  return {
5130
5119
  points: points,
5131
5120
  totalLength: totalLength,
@@ -5255,6 +5244,68 @@ function parseTransform(string) {
5255
5244
  }
5256
5245
  return [];
5257
5246
  }
5247
+ function parseTransformUnmemoize(string) {
5248
+ string = (string || 'none').toLowerCase().trim();
5249
+ if (string === 'none') {
5250
+ return [];
5251
+ }
5252
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5253
+ var result = [];
5254
+ var match;
5255
+ var prevLastIndex = 0;
5256
+ while ((match = transformRegExp.exec(string))) {
5257
+ if (match.index !== prevLastIndex) {
5258
+ return [];
5259
+ }
5260
+ prevLastIndex = match.index + match[0].length;
5261
+ var functionName = match[1]; // scale
5262
+ var functionData = transformFunctions[functionName]; // scale(1, 2)
5263
+ if (!functionData) {
5264
+ // invalid, eg. scale()
5265
+ return [];
5266
+ }
5267
+ var args = match[2].split(','); // 1,2
5268
+ var argTypes = functionData[0]; // Nn
5269
+ if (argTypes.length < args.length) {
5270
+ // scale(N, n)
5271
+ return [];
5272
+ }
5273
+ var parsedArgs = [];
5274
+ for (var i = 0; i < argTypes.length; i++) {
5275
+ var arg = args[i];
5276
+ var type = argTypes[i];
5277
+ var parsedArg = void 0;
5278
+ if (!arg) {
5279
+ // @ts-ignore
5280
+ parsedArg = {
5281
+ a: Odeg,
5282
+ n: parsedArgs[0],
5283
+ t: Opx,
5284
+ }[type];
5285
+ }
5286
+ else {
5287
+ // @ts-ignore
5288
+ parsedArg = {
5289
+ A: function (s) {
5290
+ return s.trim() === '0' ? Odeg : parseAngleUnmemoize(s);
5291
+ },
5292
+ N: parseNumberUnmemoize,
5293
+ T: parseLengthOrPercentageUnmemoize,
5294
+ L: parseLengthUnmemoize,
5295
+ }[type.toUpperCase()](arg);
5296
+ }
5297
+ if (parsedArg === undefined) {
5298
+ return [];
5299
+ }
5300
+ parsedArgs.push(parsedArg);
5301
+ }
5302
+ result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5303
+ if (transformRegExp.lastIndex === string.length) {
5304
+ return result;
5305
+ }
5306
+ }
5307
+ return [];
5308
+ }
5258
5309
  function convertItemToMatrix(item) {
5259
5310
  var x;
5260
5311
  var y;
@@ -5870,6 +5921,39 @@ var parseTransformOrigin = memoize(function (value) {
5870
5921
  ];
5871
5922
  }
5872
5923
  });
5924
+ var parseTransformOriginUnmemoize = function (value) {
5925
+ if (isString(value)) {
5926
+ if (value === 'text-anchor') {
5927
+ return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
5928
+ }
5929
+ var values = value.split(' ');
5930
+ if (values.length === 1) {
5931
+ if (values[0] === 'top' || values[0] === 'bottom') {
5932
+ // 'top' -> 'center top'
5933
+ values[1] = values[0];
5934
+ values[0] = 'center';
5935
+ }
5936
+ else {
5937
+ // '50px' -> '50px center'
5938
+ values[1] = 'center';
5939
+ }
5940
+ }
5941
+ if (values.length !== 2) {
5942
+ return null;
5943
+ }
5944
+ // eg. center bottom
5945
+ return [
5946
+ parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
5947
+ parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
5948
+ ];
5949
+ }
5950
+ else {
5951
+ return [
5952
+ getOrCreateUnitValue(value[0] || 0, 'px'),
5953
+ getOrCreateUnitValue(value[1] || 0, 'px'),
5954
+ ];
5955
+ }
5956
+ };
5873
5957
  function convertKeyword2Percent(keyword) {
5874
5958
  if (keyword === 'center') {
5875
5959
  return '50%';
@@ -6160,9 +6244,9 @@ var BUILT_IN_PROPERTIES = [
6160
6244
  n: 'anchor',
6161
6245
  p: 99,
6162
6246
  d: function (nodeName) {
6163
- if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6164
- return '0.5 0.5';
6165
- }
6247
+ // if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6248
+ // return '0.5 0.5';
6249
+ // }
6166
6250
  return '0 0';
6167
6251
  },
6168
6252
  l: true,
@@ -6522,6 +6606,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6522
6606
  skipParse: false,
6523
6607
  forceUpdateGeometry: false,
6524
6608
  usedAttributes: [],
6609
+ memoize: true,
6525
6610
  }; }
6526
6611
  if (!this.runtime.enableCSSParsing) {
6527
6612
  Object.assign(object.attributes, attributes);
@@ -6566,7 +6651,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6566
6651
  // @ts-ignore
6567
6652
  if (attributes.points) {
6568
6653
  // @ts-ignore
6569
- object.parsedStyle.points = parsePoints(attributes.points, object);
6654
+ object.parsedStyle.points = parsePoints(attributes.points);
6570
6655
  }
6571
6656
  // Path
6572
6657
  // @ts-ignore
@@ -6578,8 +6663,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6578
6663
  object.parsedStyle.path = parsePath(
6579
6664
  // @ts-ignore
6580
6665
  attributes.path);
6581
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
6582
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
6583
6666
  }
6584
6667
  // Text
6585
6668
  if (attributes.textTransform) {
@@ -6627,42 +6710,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6627
6710
  // @ts-ignore
6628
6711
  attributes.markerMid, null, null);
6629
6712
  }
6630
- if (
6631
- // Circle & Ellipse
6632
- ((object.nodeName === Shape.CIRCLE ||
6633
- object.nodeName === Shape.ELLIPSE) &&
6634
- // @ts-ignore
6635
- (!isNil(attributes.cx) ||
6636
- // @ts-ignore
6637
- !isNil(attributes.cy))) ||
6638
- ((object.nodeName === Shape.RECT ||
6639
- object.nodeName === Shape.IMAGE ||
6640
- object.nodeName === Shape.GROUP ||
6641
- object.nodeName === Shape.HTML ||
6642
- object.nodeName === Shape.TEXT ||
6643
- object.nodeName === Shape.MESH) &&
6644
- // @ts-ignore
6645
- (!isNil(attributes.x) ||
6646
- // @ts-ignore
6647
- !isNil(attributes.y) ||
6648
- // @ts-ignore
6649
- !isNil(attributes.z))) ||
6650
- // Line
6651
- (object.nodeName === Shape.LINE &&
6652
- // @ts-ignore
6653
- (!isNil(attributes.x1) ||
6654
- // @ts-ignore
6655
- !isNil(attributes.y1) ||
6656
- // @ts-ignore
6657
- !isNil(attributes.z1) ||
6658
- // @ts-ignore
6659
- !isNil(attributes.x2) ||
6660
- // @ts-ignore
6661
- !isNil(attributes.y2) ||
6662
- // @ts-ignore
6663
- !isNil(attributes.z2)))) {
6664
- this.runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object, attributeNames_1);
6665
- }
6666
6713
  if (!isNil(attributes.zIndex)) {
6667
6714
  this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames_1);
6668
6715
  }
@@ -6685,7 +6732,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6685
6732
  }
6686
6733
  return;
6687
6734
  }
6688
- var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes;
6735
+ var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize = options.memoize;
6689
6736
  var needUpdateGeometry = forceUpdateGeometry;
6690
6737
  var attributeNames = Object.keys(attributes);
6691
6738
  attributeNames.forEach(function (attributeName) {
@@ -6699,7 +6746,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6699
6746
  });
6700
6747
  if (!skipParse) {
6701
6748
  attributeNames.forEach(function (name) {
6702
- object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
6749
+ object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
6703
6750
  });
6704
6751
  }
6705
6752
  // let hasUnresolvedProperties = false;
@@ -6733,7 +6780,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6733
6780
  attributeNames.forEach(function (name) {
6734
6781
  // some style props maybe deleted after parsing such as `anchor` in Text
6735
6782
  if (name in object.computedStyle) {
6736
- object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object);
6783
+ object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
6737
6784
  }
6738
6785
  });
6739
6786
  // if (hasUnresolvedProperties) {
@@ -6768,7 +6815,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6768
6815
  /**
6769
6816
  * string -> parsed value
6770
6817
  */
6771
- DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
6818
+ DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object, memoized) {
6772
6819
  var metadata = propertyMetadataCache[name];
6773
6820
  var computed = value;
6774
6821
  if (value === '' || isNil(value)) {
@@ -6787,9 +6834,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6787
6834
  // computed = new CSSKeywordValue(value);
6788
6835
  computed = getOrCreateKeyword(value);
6789
6836
  }
6790
- else if (handler && handler.parser) {
6791
- // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
6792
- computed = handler.parser(value, object);
6837
+ else if (handler) {
6838
+ if (!memoized && handler.parserUnmemoize) {
6839
+ computed = handler.parserUnmemoize(value, object);
6840
+ }
6841
+ else if (handler.parser) {
6842
+ // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
6843
+ computed = handler.parser(value, object);
6844
+ }
6793
6845
  }
6794
6846
  }
6795
6847
  }
@@ -6798,7 +6850,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6798
6850
  /**
6799
6851
  * computed value -> used value
6800
6852
  */
6801
- DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
6853
+ DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object, memoized) {
6802
6854
  var metadata = propertyMetadataCache[name];
6803
6855
  var isDocumentElement = object.id === 'g-root';
6804
6856
  // let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
@@ -6823,7 +6875,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6823
6875
  if (!isNil(defaultValue)) {
6824
6876
  computed = this.parseProperty(name, isFunction(defaultValue)
6825
6877
  ? defaultValue(object.nodeName)
6826
- : defaultValue, object);
6878
+ : defaultValue, object, memoized);
6827
6879
  }
6828
6880
  }
6829
6881
  else if (value === 'inherit') {
@@ -6936,12 +6988,12 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6936
6988
  geometry_1.renderBounds = new AABB();
6937
6989
  }
6938
6990
  var parsedStyle = object.parsedStyle;
6939
- var _a = geometryUpdater.update(parsedStyle, object), width = _a.width, height = _a.height, _b = _a.depth, depth = _b === void 0 ? 0 : _b, _c = _a.offsetX, offsetX = _c === void 0 ? 0 : _c, _d = _a.offsetY, offsetY = _d === void 0 ? 0 : _d, _e = _a.offsetZ, offsetZ = _e === void 0 ? 0 : _e;
6991
+ var _a = geometryUpdater.update(parsedStyle, object), cx = _a.cx, cy = _a.cy, _b = _a.cz, cz = _b === void 0 ? 0 : _b, hwidth = _a.hwidth, hheight = _a.hheight, _c = _a.hdepth, hdepth = _c === void 0 ? 0 : _c;
6940
6992
  // init with content box
6941
6993
  var halfExtents = [
6942
- Math.abs(width) / 2,
6943
- Math.abs(height) / 2,
6944
- depth / 2,
6994
+ Math.abs(hwidth),
6995
+ Math.abs(hheight),
6996
+ hdepth,
6945
6997
  ];
6946
6998
  // const halfExtents = vec3.set(
6947
6999
  // tmpVec3a,
@@ -6950,30 +7002,19 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6950
7002
  // depth / 2,
6951
7003
  // );
6952
7004
  // anchor is center by default, don't account for lineWidth here
6953
- var _f = parsedStyle, stroke = _f.stroke, lineWidth = _f.lineWidth,
7005
+ var _d = parsedStyle, stroke = _d.stroke, lineWidth = _d.lineWidth,
6954
7006
  // lineCap,
6955
7007
  // lineJoin,
6956
7008
  // miterLimit,
6957
- increasedLineWidthForHitTesting = _f.increasedLineWidthForHitTesting, shadowType = _f.shadowType, shadowColor = _f.shadowColor, _g = _f.filter, filter = _g === void 0 ? [] : _g, transformOrigin = _f.transformOrigin;
6958
- var anchor = parsedStyle.anchor;
7009
+ increasedLineWidthForHitTesting = _d.increasedLineWidthForHitTesting, shadowType = _d.shadowType, shadowColor = _d.shadowColor, _e = _d.filter, filter = _e === void 0 ? [] : _e, transformOrigin = _d.transformOrigin;
7010
+ // let anchor = parsedStyle.anchor;
6959
7011
  // <Text> use textAlign & textBaseline instead of anchor
6960
- if (nodeName === Shape.TEXT) {
6961
- delete parsedStyle.anchor;
6962
- }
6963
- else if (nodeName === Shape.MESH) {
6964
- parsedStyle.anchor[2] = 0.5;
6965
- }
6966
- var center = [
6967
- ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
6968
- ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
6969
- (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
6970
- ];
6971
- // const center = vec3.set(
6972
- // tmpVec3b,
6973
- // ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
6974
- // ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
6975
- // (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
6976
- // );
7012
+ // if (nodeName === Shape.TEXT) {
7013
+ // delete parsedStyle.anchor;
7014
+ // } else if (nodeName === Shape.MESH) {
7015
+ // parsedStyle.anchor[2] = 0.5;
7016
+ // }
7017
+ var center = [cx, cy, cz];
6977
7018
  // update geometry's AABB
6978
7019
  geometry_1.contentBounds.update(center, halfExtents);
6979
7020
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
@@ -7006,8 +7047,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7006
7047
  geometry_1.renderBounds.update(center, halfExtents);
7007
7048
  // account for shadow, only support constant value now
7008
7049
  if (shadowColor && shadowType && shadowType !== 'inner') {
7009
- var _h = geometry_1.renderBounds, min = _h.min, max = _h.max;
7010
- var _j = parsedStyle, shadowBlur = _j.shadowBlur, shadowOffsetX = _j.shadowOffsetX, shadowOffsetY = _j.shadowOffsetY;
7050
+ var _f = geometry_1.renderBounds, min = _f.min, max = _f.max;
7051
+ var _g = parsedStyle, shadowBlur = _g.shadowBlur, shadowOffsetX = _g.shadowOffsetX, shadowOffsetY = _g.shadowOffsetY;
7011
7052
  var shadowBlurInPixels = shadowBlur || 0;
7012
7053
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7013
7054
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7044,12 +7085,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7044
7085
  geometry_1.renderBounds.setMinMax(min, max);
7045
7086
  }
7046
7087
  });
7047
- anchor = parsedStyle.anchor;
7048
7088
  // if (nodeName === Shape.RECT) {
7049
7089
  // account for negative width / height of Rect
7050
7090
  // @see https://github.com/antvis/g/issues/957
7051
- var flipY = width < 0;
7052
- var flipX = height < 0;
7091
+ var flipY = hwidth < 0;
7092
+ var flipX = hheight < 0;
7053
7093
  // } else {
7054
7094
  // }
7055
7095
  // set transform origin
@@ -7061,19 +7101,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7061
7101
  (transformOrigin
7062
7102
  ? convertPercentUnit(transformOrigin[1], 1, object)
7063
7103
  : 0);
7064
- usedOriginXValue =
7065
- usedOriginXValue -
7066
- (flipY ? -1 : 1) *
7067
- ((anchor && anchor[0]) || 0) *
7068
- geometry_1.contentBounds.halfExtents[0] *
7069
- 2;
7070
- usedOriginYValue =
7071
- usedOriginYValue -
7072
- (flipX ? -1 : 1) *
7073
- ((anchor && anchor[1]) || 0) *
7074
- geometry_1.contentBounds.halfExtents[1] *
7075
- 2;
7076
- object.setOrigin(usedOriginXValue, usedOriginYValue);
7104
+ object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7077
7105
  // FIXME setOrigin may have already dirtified to root.
7078
7106
  this.runtime.sceneGraphService.dirtifyToRoot(object);
7079
7107
  }
@@ -7091,6 +7119,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7091
7119
  var CSSPropertyAngle = /** @class */ (function () {
7092
7120
  function CSSPropertyAngle() {
7093
7121
  this.parser = parseAngle;
7122
+ this.parserUnmemoize = parseAngleUnmemoize;
7094
7123
  this.parserWithCSSDisabled = null;
7095
7124
  this.mixer = mergeNumbers;
7096
7125
  }
@@ -7165,6 +7194,7 @@ function getFontSize(object) {
7165
7194
  var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7166
7195
  function CSSPropertyLengthOrPercentage() {
7167
7196
  this.parser = parseLengthOrPercentage;
7197
+ this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
7168
7198
  this.parserWithCSSDisabled = null;
7169
7199
  this.mixer = mergeNumbers;
7170
7200
  }
@@ -7293,177 +7323,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
7293
7323
  return CSSPropertyLengthOrPercentage14;
7294
7324
  }());
7295
7325
 
7296
- var tmpMat4 = mat4.create();
7297
- function parsedTransformToMat4(transform, object) {
7298
- var defX = object.parsedStyle.defX || 0;
7299
- var defY = object.parsedStyle.defY || 0;
7300
- // reset transform
7301
- object.resetLocalTransform();
7302
- object.setLocalPosition(defX, defY);
7303
- transform.forEach(function (parsed) {
7304
- var t = parsed.t, d = parsed.d;
7305
- if (t === 'scale') {
7306
- // scale(1) scale(1, 1)
7307
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7308
- object.scaleLocal(newScale[0], newScale[1], 1);
7309
- }
7310
- else if (t === 'scalex') {
7311
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7312
- object.scaleLocal(newScale[0], 1, 1);
7313
- }
7314
- else if (t === 'scaley') {
7315
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7316
- object.scaleLocal(1, newScale[0], 1);
7317
- }
7318
- else if (t === 'scalez') {
7319
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7320
- object.scaleLocal(1, 1, newScale[0]);
7321
- }
7322
- else if (t === 'scale3d') {
7323
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7324
- object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7325
- }
7326
- else if (t === 'translate') {
7327
- var newTranslation = d || [Opx, Opx];
7328
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7329
- }
7330
- else if (t === 'translatex') {
7331
- var newTranslation = d || [Opx];
7332
- object.translateLocal(newTranslation[0].value, 0, 0);
7333
- }
7334
- else if (t === 'translatey') {
7335
- var newTranslation = d || [Opx];
7336
- object.translateLocal(0, newTranslation[0].value, 0);
7337
- }
7338
- else if (t === 'translatez') {
7339
- var newTranslation = d || [Opx];
7340
- object.translateLocal(0, 0, newTranslation[0].value);
7341
- }
7342
- else if (t === 'translate3d') {
7343
- var newTranslation = d || [Opx, Opx, Opx];
7344
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7345
- }
7346
- else if (t === 'rotate') {
7347
- var newAngles = d || [Odeg];
7348
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7349
- }
7350
- else if (t === 'rotatex') {
7351
- var newAngles = d || [Odeg];
7352
- object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7353
- }
7354
- else if (t === 'rotatey') {
7355
- var newAngles = d || [Odeg];
7356
- object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7357
- }
7358
- else if (t === 'rotatez') {
7359
- var newAngles = d || [Odeg];
7360
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7361
- }
7362
- else if (t === 'rotate3d') ;
7363
- else if (t === 'skew') {
7364
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7365
- object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7366
- }
7367
- else if (t === 'skewx') {
7368
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7369
- object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7370
- }
7371
- else if (t === 'skewy') {
7372
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7373
- object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7374
- }
7375
- else if (t === 'matrix') {
7376
- var _a = __read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
7377
- object.setLocalTransform(mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx + defX, ty + defY, 0, 1));
7378
- }
7379
- else if (t === 'matrix3d') {
7380
- // @ts-ignore
7381
- mat4.set.apply(mat4, __spreadArray([tmpMat4], __read(d.map(function (s) { return s.value; })), false));
7382
- tmpMat4[12] += defX;
7383
- tmpMat4[13] += defY;
7384
- object.setLocalTransform(tmpMat4);
7385
- }
7386
- });
7387
- return object.getLocalTransform();
7388
- }
7389
-
7390
- /**
7391
- * local position
7392
- */
7393
- var CSSPropertyLocalPosition = /** @class */ (function (_super) {
7394
- __extends(CSSPropertyLocalPosition, _super);
7395
- function CSSPropertyLocalPosition() {
7396
- return _super !== null && _super.apply(this, arguments) || this;
7397
- }
7398
- /**
7399
- * update local position
7400
- */
7401
- CSSPropertyLocalPosition.prototype.postProcessor = function (object, attributes) {
7402
- var x;
7403
- var y;
7404
- var z;
7405
- switch (object.nodeName) {
7406
- case Shape.CIRCLE:
7407
- case Shape.ELLIPSE:
7408
- var _a = object.parsedStyle, cx = _a.cx, cy = _a.cy, cz = _a.cz;
7409
- if (!isNil(cx)) {
7410
- x = cx;
7411
- }
7412
- if (!isNil(cy)) {
7413
- y = cy;
7414
- }
7415
- if (!isNil(cz)) {
7416
- z = cz;
7417
- }
7418
- break;
7419
- case Shape.LINE:
7420
- var _b = object.parsedStyle, x1 = _b.x1, x2 = _b.x2, y1 = _b.y1, y2 = _b.y2;
7421
- var minX = Math.min(x1, x2);
7422
- var minY = Math.min(y1, y2);
7423
- x = minX;
7424
- y = minY;
7425
- z = 0;
7426
- break;
7427
- case Shape.RECT:
7428
- case Shape.IMAGE:
7429
- case Shape.GROUP:
7430
- case Shape.HTML:
7431
- case Shape.TEXT:
7432
- case Shape.MESH:
7433
- if (!isNil(object.parsedStyle.x)) {
7434
- x = object.parsedStyle.x;
7435
- }
7436
- if (!isNil(object.parsedStyle.y)) {
7437
- y = object.parsedStyle.y;
7438
- }
7439
- if (!isNil(object.parsedStyle.z)) {
7440
- z = object.parsedStyle.z;
7441
- }
7442
- break;
7443
- }
7444
- if (object.nodeName !== Shape.PATH &&
7445
- object.nodeName !== Shape.POLYLINE &&
7446
- object.nodeName !== Shape.POLYGON) {
7447
- object.parsedStyle.defX = x || 0;
7448
- object.parsedStyle.defY = y || 0;
7449
- }
7450
- var needResetLocalPosition = !isNil(x) || !isNil(y) || !isNil(z);
7451
- // only if `transform` won't be processed later
7452
- if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
7453
- // account for current transform if needed
7454
- var transform = object.parsedStyle.transform;
7455
- if (transform && transform.length) {
7456
- parsedTransformToMat4(transform, object);
7457
- }
7458
- else {
7459
- var _c = __read(object.getLocalPosition(), 3), ox = _c[0], oy = _c[1], oz = _c[2];
7460
- object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
7461
- }
7462
- }
7463
- };
7464
- return CSSPropertyLocalPosition;
7465
- }(CSSPropertyLengthOrPercentage));
7466
-
7467
7326
  var CSSPropertyMarker = /** @class */ (function () {
7468
7327
  function CSSPropertyMarker() {
7469
7328
  }
@@ -7486,6 +7345,7 @@ var CSSPropertyNumber = /** @class */ (function () {
7486
7345
  function CSSPropertyNumber() {
7487
7346
  this.mixer = mergeNumbers;
7488
7347
  this.parser = parseNumber;
7348
+ this.parserUnmemoize = parseNumberUnmemoize;
7489
7349
  this.parserWithCSSDisabled = null;
7490
7350
  }
7491
7351
  CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
@@ -7497,6 +7357,7 @@ var CSSPropertyNumber = /** @class */ (function () {
7497
7357
  var CSSPropertyOffsetDistance = /** @class */ (function () {
7498
7358
  function CSSPropertyOffsetDistance() {
7499
7359
  this.parser = parseNumber;
7360
+ this.parserUnmemoize = parseNumberUnmemoize;
7500
7361
  this.parserWithCSSDisabled = null;
7501
7362
  this.mixer = clampedMergeNumbers(0, 1);
7502
7363
  }
@@ -7515,8 +7376,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7515
7376
  // set position in world space
7516
7377
  var point = offsetPath.getPoint(offsetDistance);
7517
7378
  if (point) {
7518
- object.parsedStyle.defX = point.x;
7519
- object.parsedStyle.defY = point.y;
7520
7379
  object.setLocalPosition(point.x, point.y);
7521
7380
  }
7522
7381
  }
@@ -7530,6 +7389,7 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7530
7389
  var CSSPropertyOpacity = /** @class */ (function () {
7531
7390
  function CSSPropertyOpacity() {
7532
7391
  this.parser = parseNumber;
7392
+ this.parserUnmemoize = parseNumberUnmemoize;
7533
7393
  this.parserWithCSSDisabled = null;
7534
7394
  this.mixer = clampedMergeNumbers(0, 1);
7535
7395
  }
@@ -7564,18 +7424,6 @@ var CSSPropertyPath = /** @class */ (function () {
7564
7424
  }
7565
7425
  return parsed;
7566
7426
  };
7567
- /**
7568
- * update local position
7569
- */
7570
- CSSPropertyPath.prototype.postProcessor = function (object, attributes) {
7571
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
7572
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
7573
- if (object.nodeName === Shape.PATH &&
7574
- attributes.indexOf('transform') === -1) {
7575
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
7576
- object.setLocalPosition(defX, defY);
7577
- }
7578
- };
7579
7427
  return CSSPropertyPath;
7580
7428
  }());
7581
7429
 
@@ -7584,17 +7432,6 @@ var CSSPropertyPoints = /** @class */ (function () {
7584
7432
  this.parser = parsePoints;
7585
7433
  this.mixer = mergePoints;
7586
7434
  }
7587
- /**
7588
- * update local position
7589
- */
7590
- CSSPropertyPoints.prototype.postProcessor = function (object, attributes) {
7591
- if ((object.nodeName === Shape.POLYGON ||
7592
- object.nodeName === Shape.POLYLINE) &&
7593
- attributes.indexOf('transform') === -1) {
7594
- var _a = object.parsedStyle, defX = _a.defX, defY = _a.defY;
7595
- object.setLocalPosition(defX, defY);
7596
- }
7597
- };
7598
7435
  return CSSPropertyPoints;
7599
7436
  }());
7600
7437
 
@@ -8003,6 +7840,95 @@ function toFontString(attributes) {
8003
7840
  return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
8004
7841
  }
8005
7842
 
7843
+ var tmpMat4 = mat4.create();
7844
+ function parsedTransformToMat4(transform, object) {
7845
+ // reset transform
7846
+ object.resetLocalTransform();
7847
+ transform.forEach(function (parsed) {
7848
+ var t = parsed.t, d = parsed.d;
7849
+ if (t === 'scale') {
7850
+ // scale(1) scale(1, 1)
7851
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7852
+ object.scaleLocal(newScale[0], newScale[1], 1);
7853
+ }
7854
+ else if (t === 'scalex') {
7855
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7856
+ object.scaleLocal(newScale[0], 1, 1);
7857
+ }
7858
+ else if (t === 'scaley') {
7859
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7860
+ object.scaleLocal(1, newScale[0], 1);
7861
+ }
7862
+ else if (t === 'scalez') {
7863
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7864
+ object.scaleLocal(1, 1, newScale[0]);
7865
+ }
7866
+ else if (t === 'scale3d') {
7867
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7868
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7869
+ }
7870
+ else if (t === 'translate') {
7871
+ var newTranslation = d || [Opx, Opx];
7872
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7873
+ }
7874
+ else if (t === 'translatex') {
7875
+ var newTranslation = d || [Opx];
7876
+ object.translateLocal(newTranslation[0].value, 0, 0);
7877
+ }
7878
+ else if (t === 'translatey') {
7879
+ var newTranslation = d || [Opx];
7880
+ object.translateLocal(0, newTranslation[0].value, 0);
7881
+ }
7882
+ else if (t === 'translatez') {
7883
+ var newTranslation = d || [Opx];
7884
+ object.translateLocal(0, 0, newTranslation[0].value);
7885
+ }
7886
+ else if (t === 'translate3d') {
7887
+ var newTranslation = d || [Opx, Opx, Opx];
7888
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7889
+ }
7890
+ else if (t === 'rotate') {
7891
+ var newAngles = d || [Odeg];
7892
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7893
+ }
7894
+ else if (t === 'rotatex') {
7895
+ var newAngles = d || [Odeg];
7896
+ object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7897
+ }
7898
+ else if (t === 'rotatey') {
7899
+ var newAngles = d || [Odeg];
7900
+ object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7901
+ }
7902
+ else if (t === 'rotatez') {
7903
+ var newAngles = d || [Odeg];
7904
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7905
+ }
7906
+ else if (t === 'rotate3d') ;
7907
+ else if (t === 'skew') {
7908
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7909
+ object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7910
+ }
7911
+ else if (t === 'skewx') {
7912
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7913
+ object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7914
+ }
7915
+ else if (t === 'skewy') {
7916
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7917
+ object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7918
+ }
7919
+ else if (t === 'matrix') {
7920
+ var _a = __read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
7921
+ object.setLocalTransform(mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1));
7922
+ }
7923
+ else if (t === 'matrix3d') {
7924
+ // @ts-ignore
7925
+ mat4.set.apply(mat4, __spreadArray([tmpMat4], __read(d.map(function (s) { return s.value; })), false));
7926
+ object.setLocalTransform(tmpMat4);
7927
+ }
7928
+ });
7929
+ return object.getLocalTransform();
7930
+ }
7931
+
8006
7932
  /**
8007
7933
  * @see /zh/docs/api/animation#支持变换的属性
8008
7934
  *
@@ -8036,7 +7962,8 @@ function toFontString(attributes) {
8036
7962
  var CSSPropertyTransform = /** @class */ (function () {
8037
7963
  function CSSPropertyTransform() {
8038
7964
  this.parser = parseTransform;
8039
- this.parserWithCSSDisabled = parseTransform;
7965
+ this.parserUnmemoize = parseTransformUnmemoize;
7966
+ this.parserWithCSSDisabled = parseTransformUnmemoize;
8040
7967
  this.mixer = mergeTransforms;
8041
7968
  }
8042
7969
  CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
@@ -8061,6 +7988,7 @@ var CSSPropertyTransform = /** @class */ (function () {
8061
7988
  var CSSPropertyTransformOrigin = /** @class */ (function () {
8062
7989
  function CSSPropertyTransformOrigin() {
8063
7990
  this.parser = parseTransformOrigin;
7991
+ this.parserUnmemoize = parseTransformOriginUnmemoize;
8064
7992
  // calculator(
8065
7993
  // name: string,
8066
7994
  // oldParsed: [CSSUnitValue, CSSUnitValue],
@@ -8078,6 +8006,7 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
8078
8006
  var CSSPropertyZIndex = /** @class */ (function () {
8079
8007
  function CSSPropertyZIndex() {
8080
8008
  this.parser = parseNumber;
8009
+ this.parserUnmemoize = parseNumberUnmemoize;
8081
8010
  }
8082
8011
  CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
8083
8012
  return computed.value;
@@ -8104,12 +8033,12 @@ var CircleUpdater = /** @class */ (function () {
8104
8033
  function CircleUpdater() {
8105
8034
  }
8106
8035
  CircleUpdater.prototype.update = function (parsedStyle, object) {
8107
- var r = parsedStyle.r;
8108
- var width = r * 2;
8109
- var height = r * 2;
8036
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r;
8110
8037
  return {
8111
- width: width,
8112
- height: height,
8038
+ cx: cx,
8039
+ cy: cy,
8040
+ hwidth: r,
8041
+ hheight: r,
8113
8042
  };
8114
8043
  };
8115
8044
  return CircleUpdater;
@@ -8119,12 +8048,12 @@ var EllipseUpdater = /** @class */ (function () {
8119
8048
  function EllipseUpdater() {
8120
8049
  }
8121
8050
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
8122
- var rx = parsedStyle.rx, ry = parsedStyle.ry;
8123
- var width = rx * 2;
8124
- var height = ry * 2;
8051
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry;
8125
8052
  return {
8126
- width: width,
8127
- height: height,
8053
+ cx: cx,
8054
+ cy: cy,
8055
+ hwidth: rx,
8056
+ hheight: ry,
8128
8057
  };
8129
8058
  };
8130
8059
  return EllipseUpdater;
@@ -8141,9 +8070,13 @@ var LineUpdater = /** @class */ (function () {
8141
8070
  var maxY = Math.max(y1, y2);
8142
8071
  var width = maxX - minX;
8143
8072
  var height = maxY - minY;
8073
+ var hwidth = width / 2;
8074
+ var hheight = height / 2;
8144
8075
  return {
8145
- width: width,
8146
- height: height,
8076
+ cx: minX + hwidth,
8077
+ cy: minY + hheight,
8078
+ hwidth: hwidth,
8079
+ hheight: hheight,
8147
8080
  };
8148
8081
  };
8149
8082
  return LineUpdater;
@@ -8154,10 +8087,14 @@ var PathUpdater = /** @class */ (function () {
8154
8087
  }
8155
8088
  PathUpdater.prototype.update = function (parsedStyle) {
8156
8089
  var path = parsedStyle.path;
8157
- var _a = path.rect, width = _a.width, height = _a.height;
8090
+ var _a = path.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8091
+ var hwidth = width / 2;
8092
+ var hheight = height / 2;
8158
8093
  return {
8159
- width: width,
8160
- height: height,
8094
+ cx: x + hwidth,
8095
+ cy: y + hheight,
8096
+ hwidth: hwidth,
8097
+ hheight: hheight,
8161
8098
  };
8162
8099
  };
8163
8100
  return PathUpdater;
@@ -8176,14 +8113,20 @@ var PolylineUpdater = /** @class */ (function () {
8176
8113
  var maxY = Math.max.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[1]; })), false));
8177
8114
  var width = maxX - minX;
8178
8115
  var height = maxY - minY;
8116
+ var hwidth = width / 2;
8117
+ var hheight = height / 2;
8179
8118
  return {
8180
- width: width,
8181
- height: height,
8119
+ cx: minX + hwidth,
8120
+ cy: minY + hheight,
8121
+ hwidth: hwidth,
8122
+ hheight: hheight,
8182
8123
  };
8183
8124
  }
8184
8125
  return {
8185
- width: 0,
8186
- height: 0,
8126
+ cx: 0,
8127
+ cy: 0,
8128
+ hwidth: 0,
8129
+ hheight: 0,
8187
8130
  };
8188
8131
  };
8189
8132
  return PolylineUpdater;
@@ -8193,7 +8136,7 @@ var RectUpdater = /** @class */ (function () {
8193
8136
  function RectUpdater() {
8194
8137
  }
8195
8138
  RectUpdater.prototype.update = function (parsedStyle, object) {
8196
- var img = parsedStyle.img, _a = parsedStyle.width, width = _a === void 0 ? 0 : _a, _b = parsedStyle.height, height = _b === void 0 ? 0 : _b;
8139
+ var x = parsedStyle.x, y = parsedStyle.y, img = parsedStyle.img, _a = parsedStyle.width, width = _a === void 0 ? 0 : _a, _b = parsedStyle.height, height = _b === void 0 ? 0 : _b;
8197
8140
  var contentWidth = width;
8198
8141
  var contentHeight = height;
8199
8142
  // resize with HTMLImageElement's size
@@ -8208,8 +8151,10 @@ var RectUpdater = /** @class */ (function () {
8208
8151
  }
8209
8152
  }
8210
8153
  return {
8211
- width: contentWidth,
8212
- height: contentHeight,
8154
+ cx: x + contentWidth / 2,
8155
+ cy: y + contentHeight / 2,
8156
+ hwidth: contentWidth / 2,
8157
+ hheight: contentHeight / 2,
8213
8158
  };
8214
8159
  };
8215
8160
  return RectUpdater;
@@ -8232,7 +8177,7 @@ var TextUpdater = /** @class */ (function () {
8232
8177
  };
8233
8178
  TextUpdater.prototype.update = function (parsedStyle, object) {
8234
8179
  var _a, _b;
8235
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy;
8180
+ var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy, x = parsedStyle.x, y = parsedStyle.y;
8236
8181
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8237
8182
  parsedStyle.metrics = {
8238
8183
  font: '',
@@ -8250,47 +8195,42 @@ var TextUpdater = /** @class */ (function () {
8250
8195
  lineMetrics: [],
8251
8196
  };
8252
8197
  return {
8253
- width: 0,
8254
- height: 0,
8255
- x: 0,
8256
- y: 0,
8257
- offsetX: 0,
8258
- offsetY: 0,
8198
+ hwidth: 0,
8199
+ hheight: 0,
8200
+ cx: 0,
8201
+ cy: 0,
8259
8202
  };
8260
8203
  }
8261
8204
  var offscreenCanvas = (((_b = (_a = object === null || object === void 0 ? void 0 : object.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getConfig()) || {}).offscreenCanvas;
8262
8205
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8263
8206
  parsedStyle.metrics = metrics;
8264
8207
  var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
8265
- // anchor is left-top by default
8266
- var halfExtents = [width / 2, height / 2, 0];
8208
+ var hwidth = width / 2;
8209
+ var hheight = height / 2;
8267
8210
  // default 'left'
8268
- var anchor = [0, 1];
8269
- var lineXOffset = 0;
8211
+ var lineXOffset = x + hwidth;
8270
8212
  if (textAlign === 'center' || textAlign === 'middle') {
8271
- lineXOffset = lineWidth / 2;
8272
- anchor = [0.5, 1];
8213
+ lineXOffset += lineWidth / 2 - hwidth;
8273
8214
  }
8274
8215
  else if (textAlign === 'right' || textAlign === 'end') {
8275
- lineXOffset = lineWidth;
8276
- anchor = [1, 1];
8216
+ lineXOffset += lineWidth - hwidth * 2;
8277
8217
  }
8278
- var lineYOffset = 0;
8218
+ var lineYOffset = y - hheight;
8279
8219
  if (textBaseline === 'middle') {
8280
8220
  // eslint-disable-next-line prefer-destructuring
8281
- lineYOffset = halfExtents[1];
8221
+ lineYOffset += hheight;
8282
8222
  }
8283
8223
  else if (textBaseline === 'top' || textBaseline === 'hanging') {
8284
- lineYOffset = halfExtents[1] * 2;
8224
+ lineYOffset += hheight * 2;
8285
8225
  }
8286
8226
  else if (textBaseline === 'alphabetic') {
8287
8227
  // prevent calling getImageData for ascent metrics
8288
- lineYOffset = this.globalRuntime.enableCSSParsing
8228
+ lineYOffset += this.globalRuntime.enableCSSParsing
8289
8229
  ? lineHeight - fontProperties.ascent
8290
8230
  : 0;
8291
8231
  }
8292
8232
  else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
8293
- lineYOffset = 0;
8233
+ lineYOffset += 0;
8294
8234
  }
8295
8235
  // TODO: ideographic & bottom
8296
8236
  if (dx) {
@@ -8299,13 +8239,11 @@ var TextUpdater = /** @class */ (function () {
8299
8239
  if (dy) {
8300
8240
  lineYOffset += dy;
8301
8241
  }
8302
- // update anchor
8303
- parsedStyle.anchor = [anchor[0], anchor[1], 0];
8304
8242
  return {
8305
- width: halfExtents[0] * 2,
8306
- height: halfExtents[1] * 2,
8307
- offsetX: lineXOffset,
8308
- offsetY: lineYOffset,
8243
+ cx: lineXOffset,
8244
+ cy: lineYOffset,
8245
+ hwidth: hwidth,
8246
+ hheight: hheight,
8309
8247
  };
8310
8248
  };
8311
8249
  return TextUpdater;
@@ -11580,7 +11518,7 @@ var CSSPropertySyntaxFactory = (function () {
11580
11518
  _a[PropertySyntax.LENGTH_PERCENTAGE] = length,
11581
11519
  _a[PropertySyntax.LENGTH_PERCENTAGE_12] = new CSSPropertyLengthOrPercentage12(),
11582
11520
  _a[PropertySyntax.LENGTH_PERCENTAGE_14] = new CSSPropertyLengthOrPercentage14(),
11583
- _a[PropertySyntax.COORDINATE] = new CSSPropertyLocalPosition(),
11521
+ _a[PropertySyntax.COORDINATE] = new CSSPropertyLengthOrPercentage(),
11584
11522
  _a[PropertySyntax.OFFSET_DISTANCE] = new CSSPropertyOffsetDistance(),
11585
11523
  _a[PropertySyntax.OPACITY_VALUE] = new CSSPropertyOpacity(),
11586
11524
  _a[PropertySyntax.PATH] = new CSSPropertyPath(),
@@ -11876,8 +11814,11 @@ var Element = /** @class */ (function (_super) {
11876
11814
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11877
11815
  this.ownerDocument.defaultView.mountChildren(child);
11878
11816
  }
11879
- insertedEvent.relatedNode = this;
11880
- child.dispatchEvent(insertedEvent);
11817
+ // @ts-ignore
11818
+ if (child.isMutationObserved) {
11819
+ insertedEvent.relatedNode = this;
11820
+ child.dispatchEvent(insertedEvent);
11821
+ }
11881
11822
  return child;
11882
11823
  };
11883
11824
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12304,7 +12245,6 @@ var DATASET_PREFIX = 'data-';
12304
12245
  var DisplayObject = /** @class */ (function (_super) {
12305
12246
  __extends(DisplayObject, _super);
12306
12247
  function DisplayObject(config) {
12307
- var _a;
12308
12248
  var _this = _super.call(this) || this;
12309
12249
  _this.isCustomElement = false;
12310
12250
  _this.isMutationObserved = false;
@@ -12323,7 +12263,7 @@ var DisplayObject = /** @class */ (function (_super) {
12323
12263
  // eg. group.get('name')
12324
12264
  _this.config = config;
12325
12265
  // compatible with G 3.0
12326
- _this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive;
12266
+ // this.config.interactive = this.config.capture ?? this.config.interactive;
12327
12267
  // init scene graph node
12328
12268
  _this.id = _this.config.id || '';
12329
12269
  _this.name = _this.config.name || '';
@@ -12331,23 +12271,23 @@ var DisplayObject = /** @class */ (function (_super) {
12331
12271
  _this.className = _this.config.className || _this.config.class;
12332
12272
  }
12333
12273
  _this.nodeName = _this.config.type || Shape.GROUP;
12334
- // compatible with G 3.0
12335
- _this.config.style =
12336
- _this.config.style || _this.config.attrs || {};
12337
- Object.assign(_this.config.style, _this.config.attrs);
12338
- // this.config.style = {
12339
- // // ...DEFAULT_STYLE_PROPS,
12340
- // ...this.config.style,
12341
- // ...this.config.attrs,
12342
- // };
12343
- if (_this.config.visible != null) {
12344
- _this.config.style.visibility =
12345
- _this.config.visible === false ? 'hidden' : 'visible';
12346
- }
12347
- if (_this.config.interactive != null) {
12348
- _this.config.style.pointerEvents =
12349
- _this.config.interactive === false ? 'none' : 'auto';
12350
- }
12274
+ // // compatible with G 3.0
12275
+ // this.config.style =
12276
+ // this.config.style || this.config.attrs || ({} as StyleProps);
12277
+ // // Object.assign(this.config.style, this.config.attrs);
12278
+ // // this.config.style = {
12279
+ // // // ...DEFAULT_STYLE_PROPS,
12280
+ // // ...this.config.style,
12281
+ // // ...this.config.attrs,
12282
+ // // };
12283
+ // if (this.config.visible != null) {
12284
+ // this.config.style.visibility =
12285
+ // this.config.visible === false ? 'hidden' : 'visible';
12286
+ // }
12287
+ // if (this.config.interactive != null) {
12288
+ // this.config.style.pointerEvents =
12289
+ // this.config.interactive === false ? 'none' : 'auto';
12290
+ // }
12351
12291
  // merge parsed value
12352
12292
  Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12353
12293
  ? DEFAULT_PARSED_STYLE_PROPS
@@ -12486,15 +12426,16 @@ var DisplayObject = /** @class */ (function (_super) {
12486
12426
  // redraw at next frame
12487
12427
  renderable.dirty = true;
12488
12428
  };
12489
- DisplayObject.prototype.setAttribute = function (name, value, force) {
12429
+ DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
12490
12430
  if (force === void 0) { force = false; }
12431
+ if (memoize === void 0) { memoize = true; }
12491
12432
  var attributeName = formatAttributeName(name);
12492
12433
  // ignore undefined value
12493
12434
  if (isUndefined(value)) {
12494
12435
  return;
12495
12436
  }
12496
12437
  if (force || value !== this.attributes[attributeName]) {
12497
- this.internalSetAttribute(attributeName, value);
12438
+ this.internalSetAttribute(attributeName, value, { memoize: memoize });
12498
12439
  _super.prototype.setAttribute.call(this, attributeName, value);
12499
12440
  }
12500
12441
  };
@@ -13098,12 +13039,16 @@ var CSS = {
13098
13039
 
13099
13040
  var Circle = /** @class */ (function (_super) {
13100
13041
  __extends(Circle, _super);
13042
+ // constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
13043
+ // super(options);
13044
+ // this.nodeName = Shape.CIRCLE;
13045
+ // }
13101
13046
  function Circle(_a) {
13102
13047
  if (_a === void 0) { _a = {}; }
13103
13048
  var style = _a.style, rest = __rest(_a, ["style"]);
13104
13049
  return _super.call(this, __assign({ type: Shape.CIRCLE, style: runtime.enableCSSParsing
13105
13050
  ? __assign({ cx: '', cy: '', r: '' }, style) : __assign({}, style), initialParsedStyle: {
13106
- anchor: [0.5, 0.5],
13051
+ // anchor: [0.5, 0.5],
13107
13052
  transformOrigin: runtime.enableCSSParsing
13108
13053
  ? null
13109
13054
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13141,7 +13086,7 @@ var Ellipse = /** @class */ (function (_super) {
13141
13086
  var style = _a.style, rest = __rest(_a, ["style"]);
13142
13087
  return _super.call(this, __assign({ type: Shape.ELLIPSE, style: runtime.enableCSSParsing
13143
13088
  ? __assign({ cx: '', cy: '', rx: '', ry: '' }, style) : __assign({}, style), initialParsedStyle: {
13144
- anchor: [0.5, 0.5],
13089
+ // anchor: [0.5, 0.5],
13145
13090
  transformOrigin: runtime.enableCSSParsing
13146
13091
  ? null
13147
13092
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13311,7 +13256,7 @@ var Line = /** @class */ (function (_super) {
13311
13256
  }
13312
13257
  };
13313
13258
  Line.prototype.transformMarker = function (isStart) {
13314
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, x1 = _a.x1, x2 = _a.x2, y1 = _a.y1, y2 = _a.y2, defX = _a.defX, defY = _a.defY;
13259
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, x1 = _a.x1, x2 = _a.x2, y1 = _a.y1, y2 = _a.y2;
13315
13260
  var marker = isStart ? markerStart : markerEnd;
13316
13261
  if (!marker || !isDisplayObject(marker)) {
13317
13262
  return;
@@ -13324,16 +13269,16 @@ var Line = /** @class */ (function (_super) {
13324
13269
  var offset;
13325
13270
  var originalAngle;
13326
13271
  if (isStart) {
13327
- ox = x1 - defX;
13328
- oy = y1 - defY;
13272
+ ox = x1;
13273
+ oy = y1;
13329
13274
  x = x2 - x1;
13330
13275
  y = y2 - y1;
13331
13276
  offset = markerStartOffset || 0;
13332
13277
  originalAngle = this.markerStartAngle;
13333
13278
  }
13334
13279
  else {
13335
- ox = x2 - defX;
13336
- oy = y2 - defY;
13280
+ ox = x2;
13281
+ oy = y2;
13337
13282
  x = x1 - x2;
13338
13283
  y = y1 - y2;
13339
13284
  offset = markerEndOffset || 0;
@@ -13347,9 +13292,9 @@ var Line = /** @class */ (function (_super) {
13347
13292
  Line.prototype.getPoint = function (ratio, inWorldSpace) {
13348
13293
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13349
13294
  // TODO: account for z1/z2 in 3D line
13350
- var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2, defX = _a.defX, defY = _a.defY;
13295
+ var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
13351
13296
  var _b = linePointAt(x1, y1, x2, y2, ratio), x = _b.x, y = _b.y;
13352
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13297
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13353
13298
  // apply local transformation
13354
13299
  return new Point(transformed[0], transformed[1]);
13355
13300
  };
@@ -13440,7 +13385,7 @@ var Path = /** @class */ (function (_super) {
13440
13385
  }
13441
13386
  };
13442
13387
  Path.prototype.transformMarker = function (isStart) {
13443
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, defX = _a.defX, defY = _a.defY;
13388
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset;
13444
13389
  var marker = isStart ? markerStart : markerEnd;
13445
13390
  if (!marker || !isDisplayObject(marker)) {
13446
13391
  return;
@@ -13454,8 +13399,8 @@ var Path = /** @class */ (function (_super) {
13454
13399
  var originalAngle;
13455
13400
  if (isStart) {
13456
13401
  var _b = __read(this.getStartTangent(), 2), p1 = _b[0], p2 = _b[1];
13457
- ox = p2[0] - defX;
13458
- oy = p2[1] - defY;
13402
+ ox = p2[0];
13403
+ oy = p2[1];
13459
13404
  x = p1[0] - p2[0];
13460
13405
  y = p1[1] - p2[1];
13461
13406
  offset = markerStartOffset || 0;
@@ -13463,8 +13408,8 @@ var Path = /** @class */ (function (_super) {
13463
13408
  }
13464
13409
  else {
13465
13410
  var _c = __read(this.getEndTangent(), 2), p1 = _c[0], p2 = _c[1];
13466
- ox = p2[0] - defX;
13467
- oy = p2[1] - defY;
13411
+ ox = p2[0];
13412
+ oy = p2[1];
13468
13413
  x = p1[0] - p2[0];
13469
13414
  y = p1[1] - p2[1];
13470
13415
  offset = markerEndOffset || 0;
@@ -13476,18 +13421,18 @@ var Path = /** @class */ (function (_super) {
13476
13421
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13477
13422
  };
13478
13423
  Path.prototype.placeMarkerMid = function (marker) {
13479
- var _a = this.parsedStyle, segments = _a.path.segments, defX = _a.defX, defY = _a.defY;
13424
+ var segments = this.parsedStyle.path.segments;
13480
13425
  // clear all existed markers
13481
13426
  this.markerMidList.forEach(function (marker) {
13482
13427
  marker.remove();
13483
13428
  });
13484
13429
  if (marker && isDisplayObject(marker)) {
13485
13430
  for (var i = 1; i < segments.length - 1; i++) {
13486
- var _b = __read(segments[i].currentPoint, 2), ox = _b[0], oy = _b[1];
13431
+ var _a = __read(segments[i].currentPoint, 2), ox = _a[0], oy = _a[1];
13487
13432
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13488
13433
  this.markerMidList.push(cloned);
13489
13434
  this.appendChild(cloned);
13490
- cloned.setLocalPosition(ox - defX, oy - defY);
13435
+ cloned.setLocalPosition(ox, oy);
13491
13436
  // TODO: orient of marker
13492
13437
  }
13493
13438
  }
@@ -13505,9 +13450,9 @@ var Path = /** @class */ (function (_super) {
13505
13450
  */
13506
13451
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13507
13452
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13508
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, absolutePath = _a.path.absolutePath;
13509
- var _b = getPointAtLength(absolutePath, distance), x = _b.x, y = _b.y;
13510
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13453
+ var absolutePath = this.parsedStyle.path.absolutePath;
13454
+ var _a = getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13455
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13511
13456
  // apply local transformation
13512
13457
  return new Point(transformed[0], transformed[1]);
13513
13458
  };
@@ -13646,7 +13591,7 @@ var Polygon = /** @class */ (function (_super) {
13646
13591
  }
13647
13592
  };
13648
13593
  Polygon.prototype.transformMarker = function (isStart) {
13649
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, P = _a.points, defX = _a.defX, defY = _a.defY;
13594
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, P = _a.points;
13650
13595
  var points = (P || {}).points;
13651
13596
  var marker = isStart ? markerStart : markerEnd;
13652
13597
  if (!marker || !isDisplayObject(marker) || !points) {
@@ -13659,8 +13604,8 @@ var Polygon = /** @class */ (function (_super) {
13659
13604
  var oy;
13660
13605
  var offset;
13661
13606
  var originalAngle;
13662
- ox = points[0][0] - defX;
13663
- oy = points[0][1] - defY;
13607
+ ox = points[0][0];
13608
+ oy = points[0][1];
13664
13609
  if (isStart) {
13665
13610
  x = points[1][0] - points[0][0];
13666
13611
  y = points[1][1] - points[0][1];
@@ -13670,8 +13615,8 @@ var Polygon = /** @class */ (function (_super) {
13670
13615
  else {
13671
13616
  var length_1 = points.length;
13672
13617
  if (!this.parsedStyle.isClosed) {
13673
- ox = points[length_1 - 1][0] - defX;
13674
- oy = points[length_1 - 1][1] - defY;
13618
+ ox = points[length_1 - 1][0];
13619
+ oy = points[length_1 - 1][1];
13675
13620
  x = points[length_1 - 2][0] - points[length_1 - 1][0];
13676
13621
  y = points[length_1 - 2][1] - points[length_1 - 1][1];
13677
13622
  }
@@ -13688,7 +13633,7 @@ var Polygon = /** @class */ (function (_super) {
13688
13633
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13689
13634
  };
13690
13635
  Polygon.prototype.placeMarkerMid = function (marker) {
13691
- var _a = this.parsedStyle, P = _a.points, defX = _a.defX, defY = _a.defY;
13636
+ var P = this.parsedStyle.points;
13692
13637
  var points = (P || {}).points;
13693
13638
  // clear all existed markers
13694
13639
  this.markerMidList.forEach(function (marker) {
@@ -13697,8 +13642,8 @@ var Polygon = /** @class */ (function (_super) {
13697
13642
  this.markerMidList = [];
13698
13643
  if (marker && isDisplayObject(marker) && points) {
13699
13644
  for (var i = 1; i < (this.parsedStyle.isClosed ? points.length : points.length - 1); i++) {
13700
- var ox = points[i][0] - defX;
13701
- var oy = points[i][1] - defY;
13645
+ var ox = points[i][0];
13646
+ var oy = points[i][1];
13702
13647
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13703
13648
  this.markerMidList.push(cloned);
13704
13649
  this.appendChild(cloned);
@@ -13740,7 +13685,7 @@ var Polyline = /** @class */ (function (_super) {
13740
13685
  };
13741
13686
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13742
13687
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13743
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, _b = _a.points, points = _b.points, segments = _b.segments;
13688
+ var _a = this.parsedStyle.points, points = _a.points, segments = _a.segments;
13744
13689
  var subt = 0;
13745
13690
  var index = 0;
13746
13691
  segments.forEach(function (v, i) {
@@ -13749,8 +13694,8 @@ var Polyline = /** @class */ (function (_super) {
13749
13694
  index = i;
13750
13695
  }
13751
13696
  });
13752
- var _c = linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _c.x, y = _c.y;
13753
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13697
+ var _b = linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _b.x, y = _b.y;
13698
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13754
13699
  // apply local transformation
13755
13700
  return new Point(transformed[0], transformed[1]);
13756
13701
  };