@antv/g-lite 1.2.21 → 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.
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;
@@ -4791,11 +4791,10 @@ function getArcParams(startPoint, params) {
4791
4791
  };
4792
4792
  }
4793
4793
  function commandsToPathString(commands, object, transform) {
4794
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
4795
4794
  return commands.reduce(function (prev, cur) {
4796
4795
  var path = '';
4797
4796
  if (cur[0] === 'M' || cur[0] === 'L') {
4798
- var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4797
+ var p = vec3.fromValues(cur[1], cur[2], 0);
4799
4798
  if (transform) {
4800
4799
  vec3.transformMat4(p, p, transform);
4801
4800
  }
@@ -4805,9 +4804,9 @@ function commandsToPathString(commands, object, transform) {
4805
4804
  path = cur[0];
4806
4805
  }
4807
4806
  else if (cur[0] === 'C') {
4808
- var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4809
- var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
4810
- 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);
4811
4810
  if (transform) {
4812
4811
  vec3.transformMat4(p1, p1, transform);
4813
4812
  vec3.transformMat4(p2, p2, transform);
@@ -4816,15 +4815,15 @@ function commandsToPathString(commands, object, transform) {
4816
4815
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
4817
4816
  }
4818
4817
  else if (cur[0] === 'A') {
4819
- var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
4818
+ var c = vec3.fromValues(cur[6], cur[7], 0);
4820
4819
  if (transform) {
4821
4820
  vec3.transformMat4(c, c, transform);
4822
4821
  }
4823
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]);
4824
4823
  }
4825
4824
  else if (cur[0] === 'Q') {
4826
- var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
4827
- 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);
4828
4827
  if (transform) {
4829
4828
  vec3.transformMat4(p1, p1, transform);
4830
4829
  vec3.transformMat4(p2, p2, transform);
@@ -4945,7 +4944,7 @@ function convertToPath(object, transform) {
4945
4944
  return commandsToPathString(commands, object, transform);
4946
4945
  }
4947
4946
  }
4948
- function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4947
+ function translatePathToString(absolutePath, startOffsetX, startOffsetY, endOffsetX, endOffsetY) {
4949
4948
  if (startOffsetX === void 0) { startOffsetX = 0; }
4950
4949
  if (startOffsetY === void 0) { startOffsetY = 0; }
4951
4950
  if (endOffsetX === void 0) { endOffsetX = 0; }
@@ -4964,27 +4963,27 @@ function translatePathToString(absolutePath, defX, defY, startOffsetX, startOffs
4964
4963
  case 'M':
4965
4964
  // Use start marker offset
4966
4965
  if (useStartOffset) {
4967
- 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]);
4968
4967
  }
4969
4968
  else {
4970
- return "M ".concat(params[1] - defX, ",").concat(params[2] - defY);
4969
+ return "M ".concat(params[1], ",").concat(params[2]);
4971
4970
  }
4972
4971
  case 'L':
4973
- 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));
4974
4973
  case 'Q':
4975
- 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]) +
4976
4975
  (useEndOffset
4977
- ? " L ".concat(params[3] - defX + endOffsetX, ",").concat(params[4] - defY + endOffsetY)
4976
+ ? " L ".concat(params[3] + endOffsetX, ",").concat(params[4] + endOffsetY)
4978
4977
  : ''));
4979
4978
  case 'C':
4980
- 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]) +
4981
4980
  (useEndOffset
4982
- ? " L ".concat(params[5] - defX + endOffsetX, ",").concat(params[6] - defY + endOffsetY)
4981
+ ? " L ".concat(params[5] + endOffsetX, ",").concat(params[6] + endOffsetY)
4983
4982
  : ''));
4984
4983
  case 'A':
4985
- 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]) +
4986
4985
  (useEndOffset
4987
- ? " L ".concat(params[6] - defX + endOffsetX, ",").concat(params[7] - defY + endOffsetY)
4986
+ ? " L ".concat(params[6] + endOffsetX, ",").concat(params[7] + endOffsetY)
4988
4987
  : ''));
4989
4988
  case 'Z':
4990
4989
  return 'Z';
@@ -5114,12 +5113,8 @@ function parsePoints(pointsOrStr, object) {
5114
5113
  segments.push(segmentT);
5115
5114
  }
5116
5115
  });
5117
- var minX = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[0]; })), false));
5118
- var minY = Math.min.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[1]; })), false));
5119
- if (object) {
5120
- object.parsedStyle.defX = minX;
5121
- object.parsedStyle.defY = minY;
5122
- }
5116
+ // const minX = Math.min(...points.map((point) => point[0]));
5117
+ // const minY = Math.min(...points.map((point) => point[1]));
5123
5118
  return {
5124
5119
  points: points,
5125
5120
  totalLength: totalLength,
@@ -6249,9 +6244,9 @@ var BUILT_IN_PROPERTIES = [
6249
6244
  n: 'anchor',
6250
6245
  p: 99,
6251
6246
  d: function (nodeName) {
6252
- if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6253
- return '0.5 0.5';
6254
- }
6247
+ // if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
6248
+ // return '0.5 0.5';
6249
+ // }
6255
6250
  return '0 0';
6256
6251
  },
6257
6252
  l: true,
@@ -6656,7 +6651,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6656
6651
  // @ts-ignore
6657
6652
  if (attributes.points) {
6658
6653
  // @ts-ignore
6659
- object.parsedStyle.points = parsePoints(attributes.points, object);
6654
+ object.parsedStyle.points = parsePoints(attributes.points);
6660
6655
  }
6661
6656
  // Path
6662
6657
  // @ts-ignore
@@ -6668,8 +6663,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6668
6663
  object.parsedStyle.path = parsePath(
6669
6664
  // @ts-ignore
6670
6665
  attributes.path);
6671
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
6672
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
6673
6666
  }
