@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.js CHANGED
@@ -3569,7 +3569,7 @@ var parseGradient$1 = (function () {
3569
3569
  return getAST();
3570
3570
  };
3571
3571
  })();
3572
- function computeLinearGradient(width, height, angle) {
3572
+ function computeLinearGradient(min, width, height, angle) {
3573
3573
  var rad = deg2rad(angle.value);
3574
3574
  var rx = 0;
3575
3575
  var ry = 0;
@@ -3578,13 +3578,13 @@ function computeLinearGradient(width, height, angle) {
3578
3578
  // get the length of gradient line
3579
3579
  // @see https://observablehq.com/@danburzo/css-gradient-line
3580
3580
  var length = Math.abs(width * Math.cos(rad)) + Math.abs(height * Math.sin(rad));
3581
- var x1 = rcx - (Math.cos(rad) * length) / 2;
3582
- var y1 = rcy - (Math.sin(rad) * length) / 2;
3583
- var x2 = rcx + (Math.cos(rad) * length) / 2;
3584
- var y2 = rcy + (Math.sin(rad) * length) / 2;
3581
+ var x1 = min[0] + rcx - (Math.cos(rad) * length) / 2;
3582
+ var y1 = min[1] + rcy - (Math.sin(rad) * length) / 2;
3583
+ var x2 = min[0] + rcx + (Math.cos(rad) * length) / 2;
3584
+ var y2 = min[1] + rcy + (Math.sin(rad) * length) / 2;
3585
3585
  return { x1: x1, y1: y1, x2: x2, y2: y2 };
3586
3586
  }
3587
- function computeRadialGradient(width, height, cx, cy, size) {
3587
+ function computeRadialGradient(min, width, height, cx, cy, size) {
3588
3588
  // 'px'
3589
3589
  var x = cx.value;
3590
3590
  var y = cy.value;
@@ -3615,7 +3615,7 @@ function computeRadialGradient(width, height, cx, cy, size) {
3615
3615
  }
3616
3616
  }
3617
3617
  }
3618
- return { x: x, y: y, r: r };
3618
+ return { x: x + min[0], y: y + min[1], r: r };
3619
3619
  }
3620
3620
 
3621
3621
  var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
@@ -3976,29 +3976,25 @@ function parseDimension(unitRegExp, string) {
3976
3976
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
3977
3977
  * length with only absolute unit, eg. 1px
3978
3978
  */
3979
- var parseLength = memoize(function (css) {
3979
+ var parseLengthUnmemoize = function (css) {
3980
3980
  return parseDimension(new RegExp('px', 'g'), css);
3981
- });
3981
+ };
3982
+ var parseLength = memoize(parseLengthUnmemoize);
3982
3983
  /**
3983
3984
  * <percentage>
3984
3985
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
3985
3986
  */
3986
- memoize(function (css) {
3987
+ var parserPercentageUnmemoize = function (css) {
3987
3988
  return parseDimension(new RegExp('%', 'g'), css);
3988
- });
3989
+ };
3990
+ memoize(parserPercentageUnmemoize);
3989
3991
  /**
3990
3992
  * length with absolute or relative unit,
3991
3993
  * eg. 1px, 0.7em, 50%, calc(100% - 200px);
3992
3994
  *
3993
3995
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
3994
3996
  */
3995
- // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
3996
- // if (isNumber(css) || isFinite(Number(css))) {
3997
- // return getOrCreateUnitValue(Number(css), 'px');
3998
- // }
3999
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
4000
- // });
4001
- var parseLengthOrPercentage = function (css) {
3997
+ var parseLengthOrPercentageUnmemoize = function (css) {
4002
3998
  if (util.isNumber(css) || isFinite(Number(css))) {
4003
3999
  // Number(css) is NaN
4004
4000
  return getOrCreateUnitValue(Number(css) || 0, 'px');
@@ -4006,9 +4002,11 @@ var parseLengthOrPercentage = function (css) {
4006
4002
  }
4007
4003
  return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
4008
4004
  };
4009
- var parseAngle = memoize(function (css) {
4005
+ var parseLengthOrPercentage = memoize(parseLengthOrPercentageUnmemoize);
4006
+ var parseAngleUnmemoize = function (css) {
4010
4007
  return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
4011
- });
4008
+ };
4009
+ var parseAngle = memoize(parseAngleUnmemoize);
4012
4010
  /**
4013
4011
  * merge CSSUnitValue
4014
4012
  *
@@ -4201,7 +4199,7 @@ function numberToString(x) {
4201
4199
  * * 0 -> CSSUnitValue(0)
4202
4200
  * * '2' -> CSSUnitValue(2)
4203
4201
  */
4204
- var parseNumber = memoize(function (string) {
4202
+ var parseNumberUnmemoize = function (string) {
4205
4203
  if (typeof string === 'number') {
4206
4204
  return getOrCreateUnitValue(string);
4207
4205
  }
@@ -4211,12 +4209,8 @@ var parseNumber = memoize(function (string) {
4211
4209
  else {
4212
4210
  return getOrCreateUnitValue(0);
4213
4211
  }
4214
- });
4215
- /**
4216
- * separate string to array
4217
- * eg.
4218
- * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
4219
- */
4212
+ };
4213
+ var parseNumber = memoize(parseNumberUnmemoize);
4220
4214
  memoize(function (string) {
4221
4215
  if (util.isString(string)) {
4222
4216
  return string.split(' ').map(parseNumber);
@@ -4818,11 +4812,10 @@ function getArcParams(startPoint, params) {
4818
4812
  };
4819
4813
  }
4820
4814
  function commandsToPathString(commands, object, transform) {
4821
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
4822
4815
  return commands.reduce(function (prev, cur) {
4823
4816
  var path = '';
4824
4817
  if (cur[0] === 'M' || cur[0] === 'L') {
4825
- var p = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4818
+ var p = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4826
4819
  if (transform) {
4827
4820
  glMatrix.vec3.transformMat4(p, p, transform);
4828
4821
  }
@@ -4832,9 +4825,9 @@ function commandsToPathString(commands, object, transform) {
4832
4825
  path = cur[0];
4833
4826
  }
4834
4827
  else if (cur[0] === 'C') {
4835
- var p1 = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4836
- var p2 = glMatrix.vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4837
- var p3 = glMatrix.vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
4828
+ var p1 = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4829
+ var p2 = glMatrix.vec3.fromValues(cur[3], cur[4], 0);
4830
+ var p3 = glMatrix.vec3.fromValues(cur[5], cur[6], 0);
4838
4831
  if (transform) {
4839
4832
  glMatrix.vec3.transformMat4(p1, p1, transform);
4840
4833
  glMatrix.vec3.transformMat4(p2, p2, transform);
@@ -4843,15 +4836,15 @@ function commandsToPathString(commands, object, transform) {
4843
4836
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
4844
4837
  }
4845
4838
  else if (cur[0] === 'A') {
4846
- var c = glMatrix.vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
4839
+ var c = glMatrix.vec3.fromValues(cur[6], cur[7], 0);
4847
4840
  if (transform) {
4848
4841
  glMatrix.vec3.transformMat4(c, c, transform);
4849
4842
  }
4850
4843
  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]);
4851
4844
  }
4852
4845
  else if (cur[0] === 'Q') {
4853
- var p1 = glMatrix.vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4854
- var p2 = glMatrix.vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4846
+ var p1 = glMatrix.vec3.fromValues(cur[1], cur[2], 0);
4847
+ var p2 = glMatrix.vec3.fromValues(cur[3], cur[4], 0);
4855
4848
  if (transform) {
4856
4849
  glMatrix.vec3.transformMat4(p1, p1, transform);
4857
4850
  glMatrix.vec3.transformMat4(p2, p2, transform);
@@ -4972,7 +4965,7 @@ function convertToPath(object, transform) {
4972
4965
  return commandsToPathString(commands, object, transform);
4973
4966
  }
4974
4967
  }
4975
- function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4968
+ function translatePathToString(absolutePath, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4976
4969
  if (startOffsetX === void 0) { startOffsetX = 0; }
4977
4970
  if (startOffsetY === void 0) { startOffsetY = 0; }
4978
4971
  if (endOffsetX === void 0) { endOffsetX = 0; }
@@ -4991,27 +4984,27 @@ function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffs
4991
4984
  case 'M':
4992
4985
  // Use start marker offset
4993
4986
  if (useStartOffset) {
4994
- return "M ".concat(params[1] - defX + startOffsetX, ",").concat(params[2] - defY + startOffsetY, " L ").concat(params[1] - defX, ",").concat(params[2] - defY);
4987
+ return "M ".concat(params[1] + startOffsetX, ",").concat(params[2] + startOffsetY, " L ").concat(params[1], ",").concat(params[2]);
4995
4988
  }
4996
4989
  else {
4997
- return "M ".concat(params[1] - defX, ",").concat(params[2] - defY);
4990
+ return "M ".concat(params[1], ",").concat(params[2]);
4998
4991
  }
4999
4992
  case 'L':
5000
- return "L ".concat(params[1] - defX + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] - defY + (useEndOffset ? endOffsetY : 0));
4993
+ return "L ".concat(params[1] + (useEndOffset ? endOffsetX : 0), ",").concat(params[2] + (useEndOffset ? endOffsetY : 0));
5001
4994
  case 'Q':
5002
- return ("Q ".concat(params[1] - defX, " ").concat(params[2] - defY, ",").concat(params[3] - defX, " ").concat(params[4] - defY) +
4995
+ return ("Q ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4]) +
5003
4996
  (useEndOffset
5004
- ? " L ".concat(params[3] - defX + endOffsetX, ",").concat(params[4] - defY + endOffsetY)
4997
+ ? " L ".concat(params[3] + endOffsetX, ",").concat(params[4] + endOffsetY)
5005
4998
  : ''));
5006
4999
  case 'C':
5007
- 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) +
5000
+ return ("C ".concat(params[1], " ").concat(params[2], ",").concat(params[3], " ").concat(params[4], ",").concat(params[5], " ").concat(params[6]) +
5008
5001
  (useEndOffset
5009
- ? " L ".concat(params[5] - defX + endOffsetX, ",").concat(params[6] - defY + endOffsetY)
5002
+ ? " L ".concat(params[5] + endOffsetX, ",").concat(params[6] + endOffsetY)
5010
5003
  : ''));
5011
5004
  case 'A':
5012
- 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) +
5005
+ return ("A ".concat(params[1], " ").concat(params[2], " ").concat(params[3], " ").concat(params[4], " ").concat(params[5], " ").concat(params[6], " ").concat(params[7]) +
5013
5006
  (useEndOffset
5014
- ? " L ".concat(params[6] - defX + endOffsetX, ",").concat(params[7] - defY + endOffsetY)
5007
+ ? " L ".concat(params[6] + endOffsetX, ",").concat(params[7] + endOffsetY)
5015
5008
  : ''));
5016
5009
  case 'Z':
5017
5010
  return 'Z';
@@ -5141,12 +5134,8 @@ function parsePoints(pointsOrStr, object) {
5141
5134
  segments.push(segmentT);
5142
5135
  }
5143
5136
  });
5144
- var minX = Math.min.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[0]; })), false));
5145
- var minY = Math.min.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[1]; })), false));
5146
- if (object) {
5147
- object.parsedStyle.defX = minX;
5148
- object.parsedStyle.defY = minY;
5149
- }
5137
+ // const minX = Math.min(...points.map((point) => point[0]));
5138
+ // const minY = Math.min(...points.map((point) => point[1]));
5150
5139
  return {
5151
5140
  points: points,
5152
5141
  totalLength: totalLength,
@@ -5276,6 +5265,68 @@ function parseTransform(string) {
5276
5265
  }
5277
5266
  return [];
5278
5267
  }
