@antv/l7-map 2.9.19 → 2.9.22-alpha.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 (223) hide show
  1. package/es/camera.js +115 -85
  2. package/es/css/l7.css +98 -0
  3. package/es/earthmap.js +27 -43
  4. package/es/geo/edge_insets.js +44 -14
  5. package/es/geo/lng_lat.js +15 -11
  6. package/es/geo/lng_lat_bounds.js +6 -10
  7. package/es/geo/mercator.js +24 -12
  8. package/es/geo/point.js +2 -8
  9. package/es/geo/simple.js +24 -12
  10. package/es/geo/transform.js +421 -120
  11. package/es/handler/IHandler.js +1 -2
  12. package/es/handler/blockable_map_event.js +13 -14
  13. package/es/handler/box_zoom.js +43 -27
  14. package/es/handler/click_zoom.js +3 -8
  15. package/es/handler/events/event.js +3 -6
  16. package/es/handler/events/index.js +4 -5
  17. package/es/handler/events/map_mouse_event.js +30 -20
  18. package/es/handler/events/map_touch_event.js +55 -25
  19. package/es/handler/events/map_wheel_event.js +24 -15
  20. package/es/handler/events/render_event.js +3 -6
  21. package/es/handler/handler_inertia.js +10 -12
  22. package/es/handler/handler_manager.js +75 -72
  23. package/es/handler/handler_util.js +2 -2
  24. package/es/handler/keyboard.js +20 -15
  25. package/es/handler/map_event.js +23 -12
  26. package/es/handler/mouse/index.js +4 -5
  27. package/es/handler/mouse/mouse_handler.js +17 -21
  28. package/es/handler/mouse/mousepan_handler.js +5 -5
  29. package/es/handler/mouse/mousepitch_hander.js +7 -5
  30. package/es/handler/mouse/mouserotate_hander.js +7 -5
  31. package/es/handler/mouse/util.js +3 -3
  32. package/es/handler/scroll_zoom.js +103 -67
  33. package/es/handler/shim/dblclick_zoom.js +35 -8
  34. package/es/handler/shim/drag_pan.js +48 -12
  35. package/es/handler/shim/drag_rotate.js +39 -10
  36. package/es/handler/shim/touch_zoom_rotate.js +59 -16
  37. package/es/handler/tap/single_tap_recognizer.js +7 -17
  38. package/es/handler/tap/tap_drag_zoom.js +5 -18
  39. package/es/handler/tap/tap_recognizer.js +4 -15
  40. package/es/handler/tap/tap_zoom.js +4 -13
  41. package/es/handler/touch/index.js +5 -6
  42. package/es/handler/touch/touch_pan.js +9 -20
  43. package/es/handler/touch/touch_pitch.js +11 -23
  44. package/es/handler/touch/touch_rotate.js +15 -18
  45. package/es/handler/touch/touch_zoom.js +5 -19
  46. package/es/handler/touch/two_touch.js +14 -21
  47. package/es/hash.js +28 -16
  48. package/es/index.js +2 -3
  49. package/es/interface.js +1 -2
  50. package/es/map.js +26 -47
  51. package/es/util.js +15 -6
  52. package/es/utils/Aabb.js +11 -12
  53. package/es/utils/dom.js +30 -11
  54. package/es/utils/performance.js +10 -6
  55. package/es/utils/primitives.js +11 -10
  56. package/es/utils/task_queue.js +6 -13
  57. package/lib/camera.js +508 -721
  58. package/lib/css/l7.css +98 -0
  59. package/lib/earthmap.js +222 -392
  60. package/lib/geo/edge_insets.js +64 -83
  61. package/lib/geo/lng_lat.js +65 -81
  62. package/lib/geo/lng_lat_bounds.js +124 -165
  63. package/lib/geo/mercator.js +62 -78
  64. package/lib/geo/point.js +171 -239
  65. package/lib/geo/simple.js +61 -80
  66. package/lib/geo/transform.js +470 -653
  67. package/lib/handler/IHandler.js +17 -2
  68. package/lib/handler/blockable_map_event.js +63 -83
  69. package/lib/handler/box_zoom.js +123 -176
  70. package/lib/handler/click_zoom.js +56 -68
  71. package/lib/handler/events/event.js +35 -23
  72. package/lib/handler/events/index.js +35 -29
  73. package/lib/handler/events/map_mouse_event.js +42 -72
  74. package/lib/handler/events/map_touch_event.js +45 -80
  75. package/lib/handler/events/map_wheel_event.js +34 -58
  76. package/lib/handler/events/render_event.js +31 -52
  77. package/lib/handler/handler_inertia.js +113 -160
  78. package/lib/handler/handler_manager.js +379 -620
  79. package/lib/handler/handler_util.js +28 -10
  80. package/lib/handler/keyboard.js +114 -146
  81. package/lib/handler/map_event.js +84 -120
  82. package/lib/handler/mouse/index.js +35 -29
  83. package/lib/handler/mouse/mouse_handler.js +90 -123
  84. package/lib/handler/mouse/mousepan_handler.js +46 -65
  85. package/lib/handler/mouse/mousepitch_hander.js +44 -63
  86. package/lib/handler/mouse/mouserotate_hander.js +44 -63
  87. package/lib/handler/mouse/util.js +38 -20
  88. package/lib/handler/scroll_zoom.js +175 -258
  89. package/lib/handler/shim/dblclick_zoom.js +42 -48
  90. package/lib/handler/shim/drag_pan.js +48 -59
  91. package/lib/handler/shim/drag_rotate.js +43 -51
  92. package/lib/handler/shim/touch_zoom_rotate.js +58 -78
  93. package/lib/handler/tap/single_tap_recognizer.js +84 -117
  94. package/lib/handler/tap/tap_drag_zoom.js +92 -115
  95. package/lib/handler/tap/tap_recognizer.js +60 -78
  96. package/lib/handler/tap/tap_zoom.js +88 -119
  97. package/lib/handler/touch/index.js +38 -37
  98. package/lib/handler/touch/touch_pan.js +98 -132
  99. package/lib/handler/touch/touch_pitch.js +73 -117
  100. package/lib/handler/touch/touch_rotate.js +58 -94
  101. package/lib/handler/touch/touch_zoom.js +49 -84
  102. package/lib/handler/touch/two_touch.js +88 -128
  103. package/lib/hash.js +100 -133
  104. package/lib/index.js +19 -31
  105. package/lib/interface.js +17 -2
  106. package/lib/map.js +238 -420
  107. package/lib/util.js +67 -78
  108. package/lib/utils/Aabb.js +80 -132
  109. package/lib/utils/dom.js +84 -141
  110. package/lib/utils/performance.js +54 -42
  111. package/lib/utils/primitives.js +59 -51
  112. package/lib/utils/task_queue.js +61 -108
  113. package/package.json +11 -8
  114. package/es/camera.js.map +0 -1
  115. package/es/earthmap.js.map +0 -1
  116. package/es/geo/edge_insets.js.map +0 -1
  117. package/es/geo/lng_lat.js.map +0 -1
  118. package/es/geo/lng_lat_bounds.js.map +0 -1
  119. package/es/geo/mercator.js.map +0 -1
  120. package/es/geo/point.js.map +0 -1
  121. package/es/geo/simple.js.map +0 -1
  122. package/es/geo/transform.js.map +0 -1
  123. package/es/handler/IHandler.js.map +0 -1
  124. package/es/handler/blockable_map_event.js.map +0 -1
  125. package/es/handler/box_zoom.js.map +0 -1
  126. package/es/handler/click_zoom.js.map +0 -1
  127. package/es/handler/events/event.js.map +0 -1
  128. package/es/handler/events/index.js.map +0 -1
  129. package/es/handler/events/map_mouse_event.js.map +0 -1
  130. package/es/handler/events/map_touch_event.js.map +0 -1
  131. package/es/handler/events/map_wheel_event.js.map +0 -1
  132. package/es/handler/events/render_event.js.map +0 -1
  133. package/es/handler/handler_inertia.js.map +0 -1
  134. package/es/handler/handler_manager.js.map +0 -1
  135. package/es/handler/handler_util.js.map +0 -1
  136. package/es/handler/keyboard.js.map +0 -1
  137. package/es/handler/map_event.js.map +0 -1
  138. package/es/handler/mouse/index.js.map +0 -1
  139. package/es/handler/mouse/mouse_handler.js.map +0 -1
  140. package/es/handler/mouse/mousepan_handler.js.map +0 -1
  141. package/es/handler/mouse/mousepitch_hander.js.map +0 -1
  142. package/es/handler/mouse/mouserotate_hander.js.map +0 -1
  143. package/es/handler/mouse/util.js.map +0 -1
  144. package/es/handler/scroll_zoom.js.map +0 -1
  145. package/es/handler/shim/dblclick_zoom.js.map +0 -1
  146. package/es/handler/shim/drag_pan.js.map +0 -1
  147. package/es/handler/shim/drag_rotate.js.map +0 -1
  148. package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
  149. package/es/handler/tap/single_tap_recognizer.js.map +0 -1
  150. package/es/handler/tap/tap_drag_zoom.js.map +0 -1
  151. package/es/handler/tap/tap_recognizer.js.map +0 -1
  152. package/es/handler/tap/tap_zoom.js.map +0 -1
  153. package/es/handler/touch/index.js.map +0 -1
  154. package/es/handler/touch/touch_pan.js.map +0 -1
  155. package/es/handler/touch/touch_pitch.js.map +0 -1
  156. package/es/handler/touch/touch_rotate.js.map +0 -1
  157. package/es/handler/touch/touch_zoom.js.map +0 -1
  158. package/es/handler/touch/two_touch.js.map +0 -1
  159. package/es/hash.js.map +0 -1
  160. package/es/index.js.map +0 -1
  161. package/es/interface.js.map +0 -1
  162. package/es/map.js.map +0 -1
  163. package/es/util.js.map +0 -1
  164. package/es/utils/Aabb.js.map +0 -1
  165. package/es/utils/dom.js.map +0 -1
  166. package/es/utils/performance.js.map +0 -1
  167. package/es/utils/primitives.js.map +0 -1
  168. package/es/utils/task_queue.js.map +0 -1
  169. package/lib/camera.js.map +0 -1
  170. package/lib/earthmap.js.map +0 -1
  171. package/lib/geo/edge_insets.js.map +0 -1
  172. package/lib/geo/lng_lat.js.map +0 -1
  173. package/lib/geo/lng_lat_bounds.js.map +0 -1
  174. package/lib/geo/mercator.js.map +0 -1
  175. package/lib/geo/point.js.map +0 -1
  176. package/lib/geo/simple.js.map +0 -1
  177. package/lib/geo/transform.js.map +0 -1
  178. package/lib/handler/IHandler.js.map +0 -1
  179. package/lib/handler/blockable_map_event.js.map +0 -1
  180. package/lib/handler/box_zoom.js.map +0 -1
  181. package/lib/handler/click_zoom.js.map +0 -1
  182. package/lib/handler/events/event.js.map +0 -1
  183. package/lib/handler/events/index.js.map +0 -1
  184. package/lib/handler/events/map_mouse_event.js.map +0 -1
  185. package/lib/handler/events/map_touch_event.js.map +0 -1
  186. package/lib/handler/events/map_wheel_event.js.map +0 -1
  187. package/lib/handler/events/render_event.js.map +0 -1
  188. package/lib/handler/handler_inertia.js.map +0 -1
  189. package/lib/handler/handler_manager.js.map +0 -1
  190. package/lib/handler/handler_util.js.map +0 -1
  191. package/lib/handler/keyboard.js.map +0 -1
  192. package/lib/handler/map_event.js.map +0 -1
  193. package/lib/handler/mouse/index.js.map +0 -1
  194. package/lib/handler/mouse/mouse_handler.js.map +0 -1
  195. package/lib/handler/mouse/mousepan_handler.js.map +0 -1
  196. package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
  197. package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
  198. package/lib/handler/mouse/util.js.map +0 -1
  199. package/lib/handler/scroll_zoom.js.map +0 -1
  200. package/lib/handler/shim/dblclick_zoom.js.map +0 -1
  201. package/lib/handler/shim/drag_pan.js.map +0 -1
  202. package/lib/handler/shim/drag_rotate.js.map +0 -1
  203. package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
  204. package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
  205. package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
  206. package/lib/handler/tap/tap_recognizer.js.map +0 -1
  207. package/lib/handler/tap/tap_zoom.js.map +0 -1
  208. package/lib/handler/touch/index.js.map +0 -1
  209. package/lib/handler/touch/touch_pan.js.map +0 -1
  210. package/lib/handler/touch/touch_pitch.js.map +0 -1
  211. package/lib/handler/touch/touch_rotate.js.map +0 -1
  212. package/lib/handler/touch/touch_zoom.js.map +0 -1
  213. package/lib/handler/touch/two_touch.js.map +0 -1
  214. package/lib/hash.js.map +0 -1
  215. package/lib/index.js.map +0 -1
  216. package/lib/interface.js.map +0 -1
  217. package/lib/map.js.map +0 -1
  218. package/lib/util.js.map +0 -1
  219. package/lib/utils/Aabb.js.map +0 -1
  220. package/lib/utils/dom.js.map +0 -1
  221. package/lib/utils/performance.js.map +0 -1
  222. package/lib/utils/primitives.js.map +0 -1
  223. package/lib/utils/task_queue.js.map +0 -1
