plotboilerplate 1.24.0 → 1.26.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 (222) hide show
  1. package/README.md +14 -1
  2. package/dist/index.esm.js +433 -162
  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 +12312 -12041
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +9 -5
  11. package/src/cjs/Bounds.d.ts +79 -25
  12. package/src/cjs/Bounds.js +102 -29
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/CircleSector.d.ts +3 -0
  15. package/src/cjs/CircleSector.js +28 -1
  16. package/src/cjs/CircleSector.js.map +1 -1
  17. package/src/cjs/PlotBoilerplate.d.ts +37 -6
  18. package/src/cjs/PlotBoilerplate.js +222 -116
  19. package/src/cjs/PlotBoilerplate.js.map +1 -1
  20. package/src/cjs/Polygon.d.ts +26 -7
  21. package/src/cjs/Polygon.js +56 -10
  22. package/src/cjs/Polygon.js.map +1 -1
  23. package/src/cjs/Triangle.js +2 -2
  24. package/src/cjs/Triangle.js.map +1 -1
  25. package/src/cjs/Vertex.d.ts +15 -3
  26. package/src/cjs/Vertex.js +18 -1
  27. package/src/cjs/Vertex.js.map +1 -1
  28. package/src/cjs/drawutilssvg.d.ts +2 -1
  29. package/src/cjs/drawutilssvg.js +9 -3
  30. package/src/cjs/drawutilssvg.js.map +1 -1
  31. package/src/cjs/interfaces/core.d.ts +28 -0
  32. package/src/cjs/interfaces/core.js +2 -0
  33. package/src/cjs/interfaces/core.js.map +1 -1
  34. package/src/cjs/utils/LissajousFigure.d.ts +34 -0
  35. package/src/cjs/utils/LissajousFigure.js +100 -0
  36. package/src/cjs/utils/LissajousFigure.js.map +1 -0
  37. package/src/cjs/utils/PerlinNoise.d.ts +19 -0
  38. package/src/cjs/utils/PerlinNoise.js +352 -0
  39. package/src/cjs/utils/PerlinNoise.js.map +1 -0
  40. package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
  41. package/src/cjs/utils/SVGPathUtils.js +45 -0
  42. package/src/cjs/utils/SVGPathUtils.js.map +1 -0
  43. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  44. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  45. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  46. package/src/cjs/utils/datastructures/Color.d.ts +147 -1
  47. package/src/cjs/utils/datastructures/Color.js +385 -41
  48. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  49. package/src/cjs/utils/datastructures/ColorGradient.d.ts +79 -0
  50. package/src/cjs/utils/datastructures/ColorGradient.js +171 -0
  51. package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -0
  52. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
  53. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  54. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
  55. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  56. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  57. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  58. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  59. package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
  60. package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
  61. package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
  62. package/src/cjs/utils/detectDarkMode.js +16 -7
  63. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  64. package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  65. package/src/cjs/utils/dom/components/ColorGradientPicker.js +667 -0
  66. package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
  67. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  68. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
  69. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  70. package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  71. package/src/cjs/utils/dom/components/ColorGradientSelector.js +327 -0
  72. package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
  73. package/src/cjs/utils/dom/components/Test.d.ts +7 -0
  74. package/src/cjs/utils/dom/components/Test.js +30 -0
  75. package/src/cjs/utils/dom/components/Test.js.map +1 -0
  76. package/src/cjs/utils/dom/guiSizeToggler.js +1 -1
  77. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  78. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  79. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +20 -13
  80. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  81. package/src/cjs/utils/helpers/CircleHelper.d.ts +10 -1
  82. package/src/cjs/utils/helpers/CircleHelper.js +13 -2
  83. package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
  84. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +2 -2
  85. package/src/cjs/utils/helpers/CircleSectorHelper.js +1 -0
  86. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  87. package/src/cjs/utils/helpers/TriangleHelper.d.ts +57 -0
  88. package/src/cjs/utils/helpers/TriangleHelper.js +83 -0
  89. package/src/cjs/utils/helpers/TriangleHelper.js.map +1 -0
  90. package/src/cjs/utils/helpers/VEllipseHelper.d.ts +6 -4
  91. package/src/cjs/utils/helpers/VEllipseHelper.js +4 -2
  92. package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -1
  93. package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  94. package/src/cjs/utils/helpers/VEllipseSectorHelper.js +1 -0
  95. package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  96. package/src/cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  97. package/src/cjs/utils/parsers/LinearColorGradientParser.js +224 -0
  98. package/src/cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
  99. package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
  100. package/src/createDemoDrawables.js +1 -0
  101. package/src/esm/Bounds.d.ts +79 -25
  102. package/src/esm/Bounds.js +102 -29
  103. package/src/esm/Bounds.js.map +1 -1
  104. package/src/esm/CircleSector.d.ts +3 -0
  105. package/src/esm/CircleSector.js +28 -1
  106. package/src/esm/CircleSector.js.map +1 -1
  107. package/src/esm/PlotBoilerplate.d.ts +37 -6
  108. package/src/esm/PlotBoilerplate.js +222 -116
  109. package/src/esm/PlotBoilerplate.js.map +1 -1
  110. package/src/esm/Polygon.d.ts +26 -7
  111. package/src/esm/Polygon.js +53 -10
  112. package/src/esm/Polygon.js.map +1 -1
  113. package/src/esm/Triangle.js +2 -2
  114. package/src/esm/Triangle.js.map +1 -1
  115. package/src/esm/Vertex.d.ts +15 -3
  116. package/src/esm/Vertex.js +18 -1
  117. package/src/esm/Vertex.js.map +1 -1
  118. package/src/esm/drawutilssvg.d.ts +2 -1
  119. package/src/esm/drawutilssvg.js +9 -3
  120. package/src/esm/drawutilssvg.js.map +1 -1
  121. package/src/esm/interfaces/core.d.ts +28 -0
  122. package/src/esm/interfaces/core.js +2 -0
  123. package/src/esm/interfaces/core.js.map +1 -1
  124. package/src/esm/utils/LissajousFigure.d.ts +34 -0
  125. package/src/esm/utils/LissajousFigure.js +95 -0
  126. package/src/esm/utils/LissajousFigure.js.map +1 -0
  127. package/src/esm/utils/PerlinNoise.d.ts +19 -0
  128. package/src/esm/utils/PerlinNoise.js +346 -0
  129. package/src/esm/utils/PerlinNoise.js.map +1 -0
  130. package/src/esm/utils/SVGPathUtils.d.ts +22 -0
  131. package/src/esm/utils/SVGPathUtils.js +42 -0
  132. package/src/esm/utils/SVGPathUtils.js.map +1 -0
  133. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  134. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
  135. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  136. package/src/esm/utils/datastructures/Color.d.ts +147 -1
  137. package/src/esm/utils/datastructures/Color.js +386 -42
  138. package/src/esm/utils/datastructures/Color.js.map +1 -1
  139. package/src/esm/utils/datastructures/ColorGradient.d.ts +79 -0
  140. package/src/esm/utils/datastructures/ColorGradient.js +166 -0
  141. package/src/esm/utils/datastructures/ColorGradient.js.map +1 -0
  142. package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
  143. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  144. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
  145. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  146. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  147. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  148. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  149. package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
  150. package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
  151. package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
  152. package/src/esm/utils/detectDarkMode.js +16 -7
  153. package/src/esm/utils/detectDarkMode.js.map +1 -1
  154. package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  155. package/src/esm/utils/dom/components/ColorGradientPicker.js +743 -0
  156. package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
  157. package/src/esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  158. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
  159. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  160. package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  161. package/src/esm/utils/dom/components/ColorGradientSelector.js +339 -0
  162. package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
  163. package/src/esm/utils/dom/components/Test.d.ts +7 -0
  164. package/src/esm/utils/dom/components/Test.js +26 -0
  165. package/src/esm/utils/dom/components/Test.js.map +1 -0
  166. package/src/esm/utils/dom/guiSizeToggler.js +1 -1
  167. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  168. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  169. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +20 -13
  170. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  171. package/src/esm/utils/helpers/CircleHelper.d.ts +10 -1
  172. package/src/esm/utils/helpers/CircleHelper.js +13 -2
  173. package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
  174. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +2 -2
  175. package/src/esm/utils/helpers/CircleSectorHelper.js +1 -0
  176. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  177. package/src/esm/utils/helpers/TriangleHelper.d.ts +57 -0
  178. package/src/esm/utils/helpers/TriangleHelper.js +78 -0
  179. package/src/esm/utils/helpers/TriangleHelper.js.map +1 -0
  180. package/src/esm/utils/helpers/VEllipseHelper.d.ts +6 -4
  181. package/src/esm/utils/helpers/VEllipseHelper.js +4 -2
  182. package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -1
  183. package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  184. package/src/esm/utils/helpers/VEllipseSectorHelper.js +1 -0
  185. package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  186. package/src/esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  187. package/src/esm/utils/parsers/LinearColorGradientParser.js +217 -0
  188. package/src/esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
  189. package/src/esm/utils/parsers/svg/types.d.ts +8 -8
  190. package/src/external.d.ts +9 -0
  191. package/src/ts/Bounds.ts +107 -22
  192. package/src/ts/CircleSector.ts +39 -6
  193. package/src/ts/PlotBoilerplate.ts +233 -105
  194. package/src/ts/Polygon.ts +68 -14
  195. package/src/ts/Triangle.ts +2 -2
  196. package/src/ts/Vertex.ts +21 -3
  197. package/src/ts/drawutilssvg.ts +8 -3
  198. package/src/ts/interfaces/core.ts +31 -0
  199. package/src/ts/utils/LissajousFigure.ts +110 -0
  200. package/src/ts/utils/PerlinNoise.ts +368 -0
  201. package/src/ts/utils/SVGPathUtils.ts +55 -0
  202. package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
  203. package/src/ts/utils/datastructures/Color.ts +423 -44
  204. package/src/ts/utils/datastructures/ColorGradient.ts +196 -0
  205. package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
  206. package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
  207. package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
  208. package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
  209. package/src/ts/utils/detectDarkMode.ts +17 -8
  210. package/src/ts/utils/dom/components/ColorGradientPicker.tsx +889 -0
  211. package/src/ts/utils/dom/components/ColorGradientSelector.tsx +452 -0
  212. package/src/ts/utils/dom/components/Test.tsx +44 -0
  213. package/src/ts/utils/dom/components/_ColorGradientPicker_raw.ts_ +392 -0
  214. package/src/ts/utils/dom/guiSizeToggler.ts +1 -1
  215. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +25 -15
  216. package/src/ts/utils/helpers/CircleHelper.ts +17 -3
  217. package/src/ts/utils/helpers/CircleSectorHelper.ts +4 -2
  218. package/src/ts/utils/helpers/TriangleHelper.ts +102 -0
  219. package/src/ts/utils/helpers/VEllipseHelper.ts +6 -4
  220. package/src/ts/utils/helpers/VEllipseSectorHelper.ts +3 -2
  221. package/src/ts/utils/parsers/LinearColorGradientParser.ts +297 -0
  222. package/src/ts/utils/parsers/svg/types.ts +8 -8
