plotboilerplate 1.23.2 → 1.24.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 (218) hide show
  1. package/README.md +6 -0
  2. package/dist/index.esm.js +8351 -6928
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +1590 -123
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +4 -2
  11. package/src/cjs/BezierPath.d.ts +41 -5
  12. package/src/cjs/BezierPath.js +52 -2
  13. package/src/cjs/BezierPath.js.map +1 -1
  14. package/src/cjs/Bounds.d.ts +67 -3
  15. package/src/cjs/Bounds.js +101 -3
  16. package/src/cjs/Bounds.js.map +1 -1
  17. package/src/cjs/Circle.d.ts +46 -4
  18. package/src/cjs/Circle.js +82 -3
  19. package/src/cjs/Circle.js.map +1 -1
  20. package/src/cjs/CircleSector.d.ts +51 -2
  21. package/src/cjs/CircleSector.js +112 -3
  22. package/src/cjs/CircleSector.js.map +1 -1
  23. package/src/cjs/CubicBezierCurve.d.ts +113 -7
  24. package/src/cjs/CubicBezierCurve.js +281 -33
  25. package/src/cjs/CubicBezierCurve.js.map +1 -1
  26. package/src/cjs/Line.d.ts +38 -3
  27. package/src/cjs/Line.js +64 -1
  28. package/src/cjs/Line.js.map +1 -1
  29. package/src/cjs/PlotBoilerplate.d.ts +4 -2
  30. package/src/cjs/PlotBoilerplate.js +9 -12
  31. package/src/cjs/PlotBoilerplate.js.map +1 -1
  32. package/src/cjs/Polygon.d.ts +153 -6
  33. package/src/cjs/Polygon.js +304 -23
  34. package/src/cjs/Polygon.js.map +1 -1
  35. package/src/cjs/Triangle.d.ts +73 -4
  36. package/src/cjs/Triangle.js +94 -2
  37. package/src/cjs/Triangle.js.map +1 -1
  38. package/src/cjs/VEllipse.d.ts +62 -3
  39. package/src/cjs/VEllipse.js +181 -17
  40. package/src/cjs/VEllipse.js.map +1 -1
  41. package/src/cjs/VEllipseSector.d.ts +86 -2
  42. package/src/cjs/VEllipseSector.js +148 -4
  43. package/src/cjs/VEllipseSector.js.map +1 -1
  44. package/src/cjs/Vector.d.ts +12 -2
  45. package/src/cjs/Vector.js +15 -2
  46. package/src/cjs/Vector.js.map +1 -1
  47. package/src/cjs/VertTuple.d.ts +39 -10
  48. package/src/cjs/VertTuple.js +49 -11
  49. package/src/cjs/VertTuple.js.map +1 -1
  50. package/src/cjs/Vertex.d.ts +18 -2
  51. package/src/cjs/Vertex.js +22 -2
  52. package/src/cjs/Vertex.js.map +1 -1
  53. package/src/cjs/draw.d.ts +1 -0
  54. package/src/cjs/draw.js +2 -1
  55. package/src/cjs/draw.js.map +1 -1
  56. package/src/cjs/drawutilssvg.js +24 -0
  57. package/src/cjs/drawutilssvg.js.map +1 -1
  58. package/src/cjs/geomutils.d.ts +32 -1
  59. package/src/cjs/geomutils.js +47 -1
  60. package/src/cjs/geomutils.js.map +1 -1
  61. package/src/cjs/interfaces/core.d.ts +39 -0
  62. package/src/cjs/interfaces/core.js +2 -0
  63. package/src/cjs/interfaces/core.js.map +1 -1
  64. package/src/cjs/utils/algorithms/PolygonInset.d.ts +184 -0
  65. package/src/cjs/utils/algorithms/PolygonInset.js +431 -0
  66. package/src/cjs/utils/algorithms/PolygonInset.js.map +1 -0
  67. package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
  68. package/src/cjs/utils/algorithms/clearDuplicateVertices.js +6 -3
  69. package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  70. package/src/cjs/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
  71. package/src/cjs/utils/algorithms/convexPolygonIncircle.js +14 -6
  72. package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
  73. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
  74. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js +3 -3
  75. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  76. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
  77. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
  78. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  79. package/src/cjs/utils/createRandomizedPolygon.d.ts +14 -0
  80. package/src/cjs/utils/createRandomizedPolygon.js +32 -0
  81. package/src/cjs/utils/createRandomizedPolygon.js.map +1 -0
  82. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  83. package/src/cjs/utils/dom/guiSizeToggler.d.ts +2 -1
  84. package/src/cjs/utils/dom/guiSizeToggler.js +5 -3
  85. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  86. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
  87. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +37 -23
  88. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  89. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +10 -1
  90. package/src/cjs/utils/helpers/CircleSectorHelper.js +19 -20
  91. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  92. package/src/cjs/utils/helpers/VEllipseHelper.d.ts +30 -0
  93. package/src/cjs/utils/helpers/VEllipseHelper.js +86 -0
  94. package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -0
  95. package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
  96. package/src/cjs/utils/helpers/VEllipseSectorHelper.js +107 -25
  97. package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  98. package/src/createDemoDrawables.js +3 -1
  99. package/src/esm/BezierPath.d.ts +41 -5
  100. package/src/esm/BezierPath.js +50 -2
  101. package/src/esm/BezierPath.js.map +1 -1
  102. package/src/esm/Bounds.d.ts +67 -3
  103. package/src/esm/Bounds.js +101 -3
  104. package/src/esm/Bounds.js.map +1 -1
  105. package/src/esm/Circle.d.ts +46 -4
  106. package/src/esm/Circle.js +79 -3
  107. package/src/esm/Circle.js.map +1 -1
  108. package/src/esm/CircleSector.d.ts +51 -2
  109. package/src/esm/CircleSector.js +108 -3
  110. package/src/esm/CircleSector.js.map +1 -1
  111. package/src/esm/CubicBezierCurve.d.ts +113 -7
  112. package/src/esm/CubicBezierCurve.js +277 -33
  113. package/src/esm/CubicBezierCurve.js.map +1 -1
  114. package/src/esm/Line.d.ts +38 -3
  115. package/src/esm/Line.js +62 -1
  116. package/src/esm/Line.js.map +1 -1
  117. package/src/esm/PlotBoilerplate.d.ts +4 -2
  118. package/src/esm/PlotBoilerplate.js +9 -12
  119. package/src/esm/PlotBoilerplate.js.map +1 -1
  120. package/src/esm/Polygon.d.ts +153 -6
  121. package/src/esm/Polygon.js +301 -23
  122. package/src/esm/Polygon.js.map +1 -1
  123. package/src/esm/Triangle.d.ts +73 -4
  124. package/src/esm/Triangle.js +91 -2
  125. package/src/esm/Triangle.js.map +1 -1
  126. package/src/esm/VEllipse.d.ts +62 -3
  127. package/src/esm/VEllipse.js +178 -17
  128. package/src/esm/VEllipse.js.map +1 -1
  129. package/src/esm/VEllipseSector.d.ts +86 -2
  130. package/src/esm/VEllipseSector.js +146 -7
  131. package/src/esm/VEllipseSector.js.map +1 -1
  132. package/src/esm/Vector.d.ts +12 -2
  133. package/src/esm/Vector.js +15 -2
  134. package/src/esm/Vector.js.map +1 -1
  135. package/src/esm/VertTuple.d.ts +39 -10
  136. package/src/esm/VertTuple.js +49 -11
  137. package/src/esm/VertTuple.js.map +1 -1
  138. package/src/esm/Vertex.d.ts +18 -2
  139. package/src/esm/Vertex.js +22 -2
  140. package/src/esm/Vertex.js.map +1 -1
  141. package/src/esm/draw.d.ts +1 -0
  142. package/src/esm/draw.js +2 -1
  143. package/src/esm/draw.js.map +1 -1
  144. package/src/esm/drawutilssvg.js +24 -0
  145. package/src/esm/drawutilssvg.js.map +1 -1
  146. package/src/esm/geomutils.d.ts +32 -1
  147. package/src/esm/geomutils.js +47 -1
  148. package/src/esm/geomutils.js.map +1 -1
  149. package/src/esm/interfaces/core.d.ts +39 -0
  150. package/src/esm/interfaces/core.js +2 -0
  151. package/src/esm/interfaces/core.js.map +1 -1
  152. package/src/esm/utils/algorithms/PolygonInset.d.ts +184 -0
  153. package/src/esm/utils/algorithms/PolygonInset.js +424 -0
  154. package/src/esm/utils/algorithms/PolygonInset.js.map +1 -0
  155. package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +5 -4
  156. package/src/esm/utils/algorithms/clearDuplicateVertices.js +6 -3
  157. package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  158. package/src/esm/utils/algorithms/convexPolygonIncircle.d.ts +2 -1
  159. package/src/esm/utils/algorithms/convexPolygonIncircle.js +15 -7
  160. package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
  161. package/src/esm/utils/algorithms/createRandomizedPolygon.d.ts +14 -0
  162. package/src/esm/utils/algorithms/createRandomizedPolygon.js +28 -0
  163. package/src/esm/utils/algorithms/createRandomizedPolygon.js.map +1 -0
  164. package/src/esm/utils/algorithms/findPolygonSelfIntersections.d.ts +2 -1
  165. package/src/esm/utils/algorithms/findPolygonSelfIntersections.js +3 -3
  166. package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  167. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.d.ts +3 -2
  168. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js +11 -9
  169. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  170. package/src/esm/utils/createRandomizedPolygon.d.ts +14 -0
  171. package/src/esm/utils/createRandomizedPolygon.js +28 -0
  172. package/src/esm/utils/createRandomizedPolygon.js.map +1 -0
  173. package/src/esm/utils/detectDarkMode.js.map +1 -1
  174. package/src/esm/utils/dom/guiSizeToggler.d.ts +2 -1
  175. package/src/esm/utils/dom/guiSizeToggler.js +4 -2
  176. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  177. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -7
  178. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +35 -22
  179. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  180. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +10 -1
  181. package/src/esm/utils/helpers/CircleSectorHelper.js +19 -20
  182. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  183. package/src/esm/utils/helpers/VEllipseHelper.d.ts +30 -0
  184. package/src/esm/utils/helpers/VEllipseHelper.js +81 -0
  185. package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -0
  186. package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +42 -3
  187. package/src/esm/utils/helpers/VEllipseSectorHelper.js +106 -24
  188. package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  189. package/src/ts/BezierPath.ts +58 -5
  190. package/src/ts/Bounds.ts +110 -6
  191. package/src/ts/Circle.ts +87 -5
  192. package/src/ts/CircleSector.ts +115 -5
  193. package/src/ts/CubicBezierCurve.ts +332 -42
  194. package/src/ts/Line.ts +66 -3
  195. package/src/ts/PlotBoilerplate.ts +10 -12
  196. package/src/ts/Polygon.ts +329 -27
  197. package/src/ts/Triangle.ts +101 -5
  198. package/src/ts/VEllipse.ts +214 -19
  199. package/src/ts/VEllipseSector.ts +154 -8
  200. package/src/ts/Vector.ts +16 -2
  201. package/src/ts/VertTuple.ts +53 -13
  202. package/src/ts/Vertex.ts +24 -3
  203. package/src/ts/draw.ts +2 -1
  204. package/src/ts/drawutilssvg.ts +29 -0
  205. package/src/ts/geomutils.ts +49 -1
  206. package/src/ts/interfaces/core.ts +42 -0
  207. package/src/ts/utils/algorithms/PolygonInset.ts +529 -0
  208. package/src/ts/utils/algorithms/clearDuplicateVertices.ts +11 -8
  209. package/src/ts/utils/algorithms/convexPolygonIncircle.ts +82 -78
  210. package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts +25 -26
  211. package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts +92 -99
  212. package/src/ts/utils/createRandomizedPolygon.ts +31 -0
  213. package/src/ts/utils/detectDarkMode.ts +1 -3
  214. package/src/ts/utils/dom/guiSizeToggler.ts +4 -2
  215. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +45 -29
  216. package/src/ts/utils/helpers/CircleSectorHelper.ts +115 -125
  217. package/src/ts/utils/helpers/VEllipseHelper.ts +113 -0
  218. package/src/ts/utils/helpers/VEllipseSectorHelper.ts +142 -25