@@ -1,107 +1,91 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/geo/mercator.ts
23
+ var mercator_exports = {};
24
+ __export(mercator_exports, {
25
+ altitudeFromMercatorZ: () => altitudeFromMercatorZ,
26
+ default: () => MercatorCoordinate,
27
+ latFromMercatorY: () => latFromMercatorY,
28
+ lngFromMercatorX: () => lngFromMercatorX,
29
+ mercatorScale: () => mercatorScale,
30
+ mercatorXfromLng: () => mercatorXfromLng,
31
+ mercatorYfromLat: () => mercatorYfromLat,
32
+ mercatorZfromAltitude: () => mercatorZfromAltitude
9
33
  });
10
- exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
11
- exports.default = void 0;
12
- exports.latFromMercatorY = latFromMercatorY;
13
- exports.lngFromMercatorX = lngFromMercatorX;
14
- exports.mercatorScale = mercatorScale;
15
- exports.mercatorXfromLng = mercatorXfromLng;
16
- exports.mercatorYfromLat = mercatorYfromLat;
17
- exports.mercatorZfromAltitude = mercatorZfromAltitude;
18
-
19
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
20
-
21
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
22
-
23
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
-
25
- var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
26
-
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
-
29
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
30
-
31
- var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius;
32
-
34
+ module.exports = __toCommonJS(mercator_exports);
35
+ var import_lng_lat = __toESM(require("../geo/lng_lat"));
36
+ var earthCircumfrence = 2 * Math.PI * import_lng_lat.earthRadius;
33
37
  function circumferenceAtLatitude(latitude) {
34
38
  return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
35
39
  }