package/src/ts/Vertex.ts CHANGED
@@ -35,7 +35,8 @@
35
35
  * @modified 2024-12-17 Outsourced the euclidean distance calculation of `Vertex.distance` to `geomutils.dist4`.
36
36
  * @modified 2025-03-24 Making the second parameter `center` of the `Vertex.rotate` method optional.
37
37
  * @modified 2025-04-13 Adding the `Vertex.move(amount: XYCoords)` method (does the same as `add`, added by naming convention).
38
- * @version 2.10.0
38
+ * @modified 2025-05-07 Class `Vertex` is now implementing interface `IBounded` (to meet convention).
39
+ * @version 2.11.0
39
40
  *
40
41
  * @file Vertex
41
42
  * @public
@@ -44,8 +45,9 @@
44
45
  import { IVertexAttr, VertexAttr } from "./VertexAttr";
45
46
  import { UIDGenerator } from "./UIDGenerator";
46
47
  import { VertexListeners } from "./VertexListeners";
47
- import { XYCoords, SVGSerializable, UID } from "./interfaces";
48
+ import { XYCoords, SVGSerializable, UID, IBounded } from "./interfaces";
48
49
  import { geomutils } from "./geomutils";
50
+ import { Bounds } from "./Bounds";
49
51
 
50
52
  /**
51
53
  * @classdesc A vertex is a pair of two numbers.<br>
@@ -61,7 +63,7 @@ import { geomutils } from "./geomutils";
61
63
  * @requires XYCoords
62
64
  *
63
65
  */
64
- export class Vertex implements XYCoords, SVGSerializable {
66
+ export class Vertex implements IBounded, XYCoords, SVGSerializable {
65
67
  private static readonly ZERO = new Vertex(0, 0);
66
68
 
67
69
  /**
@@ -645,6 +647,22 @@ export class Vertex implements XYCoords, SVGSerializable {
645
647
  return this;
646
648
  }
647
649
 
650
+ //--- BEGIN --- Implement interface `IBounded`
651
+ /**
652
+ * Get the bounding box (bounds) of this Vertex.
653
+ * This is just by convention – any vertex is just a position without any useful with or height (0).
654
+ *
655
+ * @method getBounds
656
+ * @instance
657
+ * @memberof Vertex
658
+ * @return {Bounds} The rectangular bounds of this Vertex (width and height are zero).
659
+ **/
660
+ getBounds(): Bounds {
661
+ // return Bounds.computeFromVertices([this.a, this.b, this.c]);
662
+ return Bounds.computeFromVertices([this]);
663
+ }
664
+ //--- END --- Implement interface `IBounded`
665
+
648
666
  /**
649
667
  * Get a string representation of this vertex.
650
668
  *
@@ -47,7 +47,8 @@
47
47
  * @modified 2024-01-30 Fixing an issue with immutable style sets; changes to the global draw config did not reflect here (do now).
48
48
  * @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
49
49
  * @modified 2024-07-24 Caching custom style defs in a private buffer variable.
50
- * @version 1.6.10
50
+ * @modified 2025-11-14 Fixing a bug in the CSS `mix-blend-mode` property handling (caused a runtime error).
51
+ * @version 1.6.11
51
52
  **/
52
53
 
53
54
  import { CircleSector } from "./CircleSector";
@@ -416,8 +417,12 @@ export class drawutilssvg implements DrawLib<void | SVGElement> {
416
417
  node = this.createSVGNode(nodeName);
417
418
  }
418
419
  if (this.drawlibConfiguration.blendMode) {
419
- // node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
420
- node.style["mix-blend-mode" as keyof Object](this.drawlibConfiguration.blendMode);
420
+ const blendMode = node.style["mix-blend-mode" as keyof Object];
421
+ if (typeof blendMode === "function") {
422
+ blendMode(this.drawlibConfiguration.blendMode);
423
+ } else {
424
+ node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
425
+ }
421
426
  }
422
427
  // if (this.lineDashEnabled && this.lineDash && this.lineDash.length > 0 && drawutilssvg.nodeSupportsLineDash(nodeName)) {
423
428
  // node.setAttribute("stroke-dasharray", this.lineDash.join(" "));
@@ -22,6 +22,8 @@
22
22
  * @modified 2024-08-25 Added the `CSSBackdropFilterParams` params to the global params (all optional).
23
23
  * @modified 2025-03-29 Added interface `Intersectable`.
24
24
  * @modified 2025-04-16 Added interface `IBounded`.
25
+ * @modified 2025-05-07 Added callback `onContentChanged` to PB to track if the drawable content changed.
26
+ * @modified 2025-06-07 Adding helper type `PolygonIntersectionTuple` for re-usability.
25
27
  **/
26
28
 
27
29
  import { Vertex } from "../Vertex";
@@ -114,6 +116,18 @@ export interface CanvasWrapper {
114
116
  setSize: (width: number, height: number) => void;
115
117
  element: HTMLCanvasElement | SVGElement;
116
118
  }
119
+
120
+ /**
121
+ * The interface for PB change events.
122
+ */
123
+ export interface IPBChangeEvent {
124
+ type: "DRAWABLES_ADDED" | "DRAWABLES_REMOVED";
125
+ addedDrawables: Array<Drawable>;
126
+ removedDrawables: Array<Drawable>;
127
+ }
128
+
129
+ export type PBContentChangeListener = (event: IPBChangeEvent) => void; // A callback function that will be triggered after content changed.
130
+
117
131
  /**
118
132
  * The config that's used by PB.
119
133
  */
@@ -303,3 +317,20 @@ export interface IBounded {
303
317
  **/
304
318
  getBounds(): IBounds;
305
319
  }
320
+
321
+ export interface IShapeInteractionHelper {
322
+ /**
323
+ * Let this shape helper draw it's handle lines. It's up to the helper what they look like.
324
+ * @param {DrawLib<any>} draw - The draw library to use.
325
+ * @param {DrawLib<any>} fill - The fill library to use.
326
+ */
327
+ drawHandleLines(draw: DrawLib<any>, fill: DrawLib<any>): void;
328
+
329
+ /**
330
+ * Destroys this helper. This means that all listeners get released and this helper
331
+ * will not receive or handle any events.
332
+ */
333
+ destroy(): void;
334
+ }
335
+
336
+ export type PolygonIntersectionTuple<T> = { edgeIndex: number; intersection: T };
@@ -0,0 +1,110 @@
1
+ /**
2
+ * A wrapper for Lissajous figure params.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2018-11-22
6
+ * @modified 2025-10-29 Ported to typescript from demo 13-lissajous.
7
+ * @version 1.0.0
8
+ */
9
+
10
+ import { Vertex } from "../Vertex";
11
+
12
+ export class LissajousFigure {
13
+ freqA: number;
14
+ freqB: number;
15
+ phaseA: number;
16
+ phaseB: number;
17
+
18
+ /**
19
+ * Create a new figure with the given settings.
20
+ * @param {number} freqA - The 'horizontal' frequency.
21
+ * @param {number} freqB - The 'vertical' frequency.
22
+ * @param {number} phaseA - The 'horizonal' phase shift.
23
+ * @param {number} phaseB - The 'vertical' phase shift.
24
+ */
25
+ constructor(freqA: number, freqB: number, phaseA: number, phaseB: number) {
26
+ this.freqA = freqA;
27
+ this.freqB = freqB;
28
+ this.phaseA = phaseA;
29
+ this.phaseB = phaseB;
30
+ }
31
+
32
+ /**
33
+ * Get the point at the given abstract time.
34
+ *
35
+ * The result is periodic in 0..TWO_PI.
36
+ *
37
+ * @param {number} t - The timing value (for example milliseconds).
38
+ * @returns {Vertex} The x-y-position on the Lissajous figure at the given time.
39
+ */
40
+ public getPointAt(t: number): Vertex {
41
+ return new Vertex(Math.sin(this.phaseA + this.freqA * t), Math.sin(this.phaseB + this.freqB * t));
42
+ }
43
+
44
+ public toPolyLine(stepSize: number): Array<Vertex> {
45
+ const polyLine: Array<Vertex> = [];
46
+
47
+ let pA = new Vertex(0, 0);
48
+
49
+ stepSize = Math.abs(stepSize);
50
+ for (var t = 0; t <= 2 * Math.PI; t += stepSize) {
51
+ pA = this.getPointAt(t);
52
+ polyLine.push(pA.clone());
53
+ }
54
+ return polyLine;
55
+ }
56
+
57
+ public toQuadraticBezierApproximation(
58
+ stepSize: number
59
+ // scale: number
60
+ // alternating: boolean
61
+ ): Array<[Vertex, Vertex, Vertex] | [Vertex, Vertex]> {
62
+ const result: Array<[Vertex, Vertex, Vertex] | [Vertex, Vertex]> = [];
63
+ let pA = new Vertex(0, 0);
64
+ let pB = new Vertex(0, 0);
65
+ stepSize = Math.abs(stepSize);
66
+
67
+ let p1 = new Vertex(0, 0);
68
+ let dx1 = this.freqA;
69
+ let dy1 = this.freqB;
70
+ pA = this.getPointAt(stepSize);
71
+ let x2, y2, dx2, dy2, det, x3, y3;
72
+ var i = 0;
73
+ for (var t = stepSize; t <= 2 * Math.PI + 2 * stepSize; t += stepSize) {
74
+ x2 = Math.sin(this.phaseA + this.freqA * t);
75
+ y2 = Math.sin(this.phaseB + this.freqB * t);
76
+ dx2 = this.freqA * Math.cos(this.phaseA + this.freqA * t);
77
+ dy2 = this.freqB * Math.cos(this.phaseB + this.freqB * t);
78
+ det = dx1 * dy2 - dy1 * dx2;
79
+ if (Math.abs(det) > 0.1) {
80
+ x3 = ((x2 * dy2 - y2 * dx2) * dx1 - (p1.x * dy1 - p1.y * dx1) * dx2) / det;
81
+ y3 = ((x2 * dy2 - y2 * dx2) * dy1 - (p1.x * dy1 - p1.y * dx1) * dy2) / det;
82
+ // pB.set(scale * x2, scale * y2 * (alternating ? -1 : 1));
83
+ // pB.set(scale * x2, scale * y2);
84
+ pB.set(x2, y2);
85
+
86
+ // pB.set(x2, y2);
87
+
88
+ if (i > 0) {
89
+ // pb.draw.quadraticBezier(pA, new Vertex(scale * x3, scale * y3), pB, "rgba(0,108,255,1.0)", 2);
90
+ // result.push([pA.clone(), new Vertex(scale * x3, scale * y3), pB.clone()]);
91
+ result.push([pA.clone(), new Vertex(x3, y3), pB.clone()]);
92
+ }
93
+ } else {
94
+ // pB.set(scale * x2, scale * y2);
95
+ pB.set(x2, y2);
96
+
97
+ if (i > 0) {
98
+ // pb.draw.line(pA, pB, "rgba(0,192,192,0.8)", 2);
99
+ result.push([pA.clone(), pB.clone()]);
100
+ }
101
+ }
102
+ p1.set(x2, y2);
103
+ dx1 = dx2;
104
+ dy1 = dy2;
105
+ pA.set(pB);
106
+ i++;
107
+ } // END for
108
+ return result;
109
+ }
110
+ }
@@ -0,0 +1,368 @@
1
+ /*
2
+ * A speed-improved perlin and simplex noise algorithms for 2D.
3
+ *
4
+ * Based on example code by Stefan Gustavson (stegu@itn.liu.se).
5
+ * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
6
+ * Better rank ordering method by Stefan Gustavson in 2012.
7
+ * Converted to Javascript by Joseph Gentle.
8
+ *
9
+ * Version 2012-03-09
10
+ *
11
+ * This code was placed in the public domain by its original author,
12
+ * Stefan Gustavson. You may use it as you see fit, but
13
+ * attribution is appreciated.
14
+ *
15
+ * @modified 2023-03-07 Ikaros Kappler; ported to Typescript & refactored to class.
16
+ * @modified 2025-11-12 Ikaros Kappler; moved from a different project `floatsim` and refactored the class.
17
+ */
18
+
19
+ class Grad {
20
+ x: number;
21
+ y: number;
22
+ z: number;
23
+ constructor(x: number, y: number, z: number) {
24
+ this.x = x;
25
+ this.y = y;
26
+ this.z = z;
27
+ }
28
+ dot2(x: number, y: number) {
29
+ return this.x * x + this.y * y;
30
+ }
31
+ dot3(x: number, y: number, z: number) {
32
+ return this.x * x + this.y * y + this.z * z;
33
+ }
34
+ }
35
+
36
+ const grad3: Array<Grad> = [
37
+ new Grad(1, 1, 0),
38
+ new Grad(-1, 1, 0),
39
+ new Grad(1, -1, 0),
40
+ new Grad(-1, -1, 0),
41
+ new Grad(1, 0, 1),
42
+ new Grad(-1, 0, 1),
43
+ new Grad(1, 0, -1),
44
+ new Grad(-1, 0, -1),
45
+ new Grad(0, 1, 1),
46
+ new Grad(0, -1, 1),
47
+ new Grad(0, 1, -1),
48
+ new Grad(0, -1, -1)
49
+ ];
50
+
51
+ const p: Array<number> = [
52
+ 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
53
+ 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20,
54
+ 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220,
55
+ 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196,
56
+ 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255,
57
+ 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221,
58
+ 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228,
59
+ 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106,
60
+ 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78,
61
+ 66, 215, 61, 156, 180
62
+ ];
63
+ // To remove the need for index wrapping, double the permutation table length
64
+ // const perm = new Array<number>(512);
65
+ // const gradP = new Array<Grad>(512);
66
+
67
+ // Skewing and unskewing factors for 2, 3, and 4 dimensions
68
+ const F2 = 0.5 * (Math.sqrt(3) - 1);
69
+ const G2 = (3 - Math.sqrt(3)) / 6;
70
+
71
+ const F3 = 1 / 3;
72
+ const G3 = 1 / 6;
73
+
74
+ const fade = (t: number) => {
75
+ return t * t * t * (t * (t * 6 - 15) + 10);
76
+ };
77
+
78
+ const lerp = (a: number, b: number, t: number) => {
79
+ return (1 - t) * a + t * b;
80
+ };
81
+
82
+ // export const noise = {
83
+ export class PerlinNoise {
84
+ // To remove the need for index wrapping, double the permutation table length
85
+ perm = new Array<number>(512);
86
+ gradP = new Array<Grad>(512);
87
+
88
+ constructor() {
89
+ // Use initial seed.
90
+ this.seed(0);
91
+ }
92
+
93
+ // This isn't a very good seeding function, but it works ok. It supports 2^16
94
+ // different seed values. Write something better if you need more seeds.
95
+ // module.seed = function (seed) {
96
+ seed(seed: number): PerlinNoise {
97
+ if (seed > 0 && seed < 1) {
98
+ // Scale the seed out
99
+ seed *= 65536;
100
+ }
101
+
102
+ seed = Math.floor(seed);
103
+ if (seed < 256) {
104
+ seed |= seed << 8;
105
+ }
106
+
107
+ for (var i = 0; i < 256; i++) {
108
+ var v: number;
109
+ if (i & 1) {
110
+ v = p[i] ^ (seed & 255);
111
+ } else {
112
+ v = p[i] ^ ((seed >> 8) & 255);
113
+ }
114
+
115
+ this.perm[i] = this.perm[i + 256] = v;
116
+ this.gradP[i] = this.gradP[i + 256] = grad3[v % 12];
117
+ }
118
+ return this;
119
+ }
120
+
121
+ // 2D simplex noise
122
+ simplex2(xin: number, yin: number): number {
123
+ var n0: number, n1: number, n2: number; // Noise contributions from the three corners
124
+ // Skew the input space to determine which simplex cell we're in
125
+ const s = (xin + yin) * F2; // Hairy factor for 2D
126
+ var i: number = Math.floor(xin + s);
127
+ var j: number = Math.floor(yin + s);
128
+ const t: number = (i + j) * G2;
129
+ const x0: number = xin - i + t; // The x,y distances from the cell origin, unskewed.
130
+ const y0: number = yin - j + t;
131
+ // For the 2D case, the simplex shape is an equilateral triangle.
132
+ // Determine which simplex we are in.
133
+ var i1: number, j1: number; // Offsets for second (middle) corner of simplex in (i,j) coords
134
+ if (x0 > y0) {
135
+ // lower triangle, XY order: (0,0)->(1,0)->(1,1)
136
+ i1 = 1;
137
+ j1 = 0;
138
+ } else {
139
+ // upper triangle, YX order: (0,0)->(0,1)->(1,1)
140
+ i1 = 0;
141
+ j1 = 1;
142
+ }
143
+ // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
144
+ // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
145
+ // c = (3-sqrt(3))/6
146
+ const x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords
147
+ const y1 = y0 - j1 + G2;
148
+ const x2 = x0 - 1 + 2 * G2; // Offsets for last corner in (x,y) unskewed coords
149
+ const y2 = y0 - 1 + 2 * G2;
150
+ // Work out the hashed gradient indices of the three simplex corners
151
+ i &= 255;
152
+ j &= 255;
153
+ const gi0 = this.gradP[i + this.perm[j]];
154
+ const gi1 = this.gradP[i + i1 + this.perm[j + j1]];
155
+ const gi2 = this.gradP[i + 1 + this.perm[j + 1]];
156
+ // Calculate the contribution from the three corners
157
+ var t0 = 0.5 - x0 * x0 - y0 * y0;
158
+ if (t0 < 0) {
159
+ n0 = 0;
160
+ } else {
161
+ t0 *= t0;
162
+ n0 = t0 * t0 * gi0.dot2(x0, y0); // (x,y) of grad3 used for 2D gradient
163
+ }
164
+ var t1 = 0.5 - x1 * x1 - y1 * y1;
165
+ if (t1 < 0) {
166
+ n1 = 0;
167
+ } else {
168
+ t1 *= t1;
169
+ n1 = t1 * t1 * gi1.dot2(x1, y1);
170
+ }
171
+ var t2 = 0.5 - x2 * x2 - y2 * y2;
172
+ if (t2 < 0) {
173
+ n2 = 0;
174
+ } else {
175
+ t2 *= t2;
176
+ n2 = t2 * t2 * gi2.dot2(x2, y2);
177
+ }
178
+ // Add contributions from each corner to get the final noise value.
179
+ // The result is scaled to return values in the interval [-1,1].
180
+ return 70 * (n0 + n1 + n2);
181
+ }
182
+
183
+ // 3D simplex noise
184
+ simplex3(xin: number, yin: number, zin: number): number {
185
+ var n0: number, n1: number, n2: number, n3: number; // Noise contributions from the four corners
186
+
187
+ // Skew the input space to determine which simplex cell we're in
188
+ const s: number = (xin + yin + zin) * F3; // Hairy factor for 2D
189
+ var i: number = Math.floor(xin + s);
190
+ var j: number = Math.floor(yin + s);
191
+ var k: number = Math.floor(zin + s);
192
+
193
+ const t: number = (i + j + k) * G3;
194
+ const x0: number = xin - i + t; // The x,y distances from the cell origin, unskewed.
195
+ const y0: number = yin - j + t;
196
+ const z0: number = zin - k + t;
197
+
198
+ // For the 3D case, the simplex shape is a slightly irregular tetrahedron.
199
+ // Determine which simplex we are in.
200
+ var i1: number, j1: number, k1: number; // Offsets for second corner of simplex in (i,j,k) coords
201
+ var i2: number, j2: number, k2: number; // Offsets for third corner of simplex in (i,j,k) coords
202
+ if (x0 >= y0) {
203
+ if (y0 >= z0) {
204
+ i1 = 1;
205
+ j1 = 0;
206
+ k1 = 0;
207
+ i2 = 1;
208
+ j2 = 1;
209
+ k2 = 0;
210
+ } else if (x0 >= z0) {
211
+ i1 = 1;
212
+ j1 = 0;
213
+ k1 = 0;
214
+ i2 = 1;
215
+ j2 = 0;
216
+ k2 = 1;
217
+ } else {
218
+ i1 = 0;
219
+ j1 = 0;
220
+ k1 = 1;
221
+ i2 = 1;
222
+ j2 = 0;
223
+ k2 = 1;
224
+ }
225
+ } else {
226
+ if (y0 < z0) {
227
+ i1 = 0;
228
+ j1 = 0;
229
+ k1 = 1;
230
+ i2 = 0;
231
+ j2 = 1;
232
+ k2 = 1;
233
+ } else if (x0 < z0) {
234
+ i1 = 0;
235
+ j1 = 1;
236
+ k1 = 0;
237
+ i2 = 0;
238
+ j2 = 1;
239
+ k2 = 1;
240
+ } else {
241
+ i1 = 0;
242
+ j1 = 1;
243
+ k1 = 0;
244
+ i2 = 1;
245
+ j2 = 1;
246
+ k2 = 0;
247
+ }
248
+ }
249
+ // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z),
250
+ // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and
251
+ // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where
252
+ // c = 1/6.
253
+ const x1: number = x0 - i1 + G3; // Offsets for second corner
254
+ const y1: number = y0 - j1 + G3;
255
+ const z1: number = z0 - k1 + G3;
256
+
257
+ const x2: number = x0 - i2 + 2 * G3; // Offsets for third corner
258
+ const y2: number = y0 - j2 + 2 * G3;
259
+ const z2: number = z0 - k2 + 2 * G3;
260
+
261
+ const x3: number = x0 - 1 + 3 * G3; // Offsets for fourth corner
262
+ const y3: number = y0 - 1 + 3 * G3;
263
+ const z3: number = z0 - 1 + 3 * G3;
264
+
265
+ // Work out the hashed gradient indices of the four simplex corners
266
+ i &= 255;
267
+ j &= 255;
268
+ k &= 255;
269
+ const gi0: Grad = this.gradP[i + this.perm[j + this.perm[k]]];
270
+ const gi1: Grad = this.gradP[i + i1 + this.perm[j + j1 + this.perm[k + k1]]];
271
+ const gi2: Grad = this.gradP[i + i2 + this.perm[j + j2 + this.perm[k + k2]]];
272
+ const gi3: Grad = this.gradP[i + 1 + this.perm[j + 1 + this.perm[k + 1]]];
273
+
274
+ // Calculate the contribution from the four corners
275
+ var t0: number = 0.5 - x0 * x0 - y0 * y0 - z0 * z0;
276
+ if (t0 < 0) {
277
+ n0 = 0;
278
+ } else {
279
+ t0 *= t0;
280
+ n0 = t0 * t0 * gi0.dot3(x0, y0, z0); // (x,y) of grad3 used for 2D gradient
281
+ }
282
+ var t1 = 0.5 - x1 * x1 - y1 * y1 - z1 * z1;
283
+ if (t1 < 0) {
284
+ n1 = 0;
285
+ } else {
286
+ t1 *= t1;
287
+ n1 = t1 * t1 * gi1.dot3(x1, y1, z1);
288
+ }
289
+ var t2 = 0.5 - x2 * x2 - y2 * y2 - z2 * z2;
290
+ if (t2 < 0) {
291
+ n2 = 0;
292
+ } else {
293
+ t2 *= t2;
294
+ n2 = t2 * t2 * gi2.dot3(x2, y2, z2);
295
+ }
296
+ var t3 = 0.5 - x3 * x3 - y3 * y3 - z3 * z3;
297
+ if (t3 < 0) {
298
+ n3 = 0;
299
+ } else {
300
+ t3 *= t3;
301
+ n3 = t3 * t3 * gi3.dot3(x3, y3, z3);
302
+ }
303
+ // Add contributions from each corner to get the final noise value.
304
+ // The result is scaled to return values in the interval [-1,1].
305
+ return 32 * (n0 + n1 + n2 + n3);
306
+ }
307
+
308
+ // 2D Perlin Noise
309
+ perlin2(x_init: number, y_init: number): number {
310
+ // Find unit grid cell containing point
311
+ var X: number = Math.floor(x_init),
312
+ Y: number = Math.floor(y_init);
313
+ // Get relative xy coordinates of point within that cell
314
+ const x: number = x_init - X;
315
+ const y: number = y_init - Y;
316
+ // Wrap the integer cells at 255 (smaller integer period can be introduced here)
317
+ X = X & 255;
318
+ Y = Y & 255;
319
+
320
+ // Calculate noise contributions from each of the four corners
321
+ const n00: number = this.gradP[X + this.perm[Y]].dot2(x, y);
322
+ const n01: number = this.gradP[X + this.perm[Y + 1]].dot2(x, y - 1);
323
+ const n10: number = this.gradP[X + 1 + this.perm[Y]].dot2(x - 1, y);
324
+ const n11: number = this.gradP[X + 1 + this.perm[Y + 1]].dot2(x - 1, y - 1);
325
+
326
+ // Compute the fade curve value for x
327
+ const u: number = fade(x);
328
+
329
+ // Interpolate the four results
330
+ return lerp(lerp(n00, n10, u), lerp(n01, n11, u), fade(y));
331
+ }
332
+
333
+ // 3D Perlin Noise
334
+ perlin3(x_init: number, y_init: number, z_init: number): number {
335
+ // Find unit grid cell containing point
336
+ var X: number = Math.floor(x_init),
337
+ Y: number = Math.floor(y_init),
338
+ Z: number = Math.floor(z_init);
339
+ // Get relative xyz coordinates of point within that cell
340
+ const x: number = x_init - X;
341
+ const y: number = y_init - Y;
342
+ const z: number = z_init - Z;
343
+ // Wrap the integer cells at 255 (smaller integer period can be introduced here)
344
+ X = X & 255;
345
+ Y = Y & 255;
346
+ Z = Z & 255;
347
+
348
+ // Calculate noise contributions from each of the eight corners
349
+ const n000: number = this.gradP[X + this.perm[Y + this.perm[Z]]].dot3(x, y, z);
350
+ const n001: number = this.gradP[X + this.perm[Y + this.perm[Z + 1]]].dot3(x, y, z - 1);
351
+ const n010: number = this.gradP[X + this.perm[Y + 1 + this.perm[Z]]].dot3(x, y - 1, z);
352
+ const n011: number = this.gradP[X + this.perm[Y + 1 + this.perm[Z + 1]]].dot3(x, y - 1, z - 1);
353
+ const n100: number = this.gradP[X + 1 + this.perm[Y + this.perm[Z]]].dot3(x - 1, y, z);
354
+ const n101: number = this.gradP[X + 1 + this.perm[Y + this.perm[Z + 1]]].dot3(x - 1, y, z - 1);
355
+ const n110: number = this.gradP[X + 1 + this.perm[Y + 1 + this.perm[Z]]].dot3(x - 1, y - 1, z);
356
+ const n111: number = this.gradP[X + 1 + this.perm[Y + 1 + this.perm[Z + 1]]].dot3(x - 1, y - 1, z - 1);
357
+
358
+ // Compute the fade curve value for x, y, z
359
+ const u: number = fade(x);
360
+ const v: number = fade(y);
361
+ const w: number = fade(z);
362
+
363
+ // Interpolate
364
+ return lerp(lerp(lerp(n000, n100, u), lerp(n001, n101, u), w), lerp(lerp(n010, n110, u), lerp(n011, n111, u), w), v);
365
+ }
366
+ }
367
+
368
+ // noise.seed(0);
@@ -0,0 +1,55 @@
1
+ /**
2
+ * A collection of SVG path generation tools.
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2025-04-04
6
+ * @version 1.0.0
7
+ */
8
+
9
+ import { Circle } from "../Circle";
10
+ import { Vertex } from "../Vertex";
11
+ import { geomutils } from "../geomutils";
12
+ import { SVGPathParams } from "../interfaces";
13
+
14
+ export const SVGPathUtils = {
15
+ /**
16
+ * Creates an SVG shape resembling a circlular ring sector.
17
+ *
18
+ * @param {Vertex} center - The center position of the ring.
19
+ * @param {number} innerRadius - The inner radius of the ring.
20
+ * @param {number} outerRadius - The outer radius of the ring.
21
+ * @param {number} startAngle - The start angle of the ring.
22
+ * @param {number} endAngle - The end angle of the ring.
23
+ * @returns {SVGPathParams} SVG path parmams for a closed shape representing the circular ring sector.
24
+ */
25
+ mkCircularRingSector: (
26
+ center: Vertex,
27
+ innerRadius: number,
28
+ outerRadius: number,
29
+ startAngle: number,
30
+ endAngle: number
31
+ ): SVGPathParams => {
32
+ const innerStart: Vertex = Circle.circleUtils.vertAt(startAngle, innerRadius).add(center);
33
+ const innerEnd: Vertex = Circle.circleUtils.vertAt(endAngle, innerRadius).add(center);
34
+ const outerStart: Vertex = Circle.circleUtils.vertAt(startAngle, outerRadius).add(center);
35
+ const outerEnd: Vertex = Circle.circleUtils.vertAt(endAngle, outerRadius).add(center);
36
+
37
+ const buffer: SVGPathParams = ["M", innerStart.x, innerStart.y];
38
+ // var isLargeArcRequired = geomutils.mapAngleTo2PI(Math.abs(startAngle - endAngle)) >= Math.PI;
39
+ // var isLargeArcRequired = Math.abs(geomutils.mapAngleTo2PI(startAngle) - geomutils.mapAngleTo2PI(endAngle)) >= Math.PI;
40
+ const isLargeArcRequired =
41
+ geomutils.mapAngleTo2PI(geomutils.mapAngleTo2PI(startAngle) - geomutils.mapAngleTo2PI(endAngle)) >= Math.PI;
42
+
43
+ const rotation: number = 0.0;
44
+ const innerLargeArcFlag: number = isLargeArcRequired ? 0 : 1;
45
+ const innerSweepFlag: number = 1; // isLargeArcRequired ? 1 : 0; // 1;
46
+ const outerLargeArcFlag: number = isLargeArcRequired ? 0 : 1;
47
+ const outerSweepFlag: number = 0; // isLargeArcRequired ? 0 : 1; // 0;
48
+ buffer.push("A", innerRadius, innerRadius, rotation, innerLargeArcFlag, innerSweepFlag, innerEnd.x, innerEnd.y);
49
+ buffer.push("L", outerEnd.x, outerEnd.y);
50
+ buffer.push("A", outerRadius, outerRadius, rotation, outerLargeArcFlag, outerSweepFlag, outerStart.x, outerStart.y);
51
+ buffer.push("Z");
52
+
53
+ return buffer;
54
+ }
55
+ };