@@ -1 +1 @@
1
- {"version":3,"file":"CircleSectorHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/CircleSectorHelper.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsBH;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAU3B;;;;;;;;;QASI;IACJ,YAAa,YAAyB,EACvC,iBAAwB,EACxB,eAAsB,EACtB,EAAkB;QAGlB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAE,CAAC;QAC5G,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,eAAe,CAAE,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,4BAA4B,EAAE,CAAE,CAAC;QACnH,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,eAAe,CAAE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAE,CAAC;QAC/G,2EAA2E;QAC3E,oDAAoD;QACpD,kDAAkD;QAClD,OAAO;QAEP,kE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S,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A helper for VEllipses.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-03-31
6
+ * @modified 2025-04-02 Adding `VEllipseHelper.drawHandleLines()`.
7
+ * @modified 2025-04-09 Adding `VEllipseHelper.destroy()`.
8
+ * @version 1.0.0
9
+ */
10
+ import { VEllipse } from "../../VEllipse";
11
+ import { Vertex } from "../../Vertex";
12
+ import { DrawLib } from "../../interfaces";
13
+ export declare class VEllipseHelper {
14
+ private readonly ellipse;
15
+ private readonly rotationControlPoint;
16
+ private _rotationControlLine;
17
+ private _centerPointHandler;
18
+ private _rotationPointHandler;
19
+ constructor(ellipse: VEllipse, rotationControlPoint: Vertex);
20
+ private _handleDragCenterPoint;
21
+ private _handleRotationCenterPoint;
22
+ /**
23
+ * Draw grey handle lines.
24
+ *
25
+ * @param {DrawLib<any>} draw - The draw library instance to use.
26
+ * @param {DrawLib<any>} fill - The fill library instance to use.
27
+ */
28
+ drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>): void;
29
+ detroy(): void;
30
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * A helper for VEllipses.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-03-31
6
+ * @modified 2025-04-02 Adding `VEllipseHelper.drawHandleLines()`.
7
+ * @modified 2025-04-09 Adding `VEllipseHelper.destroy()`.
8
+ * @version 1.0.0
9
+ */
10
+ import { Line } from "../../Line";
11
+ export class VEllipseHelper {
12
+ constructor(ellipse, rotationControlPoint) {
13
+ this.ellipse = ellipse;
14
+ this.rotationControlPoint = rotationControlPoint;
15
+ // const rotationControlLine: Line = new Line(ellipse.center, rotationControlPoint);
16
+ this._rotationControlLine = new Line(ellipse.center, rotationControlPoint);
17
+ // +---------------------------------------------------------------------
18
+ // | Listen for the center to be moved.
19
+ // +-------------------------------------------
20
+ // ellipse.center.listeners.addDragListener((event: VertEvent) => {
21
+ // rotationControlPoint.add(event.params.dragAmount);
22
+ // });
23
+ ellipse.center.listeners.addDragListener((this._centerPointHandler = this._handleDragCenterPoint()));
24
+ // +---------------------------------------------------------------------
25
+ // | Listen for rotation changes.
26
+ // +-------------------------------------------
27
+ // rotationControlPoint.listeners.addDragListener((_event: VertEvent) => {
28
+ // var newRotation = rotationControlLine.angle();
29
+ // var rDiff = newRotation - ellipse.rotation;
30
+ // ellipse.rotation = newRotation;
31
+ // ellipse.axis.rotate(rDiff, ellipse.center);
32
+ // });
33
+ rotationControlPoint.listeners.addDragListener((this._rotationPointHandler = this._handleRotationCenterPoint()));
34
+ }
35
+ _handleDragCenterPoint() {
36
+ const _self = this;
37
+ return (event) => {
38
+ _self.rotationControlPoint.add(event.params.dragAmount);
39
+ };
40
+ }
41
+ _handleRotationCenterPoint() {
42
+ const _self = this;
43
+ return (_event) => {
44
+ var newRotation = _self._rotationControlLine.angle();
45
+ var rDiff = newRotation - _self.ellipse.rotation;
46
+ _self.ellipse.rotation = newRotation;
47
+ _self.ellipse.axis.rotate(rDiff, _self.ellipse.center);
48
+ };
49
+ }
50
+ /**
51
+ * Draw grey handle lines.
52
+ *
53
+ * @param {DrawLib<any>} draw - The draw library instance to use.
54
+ * @param {DrawLib<any>} fill - The fill library instance to use.
55
+ */
56
+ drawHandleLines(draw, fill) {
57
+ // Draw rotation handle line
58
+ draw.line(this.ellipse.center, this.rotationControlPoint, "rgba(192,64,128,0.333)", 1.0, {
59
+ dashOffset: 0.0,
60
+ dashArray: [4, 2]
61
+ });
62
+ // Draw helper box
63
+ draw.setCurrentId(`${this.ellipse.uid}_e0`);
64
+ draw.setCurrentClassName(`${this.ellipse.className}-v-line`);
65
+ draw.line(this.ellipse.center.clone().add(0, this.ellipse.signedRadiusV()).rotate(this.ellipse.rotation, this.ellipse.center), this.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
66
+ dashOffset: 0.0,
67
+ dashArray: [4, 2]
68
+ });
69
+ draw.setCurrentId(`${this.ellipse.uid}_e1`);
70
+ draw.setCurrentClassName(`${this.ellipse.className}-h-line`);
71
+ draw.line(this.ellipse.center.clone().add(this.ellipse.signedRadiusH(), 0).rotate(this.ellipse.rotation, this.ellipse.center), this.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
72
+ dashOffset: 0.0,
73
+ dashArray: [4, 2]
74
+ });
75
+ }
76
+ detroy() {
77
+ this.ellipse.center.listeners.removeDragListener(this._centerPointHandler);
78
+ this.rotationControlPoint.listeners.removeDragListener(this._rotationPointHandler);
79
+ }
80
+ }
81
+ //# sourceMappingURL=VEllipseHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VEllipseHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/VEllipseHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMlC,MAAM,OAAO,cAAc;IASzB,YAAY,OAAiB,EAAE,oBAA4B;QACzD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QAEjD,oFAAoF;QACpF,IAAI,CAAC,oBAAoB,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAE3E,yEAAyE;QACzE,uCAAuC;QACvC,+CAA+C;QAC/C,mEAAmE;QACnE,uDAAuD;QACvD,MAAM;QACN,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;QAErG,yEAAyE;QACzE,iCAAiC;QACjC,+CAA+C;QAC/C,0EAA0E;QAC1E,mDAAmD;QACnD,gDAAgD;QAChD,oCAAoC;QACpC,gDAAgD;QAChD,MAAM;QACN,oBAAoB,CAAC,SAAS,CAAC,eAAe,C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appler
5
- * @date 2021-03-24
6
- * @version 1.0.0
4
+ * @author Ikaros Kappler
5
+ * @date 2021-03-24
6
+ * @modified 2025-04-02 Adding `VEllipseSectorHelper.drawHandleLines`.
7
+ * @modified 2025-04-07 Modifying the calculation of `startAngle` and `endAngle` from the rotation control point: wrapping result into [0,TWO_PI).
8
+ * @modified 2025-04-09 Adding the `VEllipseSectorHelper.destroy` method.
9
+ * @version 1.1.0
7
10
  */