36
-
37
40
  function mercatorXfromLng(lng) {
38
41
  return (180 + lng) / 360;
39
42
  }
40
-
41
43
  function mercatorYfromLat(lat) {
42
44
  return (180 - 180 / Math.PI * Math.log(Math.tan(Math.PI / 4 + lat * Math.PI / 360))) / 360;
43
45
  }
44
-
45
46
  function mercatorZfromAltitude(altitude, lat) {
46
47
  return altitude / circumferenceAtLatitude(lat);
47
48
  }
48
-
49
49
  function lngFromMercatorX(x) {
50
50
  return x * 360 - 180;
51
51
  }
52
-
53
52
  function latFromMercatorY(y) {
54
- var y2 = 180 - y * 360;
53
+ const y2 = 180 - y * 360;
55
54
  return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
56
55
  }
57
-
58
56
  function altitudeFromMercatorZ(z, y) {
59
57
  return z * circumferenceAtLatitude(latFromMercatorY(y));
60
58
  }
61
-
62
59
  function mercatorScale(lat) {
63
60
  return 1 / Math.cos(lat * Math.PI / 180);
64
61
  }
65
-
66
- var MercatorCoordinate = function () {
67
- function MercatorCoordinate(x, y) {
68
- var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
69
- (0, _classCallCheck2.default)(this, MercatorCoordinate);
70
- (0, _defineProperty2.default)(this, "x", void 0);
71
- (0, _defineProperty2.default)(this, "y", void 0);
72
- (0, _defineProperty2.default)(this, "z", void 0);
62
+ var MercatorCoordinate = class {
63
+ static fromLngLat(lngLatLike, altitude = 0) {
64
+ const lngLat = import_lng_lat.default.convert(lngLatLike);
65
+ return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
66
+ }
67
+ constructor(x, y, z = 0) {
73
68
  this.x = +x;
74
69
  this.y = +y;
75
70
  this.z = +z;
76
71
  }
77
-
78
- (0, _createClass2.default)(MercatorCoordinate, [{
79
- key: "toLngLat",
80
- value: function toLngLat() {
81
- return new _lng_lat.default(lngFromMercatorX(this.x), latFromMercatorY(this.y));
82
- }
83
- }, {
84
- key: "toAltitude",
85
- value: function toAltitude() {
86
- return altitudeFromMercatorZ(this.z, this.y);
87
- }
88
- }, {
89
- key: "meterInMercatorCoordinateUnits",
90
- value: function meterInMercatorCoordinateUnits() {
91
- return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
92
- }
93
- }], [{
94
- key: "fromLngLat",
95
- value: function fromLngLat(lngLatLike) {
96
- var altitude = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
97
-
98
- var lngLat = _lng_lat.default.convert(lngLatLike);
99
-
100
- return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
101
- }
102
- }]);
103
- return MercatorCoordinate;
104
- }();
105
-
106
- exports.default = MercatorCoordinate;
107
- //# sourceMappingURL=mercator.js.map
72
+ toLngLat() {
73
+ return new import_lng_lat.default(lngFromMercatorX(this.x), latFromMercatorY(this.y));
74
+ }
75
+ toAltitude() {
76
+ return altitudeFromMercatorZ(this.z, this.y);
77
+ }
78
+ meterInMercatorCoordinateUnits() {
79
+ return 1 / earthCircumfrence * mercatorScale(latFromMercatorY(this.y));
80
+ }
81
+ };
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ altitudeFromMercatorZ,
85
+ latFromMercatorY,
86
+ lngFromMercatorX,
87
+ mercatorScale,
88
+ mercatorXfromLng,
89
+ mercatorYfromLat,
90
+ mercatorZfromAltitude
91
+ });
package/lib/geo/point.js CHANGED
@@ -1,244 +1,176 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
4
18
 
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
19
+ // src/geo/point.ts
20
+ var point_exports = {};
21
+ __export(point_exports, {
22
+ default: () => Point
7
23
  });