6674
6667
  // Text
6675
6668
  if (attributes.textTransform) {
@@ -6717,42 +6710,6 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
6717
6710
  // @ts-ignore
6718
6711
  attributes.markerMid, null, null);
6719
6712
  }
6720
- if (
6721
- // Circle & Ellipse
6722
- ((object.nodeName === Shape.CIRCLE ||
6723
- object.nodeName === Shape.ELLIPSE) &&
6724
- // @ts-ignore
6725
- (!isNil(attributes.cx) ||
6726
- // @ts-ignore
6727
- !isNil(attributes.cy))) ||
6728
- ((object.nodeName === Shape.RECT ||
6729
- object.nodeName === Shape.IMAGE ||
6730
- object.nodeName === Shape.GROUP ||
6731
- object.nodeName === Shape.HTML ||
6732
- object.nodeName === Shape.TEXT ||
6733
- object.nodeName === Shape.MESH) &&
6734
- // @ts-ignore
6735
- (!isNil(attributes.x) ||
6736
- // @ts-ignore
6737
- !isNil(attributes.y) ||
6738
- // @ts-ignore
6739
- !isNil(attributes.z))) ||
6740
- // Line
6741
- (object.nodeName === Shape.LINE &&
6742
- // @ts-ignore
6743
- (!isNil(attributes.x1) ||
6744
- // @ts-ignore
6745
- !isNil(attributes.y1) ||
6746
- // @ts-ignore
6747
- !isNil(attributes.z1) ||
6748
- // @ts-ignore
6749
- !isNil(attributes.x2) ||
6750
- // @ts-ignore
6751
- !isNil(attributes.y2) ||
6752
- // @ts-ignore
6753
- !isNil(attributes.z2)))) {
6754
- this.runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object, attributeNames_1);
6755
- }
6756
6713
  if (!isNil(attributes.zIndex)) {
6757
6714
  this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames_1);
6758
6715
  }
@@ -7031,12 +6988,12 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7031
6988
  geometry_1.renderBounds = new AABB();
7032
6989
  }
7033
6990
  var parsedStyle = object.parsedStyle;
7034
- 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;
7035
6992
  // init with content box
7036
6993
  var halfExtents = [
7037
- Math.abs(width) / 2,
7038
- Math.abs(height) / 2,
7039
- depth / 2,
6994
+ Math.abs(hwidth),
6995
+ Math.abs(hheight),
6996
+ hdepth,
7040
6997
  ];
7041
6998
  // const halfExtents = vec3.set(
7042
6999
  // tmpVec3a,
@@ -7045,30 +7002,19 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7045
7002
  // depth / 2,
7046
7003
  // );
7047
7004
  // anchor is center by default, don't account for lineWidth here
7048
- var _f = parsedStyle, stroke = _f.stroke, lineWidth = _f.lineWidth,
7005
+ var _d = parsedStyle, stroke = _d.stroke, lineWidth = _d.lineWidth,
7049
7006
  // lineCap,
7050
7007
  // lineJoin,
7051
7008
  // miterLimit,
7052
- increasedLineWidthForHitTesting = _f.increasedLineWidthForHitTesting, shadowType = _f.shadowType, shadowColor = _f.shadowColor, _g = _f.filter, filter = _g === void 0 ? [] : _g, transformOrigin = _f.transformOrigin;
7053
- 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;
7054
7011
  // <Text> use textAlign & textBaseline instead of anchor
7055
- if (nodeName === Shape.TEXT) {
7056
- delete parsedStyle.anchor;
7057
- }
7058
- else if (nodeName === Shape.MESH) {
7059
- parsedStyle.anchor[2] = 0.5;
7060
- }
7061
- var center = [
7062
- ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
7063
- ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
7064
- (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
7065
- ];
7066
- // const center = vec3.set(
7067
- // tmpVec3b,
7068
- // ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
7069
- // ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
7070
- // (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
7071
- // );
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];
7072
7018
  // update geometry's AABB
7073
7019
  geometry_1.contentBounds.update(center, halfExtents);
7074
7020
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
@@ -7101,8 +7047,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7101
7047
  geometry_1.renderBounds.update(center, halfExtents);
7102
7048
  // account for shadow, only support constant value now
7103
7049
  if (shadowColor && shadowType && shadowType !== 'inner') {
7104
- var _h = geometry_1.renderBounds, min = _h.min, max = _h.max;
7105
- 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;
7106
7052
  var shadowBlurInPixels = shadowBlur || 0;
7107
7053
  var shadowOffsetXInPixels = shadowOffsetX || 0;
7108
7054
  var shadowOffsetYInPixels = shadowOffsetY || 0;
@@ -7139,12 +7085,11 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7139
7085
  geometry_1.renderBounds.setMinMax(min, max);
7140
7086
  }
7141
7087
  });
7142
- anchor = parsedStyle.anchor;
7143
7088
  // if (nodeName === Shape.RECT) {
7144
7089
  // account for negative width / height of Rect
7145
7090
  // @see https://github.com/antvis/g/issues/957
7146
- var flipY = width < 0;
7147
- var flipX = height < 0;
7091
+ var flipY = hwidth < 0;
7092
+ var flipX = hheight < 0;
7148
7093
  // } else {
7149
7094
  // }
7150
7095
  // set transform origin