5268
+ function parseTransformUnmemoize(string) {
5269
+ string = (string || 'none').toLowerCase().trim();
5270
+ if (string === 'none') {
5271
+ return [];
5272
+ }
5273
+ var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
5274
+ var result = [];
5275
+ var match;
5276
+ var prevLastIndex = 0;
5277
+ while ((match = transformRegExp.exec(string))) {
5278
+ if (match.index !== prevLastIndex) {
5279
+ return [];
5280
+ }
5281
+ prevLastIndex = match.index + match[0].length;
5282
+ var functionName = match[1]; // scale
5283
+ var functionData = transformFunctions[functionName]; // scale(1, 2)
5284
+ if (!functionData) {
5285
+ // invalid, eg. scale()
5286
+ return [];
5287
+ }
5288
+ var args = match[2].split(','); // 1,2
5289
+ var argTypes = functionData[0]; // Nn
5290
+ if (argTypes.length < args.length) {
5291
+ // scale(N, n)
5292
+ return [];
5293
+ }
5294
+ var parsedArgs = [];
5295
+ for (var i = 0; i < argTypes.length; i++) {
5296
+ var arg = args[i];
5297
+ var type = argTypes[i];
5298
+ var parsedArg = void 0;
5299
+ if (!arg) {
5300
+ // @ts-ignore
5301
+ parsedArg = {
5302
+ a: Odeg,
5303
+ n: parsedArgs[0],
5304
+ t: Opx,
5305
+ }[type];
5306
+ }
5307
+ else {
5308
+ // @ts-ignore
5309
+ parsedArg = {
5310
+ A: function (s) {
5311
+ return s.trim() === '0' ? Odeg : parseAngleUnmemoize(s);
5312
+ },
5313
+ N: parseNumberUnmemoize,
5314
+ T: parseLengthOrPercentageUnmemoize,
5315
+ L: parseLengthUnmemoize,
5316
+ }[type.toUpperCase()](arg);
5317
+ }
5318
+ if (parsedArg === undefined) {
5319
+ return [];
5320
+ }
5321
+ parsedArgs.push(parsedArg);
5322
+ }
5323
+ result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
5324
+ if (transformRegExp.lastIndex === string.length) {
5325
+ return result;
5326
+ }
5327
+ }
5328
+ return [];
5329
+ }
5279
5330
  function convertItemToMatrix(item) {
5280
5331
  var x;
5281
5332
  var y;
@@ -5891,6 +5942,39 @@ var parseTransformOrigin = memoize(function (value) {
5891
5942
  ];
5892
5943
  }
5893
5944
  });
5945
+ var parseTransformOriginUnmemoize = function (value) {
5946
+ if (util.isString(value)) {
5947
+ if (value === 'text-anchor') {
5948
+ return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
5949
+ }
5950
+ var values = value.split(' ');
5951
+ if (values.length === 1) {
5952
+ if (values[0] === 'top' || values[0] === 'bottom') {
5953
+ // 'top' -> 'center top'
5954
+ values[1] = values[0];
5955
+ values[0] = 'center';
5956
+ }
5957
+ else {
5958
+ // '50px' -> '50px center'
5959
+ values[1] = 'center';
5960
+ }
5961
+ }
5962
+ if (values.length !== 2) {
5963
+ return null;
5964
+ }
5965
+ // eg. center bottom
5966
+ return [
5967
+ parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
5968
+ parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
5969
+ ];
5970
+ }
5971
+ else {
5972
+ return [
5973
+ getOrCreateUnitValue(value[0] || 0, 'px'),
5974
+ getOrCreateUnitValue(value[1] || 0, 'px'),
5975
+ ];
5976
+ }
5977
+ };
5894
5978
  function convertKeyword2Percent(keyword) {
5895
5979
  if (keyword === 'center') {
5896
5980
  return '50%';
@@ -6181,9 +6265,9 @@ var BUILT_IN_PROPERTIES = [
6181
6265
  n: 'anchor',
6182
6266
  p: 99,
6183
6267
  d: function (nodeName) {
6184
- if (nodeName === exports.Shape.CIRCLE || nodeName === exports.Shape.ELLIPSE) {
6185
- return '0.5 0.5';
6186
- }
6268
+ // if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6269
+ // return '0.5 0.5';
6270
+ // }
6187
6271
  return '0 0';
6188
6272
  },
6189
6273
  l: true,
@@ -6543,6 +6627,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6543
6627
  skipParse: false,
6544
6628
  forceUpdateGeometry: false,
6545
6629
  usedAttributes: [],
6630
+ memoize: true,
6546
6631
  }; }
6547
6632
  if (!this.runtime.enableCSSParsing) {
6548
6633
  Object.assign(object.attributes, attributes);
@@ -6587,7 +6672,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6587
6672
  // @ts-ignore
6588
6673
  if (attributes.points) {
6589
6674
  // @ts-ignore
6590
- object.parsedStyle.points = parsePoints(attributes.points, object);
6675
+ object.parsedStyle.points = parsePoints(attributes.points);
6591
6676
  }
6592
6677
  // Path
6593
6678
  // @ts-ignore
@@ -6599,8 +6684,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6599
6684
  object.parsedStyle.path = parsePath(
6600
6685
  // @ts-ignore
6601
6686
  attributes.path);
6602
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
6603
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
6604
6687
  }
6605
6688
  // Text
6606
6689
  if (attributes.textTransform) {
@@ -6648,42 +6731,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6648
6731
  // @ts-ignore
6649
6732
  attributes.markerMid, null, null);
6650
6733
  }