8
- exports.default = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
- var Point = function () {
17
- function Point(x, y) {
18
- (0, _classCallCheck2.default)(this, Point);
19
- (0, _defineProperty2.default)(this, "x", void 0);
20
- (0, _defineProperty2.default)(this, "y", void 0);
24
+ module.exports = __toCommonJS(point_exports);
25
+ var Point = class {
26
+ static convert(a) {
27
+ if (a instanceof Point) {
28
+ return a;
29
+ }
30
+ if (Array.isArray(a)) {
31
+ return new Point(a[0], a[1]);
32
+ }
33
+ return a;
34
+ }
35
+ constructor(x, y) {
21
36
  this.x = x;
22
37
  this.y = y;
23
38
  }
24
-
25
- (0, _createClass2.default)(Point, [{
26
- key: "clone",
27
- value: function clone() {
28
- return new Point(this.x, this.y);
29
- }
30
- }, {
31
- key: "_add",
32
- value: function _add(p) {
33
- this.x += p.x;
34
- this.y += p.y;
35
- return this;
36
- }
37
- }, {
38
- key: "add",
39
- value: function add(p) {
40
- return this.clone()._add(p);
41
- }
42
- }, {
43
- key: "_sub",
44
- value: function _sub(p) {
45
- this.x -= p.x;
46
- this.y -= p.y;
47
- return this;
48
- }
49
- }, {
50
- key: "sub",
51
- value: function sub(p) {
52
- return this.clone()._sub(p);
53
- }
54
- }, {
55
- key: "_multByPoint",
56
- value: function _multByPoint(p) {
57
- this.x *= p.x;
58
- this.y *= p.y;
59
- return this;
60
- }
61
- }, {
62
- key: "multByPoint",
63
- value: function multByPoint(p) {
64
- return this.clone()._multByPoint(p);
65
- }
66
- }, {
67
- key: "_divByPoint",
68
- value: function _divByPoint(p) {
69
- this.x /= p.x;
70
- this.y /= p.y;
71
- return this;
72
- }
73
- }, {
74
- key: "divByPoint",
75
- value: function divByPoint(p) {
76
- return this.clone()._divByPoint(p);
77
- }
78
- }, {
79
- key: "_mult",
80
- value: function _mult(k) {
81
- this.x *= k;
82
- this.y *= k;
83
- return this;
84
- }
85
- }, {
86
- key: "mult",
87
- value: function mult(k) {
88
- return this.clone()._mult(k);
89
- }
90
- }, {
91
- key: "_div",
92
- value: function _div(k) {
93
- this.x /= k;
94
- this.y /= k;
95
- return this;
96
- }
97
- }, {
98
- key: "div",
99
- value: function div(k) {
100
- return this.clone()._div(k);
101
- }
102
- }, {
103
- key: "_rotate",
104
- value: function _rotate(angle) {
105
- var cos = Math.cos(angle);
106
- var sin = Math.sin(angle);
107
- var x = cos * this.x - sin * this.y;
108
- var y = sin * this.x + cos * this.y;
109
- this.x = x;
110
- this.y = y;
111
- return this;
112
- }
113
- }, {
114
- key: "rotate",
115
- value: function rotate(angle) {
116
- return this.clone()._rotate(angle);
117
- }
118
- }, {
119
- key: "_rotateAround",
120
- value: function _rotateAround(angle, p) {
121
- var cos = Math.cos(angle);
122
- var sin = Math.sin(angle);
123
- var x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
124
- var y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
125
- this.x = x;
126
- this.y = y;
127
- return this;
128
- }
129
- }, {
130
- key: "roateAround",
131
- value: function roateAround(angle, p) {
132
- return this.clone()._rotateAround(angle, p);
133
- }
134
- }, {
135
- key: "_matMult",
136
- value: function _matMult(m) {
137
- var x = m[0] * this.x + m[1] * this.y;
138
- var y = m[2] * this.x + m[3] * this.y;
139
- this.x = x;
140
- this.y = y;
141
- return this;
142
- }
143
- }, {
144
- key: "matMult",
145
- value: function matMult(m) {
146
- return this.clone()._matMult(m);
147
- }
148
- }, {
149
- key: "_unit",
150
- value: function _unit() {
151
- this.div(this.mag());
152
- return this;
153
- }
154
- }, {
155
- key: "unit",
156
- value: function unit() {
157
- return this.clone()._unit();
158
- }
159
- }, {
160
- key: "_perp",
161
- value: function _perp() {
162
- var y = this.y;
163
- this.y = this.x;
164
- this.x = -y;
165
- return this;
166
- }
167
- }, {
168
- key: "perp",
169
- value: function perp() {
170
- return this.clone()._perp();
171
- }
172
- }, {
173
- key: "_round",
174
- value: function _round() {
175
- this.x = Math.round(this.x);
176
- this.y = Math.round(this.y);
177
- return this;
178
- }
179
- }, {
180
- key: "round",
181
- value: function round() {
182
- return this.clone()._round();
183
- }
184
- }, {
185
- key: "mag",
186
- value: function mag() {
187
- return Math.sqrt(this.x * this.x + this.y * this.y);
188
- }
189
- }, {
190
- key: "equals",
191
- value: function equals(other) {
192
- return this.x === other.x && this.y === other.y;
193
- }
194
- }, {
195
- key: "dist",
196
- value: function dist(p) {
197
- return Math.sqrt(this.distSqr(p));
198
- }
199
- }, {
200
- key: "distSqr",
201
- value: function distSqr(p) {
202
- var dx = p.x - this.x;
203
- var dy = p.y - this.y;
204
- return dx * dx + dy * dy;
205
- }
206
- }, {
207
- key: "angle",
208
- value: function angle() {
209
- return Math.atan2(this.y, this.x);
210
- }
211
- }, {
212
- key: "angleTo",
213
- value: function angleTo(b) {
214
- return Math.atan2(this.y - b.y, this.x - b.x);
215
- }
216
- }, {
217
- key: "angleWith",
218
- value: function angleWith(b) {
219
- return this.angleWithSep(b.x, b.y);
220
- }
221
- }, {
222
- key: "angleWithSep",
223
- value: function angleWithSep(x, y) {
224
- return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
225
- }
226
- }], [{
227
- key: "convert",
228
- value: function convert(a) {
229
- if (a instanceof Point) {
230
- return a;
231
- }
232
-
233
- if (Array.isArray(a)) {
234
- return new Point(a[0], a[1]);
235
- }
236
-
237
- return a;
238
- }
239
- }]);
240
- return Point;
241
- }();
242
-
243
- exports.default = Point;
244
- //# sourceMappingURL=point.js.map
39
+ clone() {
40
+ return new Point(this.x, this.y);
41
+ }
42
+ _add(p) {
43
+ this.x += p.x;
44
+ this.y += p.y;
45
+ return this;
46
+ }
47
+ add(p) {
48
+ return this.clone()._add(p);
49
+ }
50
+ _sub(p) {
51
+ this.x -= p.x;
52
+ this.y -= p.y;
53
+ return this;
54
+ }
55
+ sub(p) {
56
+ return this.clone()._sub(p);
57
+ }
58
+ _multByPoint(p) {
59
+ this.x *= p.x;
60
+ this.y *= p.y;
61
+ return this;
62
+ }
63
+ multByPoint(p) {
64
+ return this.clone()._multByPoint(p);
65
+ }
66
+ _divByPoint(p) {
67
+ this.x /= p.x;
68
+ this.y /= p.y;
69
+ return this;
70
+ }
71
+ divByPoint(p) {
72
+ return this.clone()._divByPoint(p);
73
+ }
74
+ _mult(k) {
75
+ this.x *= k;
76
+ this.y *= k;
77
+ return this;
78
+ }
79
+ mult(k) {
80
+ return this.clone()._mult(k);
81
+ }
82
+ _div(k) {
83
+ this.x /= k;
84
+ this.y /= k;
85
+ return this;
86
+ }
87
+ div(k) {
88
+ return this.clone()._div(k);
89
+ }
90
+ _rotate(angle) {
91
+ const cos = Math.cos(angle);
92
+ const sin = Math.sin(angle);
93
+ const x = cos * this.x - sin * this.y;
94
+ const y = sin * this.x + cos * this.y;
95
+ this.x = x;
96
+ this.y = y;
97
+ return this;
98
+ }
99
+ rotate(angle) {
100
+ return this.clone()._rotate(angle);
101
+ }
102
+ _rotateAround(angle, p) {
103
+ const cos = Math.cos(angle);
104
+ const sin = Math.sin(angle);
105
+ const x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y);
106
+ const y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
107
+ this.x = x;
108
+ this.y = y;
109
+ return this;
110
+ }
111
+ roateAround(angle, p) {
112
+ return this.clone()._rotateAround(angle, p);
113
+ }
114
+ _matMult(m) {
115
+ const x = m[0] * this.x + m[1] * this.y;
116
+ const y = m[2] * this.x + m[3] * this.y;
117
+ this.x = x;
118
+ this.y = y;
119
+ return this;
120
+ }
121
+ matMult(m) {
122
+ return this.clone()._matMult(m);
123
+ }
124
+ _unit() {
125
+ this.div(this.mag());
126
+ return this;
127
+ }
128
+ unit() {
129
+ return this.clone()._unit();
130
+ }
131
+ _perp() {
132
+ const y = this.y;
133
+ this.y = this.x;
134
+ this.x = -y;
135
+ return this;
136
+ }
137
+ perp() {
138
+ return this.clone()._perp();
139
+ }
140
+ _round() {
141
+ this.x = Math.round(this.x);
142
+ this.y = Math.round(this.y);
143
+ return this;
144
+ }
145
+ round() {
146
+ return this.clone()._round();
147
+ }
148
+ mag() {
149
+ return Math.sqrt(this.x * this.x + this.y * this.y);
150
+ }
151
+ equals(other) {
152
+ return this.x === other.x && this.y === other.y;
153
+ }
154
+ dist(p) {
155
+ return Math.sqrt(this.distSqr(p));
156
+ }
157
+ distSqr(p) {
158
+ const dx = p.x - this.x;
159
+ const dy = p.y - this.y;
160
+ return dx * dx + dy * dy;
161
+ }
162
+ angle() {
163
+ return Math.atan2(this.y, this.x);
164
+ }
165
+ angleTo(b) {
166
+ return Math.atan2(this.y - b.y, this.x - b.x);
167
+ }
168
+ angleWith(b) {
169
+ return this.angleWithSep(b.x, b.y);
170
+ }
171
+ angleWithSep(x, y) {
172
+ return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
173
+ }
174
+ };
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {});