@antv/g 5.0.14 → 5.0.17

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 (305) hide show
  1. package/es/AbstractRenderer.js +1 -3
  2. package/es/Canvas.d.ts +3 -0
  3. package/es/Canvas.js +10 -12
  4. package/es/DisplayObjectPool.js +1 -3
  5. package/es/camera/Camera.d.ts +3 -2
  6. package/es/camera/Camera.js +17 -11
  7. package/es/camera/Landmark.js +1 -3
  8. package/es/canvas-module.js +11 -17
  9. package/es/components/Cullable.js +1 -3
  10. package/es/components/Geometry.js +1 -3
  11. package/es/components/Renderable.js +1 -3
  12. package/es/components/Sortable.js +1 -3
  13. package/es/components/Transform.d.ts +0 -1
  14. package/es/components/Transform.js +1 -4
  15. package/es/display-objects/Circle.d.ts +4 -2
  16. package/es/display-objects/Circle.js +9 -6
  17. package/es/display-objects/CustomElement.d.ts +3 -2
  18. package/es/display-objects/CustomElement.js +10 -9
  19. package/es/display-objects/DisplayObject.d.ts +9 -3
  20. package/es/display-objects/DisplayObject.js +98 -50
  21. package/es/display-objects/Ellipse.d.ts +6 -3
  22. package/es/display-objects/Ellipse.js +9 -6
  23. package/es/display-objects/Group.d.ts +18 -2
  24. package/es/display-objects/Group.js +15 -12
  25. package/es/display-objects/HTML.d.ts +6 -1
  26. package/es/display-objects/HTML.js +8 -6
  27. package/es/display-objects/Image.d.ts +12 -7
  28. package/es/display-objects/Image.js +11 -6
  29. package/es/display-objects/Line.d.ts +1 -1
  30. package/es/display-objects/Line.js +13 -7
  31. package/es/display-objects/Path.d.ts +3 -2
  32. package/es/display-objects/Path.js +11 -8
  33. package/es/display-objects/Polygon.d.ts +1 -1
  34. package/es/display-objects/Polygon.js +10 -6
  35. package/es/display-objects/Polyline.d.ts +1 -1
  36. package/es/display-objects/Polyline.js +11 -8
  37. package/es/display-objects/Rect.d.ts +8 -5
  38. package/es/display-objects/Rect.js +10 -7
  39. package/es/display-objects/TSpan.d.ts +1 -0
  40. package/es/display-objects/TSpan.js +0 -0
  41. package/es/display-objects/Text.d.ts +32 -4
  42. package/es/display-objects/Text.js +71 -14
  43. package/es/dom/Animation.js +2 -4
  44. package/es/dom/AnimationEffectTiming.js +1 -3
  45. package/es/dom/AnimationEvent.js +1 -3
  46. package/es/dom/AnimationTimeline.js +2 -5
  47. package/es/dom/CustomElementRegistry.js +13 -15
  48. package/es/dom/CustomEvent.js +1 -3
  49. package/es/dom/Document.d.ts +2 -1
  50. package/es/dom/Document.js +23 -5
  51. package/es/dom/Element.d.ts +36 -9
  52. package/es/dom/Element.js +103 -15
  53. package/es/dom/EventTarget.d.ts +2 -2
  54. package/es/dom/EventTarget.js +3 -4
  55. package/es/dom/FederatedEvent.d.ts +5 -2
  56. package/es/dom/FederatedEvent.js +1 -3
  57. package/es/dom/FederatedMouseEvent.js +1 -3
  58. package/es/dom/FederatedPointerEvent.js +1 -3
  59. package/es/dom/FederatedWheelEvent.js +1 -3
  60. package/es/dom/KeyframeEffect.js +1 -3
  61. package/es/dom/MutationEvent.d.ts +15 -0
  62. package/es/dom/MutationEvent.js +27 -0
  63. package/es/dom/MutationObserver.d.ts +36 -0
  64. package/es/dom/MutationObserver.js +406 -0
  65. package/es/dom/MutationRecord.d.ts +14 -0
  66. package/es/dom/MutationRecord.js +29 -0
  67. package/es/dom/Node.d.ts +35 -3
  68. package/es/dom/Node.js +185 -20
  69. package/es/dom/index.d.ts +3 -0
  70. package/es/dom/index.js +3 -0
  71. package/es/dom/interfaces.d.ts +36 -8
  72. package/es/dom/interfaces.js +23 -5
  73. package/es/global-module.d.ts +4 -1
  74. package/es/global-module.js +36 -79
  75. package/es/index.d.ts +1 -0
  76. package/es/index.js +1 -0
  77. package/es/plugins/CullingPlugin.d.ts +0 -2
  78. package/es/plugins/CullingPlugin.js +4 -27
  79. package/es/plugins/DirtyCheckPlugin.js +3 -5
  80. package/es/plugins/EventPlugin.d.ts +2 -1
  81. package/es/plugins/EventPlugin.js +16 -8
  82. package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
  83. package/es/plugins/FrustumCullingStrategy.js +40 -35
  84. package/es/plugins/PrepareRendererPlugin.js +22 -8
  85. package/es/property-handlers/aabb.js +22 -24
  86. package/es/property-handlers/anchor.js +2 -1
  87. package/es/property-handlers/color.js +3 -0
  88. package/es/property-handlers/dimension.d.ts +15 -2
  89. package/es/property-handlers/dimension.js +77 -8
  90. package/es/property-handlers/index.d.ts +3 -0
  91. package/es/property-handlers/index.js +4 -1
  92. package/es/property-handlers/inherit.d.ts +6 -0
  93. package/es/property-handlers/inherit.js +25 -0
  94. package/es/property-handlers/interfaces.d.ts +2 -2
  95. package/es/property-handlers/lineDash.d.ts +6 -1
  96. package/es/property-handlers/lineDash.js +23 -4
  97. package/es/property-handlers/offsetDistance.js +2 -2
  98. package/es/property-handlers/path.d.ts +1 -1
  99. package/es/property-handlers/text.d.ts +2 -0
  100. package/es/property-handlers/text.js +3 -0
  101. package/es/property-handlers/textTransform.d.ts +6 -0
  102. package/es/property-handlers/textTransform.js +19 -0
  103. package/es/services/EventService.js +2 -6
  104. package/es/services/RenderingContext.d.ts +5 -8
  105. package/es/services/RenderingContext.js +6 -7
  106. package/es/services/RenderingService.js +3 -11
  107. package/es/services/SceneGraphSelector.d.ts +3 -2
  108. package/es/services/SceneGraphSelector.js +9 -7
  109. package/es/services/SceneGraphService.d.ts +7 -14
  110. package/es/services/SceneGraphService.js +15 -85
  111. package/es/services/aabb/CircleUpdater.d.ts +2 -2
  112. package/es/services/aabb/CircleUpdater.js +22 -14
  113. package/es/services/aabb/EllipseUpdater.d.ts +2 -2
  114. package/es/services/aabb/EllipseUpdater.js +29 -16
  115. package/es/services/aabb/LineUpdater.js +3 -5
  116. package/es/services/aabb/PathUpdater.js +3 -5
  117. package/es/services/aabb/PolylineUpdater.js +4 -6
  118. package/es/services/aabb/RectUpdater.d.ts +2 -2
  119. package/es/services/aabb/RectUpdater.js +32 -21
  120. package/es/services/aabb/TextUpdater.js +20 -13
  121. package/es/services/text/OffscreenCanvasCreator.js +1 -3
  122. package/es/services/text/index.js +18 -22
  123. package/es/shapes/AABB.d.ts +1 -0
  124. package/es/shapes/AABB.js +9 -3
  125. package/es/shapes/BoundingSphere.js +1 -3
  126. package/es/shapes/Frustum.js +1 -3
  127. package/es/shapes/Plane.js +1 -3
  128. package/es/shapes/Point.js +1 -3
  129. package/es/shapes/Polygon.js +1 -3
  130. package/es/shapes/Ray.js +1 -3
  131. package/es/shapes/Rect.js +1 -3
  132. package/es/shapes/Rectangle.js +1 -3
  133. package/es/types.d.ts +48 -26
  134. package/es/types.js +50 -31
  135. package/es/utils/animation.js +1 -1
  136. package/es/utils/event.js +5 -3
  137. package/es/utils/index.d.ts +1 -0
  138. package/es/utils/index.js +2 -1
  139. package/es/utils/interpolation.d.ts +1 -0
  140. package/es/utils/interpolation.js +41 -8
  141. package/es/utils/path.d.ts +1 -1
  142. package/es/utils/path.js +13 -13
  143. package/es/utils/raf.d.ts +1 -1
  144. package/es/utils/raf.js +0 -2
  145. package/es/utils/string.d.ts +1 -0
  146. package/es/utils/string.js +9 -0
  147. package/es/utils/text.js +1 -1
  148. package/lib/AbstractRenderer.js +1 -3
  149. package/lib/Canvas.d.ts +3 -0
  150. package/lib/Canvas.js +9 -11
  151. package/lib/DisplayObjectPool.js +1 -3
  152. package/lib/camera/Camera.d.ts +3 -2
  153. package/lib/camera/Camera.js +21 -13
  154. package/lib/camera/Landmark.js +1 -3
  155. package/lib/canvas-module.js +10 -15
  156. package/lib/components/Cullable.js +2 -4
  157. package/lib/components/Geometry.js +1 -3
  158. package/lib/components/Renderable.js +1 -3
  159. package/lib/components/Sortable.js +1 -3
  160. package/lib/components/Transform.d.ts +0 -1
  161. package/lib/components/Transform.js +1 -4
  162. package/lib/display-objects/Circle.d.ts +4 -2
  163. package/lib/display-objects/Circle.js +8 -5
  164. package/lib/display-objects/CustomElement.d.ts +3 -2
  165. package/lib/display-objects/CustomElement.js +10 -9
  166. package/lib/display-objects/DisplayObject.d.ts +9 -3
  167. package/lib/display-objects/DisplayObject.js +98 -47
  168. package/lib/display-objects/Ellipse.d.ts +6 -3
  169. package/lib/display-objects/Ellipse.js +8 -5
  170. package/lib/display-objects/Group.d.ts +18 -2
  171. package/lib/display-objects/Group.js +14 -12
  172. package/lib/display-objects/HTML.d.ts +6 -1
  173. package/lib/display-objects/HTML.js +7 -5
  174. package/lib/display-objects/Image.d.ts +12 -7
  175. package/lib/display-objects/Image.js +10 -5
  176. package/lib/display-objects/Line.d.ts +1 -1
  177. package/lib/display-objects/Line.js +12 -6
  178. package/lib/display-objects/Path.d.ts +3 -2
  179. package/lib/display-objects/Path.js +10 -7
  180. package/lib/display-objects/Polygon.d.ts +1 -1
  181. package/lib/display-objects/Polygon.js +9 -5
  182. package/lib/display-objects/Polyline.d.ts +1 -1
  183. package/lib/display-objects/Polyline.js +10 -7
  184. package/lib/display-objects/Rect.d.ts +8 -5
  185. package/lib/display-objects/Rect.js +9 -6
  186. package/lib/display-objects/TSpan.d.ts +1 -0
  187. package/lib/display-objects/TSpan.js +1 -0
  188. package/lib/display-objects/Text.d.ts +32 -4
  189. package/lib/display-objects/Text.js +71 -13
  190. package/lib/dom/Animation.js +2 -4
  191. package/lib/dom/AnimationEffectTiming.js +1 -3
  192. package/lib/dom/AnimationEvent.js +1 -3
  193. package/lib/dom/AnimationTimeline.js +3 -6
  194. package/lib/dom/CustomElementRegistry.js +12 -14
  195. package/lib/dom/CustomEvent.js +1 -3
  196. package/lib/dom/Document.d.ts +2 -1
  197. package/lib/dom/Document.js +25 -6
  198. package/lib/dom/Element.d.ts +36 -9
  199. package/lib/dom/Element.js +105 -15
  200. package/lib/dom/EventTarget.d.ts +2 -2
  201. package/lib/dom/EventTarget.js +3 -4
  202. package/lib/dom/FederatedEvent.d.ts +5 -2
  203. package/lib/dom/FederatedEvent.js +1 -3
  204. package/lib/dom/FederatedMouseEvent.js +1 -3
  205. package/lib/dom/FederatedPointerEvent.js +1 -3
  206. package/lib/dom/FederatedWheelEvent.js +1 -3
  207. package/lib/dom/KeyframeEffect.js +2 -4
  208. package/lib/dom/MutationEvent.d.ts +15 -0
  209. package/lib/dom/MutationEvent.js +35 -0
  210. package/lib/dom/MutationObserver.d.ts +36 -0
  211. package/lib/dom/MutationObserver.js +417 -0
  212. package/lib/dom/MutationRecord.d.ts +14 -0
  213. package/lib/dom/MutationRecord.js +36 -0
  214. package/lib/dom/Node.d.ts +35 -3
  215. package/lib/dom/Node.js +186 -19
  216. package/lib/dom/index.d.ts +3 -0
  217. package/lib/dom/index.js +39 -0
  218. package/lib/dom/interfaces.d.ts +36 -8
  219. package/lib/dom/interfaces.js +23 -5
  220. package/lib/global-module.d.ts +4 -1
  221. package/lib/global-module.js +42 -76
  222. package/lib/index.d.ts +1 -0
  223. package/lib/index.js +2 -0
  224. package/lib/plugins/CullingPlugin.d.ts +0 -2
  225. package/lib/plugins/CullingPlugin.js +4 -27
  226. package/lib/plugins/DirtyCheckPlugin.js +2 -4
  227. package/lib/plugins/EventPlugin.d.ts +2 -1
  228. package/lib/plugins/EventPlugin.js +14 -8
  229. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
  230. package/lib/plugins/FrustumCullingStrategy.js +41 -35
  231. package/lib/plugins/PrepareRendererPlugin.js +25 -7
  232. package/lib/property-handlers/aabb.js +21 -23
  233. package/lib/property-handlers/anchor.js +3 -1
  234. package/lib/property-handlers/color.js +5 -2
  235. package/lib/property-handlers/dimension.d.ts +15 -2
  236. package/lib/property-handlers/dimension.js +84 -12
  237. package/lib/property-handlers/index.d.ts +3 -0
  238. package/lib/property-handlers/index.js +39 -0
  239. package/lib/property-handlers/inherit.d.ts +6 -0
  240. package/lib/property-handlers/inherit.js +34 -0
  241. package/lib/property-handlers/interfaces.d.ts +2 -2
  242. package/lib/property-handlers/interfaces.js +1 -1
  243. package/lib/property-handlers/lineDash.d.ts +6 -1
  244. package/lib/property-handlers/lineDash.js +25 -4
  245. package/lib/property-handlers/numeric.js +3 -3
  246. package/lib/property-handlers/offsetDistance.js +1 -1
  247. package/lib/property-handlers/path.d.ts +1 -1
  248. package/lib/property-handlers/path.js +1 -1
  249. package/lib/property-handlers/text.d.ts +2 -0
  250. package/lib/property-handlers/text.js +10 -0
  251. package/lib/property-handlers/textTransform.d.ts +6 -0
  252. package/lib/property-handlers/textTransform.js +27 -0
  253. package/lib/property-handlers/transform.js +1 -1
  254. package/lib/services/EventService.js +2 -6
  255. package/lib/services/RenderingContext.d.ts +5 -8
  256. package/lib/services/RenderingContext.js +8 -9
  257. package/lib/services/RenderingService.js +2 -10
  258. package/lib/services/SceneGraphSelector.d.ts +3 -2
  259. package/lib/services/SceneGraphSelector.js +12 -7
  260. package/lib/services/SceneGraphService.d.ts +7 -14
  261. package/lib/services/SceneGraphService.js +18 -87
  262. package/lib/services/aabb/CircleUpdater.d.ts +2 -2
  263. package/lib/services/aabb/CircleUpdater.js +21 -13
  264. package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
  265. package/lib/services/aabb/EllipseUpdater.js +28 -15
  266. package/lib/services/aabb/LineUpdater.js +2 -4
  267. package/lib/services/aabb/PathUpdater.js +2 -4
  268. package/lib/services/aabb/PolylineUpdater.js +3 -5
  269. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  270. package/lib/services/aabb/RectUpdater.js +31 -20
  271. package/lib/services/aabb/TextUpdater.js +19 -12
  272. package/lib/services/aabb/index.js +10 -10
  273. package/lib/services/aabb/interfaces.js +1 -1
  274. package/lib/services/text/OffscreenCanvasCreator.js +1 -3
  275. package/lib/services/text/index.js +18 -22
  276. package/lib/shapes/AABB.d.ts +1 -0
  277. package/lib/shapes/AABB.js +9 -3
  278. package/lib/shapes/BoundingSphere.js +1 -3
  279. package/lib/shapes/Frustum.js +2 -4
  280. package/lib/shapes/Plane.js +1 -3
  281. package/lib/shapes/Point.js +1 -3
  282. package/lib/shapes/Polygon.js +1 -3
  283. package/lib/shapes/Ray.js +1 -3
  284. package/lib/shapes/Rect.js +1 -3
  285. package/lib/shapes/Rectangle.js +1 -3
  286. package/lib/types.d.ts +48 -26
  287. package/lib/types.js +56 -35
  288. package/lib/utils/animation.js +3 -4
  289. package/lib/utils/bezier-easing.js +1 -1
  290. package/lib/utils/custom-easing.js +1 -1
  291. package/lib/utils/event.js +7 -6
  292. package/lib/utils/index.d.ts +1 -0
  293. package/lib/utils/index.js +13 -0
  294. package/lib/utils/interpolation.d.ts +1 -0
  295. package/lib/utils/interpolation.js +43 -7
  296. package/lib/utils/math.js +5 -5
  297. package/lib/utils/path.d.ts +1 -1
  298. package/lib/utils/path.js +15 -15
  299. package/lib/utils/raf.d.ts +1 -1
  300. package/lib/utils/raf.js +1 -4
  301. package/lib/utils/string.d.ts +1 -0
  302. package/lib/utils/string.js +16 -0
  303. package/lib/utils/text.js +1 -1
  304. package/package.json +6 -4
  305. package/dist/index.umd.min.js +0 -15
@@ -1,25 +1,38 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
- import { SHAPE } from '../../types';
4
+ import { Shape } from '../../types';
5
5
 
6
- var EllipseUpdater =
7
- /** @class */
8
- function () {
6
+ var EllipseUpdater = function () {
9
7
  function EllipseUpdater() {}
10
8
 
11
- EllipseUpdater.prototype.update = function (parsedStyle) {
12
- var _a = parsedStyle.rx,
13
- rx = _a === void 0 ? 0 : _a,
14
- _b = parsedStyle.ry,
15
- ry = _b === void 0 ? 0 : _b,
16
- _c = parsedStyle.x,
17
- x = _c === void 0 ? 0 : _c,
18
- _d = parsedStyle.y,
19
- y = _d === void 0 ? 0 : _d;
9
+ EllipseUpdater.prototype.update = function (parsedStyle, object) {
10
+ var rx = parsedStyle.rx,
11
+ ry = parsedStyle.ry,
12
+ _a = parsedStyle.x,
13
+ x = _a === void 0 ? 0 : _a,
14
+ _b = parsedStyle.y,
15
+ y = _b === void 0 ? 0 : _b;
16
+ var rxUnit = rx.unit,
17
+ rxValue = rx.value;
18
+ var ryUnit = ry.unit,
19
+ ryValue = ry.value;
20
+ var width = 0;
21
+ var height = 0;
22
+
23
+ if (rxUnit === '' || rxUnit === 'px') {
24
+ width = rxValue * 2;
25
+ }
26
+
27
+ if (ryUnit === '' || ryUnit === 'px') {
28
+ height = ryValue * 2;
29
+ }
30
+
31
+ object.parsedStyle.rxInPixels = width / 2;
32
+ object.parsedStyle.ryInPixels = height / 2;
20
33
  return {
21
- width: rx * 2,
22
- height: ry * 2,
34
+ width: width,
35
+ height: height,
23
36
  x: x,
24
37
  y: y
25
38
  };
@@ -28,7 +41,7 @@ function () {
28
41
  EllipseUpdater = __decorate([singleton({
29
42
  token: {
30
43
  token: GeometryAABBUpdater,
31
- named: SHAPE.Ellipse
44
+ named: Shape.ELLIPSE
32
45
  }
33
46
  })], EllipseUpdater);
34
47
  return EllipseUpdater;
@@ -1,11 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
- import { SHAPE } from '../../types';
4
+ import { Shape } from '../../types';
5
5
 
6
- var LineUpdater =
7
- /** @class */
8
- function () {
6
+ var LineUpdater = function () {
9
7
  function LineUpdater() {}
10
8
 
11
9
  LineUpdater.prototype.update = function (parsedStyle) {
@@ -30,7 +28,7 @@ function () {
30
28
  LineUpdater = __decorate([singleton({
31
29
  token: {
32
30
  token: GeometryAABBUpdater,
33
- named: SHAPE.Line
31
+ named: Shape.LINE
34
32
  }
35
33
  })], LineUpdater);
36
34
  return LineUpdater;
@@ -1,11 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
- import { SHAPE } from '../../types';
4
+ import { Shape } from '../../types';
5
5
 
6
- var PathUpdater =
7
- /** @class */
8
- function () {
6
+ var PathUpdater = function () {
9
7
  function PathUpdater() {}
10
8
 
11
9
  PathUpdater.prototype.update = function (parsedStyle) {
@@ -26,7 +24,7 @@ function () {
26
24
  PathUpdater = __decorate([singleton({
27
25
  token: {
28
26
  token: GeometryAABBUpdater,
29
- named: SHAPE.Path
27
+ named: Shape.PATH
30
28
  }
31
29
  })], PathUpdater);
32
30
  return PathUpdater;
@@ -1,11 +1,9 @@
1
1
  import { __decorate, __read, __spreadArray } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
- import { SHAPE } from '../../types';
4
+ import { Shape } from '../../types';
5
5
 
6
- var PolylineUpdater =
7
- /** @class */
8
- function () {
6
+ var PolylineUpdater = function () {
9
7
  function PolylineUpdater() {}
10
8
 
11
9
  PolylineUpdater.prototype.update = function (parsedStyle) {
@@ -36,10 +34,10 @@ function () {
36
34
  PolylineUpdater = __decorate([singleton({
37
35
  token: [{
38
36
  token: GeometryAABBUpdater,
39
- named: SHAPE.Polyline
37
+ named: Shape.POLYLINE
40
38
  }, {
41
39
  token: GeometryAABBUpdater,
42
- named: SHAPE.Polygon
40
+ named: Shape.POLYGON
43
41
  }]
44
42
  })], PolylineUpdater);
45
43
  return PolylineUpdater;
@@ -1,7 +1,7 @@
1
1
  import { GeometryAABBUpdater } from './interfaces';
2
- import type { ParsedImageStyleProps } from '../../display-objects/Image';
2
+ import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
3
3
  export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
4
- update(attributes: ParsedImageStyleProps): {
4
+ update(parsedStyle: ParsedImageStyleProps, object: Image): {
5
5
  width: number;
6
6
  height: number;
7
7
  x: number;
@@ -2,39 +2,50 @@ import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
  import { isString } from '@antv/util';
4
4
  import { GeometryAABBUpdater } from './interfaces';
5
- import { SHAPE } from '../../types';
5
+ import { Shape } from '../../types';
6
6
 
7
- var RectUpdater =
8
- /** @class */
9
- function () {
7
+ var RectUpdater = function () {
10
8
  function RectUpdater() {}
11
9
 
12
- RectUpdater.prototype.update = function (attributes) {
13
- var img = attributes.img,
14
- _a = attributes.x,
10
+ RectUpdater.prototype.update = function (parsedStyle, object) {
11
+ var img = parsedStyle.img,
12
+ _a = parsedStyle.x,
15
13
  x = _a === void 0 ? 0 : _a,
16
- _b = attributes.y,
14
+ _b = parsedStyle.y,
17
15
  y = _b === void 0 ? 0 : _b,
18
- _c = attributes.width,
19
- width = _c === void 0 ? 0 : _c,
20
- _d = attributes.height,
21
- height = _d === void 0 ? 0 : _d;
22
- var contentWidth;
23
- var contentHeight; // resize with HTMLImageElement's size
16
+ width = parsedStyle.width,
17
+ height = parsedStyle.height;
18
+ var contentWidth = 0;
19
+ var contentHeight = 0;
20
+ var widthUnit = width.unit,
21
+ widthValue = width.value;
22
+ var heightUnit = height.unit,
23
+ heightValue = height.value;
24
+
25
+ if (widthUnit === '' || widthUnit === 'px') {
26
+ contentWidth = widthValue;
27
+ }
28
+
29
+ if (heightUnit === '' || heightUnit === 'px') {
30
+ contentHeight = heightValue;
31
+ } // resize with HTMLImageElement's size
32
+
24
33
 
25
34
  if (img && !isString(img)) {
26
- if (!attributes.width) {
35
+ if (!contentWidth) {
27
36
  contentWidth = img.width;
28
37
  }
29
38
 
30
- if (!attributes.height) {
39
+ if (!contentHeight) {
31
40
  contentHeight = img.height;
32
41
  }
33
42
  }
34
43
 
44
+ object.parsedStyle.widthInPixels = contentWidth;
45
+ object.parsedStyle.heightInPixels = contentHeight;
35
46
  return {
36
- width: contentWidth || width,
37
- height: contentHeight || height,
47
+ width: contentWidth,
48
+ height: contentHeight,
38
49
  x: x,
39
50
  y: y
40
51
  };
@@ -43,13 +54,13 @@ function () {
43
54
  RectUpdater = __decorate([singleton({
44
55
  token: [{
45
56
  token: GeometryAABBUpdater,
46
- named: SHAPE.Rect
57
+ named: Shape.RECT
47
58
  }, {
48
59
  token: GeometryAABBUpdater,
49
- named: SHAPE.Image
60
+ named: Shape.IMAGE
50
61
  }, {
51
62
  token: GeometryAABBUpdater,
52
- named: SHAPE.Group
63
+ named: Shape.GROUP
53
64
  }]
54
65
  })], RectUpdater);
55
66
  return RectUpdater;
@@ -3,24 +3,23 @@ import { vec3 } from 'gl-matrix';
3
3
  import { singleton, inject } from 'mana-syringe';
4
4
  import { GeometryAABBUpdater } from './interfaces';
5
5
  import { TextService } from '../text';
6
- import { SHAPE } from '../../types';
6
+ import { Shape } from '../../types';
7
7
 
8
- var TextUpdater =
9
- /** @class */
10
- function () {
8
+ var TextUpdater = function () {
11
9
  function TextUpdater() {}
12
10
 
13
11
  TextUpdater.prototype.update = function (parsedStyle) {
14
12
  var _a = parsedStyle.text,
15
13
  text = _a === void 0 ? '' : _a,
16
14
  textAlign = parsedStyle.textAlign,
17
- _b = parsedStyle.lineWidth,
18
- lineWidth = _b === void 0 ? 0 : _b,
15
+ lineWidth = parsedStyle.lineWidth,
19
16
  textBaseline = parsedStyle.textBaseline,
20
- _c = parsedStyle.x,
21
- x = _c === void 0 ? 0 : _c,
22
- _d = parsedStyle.y,
23
- y = _d === void 0 ? 0 : _d;
17
+ _b = parsedStyle.x,
18
+ x = _b === void 0 ? 0 : _b,
19
+ _c = parsedStyle.y,
20
+ y = _c === void 0 ? 0 : _c,
21
+ dx = parsedStyle.dx,
22
+ dy = parsedStyle.dy;
24
23
  var metrics = this.textService.measureText(text, parsedStyle);
25
24
  parsedStyle.metrics = metrics;
26
25
  var width = metrics.width,
@@ -34,10 +33,10 @@ function () {
34
33
  var lineXOffset = 0;
35
34
 
36
35
  if (textAlign === 'center') {
37
- lineXOffset = lineWidth / 2;
36
+ lineXOffset = lineWidth.value / 2;
38
37
  anchor = [0.5, 1];
39
38
  } else if (textAlign === 'right' || textAlign === 'end') {
40
- lineXOffset = lineWidth;
39
+ lineXOffset = lineWidth.value;
41
40
  anchor = [1, 1];
42
41
  } // update anchor
43
42
 
@@ -57,6 +56,14 @@ function () {
57
56
  } // TODO: ideographic & bottom
58
57
 
59
58
 
59
+ if (dx && dx.unit === 'px') {
60
+ lineXOffset += dx.value;
61
+ }
62
+
63
+ if (dy && dy.unit === 'px') {
64
+ lineYOffset += dy.value;
65
+ }
66
+
60
67
  return {
61
68
  width: halfExtents[0] * 2,
62
69
  height: halfExtents[1] * 2,
@@ -72,7 +79,7 @@ function () {
72
79
  TextUpdater = __decorate([singleton({
73
80
  token: {
74
81
  token: GeometryAABBUpdater,
75
- named: SHAPE.Text
82
+ named: Shape.TEXT
76
83
  }
77
84
  })], TextUpdater);
78
85
  return TextUpdater;
@@ -1,9 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
 
4
- var OffscreenCanvasCreator =
5
- /** @class */
6
- function () {
4
+ var OffscreenCanvasCreator = function () {
7
5
  function OffscreenCanvasCreator() {}
8
6
 
9
7
  OffscreenCanvasCreator.prototype.getOrCreateCanvas = function () {
@@ -27,9 +27,7 @@ var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
27
27
  var regexCannotStart = new RegExp(regexCannotStartZhCn.source + "|" + regexCannotStartZhTw.source + "|" + regexCannotStartJaJp.source + "|" + regexCannotStartKoKr.source);
28
28
  var regexCannotEnd = new RegExp(regexCannotEndZhCn.source + "|" + regexCannotEndZhTw.source + "|" + regexCannotEndJaJp.source + "|" + regexCannotEndKoKr.source);
29
29
 
30
- var TextService =
31
- /** @class */
32
- function () {
30
+ var TextService = function () {
33
31
  function TextService() {
34
32
  var _this = this;
35
33
 
@@ -93,7 +91,7 @@ function () {
93
91
  context.textBaseline = 'alphabetic';
94
92
  context.fillStyle = '#000';
95
93
  context.fillText(metricsString, 0, baseline);
96
- var imagedata = context.getImageData(0, 0, width, height).data;
94
+ var imagedata = context.getImageData(0, 0, width || 1, height || 1).data;
97
95
  var pixels = imagedata.length;
98
96
  var line = width * 4;
99
97
  var i = 0;
@@ -141,29 +139,27 @@ function () {
141
139
  };
142
140
 
143
141
  TextService.prototype.measureText = function (text, attributes) {
144
- var _a = attributes.fontSize,
145
- fontSize = _a === void 0 ? 0 : _a,
142
+ var fontSize = attributes.fontSize,
146
143
  wordWrap = attributes.wordWrap,
147
- _b = attributes.lineHeight,
148
- strokeHeight = _b === void 0 ? 0 : _b,
149
- _c = attributes.lineWidth,
150
- lineWidth = _c === void 0 ? 0 : _c,
144
+ _a = attributes.lineHeight,
145
+ strokeHeight = _a === void 0 ? 0 : _a,
146
+ lineWidth = attributes.lineWidth,
151
147
  textBaseline = attributes.textBaseline,
152
148
  textAlign = attributes.textAlign,
153
- _d = attributes.letterSpacing,
154
- letterSpacing = _d === void 0 ? 0 : _d,
149
+ _b = attributes.letterSpacing,
150
+ letterSpacing = _b === void 0 ? 0 : _b,
155
151
  dropShadow = attributes.dropShadow,
156
- _e = attributes.dropShadowDistance,
157
- dropShadowDistance = _e === void 0 ? 0 : _e,
158
- _f = attributes.leading,
159
- leading = _f === void 0 ? 0 : _f;
152
+ _c = attributes.dropShadowDistance,
153
+ dropShadowDistance = _c === void 0 ? 0 : _c,
154
+ _d = attributes.leading,
155
+ leading = _d === void 0 ? 0 : _d;
160
156
  var font = toFontString(attributes);
161
157
  var fontProperties = this.measureFont(font); // fallback in case UA disallow canvas data extraction
162
158
  // (toDataURI, getImageData functions)
163
159
 
164
160
  if (fontProperties.fontSize === 0) {
165
- fontProperties.fontSize = fontSize;
166
- fontProperties.ascent = fontSize;
161
+ fontProperties.fontSize = fontSize.value;
162
+ fontProperties.ascent = fontSize.value;
167
163
  }
168
164
 
169
165
  var context = this.offscreenCanvas.getOrCreateContext();
@@ -179,14 +175,14 @@ function () {
179
175
  maxLineWidth = Math.max(maxLineWidth, lineWidth_1);
180
176
  }
181
177
 
182
- var width = maxLineWidth + lineWidth;
178
+ var width = maxLineWidth + lineWidth.value;
183
179
 
184
180
  if (dropShadow) {
185
181
  width += dropShadowDistance;
186
182
  }
187
183
 
188
- var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth;
189
- var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth) + (lines.length - 1) * (lineHeight + leading);
184
+ var lineHeight = strokeHeight || fontProperties.fontSize + lineWidth.value;
185
+ var height = Math.max(lineHeight, fontProperties.fontSize + lineWidth.value) + (lines.length - 1) * (lineHeight + leading);
190
186
 
191
187
  if (dropShadow) {
192
188
  height += dropShadowDistance;
@@ -222,7 +218,7 @@ function () {
222
218
  offsetX -= width;
223
219
  }
224
220
 
225
- return new Rectangle(offsetX - lineWidth / 2, offsetY + i * lineHeight, width + lineWidth, lineHeight);
221
+ return new Rectangle(offsetX - lineWidth.value / 2, offsetY + i * lineHeight, width + lineWidth.value, lineHeight);
226
222
  })
227
223
  };
228
224
  };
@@ -7,6 +7,7 @@ import type { Plane } from './Plane';
7
7
  * @see https://github.com/antvis/GWebGPUEngine/issues/3
8
8
  */
9
9
  export declare class AABB {
10
+ static isEmpty(aabb: AABB): boolean;
10
11
  center: vec3;
11
12
  halfExtents: vec3;
12
13
  min: vec3;
package/es/shapes/AABB.js CHANGED
@@ -5,15 +5,17 @@ import { vec3 } from 'gl-matrix';
5
5
  * @see https://github.com/antvis/GWebGPUEngine/issues/3
6
6
  */
7
7
 
8
- var AABB =
9
- /** @class */
10
- function () {
8
+ var AABB = function () {
11
9
  function AABB(center, halfExtents) {
12
10
  this.min = vec3.create();
13
11
  this.max = vec3.create();
14
12
  this.update(center, halfExtents);
15
13
  }
16
14
 
15
+ AABB.isEmpty = function (aabb) {
16
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
17
+ };
18
+
17
19
  AABB.prototype.update = function (center, halfExtents) {
18
20
  this.center = vec3.copy(vec3.create(), center || vec3.create());
19
21
  this.halfExtents = vec3.copy(vec3.create(), halfExtents || vec3.fromValues(0, 0, 0));
@@ -39,6 +41,10 @@ function () {
39
41
  };
40
42
 
41
43
  AABB.prototype.add = function (aabb) {
44
+ if (AABB.isEmpty(aabb)) {
45
+ return;
46
+ }
47
+
42
48
  var tc = this.center;
43
49
  var tcx = tc[0];
44
50
  var tcy = tc[1];
@@ -1,9 +1,7 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
  var tmpVecA = vec3.create();
3
3
 
4
- var BoundingSphere =
5
- /** @class */
6
- function () {
4
+ var BoundingSphere = function () {
7
5
  function BoundingSphere(center, radius) {
8
6
  this.center = center || vec3.create();
9
7
  this.radius = radius || 0.5;
@@ -9,9 +9,7 @@ export var Mask;
9
9
  Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
10
10
  })(Mask || (Mask = {}));
11
11
 
12
- var Frustum =
13
- /** @class */
14
- function () {
12
+ var Frustum = function () {
15
13
  function Frustum(planes) {
16
14
  this.planes = [];
17
15
 
@@ -1,8 +1,6 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
 
3
- var Plane =
4
- /** @class */
5
- function () {
3
+ var Plane = function () {
6
4
  function Plane(distance, normal) {
7
5
  this.distance = distance || 0;
8
6
  this.normal = normal || vec3.fromValues(0, 1, 0);
@@ -1,6 +1,4 @@
1
- var Point =
2
- /** @class */
3
- function () {
1
+ var Point = function () {
4
2
  function Point(x, y) {
5
3
  if (x === void 0) {
6
4
  x = 0;
@@ -1,6 +1,4 @@
1
- var PolygonShape =
2
- /** @class */
3
- function () {
1
+ var PolygonShape = function () {
4
2
  function PolygonShape() {
5
3
  var points = [];
6
4
 
package/es/shapes/Ray.js CHANGED
@@ -11,9 +11,7 @@ var tmpVecE = vec3.create();
11
11
  * @see https://github.com/mrdoob/three.js/blob/dev/src/math/Ray.js
12
12
  */
13
13
 
14
- var Ray =
15
- /** @class */
16
- function () {
14
+ var Ray = function () {
17
15
  function Ray(origin, direction) {
18
16
  this.origin = origin || vec3.create();
19
17
  this.direction = direction || vec3.fromValues(0, 0, -1);
package/es/shapes/Rect.js CHANGED
@@ -1,6 +1,4 @@
1
- var Rect =
2
- /** @class */
3
- function () {
1
+ var Rect = function () {
4
2
  function Rect(x, y, width, height) {
5
3
  this.x = x;
6
4
  this.y = y;
@@ -1,6 +1,4 @@
1
- var Rectangle =
2
- /** @class */
3
- function () {
1
+ var Rectangle = function () {
4
2
  function Rectangle(x, y, width, height) {
5
3
  this.x = x;
6
4
  this.y = y;
package/es/types.d.ts CHANGED
@@ -2,19 +2,19 @@
2
2
  import type { vec2, vec3 } from 'gl-matrix';
3
3
  import type { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
4
4
  import type { DisplayObject } from './display-objects';
5
- import type { ParsedColorStyleProperty } from './property-handlers';
5
+ import type { ParsedColorStyleProperty, ParsedElement } from './property-handlers';
6
6
  import type { IRenderer } from './AbstractRenderer';
7
- export declare enum SHAPE {
8
- Group = "group",
9
- Circle = "circle",
10
- Ellipse = "ellipse",
11
- Image = "image",
12
- Rect = "rect",
13
- Line = "line",
14
- Polyline = "polyline",
15
- Polygon = "polygon",
16
- Text = "text",
17
- Path = "path",
7
+ export declare enum Shape {
8
+ GROUP = "g",
9
+ CIRCLE = "circle",
10
+ ELLIPSE = "ellipse",
11
+ IMAGE = "image",
12
+ RECT = "rect",
13
+ LINE = "line",
14
+ POLYLINE = "polyline",
15
+ POLYGON = "polygon",
16
+ TEXT = "text",
17
+ PATH = "path",
18
18
  HTML = "html"
19
19
  }
20
20
  declare type ColorType = string | null;
@@ -26,17 +26,31 @@ export interface EventPosition {
26
26
  x: number;
27
27
  y: number;
28
28
  }
29
- export declare enum LINE_CAP {
30
- Butt = "butt",
31
- Round = "round",
32
- Square = "square"
29
+ export declare enum LineCap {
30
+ BUTT = "butt",
31
+ ROUND = "round",
32
+ SQUARE = "square"
33
33
  }
34
- export declare enum LINE_JOIN {
35
- Bevel = "bevel",
36
- Round = "round",
37
- Miter = "miter"
34
+ export declare enum LineJoin {
35
+ BEVEL = "bevel",
36
+ ROUND = "round",
37
+ MITER = "miter"
38
+ }
39
+ export declare enum TextTransform {
40
+ CAPITALIZE = "capitalize",
41
+ UPPERCASE = "uppercase",
42
+ LOWERCASE = "lowercase",
43
+ NONE = "none"
44
+ }
45
+ export declare enum TextAlign {
46
+ START = "start",
47
+ CENTER = "center",
48
+ END = "end",
49
+ LEFT = "left",
50
+ RIGHT = "right"
38
51
  }
39
52
  export interface BaseStyleProps {
53
+ class?: string;
40
54
  /**
41
55
  * x in local space
42
56
  */
@@ -100,11 +114,11 @@ export interface BaseStyleProps {
100
114
  /** 整体透明度 */
101
115
  opacity?: number;
102
116
  /** 线宽 */
103
- lineWidth?: number;
117
+ lineWidth?: string | number;
104
118
  /** 指定如何绘制每一条线段末端 */
105
- lineCap?: LINE_CAP;
119
+ lineCap?: LineCap;
106
120
  /** 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略) */
107
- lineJoin?: LINE_JOIN;
121
+ lineJoin?: LineJoin;
108
122
  /**
109
123
  * 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数, 数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
110
124
  */
@@ -126,16 +140,23 @@ export interface BaseStyleProps {
126
140
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter
127
141
  */
128
142
  filter?: string;
143
+ /**
144
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
145
+ */
146
+ textTransform?: TextTransform;
147
+ /**
148
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit
149
+ */
150
+ miterLimit?: number;
129
151
  }
130
- export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points'> {
152
+ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'stroke' | 'path' | 'points' | 'lineWidth' | 'shadowColor'> {
131
153
  fill?: ParsedColorStyleProperty;
132
154
  stroke?: ParsedColorStyleProperty;
133
155
  path?: ParsedPathStyleProps;
134
156
  points?: ParsedPolylineStyleProps;
135
157
  x?: number;
136
158
  y?: number;
137
- width?: number;
138
- height?: number;
159
+ lineWidth?: ParsedElement;
139
160
  /**
140
161
  * x according to definition, eg. Line's x1/x2, Polyline's points
141
162
  */
@@ -146,6 +167,7 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
146
167
  */
147
168
  offsetX?: number;
148
169
  offsetY?: number;
170
+ shadowColor?: ParsedColorStyleProperty;
149
171
  }
150
172
  export declare type Cursor = 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'all-scroll' | 'col-resize' | 'row-resize' | 'n-resize' | 'e-resize' | 's-resize' | 'w-resize' | 'ne-resize' | 'nw-resize' | 'se-resize' | 'sw-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'zoom-in' | 'zoom-out';
151
173
  export interface RendererConfig {