8
11
  import { VEllipseSector } from "../../VEllipseSector";
9
12
  import { Vertex } from "../../Vertex";
13
+ import { DrawLib } from "../../interfaces";
10
14
  export declare class VEllipseSectorHelper {
15
+ private sector;
16
+ private startAngleControlPoint;
17
+ private endAngleControlPoint;
18
+ private rotationControlPoint;
19
+ private _rotationControlLine;
20
+ private _startAngleControlLine;
21
+ private _endAngleControlLine;
22
+ private _centerHandler;
23
+ private _rotationHandler;
24
+ private _startAngleHandler;
25
+ private _endAngleHandler;
11
26
  constructor(sector: VEllipseSector, startAngleControlPoint: Vertex, endAngleControlPoint: Vertex, rotationControlPoint: Vertex);
27
+ /**
28
+ * Creates a new drag handler for the circle sector's start control point.
29
+ *
30
+ * @private
31
+ * @method _handleDragStartControlPoint
32
+ * @instance
33
+ * @memberof CircleSectorHelper
34
+ * @returns A new event handler.
35
+ */
36
+ private _handleDragCenterPoint;
37
+ private _handleDragRotationControlPoint;
38
+ private _handleDragStartAngleControlPoint;
39
+ private _handleDragEndAngleControlPoint;
40
+ /**
41
+ * Draw grey handle lines.
42
+ *
43
+ * @param {DrawLib<any>} draw - The draw library instance to use.
44
+ * @param {DrawLib<any>} fill - The fill library instance to use.
45
+ */
46
+ drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>): void;
47
+ /**
48
+ * Destroy this VEllipseHandler which means: all listeners are being removed.
49
+ */
50
+ destroy(): void;
12
51
  }
