@antv/g 5.0.24 → 5.1.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 (132) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +2 -0
  3. package/es/css/CSSProperty.d.ts +2 -1
  4. package/es/css/StyleValueRegistry.d.ts +2 -1
  5. package/es/css/StyleValueRegistry.js +68 -72
  6. package/es/css/parser/color.d.ts +1 -1
  7. package/es/css/parser/color.js +2 -2
  8. package/es/css/parser/dimension.js +5 -1
  9. package/es/css/parser/path.d.ts +2 -2
  10. package/es/css/parser/path.js +9 -2
  11. package/es/css/parser/points.d.ts +8 -1
  12. package/es/css/parser/points.js +33 -3
  13. package/es/css/parser/transform.js +1 -1
  14. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  15. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  16. package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
  17. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  18. package/es/css/properties/CSSPropertyPath.js +7 -5
  19. package/es/css/properties/CSSPropertyPoints.js +3 -4
  20. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  21. package/es/css/properties/CSSPropertyTransform.js +76 -104
  22. package/es/display-objects/Circle.d.ts +4 -0
  23. package/es/display-objects/Circle.js +2 -0
  24. package/es/display-objects/DisplayObject.d.ts +1 -7
  25. package/es/display-objects/DisplayObject.js +6 -26
  26. package/es/display-objects/Ellipse.d.ts +4 -0
  27. package/es/display-objects/Ellipse.js +2 -0
  28. package/es/display-objects/Group.d.ts +4 -0
  29. package/es/display-objects/Group.js +2 -0
  30. package/es/display-objects/HTML.d.ts +4 -4
  31. package/es/display-objects/HTML.js +5 -3
  32. package/es/display-objects/Image.d.ts +4 -0
  33. package/es/display-objects/Image.js +2 -0
  34. package/es/display-objects/Line.js +2 -0
  35. package/es/display-objects/Path.d.ts +2 -2
  36. package/es/display-objects/Polygon.js +1 -1
  37. package/es/display-objects/Polyline.js +1 -1
  38. package/es/display-objects/Rect.d.ts +6 -2
  39. package/es/display-objects/Rect.js +2 -0
  40. package/es/display-objects/Text.d.ts +4 -0
  41. package/es/display-objects/Text.js +2 -0
  42. package/es/dom/Element.js +1 -0
  43. package/es/services/EventService.js +10 -2
  44. package/es/services/SceneGraphService.d.ts +2 -0
  45. package/es/services/SceneGraphService.js +9 -0
  46. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  47. package/es/services/aabb/CircleUpdater.js +2 -6
  48. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  49. package/es/services/aabb/EllipseUpdater.js +2 -6
  50. package/es/services/aabb/LineUpdater.d.ts +0 -2
  51. package/es/services/aabb/LineUpdater.js +1 -3
  52. package/es/services/aabb/PathUpdater.d.ts +0 -2
  53. package/es/services/aabb/PathUpdater.js +1 -5
  54. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  55. package/es/services/aabb/PolylineUpdater.js +1 -3
  56. package/es/services/aabb/RectUpdater.d.ts +0 -2
  57. package/es/services/aabb/RectUpdater.js +1 -5
  58. package/es/services/aabb/TextUpdater.d.ts +7 -0
  59. package/es/services/aabb/TextUpdater.js +0 -4
  60. package/es/services/aabb/interfaces.d.ts +0 -3
  61. package/es/types.d.ts +6 -19
  62. package/es/types.js +1 -0
  63. package/es/utils/interpolation.js +2 -8
  64. package/es/utils/math.js +4 -3
  65. package/es/utils/path.d.ts +2 -2
  66. package/es/utils/path.js +61 -24
  67. package/lib/Canvas.js +2 -0
  68. package/lib/css/CSSProperty.d.ts +2 -1
  69. package/lib/css/StyleValueRegistry.d.ts +2 -1
  70. package/lib/css/StyleValueRegistry.js +67 -71
  71. package/lib/css/parser/color.d.ts +1 -1
  72. package/lib/css/parser/color.js +1 -1
  73. package/lib/css/parser/dimension.js +4 -0
  74. package/lib/css/parser/path.d.ts +2 -2
  75. package/lib/css/parser/path.js +9 -2
  76. package/lib/css/parser/points.d.ts +8 -1
  77. package/lib/css/parser/points.js +33 -3
  78. package/lib/css/parser/transform.js +1 -1
  79. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  80. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  81. package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
  82. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  83. package/lib/css/properties/CSSPropertyPath.js +7 -5
  84. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  85. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  86. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  87. package/lib/display-objects/Circle.d.ts +4 -0
  88. package/lib/display-objects/Circle.js +2 -0
  89. package/lib/display-objects/DisplayObject.d.ts +1 -7
  90. package/lib/display-objects/DisplayObject.js +6 -27
  91. package/lib/display-objects/Ellipse.d.ts +4 -0
  92. package/lib/display-objects/Ellipse.js +2 -0
  93. package/lib/display-objects/Group.d.ts +4 -0
  94. package/lib/display-objects/Group.js +2 -0
  95. package/lib/display-objects/HTML.d.ts +4 -4
  96. package/lib/display-objects/HTML.js +5 -3
  97. package/lib/display-objects/Image.d.ts +4 -0
  98. package/lib/display-objects/Image.js +2 -0
  99. package/lib/display-objects/Line.js +2 -0
  100. package/lib/display-objects/Path.d.ts +2 -2
  101. package/lib/display-objects/Polygon.js +1 -1
  102. package/lib/display-objects/Polyline.js +1 -1
  103. package/lib/display-objects/Rect.d.ts +6 -2
  104. package/lib/display-objects/Rect.js +2 -0
  105. package/lib/display-objects/Text.d.ts +4 -0
  106. package/lib/display-objects/Text.js +2 -0
  107. package/lib/dom/Element.js +1 -0
  108. package/lib/services/EventService.js +10 -2
  109. package/lib/services/SceneGraphService.d.ts +2 -0
  110. package/lib/services/SceneGraphService.js +12 -0
  111. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  112. package/lib/services/aabb/CircleUpdater.js +2 -6
  113. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  114. package/lib/services/aabb/EllipseUpdater.js +2 -6
  115. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  116. package/lib/services/aabb/LineUpdater.js +1 -3
  117. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  118. package/lib/services/aabb/PathUpdater.js +1 -5
  119. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  120. package/lib/services/aabb/PolylineUpdater.js +1 -3
  121. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  122. package/lib/services/aabb/RectUpdater.js +1 -5
  123. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  124. package/lib/services/aabb/TextUpdater.js +0 -4
  125. package/lib/services/aabb/interfaces.d.ts +0 -3
  126. package/lib/types.d.ts +6 -19
  127. package/lib/types.js +1 -0
  128. package/lib/utils/interpolation.js +2 -8
  129. package/lib/utils/math.js +4 -3
  130. package/lib/utils/path.d.ts +2 -2
  131. package/lib/utils/path.js +55 -24
  132. package/package.json +3 -3
@@ -10,16 +10,12 @@ function () {
10
10
 
11
11
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
12
12
  var rx = parsedStyle.rx,
13
- ry = parsedStyle.ry,
14
- x = parsedStyle.x,
15
- y = parsedStyle.y;
13
+ ry = parsedStyle.ry;
16
14
  var width = rx.value * 2;
17
15
  var height = ry.value * 2;
18
16
  return {
19
17
  width: width,
20
- height: height,
21
- x: x.value || 0,
22
- y: y.value || 0
18
+ height: height
23
19
  };
24
20
  };
25
21
 
@@ -4,7 +4,5 @@ export declare class LineUpdater implements GeometryAABBUpdater<ParsedLineStyleP
4
4
  update(parsedStyle: ParsedLineStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -21,9 +21,7 @@ function () {
21
21
  var height = maxY - minY;
22
22
  return {
23
23
  width: width,
24
- height: height,
25
- x: minX,
26
- y: minY
24
+ height: height
27
25
  };
28
26
  };
29
27
 
@@ -4,7 +4,5 @@ export declare class PathUpdater implements GeometryAABBUpdater<ParsedPathStyleP
4
4
  update(parsedStyle: ParsedPathStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -11,15 +11,11 @@ function () {
11
11
  PathUpdater.prototype.update = function (parsedStyle) {
12
12
  var path = parsedStyle.path;
13
13
  var _a = path.rect,
14
- minX = _a.x,
15
- minY = _a.y,
16
14
  width = _a.width,
17
15
  height = _a.height;
18
16
  return {
19
17
  width: width,
20
- height: height,
21
- x: minX,
22
- y: minY
18
+ height: height
23
19
  };
24
20
  };
25
21
 
@@ -4,7 +4,5 @@ export declare class PolylineUpdater implements GeometryAABBUpdater<ParsedPolyli
4
4
  update(parsedStyle: ParsedPolylineStyleProps): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -27,9 +27,7 @@ function () {
27
27
  var height = maxY - minY;
28
28
  return {
29
29
  width: width,
30
- height: height,
31
- x: minX,
32
- y: minY
30
+ height: height
33
31
  };
34
32
  };
35
33
 
@@ -4,7 +4,5 @@ export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyle
4
4
  update(parsedStyle: ParsedImageStyleProps, object: Image | Rect | Group): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -12,8 +12,6 @@ function () {
12
12
 
13
13
  RectUpdater.prototype.update = function (parsedStyle, object) {
14
14
  var img = parsedStyle.img,
15
- x = parsedStyle.x,
16
- y = parsedStyle.y,
17
15
  width = parsedStyle.width,
18
16
  height = parsedStyle.height;
19
17
  var contentWidth = 0;
@@ -52,9 +50,7 @@ function () {
52
50
 
53
51
  return {
54
52
  width: contentWidth,
55
- height: contentHeight,
56
- x: x.value || 0,
57
- y: y.value || 0
53
+ height: contentHeight
58
54
  };
59
55
  };
60
56
 
@@ -10,5 +10,12 @@ export declare class TextUpdater implements GeometryAABBUpdater<ParsedTextStyleP
10
10
  y: number;
11
11
  offsetX: number;
12
12
  offsetY: number;
13
+ } | {
14
+ width: number;
15
+ height: number;
16
+ offsetX: number;
17
+ offsetY: number;
18
+ x?: undefined;
19
+ y?: undefined;
13
20
  };
14
21
  }
@@ -29,8 +29,6 @@ function () {
29
29
  textAlign = parsedStyle.textAlign,
30
30
  lineWidth = parsedStyle.lineWidth,
31
31
  textBaseline = parsedStyle.textBaseline,
32
- x = parsedStyle.x,
33
- y = parsedStyle.y,
34
32
  dx = parsedStyle.dx,
35
33
  dy = parsedStyle.dy;
36
34
  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;
@@ -119,8 +117,6 @@ function () {
119
117
  return {
120
118
  width: halfExtents[0] * 2,
121
119
  height: halfExtents[1] * 2,
122
- x: x.value || 0,
123
- y: y.value || 0,
124
120
  offsetX: lineXOffset,
125
121
  offsetY: lineYOffset
126
122
  };
@@ -8,9 +8,6 @@ export interface GeometryAABBUpdater<T extends ParsedBaseStyleProps = any> {
8
8
  width: number;
9
9
  height: number;
10
10
  depth?: number;
11
- x: number;
12
- y: number;
13
- z?: number;
14
11
  offsetX?: number;
15
12
  offsetY?: number;
16
13
  offsetZ?: number;
package/es/types.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import type { vec2, vec3 } from 'gl-matrix';
3
3
  import type { DisplayObject } from './display-objects';
4
4
  import type { IRenderer } from './AbstractRenderer';
5
- import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue } from './css';
5
+ import type { CSSGlobalKeywords, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSUnitValue, ParsedTransform } from './css';
6
6
  import { Syringe } from 'mana-syringe';
7
7
  export declare enum Shape {
8
8
  GROUP = "g",
@@ -15,7 +15,8 @@ export declare enum Shape {
15
15
  POLYGON = "polygon",
16
16
  TEXT = "text",
17
17
  PATH = "path",
18
- HTML = "html"
18
+ HTML = "html",
19
+ MESH = "mesh"
19
20
  }
20
21
  declare type ColorType = string | null;
21
22
  export interface EventPosition {
@@ -51,18 +52,6 @@ export declare enum TextAlign {
51
52
  }
52
53
  export interface BaseStyleProps {
53
54
  class?: string;
54
- /**
55
- * x in local space
56
- */
57
- x?: number | string;
58
- /**
59
- * y in local space
60
- */
61
- y?: number | string;
62
- /**
63
- * z in local space
64
- */
65
- z?: number | string;
66
55
  /**
67
56
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
68
57
  */
@@ -163,7 +152,7 @@ export interface BaseStyleProps {
163
152
  miterLimit?: number;
164
153
  display?: string;
165
154
  }
166
- export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transformOrigin' | 'textTransform'> {
155
+ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x' | 'y' | 'z' | 'opacity' | 'strokeOpacity' | 'fillOpacity' | 'fill' | 'stroke' | 'lineWidth' | 'increasedLineWidthForHitTesting' | 'lineJoin' | 'lineCap' | 'lineDash' | 'lineDashOffset' | 'path' | 'points' | 'shadowColor' | 'shadowBlur' | 'shadowOffsetX' | 'shadowOffsetY' | 'visibility' | 'pointerEvents' | 'zIndex' | 'transform' | 'transformOrigin' | 'textTransform'> {
167
156
  zIndex?: CSSUnitValue;
168
157
  visibility?: CSSKeywordValue;
169
158
  pointerEvents?: CSSKeywordValue;
@@ -177,10 +166,8 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'anchor' | 'x
177
166
  lineJoin?: CSSKeywordValue;
178
167
  lineDashOffset?: CSSUnitValue;
179
168
  anchor?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
169
+ transform: ParsedTransform[];
180
170
  transformOrigin?: [CSSUnitValue, CSSUnitValue, CSSUnitValue];
181
- x?: CSSUnitValue;
182
- y?: CSSUnitValue;
183
- z?: CSSUnitValue;
184
171
  width?: CSSUnitValue;
185
172
  height?: CSSUnitValue;
186
173
  lineWidth?: CSSUnitValue;
@@ -247,7 +234,7 @@ export interface CanvasConfig {
247
234
  /**
248
235
  * replace `new window.Image()`
249
236
  */
250
- createImage?: () => HTMLImageElement;
237
+ createImage?: (src: string) => HTMLImageElement;
251
238
  /**
252
239
  * limits query
253
240
  */
package/es/types.js CHANGED
@@ -13,6 +13,7 @@ export var Shape;
13
13
  Shape["TEXT"] = "text";
14
14
  Shape["PATH"] = "path";
15
15
  Shape["HTML"] = "html";
16
+ Shape["MESH"] = "mesh";
16
17
  })(Shape || (Shape = {}));
17
18
 
18
19
  export var LineCap;
@@ -121,8 +121,8 @@ function propertyInterpolation(property, left, right, target) {
121
121
 
122
122
  if (propertyHandler) {
123
123
  if (propertyHandler.parser) {
124
- parsedLeft = propertyHandler.parser(left);
125
- parsedRight = propertyHandler.parser(right);
124
+ parsedLeft = propertyHandler.parser(left, target);
125
+ parsedRight = propertyHandler.parser(right, target);
126
126
  } // if (propertyHandler.calculator) {
127
127
  // parsedLeft = propertyHandler.calculator(parsedLeft);
128
128
  // // parsedLeft = handler.calculator
@@ -184,12 +184,6 @@ var FORMAT_ATTR_MAP = {
184
184
  d: {
185
185
  alias: 'path'
186
186
  },
187
- cx: {
188
- alias: 'x'
189
- },
190
- cy: {
191
- alias: 'y'
192
- },
193
187
  strokeDasharray: {
194
188
  alias: 'lineDash'
195
189
  },
package/es/utils/math.js CHANGED
@@ -199,8 +199,8 @@ export function makePerspective(out, left, right, top, bottom, near, far) {
199
199
  }
200
200
  export function decompose(mat) {
201
201
  var row0x = mat[0];
202
- var row0y = mat[3];
203
- var row1x = mat[1];
202
+ var row0y = mat[1];
203
+ var row1x = mat[3];
204
204
  var row1y = mat[4]; // decompose 3x3 matrix
205
205
  // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
206
206
 
@@ -230,6 +230,7 @@ export function decompose(mat) {
230
230
  } // Compute rotation and renormalize matrix.
231
231
 
232
232
 
233
- var angle = Math.atan2(row0y, row0x);
233
+ var rotation = Math.atan2(row0y, row0x);
234
+ var angle = rad2deg(rotation);
234
235
  return [mat[6], mat[7], scalingX, scalingY, angle];
235
236
  }
@@ -1,4 +1,4 @@
1
- import type { DisplayObject } from '../display-objects';
1
+ import type { Circle, Ellipse, Line, Path, Polyline, Polygon, Rect } from '../display-objects';
2
2
  import type { PathCommand } from '../types';
3
3
  export declare function equalizeSegments(path1: PathCommand[], path2: PathCommand[], TL?: number): PathCommand[][];
4
4
  export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
@@ -12,4 +12,4 @@ export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (st
12
12
  * * anchor
13
13
  * * lineWidth
14
14
  */
15
- export declare function convertToPath(object: DisplayObject): string;
15
+ export declare function convertToPath(object: Circle | Ellipse | Rect | Line | Polyline | Polygon | Path, applyLocalTransform?: boolean): string;
package/es/utils/path.js CHANGED
@@ -205,17 +205,32 @@ export function getRotatedCurve(a, b) {
205
205
  return rotations[computedIndex];
206
206
  }
207
207
 
208
- function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
209
- var _a = parsedStyle.defX,
210
- defX = _a === void 0 ? 0 : _a,
211
- _b = parsedStyle.defY,
212
- defY = _b === void 0 ? 0 : _b;
208
+ function commandsToPathString(commands, object, applyLocalTransform) {
209
+ if (applyLocalTransform === void 0) {
210
+ applyLocalTransform = true;
211
+ }
212
+
213
+ var transform;
214
+
215
+ if (applyLocalTransform) {
216
+ transform = object.getLocalTransform();
217
+ }
218
+
219
+ var _a = object.parsedStyle,
220
+ _b = _a.defX,
221
+ defX = _b === void 0 ? 0 : _b,
222
+ _c = _a.defY,
223
+ defY = _c === void 0 ? 0 : _c;
213
224
  return commands.reduce(function (prev, cur) {
214
225
  var path = '';
215
226
 
216
227
  if (cur[0] === 'M' || cur[0] === 'L') {
217
228
  var p = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
218
- vec3.transformMat4(p, p, localTransform);
229
+
230
+ if (applyLocalTransform) {
231
+ vec3.transformMat4(p, p, transform);
232
+ }
233
+
219
234
  path = "".concat(cur[0]).concat(p[0], ",").concat(p[1]);
220
235
  } else if (cur[0] === 'Z') {
221
236
  path = cur[0];
@@ -223,13 +238,21 @@ function commandsToPathString(commands, localTransform, anchor, parsedStyle) {
223
238
  var p1 = vec3.fromValues(cur[1] - defX, cur[2] - defY, 0);
224
239
  var p2 = vec3.fromValues(cur[3] - defX, cur[4] - defY, 0);
225
240
  var p3 = vec3.fromValues(cur[5] - defX, cur[6] - defY, 0);
226
- vec3.transformMat4(p1, p1, localTransform);
227
- vec3.transformMat4(p2, p2, localTransform);
228
- vec3.transformMat4(p3, p3, localTransform);
241
+
242
+ if (applyLocalTransform) {
243
+ vec3.transformMat4(p1, p1, transform);
244
+ vec3.transformMat4(p2, p2, transform);
245
+ vec3.transformMat4(p3, p3, transform);
246
+ }
247
+
229
248
  path = "".concat(cur[0]).concat(p1[0], ",").concat(p1[1], ",").concat(p2[0], ",").concat(p2[1], ",").concat(p3[0], ",").concat(p3[1]);
230
249
  } else if (cur[0] === 'A') {
231
250
  var c = vec3.fromValues(cur[6] - defX, cur[7] - defY, 0);
232
- vec3.transformMat4(c, c, localTransform);
251
+
252
+ if (applyLocalTransform) {
253
+ vec3.transformMat4(c, c, transform);
254
+ }
255
+
233
256
  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]);
234
257
  }
235
258
 
@@ -252,10 +275,16 @@ function ellipseToCommands(rx, ry, cx, cy) {
252
275
  return [['M', left, cy], ['C', left, cy - dy, cx - dx, top, cx, top], ['C', cx + dx, top, right, cy - dy, right, cy], ['C', right, cy + dy, cx + dx, bottom, cx, bottom], ['C', cx - dx, bottom, left, cy + dy, left, cy], ['Z']];
253
276
  }
254
277
 
255
- function polygonToCommands(points) {
256
- return points.map(function (point, i) {
278
+ function polygonToCommands(points, closed) {
279
+ var result = points.map(function (point, i) {
257
280
  return [i === 0 ? 'M' : 'L', point[0], point[1]];
258
281
  });
282
+
283
+ if (closed) {
284
+ result.push(['Z']);
285
+ }
286
+
287
+ return result;
259
288
  }
260
289
 
261
290
  function rectToCommands(width, height, x, y, radius) {
@@ -274,9 +303,11 @@ function rectToCommands(width, height, x, y, radius) {
274
303
  */
275
304
 
276
305
 
277
- export function convertToPath(object) {
278
- var localTransform = object.getLocalTransform();
279
- var anchor = object.style.anchor;
306
+ export function convertToPath(object, applyLocalTransform) {
307
+ if (applyLocalTransform === void 0) {
308
+ applyLocalTransform = true;
309
+ }
310
+
280
311
  var commands = [];
281
312
 
282
313
  switch (object.nodeName) {
@@ -293,9 +324,9 @@ export function convertToPath(object) {
293
324
  {
294
325
  var _b = object.parsedStyle,
295
326
  r = _b.r,
296
- x_1 = _b.x,
297
- y_1 = _b.y;
298
- commands = ellipseToCommands(r.value, r.value, x_1.value, y_1.value);
327
+ cx = _b.cx,
328
+ cy = _b.cy;
329
+ commands = ellipseToCommands(r.value, r.value, cx.value, cy.value);
299
330
  break;
300
331
  }
301
332
 
@@ -304,16 +335,16 @@ export function convertToPath(object) {
304
335
  var _c = object.parsedStyle,
305
336
  rx = _c.rx,
306
337
  ry = _c.ry,
307
- x_2 = _c.x,
308
- y_2 = _c.y;
309
- commands = ellipseToCommands(rx.value, ry.value, x_2.value, y_2.value);
338
+ cx = _c.cx,
339
+ cy = _c.cy;
340
+ commands = ellipseToCommands(rx.value, ry.value, cx.value, cy.value);
310
341
  break;
311
342
  }
312
343
 
313
344
  case Shape.POLYLINE:
314
345
  case Shape.POLYGON:
315
346
  var points = object.parsedStyle.points;
316
- commands = polygonToCommands(points.points);
347
+ commands = polygonToCommands(points.points, object.nodeName === Shape.POLYGON);
317
348
  break;
318
349
 
319
350
  case Shape.RECT:
@@ -327,11 +358,17 @@ export function convertToPath(object) {
327
358
  break;
328
359
 
329
360
  case Shape.PATH:
330
- commands = object.parsedStyle.path.curve;
361
+ var _e = object.parsedStyle.path,
362
+ curve = _e.curve,
363
+ zCommandIndexes = _e.zCommandIndexes;
364
+ commands = __spreadArray([], __read(curve), false);
365
+ zCommandIndexes.forEach(function (zIndex, index) {
366
+ commands.splice(zIndex + index, 1, ['Z']);
367
+ });
331
368
  break;
332
369
  }
333
370
 
334
371
  if (commands.length) {
335
- return commandsToPathString(commands, localTransform, anchor, object.parsedStyle);
372
+ return commandsToPathString(commands, object, applyLocalTransform);
336
373
  }
337
374
  }
package/lib/Canvas.js CHANGED
@@ -116,6 +116,8 @@ function (_super) {
116
116
  /**
117
117
  * limits query
118
118
  */
119
+ // the following feature-detect from hammer.js
120
+ // @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
119
121
 
120
122
  _this.supportTouchEvent = supportTouchEvent !== null && supportTouchEvent !== void 0 ? supportTouchEvent : 'ontouchstart' in globalThis;
121
123
  _this.supportPointerEvent = supportPointerEvent !== null && supportPointerEvent !== void 0 ? supportPointerEvent : !!globalThis.PointerEvent;
@@ -1,8 +1,9 @@
1
+ import type { DisplayObject } from '../display-objects';
1
2
  import type { IElement } from '../dom';
2
3
  import type { StyleValueRegistry } from './interfaces';
3
4
  export declare type Interpolatable = number | boolean | number[] | boolean[];
4
5
  declare type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
5
- declare type CSSPropertyParser<Parsed> = (value: string | any) => Parsed;
6
+ declare type CSSPropertyParser<Parsed> = (value: string | any, object: DisplayObject) => Parsed;
6
7
  declare type CSSPropertyCalculator<Parsed, Used> = (name: string, oldParsed: Parsed, parsed: Parsed, object: IElement, registry: StyleValueRegistry) => Used;
7
8
  /**
8
9
  * 1. parser: raw CSS string -> Computed Value
@@ -14,6 +14,7 @@ export declare const PropertySyntax: {
14
14
  LENGTH: string;
15
15
  PERCENTAGE: string;
16
16
  LENGTH_PERCENTAGE: string;
17
+ LIST_OF_POINTS: string;
17
18
  };
18
19
  export interface PropertyMetadata {
19
20
  name: string;
@@ -99,7 +100,7 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
99
100
  /**
100
101
  * string -> parsed value
101
102
  */
102
- parseProperty(name: string, value: any): CSSStyleValue;
103
+ parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
103
104
  /**
104
105
  * computed value -> used value
105
106
  */