@@ -7156,19 +7101,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
7156
7101
  (transformOrigin
7157
7102
  ? convertPercentUnit(transformOrigin[1], 1, object)
7158
7103
  : 0);
7159
- usedOriginXValue =
7160
- usedOriginXValue -
7161
- (flipY ? -1 : 1) *
7162
- ((anchor && anchor[0]) || 0) *
7163
- geometry_1.contentBounds.halfExtents[0] *
7164
- 2;
7165
- usedOriginYValue =
7166
- usedOriginYValue -
7167
- (flipX ? -1 : 1) *
7168
- ((anchor && anchor[1]) || 0) *
7169
- geometry_1.contentBounds.halfExtents[1] *
7170
- 2;
7171
- object.setOrigin(usedOriginXValue, usedOriginYValue);
7104
+ object.setOrigin(cx - hwidth + usedOriginXValue, cy - hheight + usedOriginYValue);
7172
7105
  // FIXME setOrigin may have already dirtified to root.
7173
7106
  this.runtime.sceneGraphService.dirtifyToRoot(object);
7174
7107
  }
@@ -7390,177 +7323,6 @@ var CSSPropertyLengthOrPercentage14 = /** @class */ (function () {
7390
7323
  return CSSPropertyLengthOrPercentage14;
7391
7324
  }());
7392
7325
 
7393
- var tmpMat4 = mat4.create();
7394
- function parsedTransformToMat4(transform, object) {
7395
- var defX = object.parsedStyle.defX || 0;
7396
- var defY = object.parsedStyle.defY || 0;
7397
- // reset transform
7398
- object.resetLocalTransform();
7399
- object.setLocalPosition(defX, defY);
7400
- transform.forEach(function (parsed) {
7401
- var t = parsed.t, d = parsed.d;
7402
- if (t === 'scale') {
7403
- // scale(1) scale(1, 1)
7404
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1];
7405
- object.scaleLocal(newScale[0], newScale[1], 1);
7406
- }
7407
- else if (t === 'scalex') {
7408
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7409
- object.scaleLocal(newScale[0], 1, 1);
7410
- }
7411
- else if (t === 'scaley') {
7412
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7413
- object.scaleLocal(1, newScale[0], 1);
7414
- }
7415
- else if (t === 'scalez') {
7416
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1];
7417
- object.scaleLocal(1, 1, newScale[0]);
7418
- }
7419
- else if (t === 'scale3d') {
7420
- var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [1, 1, 1];
7421
- object.scaleLocal(newScale[0], newScale[1], newScale[2]);
7422
- }
7423
- else if (t === 'translate') {
7424
- var newTranslation = d || [Opx, Opx];
7425
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
7426
- }
7427
- else if (t === 'translatex') {
7428
- var newTranslation = d || [Opx];
7429
- object.translateLocal(newTranslation[0].value, 0, 0);
7430
- }
7431
- else if (t === 'translatey') {
7432
- var newTranslation = d || [Opx];
7433
- object.translateLocal(0, newTranslation[0].value, 0);
7434
- }
7435
- else if (t === 'translatez') {
7436
- var newTranslation = d || [Opx];
7437
- object.translateLocal(0, 0, newTranslation[0].value);
7438
- }
7439
- else if (t === 'translate3d') {
7440
- var newTranslation = d || [Opx, Opx, Opx];
7441
- object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
7442
- }
7443
- else if (t === 'rotate') {
7444
- var newAngles = d || [Odeg];
7445
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7446
- }
7447
- else if (t === 'rotatex') {
7448
- var newAngles = d || [Odeg];
7449
- object.rotateLocal(convertAngleUnit(newAngles[0]), 0, 0);
7450
- }
7451
- else if (t === 'rotatey') {
7452
- var newAngles = d || [Odeg];
7453
- object.rotateLocal(0, convertAngleUnit(newAngles[0]), 0);
7454
- }
7455
- else if (t === 'rotatez') {
7456
- var newAngles = d || [Odeg];
7457
- object.rotateLocal(0, 0, convertAngleUnit(newAngles[0]));
7458
- }
7459
- else if (t === 'rotate3d') ;
7460
- else if (t === 'skew') {
7461
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
7462
- object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
7463
- }
7464
- else if (t === 'skewx') {
7465
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7466
- object.setLocalSkew(deg2rad(newSkew[0]), object.getLocalSkew()[1]);
7467
- }
7468
- else if (t === 'skewy') {
7469
- var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
7470
- object.setLocalSkew(object.getLocalSkew()[0], deg2rad(newSkew[0]));
7471
- }
7472
- else if (t === 'matrix') {
7473
- 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];
7474
- object.setLocalTransform(mat4.set(tmpMat4, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx + defX, ty + defY, 0, 1));
7475
- }
7476
- else if (t === 'matrix3d') {
7477
- // @ts-ignore
7478
- mat4.set.apply(mat4, __spreadArray([tmpMat4], __read(d.map(function (s) { return s.value; })), false));
7479
- tmpMat4[12] += defX;
7480
- tmpMat4[13] += defY;
7481
- object.setLocalTransform(tmpMat4);
7482
- }
7483
- });
7484
- return object.getLocalTransform();
7485
- }
7486
-
7487
- /**
7488
- * local position
7489
- */
7490
- var CSSPropertyLocalPosition = /** @class */ (function (_super) {
7491
- __extends(CSSPropertyLocalPosition, _super);
7492
- function CSSPropertyLocalPosition() {
7493
- return _super !== null && _super.apply(this, arguments) || this;
7494
- }
7495
- /**
7496
- * update local position
7497
- */
7498
- CSSPropertyLocalPosition.prototype.postProcessor = function (object, attributes) {
7499
- var x;
7500
- var y;
7501
- var z;
7502
- switch (object.nodeName) {
7503
- case Shape.CIRCLE:
7504
- case Shape.ELLIPSE:
7505
- var _a = object.parsedStyle, cx = _a.cx, cy = _a.cy, cz = _a.cz;
7506
- if (!isNil(cx)) {
7507
- x = cx;
7508
- }
7509
- if (!isNil(cy)) {
7510
- y = cy;
7511
- }
7512
- if (!isNil(cz)) {
7513
- z = cz;
7514
- }
7515
- break;
7516
- case Shape.LINE:
7517
- var _b = object.parsedStyle, x1 = _b.x1, x2 = _b.x2, y1 = _b.y1, y2 = _b.y2;
7518
- var minX = Math.min(x1, x2);
7519
- var minY = Math.min(y1, y2);
7520
- x = minX;
7521
- y = minY;
7522
- z = 0;
7523
- break;
7524
- case Shape.RECT:
7525
- case Shape.IMAGE:
7526
- case Shape.GROUP:
7527
- case Shape.HTML:
7528
- case Shape.TEXT:
7529
- case Shape.MESH:
7530
- if (!isNil(object.parsedStyle.x)) {
7531
- x = object.parsedStyle.x;
7532
- }
7533
- if (!isNil(object.parsedStyle.y)) {
7534
- y = object.parsedStyle.y;
7535
- }
7536
- if (!isNil(object.parsedStyle.z)) {
7537
- z = object.parsedStyle.z;
7538
- }
7539
- break;
7540
- }
7541
- if (object.nodeName !== Shape.PATH &&
7542
- object.nodeName !== Shape.POLYLINE &&
7543
- object.nodeName !== Shape.POLYGON) {
7544
- object.parsedStyle.defX = x || 0;
7545
- object.parsedStyle.defY = y || 0;
7546
- }
7547
- var needResetLocalPosition = !isNil(x) || !isNil(y) || !isNil(z);
7548
- // only if `transform` won't be processed later
7549
- if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
7550
- // account for current transform if needed
7551
- var transform = object.parsedStyle.transform;
7552
- if (transform && transform.length) {
7553
- parsedTransformToMat4(transform, object);
7554
- }
7555
- else {
7556
- var _c = __read(object.getLocalPosition(), 3), ox = _c[0], oy = _c[1], oz = _c[2];
7557
- object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
7558
- }
7559
- }
7560
- };
7561
- return CSSPropertyLocalPosition;
7562
- }(CSSPropertyLengthOrPercentage));
7563
-
7564
7326
  var CSSPropertyMarker = /** @class */ (function () {
7565
7327
  function CSSPropertyMarker() {
7566
7328
  }
@@ -7614,8 +7376,6 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
7614
7376
  // set position in world space
7615
7377
  var point = offsetPath.getPoint(offsetDistance);
7616
7378
  if (point) {
7617
- object.parsedStyle.defX = point.x;
7618
- object.parsedStyle.defY = point.y;
7619
7379
  object.setLocalPosition(point.x, point.y);
7620
7380
  }
7621
7381
  }
@@ -7664,18 +7424,6 @@ var CSSPropertyPath = /** @class */ (function () {
7664
7424
  }
7665
7425
  return parsed;
7666
7426
  };
7667
- /**
7668
- * update local position
7669
- */
7670
- CSSPropertyPath.prototype.postProcessor = function (object, attributes) {
7671
- object.parsedStyle.defX = object.parsedStyle.path.rect.x;
7672
- object.parsedStyle.defY = object.parsedStyle.path.rect.y;
7673
- if (object.nodeName === Shape.PATH &&
7674
- attributes.indexOf('transform') === -1) {
7675
- var _a = object.parsedStyle, _b = _a.defX, defX = _b === void 0 ? 0 : _b, _c = _a.defY, defY = _c === void 0 ? 0 : _c;
7676
- object.setLocalPosition(defX, defY);
7677
- }
7678
- };
7679
7427
  return CSSPropertyPath;
7680
7428
  }());