6651
- if (
6652
- // Circle & Ellipse
6653
- ((object.nodeName === exports.Shape.CIRCLE ||
6654
- object.nodeName === exports.Shape.ELLIPSE) &&
6655
- // @ts-ignore
6656
- (!util.isNil(attributes.cx) ||
6657
- // @ts-ignore
6658
- !util.isNil(attributes.cy))) ||
6659
- ((object.nodeName === exports.Shape.RECT ||
6660
- object.nodeName === exports.Shape.IMAGE ||
6661
- object.nodeName === exports.Shape.GROUP ||
6662
- object.nodeName === exports.Shape.HTML ||
6663
- object.nodeName === exports.Shape.TEXT ||
6664
- object.nodeName === exports.Shape.MESH) &&
6665
- // @ts-ignore
6666
- (!util.isNil(attributes.x) ||
6667
- // @ts-ignore
6668
- !util.isNil(attributes.y) ||
6669
- // @ts-ignore
6670
- !util.isNil(attributes.z))) ||
6671
- // Line
6672
- (object.nodeName === exports.Shape.LINE &&
6673
- // @ts-ignore
6674
- (!util.isNil(attributes.x1) ||
6675
- // @ts-ignore
6676
- !util.isNil(attributes.y1) ||
6677
- // @ts-ignore
6678
- !util.isNil(attributes.z1) ||
6679
- // @ts-ignore
6680
- !util.isNil(attributes.x2) ||
6681
- // @ts-ignore
6682
- !util.isNil(attributes.y2) ||
6683
- // @ts-ignore
6684
- !util.isNil(attributes.z2)))) {
6685
- this.runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object, attributeNames_1);
6686
- }
6687
6734
  if (!util.isNil(attributes.zIndex)) {
6688
6735
  this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames_1);
6689
6736
  }
@@ -6706,7 +6753,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6706
6753
  }
6707
6754
  return;
6708
6755
  }
6709
- var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes;
6756
+ var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize = options.memoize;
6710
6757
  var needUpdateGeometry = forceUpdateGeometry;
6711
6758
  var attributeNames = Object.keys(attributes);
6712
6759
  attributeNames.forEach(function (attributeName) {
@@ -6720,7 +6767,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6720
6767
  });
6721
6768
  if (!skipParse) {
6722
6769
  attributeNames.forEach(function (name) {
6723
- object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
6770
+ object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
6724
6771
  });
6725
6772
  }
6726
6773
  // let hasUnresolvedProperties = false;
@@ -6754,7 +6801,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6754
6801
  attributeNames.forEach(function (name) {
6755
6802
  // some style props maybe deleted after parsing such as `anchor` in Text
6756
6803
  if (name in object.computedStyle) {
6757
- object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object);
6804
+ object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
6758
6805
  }
6759
6806
  });
6760
6807
  // if (hasUnresolvedProperties) {
@@ -6789,7 +6836,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6789
6836
  /**
6790
6837
  * string -> parsed value
6791
6838
  */
6792
- DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
6839
+ DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object, memoized) {
6793
6840
  var metadata = propertyMetadataCache[name];
6794
6841
  var computed = value;
6795
6842
  if (value === '' || util.isNil(value)) {
@@ -6808,9 +6855,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6808
6855
  // computed = new CSSKeywordValue(value);
6809
6856
  computed = getOrCreateKeyword(value);
6810
6857
  }
6811
- else if (handler && handler.parser) {
6812
- // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
6813
- computed = handler.parser(value, object);
6858
+ else if (handler) {
6859
+ if (!memoized && handler.parserUnmemoize) {
6860
+ computed = handler.parserUnmemoize(value, object);
6861
+ }
6862
+ else if (handler.parser) {
6863
+ // try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
6864
+ computed = handler.parser(value, object);
6865
+ }
6814
6866
  }
6815
6867
  }
6816
6868
  }
@@ -6819,7 +6871,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6819
6871
  /**
6820
6872
  * computed value -> used value
6821
6873
  */
6822
- DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
6874
+ DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object, memoized) {
6823
6875
  var metadata = propertyMetadataCache[name];
6824
6876
  var isDocumentElement = object.id === 'g-root';
6825
6877
  // let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
@@ -6844,7 +6896,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6844
6896
  if (!util.isNil(defaultValue)) {
6845
6897
  computed = this.parseProperty(name, isFunction(defaultValue)
6846
6898
  ? defaultValue(object.nodeName)
6847
- : defaultValue, object);
6899
+ : defaultValue, object, memoized);
6848
6900
  }
6849
6901
  }
6850
6902
  else if (value === 'inherit') {
@@ -6957,12 +7009,12 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6957
7009
  geometry_1.renderBounds = new AABB();
6958
7010
  }
6959
7011
  var parsedStyle = object.parsedStyle;
6960
- 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;
7012
+ 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;
6961
7013
  // init with content box
6962
7014
  var halfExtents = [
6963
- Math.abs(width) / 2,
6964
- Math.abs(height) / 2,
6965
- depth / 2,
7015
+ Math.abs(hwidth),
7016
+ Math.abs(hheight),
7017
+ hdepth,
6966
7018
  ];
6967
7019
  // const halfExtents = vec3.set(
6968
7020
  // tmpVec3a,
@@ -6971,30 +7023,19 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6971
7023
  // depth / 2,
6972
7024
  // );
6973
7025
  // anchor is center by default, don't account for lineWidth here
6974
- var _f = parsedStyle, stroke = _f.stroke, lineWidth = _f.lineWidth,
7026
+ var _d = parsedStyle, stroke = _d.stroke, lineWidth = _d.lineWidth,
6975
7027
  // lineCap,
6976
7028
  // lineJoin,
6977
7029
  // miterLimit,
6978
- increasedLineWidthForHitTesting = _f.increasedLineWidthForHitTesting, shadowType = _f.shadowType, shadowColor = _f.shadowColor, _g = _f.filter, filter = _g === void 0 ? [] : _g, transformOrigin = _f.transformOrigin;
6979
- var anchor = parsedStyle.anchor;
7030
+ increasedLineWidthForHitTesting = _d.increasedLineWidthForHitTesting, shadowType = _d.shadowType, shadowColor = _d.shadowColor, _e = _d.filter, filter = _e === void 0 ? [] : _e, transformOrigin = _d.transformOrigin;
7031
+ // let anchor = parsedStyle.anchor;
6980
7032
  // <Text> use textAlign & textBaseline instead of anchor
6981
- if (nodeName === exports.Shape.TEXT) {
6982
- delete parsedStyle.anchor;
6983
- }
6984
- else if (nodeName === exports.Shape.MESH) {
6985
- parsedStyle.anchor[2] = 0.5;
6986
- }
6987
- var center = [
6988
- ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
6989
- ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
6990
- (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
6991
- ];
6992
- // const center = vec3.set(
6993
- // tmpVec3b,
6994
- // ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
6995
- // ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
6996
- // (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
6997
- // );
7033
+ // if (nodeName === Shape.TEXT) {
7034
+ // delete parsedStyle.anchor;
7035
+ // } else if (nodeName === Shape.MESH) {
7036
+ // parsedStyle.anchor[2] = 0.5;
7037
+ // }
7038
+ var center = [cx, cy, cz];
6998
7039
  // update geometry's AABB
6999
7040
  geometry_1.contentBounds.update(center, halfExtents);
7000
7041
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
@@ -7027,8 +7068,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7027
7068
  geometry_1.renderBounds.update(center, halfExtents);
7028
7069
  // account for shadow, only support constant value now
7029
7070
  if (shadowColor && shadowType && shadowType !== 'inner') {
7030
- var _h = geometry_1.renderBounds, min = _h.min, max = _h.max;
7031
- var _j = parsedStyle, shadowBlur = _j.shadowBlur, shadowOffsetX = _j.shadowOffsetX, shadowOffsetY = _j.shadowOffsetY;
7071
+ var _f = geometry_1.renderBounds, min = _f.min, max = _f.max;
7072
+ var _g = parsedStyle, shadowBlur = _g.shadowBlur, shadowOffsetX = _g.shadowOffsetX, shadowOffsetY = _g.shadowOffsetY;
7032
7073
  var shadowBlurInPixels = shadowBlur || 0;
7033
7074
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7034
7075
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7065,12 +7106,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7065
7106
  geometry_1.renderBounds.setMinMax(min, max);
7066
7107
  }
7067
7108
  });