@@ -1,47 +1,129 @@
1
1
  /**
2
2
  * A helper for VEllipseSectors.
3
3
  *
4
- * @author Ikaros Kappler
5
- * @date 2021-03-24
6
- * @version 1.0.0
4
+ * @author Ikaros Kappler
5
+ * @date 2021-03-24
6
+ * @modified 2025-04-02 Adding `VEllipseSectorHelper.drawHandleLines`.
7
+ * @modified 2025-04-07 Modifying the calculation of `startAngle` and `endAngle` from the rotation control point: wrapping result into [0,TWO_PI).
8
+ * @modified 2025-04-09 Adding the `VEllipseSectorHelper.destroy` method.
9
+ * @version 1.1.0
7
10
  */
8
11
  import { Line } from "../../Line";
12
+ import { geomutils } from "../../geomutils";
9
13
  export class VEllipseSectorHelper {
10
14
  constructor(sector, startAngleControlPoint, endAngleControlPoint, rotationControlPoint) {
11
- const rotationControlLine = new Line(sector.ellipse.center, rotationControlPoint);
12
- const startAngleControlLine = new Line(sector.ellipse.center, startAngleControlPoint);
13
- const endAngleControlLine = new Line(sector.ellipse.center, endAngleControlPoint);
15
+ this.sector = sector;
16
+ this.startAngleControlPoint = startAngleControlPoint;
17
+ this.endAngleControlPoint = endAngleControlPoint;
18
+ this.rotationControlPoint = rotationControlPoint;
19
+ // const rotationControlLine: Line = new Line(sector.ellipse.center, rotationControlPoint);
20
+ this._rotationControlLine = new Line(sector.ellipse.center, rotationControlPoint);
21
+ // const startAngleControlLine: Line = new Line(sector.ellipse.center, startAngleControlPoint);
22
+ this._startAngleControlLine = new Line(sector.ellipse.center, startAngleControlPoint);
23
+ // const endAngleControlLine: Line = new Line(sector.ellipse.center, endAngleControlPoint);
24
+ this._endAngleControlLine = new Line(sector.ellipse.center, endAngleControlPoint);
14
25
  // +---------------------------------------------------------------------
15
26
  // | Listen for the center to be moved.
16
27
  // +-------------------------------------------
17
- sector.ellipse.center.listeners.addDragListener((event) => {
18
- startAngleControlPoint.add(event.params.dragAmount);
19
- endAngleControlPoint.add(event.params.dragAmount);
20
- rotationControlPoint.add(event.params.dragAmount);
21
- });
28
+ sector.ellipse.center.listeners.addDragListener((this._centerHandler = this._handleDragCenterPoint()));
22
29
  // +---------------------------------------------------------------------
23
30
  // | Listen for rotation changes.
24
31
  // +-------------------------------------------
25
- rotationControlPoint.listeners.addDragListener((event) => {
26
- var newRotation = rotationControlLine.angle();
27
- var rDiff = newRotation - sector.ellipse.rotation;
28
- sector.ellipse.rotation = newRotation;
29
- sector.ellipse.axis.rotate(rDiff, sector.ellipse.center);
30
- startAngleControlPoint.rotate(rDiff, sector.ellipse.center);
31
- endAngleControlPoint.rotate(rDiff, sector.ellipse.center);
32
- });
32
+ rotationControlPoint.listeners.addDragListener((this._rotationHandler = this._handleDragRotationControlPoint()));
33
33
  // +---------------------------------------------------------------------
34
34
  // | Listen for start angle changes.
35
35
  // +-------------------------------------------
36
- startAngleControlPoint.listeners.addDragListener((event) => {
37
- sector.startAngle = startAngleControlLine.angle() - sector.ellipse.rotation;
38
- });
36
+ startAngleControlPoint.listeners.addDragListener((this._startAngleHandler = this._handleDragStartAngleControlPoint()));
39
37
  // +---------------------------------------------------------------------
40
38
  // | Listen for end angle changes.
41
39
  // +-------------------------------------------
42
- endAngleControlPoint.listeners.addDragListener((event) => {
43
- sector.endAngle = endAngleControlLine.angle() - sector.ellipse.rotation;
40
+ endAngleControlPoint.listeners.addDragListener((this._endAngleHandler = this._handleDragEndAngleControlPoint()));
41
+ }
42
+ /**
43
+ * Creates a new drag handler for the circle sector's start control point.
44
+ *
45
+ * @private
46
+ * @method _handleDragStartControlPoint
47
+ * @instance
48
+ * @memberof CircleSectorHelper
49
+ * @returns A new event handler.
50
+ */
51
+ _handleDragCenterPoint() {
52
+ const _self = this;
53
+ return (event) => {
54
+ _self.startAngleControlPoint.add(event.params.dragAmount);
55
+ _self.endAngleControlPoint.add(event.params.dragAmount);
56
+ _self.rotationControlPoint.add(event.params.dragAmount);
57
+ };
58
+ }
59
+ _handleDragRotationControlPoint() {
60
+ const _self = this;
61
+ return (event) => {
62
+ const newRotation = _self._rotationControlLine.angle();
63
+ const rDiff = newRotation - _self.sector.ellipse.rotation;
64
+ _self.sector.ellipse.rotation = newRotation;
65
+ _self.sector.ellipse.axis.rotate(rDiff, _self.sector.ellipse.center);
66
+ _self.startAngleControlPoint.rotate(rDiff, _self.sector.ellipse.center);
67
+ _self.endAngleControlPoint.rotate(rDiff, _self.sector.ellipse.center);
68
+ };
69
+ }
70
+ _handleDragStartAngleControlPoint() {
71
+ const _self = this;
72
+ return (_event) => {
73
+ // sector.startAngle = startAngleControlLine.angle() - sector.ellipse.rotation;
74
+ _self.sector.startAngle = geomutils.mapAngleTo2PI(_self._startAngleControlLine.angle() - _self.sector.ellipse.rotation);
75
+ };
76
+ }
77
+ _handleDragEndAngleControlPoint() {
78
+ const _self = this;
79
+ return (event) => {
80
+ _self.sector.endAngle = geomutils.mapAngleTo2PI(_self._endAngleControlLine.angle() - _self.sector.ellipse.rotation);
81
+ };
82
+ }
83
+ /**
84
+ * Draw grey handle lines.
85
+ *
86
+ * @param {DrawLib<any>} draw - The draw library instance to use.
87
+ * @param {DrawLib<any>} fill - The fill library instance to use.
88
+ */
89
+ drawHandleLines(draw, fill) {
90
+ draw.line(this.sector.ellipse.center, this.startAngleControlPoint, "rgba(64,192,128,0.333)", 1.0, {
91
+ dashOffset: 0.0,
92
+ dashArray: [4, 2]
93
+ });
94
+ draw.line(this.sector.ellipse.center, this.endAngleControlPoint, "rgba(64,192,128,0.333)", 1.0, {
95
+ dashOffset: 0.0,
96
+ dashArray: [4, 2]
97
+ });
98
+ // Draw rotation handle line
99
+ draw.line(this.sector.ellipse.center, this.rotationControlPoint, "rgba(192,64,128,0.333)", 1.0, {
100
+ dashOffset: 0.0,
101
+ dashArray: [4, 2]
102
+ });
103
+ // Draw helper box
104
+ draw.line(this.sector.ellipse.center
105
+ .clone()
106
+ .add(0, this.sector.ellipse.signedRadiusV())
107
+ .rotate(this.sector.ellipse.rotation, this.sector.ellipse.center), this.sector.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
108
+ dashOffset: 0.0,
109
+ dashArray: [4, 2]
110
+ });
111
+ draw.line(this.sector.ellipse.center
112
+ .clone()
113
+ .add(this.sector.ellipse.signedRadiusH(), 0)
114
+ .rotate(this.sector.ellipse.rotation, this.sector.ellipse.center), this.sector.ellipse.axis, "rgba(64,128,192,0.333)", 1.0, {
115
+ dashOffset: 0.0,
116
+ dashArray: [4, 2]
44
117
  });
118
+ } // END drawHandleLines
119
+ /**
120
+ * Destroy this VEllipseHandler which means: all listeners are being removed.
121
+ */
122
+ destroy() {
123
+ this.sector.ellipse.center.listeners.removeDragListener(this._centerHandler);
124
+ this.rotationControlPoint.listeners.removeDragListener(this._rotationHandler);
125
+ this.startAngleControlPoint.listeners.removeDragListener(this._startAngleHandler);
126
+ this.endAngleControlPoint.listeners.removeDragListener(this._endAngleHandler);
45
127
  }
46
128
  }
47
129
  //# sourceMappingURL=VEllipseSectorHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"VEllipseSectorHelper.js","sourceRoot":"","sources":["../../../ts/utils/helpers/VEllipseSectorHelper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKlC,MAAM,OAAO,oBAAoB;IAC/B,YACE,MAAsB,EACtB,sBAA8B,EAC9B,oBAA4B,EAC5B,oBAA4B;QAE5B,MAAM,mBAAmB,GAAS,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QACxF,MAAM,qBAAqB,GAAS,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;QAC5F,MAAM,mBAAmB,GAAS,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;QAExF,yEAAyE;QACzE,uCAAuC;QACvC,+CAA+C;QAC/C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,KAAgB,EAAE,EAAE;YACnE,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CA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,CAAC;SAClB,CACF,CAAC;IACJ,CAAC,CAAC,sBAAsB;IAExB;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC7E,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC9E,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAClF,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChF,CAAC;CACF"}
@@ -25,7 +25,10 @@
25
25
  * @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
26
26
  * @modified 2023-10-06 Adding the `BezierPath.toPathPoints()` method.
27
27
  * @modified 2023-10-07 Adding the `BezierPath.fromCurve(CubicBezierCurve)` static function.
28
- * @version 2.6.0
28
+ * @modified 2025-04-09 Added the `BezierPath.move` method to match the convention – which just calls `translate`.
29
+ * @modified 2025-04-09 Modified the `BezierPath.translate` method: chaning parameter `Vertex` to more generalized `XYCoords`.
30
+ * @modified 2025-04-14 Class `BezierPath` is now implementing interface `Intersectable`.
31
+ * @version 2.7.0
29
32
  *
30
33
  * @file BezierPath
31
34
  * @public
@@ -34,8 +37,10 @@
34
37
  import { Bounds } from "./Bounds";
35
38
  import { CubicBezierCurve } from "./CubicBezierCurve";
36
39
  import { UIDGenerator } from "./UIDGenerator";
40
+ import { Vector } from "./Vector";
41
+ import { VertTuple } from "./VertTuple";
37
42
  import { Vertex } from "./Vertex";
38
- import { XYCoords, SVGSerializable, UID } from "./interfaces";
43
+ import { XYCoords, SVGSerializable, UID, Intersectable, IBounded } from "./interfaces";
39
44
 
40
45
  /**
41
46
  * @classdesc A BezierPath class.
@@ -50,7 +55,7 @@ import { XYCoords, SVGSerializable, UID } from "./interfaces";
50
55
  * @requires UID
51
56
  * @requires UIDGenerator
52
57
  **/
53
- export class BezierPath implements SVGSerializable {
58
+ export class BezierPath implements IBounded, Intersectable, SVGSerializable {
54
59
  /**
55
60
  * Required to generate proper CSS classes and other class related IDs.
56
61
  **/
@@ -309,13 +314,13 @@ export class BezierPath implements SVGSerializable {
309
314
  * Move the whole bezier path by the given (x,y)-amount.
310
315
  *
311
316
  * @method translate
312
- * @param {Vertex} amount - The amount to be added (amount.x and amount.y)
317
+ * @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
313
318
  * to each vertex of the curve.
314
319
  * @instance
315
320
  * @memberof BezierPath
316
321
  * @return {BezierPath} this for chaining
317
322
  **/
318
- translate(amount: Vertex): BezierPath {
323
+ translate(amount: XYCoords): BezierPath {
319
324
  for (var i = 0; i < this.bezierCurves.length; i++) {
320
325
  var curve = this.bezierCurves[i];
321
326
  curve.getStartPoint().add(amount);
@@ -331,6 +336,20 @@ export class BezierPath implements SVGSerializable {
331
336
  return this;
332
337
  }
333
338
 
339
+ /**
340
+ * Move the whole bezier path by the given (x,y)-amount.
341
+ *
342
+ * @method move
343
+ * @param {XYCoords} amount - The amount to be added (amount.x and amount.y)
344
+ * to each vertex of the curve.
345
+ * @instance
346
+ * @memberof BezierPath
347
+ * @return {BezierPath} this for chaining
348
+ **/
349
+ move(amount: XYCoords): BezierPath {
350
+ return this.translate(amount);
351
+ }
352
+
334
353
  /**
335
354
  * Scale the whole bezier path by the given uniform factor.
336
355
  *
@@ -559,6 +578,38 @@ export class BezierPath implements SVGSerializable {
559
578
  return bCurve.getPerpendicular(relativeU);
560
579
  }
561
580
 
581
+ //--- BEGIN --- Implement interface `Intersectable`
582
+ /**
583
+ * Get all line intersections with this shape.
584
+ *
585
+ * This method returns all intersections (as vertices) with this shape. The returned array of vertices is in no specific order.
586
+ *
587
+ * @param {VertTuple} line - The line to find intersections with.
588
+ * @param {boolean} inVectorBoundsOnly - If set to true only intersecion points on the passed vector are returned (located strictly between start and end vertex).
589
+ * @returns {Array<Vertex>} - An array of all intersections with the shape's outline.
590
+ */
591
+ lineIntersections(line: VertTuple<any>, inVectorBoundsOnly: boolean = false): Array<Vertex> {
592
+ return this.bezierCurves.reduce((accu: Array<Vertex>, curCurve: CubicBezierCurve) => {
593
+ return accu.concat(curCurve.lineIntersections(line, inVectorBoundsOnly));
594
+ }, []);
595
+ }
596
+
597
+ /**
598
+ * Get all line intersections of this polygon and their tangents along the shape.
599
+ *
600
+ * This method returns all intersection tangents (as vectors) with this shape. The returned array of vectors is in no specific order.
601
+ *
602
+ * @param line
603
+ * @param lineIntersectionTangents
604
+ * @returns
605
+ */
606
+ lineIntersectionTangents(line: VertTuple<any>, inVectorBoundsOnly: boolean = false): Array<Vector> {
607
+ return this.bezierCurves.reduce((accu: Array<Vector>, curCurve: CubicBezierCurve) => {
608
+ return accu.concat(curCurve.lineIntersectionTangents(line, inVectorBoundsOnly));
609
+ }, []);
610
+ }
611
+ //--- END --- Implement interface `Intersectable`
612
+
562
613
  /**
563
614
  * This is a helper function to locate the curve index for a given
564
615
  * absolute path position u.
@@ -816,6 +867,7 @@ export class BezierPath implements SVGSerializable {
816
867
  neighbourCurve.updateArcLengths();
817
868
  }
818
869
 
870
+ //--- BEGIN --- Implement interface `IBounded`
819
871
  /**
820
872
  * Get the bounds of this Bézier path.
821
873
  *
@@ -837,6 +889,7 @@ export class BezierPath implements SVGSerializable {
837
889
  }
838
890
  return new Bounds(min, max);
839
891
  }
892
+ //--- END --- Implement interface `IBounded`
840
893
 
841
894
  /**
842
895
  * Get n 'equally' distributed vertices along this Bézier path.
package/src/ts/Bounds.ts CHANGED
@@ -9,13 +9,16 @@
9
9
  * @modified 2022-10-09 Added the `fromDimension` function.
10
10
  * @modified 2022-11-28 Added the `clone` method.
11
11
  * @modified 2023-09-29 Added the `randomPoint` method.
12
- * @version 1.7.0
12
+ * @modified 2025-03-23 Added the `getMinDimension` and `getMaxDimension` methods.
13
+ * @modified 2025-04-18 Change parameter type in `Bounds.computeFromVertices` from `Vertex` to more general `XYCoords`.
14
+ * @modified 2025-04-19 Added methods to `Bounds` class: `getNorthPoint`, `getSouthPoint`, `getEastPoint` and `getWestPoint`.
15
+ * @modified 2025-04-26 Added static method `Bounds.computeFromBoundsSet` to calculate containing bounds for a set of bounding boxes.
16
+ * @version 1.8.0
13
17
  **/
14
18
 
15
19
  import { Polygon } from "./Polygon";
16
20
  import { XYCoords, IBounds, XYDimension } from "./interfaces";
17
21
  import { Vertex } from "./Vertex";
18
- import { VertTuple } from "./VertTuple";
19
22
 
20
23
  /**
21
24
  * @classdesc A bounds class with min and max values. Implementing IBounds.
@@ -72,6 +75,55 @@ export class Bounds implements IBounds, XYDimension {
72
75
  this.height = max.y - min.y;
73
76
  }
74
77
 
78
+ /**
79
+ * Get the center point of the north bound.
80
+ *
81
+ * @method getNorthPoint
82
+ * @instance
83
+ * @memberof Bounds
84
+ * @return {Vertex} The "northmost" centered point of this bounding box.
85
+ */
86
+ getNorthPoint() : Vertex {
87
+ return new Vertex(this.min.x + this.width/2.0, this.min.y );
88
+ };
89
+
90
+ /**
91
+ * Get the center point of the south bound.
92
+ *
93
+ * @method getNorthPoint
94
+ * @instance
95
+ * @memberof Bounds
96
+ * @return {Vertex} The "southhmost" centered point of this bounding box.
97
+ */
98
+ getSouthPoint() : Vertex {
99
+ return new Vertex( this.min.x + this.width/2.0, this.max.y );
100
+ };
101
+
102
+ /**
103
+ * Get the center point of the west bound.
104
+ *
105
+ * @method getWestPoint
106
+ * @instance
107
+ * @memberof Bounds
108
+ * @return {Vertex} The "westhmost" centered point of this bounding box.
109
+ */
110
+ getWestPoint() : Vertex {
111
+ return new Vertex( this.min.x, this.min.y + this.height/2.0 );
112
+ };
113
+
114
+ /**
115
+ * Get the center point of the east bound.
116
+ *
117
+ * @method getEastPoint
118
+ * @instance
119
+ * @memberof Bounds
120
+ * @return {Vertex} The "easthmost" centered point of this bounding box.
121
+ */
122
+ getEastPoint() : Vertex {
123
+ return new Vertex( this.max.x, this.min.y + this.height/2.0 );
124
+ };
125
+
126
+
75
127
  /**
76
128
  * Convert this rectangular bounding box to a polygon with four vertices.
77
129
  *
@@ -99,6 +151,24 @@ export class Bounds implements IBounds, XYDimension {
99
151
  return new Vertex(this.min.x + (this.max.x - this.min.x) / 2.0, this.min.y + (this.max.y - this.min.y) / 2);
100
152
  }
101
153
 
154
+ /**
155
+ * Get the minimum of `width` and `height`.
156
+ *
157
+ * @returns {number} The value of Math.min( this.width, this.height )
158
+ */
159
+ getMinDimension(): number {
160
+ return Math.min(this.width, this.height);
161
+ }
162
+
163
+ /**
164
+ * Get the minimum of `width` and `height`.
165
+ *
166
+ * @returns {number} The value of Math.min( this.width, this.height )
167
+ */
168
+ getMaxDimension(): number {
169
+ return Math.max(this.width, this.height);
170
+ }
171
+
102
172
  /**
103
173
  * Generate a random point inside this bounds object. Safe areas at the border to avoid
104
174
  * included.
@@ -156,18 +226,20 @@ export class Bounds implements IBounds, XYDimension {
156
226
  * @static
157
227
  * @method computeFromVertices
158
228
  * @memberof Bounds
159
- * @param {Array<Vertex>} vertices - The set of vertices you want to get the bounding box for.
229
+ * @param {Array<XYCoords>} vertices - The set of vertices you want to get the bounding box for.
160
230
  * @return The minimal Bounds for the given vertices.
161
231
  **/
162
- static computeFromVertices(vertices: Array<Vertex>): Bounds {
163
- if (vertices.length == 0) return new Bounds(new Vertex(0, 0), new Vertex(0, 0));
232
+ static computeFromVertices(vertices: Array<XYCoords>): Bounds {
233
+ if (vertices.length == 0) {
234
+ return new Bounds(new Vertex(0, 0), new Vertex(0, 0));
235
+ }
164
236
 
165
237
  let xMin = vertices[0].x;
166
238
  let xMax = vertices[0].x;
167
239
  let yMin = vertices[0].y;
168
240
  let yMax = vertices[0].y;
169
241
 
170
- let vert: Vertex;
242
+ let vert: XYCoords;
171
243
  for (var i in vertices) {
172
244
  vert = vertices[i];
173
245
  xMin = Math.min(xMin, vert.x);
@@ -178,6 +250,38 @@ export class Bounds implements IBounds, XYDimension {
178
250
  return new Bounds(new Vertex(xMin, yMin), new Vertex(xMax, yMax));
179
251
  }
180
252
 
253
+ /**
254
+ * Compute the minimal bounding box for a given set of existing bounding boxes.
255
+ *
256
+ * An empty vertex array will return an empty bounding box located at (0,0).
257
+ *
258
+ * @static
259
+ * @method computeFromBoundsSet
260
+ * @memberof Bounds
261
+ * @param {Array<IBounds>} boundingBoxes - The set of existing bounding boxes to get the containing bounding box for.
262
+ * @return The minimal Bounds for the given bounds instances.
263
+ **/
264
+ static computeFromBoundsSet(boundingBoxes:Array<IBounds>) : Bounds {
265
+ if (boundingBoxes.length == 0) {
266
+ return new Bounds(new Vertex(0, 0), new Vertex(0, 0));
267
+ }
268
+
269
+ let xMin = boundingBoxes[0].min.x;
270
+ let xMax = boundingBoxes[0].max.x;
271
+ let yMin = boundingBoxes[0].min.y;
272
+ let yMax = boundingBoxes[0].min.y;
273
+
274
+ let bounds: IBounds;
275
+ for (var i in boundingBoxes) {
276
+ bounds = boundingBoxes[i];
277
+ xMin = Math.min(xMin, bounds.min.x);
278
+ xMax = Math.max(xMax, bounds.max.x);
279
+ yMin = Math.min(yMin, bounds.min.y);
280
+ yMax = Math.max(yMax, bounds.min.y);
281
+ }
282
+ return new Bounds(new Vertex(xMin, yMin), new Vertex(xMax, yMax));
283
+ }
284
+
181
285
  /**
182
286
  * Create a new `Bounds` instance just from `width` and `height`, located at (0,0) or the optionally given origin.
183
287
  *