7681
7429
 
@@ -7684,17 +7432,6 @@ var CSSPropertyPoints = /** @class */ (function () {
7684
7432
  this.parser = parsePoints;
7685
7433
  this.mixer = mergePoints;
7686
7434
  }
7687
- /**
7688
- * update local position
7689
- */
7690
- CSSPropertyPoints.prototype.postProcessor = function (object, attributes) {
7691
- if ((object.nodeName === Shape.POLYGON ||
7692
- object.nodeName === Shape.POLYLINE) &&
7693
- attributes.indexOf('transform') === -1) {
7694
- var _a = object.parsedStyle, defX = _a.defX, defY = _a.defY;
7695
- object.setLocalPosition(defX, defY);
7696
- }
7697
- };
7698
7435
  return CSSPropertyPoints;
7699
7436
  }());
7700
7437
 
@@ -8103,6 +7840,95 @@ function toFontString(attributes) {
8103
7840
  return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
8104
7841
  }
8105
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
+
8106
7932
  /**
8107
7933
  * @see /zh/docs/api/animation#支持变换的属性
8108
7934
  *
@@ -8207,12 +8033,12 @@ var CircleUpdater = /** @class */ (function () {
8207
8033
  function CircleUpdater() {
8208
8034
  }
8209
8035
  CircleUpdater.prototype.update = function (parsedStyle, object) {
8210
- var r = parsedStyle.r;
8211
- var width = r * 2;
8212
- var height = r * 2;
8036
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, r = parsedStyle.r;
8213
8037
  return {
8214
- width: width,
8215
- height: height,
8038
+ cx: cx,
8039
+ cy: cy,
8040
+ hwidth: r,
8041
+ hheight: r,
8216
8042
  };
8217
8043
  };
8218
8044
  return CircleUpdater;
@@ -8222,12 +8048,12 @@ var EllipseUpdater = /** @class */ (function () {
8222
8048
  function EllipseUpdater() {
8223
8049
  }
8224
8050
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
8225
- var rx = parsedStyle.rx, ry = parsedStyle.ry;
8226
- var width = rx * 2;
8227
- var height = ry * 2;
8051
+ var cx = parsedStyle.cx, cy = parsedStyle.cy, rx = parsedStyle.rx, ry = parsedStyle.ry;
8228
8052
  return {
8229
- width: width,
8230
- height: height,
8053
+ cx: cx,
8054
+ cy: cy,
8055
+ hwidth: rx,
8056
+ hheight: ry,
8231
8057
  };
8232
8058
  };
8233
8059
  return EllipseUpdater;
@@ -8244,9 +8070,13 @@ var LineUpdater = /** @class */ (function () {
8244
8070
  var maxY = Math.max(y1, y2);
8245
8071
  var width = maxX - minX;
8246
8072
  var height = maxY - minY;
8073
+ var hwidth = width / 2;
8074
+ var hheight = height / 2;
8247
8075
  return {
8248
- width: width,
8249
- height: height,
8076
+ cx: minX + hwidth,
8077
+ cy: minY + hheight,
8078
+ hwidth: hwidth,
8079
+ hheight: hheight,
8250
8080
  };
8251
8081
  };
8252
8082
  return LineUpdater;
@@ -8257,10 +8087,14 @@ var PathUpdater = /** @class */ (function () {
8257
8087
  }
8258
8088
  PathUpdater.prototype.update = function (parsedStyle) {
8259
8089
  var path = parsedStyle.path;
8260
- 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;
8261
8093
  return {
8262
- width: width,
8263
- height: height,
8094
+ cx: x + hwidth,
8095
+ cy: y + hheight,
8096
+ hwidth: hwidth,
8097
+ hheight: hheight,
8264
8098
  };
8265
8099
  };
8266
8100
  return PathUpdater;
@@ -8279,14 +8113,20 @@ var PolylineUpdater = /** @class */ (function () {
8279
8113
  var maxY = Math.max.apply(Math, __spreadArray([], __read(points.map(function (point) { return point[1]; })), false));
8280
8114
  var width = maxX - minX;
8281
8115
  var height = maxY - minY;
8116
+ var hwidth = width / 2;
8117
+ var hheight = height / 2;
8282
8118
  return {
8283
- width: width,
8284
- height: height,
8119
+ cx: minX + hwidth,
8120
+ cy: minY + hheight,
8121
+ hwidth: hwidth,
8122
+ hheight: hheight,
8285
8123
  };
8286
8124
  }
8287
8125
  return {
8288
- width: 0,
8289
- height: 0,
8126
+ cx: 0,
8127
+ cy: 0,
8128
+ hwidth: 0,
8129
+ hheight: 0,
8290
8130
  };
8291
8131
  };
8292
8132
  return PolylineUpdater;
@@ -8296,7 +8136,7 @@ var RectUpdater = /** @class */ (function () {
8296
8136
  function RectUpdater() {
8297
8137
  }
8298
8138
  RectUpdater.prototype.update = function (parsedStyle, object) {
8299
- 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;
8300
8140
  var contentWidth = width;
8301
8141
  var contentHeight = height;
8302
8142
  // resize with HTMLImageElement's size
@@ -8311,8 +8151,10 @@ var RectUpdater = /** @class */ (function () {
8311
8151
  }
8312
8152
  }
8313
8153
  return {
8314
- width: contentWidth,
8315
- height: contentHeight,
8154
+ cx: x + contentWidth / 2,
8155
+ cy: y + contentHeight / 2,
8156
+ hwidth: contentWidth / 2,
8157
+ hheight: contentHeight / 2,
8316
8158
  };
8317
8159
  };
8318
8160
  return RectUpdater;
@@ -8335,7 +8177,7 @@ var TextUpdater = /** @class */ (function () {
8335
8177
  };
8336
8178
  TextUpdater.prototype.update = function (parsedStyle, object) {
8337
8179
  var _a, _b;
8338
- 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;
8339
8181
  if (!this.isReadyToMeasure(parsedStyle, object)) {
8340
8182
  parsedStyle.metrics = {
8341
8183
  font: '',
@@ -8353,47 +8195,42 @@ var TextUpdater = /** @class */ (function () {
8353
8195
  lineMetrics: [],
8354
8196
  };
8355
8197
  return {
8356
- width: 0,
8357
- height: 0,
8358
- x: 0,
8359
- y: 0,
8360
- offsetX: 0,
8361
- offsetY: 0,
8198
+ hwidth: 0,
8199
+ hheight: 0,
8200
+ cx: 0,
8201
+ cy: 0,
8362
8202
  };
8363
8203
  }
8364
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;
8365
8205
  var metrics = this.globalRuntime.textService.measureText(text, parsedStyle, offscreenCanvas);
8366
8206
  parsedStyle.metrics = metrics;
8367
8207
  var width = metrics.width, height = metrics.height, lineHeight = metrics.lineHeight, fontProperties = metrics.fontProperties;
8368
- // anchor is left-top by default
8369
- var halfExtents = [width / 2, height / 2, 0];
8208
+ var hwidth = width / 2;
8209
+ var hheight = height / 2;
8370
8210
  // default 'left'
8371
- var anchor = [0, 1];
8372
- var lineXOffset = 0;
8211
+ var lineXOffset = x + hwidth;
8373
8212
  if (textAlign === 'center' || textAlign === 'middle') {
8374
- lineXOffset = lineWidth / 2;
8375
- anchor = [0.5, 1];
8213
+ lineXOffset += lineWidth / 2 - hwidth;
8376
8214
  }
8377
8215
  else if (textAlign === 'right' || textAlign === 'end') {
8378
- lineXOffset = lineWidth;
8379
- anchor = [1, 1];
8216
+ lineXOffset += lineWidth - hwidth * 2;
8380
8217
  }
8381
- var lineYOffset = 0;
8218
+ var lineYOffset = y - hheight;
8382
8219
  if (textBaseline === 'middle') {
8383
8220
  // eslint-disable-next-line prefer-destructuring
8384
- lineYOffset = halfExtents[1];
8221
+ lineYOffset += hheight;
8385
8222
  }
8386
8223
  else if (textBaseline === 'top' || textBaseline === 'hanging') {
8387
- lineYOffset = halfExtents[1] * 2;
8224
+ lineYOffset += hheight * 2;
8388
8225
  }
8389
8226
  else if (textBaseline === 'alphabetic') {
8390
8227
  // prevent calling getImageData for ascent metrics
8391
- lineYOffset = this.globalRuntime.enableCSSParsing
8228
+ lineYOffset += this.globalRuntime.enableCSSParsing
8392
8229
  ? lineHeight - fontProperties.ascent
8393
8230
  : 0;
8394
8231
  }
8395
8232
  else if (textBaseline === 'bottom' || textBaseline === 'ideographic') {
8396
- lineYOffset = 0;
8233
+ lineYOffset += 0;
8397
8234
  }
8398
8235
  // TODO: ideographic & bottom
8399
8236
  if (dx) {
@@ -8402,13 +8239,11 @@ var TextUpdater = /** @class */ (function () {
8402
8239
  if (dy) {
8403
8240
  lineYOffset += dy;
8404
8241
  }
8405
- // update anchor
8406
- parsedStyle.anchor = [anchor[0], anchor[1], 0];
8407
8242
  return {
8408
- width: halfExtents[0] * 2,
8409
- height: halfExtents[1] * 2,
8410
- offsetX: lineXOffset,
8411
- offsetY: lineYOffset,
8243
+ cx: lineXOffset,
8244
+ cy: lineYOffset,
8245
+ hwidth: hwidth,
8246
+ hheight: hheight,
8412
8247
  };
8413
8248
  };
8414
8249
  return TextUpdater;
@@ -11683,7 +11518,7 @@ var CSSPropertySyntaxFactory = (function () {
11683
11518
  _a[PropertySyntax.LENGTH_PERCENTAGE] = length,
11684
11519
  _a[PropertySyntax.LENGTH_PERCENTAGE_12] = new CSSPropertyLengthOrPercentage12(),
11685
11520
  _a[PropertySyntax.LENGTH_PERCENTAGE_14] = new CSSPropertyLengthOrPercentage14(),
11686
- _a[PropertySyntax.COORDINATE] = new CSSPropertyLocalPosition(),
11521
+ _a[PropertySyntax.COORDINATE] = new CSSPropertyLengthOrPercentage(),
11687
11522
  _a[PropertySyntax.OFFSET_DISTANCE] = new CSSPropertyOffsetDistance(),
11688
11523
  _a[PropertySyntax.OPACITY_VALUE] = new CSSPropertyOpacity(),
11689
11524
  _a[PropertySyntax.PATH] = new CSSPropertyPath(),
@@ -11979,8 +11814,11 @@ var Element = /** @class */ (function (_super) {
11979
11814
  if ((_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) {
11980
11815
  this.ownerDocument.defaultView.mountChildren(child);
11981
11816
  }
11982
- insertedEvent.relatedNode = this;
11983
- child.dispatchEvent(insertedEvent);
11817
+ // @ts-ignore
11818
+ if (child.isMutationObserved) {
11819
+ insertedEvent.relatedNode = this;
11820
+ child.dispatchEvent(insertedEvent);
11821
+ }
11984
11822
  return child;
11985
11823
  };
11986
11824
  Element.prototype.insertBefore = function (newChild, refChild) {
@@ -12407,7 +12245,6 @@ var DATASET_PREFIX = 'data-';
12407
12245
  var DisplayObject = /** @class */ (function (_super) {
12408
12246
  __extends(DisplayObject, _super);
12409
12247
  function DisplayObject(config) {
12410
- var _a;
12411
12248
  var _this = _super.call(this) || this;
12412
12249
  _this.isCustomElement = false;
12413
12250
  _this.isMutationObserved = false;
@@ -12426,7 +12263,7 @@ var DisplayObject = /** @class */ (function (_super) {
12426
12263
  // eg. group.get('name')
12427
12264
  _this.config = config;
12428
12265
  // compatible with G 3.0
12429
- _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;
12430
12267
  // init scene graph node
12431
12268
  _this.id = _this.config.id || '';
12432
12269
  _this.name = _this.config.name || '';
@@ -12434,23 +12271,23 @@ var DisplayObject = /** @class */ (function (_super) {
12434
12271
  _this.className = _this.config.className || _this.config.class;
12435
12272
  }
12436
12273
  _this.nodeName = _this.config.type || Shape.GROUP;
12437
- // compatible with G 3.0
12438
- _this.config.style =
12439
- _this.config.style || _this.config.attrs || {};
12440
- Object.assign(_this.config.style, _this.config.attrs);
12441
- // this.config.style = {
12442
- // // ...DEFAULT_STYLE_PROPS,
12443
- // ...this.config.style,
12444
- // ...this.config.attrs,
12445
- // };
12446
- if (_this.config.visible != null) {
12447
- _this.config.style.visibility =
12448
- _this.config.visible === false ? 'hidden' : 'visible';
12449
- }
12450
- if (_this.config.interactive != null) {
12451
- _this.config.style.pointerEvents =
12452
- _this.config.interactive === false ? 'none' : 'auto';
12453
- }
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
+ // }
12454
12291
  // merge parsed value
12455
12292
  Object.assign(_this.parsedStyle, runtime.enableCSSParsing
12456
12293
  ? DEFAULT_PARSED_STYLE_PROPS
@@ -13202,12 +13039,16 @@ var CSS = {
13202
13039
 
13203
13040
  var Circle = /** @class */ (function (_super) {
13204
13041
  __extends(Circle, _super);
13042
+ // constructor(options: DisplayObjectConfig<CircleStyleProps> = {}) {
13043
+ // super(options);
13044
+ // this.nodeName = Shape.CIRCLE;
13045
+ // }
13205
13046
  function Circle(_a) {
13206
13047
  if (_a === void 0) { _a = {}; }
13207
13048
  var style = _a.style, rest = __rest(_a, ["style"]);
13208
13049
  return _super.call(this, __assign({ type: Shape.CIRCLE, style: runtime.enableCSSParsing
13209
13050
  ? __assign({ cx: '', cy: '', r: '' }, style) : __assign({}, style), initialParsedStyle: {
13210
- anchor: [0.5, 0.5],
13051
+ // anchor: [0.5, 0.5],
13211
13052
  transformOrigin: runtime.enableCSSParsing
13212
13053
  ? null
13213
13054
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13245,7 +13086,7 @@ var Ellipse = /** @class */ (function (_super) {
13245
13086
  var style = _a.style, rest = __rest(_a, ["style"]);
13246
13087
  return _super.call(this, __assign({ type: Shape.ELLIPSE, style: runtime.enableCSSParsing
13247
13088
  ? __assign({ cx: '', cy: '', rx: '', ry: '' }, style) : __assign({}, style), initialParsedStyle: {
13248
- anchor: [0.5, 0.5],
13089
+ // anchor: [0.5, 0.5],
13249
13090
  transformOrigin: runtime.enableCSSParsing
13250
13091
  ? null
13251
13092
  : [PECENTAGE_50, PECENTAGE_50],
@@ -13415,7 +13256,7 @@ var Line = /** @class */ (function (_super) {
13415
13256
  }
13416
13257
  };
13417
13258
  Line.prototype.transformMarker = function (isStart) {
13418
- 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;
13419
13260
  var marker = isStart ? markerStart : markerEnd;
13420
13261
  if (!marker || !isDisplayObject(marker)) {
13421
13262
  return;
@@ -13428,16 +13269,16 @@ var Line = /** @class */ (function (_super) {
13428
13269
  var offset;
13429
13270
  var originalAngle;
13430
13271
  if (isStart) {
13431
- ox = x1 - defX;
13432
- oy = y1 - defY;
13272
+ ox = x1;
13273
+ oy = y1;
13433
13274
  x = x2 - x1;
13434
13275
  y = y2 - y1;
13435
13276
  offset = markerStartOffset || 0;
13436
13277
  originalAngle = this.markerStartAngle;
13437
13278
  }
13438
13279
  else {
13439
- ox = x2 - defX;
13440
- oy = y2 - defY;
13280
+ ox = x2;
13281
+ oy = y2;
13441
13282
  x = x1 - x2;
13442
13283
  y = y1 - y2;
13443
13284
  offset = markerEndOffset || 0;
@@ -13451,9 +13292,9 @@ var Line = /** @class */ (function (_super) {
13451
13292
  Line.prototype.getPoint = function (ratio, inWorldSpace) {
13452
13293
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13453
13294
  // TODO: account for z1/z2 in 3D line
13454
- 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;
13455
13296
  var _b = linePointAt(x1, y1, x2, y2, ratio), x = _b.x, y = _b.y;
13456
- 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());
13457
13298
  // apply local transformation
13458
13299
  return new Point(transformed[0], transformed[1]);
13459
13300
  };
@@ -13544,7 +13385,7 @@ var Path = /** @class */ (function (_super) {
13544
13385
  }
13545
13386
  };
13546
13387
  Path.prototype.transformMarker = function (isStart) {
13547
- 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;
13548
13389
  var marker = isStart ? markerStart : markerEnd;
13549
13390
  if (!marker || !isDisplayObject(marker)) {
13550
13391
  return;
@@ -13558,8 +13399,8 @@ var Path = /** @class */ (function (_super) {
13558
13399
  var originalAngle;
13559
13400
  if (isStart) {
13560
13401
  var _b = __read(this.getStartTangent(), 2), p1 = _b[0], p2 = _b[1];
13561
- ox = p2[0] - defX;
13562
- oy = p2[1] - defY;
13402
+ ox = p2[0];
13403
+ oy = p2[1];
13563
13404
  x = p1[0] - p2[0];
13564
13405
  y = p1[1] - p2[1];
13565
13406
  offset = markerStartOffset || 0;
@@ -13567,8 +13408,8 @@ var Path = /** @class */ (function (_super) {
13567
13408
  }
13568
13409
  else {
13569
13410
  var _c = __read(this.getEndTangent(), 2), p1 = _c[0], p2 = _c[1];
13570
- ox = p2[0] - defX;
13571
- oy = p2[1] - defY;
13411
+ ox = p2[0];
13412
+ oy = p2[1];
13572
13413
  x = p1[0] - p2[0];
13573
13414
  y = p1[1] - p2[1];
13574
13415
  offset = markerEndOffset || 0;
@@ -13580,18 +13421,18 @@ var Path = /** @class */ (function (_super) {
13580
13421
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13581
13422
  };
13582
13423
  Path.prototype.placeMarkerMid = function (marker) {
13583
- var _a = this.parsedStyle, segments = _a.path.segments, defX = _a.defX, defY = _a.defY;
13424
+ var segments = this.parsedStyle.path.segments;
13584
13425
  // clear all existed markers
13585
13426
  this.markerMidList.forEach(function (marker) {
13586
13427
  marker.remove();
13587
13428
  });
13588
13429
  if (marker && isDisplayObject(marker)) {
13589
13430
  for (var i = 1; i < segments.length - 1; i++) {
13590
- 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];
13591
13432
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13592
13433
  this.markerMidList.push(cloned);
13593
13434
  this.appendChild(cloned);
13594
- cloned.setLocalPosition(ox - defX, oy - defY);
13435
+ cloned.setLocalPosition(ox, oy);
13595
13436
  // TODO: orient of marker
13596
13437
  }
13597
13438
  }
@@ -13609,9 +13450,9 @@ var Path = /** @class */ (function (_super) {
13609
13450
  */
13610
13451
  Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
13611
13452
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13612
- var _a = this.parsedStyle, defX = _a.defX, defY = _a.defY, absolutePath = _a.path.absolutePath;
13613
- var _b = getPointAtLength(absolutePath, distance), x = _b.x, y = _b.y;
13614
- 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());
13615
13456
  // apply local transformation
13616
13457
  return new Point(transformed[0], transformed[1]);
13617
13458
  };
@@ -13750,7 +13591,7 @@ var Polygon = /** @class */ (function (_super) {
13750
13591
  }
13751
13592
  };
13752
13593
  Polygon.prototype.transformMarker = function (isStart) {
13753
- 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;
13754
13595
  var points = (P || {}).points;
13755
13596
  var marker = isStart ? markerStart : markerEnd;
13756
13597
  if (!marker || !isDisplayObject(marker) || !points) {
@@ -13763,8 +13604,8 @@ var Polygon = /** @class */ (function (_super) {
13763
13604
  var oy;
13764
13605
  var offset;
13765
13606
  var originalAngle;
13766
- ox = points[0][0] - defX;
13767
- oy = points[0][1] - defY;
13607
+ ox = points[0][0];
13608
+ oy = points[0][1];
13768
13609
  if (isStart) {
13769
13610
  x = points[1][0] - points[0][0];
13770
13611
  y = points[1][1] - points[0][1];
@@ -13774,8 +13615,8 @@ var Polygon = /** @class */ (function (_super) {
13774
13615
  else {
13775
13616
  var length_1 = points.length;
13776
13617
  if (!this.parsedStyle.isClosed) {
13777
- ox = points[length_1 - 1][0] - defX;
13778
- oy = points[length_1 - 1][1] - defY;
13618
+ ox = points[length_1 - 1][0];
13619
+ oy = points[length_1 - 1][1];
13779
13620
  x = points[length_1 - 2][0] - points[length_1 - 1][0];
13780
13621
  y = points[length_1 - 2][1] - points[length_1 - 1][1];
13781
13622
  }
@@ -13792,7 +13633,7 @@ var Polygon = /** @class */ (function (_super) {
13792
13633
  marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
13793
13634
  };
13794
13635
  Polygon.prototype.placeMarkerMid = function (marker) {
13795
- var _a = this.parsedStyle, P = _a.points, defX = _a.defX, defY = _a.defY;
13636
+ var P = this.parsedStyle.points;
13796
13637
  var points = (P || {}).points;
13797
13638
  // clear all existed markers
13798
13639
  this.markerMidList.forEach(function (marker) {
@@ -13801,8 +13642,8 @@ var Polygon = /** @class */ (function (_super) {
13801
13642
  this.markerMidList = [];
13802
13643
  if (marker && isDisplayObject(marker) && points) {
13803
13644
  for (var i = 1; i < (this.parsedStyle.isClosed ? points.length : points.length - 1); i++) {
13804
- var ox = points[i][0] - defX;
13805
- var oy = points[i][1] - defY;
13645
+ var ox = points[i][0];
13646
+ var oy = points[i][1];
13806
13647
  var cloned = i === 1 ? marker : marker.cloneNode(true);
13807
13648
  this.markerMidList.push(cloned);
13808
13649
  this.appendChild(cloned);
@@ -13844,7 +13685,7 @@ var Polyline = /** @class */ (function (_super) {
13844
13685
  };
13845
13686
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13846
13687
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13847
- 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;
13848
13689
  var subt = 0;
13849
13690
  var index = 0;
13850
13691
  segments.forEach(function (v, i) {
@@ -13853,8 +13694,8 @@ var Polyline = /** @class */ (function (_super) {
13853
13694
  index = i;
13854
13695
  }
13855
13696
  });
13856
- var _c = linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _c.x, y = _c.y;
13857
- 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());
13858
13699
  // apply local transformation
13859
13700
  return new Point(transformed[0], transformed[1]);
13860
13701
  };