7068
- anchor = parsedStyle.anchor;
7069
7109
  // if (nodeName === Shape.RECT) {
7070
7110
  // account for negative width / height of Rect
7071
7111
  // @see https://github.com/antvis/g/issues/957
7072
- var flipY = width < 0;
7073
- var flipX = height < 0;
7112
+ var flipY = hwidth < 0;
7113
+ var flipX = hheight < 0;
7074
7114
  // } else {
7075
7115
  // }
7076
7116
  // set transform origin
@@ -7082,19 +7122,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7082
7122
  (transformOrigin
7083
7123
  ? convertPercentUnit(transformOrigin[1], 1, object)
7084
7124
  : 0);
7085
- usedOriginXValue =
7086
- usedOriginXValue -
7087
- (flipY ? -1 : 1) *
7088
- ((anchor && anchor[0]) || 0) *
7089
- geometry_1.contentBounds.halfExtents[0] *
7090
- 2;
7091
- usedOriginYValue =
7092
- usedOriginYValue -
7093
- (flipX ? -1 : 1) *
7094
- ((anchor && anchor[1]) || 0) *
7095
- geometry_1.contentBounds.halfExtents[1] *
7096
- 2;
7097
- object.setOrigin(usedOriginXValue, usedOriginYValue);
7125
+ object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7098
7126
  // FIXME setOrigin may have already dirtified to root.
7099
7127
  this.runtime.sceneGraphService.dirtifyToRoot(object);
7100
7128
  }
@@ -7112,6 +7140,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7112
7140
  var CSSPropertyAngle = /** @class */ (function () {
7113
7141
  function CSSPropertyAngle() {
7114
7142
  this.parser = parseAngle;
7143
+ this.parserUnmemoize = parseAngleUnmemoize;
7115
7144
  this.parserWithCSSDisabled = null;
7116
7145
  this.mixer = mergeNumbers;
7117
7146
  }
@@ -7186,6 +7215,7 @@ function getFontSize(object) {
7186
7215
  var CSSPropertyLengthOrPercentage = /** @class */ (function () {
7187
7216
  function CSSPropertyLengthOrPercentage() {
7188
7217
  this.parser = parseLengthOrPercentage;
7218
+ this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
7189
7219
  this.parserWithCSSDisabled = null;
7190
7220
  this.mixer = mergeNumbers;
7191
7221
  }
@@ -7314,177 +7344,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
7314
7344
  return CSSPropertyLengthOrPercentage14;
7315
7345
  }());
7316
7346
 
7317
- var tmpMat4 = glMatrix.mat4.create();
7318
- function parsedTransformToMat4(transform, object) {
7319
- var defX = object.parsedStyle.defX || 0;
7320
- var defY = object.parsedStyle.defY || 0;
7321
- // reset transform
7322
- object.resetLocalTransform();
7323
- object.setLocalPosition(defX, defY);
7324
- transform.forEach(function (parsed) {
7325
- var t = parsed.t, d = parsed.d;
7326
- if (t === 'scale') {
7327
- // scale(1) scale(1, 1)
7328
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7329
- object.scaleLocal(newScale[0], newScale[1], 1);
7330
- }
7331
- else if (t === 'scalex') {
7332
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7333
- object.scaleLocal(newScale[0], 1, 1);
7334
- }
7335
- else if (t === 'scaley') {
7336
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7337
- object.scaleLocal(1, newScale[0], 1);
7338
- }
7339
- else if (t === 'scalez') {
7340
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7341
- object.scaleLocal(1, 1, newScale[0]);
7342
- }
7343
- else if (t === 'scale3d') {
7344
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7345
- object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7346
- }
7347
- else if (t === 'translate') {
7348
- var newTranslation = d || [Opx, Opx];
7349
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7350
- }
7351
- else if (t === 'translatex') {
7352
- var newTranslation = d || [Opx];
7353
- object.translateLocal(newTranslation[0].value, 0, 0);
7354
- }
7355
- else if (t === 'translatey') {
7356
- var newTranslation = d || [Opx];
7357
- object.translateLocal(0, newTranslation[0].value, 0);
7358
- }
7359
- else if (t === 'translatez') {
7360
- var newTranslation = d || [Opx];
7361
- object.translateLocal(0, 0, newTranslation[0].value);
7362
- }
7363
- else if (t === 'translate3d') {
7364
- var newTranslation = d || [Opx, Opx, Opx];
7365
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7366
- }
7367
- else if (t === 'rotate') {
7368
- var newAngles = d || [Odeg];
7369
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7370
- }
7371
- else if (t === 'rotatex') {
7372
- var newAngles = d || [Odeg];
7373
- object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7374
- }
7375
- else if (t === 'rotatey') {
7376
- var newAngles = d || [Odeg];
7377
- object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7378
- }
7379
- else if (t === 'rotatez') {
7380
- var newAngles = d || [Odeg];
7381
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7382
- }
7383
- else if (t === 'rotate3d') ;
7384
- else if (t === 'skew') {
7385
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7386
- object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7387
- }
7388
- else if (t === 'skewx') {
7389
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7390
- object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7391
- }
7392
- else if (t === 'skewy') {
7393
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7394
- object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7395
- }
7396
- else if (t === 'matrix') {
7397
- var _a = tslib.__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];
7398
- object.setLocalTransform(glMatrix.mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx + defX, ty + defY, 0, 1));
7399
- }
7400
- else if (t === 'matrix3d') {
7401
- // @ts-ignore
7402
- glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([tmpMat4], tslib.__read(d.map(function (s) { return s.value; })), false));
7403
- tmpMat4[12] += defX;
7404
- tmpMat4[13] += defY;
7405
- object.setLocalTransform(tmpMat4);
7406
- }
7407
- });
7408
- return object.getLocalTransform();
7409
- }
7410
-
7411
- /**
7412
- * local position
7413
- */
7414
- var CSSPropertyLocalPosition = /** @class */ (function (_super) {
7415
- tslib.__extends(CSSPropertyLocalPosition, _super);
7416
- function CSSPropertyLocalPosition() {
7417
- return _super !== null && _super.apply(this, arguments) || this;
7418
- }
7419
- /**
7420
- * update local position
7421
- */
7422
- CSSPropertyLocalPosition.prototype.postProcessor = function (object, attributes) {
7423
- var x;
7424
- var y;
7425
- var z;
7426
- switch (object.nodeName) {
7427
- case exports.Shape.CIRCLE:
7428
- case exports.Shape.ELLIPSE:
7429
- var _a = object.parsedStyle, cx = _a.cx, cy = _a.cy, cz = _a.cz;
7430
- if (!util.isNil(cx)) {
7431
- x = cx;
7432
- }
7433
- if (!util.isNil(cy)) {
7434
- y = cy;
7435
- }
7436
- if (!util.isNil(cz)) {
7437
- z = cz;
7438
- }
7439
- break;
7440
- case exports.Shape.LINE:
7441
- var _b = object.parsedStyle, x1 = _b.x1, x2 = _b.x2, y1 = _b.y1, y2 = _b.y2;
7442
- var minX = Math.min(x1, x2);
7443
- var minY = Math.min(y1, y2);
7444
- x = minX;
7445
- y = minY;
7446
- z = 0;
7447
- break;
7448
- case exports.Shape.RECT:
7449
- case exports.Shape.IMAGE:
7450
- case exports.Shape.GROUP:
7451
- case exports.Shape.HTML:
7452
- case exports.Shape.TEXT:
7453
- case exports.Shape.MESH:
7454
- if (!util.isNil(object.parsedStyle.x)) {
7455
- x = object.parsedStyle.x;
7456
- }
7457
- if (!util.isNil(object.parsedStyle.y)) {
7458
- y = object.parsedStyle.y;
7459
- }
7460
- if (!util.isNil(object.parsedStyle.z)) {
7461
- z = object.parsedStyle.z;
7462
- }
7463
- break;
7464
- }
7465
- if (object.nodeName !== exports.Shape.PATH &&
7466
- object.nodeName !== exports.Shape.POLYLINE &&
7467
- object.nodeName !== exports.Shape.POLYGON) {
7468
- object.parsedStyle.defX = x || 0;
7469
- object.parsedStyle.defY = y || 0;
7470
- }
7471
- var needResetLocalPosition = !util.isNil(x) || !util.isNil(y) || !util.isNil(z);
7472
- // only if `transform` won't be processed later
7473
- if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
7474
- // account for current transform if needed
7475
- var transform = object.parsedStyle.transform;
7476
- if (transform && transform.length) {
7477
- parsedTransformToMat4(transform, object);
7478
- }
7479
- else {
7480
- var _c = tslib.__read(object.getLocalPosition(), 3), ox = _c[0], oy = _c[1], oz = _c[2];
7481
- object.setLocalPosition(util.isNil(x) ? ox : x, util.isNil(y) ? oy : y, util.isNil(z) ? oz : z);
7482
- }
7483
- }
7484
- };
7485
- return CSSPropertyLocalPosition;
7486
- }(CSSPropertyLengthOrPercentage));
7487
-
7488
7347
  var CSSPropertyMarker = /** @class */ (function () {
7489
7348
  function CSSPropertyMarker() {
7490
7349
  }
@@ -7507,6 +7366,7 @@ var CSSPropertyNumber = /** @class */ (function () {
7507
7366
  function CSSPropertyNumber() {
7508
7367
  this.mixer = mergeNumbers;
7509
7368
  this.parser = parseNumber;
7369
+ this.parserUnmemoize = parseNumberUnmemoize;
7510
7370
  this.parserWithCSSDisabled = null;
7511
7371
  }
7512
7372
  CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
@@ -7518,6 +7378,7 @@ var CSSPropertyNumber = /** @class */ (function () {
7518
7378
  var CSSPropertyOffsetDistance = /** @class */ (function () {
7519
7379
  function CSSPropertyOffsetDistance() {
7520
7380
  this.parser = parseNumber;
7381
+ this.parserUnmemoize = parseNumberUnmemoize;
7521
7382
  this.parserWithCSSDisabled = null;
7522
7383
  this.mixer = clampedMergeNumbers(0, 1);
7523
7384
  }
@@ -7536,8 +7397,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7536
7397
  // set position in world space
7537
7398
  var point = offsetPath.getPoint(offsetDistance);
7538
7399
  if (point) {
7539
- object.parsedStyle.defX = point.x;
7540
- object.parsedStyle.defY = point.y;
7541
7400
  object.setLocalPosition(point.x, point.y);
7542
7401
  }
7543
7402
  }
@@ -7551,6 +7410,7 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7551
7410
  var CSSPropertyOpacity = /** @class */ (function () {
7552
7411
  function CSSPropertyOpacity() {
7553
7412
  this.parser = parseNumber;
7413
+ this.parserUnmemoize = parseNumberUnmemoize;
7554
7414
  this.parserWithCSSDisabled = null;
7555
7415
  this.mixer = clampedMergeNumbers(0, 1);
7556
7416
  }
@@ -7585,18 +7445,6 @@ var CSSPropertyPath = /** @class */ (function () {
7585
7445
  }
7586
7446
  return parsed;
7587
7447
  };
7588
- /**
7589
- * update local position
7590
- */
7591
- CSSPropertyPath.prototype.postProcessor = function (object, attributes) {
7592
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
7593
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
7594
- if (object.nodeName === exports.Shape.PATH &&
7595
- attributes.indexOf('transform') === -1) {
7596
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
7597
- object.setLocalPosition(defX, defY);
7598
- }
7599
- };
7600
7448
  return CSSPropertyPath;
7601
7449
  }());
7602
7450
 
@@ -7605,17 +7453,6 @@ var CSSPropertyPoints = /** @class */ (function () {
7605
7453
  this.parser = parsePoints;
7606
7454
  this.mixer = mergePoints;
7607
7455
  }
7608
- /**
7609
- * update local position
7610
- */
7611
- CSSPropertyPoints.prototype.postProcessor = function (object, attributes) {
7612
- if ((object.nodeName === exports.Shape.POLYGON ||
7613
- object.nodeName === exports.Shape.POLYLINE) &&
7614
- attributes.indexOf('transform') === -1) {
7615
- var _a = object.parsedStyle, defX = _a.defX, defY = _a.defY;
7616
- object.setLocalPosition(defX, defY);
7617
- }
7618
- };
7619
7456
  return CSSPropertyPoints;
7620
7457
  }());
7621
7458
 
@@ -8024,6 +7861,95 @@ function toFontString(attributes) {
8024
7861
  return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
8025
7862
  }
8026
7863
 
7864
+ var tmpMat4 = glMatrix.mat4.create();
7865
+ function parsedTransformToMat4(transform, object) {
7866
+ // reset transform
7867
+ object.resetLocalTransform();
7868
+ transform.forEach(function (parsed) {
7869
+ var t = parsed.t, d = parsed.d;
7870
+ if (t === 'scale') {
7871
+ // scale(1) scale(1, 1)
7872
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7873
+ object.scaleLocal(newScale[0], newScale[1], 1);
7874
+ }
7875
+ else if (t === 'scalex') {
7876
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7877
+ object.scaleLocal(newScale[0], 1, 1);
7878
+ }
7879
+ else if (t === 'scaley') {
7880
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7881
+ object.scaleLocal(1, newScale[0], 1);
7882
+ }
7883
+ else if (t === 'scalez') {
7884
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7885
+ object.scaleLocal(1, 1, newScale[0]);
7886
+ }
7887
+ else if (t === 'scale3d') {
7888
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7889
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7890
+ }
7891
+ else if (t === 'translate') {
7892
+ var newTranslation = d || [Opx, Opx];
7893
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7894
+ }
7895
+ else if (t === 'translatex') {
7896
+ var newTranslation = d || [Opx];
7897
+ object.translateLocal(newTranslation[0].value, 0, 0);
7898
+ }
7899
+ else if (t === 'translatey') {
7900
+ var newTranslation = d || [Opx];
7901
+ object.translateLocal(0, newTranslation[0].value, 0);
7902
+ }
7903
+ else if (t === 'translatez') {
7904
+ var newTranslation = d || [Opx];
7905
+ object.translateLocal(0, 0, newTranslation[0].value);
7906
+ }
7907
+ else if (t === 'translate3d') {
7908
+ var newTranslation = d || [Opx, Opx, Opx];
7909
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7910
+ }
7911
+ else if (t === 'rotate') {
7912
+ var newAngles = d || [Odeg];
7913
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7914
+ }
7915
+ else if (t === 'rotatex') {
7916
+ var newAngles = d || [Odeg];
7917
+ object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7918
+ }
7919
+ else if (t === 'rotatey') {
7920
+ var newAngles = d || [Odeg];
7921
+ object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7922
+ }
7923
+ else if (t === 'rotatez') {
7924
+ var newAngles = d || [Odeg];
7925
+ object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7926
+ }
7927
+ else if (t === 'rotate3d') ;
7928
+ else if (t === 'skew') {
7929
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7930
+ object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7931
+ }
7932
+ else if (t === 'skewx') {
7933
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7934
+ object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7935
+ }
7936
+ else if (t === 'skewy') {
7937
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7938
+ object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7939
+ }
7940
+ else if (t === 'matrix') {
7941
+ var _a = tslib.__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];
7942
+ object.setLocalTransform(glMatrix.mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1));
7943
+ }
7944
+ else if (t === 'matrix3d') {
7945
+ // @ts-ignore
7946
+ glMatrix.mat4.set.apply(glMatrix.mat4, tslib.__spreadArray([tmpMat4], tslib.__read(d.map(function (s) { return s.value; })), false));
7947
+ object.setLocalTransform(tmpMat4);
7948
+ }
7949
+ });
7950
+ return object.getLocalTransform();
7951
+ }
7952
+
8027
7953
  /**
8028
7954
  * @see /zh/docs/api/animation#支持变换的属性
8029
7955
  *
@@ -8057,7 +7983,8 @@ function toFontString(attributes) {
8057
7983
  var CSSPropertyTransform = /** @class */ (function () {
8058
7984
  function CSSPropertyTransform() {
8059
7985
  this.parser = parseTransform;
8060
- this.parserWithCSSDisabled = parseTransform;
7986
+ this.parserUnmemoize = parseTransformUnmemoize;
7987
+ this.parserWithCSSDisabled = parseTransformUnmemoize;
8061
7988
  this.mixer = mergeTransforms;
8062
7989
  }
8063
7990
  CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
@@ -8082,6 +8009,7 @@ var CSSPropertyTransform = /** @class */ (function () {
8082
8009
  var CSSPropertyTransformOrigin = /** @class */ (function () {
8083
8010
  function CSSPropertyTransformOrigin() {
8084
8011
  this.parser = parseTransformOrigin;
8012
+ this.parserUnmemoize = parseTransformOriginUnmemoize;
8085
8013
  // calculator(
8086
8014
  // name: string,
8087
8015
  // oldParsed: [CSSUnitValue, CSSUnitValue],
@@ -8099,6 +8027,7 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
8099
8027
  var CSSPropertyZIndex = /** @class */ (function () {
8100
8028
  function CSSPropertyZIndex() {
8101
8029
  this.parser = parseNumber;
8030
+ this.parserUnmemoize = parseNumberUnmemoize;
8102
8031
  }
8103
8032
  CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
8104
8033
  return computed.value;
@@ -8125,12 +8054,12 @@ var CircleUpdater = /** @class */ (function () {
8125
8054
  function CircleUpdater() {
8126
8055
  }
8127
8056
  CircleUpdater.prototype.update = function (parsedStyle, object) {
8128
- var r = parsedStyle.r;
8129
- var width = r * 2;
8130
- var height = r * 2;
8057
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r;
8131
8058
  return {
8132
- width: width,
8133
- height: height,
8059
+ cx: cx,
8060
+ cy: cy,
8061
+ hwidth: r,
8062
+ hheight: r,
8134
8063
  };
8135
8064
  };
8136
8065
  return CircleUpdater;
@@ -8140,12 +8069,12 @@ var EllipseUpdater = /** @class */ (function () {
8140
8069
  function EllipseUpdater() {
8141
8070
  }
8142
8071
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
8143
- var rx = parsedStyle.rx, ry = parsedStyle.ry;
8144
- var width = rx * 2;
8145
- var height = ry * 2;
8072
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry;
8146
8073
  return {
8147
- width: width,
8148
- height: height,
8074
+ cx: cx,
8075
+ cy: cy,
8076
+ hwidth: rx,
8077
+ hheight: ry,
8149
8078
  };
8150
8079
  };
8151
8080
  return EllipseUpdater;
@@ -8162,9 +8091,13 @@ var LineUpdater = /** @class */ (function () {
8162
8091
  var maxY = Math.max(y1, y2);
8163
8092
  var width = maxX - minX;
8164
8093
  var height = maxY - minY;
8094
+ var hwidth = width / 2;
8095
+ var hheight = height / 2;
8165
8096
  return {
8166
- width: width,
8167
- height: height,
8097
+ cx: minX + hwidth,
8098
+ cy: minY + hheight,
8099
+ hwidth: hwidth,
8100
+ hheight: hheight,
8168
8101
  };
8169
8102
  };
8170
8103
  return LineUpdater;
@@ -8175,10 +8108,14 @@ var PathUpdater = /** @class */ (function () {
8175
8108
  }
8176
8109
  PathUpdater.prototype.update = function (parsedStyle) {
8177
8110
  var path = parsedStyle.path;
8178
- var _a = path.rect, width = _a.width, height = _a.height;
8111
+ var _a = path.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
8112
+ var hwidth = width / 2;
8113
+ var hheight = height / 2;
8179
8114
  return {
8180
- width: width,
8181
- height: height,
8115
+ cx: x + hwidth,
8116
+ cy: y + hheight,
8117
+ hwidth: hwidth,
8118
+ hheight: hheight,
8182
8119
  };
8183
8120
  };
8184
8121
  return PathUpdater;
@@ -8197,14 +8134,20 @@ var PolylineUpdater = /** @class */ (function () {
8197
8134
  var maxY = Math.max.apply(Math, tslib.__spreadArray([], tslib.__read(points.map(function (point) { return point[1]; })), false));
8198
8135
  var width = maxX - minX;
8199
8136
  var height = maxY - minY;
8137
+ var hwidth = width / 2;
8138
+ var hheight = height / 2;
8200
8139
  return {
8201
- width: width,
8202
- height: height,
8140
+ cx: minX + hwidth,
8141
+ cy: minY + hheight,
8142
+ hwidth: hwidth,
8143
+ hheight: hheight,
8203
8144
  };
8204
8145
  }
8205
8146
  return {
8206
- width: 0,
8207
- height: 0,
8147
+ cx: 0,
8148
+ cy: 0,
8149
+ hwidth: 0,
8150
+ hheight: 0,
8208
8151
  };
8209
8152
  };
8210
8153
  return PolylineUpdater;
@@ -8214,7 +8157,7 @@ var RectUpdater = /** @class */ (function () {
8214
8157
  function RectUpdater() {
8215
8158
  }
8216
8159
  RectUpdater.prototype.update = function (parsedStyle, object) {
8217
- var img = parsedStyle.img, _a = parsedStyle.width, width = _a === void 0 ? 0 : _a, _b = parsedStyle.height, height = _b === void 0 ? 0 : _b;
8160
+ 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;
8218
8161
  var contentWidth = width;
8219
8162
  var contentHeight = height;
8220
8163
  // resize with HTMLImageElement's size
@@ -8229,8 +8172,10 @@ var RectUpdater = /** @class */ (function () {
8229
8172
  }
8230
8173
  }
8231
8174
  return {
8232
- width: contentWidth,
8233
- height: contentHeight,
8175
+ cx: x + contentWidth / 2,
8176
+ cy: y + contentHeight / 2,
8177
+ hwidth: contentWidth / 2,
8178
+ hheight: contentHeight / 2,
8234
8179
  };
8235
8180
  };
8236
8181
  return RectUpdater;
@@ -8253,7 +8198,7 @@ var TextUpdater = /** @class */ (function () {
8253
8198
  };
8254
8199
  TextUpdater.prototype.update = function (parsedStyle, object) {
8255
8200
  var _a, _b;
8256
- var text = parsedStyle.text, textAlign = parsedStyle.textAlign, lineWidth = parsedStyle.lineWidth, textBaseline = parsedStyle.textBaseline, dx = parsedStyle.dx, dy = parsedStyle.dy;
8201
+ 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;
8257
8202
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8258
8203
  parsedStyle.metrics = {
8259
8204
  font: '',
@@ -8271,47 +8216,42 @@ var TextUpdater = /** @class */ (function () {
8271
8216
  lineMetrics: [],
8272
8217
  };
8273
8218
  return {
8274
- width: 0,
8275
- height: 0,
8276
- x: 0,
8277
- y: 0,
8278
- offsetX: 0,
8279
- offsetY: 0,
8219
+ hwidth: 0,
8220
+ hheight: 0,
8221
+ cx: 0,
8222
+ cy: 0,
8280
8223
  };
8281
8224
  }
8282
8225
  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;
8283
8226
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8284
8227
  parsedStyle.metrics = metrics;
8285
8228
  var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
8286
- // anchor is left-top by default
8287
- var halfExtents = [width / 2, height / 2, 0];
8229
+ var hwidth = width / 2;
8230
+ var hheight = height / 2;
8288
8231
  // default 'left'
8289
- var anchor = [0, 1];
8290
- var lineXOffset = 0;
8232
+ var lineXOffset = x + hwidth;
8291
8233
  if (textAlign === 'center' || textAlign === 'middle') {
8292
- lineXOffset = lineWidth / 2;
8293
- anchor = [0.5, 1];
8234
+ lineXOffset += lineWidth / 2 - hwidth;
8294
8235
  }
8295
8236
  else if (textAlign === 'right' || textAlign === 'end') {
8296
- lineXOffset = lineWidth;
8297
- anchor = [1, 1];
8237
+ lineXOffset += lineWidth - hwidth * 2;
8298
8238
  }
8299
- var lineYOffset = 0;
8239
+ var lineYOffset = y - hheight;
8300
8240
  if (textBaseline === 'middle') {
8301
8241
  // eslint-disable-next-line prefer-destructuring
8302
- lineYOffset = halfExtents[1];
8242
+ lineYOffset += hheight;
8303
8243
  }
8304
8244
  else if (textBaseline === 'top' || textBaseline === 'hanging') {
8305
- lineYOffset = halfExtents[1] * 2;
8245
+ lineYOffset += hheight * 2;
8306
8246
  }
8307
8247
  else if (textBaseline === 'alphabetic') {
8308
8248
  // prevent calling getImageData for ascent metrics
8309
- lineYOffset = this.globalRuntime.enableCSSParsing
8249
+ lineYOffset += this.globalRuntime.enableCSSParsing
8310
8250
  ? lineHeight - fontProperties.ascent
8311
8251
  : 0;
8312
8252
  }
8313
8253
  else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
8314
- lineYOffset = 0;
8254
+ lineYOffset += 0;
8315
8255
  }
8316
8256
  // TODO: ideographic & bottom
8317
8257
  if (dx) {
@@ -8320,13 +8260,11 @@ var TextUpdater = /** @class */ (function () {
8320
8260
  if (dy) {
8321
8261
  lineYOffset += dy;
8322
8262
  }
8323
- // update anchor
8324
- parsedStyle.anchor = [anchor[0], anchor[1], 0];
8325
8263
  return {
8326
- width: halfExtents[0] * 2,
8327
- height: halfExtents[1] * 2,
8328
- offsetX: lineXOffset,
8329
- offsetY: lineYOffset,
8264
+ cx: lineXOffset,
8265
+ cy: lineYOffset,
8266
+ hwidth: hwidth,
8267
+ hheight: hheight,
8330
8268
  };
8331
8269
  };
8332
8270
  return TextUpdater;
@@ -11601,7 +11539,7 @@ var CSSPropertySyntaxFactory = (function () {
11601
11539
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE] = length,
11602
11540
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE_12] = new CSSPropertyLengthOrPercentage12(),
11603
11541
  _a[exports.PropertySyntax.LENGTH_PERCENTAGE_14] = new CSSPropertyLengthOrPercentage14(),
11604
- _a[exports.PropertySyntax.COORDINATE] = new CSSPropertyLocalPosition(),
11542
+ _a[exports.PropertySyntax.COORDINATE] = new CSSPropertyLengthOrPercentage(),
11605
11543
  _a[exports.PropertySyntax.OFFSET_DISTANCE] = new CSSPropertyOffsetDistance(),
11606
11544
  _a[exports.PropertySyntax.OPACITY_VALUE] = new CSSPropertyOpacity(),
11607
11545
  _a[exports.PropertySyntax.PATH] = new CSSPropertyPath(),
@@ -11897,8 +11835,11 @@ var Element = /** @class */ (function (_super) {
11897
11835
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11898
11836
  this.ownerDocument.defaultView.mountChildren(child);
11899
11837
  }
11900
- insertedEvent.relatedNode = this;
11901
- child.dispatchEvent(insertedEvent);
11838
+ // @ts-ignore
11839
+ if (child.isMutationObserved) {
11840
+ insertedEvent.relatedNode = this;
11841
+ child.dispatchEvent(insertedEvent);
11842
+ }
11902
11843
  return child;
11903
11844
  };
11904
11845
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12325,7 +12266,6 @@ var DATASET_PREFIX = 'data-';
12325
12266
  var DisplayObject = /** @class */ (function (_super) {
12326
12267
  tslib.__extends(DisplayObject, _super);
12327
12268
  function DisplayObject(config) {
12328
- var _a;
12329
12269
  var _this = _super.call(this) || this;
12330
12270
  _this.isCustomElement = false;
12331
12271
  _this.isMutationObserved = false;
@@ -12344,7 +12284,7 @@ var DisplayObject = /** @class */ (function (_super) {
12344
12284
  // eg. group.get('name')
12345
12285
  _this.config = config;
12346
12286
  // compatible with G 3.0
12347
- _this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive;
12287
+ // this.config.interactive = this.config.capture ?? this.config.interactive;
12348
12288
  // init scene graph node
12349
12289
  _this.id = _this.config.id || '';
12350
12290
  _this.name = _this.config.name || '';
@@ -12352,23 +12292,23 @@ var DisplayObject = /** @class */ (function (_super) {
12352
12292
  _this.className = _this.config.className || _this.config.class;
12353
12293
  }
12354
12294
  _this.nodeName = _this.config.type || exports.Shape.GROUP;
12355
- // compatible with G 3.0
12356
- _this.config.style =
12357
- _this.config.style || _this.config.attrs || {};
12358
- Object.assign(_this.config.style, _this.config.attrs);
12359
- // this.config.style = {
12360
- // // ...DEFAULT_STYLE_PROPS,
12361
- // ...this.config.style,
12362
- // ...this.config.attrs,
12363
- // };
12364
- if (_this.config.visible != null) {
12365
- _this.config.style.visibility =
12366
- _this.config.visible === false ? 'hidden' : 'visible';
12367
- }
12368
- if (_this.config.interactive != null) {
12369
- _this.config.style.pointerEvents =
12370
- _this.config.interactive === false ? 'none' : 'auto';
12371
- }
12295
+ // // compatible with G 3.0
12296
+ // this.config.style =
12297
+ // this.config.style || this.config.attrs || ({} as StyleProps);
12298
+ // // Object.assign(this.config.style, this.config.attrs);
12299
+ // // this.config.style = {
12300
+ // // // ...DEFAULT_STYLE_PROPS,
12301
+ // // ...this.config.style,
12302
+ // // ...this.config.attrs,
12303
+ // // };
12304
+ // if (this.config.visible != null) {
12305
+ // this.config.style.visibility =
12306
+ // this.config.visible === false ? 'hidden' : 'visible';
12307
+ // }
12308
+ // if (this.config.interactive != null) {
12309
+ // this.config.style.pointerEvents =
12310
+ // this.config.interactive === false ? 'none' : 'auto';
12311
+ // }
12372
12312
  // merge parsed value
12373
12313
  Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12374
12314
  ? DEFAULT_PARSED_STYLE_PROPS
@@ -12507,15 +12447,16 @@ var DisplayObject = /** @class */ (function (_super) {
12507
12447
  // redraw at next frame
12508
12448
  renderable.dirty = true;
12509
12449
  };
12510
- DisplayObject.prototype.setAttribute = function (name, value, force) {
12450
+ DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
12511
12451
  if (force === void 0) { force = false; }
12452
+ if (memoize === void 0) { memoize = true; }
12512
12453
  var attributeName = formatAttributeName(name);
12513
12454
  // ignore undefined value
12514
12455
  if (util.isUndefined(value)) {
12515
12456
  return;
12516
12457
  }
12517
12458
  if (force || value !== this.attributes[attributeName]) {
12518
- this.internalSetAttribute(attributeName, value);
12459
+ this.internalSetAttribute(attributeName, value, { memoize: memoize });
12519
12460
  _super.prototype.setAttribute.call(this, attributeName, value);
12520
12461
  }
12521
12462
  };
@@ -13119,12 +13060,16 @@ var CSS = {
13119
13060
 
13120
13061
  var Circle = /** @class */ (function (_super) {
13121
13062
  tslib.__extends(Circle, _super);
13063
+ // constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
13064
+ // super(options);
13065
+ // this.nodeName = Shape.CIRCLE;
13066
+ // }
13122
13067
  function Circle(_a) {
13123
13068
  if (_a === void 0) { _a = {}; }
13124
13069
  var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13125
13070
  return _super.call(this, tslib.__assign({ type: exports.Shape.CIRCLE, style: runtime.enableCSSParsing
13126
13071
  ? tslib.__assign({ cx: '', cy: '', r: '' }, style) : tslib.__assign({}, style), initialParsedStyle: {
13127
- anchor: [0.5, 0.5],
13072
+ // anchor: [0.5, 0.5],
13128
13073
  transformOrigin: runtime.enableCSSParsing
13129
13074
  ? null
13130
13075
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13162,7 +13107,7 @@ var Ellipse = /** @class */ (function (_super) {
13162
13107
  var style = _a.style, rest = tslib.__rest(_a, ["style"]);
13163
13108
  return _super.call(this, tslib.__assign({ type: exports.Shape.ELLIPSE, style: runtime.enableCSSParsing
13164
13109
  ? tslib.__assign({ cx: '', cy: '', rx: '', ry: '' }, style) : tslib.__assign({}, style), initialParsedStyle: {
13165
- anchor: [0.5, 0.5],
13110
+ // anchor: [0.5, 0.5],
13166
13111
  transformOrigin: runtime.enableCSSParsing
13167
13112
  ? null
13168
13113
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13332,7 +13277,7 @@ var Line = /** @class */ (function (_super) {
13332
13277
  }
13333
13278
  };
13334
13279
  Line.prototype.transformMarker = function (isStart) {
13335
- 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;
13280
+ 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;
13336
13281
  var marker = isStart ? markerStart : markerEnd;
13337
13282
  if (!marker || !isDisplayObject(marker)) {
13338
13283
  return;
@@ -13345,16 +13290,16 @@ var Line = /** @class */ (function (_super) {
13345
13290
  var offset;
13346
13291
  var originalAngle;
13347
13292
  if (isStart) {
13348
- ox = x1 - defX;
13349
- oy = y1 - defY;
13293
+ ox = x1;
13294
+ oy = y1;
13350
13295
  x = x2 - x1;
13351
13296
  y = y2 - y1;
13352
13297
  offset = markerStartOffset || 0;
13353
13298
  originalAngle = this.markerStartAngle;
13354
13299
  }
13355
13300
  else {
13356
- ox = x2 - defX;
13357
- oy = y2 - defY;
13301
+ ox = x2;
13302
+ oy = y2;
13358
13303
  x = x1 - x2;
13359
13304
  y = y1 - y2;
13360
13305
  offset = markerEndOffset || 0;
@@ -13368,9 +13313,9 @@ var Line = /** @class */ (function (_super) {
13368
13313
  Line.prototype.getPoint = function (ratio, inWorldSpace) {
13369
13314
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13370
13315
  // TODO: account for z1/z2 in 3D line
13371
- var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2, defX = _a.defX, defY = _a.defY;
13316
+ var _a = this.parsedStyle, x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
13372
13317
  var _b = gMath.linePointAt(x1, y1, x2, y2, ratio), x = _b.x, y = _b.y;
13373
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13318
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13374
13319
  // apply local transformation
13375
13320
  return new Point(transformed[0], transformed[1]);
13376
13321
  };
@@ -13461,7 +13406,7 @@ var Path = /** @class */ (function (_super) {
13461
13406
  }
13462
13407
  };
13463
13408
  Path.prototype.transformMarker = function (isStart) {
13464
- var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, defX = _a.defX, defY = _a.defY;
13409
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset;
13465
13410
  var marker = isStart ? markerStart : markerEnd;
13466
13411
  if (!marker || !isDisplayObject(marker)) {
13467
13412
  return;
@@ -13475,8 +13420,8 @@ var Path = /** @class */ (function (_super) {
13475
13420
  var originalAngle;
13476
13421
  if (isStart) {
13477
13422
  var _b = tslib.__read(this.getStartTangent(), 2), p1 = _b[0], p2 = _b[1];
13478
- ox = p2[0] - defX;
13479
- oy = p2[1] - defY;
13423
+ ox = p2[0];
13424
+ oy = p2[1];
13480
13425
  x = p1[0] - p2[0];
13481
13426
  y = p1[1] - p2[1];
13482
13427
  offset = markerStartOffset || 0;
@@ -13484,8 +13429,8 @@ var Path = /** @class */ (function (_super) {
13484
13429
  }
13485
13430
  else {
13486
13431
  var _c = tslib.__read(this.getEndTangent(), 2), p1 = _c[0], p2 = _c[1];
13487
- ox = p2[0] - defX;
13488
- oy = p2[1] - defY;
13432
+ ox = p2[0];
13433
+ oy = p2[1];
13489
13434
  x = p1[0] - p2[0];
13490
13435
  y = p1[1] - p2[1];
13491
13436
  offset = markerEndOffset || 0;
@@ -13497,18 +13442,18 @@ var Path = /** @class */ (function (_super) {
13497
13442
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13498
13443
  };
13499
13444
  Path.prototype.placeMarkerMid = function (marker) {
13500
- var _a = this.parsedStyle, segments = _a.path.segments, defX = _a.defX, defY = _a.defY;
13445
+ var segments = this.parsedStyle.path.segments;
13501
13446
  // clear all existed markers
13502
13447
  this.markerMidList.forEach(function (marker) {
13503
13448
  marker.remove();
13504
13449
  });
13505
13450
  if (marker && isDisplayObject(marker)) {
13506
13451
  for (var i = 1; i < segments.length - 1; i++) {
13507
- var _b = tslib.__read(segments[i].currentPoint, 2), ox = _b[0], oy = _b[1];
13452
+ var _a = tslib.__read(segments[i].currentPoint, 2), ox = _a[0], oy = _a[1];
13508
13453
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13509
13454
  this.markerMidList.push(cloned);
13510
13455
  this.appendChild(cloned);
13511
- cloned.setLocalPosition(ox - defX, oy - defY);
13456
+ cloned.setLocalPosition(ox, oy);
13512
13457
  // TODO: orient of marker
13513
13458
  }
13514
13459
  }
@@ -13526,9 +13471,9 @@ var Path = /** @class */ (function (_super) {
13526
13471
  */
13527
13472
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13528
13473
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13529
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, absolutePath = _a.path.absolutePath;
13530
- var _b = util.getPointAtLength(absolutePath, distance), x = _b.x, y = _b.y;
13531
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13474
+ var absolutePath = this.parsedStyle.path.absolutePath;
13475
+ var _a = util.getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
13476
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13532
13477
  // apply local transformation
13533
13478
  return new Point(transformed[0], transformed[1]);
13534
13479
  };
@@ -13667,7 +13612,7 @@ var Polygon = /** @class */ (function (_super) {
13667
13612
  }
13668
13613
  };
13669
13614
  Polygon.prototype.transformMarker = function (isStart) {
13670
- 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;
13615
+ var _a = this.parsedStyle, markerStart = _a.markerStart, markerEnd = _a.markerEnd, markerStartOffset = _a.markerStartOffset, markerEndOffset = _a.markerEndOffset, P = _a.points;
13671
13616
  var points = (P || {}).points;
13672
13617
  var marker = isStart ? markerStart : markerEnd;
13673
13618
  if (!marker || !isDisplayObject(marker) || !points) {
@@ -13680,8 +13625,8 @@ var Polygon = /** @class */ (function (_super) {
13680
13625
  var oy;
13681
13626
  var offset;
13682
13627
  var originalAngle;
13683
- ox = points[0][0] - defX;
13684
- oy = points[0][1] - defY;
13628
+ ox = points[0][0];
13629
+ oy = points[0][1];
13685
13630
  if (isStart) {
13686
13631
  x = points[1][0] - points[0][0];
13687
13632
  y = points[1][1] - points[0][1];
@@ -13691,8 +13636,8 @@ var Polygon = /** @class */ (function (_super) {
13691
13636
  else {
13692
13637
  var length_1 = points.length;
13693
13638
  if (!this.parsedStyle.isClosed) {
13694
- ox = points[length_1 - 1][0] - defX;
13695
- oy = points[length_1 - 1][1] - defY;
13639
+ ox = points[length_1 - 1][0];
13640
+ oy = points[length_1 - 1][1];
13696
13641
  x = points[length_1 - 2][0] - points[length_1 - 1][0];
13697
13642
  y = points[length_1 - 2][1] - points[length_1 - 1][1];
13698
13643
  }
@@ -13709,7 +13654,7 @@ var Polygon = /** @class */ (function (_super) {
13709
13654
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13710
13655
  };
13711
13656
  Polygon.prototype.placeMarkerMid = function (marker) {
13712
- var _a = this.parsedStyle, P = _a.points, defX = _a.defX, defY = _a.defY;
13657
+ var P = this.parsedStyle.points;
13713
13658
  var points = (P || {}).points;
13714
13659
  // clear all existed markers
13715
13660
  this.markerMidList.forEach(function (marker) {
@@ -13718,8 +13663,8 @@ var Polygon = /** @class */ (function (_super) {
13718
13663
  this.markerMidList = [];
13719
13664
  if (marker && isDisplayObject(marker) && points) {
13720
13665
  for (var i = 1; i < (this.parsedStyle.isClosed ? points.length : points.length - 1); i++) {
13721
- var ox = points[i][0] - defX;
13722
- var oy = points[i][1] - defY;
13666
+ var ox = points[i][0];
13667
+ var oy = points[i][1];
13723
13668
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13724
13669
  this.markerMidList.push(cloned);
13725
13670
  this.appendChild(cloned);
@@ -13761,7 +13706,7 @@ var Polyline = /** @class */ (function (_super) {
13761
13706
  };
13762
13707
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13763
13708
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13764
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, _b = _a.points, points = _b.points, segments = _b.segments;
13709
+ var _a = this.parsedStyle.points, points = _a.points, segments = _a.segments;
13765
13710
  var subt = 0;
13766
13711
  var index = 0;
13767
13712
  segments.forEach(function (v, i) {
@@ -13770,8 +13715,8 @@ var Polyline = /** @class */ (function (_super) {
13770
13715
  index = i;
13771
13716
  }
13772
13717
  });
13773
- var _c = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _c.x, y = _c.y;
13774
- var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x - defX, y - defY, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13718
+ var _b = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _b.x, y = _b.y;
13719
+ var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13775
13720
  // apply local transformation
13776
13721
  return new Point(transformed[0], transformed[1]);
13777
13722
  };