plotboilerplate 1.27.0 → 1.28.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 (1107) hide show
  1. package/dist/index.esm.js +11286 -166
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +96 -17
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +2 -1
  10. package/src/_cjs/BezierPath.d.ts +610 -0
  11. package/src/_cjs/BezierPath.js +1127 -0
  12. package/src/_cjs/BezierPath.js.map +1 -0
  13. package/src/_cjs/Bounds.d.ts +252 -0
  14. package/src/_cjs/Bounds.js +320 -0
  15. package/src/_cjs/Bounds.js.map +1 -0
  16. package/src/_cjs/Circle.d.ts +214 -0
  17. package/src/_cjs/Circle.js +339 -0
  18. package/src/_cjs/Circle.js.map +1 -0
  19. package/src/_cjs/CircleSector.d.ts +211 -0
  20. package/src/_cjs/CircleSector.js +364 -0
  21. package/src/_cjs/CircleSector.js.map +1 -0
  22. package/src/_cjs/CubicBezierCurve.d.ts +656 -0
  23. package/src/_cjs/CubicBezierCurve.js +1062 -0
  24. package/src/_cjs/CubicBezierCurve.js.map +1 -0
  25. package/src/_cjs/Grid.d.ts +83 -0
  26. package/src/_cjs/Grid.js +90 -0
  27. package/src/_cjs/Grid.js.map +1 -0
  28. package/src/_cjs/KeyHandler.d.ts +177 -0
  29. package/src/_cjs/KeyHandler.js +435 -0
  30. package/src/_cjs/KeyHandler.js.map +1 -0
  31. package/src/_cjs/Line.d.ts +134 -0
  32. package/src/_cjs/Line.js +220 -0
  33. package/src/_cjs/Line.js.map +1 -0
  34. package/src/_cjs/MouseHandler.d.ts +283 -0
  35. package/src/_cjs/MouseHandler.js +423 -0
  36. package/src/_cjs/MouseHandler.js.map +1 -0
  37. package/src/_cjs/PBImage.d.ts +81 -0
  38. package/src/_cjs/PBImage.js +61 -0
  39. package/src/_cjs/PBImage.js.map +1 -0
  40. package/src/_cjs/PBText.d.ts +118 -0
  41. package/src/_cjs/PBText.js +63 -0
  42. package/src/_cjs/PBText.js.map +1 -0
  43. package/src/_cjs/PlotBoilerplate.d.ts +899 -0
  44. package/src/_cjs/PlotBoilerplate.js +2348 -0
  45. package/src/_cjs/PlotBoilerplate.js.map +1 -0
  46. package/src/_cjs/Polygon.d.ts +520 -0
  47. package/src/_cjs/Polygon.js +933 -0
  48. package/src/_cjs/Polygon.js.map +1 -0
  49. package/src/_cjs/SVGBuilder.d.ts +47 -0
  50. package/src/_cjs/SVGBuilder.js +100 -0
  51. package/src/_cjs/SVGBuilder.js.map +1 -0
  52. package/src/_cjs/Triangle.d.ts +392 -0
  53. package/src/_cjs/Triangle.js +497 -0
  54. package/src/_cjs/Triangle.js.map +1 -0
  55. package/src/_cjs/UIDGenerator.d.ts +12 -0
  56. package/src/_cjs/UIDGenerator.js +21 -0
  57. package/src/_cjs/UIDGenerator.js.map +1 -0
  58. package/src/_cjs/VEllipse.d.ts +319 -0
  59. package/src/_cjs/VEllipse.js +578 -0
  60. package/src/_cjs/VEllipse.js.map +1 -0
  61. package/src/_cjs/VEllipseSector.d.ts +230 -0
  62. package/src/_cjs/VEllipseSector.js +428 -0
  63. package/src/_cjs/VEllipseSector.js.map +1 -0
  64. package/src/_cjs/Vector.d.ts +126 -0
  65. package/src/_cjs/Vector.js +199 -0
  66. package/src/_cjs/Vector.js.map +1 -0
  67. package/src/_cjs/VertTuple.d.ts +284 -0
  68. package/src/_cjs/VertTuple.js +348 -0
  69. package/src/_cjs/VertTuple.js.map +1 -0
  70. package/src/_cjs/Vertex.d.ts +498 -0
  71. package/src/_cjs/Vertex.js +703 -0
  72. package/src/_cjs/Vertex.js.map +1 -0
  73. package/src/_cjs/VertexAttr.d.ts +72 -0
  74. package/src/_cjs/VertexAttr.js +59 -0
  75. package/src/_cjs/VertexAttr.js.map +1 -0
  76. package/src/_cjs/VertexListeners.d.ts +208 -0
  77. package/src/_cjs/VertexListeners.js +267 -0
  78. package/src/_cjs/VertexListeners.js.map +1 -0
  79. package/src/_cjs/draw.d.ts +657 -0
  80. package/src/_cjs/draw.js +1164 -0
  81. package/src/_cjs/draw.js.map +1 -0
  82. package/src/_cjs/drawgl.d.ts +544 -0
  83. package/src/_cjs/drawgl.js +794 -0
  84. package/src/_cjs/drawgl.js.map +1 -0
  85. package/src/_cjs/drawutilssvg.d.ts +954 -0
  86. package/src/_cjs/drawutilssvg.js +1713 -0
  87. package/src/_cjs/drawutilssvg.js.map +1 -0
  88. package/src/_cjs/entry-glsupport.js +28 -0
  89. package/src/_cjs/entry.js +29 -0
  90. package/src/_cjs/geomutils.d.ts +77 -0
  91. package/src/_cjs/geomutils.js +126 -0
  92. package/src/_cjs/geomutils.js.map +1 -0
  93. package/src/_cjs/index.d.ts +102 -0
  94. package/src/_cjs/index.js +128 -0
  95. package/src/_cjs/index.js.map +1 -0
  96. package/src/_cjs/interfaces/DrawLib.d.ts +582 -0
  97. package/src/_cjs/interfaces/DrawLib.js +32 -0
  98. package/src/_cjs/interfaces/DrawLib.js.map +1 -0
  99. package/src/_cjs/interfaces/additionals.d.ts +95 -0
  100. package/src/_cjs/interfaces/additionals.js +3 -0
  101. package/src/_cjs/interfaces/additionals.js.map +1 -0
  102. package/src/_cjs/interfaces/core.d.ts +286 -0
  103. package/src/_cjs/interfaces/core.js +30 -0
  104. package/src/_cjs/interfaces/core.js.map +1 -0
  105. package/src/_cjs/interfaces/externals.d.ts +56 -0
  106. package/src/_cjs/interfaces/externals.js +8 -0
  107. package/src/_cjs/interfaces/externals.js.map +1 -0
  108. package/src/_cjs/interfaces/index.d.ts +4 -0
  109. package/src/_cjs/interfaces/index.js +21 -0
  110. package/src/_cjs/interfaces/index.js.map +1 -0
  111. package/src/_cjs/module.d.ts +26 -0
  112. package/src/_cjs/module.js +60 -0
  113. package/src/_cjs/module.js.map +1 -0
  114. package/src/_cjs/utils/InitializationObserver.d.ts +18 -0
  115. package/src/_cjs/utils/InitializationObserver.js +63 -0
  116. package/src/_cjs/utils/InitializationObserver.js.map +1 -0
  117. package/src/_cjs/utils/LissajousFigure.d.ts +34 -0
  118. package/src/_cjs/utils/LissajousFigure.js +100 -0
  119. package/src/_cjs/utils/LissajousFigure.js.map +1 -0
  120. package/src/_cjs/utils/NGons.d.ts +13 -0
  121. package/src/_cjs/utils/NGons.js +36 -0
  122. package/src/_cjs/utils/NGons.js.map +1 -0
  123. package/src/_cjs/utils/Params.d.ts +17 -0
  124. package/src/_cjs/utils/Params.js +53 -0
  125. package/src/_cjs/utils/Params.js.map +1 -0
  126. package/src/_cjs/utils/PerlinNoise.d.ts +19 -0
  127. package/src/_cjs/utils/PerlinNoise.js +352 -0
  128. package/src/_cjs/utils/PerlinNoise.js.map +1 -0
  129. package/src/_cjs/utils/SVGPathUtils.d.ts +22 -0
  130. package/src/_cjs/utils/SVGPathUtils.js +45 -0
  131. package/src/_cjs/utils/SVGPathUtils.js.map +1 -0
  132. package/src/_cjs/utils/WebColors.d.ts +35 -0
  133. package/src/_cjs/utils/WebColors.js +58 -0
  134. package/src/_cjs/utils/WebColors.js.map +1 -0
  135. package/src/_cjs/utils/WebColorsContrast.d.ts +6 -0
  136. package/src/_cjs/utils/WebColorsContrast.js +12 -0
  137. package/src/_cjs/utils/WebColorsContrast.js.map +1 -0
  138. package/src/_cjs/utils/WebColorsMalachite.d.ts +12 -0
  139. package/src/_cjs/utils/WebColorsMalachite.js +28 -0
  140. package/src/_cjs/utils/WebColorsMalachite.js.map +1 -0
  141. package/src/_cjs/utils/algorithms/CatmullRomPath.d.ts +60 -0
  142. package/src/_cjs/utils/algorithms/CatmullRomPath.js +108 -0
  143. package/src/_cjs/utils/algorithms/CatmullRomPath.js.map +1 -0
  144. package/src/_cjs/utils/algorithms/CircleIntersections.d.ts +170 -0
  145. package/src/_cjs/utils/algorithms/CircleIntersections.js +310 -0
  146. package/src/_cjs/utils/algorithms/CircleIntersections.js.map +1 -0
  147. package/src/_cjs/utils/algorithms/ContourLineDetection.d.ts +150 -0
  148. package/src/_cjs/utils/algorithms/ContourLineDetection.js +367 -0
  149. package/src/_cjs/utils/algorithms/ContourLineDetection.js.map +1 -0
  150. package/src/_cjs/utils/algorithms/CubicSplinePath.d.ts +63 -0
  151. package/src/_cjs/utils/algorithms/CubicSplinePath.js +175 -0
  152. package/src/_cjs/utils/algorithms/CubicSplinePath.js.map +1 -0
  153. package/src/_cjs/utils/algorithms/HobbyPath.d.ts +81 -0
  154. package/src/_cjs/utils/algorithms/HobbyPath.js +278 -0
  155. package/src/_cjs/utils/algorithms/HobbyPath.js.map +1 -0
  156. package/src/_cjs/utils/algorithms/Metaballs.d.ts +30 -0
  157. package/src/_cjs/utils/algorithms/Metaballs.js +114 -0
  158. package/src/_cjs/utils/algorithms/Metaballs.js.map +1 -0
  159. package/src/_cjs/utils/algorithms/PolygonInset.d.ts +184 -0
  160. package/src/_cjs/utils/algorithms/PolygonInset.js +431 -0
  161. package/src/_cjs/utils/algorithms/PolygonInset.js.map +1 -0
  162. package/src/_cjs/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
  163. package/src/_cjs/utils/algorithms/PolygonTesselationOutlines.js +269 -0
  164. package/src/_cjs/utils/algorithms/PolygonTesselationOutlines.js.map +1 -0
  165. package/src/_cjs/utils/algorithms/arrayFill.d.ts +8 -0
  166. package/src/_cjs/utils/algorithms/arrayFill.js +18 -0
  167. package/src/_cjs/utils/algorithms/arrayFill.js.map +1 -0
  168. package/src/_cjs/utils/algorithms/arrayResize.d.ts +8 -0
  169. package/src/_cjs/utils/algorithms/arrayResize.js +24 -0
  170. package/src/_cjs/utils/algorithms/arrayResize.js.map +1 -0
  171. package/src/_cjs/utils/algorithms/arrayShuffle.d.ts +8 -0
  172. package/src/_cjs/utils/algorithms/arrayShuffle.js +15 -0
  173. package/src/_cjs/utils/algorithms/arrayShuffle.js.map +1 -0
  174. package/src/_cjs/utils/algorithms/clearDuplicateVertices.d.ts +22 -0
  175. package/src/_cjs/utils/algorithms/clearDuplicateVertices.js +51 -0
  176. package/src/_cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -0
  177. package/src/_cjs/utils/algorithms/clearPolygonDuplicateVertices.d.ts +24 -0
  178. package/src/_cjs/utils/algorithms/clearPolygonDuplicateVertices.js +61 -0
  179. package/src/_cjs/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -0
  180. package/src/_cjs/utils/algorithms/convexHull.d.ts +23 -0
  181. package/src/_cjs/utils/algorithms/convexHull.js +71 -0
  182. package/src/_cjs/utils/algorithms/convexHull.js.map +1 -0
  183. package/src/_cjs/utils/algorithms/convexPolygonIncircle.d.ts +41 -0
  184. package/src/_cjs/utils/algorithms/convexPolygonIncircle.js +145 -0
  185. package/src/_cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -0
  186. package/src/_cjs/utils/algorithms/delaunay.d.ts +30 -0
  187. package/src/_cjs/utils/algorithms/delaunay.js +158 -0
  188. package/src/_cjs/utils/algorithms/delaunay.js.map +1 -0
  189. package/src/_cjs/utils/algorithms/delaunay2voronoi.d.ts +25 -0
  190. package/src/_cjs/utils/algorithms/delaunay2voronoi.js +104 -0
  191. package/src/_cjs/utils/algorithms/delaunay2voronoi.js.map +1 -0
  192. package/src/_cjs/utils/algorithms/detectPaths.d.ts +21 -0
  193. package/src/_cjs/utils/algorithms/detectPaths.js +169 -0
  194. package/src/_cjs/utils/algorithms/detectPaths.js.map +1 -0
  195. package/src/_cjs/utils/algorithms/findPolygonSelfIntersections.d.ts +21 -0
  196. package/src/_cjs/utils/algorithms/findPolygonSelfIntersections.js +51 -0
  197. package/src/_cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -0
  198. package/src/_cjs/utils/algorithms/getContrastColor.d.ts +13 -0
  199. package/src/_cjs/utils/algorithms/getContrastColor.js +26 -0
  200. package/src/_cjs/utils/algorithms/getContrastColor.js.map +1 -0
  201. package/src/_cjs/utils/algorithms/matrixFill.d.ts +10 -0
  202. package/src/_cjs/utils/algorithms/matrixFill.js +21 -0
  203. package/src/_cjs/utils/algorithms/matrixFill.js.map +1 -0
  204. package/src/_cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  205. package/src/_cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  206. package/src/_cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  207. package/src/_cjs/utils/algorithms/splitPolygonToNonIntersecting.d.ts +28 -0
  208. package/src/_cjs/utils/algorithms/splitPolygonToNonIntersecting.js +102 -0
  209. package/src/_cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -0
  210. package/src/_cjs/utils/algorithms/sutherlandHodgman.d.ts +16 -0
  211. package/src/_cjs/utils/algorithms/sutherlandHodgman.js +76 -0
  212. package/src/_cjs/utils/algorithms/sutherlandHodgman.js.map +1 -0
  213. package/src/_cjs/utils/cloneVertexArray.d.ts +13 -0
  214. package/src/_cjs/utils/cloneVertexArray.js +23 -0
  215. package/src/_cjs/utils/cloneVertexArray.js.map +1 -0
  216. package/src/_cjs/utils/createRandomizedPolygon.d.ts +14 -0
  217. package/src/_cjs/utils/createRandomizedPolygon.js +32 -0
  218. package/src/_cjs/utils/createRandomizedPolygon.js.map +1 -0
  219. package/src/_cjs/utils/creategui.js +434 -0
  220. package/src/_cjs/utils/dat.gui.arrowbounce.polyfill.js +128 -0
  221. package/src/_cjs/utils/dat.gui.title.polyfill.js +35 -0
  222. package/src/_cjs/utils/datastructures/CircularIntervalSet.d.ts +83 -0
  223. package/src/_cjs/utils/datastructures/CircularIntervalSet.js +163 -0
  224. package/src/_cjs/utils/datastructures/CircularIntervalSet.js.map +1 -0
  225. package/src/_cjs/utils/datastructures/Color.d.ts +391 -0
  226. package/src/_cjs/utils/datastructures/Color.js +1084 -0
  227. package/src/_cjs/utils/datastructures/Color.js.map +1 -0
  228. package/src/_cjs/utils/datastructures/ColorGradient.d.ts +81 -0
  229. package/src/_cjs/utils/datastructures/ColorGradient.js +176 -0
  230. package/src/_cjs/utils/datastructures/ColorGradient.js.map +1 -0
  231. package/src/_cjs/utils/datastructures/DataGrid2d.d.ts +53 -0
  232. package/src/_cjs/utils/datastructures/DataGrid2d.js +20 -0
  233. package/src/_cjs/utils/datastructures/DataGrid2d.js.map +1 -0
  234. package/src/_cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  235. package/src/_cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
  236. package/src/_cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  237. package/src/_cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +59 -0
  238. package/src/_cjs/utils/datastructures/DataGrid2dListAdapter.js +84 -0
  239. package/src/_cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
  240. package/src/_cjs/utils/datastructures/GenericPath.d.ts +86 -0
  241. package/src/_cjs/utils/datastructures/GenericPath.js +122 -0
  242. package/src/_cjs/utils/datastructures/GenericPath.js.map +1 -0
  243. package/src/_cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
  244. package/src/_cjs/utils/datastructures/GeometryMesh.js +58 -0
  245. package/src/_cjs/utils/datastructures/GeometryMesh.js.map +1 -0
  246. package/src/_cjs/utils/datastructures/Girih.d.ts +181 -0
  247. package/src/_cjs/utils/datastructures/Girih.js +266 -0
  248. package/src/_cjs/utils/datastructures/Girih.js.map +1 -0
  249. package/src/_cjs/utils/datastructures/GirihBowtie.d.ts +37 -0
  250. package/src/_cjs/utils/datastructures/GirihBowtie.js +152 -0
  251. package/src/_cjs/utils/datastructures/GirihBowtie.js.map +1 -0
  252. package/src/_cjs/utils/datastructures/GirihDecagon.d.ts +52 -0
  253. package/src/_cjs/utils/datastructures/GirihDecagon.js +132 -0
  254. package/src/_cjs/utils/datastructures/GirihDecagon.js.map +1 -0
  255. package/src/_cjs/utils/datastructures/GirihHexagon.d.ts +39 -0
  256. package/src/_cjs/utils/datastructures/GirihHexagon.js +200 -0
  257. package/src/_cjs/utils/datastructures/GirihHexagon.js.map +1 -0
  258. package/src/_cjs/utils/datastructures/GirihPenroseRhombus.d.ts +46 -0
  259. package/src/_cjs/utils/datastructures/GirihPenroseRhombus.js +189 -0
  260. package/src/_cjs/utils/datastructures/GirihPenroseRhombus.js.map +1 -0
  261. package/src/_cjs/utils/datastructures/GirihPentagon.d.ts +37 -0
  262. package/src/_cjs/utils/datastructures/GirihPentagon.js +109 -0
  263. package/src/_cjs/utils/datastructures/GirihPentagon.js.map +1 -0
  264. package/src/_cjs/utils/datastructures/GirihRhombus.d.ts +38 -0
  265. package/src/_cjs/utils/datastructures/GirihRhombus.js +155 -0
  266. package/src/_cjs/utils/datastructures/GirihRhombus.js.map +1 -0
  267. package/src/_cjs/utils/datastructures/GirihTile.d.ts +283 -0
  268. package/src/_cjs/utils/datastructures/GirihTile.js +308 -0
  269. package/src/_cjs/utils/datastructures/GirihTile.js.map +1 -0
  270. package/src/_cjs/utils/datastructures/Matrix4x4.d.ts +244 -0
  271. package/src/_cjs/utils/datastructures/Matrix4x4.js +262 -0
  272. package/src/_cjs/utils/datastructures/Matrix4x4.js.map +1 -0
  273. package/src/_cjs/utils/datastructures/VoronoiCell.d.ts +122 -0
  274. package/src/_cjs/utils/datastructures/VoronoiCell.js +183 -0
  275. package/src/_cjs/utils/datastructures/VoronoiCell.js.map +1 -0
  276. package/src/_cjs/utils/datastructures/interfaces.d.ts +13 -0
  277. package/src/_cjs/utils/datastructures/interfaces.js +10 -0
  278. package/src/_cjs/utils/datastructures/interfaces.js.map +1 -0
  279. package/src/_cjs/utils/detectDarkMode.d.ts +10 -0
  280. package/src/_cjs/utils/detectDarkMode.js +41 -0
  281. package/src/_cjs/utils/detectDarkMode.js.map +1 -0
  282. package/src/_cjs/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  283. package/src/_cjs/utils/dom/components/ColorGradientPicker.js +667 -0
  284. package/src/_cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
  285. package/src/_cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  286. package/src/_cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
  287. package/src/_cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  288. package/src/_cjs/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  289. package/src/_cjs/utils/dom/components/ColorGradientSelector.js +327 -0
  290. package/src/_cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
  291. package/src/_cjs/utils/dom/components/Test.d.ts +7 -0
  292. package/src/_cjs/utils/dom/components/Test.js +30 -0
  293. package/src/_cjs/utils/dom/components/Test.js.map +1 -0
  294. package/src/_cjs/utils/dom/getAvailableContainerSpace.d.ts +2 -0
  295. package/src/_cjs/utils/dom/getAvailableContainerSpace.js +29 -0
  296. package/src/_cjs/utils/dom/getAvailableContainerSpace.js.map +1 -0
  297. package/src/_cjs/utils/dom/getFProp.d.ts +5 -0
  298. package/src/_cjs/utils/dom/getFProp.js +12 -0
  299. package/src/_cjs/utils/dom/getFProp.js.map +1 -0
  300. package/src/_cjs/utils/dom/guiSizeToggler.d.ts +18 -0
  301. package/src/_cjs/utils/dom/guiSizeToggler.js +44 -0
  302. package/src/_cjs/utils/dom/guiSizeToggler.js.map +1 -0
  303. package/src/_cjs/utils/findInVertexArray.d.ts +19 -0
  304. package/src/_cjs/utils/findInVertexArray.js +29 -0
  305. package/src/_cjs/utils/findInVertexArray.js.map +1 -0
  306. package/src/_cjs/utils/getFProp.d.ts +5 -0
  307. package/src/_cjs/utils/getFProp.js +12 -0
  308. package/src/_cjs/utils/getFProp.js.map +1 -0
  309. package/src/_cjs/utils/gup.d.ts +14 -0
  310. package/src/_cjs/utils/gup.js +31 -0
  311. package/src/_cjs/utils/gup.js.map +1 -0
  312. package/src/_cjs/utils/helpers/BezierPathInteractionHelper.d.ts +272 -0
  313. package/src/_cjs/utils/helpers/BezierPathInteractionHelper.js +655 -0
  314. package/src/_cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -0
  315. package/src/_cjs/utils/helpers/CircleHelper.d.ts +73 -0
  316. package/src/_cjs/utils/helpers/CircleHelper.js +93 -0
  317. package/src/_cjs/utils/helpers/CircleHelper.js.map +1 -0
  318. package/src/_cjs/utils/helpers/CircleSectorHelper.d.ts +90 -0
  319. package/src/_cjs/utils/helpers/CircleSectorHelper.js +114 -0
  320. package/src/_cjs/utils/helpers/CircleSectorHelper.js.map +1 -0
  321. package/src/_cjs/utils/helpers/TriangleHelper.d.ts +57 -0
  322. package/src/_cjs/utils/helpers/TriangleHelper.js +83 -0
  323. package/src/_cjs/utils/helpers/TriangleHelper.js.map +1 -0
  324. package/src/_cjs/utils/helpers/VEllipseHelper.d.ts +32 -0
  325. package/src/_cjs/utils/helpers/VEllipseHelper.js +88 -0
  326. package/src/_cjs/utils/helpers/VEllipseHelper.js.map +1 -0
  327. package/src/_cjs/utils/helpers/VEllipseSectorHelper.d.ts +52 -0
  328. package/src/_cjs/utils/helpers/VEllipseSectorHelper.js +135 -0
  329. package/src/_cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -0
  330. package/src/_cjs/utils/io/DndFileHandler.d.ts +63 -0
  331. package/src/_cjs/utils/io/DndFileHandler.js +112 -0
  332. package/src/_cjs/utils/io/DndFileHandler.js.map +1 -0
  333. package/src/_cjs/utils/io/FileDrop.d.ts +110 -0
  334. package/src/_cjs/utils/io/FileDrop.js +177 -0
  335. package/src/_cjs/utils/io/FileDrop.js.map +1 -0
  336. package/src/_cjs/utils/lil.gui.arrowbounce.polyfill.js +133 -0
  337. package/src/_cjs/utils/lil.gui.title.polyfill.js +32 -0
  338. package/src/_cjs/utils/module.js +18 -0
  339. package/src/_cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  340. package/src/_cjs/utils/parsers/LinearColorGradientParser.js +224 -0
  341. package/src/_cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
  342. package/src/_cjs/utils/parsers/OBJParser.d.ts +24 -0
  343. package/src/_cjs/utils/parsers/OBJParser.js +77 -0
  344. package/src/_cjs/utils/parsers/OBJParser.js.map +1 -0
  345. package/src/_cjs/utils/parsers/STLParser.d.ts +61 -0
  346. package/src/_cjs/utils/parsers/STLParser.js +182 -0
  347. package/src/_cjs/utils/parsers/STLParser.js.map +1 -0
  348. package/src/_cjs/utils/parsers/svg/parseSVGPathData.d.ts +27 -0
  349. package/src/_cjs/utils/parsers/svg/parseSVGPathData.js +486 -0
  350. package/src/_cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -0
  351. package/src/_cjs/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
  352. package/src/_cjs/utils/parsers/svg/splitSVGPathData.js +53 -0
  353. package/src/_cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -0
  354. package/src/_cjs/utils/parsers/svg/types.d.ts +63 -0
  355. package/src/_cjs/utils/parsers/svg/types.js +17 -0
  356. package/src/_cjs/utils/parsers/svg/types.js.map +1 -0
  357. package/src/_cjs/utils/ts-runner.js +146 -0
  358. package/src/_cjs/utils/tsAsyncScriptLoader.js +74 -0
  359. package/src/_esm/BezierPath.d.ts +610 -0
  360. package/src/_esm/BezierPath.js +1124 -0
  361. package/src/_esm/BezierPath.js.map +1 -0
  362. package/src/_esm/Bounds.d.ts +252 -0
  363. package/src/_esm/Bounds.js +317 -0
  364. package/src/_esm/Bounds.js.map +1 -0
  365. package/src/_esm/Circle.d.ts +214 -0
  366. package/src/_esm/Circle.js +335 -0
  367. package/src/_esm/Circle.js.map +1 -0
  368. package/src/_esm/CircleSector.d.ts +211 -0
  369. package/src/_esm/CircleSector.js +359 -0
  370. package/src/_esm/CircleSector.js.map +1 -0
  371. package/src/_esm/CubicBezierCurve.d.ts +656 -0
  372. package/src/_esm/CubicBezierCurve.js +1057 -0
  373. package/src/_esm/CubicBezierCurve.js.map +1 -0
  374. package/src/_esm/Grid.d.ts +83 -0
  375. package/src/_esm/Grid.js +89 -0
  376. package/src/_esm/Grid.js.map +1 -0
  377. package/src/_esm/KeyHandler.d.ts +177 -0
  378. package/src/_esm/KeyHandler.js +434 -0
  379. package/src/_esm/KeyHandler.js.map +1 -0
  380. package/src/_esm/Line.d.ts +134 -0
  381. package/src/_esm/Line.js +200 -0
  382. package/src/_esm/Line.js.map +1 -0
  383. package/src/_esm/MouseHandler.d.ts +283 -0
  384. package/src/_esm/MouseHandler.js +397 -0
  385. package/src/_esm/MouseHandler.js.map +1 -0
  386. package/src/_esm/PBImage.d.ts +81 -0
  387. package/src/_esm/PBImage.js +60 -0
  388. package/src/_esm/PBImage.js.map +1 -0
  389. package/src/_esm/PBText.d.ts +118 -0
  390. package/src/_esm/PBText.js +62 -0
  391. package/src/_esm/PBText.js.map +1 -0
  392. package/src/_esm/PlotBoilerplate.d.ts +899 -0
  393. package/src/_esm/PlotBoilerplate.js +2347 -0
  394. package/src/_esm/PlotBoilerplate.js.map +1 -0
  395. package/src/_esm/Polygon.d.ts +520 -0
  396. package/src/_esm/Polygon.js +924 -0
  397. package/src/_esm/Polygon.js.map +1 -0
  398. package/src/_esm/SVGBuilder.d.ts +47 -0
  399. package/src/_esm/SVGBuilder.js +95 -0
  400. package/src/_esm/SVGBuilder.js.map +1 -0
  401. package/src/_esm/Triangle.d.ts +392 -0
  402. package/src/_esm/Triangle.js +493 -0
  403. package/src/_esm/Triangle.js.map +1 -0
  404. package/src/_esm/UIDGenerator.d.ts +12 -0
  405. package/src/_esm/UIDGenerator.js +18 -0
  406. package/src/_esm/UIDGenerator.js.map +1 -0
  407. package/src/_esm/VEllipse.d.ts +319 -0
  408. package/src/_esm/VEllipse.js +574 -0
  409. package/src/_esm/VEllipse.js.map +1 -0
  410. package/src/_esm/VEllipseSector.d.ts +230 -0
  411. package/src/_esm/VEllipseSector.js +422 -0
  412. package/src/_esm/VEllipseSector.js.map +1 -0
  413. package/src/_esm/Vector.d.ts +126 -0
  414. package/src/_esm/Vector.js +181 -0
  415. package/src/_esm/Vector.js.map +1 -0
  416. package/src/_esm/VertTuple.d.ts +284 -0
  417. package/src/_esm/VertTuple.js +347 -0
  418. package/src/_esm/VertTuple.js.map +1 -0
  419. package/src/_esm/Vertex.d.ts +498 -0
  420. package/src/_esm/Vertex.js +702 -0
  421. package/src/_esm/Vertex.js.map +1 -0
  422. package/src/_esm/VertexAttr.d.ts +72 -0
  423. package/src/_esm/VertexAttr.js +58 -0
  424. package/src/_esm/VertexAttr.js.map +1 -0
  425. package/src/_esm/VertexListeners.d.ts +209 -0
  426. package/src/_esm/VertexListeners.js +270 -0
  427. package/src/_esm/VertexListeners.js.map +1 -0
  428. package/src/_esm/draw.d.ts +657 -0
  429. package/src/_esm/draw.js +1159 -0
  430. package/src/_esm/draw.js.map +1 -0
  431. package/src/_esm/drawgl.d.ts +544 -0
  432. package/src/_esm/drawgl.js +812 -0
  433. package/src/_esm/drawgl.js.map +1 -0
  434. package/src/_esm/drawutilssvg.d.ts +954 -0
  435. package/src/_esm/drawutilssvg.js +1705 -0
  436. package/src/_esm/drawutilssvg.js.map +1 -0
  437. package/src/_esm/entry-glsupport.js +28 -0
  438. package/src/_esm/entry.js +29 -0
  439. package/src/_esm/geomutils.d.ts +77 -0
  440. package/src/_esm/geomutils.js +126 -0
  441. package/src/_esm/geomutils.js.map +1 -0
  442. package/src/_esm/index.d.ts +102 -0
  443. package/src/_esm/index.js +128 -0
  444. package/src/_esm/index.js.map +1 -0
  445. package/src/_esm/interfaces/DrawLib.d.ts +582 -0
  446. package/src/_esm/interfaces/DrawLib.js +32 -0
  447. package/src/_esm/interfaces/DrawLib.js.map +1 -0
  448. package/src/_esm/interfaces/additionals.d.ts +95 -0
  449. package/src/_esm/interfaces/additionals.js +3 -0
  450. package/src/_esm/interfaces/additionals.js.map +1 -0
  451. package/src/_esm/interfaces/core.d.ts +286 -0
  452. package/src/_esm/interfaces/core.js +30 -0
  453. package/src/_esm/interfaces/core.js.map +1 -0
  454. package/src/_esm/interfaces/externals.d.ts +56 -0
  455. package/src/_esm/interfaces/externals.js +8 -0
  456. package/src/_esm/interfaces/externals.js.map +1 -0
  457. package/src/_esm/interfaces/index.d.ts +4 -0
  458. package/src/_esm/interfaces/index.js +21 -0
  459. package/src/_esm/interfaces/index.js.map +1 -0
  460. package/src/_esm/module.d.ts +26 -0
  461. package/src/_esm/module.js +60 -0
  462. package/src/_esm/module.js.map +1 -0
  463. package/src/_esm/src/ts/BezierPath.d.ts +610 -0
  464. package/src/_esm/src/ts/BezierPath.js +1120 -0
  465. package/src/_esm/src/ts/BezierPath.js.map +1 -0
  466. package/src/_esm/src/ts/Bounds.d.ts +252 -0
  467. package/src/_esm/src/ts/Bounds.js +313 -0
  468. package/src/_esm/src/ts/Bounds.js.map +1 -0
  469. package/src/_esm/src/ts/Circle.d.ts +214 -0
  470. package/src/_esm/src/ts/Circle.js +331 -0
  471. package/src/_esm/src/ts/Circle.js.map +1 -0
  472. package/src/_esm/src/ts/CircleSector.d.ts +211 -0
  473. package/src/_esm/src/ts/CircleSector.js +355 -0
  474. package/src/_esm/src/ts/CircleSector.js.map +1 -0
  475. package/src/_esm/src/ts/CubicBezierCurve.d.ts +656 -0
  476. package/src/_esm/src/ts/CubicBezierCurve.js +1053 -0
  477. package/src/_esm/src/ts/CubicBezierCurve.js.map +1 -0
  478. package/src/_esm/src/ts/Grid.d.ts +83 -0
  479. package/src/_esm/src/ts/Grid.js +85 -0
  480. package/src/_esm/src/ts/Grid.js.map +1 -0
  481. package/src/_esm/src/ts/KeyHandler.d.ts +177 -0
  482. package/src/_esm/src/ts/KeyHandler.js +430 -0
  483. package/src/_esm/src/ts/KeyHandler.js.map +1 -0
  484. package/src/_esm/src/ts/Line.d.ts +134 -0
  485. package/src/_esm/src/ts/Line.js +196 -0
  486. package/src/_esm/src/ts/Line.js.map +1 -0
  487. package/src/_esm/src/ts/MouseHandler.d.ts +283 -0
  488. package/src/_esm/src/ts/MouseHandler.js +391 -0
  489. package/src/_esm/src/ts/MouseHandler.js.map +1 -0
  490. package/src/_esm/src/ts/PBImage.d.ts +81 -0
  491. package/src/_esm/src/ts/PBImage.js +56 -0
  492. package/src/_esm/src/ts/PBImage.js.map +1 -0
  493. package/src/_esm/src/ts/PBText.d.ts +118 -0
  494. package/src/_esm/src/ts/PBText.js +58 -0
  495. package/src/_esm/src/ts/PBText.js.map +1 -0
  496. package/src/_esm/src/ts/PlotBoilerplate.d.ts +899 -0
  497. package/src/_esm/src/ts/PlotBoilerplate.js +2340 -0
  498. package/src/_esm/src/ts/PlotBoilerplate.js.map +1 -0
  499. package/src/_esm/src/ts/Polygon.d.ts +520 -0
  500. package/src/_esm/src/ts/Polygon.js +920 -0
  501. package/src/_esm/src/ts/Polygon.js.map +1 -0
  502. package/src/_esm/src/ts/Triangle.d.ts +392 -0
  503. package/src/_esm/src/ts/Triangle.js +489 -0
  504. package/src/_esm/src/ts/Triangle.js.map +1 -0
  505. package/src/_esm/src/ts/UIDGenerator.d.ts +12 -0
  506. package/src/_esm/src/ts/UIDGenerator.js +14 -0
  507. package/src/_esm/src/ts/UIDGenerator.js.map +1 -0
  508. package/src/_esm/src/ts/VEllipse.d.ts +319 -0
  509. package/src/_esm/src/ts/VEllipse.js +570 -0
  510. package/src/_esm/src/ts/VEllipse.js.map +1 -0
  511. package/src/_esm/src/ts/VEllipseSector.d.ts +230 -0
  512. package/src/_esm/src/ts/VEllipseSector.js +418 -0
  513. package/src/_esm/src/ts/VEllipseSector.js.map +1 -0
  514. package/src/_esm/src/ts/Vector.d.ts +126 -0
  515. package/src/_esm/src/ts/Vector.js +177 -0
  516. package/src/_esm/src/ts/Vector.js.map +1 -0
  517. package/src/_esm/src/ts/VertTuple.d.ts +284 -0
  518. package/src/_esm/src/ts/VertTuple.js +343 -0
  519. package/src/_esm/src/ts/VertTuple.js.map +1 -0
  520. package/src/_esm/src/ts/Vertex.d.ts +498 -0
  521. package/src/_esm/src/ts/Vertex.js +698 -0
  522. package/src/_esm/src/ts/Vertex.js.map +1 -0
  523. package/src/_esm/src/ts/VertexAttr.d.ts +72 -0
  524. package/src/_esm/src/ts/VertexAttr.js +54 -0
  525. package/src/_esm/src/ts/VertexAttr.js.map +1 -0
  526. package/src/_esm/src/ts/VertexListeners.d.ts +209 -0
  527. package/src/_esm/src/ts/VertexListeners.js +266 -0
  528. package/src/_esm/src/ts/VertexListeners.js.map +1 -0
  529. package/src/_esm/src/ts/draw.d.ts +657 -0
  530. package/src/_esm/src/ts/draw.js +1155 -0
  531. package/src/_esm/src/ts/draw.js.map +1 -0
  532. package/src/_esm/src/ts/drawgl.d.ts +544 -0
  533. package/src/_esm/src/ts/drawgl.js +808 -0
  534. package/src/_esm/src/ts/drawgl.js.map +1 -0
  535. package/src/_esm/src/ts/drawutilssvg.d.ts +954 -0
  536. package/src/_esm/src/ts/drawutilssvg.js +1701 -0
  537. package/src/_esm/src/ts/drawutilssvg.js.map +1 -0
  538. package/src/_esm/src/ts/geomutils.d.ts +77 -0
  539. package/src/_esm/src/ts/geomutils.js +123 -0
  540. package/src/_esm/src/ts/geomutils.js.map +1 -0
  541. package/src/_esm/src/ts/index.d.ts +102 -0
  542. package/src/_esm/src/ts/index.js +112 -0
  543. package/src/_esm/src/ts/index.js.map +1 -0
  544. package/src/_esm/src/ts/interfaces/DrawLib.d.ts +582 -0
  545. package/src/_esm/src/ts/interfaces/DrawLib.js +31 -0
  546. package/src/_esm/src/ts/interfaces/DrawLib.js.map +1 -0
  547. package/src/_esm/src/ts/interfaces/additionals.d.ts +95 -0
  548. package/src/_esm/src/ts/interfaces/additionals.js +2 -0
  549. package/src/_esm/src/ts/interfaces/additionals.js.map +1 -0
  550. package/src/_esm/src/ts/interfaces/core.d.ts +286 -0
  551. package/src/_esm/src/ts/interfaces/core.js +29 -0
  552. package/src/_esm/src/ts/interfaces/core.js.map +1 -0
  553. package/src/_esm/src/ts/interfaces/externals.d.ts +56 -0
  554. package/src/_esm/src/ts/interfaces/externals.js +7 -0
  555. package/src/_esm/src/ts/interfaces/externals.js.map +1 -0
  556. package/src/_esm/src/ts/interfaces/index.d.ts +4 -0
  557. package/src/_esm/src/ts/interfaces/index.js +5 -0
  558. package/src/_esm/src/ts/interfaces/index.js.map +1 -0
  559. package/src/_esm/src/ts/module.d.ts +26 -0
  560. package/src/_esm/src/ts/module.js +38 -0
  561. package/src/_esm/src/ts/module.js.map +1 -0
  562. package/src/_esm/src/ts/utils/InitializationObserver.d.ts +18 -0
  563. package/src/_esm/src/ts/utils/InitializationObserver.js +57 -0
  564. package/src/_esm/src/ts/utils/InitializationObserver.js.map +1 -0
  565. package/src/_esm/src/ts/utils/LissajousFigure.d.ts +34 -0
  566. package/src/_esm/src/ts/utils/LissajousFigure.js +95 -0
  567. package/src/_esm/src/ts/utils/LissajousFigure.js.map +1 -0
  568. package/src/_esm/src/ts/utils/NGons.d.ts +13 -0
  569. package/src/_esm/src/ts/utils/NGons.js +33 -0
  570. package/src/_esm/src/ts/utils/NGons.js.map +1 -0
  571. package/src/_esm/src/ts/utils/Params.d.ts +17 -0
  572. package/src/_esm/src/ts/utils/Params.js +48 -0
  573. package/src/_esm/src/ts/utils/Params.js.map +1 -0
  574. package/src/_esm/src/ts/utils/PerlinNoise.d.ts +19 -0
  575. package/src/_esm/src/ts/utils/PerlinNoise.js +346 -0
  576. package/src/_esm/src/ts/utils/PerlinNoise.js.map +1 -0
  577. package/src/_esm/src/ts/utils/SVGPathUtils.d.ts +22 -0
  578. package/src/_esm/src/ts/utils/SVGPathUtils.js +42 -0
  579. package/src/_esm/src/ts/utils/SVGPathUtils.js.map +1 -0
  580. package/src/_esm/src/ts/utils/WebColors.d.ts +35 -0
  581. package/src/_esm/src/ts/utils/WebColors.js +54 -0
  582. package/src/_esm/src/ts/utils/WebColors.js.map +1 -0
  583. package/src/_esm/src/ts/utils/WebColorsContrast.d.ts +6 -0
  584. package/src/_esm/src/ts/utils/WebColorsContrast.js +9 -0
  585. package/src/_esm/src/ts/utils/WebColorsContrast.js.map +1 -0
  586. package/src/_esm/src/ts/utils/WebColorsMalachite.d.ts +12 -0
  587. package/src/_esm/src/ts/utils/WebColorsMalachite.js +25 -0
  588. package/src/_esm/src/ts/utils/WebColorsMalachite.js.map +1 -0
  589. package/src/_esm/src/ts/utils/algorithms/CatmullRomPath.d.ts +60 -0
  590. package/src/_esm/src/ts/utils/algorithms/CatmullRomPath.js +103 -0
  591. package/src/_esm/src/ts/utils/algorithms/CatmullRomPath.js.map +1 -0
  592. package/src/_esm/src/ts/utils/algorithms/CircleIntersections.d.ts +170 -0
  593. package/src/_esm/src/ts/utils/algorithms/CircleIntersections.js +303 -0
  594. package/src/_esm/src/ts/utils/algorithms/CircleIntersections.js.map +1 -0
  595. package/src/_esm/src/ts/utils/algorithms/ContourLineDetection.d.ts +150 -0
  596. package/src/_esm/src/ts/utils/algorithms/ContourLineDetection.js +362 -0
  597. package/src/_esm/src/ts/utils/algorithms/ContourLineDetection.js.map +1 -0
  598. package/src/_esm/src/ts/utils/algorithms/CubicSplinePath.d.ts +63 -0
  599. package/src/_esm/src/ts/utils/algorithms/CubicSplinePath.js +170 -0
  600. package/src/_esm/src/ts/utils/algorithms/CubicSplinePath.js.map +1 -0
  601. package/src/_esm/src/ts/utils/algorithms/HobbyPath.d.ts +81 -0
  602. package/src/_esm/src/ts/utils/algorithms/HobbyPath.js +273 -0
  603. package/src/_esm/src/ts/utils/algorithms/HobbyPath.js.map +1 -0
  604. package/src/_esm/src/ts/utils/algorithms/Metaballs.d.ts +30 -0
  605. package/src/_esm/src/ts/utils/algorithms/Metaballs.js +109 -0
  606. package/src/_esm/src/ts/utils/algorithms/Metaballs.js.map +1 -0
  607. package/src/_esm/src/ts/utils/algorithms/PolygonInset.d.ts +184 -0
  608. package/src/_esm/src/ts/utils/algorithms/PolygonInset.js +424 -0
  609. package/src/_esm/src/ts/utils/algorithms/PolygonInset.js.map +1 -0
  610. package/src/_esm/src/ts/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
  611. package/src/_esm/src/ts/utils/algorithms/PolygonTesselationOutlines.js +262 -0
  612. package/src/_esm/src/ts/utils/algorithms/PolygonTesselationOutlines.js.map +1 -0
  613. package/src/_esm/src/ts/utils/algorithms/arrayFill.d.ts +8 -0
  614. package/src/_esm/src/ts/utils/algorithms/arrayFill.js +14 -0
  615. package/src/_esm/src/ts/utils/algorithms/arrayFill.js.map +1 -0
  616. package/src/_esm/src/ts/utils/algorithms/arrayResize.d.ts +8 -0
  617. package/src/_esm/src/ts/utils/algorithms/arrayResize.js +20 -0
  618. package/src/_esm/src/ts/utils/algorithms/arrayResize.js.map +1 -0
  619. package/src/_esm/src/ts/utils/algorithms/arrayShuffle.d.ts +8 -0
  620. package/src/_esm/src/ts/utils/algorithms/arrayShuffle.js +11 -0
  621. package/src/_esm/src/ts/utils/algorithms/arrayShuffle.js.map +1 -0
  622. package/src/_esm/src/ts/utils/algorithms/clearDuplicateVertices.d.ts +22 -0
  623. package/src/_esm/src/ts/utils/algorithms/clearDuplicateVertices.js +47 -0
  624. package/src/_esm/src/ts/utils/algorithms/clearDuplicateVertices.js.map +1 -0
  625. package/src/_esm/src/ts/utils/algorithms/clearPolygonDuplicateVertices.d.ts +24 -0
  626. package/src/_esm/src/ts/utils/algorithms/clearPolygonDuplicateVertices.js +57 -0
  627. package/src/_esm/src/ts/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -0
  628. package/src/_esm/src/ts/utils/algorithms/convexHull.d.ts +23 -0
  629. package/src/_esm/src/ts/utils/algorithms/convexHull.js +67 -0
  630. package/src/_esm/src/ts/utils/algorithms/convexHull.js.map +1 -0
  631. package/src/_esm/src/ts/utils/algorithms/convexPolygonIncircle.d.ts +41 -0
  632. package/src/_esm/src/ts/utils/algorithms/convexPolygonIncircle.js +141 -0
  633. package/src/_esm/src/ts/utils/algorithms/convexPolygonIncircle.js.map +1 -0
  634. package/src/_esm/src/ts/utils/algorithms/delaunay.d.ts +30 -0
  635. package/src/_esm/src/ts/utils/algorithms/delaunay.js +153 -0
  636. package/src/_esm/src/ts/utils/algorithms/delaunay.js.map +1 -0
  637. package/src/_esm/src/ts/utils/algorithms/delaunay2voronoi.d.ts +25 -0
  638. package/src/_esm/src/ts/utils/algorithms/delaunay2voronoi.js +99 -0
  639. package/src/_esm/src/ts/utils/algorithms/delaunay2voronoi.js.map +1 -0
  640. package/src/_esm/src/ts/utils/algorithms/detectPaths.d.ts +21 -0
  641. package/src/_esm/src/ts/utils/algorithms/detectPaths.js +165 -0
  642. package/src/_esm/src/ts/utils/algorithms/detectPaths.js.map +1 -0
  643. package/src/_esm/src/ts/utils/algorithms/findPolygonSelfIntersections.d.ts +21 -0
  644. package/src/_esm/src/ts/utils/algorithms/findPolygonSelfIntersections.js +47 -0
  645. package/src/_esm/src/ts/utils/algorithms/findPolygonSelfIntersections.js.map +1 -0
  646. package/src/_esm/src/ts/utils/algorithms/getContrastColor.d.ts +13 -0
  647. package/src/_esm/src/ts/utils/algorithms/getContrastColor.js +22 -0
  648. package/src/_esm/src/ts/utils/algorithms/getContrastColor.js.map +1 -0
  649. package/src/_esm/src/ts/utils/algorithms/matrixFill.d.ts +10 -0
  650. package/src/_esm/src/ts/utils/algorithms/matrixFill.js +17 -0
  651. package/src/_esm/src/ts/utils/algorithms/matrixFill.js.map +1 -0
  652. package/src/_esm/src/ts/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  653. package/src/_esm/src/ts/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
  654. package/src/_esm/src/ts/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  655. package/src/_esm/src/ts/utils/algorithms/splitPolygonToNonIntersecting.d.ts +28 -0
  656. package/src/_esm/src/ts/utils/algorithms/splitPolygonToNonIntersecting.js +99 -0
  657. package/src/_esm/src/ts/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -0
  658. package/src/_esm/src/ts/utils/algorithms/sutherlandHodgman.d.ts +16 -0
  659. package/src/_esm/src/ts/utils/algorithms/sutherlandHodgman.js +72 -0
  660. package/src/_esm/src/ts/utils/algorithms/sutherlandHodgman.js.map +1 -0
  661. package/src/_esm/src/ts/utils/cloneVertexArray.d.ts +13 -0
  662. package/src/_esm/src/ts/utils/cloneVertexArray.js +19 -0
  663. package/src/_esm/src/ts/utils/cloneVertexArray.js.map +1 -0
  664. package/src/_esm/src/ts/utils/createRandomizedPolygon.d.ts +14 -0
  665. package/src/_esm/src/ts/utils/createRandomizedPolygon.js +28 -0
  666. package/src/_esm/src/ts/utils/createRandomizedPolygon.js.map +1 -0
  667. package/src/_esm/src/ts/utils/datastructures/CircularIntervalSet.d.ts +83 -0
  668. package/src/_esm/src/ts/utils/datastructures/CircularIntervalSet.js +158 -0
  669. package/src/_esm/src/ts/utils/datastructures/CircularIntervalSet.js.map +1 -0
  670. package/src/_esm/src/ts/utils/datastructures/Color.d.ts +391 -0
  671. package/src/_esm/src/ts/utils/datastructures/Color.js +1063 -0
  672. package/src/_esm/src/ts/utils/datastructures/Color.js.map +1 -0
  673. package/src/_esm/src/ts/utils/datastructures/ColorGradient.d.ts +81 -0
  674. package/src/_esm/src/ts/utils/datastructures/ColorGradient.js +171 -0
  675. package/src/_esm/src/ts/utils/datastructures/ColorGradient.js.map +1 -0
  676. package/src/_esm/src/ts/utils/datastructures/DataGrid2d.d.ts +53 -0
  677. package/src/_esm/src/ts/utils/datastructures/DataGrid2d.js +19 -0
  678. package/src/_esm/src/ts/utils/datastructures/DataGrid2d.js.map +1 -0
  679. package/src/_esm/src/ts/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  680. package/src/_esm/src/ts/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
  681. package/src/_esm/src/ts/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  682. package/src/_esm/src/ts/utils/datastructures/DataGrid2dListAdapter.d.ts +59 -0
  683. package/src/_esm/src/ts/utils/datastructures/DataGrid2dListAdapter.js +79 -0
  684. package/src/_esm/src/ts/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
  685. package/src/_esm/src/ts/utils/datastructures/GenericPath.d.ts +86 -0
  686. package/src/_esm/src/ts/utils/datastructures/GenericPath.js +117 -0
  687. package/src/_esm/src/ts/utils/datastructures/GenericPath.js.map +1 -0
  688. package/src/_esm/src/ts/utils/datastructures/GeometryMesh.d.ts +49 -0
  689. package/src/_esm/src/ts/utils/datastructures/GeometryMesh.js +53 -0
  690. package/src/_esm/src/ts/utils/datastructures/GeometryMesh.js.map +1 -0
  691. package/src/_esm/src/ts/utils/datastructures/Girih.d.ts +181 -0
  692. package/src/_esm/src/ts/utils/datastructures/Girih.js +261 -0
  693. package/src/_esm/src/ts/utils/datastructures/Girih.js.map +1 -0
  694. package/src/_esm/src/ts/utils/datastructures/GirihBowtie.d.ts +37 -0
  695. package/src/_esm/src/ts/utils/datastructures/GirihBowtie.js +130 -0
  696. package/src/_esm/src/ts/utils/datastructures/GirihBowtie.js.map +1 -0
  697. package/src/_esm/src/ts/utils/datastructures/GirihDecagon.d.ts +52 -0
  698. package/src/_esm/src/ts/utils/datastructures/GirihDecagon.js +110 -0
  699. package/src/_esm/src/ts/utils/datastructures/GirihDecagon.js.map +1 -0
  700. package/src/_esm/src/ts/utils/datastructures/GirihHexagon.d.ts +39 -0
  701. package/src/_esm/src/ts/utils/datastructures/GirihHexagon.js +178 -0
  702. package/src/_esm/src/ts/utils/datastructures/GirihHexagon.js.map +1 -0
  703. package/src/_esm/src/ts/utils/datastructures/GirihPenroseRhombus.d.ts +46 -0
  704. package/src/_esm/src/ts/utils/datastructures/GirihPenroseRhombus.js +167 -0
  705. package/src/_esm/src/ts/utils/datastructures/GirihPenroseRhombus.js.map +1 -0
  706. package/src/_esm/src/ts/utils/datastructures/GirihPentagon.d.ts +37 -0
  707. package/src/_esm/src/ts/utils/datastructures/GirihPentagon.js +87 -0
  708. package/src/_esm/src/ts/utils/datastructures/GirihPentagon.js.map +1 -0
  709. package/src/_esm/src/ts/utils/datastructures/GirihRhombus.d.ts +38 -0
  710. package/src/_esm/src/ts/utils/datastructures/GirihRhombus.js +133 -0
  711. package/src/_esm/src/ts/utils/datastructures/GirihRhombus.js.map +1 -0
  712. package/src/_esm/src/ts/utils/datastructures/GirihTile.d.ts +283 -0
  713. package/src/_esm/src/ts/utils/datastructures/GirihTile.js +286 -0
  714. package/src/_esm/src/ts/utils/datastructures/GirihTile.js.map +1 -0
  715. package/src/_esm/src/ts/utils/datastructures/Matrix4x4.d.ts +244 -0
  716. package/src/_esm/src/ts/utils/datastructures/Matrix4x4.js +246 -0
  717. package/src/_esm/src/ts/utils/datastructures/Matrix4x4.js.map +1 -0
  718. package/src/_esm/src/ts/utils/datastructures/VoronoiCell.d.ts +122 -0
  719. package/src/_esm/src/ts/utils/datastructures/VoronoiCell.js +178 -0
  720. package/src/_esm/src/ts/utils/datastructures/VoronoiCell.js.map +1 -0
  721. package/src/_esm/src/ts/utils/datastructures/interfaces.d.ts +13 -0
  722. package/src/_esm/src/ts/utils/datastructures/interfaces.js +9 -0
  723. package/src/_esm/src/ts/utils/datastructures/interfaces.js.map +1 -0
  724. package/src/_esm/src/ts/utils/detectDarkMode.d.ts +10 -0
  725. package/src/_esm/src/ts/utils/detectDarkMode.js +37 -0
  726. package/src/_esm/src/ts/utils/detectDarkMode.js.map +1 -0
  727. package/src/_esm/src/ts/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  728. package/src/_esm/src/ts/utils/dom/components/ColorGradientPicker.js +743 -0
  729. package/src/_esm/src/ts/utils/dom/components/ColorGradientPicker.js.map +1 -0
  730. package/src/_esm/src/ts/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  731. package/src/_esm/src/ts/utils/dom/components/ColorGradientSelector.js +339 -0
  732. package/src/_esm/src/ts/utils/dom/components/ColorGradientSelector.js.map +1 -0
  733. package/src/_esm/src/ts/utils/dom/components/Test.d.ts +7 -0
  734. package/src/_esm/src/ts/utils/dom/components/Test.js +26 -0
  735. package/src/_esm/src/ts/utils/dom/components/Test.js.map +1 -0
  736. package/src/_esm/src/ts/utils/dom/getAvailableContainerSpace.d.ts +2 -0
  737. package/src/_esm/src/ts/utils/dom/getAvailableContainerSpace.js +25 -0
  738. package/src/_esm/src/ts/utils/dom/getAvailableContainerSpace.js.map +1 -0
  739. package/src/_esm/src/ts/utils/dom/getFProp.d.ts +5 -0
  740. package/src/_esm/src/ts/utils/dom/getFProp.js +8 -0
  741. package/src/_esm/src/ts/utils/dom/getFProp.js.map +1 -0
  742. package/src/_esm/src/ts/utils/dom/guiSizeToggler.d.ts +18 -0
  743. package/src/_esm/src/ts/utils/dom/guiSizeToggler.js +40 -0
  744. package/src/_esm/src/ts/utils/dom/guiSizeToggler.js.map +1 -0
  745. package/src/_esm/src/ts/utils/findInVertexArray.d.ts +19 -0
  746. package/src/_esm/src/ts/utils/findInVertexArray.js +25 -0
  747. package/src/_esm/src/ts/utils/findInVertexArray.js.map +1 -0
  748. package/src/_esm/src/ts/utils/gup.d.ts +14 -0
  749. package/src/_esm/src/ts/utils/gup.js +27 -0
  750. package/src/_esm/src/ts/utils/gup.js.map +1 -0
  751. package/src/_esm/src/ts/utils/helpers/BezierPathInteractionHelper.d.ts +272 -0
  752. package/src/_esm/src/ts/utils/helpers/BezierPathInteractionHelper.js +648 -0
  753. package/src/_esm/src/ts/utils/helpers/BezierPathInteractionHelper.js.map +1 -0
  754. package/src/_esm/src/ts/utils/helpers/CircleHelper.d.ts +73 -0
  755. package/src/_esm/src/ts/utils/helpers/CircleHelper.js +88 -0
  756. package/src/_esm/src/ts/utils/helpers/CircleHelper.js.map +1 -0
  757. package/src/_esm/src/ts/utils/helpers/CircleSectorHelper.d.ts +90 -0
  758. package/src/_esm/src/ts/utils/helpers/CircleSectorHelper.js +109 -0
  759. package/src/_esm/src/ts/utils/helpers/CircleSectorHelper.js.map +1 -0
  760. package/src/_esm/src/ts/utils/helpers/TriangleHelper.d.ts +57 -0
  761. package/src/_esm/src/ts/utils/helpers/TriangleHelper.js +78 -0
  762. package/src/_esm/src/ts/utils/helpers/TriangleHelper.js.map +1 -0
  763. package/src/_esm/src/ts/utils/helpers/VEllipseHelper.d.ts +32 -0
  764. package/src/_esm/src/ts/utils/helpers/VEllipseHelper.js +83 -0
  765. package/src/_esm/src/ts/utils/helpers/VEllipseHelper.js.map +1 -0
  766. package/src/_esm/src/ts/utils/helpers/VEllipseSectorHelper.d.ts +52 -0
  767. package/src/_esm/src/ts/utils/helpers/VEllipseSectorHelper.js +130 -0
  768. package/src/_esm/src/ts/utils/helpers/VEllipseSectorHelper.js.map +1 -0
  769. package/src/_esm/src/ts/utils/io/FileDrop.d.ts +110 -0
  770. package/src/_esm/src/ts/utils/io/FileDrop.js +171 -0
  771. package/src/_esm/src/ts/utils/io/FileDrop.js.map +1 -0
  772. package/src/_esm/src/ts/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  773. package/src/_esm/src/ts/utils/parsers/LinearColorGradientParser.js +217 -0
  774. package/src/_esm/src/ts/utils/parsers/LinearColorGradientParser.js.map +1 -0
  775. package/src/_esm/src/ts/utils/parsers/OBJParser.d.ts +24 -0
  776. package/src/_esm/src/ts/utils/parsers/OBJParser.js +72 -0
  777. package/src/_esm/src/ts/utils/parsers/OBJParser.js.map +1 -0
  778. package/src/_esm/src/ts/utils/parsers/STLParser.d.ts +61 -0
  779. package/src/_esm/src/ts/utils/parsers/STLParser.js +175 -0
  780. package/src/_esm/src/ts/utils/parsers/STLParser.js.map +1 -0
  781. package/src/_esm/src/ts/utils/parsers/svg/parseSVGPathData.d.ts +27 -0
  782. package/src/_esm/src/ts/utils/parsers/svg/parseSVGPathData.js +482 -0
  783. package/src/_esm/src/ts/utils/parsers/svg/parseSVGPathData.js.map +1 -0
  784. package/src/_esm/src/ts/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
  785. package/src/_esm/src/ts/utils/parsers/svg/splitSVGPathData.js +49 -0
  786. package/src/_esm/src/ts/utils/parsers/svg/splitSVGPathData.js.map +1 -0
  787. package/src/_esm/src/ts/utils/parsers/svg/types.d.ts +63 -0
  788. package/src/_esm/src/ts/utils/parsers/svg/types.js +16 -0
  789. package/src/_esm/src/ts/utils/parsers/svg/types.js.map +1 -0
  790. package/src/_esm/utils/InitializationObserver.d.ts +18 -0
  791. package/src/_esm/utils/InitializationObserver.js +61 -0
  792. package/src/_esm/utils/InitializationObserver.js.map +1 -0
  793. package/src/_esm/utils/LissajousFigure.d.ts +34 -0
  794. package/src/_esm/utils/LissajousFigure.js +99 -0
  795. package/src/_esm/utils/LissajousFigure.js.map +1 -0
  796. package/src/_esm/utils/NGons.d.ts +13 -0
  797. package/src/_esm/utils/NGons.js +36 -0
  798. package/src/_esm/utils/NGons.js.map +1 -0
  799. package/src/_esm/utils/Params.d.ts +17 -0
  800. package/src/_esm/utils/Params.js +52 -0
  801. package/src/_esm/utils/Params.js.map +1 -0
  802. package/src/_esm/utils/PerlinNoise.d.ts +19 -0
  803. package/src/_esm/utils/PerlinNoise.js +350 -0
  804. package/src/_esm/utils/PerlinNoise.js.map +1 -0
  805. package/src/_esm/utils/SVGPathUtils.d.ts +22 -0
  806. package/src/_esm/utils/SVGPathUtils.js +45 -0
  807. package/src/_esm/utils/SVGPathUtils.js.map +1 -0
  808. package/src/_esm/utils/WebColors.d.ts +35 -0
  809. package/src/_esm/utils/WebColors.js +58 -0
  810. package/src/_esm/utils/WebColors.js.map +1 -0
  811. package/src/_esm/utils/WebColorsContrast.d.ts +6 -0
  812. package/src/_esm/utils/WebColorsContrast.js +12 -0
  813. package/src/_esm/utils/WebColorsContrast.js.map +1 -0
  814. package/src/_esm/utils/WebColorsMalachite.d.ts +12 -0
  815. package/src/_esm/utils/WebColorsMalachite.js +28 -0
  816. package/src/_esm/utils/WebColorsMalachite.js.map +1 -0
  817. package/src/_esm/utils/algorithms/CatmullRomPath.d.ts +60 -0
  818. package/src/_esm/utils/algorithms/CatmullRomPath.js +107 -0
  819. package/src/_esm/utils/algorithms/CatmullRomPath.js.map +1 -0
  820. package/src/_esm/utils/algorithms/CircleIntersections.d.ts +170 -0
  821. package/src/_esm/utils/algorithms/CircleIntersections.js +307 -0
  822. package/src/_esm/utils/algorithms/CircleIntersections.js.map +1 -0
  823. package/src/_esm/utils/algorithms/ContourLineDetection.d.ts +150 -0
  824. package/src/_esm/utils/algorithms/ContourLineDetection.js +366 -0
  825. package/src/_esm/utils/algorithms/ContourLineDetection.js.map +1 -0
  826. package/src/_esm/utils/algorithms/CubicSplinePath.d.ts +63 -0
  827. package/src/_esm/utils/algorithms/CubicSplinePath.js +174 -0
  828. package/src/_esm/utils/algorithms/CubicSplinePath.js.map +1 -0
  829. package/src/_esm/utils/algorithms/HobbyPath.d.ts +81 -0
  830. package/src/_esm/utils/algorithms/HobbyPath.js +277 -0
  831. package/src/_esm/utils/algorithms/HobbyPath.js.map +1 -0
  832. package/src/_esm/utils/algorithms/Metaballs.d.ts +30 -0
  833. package/src/_esm/utils/algorithms/Metaballs.js +113 -0
  834. package/src/_esm/utils/algorithms/Metaballs.js.map +1 -0
  835. package/src/_esm/utils/algorithms/PolygonInset.d.ts +184 -0
  836. package/src/_esm/utils/algorithms/PolygonInset.js +428 -0
  837. package/src/_esm/utils/algorithms/PolygonInset.js.map +1 -0
  838. package/src/_esm/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
  839. package/src/_esm/utils/algorithms/PolygonTesselationOutlines.js +267 -0
  840. package/src/_esm/utils/algorithms/PolygonTesselationOutlines.js.map +1 -0
  841. package/src/_esm/utils/algorithms/arrayFill.d.ts +8 -0
  842. package/src/_esm/utils/algorithms/arrayFill.js +18 -0
  843. package/src/_esm/utils/algorithms/arrayFill.js.map +1 -0
  844. package/src/_esm/utils/algorithms/arrayResize.d.ts +8 -0
  845. package/src/_esm/utils/algorithms/arrayResize.js +24 -0
  846. package/src/_esm/utils/algorithms/arrayResize.js.map +1 -0
  847. package/src/_esm/utils/algorithms/arrayShuffle.d.ts +8 -0
  848. package/src/_esm/utils/algorithms/arrayShuffle.js +15 -0
  849. package/src/_esm/utils/algorithms/arrayShuffle.js.map +1 -0
  850. package/src/_esm/utils/algorithms/clearDuplicateVertices.d.ts +22 -0
  851. package/src/_esm/utils/algorithms/clearDuplicateVertices.js +51 -0
  852. package/src/_esm/utils/algorithms/clearDuplicateVertices.js.map +1 -0
  853. package/src/_esm/utils/algorithms/clearPolygonDuplicateVertices.d.ts +24 -0
  854. package/src/_esm/utils/algorithms/clearPolygonDuplicateVertices.js +61 -0
  855. package/src/_esm/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -0
  856. package/src/_esm/utils/algorithms/convexHull.d.ts +23 -0
  857. package/src/_esm/utils/algorithms/convexHull.js +71 -0
  858. package/src/_esm/utils/algorithms/convexHull.js.map +1 -0
  859. package/src/_esm/utils/algorithms/convexPolygonIncircle.d.ts +41 -0
  860. package/src/_esm/utils/algorithms/convexPolygonIncircle.js +145 -0
  861. package/src/_esm/utils/algorithms/convexPolygonIncircle.js.map +1 -0
  862. package/src/_esm/utils/algorithms/createRandomizedPolygon.d.ts +14 -0
  863. package/src/_esm/utils/algorithms/createRandomizedPolygon.js +28 -0
  864. package/src/_esm/utils/algorithms/createRandomizedPolygon.js.map +1 -0
  865. package/src/_esm/utils/algorithms/delaunay.d.ts +30 -0
  866. package/src/_esm/utils/algorithms/delaunay.js +157 -0
  867. package/src/_esm/utils/algorithms/delaunay.js.map +1 -0
  868. package/src/_esm/utils/algorithms/delaunay2voronoi.d.ts +25 -0
  869. package/src/_esm/utils/algorithms/delaunay2voronoi.js +103 -0
  870. package/src/_esm/utils/algorithms/delaunay2voronoi.js.map +1 -0
  871. package/src/_esm/utils/algorithms/detectPaths.d.ts +21 -0
  872. package/src/_esm/utils/algorithms/detectPaths.js +169 -0
  873. package/src/_esm/utils/algorithms/detectPaths.js.map +1 -0
  874. package/src/_esm/utils/algorithms/findPolygonSelfIntersections.d.ts +21 -0
  875. package/src/_esm/utils/algorithms/findPolygonSelfIntersections.js +51 -0
  876. package/src/_esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -0
  877. package/src/_esm/utils/algorithms/getContrastColor.d.ts +13 -0
  878. package/src/_esm/utils/algorithms/getContrastColor.js +26 -0
  879. package/src/_esm/utils/algorithms/getContrastColor.js.map +1 -0
  880. package/src/_esm/utils/algorithms/matrixFill.d.ts +10 -0
  881. package/src/_esm/utils/algorithms/matrixFill.js +21 -0
  882. package/src/_esm/utils/algorithms/matrixFill.js.map +1 -0
  883. package/src/_esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  884. package/src/_esm/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  885. package/src/_esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  886. package/src/_esm/utils/algorithms/splitPolygonToNonIntersecting.d.ts +28 -0
  887. package/src/_esm/utils/algorithms/splitPolygonToNonIntersecting.js +102 -0
  888. package/src/_esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -0
  889. package/src/_esm/utils/algorithms/sutherlandHodgman.d.ts +16 -0
  890. package/src/_esm/utils/algorithms/sutherlandHodgman.js +76 -0
  891. package/src/_esm/utils/algorithms/sutherlandHodgman.js.map +1 -0
  892. package/src/_esm/utils/cloneVertexArray.d.ts +13 -0
  893. package/src/_esm/utils/cloneVertexArray.js +23 -0
  894. package/src/_esm/utils/cloneVertexArray.js.map +1 -0
  895. package/src/_esm/utils/createRandomizedPolygon.d.ts +14 -0
  896. package/src/_esm/utils/createRandomizedPolygon.js +32 -0
  897. package/src/_esm/utils/createRandomizedPolygon.js.map +1 -0
  898. package/src/_esm/utils/datastructures/CircularIntervalSet.d.ts +83 -0
  899. package/src/_esm/utils/datastructures/CircularIntervalSet.js +162 -0
  900. package/src/_esm/utils/datastructures/CircularIntervalSet.js.map +1 -0
  901. package/src/_esm/utils/datastructures/Color.d.ts +391 -0
  902. package/src/_esm/utils/datastructures/Color.js +1067 -0
  903. package/src/_esm/utils/datastructures/Color.js.map +1 -0
  904. package/src/_esm/utils/datastructures/ColorGradient.d.ts +81 -0
  905. package/src/_esm/utils/datastructures/ColorGradient.js +175 -0
  906. package/src/_esm/utils/datastructures/ColorGradient.js.map +1 -0
  907. package/src/_esm/utils/datastructures/DataGrid2d.d.ts +53 -0
  908. package/src/_esm/utils/datastructures/DataGrid2d.js +20 -0
  909. package/src/_esm/utils/datastructures/DataGrid2d.js.map +1 -0
  910. package/src/_esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  911. package/src/_esm/utils/datastructures/DataGrid2dArrayMatrix.js +154 -0
  912. package/src/_esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  913. package/src/_esm/utils/datastructures/DataGrid2dListAdapter.d.ts +59 -0
  914. package/src/_esm/utils/datastructures/DataGrid2dListAdapter.js +83 -0
  915. package/src/_esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
  916. package/src/_esm/utils/datastructures/GenericPath.d.ts +86 -0
  917. package/src/_esm/utils/datastructures/GenericPath.js +121 -0
  918. package/src/_esm/utils/datastructures/GenericPath.js.map +1 -0
  919. package/src/_esm/utils/datastructures/GeometryMesh.d.ts +49 -0
  920. package/src/_esm/utils/datastructures/GeometryMesh.js +57 -0
  921. package/src/_esm/utils/datastructures/GeometryMesh.js.map +1 -0
  922. package/src/_esm/utils/datastructures/Girih.d.ts +181 -0
  923. package/src/_esm/utils/datastructures/Girih.js +265 -0
  924. package/src/_esm/utils/datastructures/Girih.js.map +1 -0
  925. package/src/_esm/utils/datastructures/GirihBowtie.d.ts +37 -0
  926. package/src/_esm/utils/datastructures/GirihBowtie.js +134 -0
  927. package/src/_esm/utils/datastructures/GirihBowtie.js.map +1 -0
  928. package/src/_esm/utils/datastructures/GirihDecagon.d.ts +52 -0
  929. package/src/_esm/utils/datastructures/GirihDecagon.js +114 -0
  930. package/src/_esm/utils/datastructures/GirihDecagon.js.map +1 -0
  931. package/src/_esm/utils/datastructures/GirihHexagon.d.ts +39 -0
  932. package/src/_esm/utils/datastructures/GirihHexagon.js +182 -0
  933. package/src/_esm/utils/datastructures/GirihHexagon.js.map +1 -0
  934. package/src/_esm/utils/datastructures/GirihPenroseRhombus.d.ts +46 -0
  935. package/src/_esm/utils/datastructures/GirihPenroseRhombus.js +171 -0
  936. package/src/_esm/utils/datastructures/GirihPenroseRhombus.js.map +1 -0
  937. package/src/_esm/utils/datastructures/GirihPentagon.d.ts +37 -0
  938. package/src/_esm/utils/datastructures/GirihPentagon.js +91 -0
  939. package/src/_esm/utils/datastructures/GirihPentagon.js.map +1 -0
  940. package/src/_esm/utils/datastructures/GirihRhombus.d.ts +38 -0
  941. package/src/_esm/utils/datastructures/GirihRhombus.js +137 -0
  942. package/src/_esm/utils/datastructures/GirihRhombus.js.map +1 -0
  943. package/src/_esm/utils/datastructures/GirihTile.d.ts +283 -0
  944. package/src/_esm/utils/datastructures/GirihTile.js +290 -0
  945. package/src/_esm/utils/datastructures/GirihTile.js.map +1 -0
  946. package/src/_esm/utils/datastructures/Matrix4x4.d.ts +244 -0
  947. package/src/_esm/utils/datastructures/Matrix4x4.js +250 -0
  948. package/src/_esm/utils/datastructures/Matrix4x4.js.map +1 -0
  949. package/src/_esm/utils/datastructures/VoronoiCell.d.ts +122 -0
  950. package/src/_esm/utils/datastructures/VoronoiCell.js +182 -0
  951. package/src/_esm/utils/datastructures/VoronoiCell.js.map +1 -0
  952. package/src/_esm/utils/datastructures/interfaces.d.ts +13 -0
  953. package/src/_esm/utils/datastructures/interfaces.js +10 -0
  954. package/src/_esm/utils/datastructures/interfaces.js.map +1 -0
  955. package/src/_esm/utils/detectDarkMode.d.ts +10 -0
  956. package/src/_esm/utils/detectDarkMode.js +41 -0
  957. package/src/_esm/utils/detectDarkMode.js.map +1 -0
  958. package/src/_esm/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  959. package/src/_esm/utils/dom/components/ColorGradientPicker.js +780 -0
  960. package/src/_esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
  961. package/src/_esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  962. package/src/_esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
  963. package/src/_esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  964. package/src/_esm/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  965. package/src/_esm/utils/dom/components/ColorGradientSelector.js +376 -0
  966. package/src/_esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
  967. package/src/_esm/utils/dom/components/Test.d.ts +7 -0
  968. package/src/_esm/utils/dom/components/Test.js +63 -0
  969. package/src/_esm/utils/dom/components/Test.js.map +1 -0
  970. package/src/_esm/utils/dom/getAvailableContainerSpace.d.ts +2 -0
  971. package/src/_esm/utils/dom/getAvailableContainerSpace.js +29 -0
  972. package/src/_esm/utils/dom/getAvailableContainerSpace.js.map +1 -0
  973. package/src/_esm/utils/dom/getFProp.d.ts +5 -0
  974. package/src/_esm/utils/dom/getFProp.js +12 -0
  975. package/src/_esm/utils/dom/getFProp.js.map +1 -0
  976. package/src/_esm/utils/dom/guiSizeToggler.d.ts +18 -0
  977. package/src/_esm/utils/dom/guiSizeToggler.js +44 -0
  978. package/src/_esm/utils/dom/guiSizeToggler.js.map +1 -0
  979. package/src/_esm/utils/findInVertexArray.d.ts +19 -0
  980. package/src/_esm/utils/findInVertexArray.js +29 -0
  981. package/src/_esm/utils/findInVertexArray.js.map +1 -0
  982. package/src/_esm/utils/getFProp.d.ts +5 -0
  983. package/src/_esm/utils/getFProp.js +8 -0
  984. package/src/_esm/utils/getFProp.js.map +1 -0
  985. package/src/_esm/utils/gup.d.ts +14 -0
  986. package/src/_esm/utils/gup.js +31 -0
  987. package/src/_esm/utils/gup.js.map +1 -0
  988. package/src/_esm/utils/helpers/BezierPathInteractionHelper.d.ts +272 -0
  989. package/src/_esm/utils/helpers/BezierPathInteractionHelper.js +655 -0
  990. package/src/_esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -0
  991. package/src/_esm/utils/helpers/CircleHelper.d.ts +73 -0
  992. package/src/_esm/utils/helpers/CircleHelper.js +92 -0
  993. package/src/_esm/utils/helpers/CircleHelper.js.map +1 -0
  994. package/src/_esm/utils/helpers/CircleSectorHelper.d.ts +90 -0
  995. package/src/_esm/utils/helpers/CircleSectorHelper.js +113 -0
  996. package/src/_esm/utils/helpers/CircleSectorHelper.js.map +1 -0
  997. package/src/_esm/utils/helpers/TriangleHelper.d.ts +57 -0
  998. package/src/_esm/utils/helpers/TriangleHelper.js +82 -0
  999. package/src/_esm/utils/helpers/TriangleHelper.js.map +1 -0
  1000. package/src/_esm/utils/helpers/VEllipseHelper.d.ts +32 -0
  1001. package/src/_esm/utils/helpers/VEllipseHelper.js +87 -0
  1002. package/src/_esm/utils/helpers/VEllipseHelper.js.map +1 -0
  1003. package/src/_esm/utils/helpers/VEllipseSectorHelper.d.ts +52 -0
  1004. package/src/_esm/utils/helpers/VEllipseSectorHelper.js +134 -0
  1005. package/src/_esm/utils/helpers/VEllipseSectorHelper.js.map +1 -0
  1006. package/src/_esm/utils/io/DndFileHandler.d.ts +63 -0
  1007. package/src/_esm/utils/io/DndFileHandler.js +106 -0
  1008. package/src/_esm/utils/io/DndFileHandler.js.map +1 -0
  1009. package/src/_esm/utils/io/FileDrop.d.ts +110 -0
  1010. package/src/_esm/utils/io/FileDrop.js +175 -0
  1011. package/src/_esm/utils/io/FileDrop.js.map +1 -0
  1012. package/src/_esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  1013. package/src/_esm/utils/parsers/LinearColorGradientParser.js +223 -0
  1014. package/src/_esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
  1015. package/src/_esm/utils/parsers/OBJParser.d.ts +25 -0
  1016. package/src/_esm/utils/parsers/OBJParser.js +78 -0
  1017. package/src/_esm/utils/parsers/OBJParser.js.map +1 -0
  1018. package/src/_esm/utils/parsers/STLParser.d.ts +61 -0
  1019. package/src/_esm/utils/parsers/STLParser.js +179 -0
  1020. package/src/_esm/utils/parsers/STLParser.js.map +1 -0
  1021. package/src/_esm/utils/parsers/svg/parseSVGPathData.d.ts +27 -0
  1022. package/src/_esm/utils/parsers/svg/parseSVGPathData.js +486 -0
  1023. package/src/_esm/utils/parsers/svg/parseSVGPathData.js.map +1 -0
  1024. package/src/_esm/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
  1025. package/src/_esm/utils/parsers/svg/splitSVGPathData.js +53 -0
  1026. package/src/_esm/utils/parsers/svg/splitSVGPathData.js.map +1 -0
  1027. package/src/_esm/utils/parsers/svg/types.d.ts +63 -0
  1028. package/src/_esm/utils/parsers/svg/types.js +17 -0
  1029. package/src/_esm/utils/parsers/svg/types.js.map +1 -0
  1030. package/src/cjs/PlotBoilerplate.d.ts +11 -1
  1031. package/src/cjs/PlotBoilerplate.js +23 -7
  1032. package/src/cjs/PlotBoilerplate.js.map +1 -1
  1033. package/src/cjs/VertexListeners.d.ts +2 -1
  1034. package/src/cjs/VertexListeners.js +5 -1
  1035. package/src/cjs/VertexListeners.js.map +1 -1
  1036. package/src/cjs/draw.d.ts +18 -2
  1037. package/src/cjs/draw.js +21 -2
  1038. package/src/cjs/draw.js.map +1 -1
  1039. package/src/cjs/drawgl.d.ts +18 -3
  1040. package/src/cjs/drawgl.js +19 -2
  1041. package/src/cjs/drawgl.js.map +1 -1
  1042. package/src/cjs/drawutilssvg.d.ts +19 -1
  1043. package/src/cjs/drawutilssvg.js +28 -5
  1044. package/src/cjs/drawutilssvg.js.map +1 -1
  1045. package/src/cjs/index.d.ts +75 -0
  1046. package/src/cjs/index.js +84 -0
  1047. package/src/cjs/index.js.map +1 -1
  1048. package/src/cjs/interfaces/DrawLib.d.ts +18 -1
  1049. package/src/cjs/interfaces/DrawLib.js +2 -0
  1050. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  1051. package/src/cjs/utils/Params.d.ts +3 -2
  1052. package/src/cjs/utils/Params.js +11 -3
  1053. package/src/cjs/utils/Params.js.map +1 -1
  1054. package/src/cjs/utils/WebColors.d.ts +2 -1
  1055. package/src/cjs/utils/WebColors.js +15 -2
  1056. package/src/cjs/utils/WebColors.js.map +1 -1
  1057. package/src/cjs/utils/WebColorsContrast.d.ts +1 -1
  1058. package/src/cjs/utils/algorithms/HobbyPath.js +13 -16
  1059. package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
  1060. package/src/cjs/utils/helpers/BezierResizeHelper.d.ts +144 -0
  1061. package/src/cjs/utils/helpers/BezierResizeHelper.js +319 -0
  1062. package/src/cjs/utils/helpers/BezierResizeHelper.js.map +1 -0
  1063. package/src/esm/PlotBoilerplate.d.ts +11 -1
  1064. package/src/esm/PlotBoilerplate.js +23 -7
  1065. package/src/esm/PlotBoilerplate.js.map +1 -1
  1066. package/src/esm/VertexListeners.d.ts +2 -1
  1067. package/src/esm/VertexListeners.js +5 -1
  1068. package/src/esm/VertexListeners.js.map +1 -1
  1069. package/src/esm/draw.d.ts +18 -2
  1070. package/src/esm/draw.js +21 -2
  1071. package/src/esm/draw.js.map +1 -1
  1072. package/src/esm/drawgl.d.ts +18 -3
  1073. package/src/esm/drawgl.js +19 -2
  1074. package/src/esm/drawgl.js.map +1 -1
  1075. package/src/esm/drawutilssvg.d.ts +19 -1
  1076. package/src/esm/drawutilssvg.js +28 -5
  1077. package/src/esm/drawutilssvg.js.map +1 -1
  1078. package/src/esm/index.d.ts +75 -0
  1079. package/src/esm/index.js +84 -0
  1080. package/src/esm/index.js.map +1 -1
  1081. package/src/esm/interfaces/DrawLib.d.ts +18 -1
  1082. package/src/esm/interfaces/DrawLib.js +2 -0
  1083. package/src/esm/interfaces/DrawLib.js.map +1 -1
  1084. package/src/esm/utils/Params.d.ts +3 -2
  1085. package/src/esm/utils/Params.js +11 -3
  1086. package/src/esm/utils/Params.js.map +1 -1
  1087. package/src/esm/utils/WebColors.d.ts +2 -1
  1088. package/src/esm/utils/WebColors.js +15 -2
  1089. package/src/esm/utils/WebColors.js.map +1 -1
  1090. package/src/esm/utils/WebColorsContrast.d.ts +1 -1
  1091. package/src/esm/utils/algorithms/HobbyPath.js +13 -16
  1092. package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
  1093. package/src/esm/utils/helpers/BezierResizeHelper.d.ts +144 -0
  1094. package/src/esm/utils/helpers/BezierResizeHelper.js +314 -0
  1095. package/src/esm/utils/helpers/BezierResizeHelper.js.map +1 -0
  1096. package/src/ts/PlotBoilerplate.ts +37 -11
  1097. package/src/ts/VertexListeners.ts +5 -1
  1098. package/src/ts/draw.ts +32 -2
  1099. package/src/ts/drawgl.ts +38 -3
  1100. package/src/ts/drawutilssvg.ts +33 -6
  1101. package/src/ts/index.ts +94 -0
  1102. package/src/ts/interfaces/DrawLib.ts +19 -1
  1103. package/src/ts/utils/Params.ts +11 -3
  1104. package/src/ts/utils/WebColors.ts +15 -2
  1105. package/src/ts/utils/algorithms/HobbyPath.ts +248 -272
  1106. package/src/ts/utils/helpers/BezierResizeHelper.ts +390 -0
  1107. /package/src/{cjs → _cjs}/utils/_gup.js_ +0 -0
@@ -0,0 +1,2348 @@
1
+ "use strict";
2
+ /**
3
+ * @author Ikaros Kappler
4
+ * @date 2018-10-23
5
+ * @modified 2018-11-19 Added multi-select and multi-drag.
6
+ * @modified 2018-12-04 Added basic SVG export.
7
+ * @modified 2018-12-09 Extended the constructor (canvas).
8
+ * @modified 2018-12-18 Added the config.redrawOnResize param.
9
+ * @modified 2018-12-18 Added the config.defaultCanvas{Width,Height} params.
10
+ * @modified 2018-12-19 Added CSS scaling.
11
+ * @modified 2018-12-28 Removed the unused 'drawLabel' param. Added the 'enableMouse' and 'enableKeys' params.
12
+ * @modified 2018-12-29 Added the 'drawOrigin' param.
13
+ * @modified 2018-12-29 Renamed the 'autoCenterOffset' param to 'autoAdjustOffset'. Added the params 'offsetAdjustXPercent' and 'offsetAdjustYPercent'.
14
+ * @modified 2019-01-14 Added params 'drawBezierHandleLines' and 'drawBezierHandlePoints'. Added the 'redraw' praam to the add() function.
15
+ * @modified 2019-01-16 Added params 'drawHandleLines' and 'drawHandlePoints'. Added the new params to the dat.gui interface.
16
+ * @modified 2019-01-30 Added the 'Vector' type (extending the Line class).
17
+ * @modified 2019-01-30 Added the 'PBImage' type (a wrapper for images).
18
+ * @modified 2019-02-02 Added the 'canvasWidthFactor' and 'canvasHeightFactor' params.
19
+ * @modified 2019-02-03 Removed the drawBackgroundImage() function, with had no purpose at all. Just add an image to the drawables-list.
20
+ * @modified 2019-02-06 Vertices (instace of Vertex) can now be added. Added the 'draggable' attribute to the vertex attributes.
21
+ * @modified 2019-02-10 Fixed a draggable-bug in PBImage handling (scaling was not possible).
22
+ * @modified 2019-02-10 Added the 'enableTouch' option (default is true).
23
+ * @modified 2019-02-14 Added the console for debugging (setConsole(object)).
24
+ * @modified 2019-02-19 Added two new constants: DEFAULT_CLICK_TOLERANCE and DEFAULT_TOUCH_TOLERANCE.
25
+ * @modified 2019-02-19 Added the second param to the locatePointNear(Vertex,Number) function.
26
+ * @modified 2019-02-20 Removed the 'loadFile' entry from the GUI as it was experimental and never in use.
27
+ * @modified 2019-02-23 Removed the 'rebuild' function as it had no purpose.
28
+ * @modified 2019-02-23 Added scaling of the click-/touch-tolerance with the CSS scale.
29
+ * @modified 2019-03-23 Added JSDoc tags. Changed the default value of config.drawOrigin to false.
30
+ * @modified 2019-04-03 Fixed the touch-drag position detection for canvas elements that are not located at document position (0,0).
31
+ * @modified 2019-04-03 Tweaked the fit-to-parent function to work with paddings and borders.
32
+ * @modified 2019-04-28 Added the preClear callback param (called before the canvas was cleared on redraw and before any elements are drawn).
33
+ * @modified 2019-09-18 Added basics for WebGL support (strictly experimental).
34
+ * @modified 2019-10-03 Added the .beginDrawCycle call in the redraw function.
35
+ * @modified 2019-11-06 Added fetch.num, fetch.val, fetch.bool, fetch.func functions.
36
+ * @modified 2019-11-13 Fixed an issue with the mouse-sensitive area around vertices (were affected by zoom).
37
+ * @modified 2019-11-13 Added the 'enableMouseWheel' param.
38
+ * @modified 2019-11-18 Added the Triangle class as a regular drawable element.
39
+ * @modified 2019-11-18 The add function now works with arrays, too.
40
+ * @modified 2019-11-18 Added the _handleColor helper function to determine the render color of non-draggable vertices.
41
+ * @modified 2019-11-19 Fixed a bug in the resizeCanvas function; retina resolution was not possible.
42
+ * @modified 2019-12-04 Added relative positioned zooming.
43
+ * @modified 2019-12-04 Added offsetX and offsetY params.
44
+ * @modified 2019-12-04 Added an 'Set to fullsize retina' button to the GUI config.
45
+ * @modified 2019-12-07 Added the drawConfig for lines, polygons, ellipse, triangles, bezier curves and image control lines.
46
+ * @modified 2019-12-08 Fixed a css scale bug in the viewport() function.
47
+ * @modified 2019-12-08 Added the drawconfig UI panel (line colors and line widths).
48
+ * @modified 2020-02-06 Added handling for the end- and end-control-points of non-cirular Bézier paths (was still missing).
49
+ * @modified 2020-02-06 Fixed a drag-amount bug in the move handling of end points of Bezier paths (control points was not properly moved when non circular).
50
+ * @modified 2020-03-28 Ported this class from vanilla-JS to Typescript.
51
+ * @modified 2020-03-29 Fixed the enableSVGExport flag (read enableEport before).
52
+ * @modified 2020-05-09 Included the Cirlcle class.
53
+ * @modified 2020-06-22 Added the rasterScaleX and rasterScaleY config params.
54
+ * @modified 2020-06-03 Fixed the selectedVerticesOnPolyon(Polygon) function: non-selectable vertices were selected too, before.
55
+ * @modified 2020-07-06 Replacing Touchy.js by AlloyFinger.js
56
+ * @modified 2020-07-27 Added the getVertexNear(XYCoords,number) function
57
+ * @modified 2020-07-27 Extended the remove(Drawable) function: vertices are now removed, too.
58
+ * @modified 2020-07-28 Added PlotBoilerplate.revertMousePosition(number,number) – the inverse function of transformMousePosition(...).
59
+ * @modified 2020-07-31 Added PlotBoilerplate.getDraggedElementCount() to check wether any elements are currently being dragged.
60
+ * @modified 2020-08-19 Added the VertexAttributes.visible attribute to make vertices invisible.
61
+ * @modified 2020-11-17 Added pure click handling (no dragEnd and !wasMoved jiggliny any more) to the PlotBoilerplate.
62
+ * @modified 2020-12-11 Added the `removeAll(boolean)` function.
63
+ * @modified 2020-12-17 Added the `CircleSector` drawable.
64
+ * @modified 2021-01-04 Avoiding multiple redraw call on adding multiple Drawables (array).
65
+ * @modified 2021-01-08 Added param `draw:DraLib<void>` to the methods `drawVertices`, `drawGrid` and `drawSelectPolygon`.
66
+ * @modified 2021-01-08 Added the customizable `drawAll(...)` function.
67
+ * @modified 2021-01-09 Added the `drawDrawable(...)` function.
68
+ * @modified 2021-01-10 Added the `eventCatcher` element (used to track mouse events on SVGs).
69
+ * @modified 2021-01-26 Fixed SVG resizing.
70
+ * @modified 2021-01-26 Replaced the old SVGBuilder by the new `drawutilssvg` library.
71
+ * @modified 2021-02-08 Fixed a lot of es2015 compatibility issues.
72
+ * @modified 2021-02-18 Adding `adjustOffset(boolean)` function.
73
+ * @modified 2021-03-01 Updated the `PlotBoilerplate.draw(...)` function: ellipses are now rotate-able.
74
+ * @modified 2021-03-03 Added the `VEllipseSector` drawable.
75
+ * @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
76
+ * @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
77
+ * @modified 2021-11-16 Adding the `PBText` drawable.
78
+ * @modified 2022-08-01 Added `title` to the params.
79
+ * @modified 2022-10-25 Added the `origin` to the default draw config.
80
+ * @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
81
+ * @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.
82
+ * @modified 2023-02-04 Fixed a bug in the `drawDrawable` function; fill's current classname was not set.
83
+ * @modified 2023-02-10 Fixing an issue of the `style.position` setting when `fitToParent=true` from `absolute` to `static` (default).
84
+ * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
85
+ * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
86
+ * @modified 2023-09-29 Adding proper dicionary key and value types to the params of `PlotBoilerplate.utils.safeMergeByKeys` (was `object` before).
87
+ * @modified 2024-07-08 Adding `PlotBoilerplate.getGUI()` to retrieve the GUI instance.
88
+ * @modified 2024-08-25 Extending main class `PlotBoilerplate` optional param `isBackdropFiltersEnabled`.
89
+ * @modified 2024-12-02 Adding the `triggerRedraw` to the `removeAll` method.
90
+ * @modified 2025-05-07 Changing the return type of `removeVertex` from `void` to `boolean`.
91
+ * @modified 2025-05-07 Handling content changes now with `contentChangeListeners`.
92
+ * @modified 2025-05-07 Added `PlogBoilerplate.addContentChangeListener` and `.removeContentChangeListener`.
93
+ * @modified 2025-05-07 Moving full vectors now by default when vector point a is moved.
94
+ * @modified 2025-05-20 Applying `lineWith` parameter in the draw routine for vectors (had been missing).
95
+ * @modified 2026-03-13 Changed visibility of `setZoom` and `setOffset` to public. There was no good reason to have the private.
96
+ *
97
+ * @version 1.21.2
98
+ *
99
+ * @file PlotBoilerplate
100
+ * @fileoverview The main class.
101
+ * @public
102
+ **/
103
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
104
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
105
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
106
+ };
107
+ Object.defineProperty(exports, "__esModule", { value: true });
108
+ exports.PlotBoilerplate = void 0;
109
+ var alloyfinger_typescript_1 = require("alloyfinger-typescript");
110
+ var draw_1 = require("./draw");
111
+ var drawgl_1 = require("./drawgl");
112
+ var drawutilssvg_1 = require("./drawutilssvg");
113
+ var BezierPath_1 = require("./BezierPath");
114
+ var Bounds_1 = require("./Bounds");
115
+ var Circle_1 = require("./Circle");
116
+ var CircleSector_1 = require("./CircleSector");
117
+ var Grid_1 = require("./Grid");
118
+ var KeyHandler_1 = require("./KeyHandler");
119
+ var Line_1 = require("./Line");
120
+ var MouseHandler_1 = require("./MouseHandler");
121
+ var PBImage_1 = require("./PBImage");
122
+ var Polygon_1 = require("./Polygon");
123
+ var Triangle_1 = require("./Triangle");
124
+ var VEllipse_1 = require("./VEllipse");
125
+ var VEllipseSector_1 = require("./VEllipseSector");
126
+ var Vector_1 = require("./Vector");
127
+ var Vertex_1 = require("./Vertex");
128
+ var VertexAttr_1 = require("./VertexAttr");
129
+ var PBText_1 = require("./PBText");
130
+ /**
131
+ * @classdesc The main class of the PlotBoilerplate.
132
+ *
133
+ * @requires Vertex
134
+ * @requires Line
135
+ * @requires Vector
136
+ * @requires Polygon
137
+ * @requires PBImage
138
+ * @requires VEllipse
139
+ * @requires Circle
140
+ * @requires MouseHandler
141
+ * @requires KeyHandler
142
+ * @requires VertexAttr
143
+ * @requires CubicBezierCurve
144
+ * @requires BezierPath
145
+ * @requires Drawable
146
+ * @requires DrawConfig
147
+ * @requires IHooks
148
+ * @requires PBParams
149
+ * @requires Triangle
150
+ * @requires drawutils
151
+ * @requires drawutilsgl
152
+ * @requires SVGSerializable
153
+ * @requires XYCoords
154
+ * @requires XYDimension
155
+ */
156
+ var PlotBoilerplate = /** @class */ (function () {
157
+ /**
158
+ * The constructor.
159
+ *
160
+ * @constructor
161
+ * @name PlotBoilerplate
162
+ * @public
163
+ * @param {object} config={} - The configuration.
164
+ * @param {HTMLCanvasElement} config.canvas - Your canvas element in the DOM (required).
165
+ * @param {boolean=} [config.fullSize=true] - If set to true the canvas will gain full window size.
166
+ * @param {boolean=} [config.fitToParent=true] - If set to true the canvas will gain the size of its parent container (overrides fullSize).
167
+ * @param {number=} [config.scaleX=1.0] - The initial x-zoom. Default is 1.0.
168
+ * @param {number=} [config.scaleY=1.0] - The initial y-zoom. Default is 1.0.
169
+ * @param {number=} [config.offsetX=1.0] - The initial x-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
170
+ * @param {number=} [config.offsetY=1.0] - The initial y-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.
171
+ * @param {boolean=} [config.rasterGrid=true] - If set to true the background grid will be drawn rastered.
172
+ * @param {boolean=} [config.rasterScaleX=1.0] - Define the default horizontal raster scale (default=1.0).
173
+ * @param {boolean=} [config.rasterScaleY=1.0] - Define the default vertical raster scale (default=1.0).
174
+ * @param {number=} [config.rasterAdjustFactor=1.0] - The exponential limit for wrapping down the grid. (2.0 means: halve the grid each 2.0*n zoom step).
175
+ * @param {boolean=} [config.drawOrigin=false] - Draw a crosshair at (0,0).
176
+ * @param {boolean=} [config.autoAdjustOffset=true] - When set to true then the origin of the XY plane will
177
+ * be re-adjusted automatically (see the params
178
+ * offsetAdjust{X,Y}Percent for more).
179
+ * @param {number=} [config.offsetAdjustXPercent=50] - The x-fallback position for the origin after
180
+ * resizing the canvas.
181
+ * @param {number=} [config.offsetAdjustYPercent=50] - The y-fallback position for the origin after
182
+ * resizing the canvas.
183
+ * @param {number=} [config.defaultCanvasWidth=1024] - The canvas size fallback (width) if no automatic resizing
184
+ * is switched on.
185
+ * @param {number=} [config.defaultCanvasHeight=768] - The canvas size fallback (height) if no automatic resizing
186
+ * is switched on.
187
+ * @param {number=} [config.canvasWidthFactor=1.0] - Scaling factor (width) upon the canvas size.
188
+ * In combination with cssScale{X,Y} this can be used to obtain
189
+ * sub pixel resolutions for retina displays.
190
+ * @param {number=} [config.canvasHeightFactor=1.0] - Scaling factor (height) upon the canvas size.
191
+ * In combination with cssScale{X,Y} this can be used to obtain
192
+ * sub pixel resolutions for retina displays.
193
+ * @param {number=} [config.cssScaleX=1.0] - Visually resize the canvas (horizontally) using CSS transforms (scale).
194
+ * @param {number=} [config.cssScaleY=1.0] - Visually resize the canvas (vertically) using CSS transforms (scale).
195
+ * @param {boolan=} [config.cssUniformScale=true] - CSS scale x and y obtaining aspect ratio.
196
+ * @param {boolean=} [config.autoDetectRetina=true] - When set to true (default) the canvas will try to use the display's pixel ratio.
197
+ * @param {string=} [config.backgroundColor=#ffffff] - The backround color.
198
+ * @param {boolean=} [config.redrawOnResize=true] - Switch auto-redrawing on resize on/off (some applications
199
+ * might want to prevent automatic redrawing to avoid data loss from the draw buffer).
200
+ * @param {boolean=} [config.drawBezierHandleLines=true] - Indicates if Bézier curve handles should be drawn (used for
201
+ * editors, no required in pure visualizations).
202
+ * @param {boolean=} [config.drawBezierHandlePoints=true] - Indicates if Bézier curve handle points should be drawn.
203
+ * @param {function=} [config.preClear=null] - A callback function that will be triggered just before the
204
+ * draw function clears the canvas (before anything else was drawn).
205
+ * @param {function=} [config.preDraw=null] - A callback function that will be triggered just before the draw
206
+ * function starts.
207
+ * @param {function=} [config.postDraw=null] - A callback function that will be triggered right after the drawing
208
+ * process finished.
209
+ * @param {boolean=} [config.enableMouse=true] - Indicates if the application should handle mouse events for you.
210
+ * @param {boolean=} [config.enableTouch=true] - Indicates if the application should handle touch events for you.
211
+ * @param {boolean=} [config.enableKeys=true] - Indicates if the application should handle key events for you.
212
+ * @param {boolean=} [config.enableMouseWheel=true] - Indicates if the application should handle mouse wheel events for you.
213
+ * @param {boolean=} [config.enablePan=true] - (default true) Set to false if you want to disable panning completely.
214
+ * @param {boolean=} [config.enableZoom=true] - (default true) Set to false if you want to disable zooming completely.
215
+ * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
216
+ * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
217
+ * Note that changes from the postDraw hook might not be visible in the export.
218
+ * @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
219
+ */
220
+ function PlotBoilerplate(config, drawConfig) {
221
+ var _b, _c;
222
+ /**
223
+ * A list of content change listeners.
224
+ */
225
+ this.contentChangeListeners = [];
226
+ /**
227
+ * A discrete timestamp to identify single render cycles.
228
+ * Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines
229
+ * multiple frames might be rendered within each millisecond.
230
+ * @member {number}
231
+ * @memberof plotboilerplate
232
+ * @instance
233
+ * @private
234
+ */
235
+ this.renderTime = 0;
236
+ /**
237
+ * A storage variable for retrieving the GUI instance once it was created.
238
+ */
239
+ this._gui = null;
240
+ // This should be in some static block ...
241
+ VertexAttr_1.VertexAttr.model = {
242
+ bezierAutoAdjust: false,
243
+ renderTime: 0,
244
+ selectable: true,
245
+ isSelected: false,
246
+ draggable: true,
247
+ visible: true
248
+ };
249
+ if (typeof config.canvas === "undefined") {
250
+ throw "No canvas specified.";
251
+ }
252
+ /**
253
+ * A global config that's attached to the dat.gui control interface.
254
+ *
255
+ * @member {Object}
256
+ * @memberof PlotBoilerplate
257
+ * @instance
258
+ */
259
+ var f = PlotBoilerplate.utils.fetch;
260
+ this.config = {
261
+ canvas: config.canvas,
262
+ fullSize: f.val(config, "fullSize", true),
263
+ fitToParent: f.bool(config, "fitToParent", true),
264
+ scaleX: f.num(config, "scaleX", 1.0),
265
+ scaleY: f.num(config, "scaleY", 1.0),
266
+ offsetX: f.num(config, "offsetX", 0.0),
267
+ offsetY: f.num(config, "offsetY", 0.0),
268
+ rasterGrid: f.bool(config, "rasterGrid", true),
269
+ drawRaster: f.bool(config, "drawRaster", true),
270
+ rasterScaleX: f.num(config, "rasterScaleX", 1.0),
271
+ rasterScaleY: f.num(config, "rasterScaleY", 1.0),
272
+ rasterAdjustFactor: f.num(config, "rasterAdjustdFactror", 2.0),
273
+ drawOrigin: f.bool(config, "drawOrigin", false),
274
+ autoAdjustOffset: f.val(config, "autoAdjustOffset", true),
275
+ offsetAdjustXPercent: f.num(config, "offsetAdjustXPercent", 50),
276
+ offsetAdjustYPercent: f.num(config, "offsetAdjustYPercent", 50),
277
+ backgroundColor: config.backgroundColor || "#ffffff",
278
+ redrawOnResize: f.bool(config, "redrawOnResize", true),
279
+ defaultCanvasWidth: f.num(config, "defaultCanvasWidth", PlotBoilerplate.DEFAULT_CANVAS_WIDTH),
280
+ defaultCanvasHeight: f.num(config, "defaultCanvasHeight", PlotBoilerplate.DEFAULT_CANVAS_HEIGHT),
281
+ canvasWidthFactor: f.num(config, "canvasWidthFactor", 1.0),
282
+ canvasHeightFactor: f.num(config, "canvasHeightFactor", 1.0),
283
+ cssScaleX: f.num(config, "cssScaleX", 1.0),
284
+ cssScaleY: f.num(config, "cssScaleY", 1.0),
285
+ cssUniformScale: f.bool(config, "cssUniformScale", true),
286
+ saveFile: function () {
287
+ _self.hooks.saveFile(_self);
288
+ },
289
+ setToRetina: function () {
290
+ _self._setToRetina();
291
+ },
292
+ autoDetectRetina: f.bool(config, "autoDetectRetina", true),
293
+ enableSVGExport: f.bool(config, "enableSVGExport", true),
294
+ // Listeners/observers
295
+ preClear: f.func(config, "preClear", null),
296
+ preDraw: f.func(config, "preDraw", null),
297
+ postDraw: f.func(config, "postDraw", null),
298
+ // Interaction
299
+ enableMouse: f.bool(config, "enableMouse", true),
300
+ enableTouch: f.bool(config, "enableTouch", true),
301
+ enableKeys: f.bool(config, "enableKeys", true),
302
+ enableMouseWheel: f.bool(config, "enableMouseWheel", true),
303
+ enableZoom: f.bool(config, "enableZoom", true), // default=true
304
+ enablePan: f.bool(config, "enablePan", true), // default=true
305
+ // Experimental (and unfinished)
306
+ enableGL: f.bool(config, "enableGL", false),
307
+ isBackdropFiltersEnabled: f.bool(config, "isBackdropFiltersEnabled", true)
308
+ }; // END confog
309
+ /**
310
+ * Configuration for drawing things.
311
+ *
312
+ * @member {Object}
313
+ * @memberof PlotBoilerplate
314
+ * @instance
315
+ */
316
+ this.drawConfig = {
317
+ drawVertices: true,
318
+ drawBezierHandleLines: f.bool(config, "drawBezierHandleLines", true),
319
+ drawBezierHandlePoints: f.bool(config, "drawBezierHandlePoints", true),
320
+ drawHandleLines: f.bool(config, "drawHandleLines", true),
321
+ drawHandlePoints: f.bool(config, "drawHandlePoints", true),
322
+ drawGrid: f.bool(config, "drawGrid", true),
323
+ drawRaster: f.bool(config, "drawRaster", true),
324
+ bezier: {
325
+ color: "#00a822",
326
+ lineWidth: 2,
327
+ handleLine: {
328
+ color: "rgba(180,180,180,0.5)",
329
+ lineWidth: 1
330
+ },
331
+ pathVertex: {
332
+ color: "#B400FF",
333
+ lineWidth: 1,
334
+ fill: true
335
+ },
336
+ controlVertex: {
337
+ color: "#B8D438",
338
+ lineWidth: 1,
339
+ fill: true
340
+ }
341
+ },
342
+ // bezierPath: {
343
+ // color: "#0022a8",
344
+ // lineWidth: 1
345
+ // },
346
+ polygon: {
347
+ color: "#0022a8",
348
+ lineWidth: 1
349
+ },
350
+ triangle: {
351
+ color: "#6600ff",
352
+ lineWidth: 1
353
+ },
354
+ ellipse: {
355
+ color: "#2222a8",
356
+ lineWidth: 1
357
+ },
358
+ ellipseSector: {
359
+ color: "#a822a8",
360
+ lineWidth: 2
361
+ },
362
+ circle: {
363
+ color: "#22a8a8",
364
+ lineWidth: 2
365
+ },
366
+ circleSector: {
367
+ color: "#2280a8",
368
+ lineWidth: 1
369
+ },
370
+ vertex: {
371
+ color: "#a8a8a8",
372
+ lineWidth: 1
373
+ },
374
+ selectedVertex: {
375
+ color: "#c08000",
376
+ lineWidth: 2
377
+ },
378
+ line: {
379
+ color: "#a844a8",
380
+ lineWidth: 1
381
+ },
382
+ vector: {
383
+ color: "#ff44a8",
384
+ lineWidth: 1
385
+ },
386
+ image: {
387
+ color: "#a8a8a8",
388
+ lineWidth: 1
389
+ },
390
+ text: {
391
+ color: "rgba(192,0,128,0.5)",
392
+ lineWidth: 1,
393
+ fill: true,
394
+ anchor: true
395
+ },
396
+ origin: {
397
+ color: "#000000"
398
+ }
399
+ }; // END drawConfig
400
+ // +---------------------------------------------------------------------------------
401
+ // | Object members.
402
+ // +-------------------------------
403
+ this.grid = new Grid_1.Grid(new Vertex_1.Vertex(0, 0), new Vertex_1.Vertex(50, 50));
404
+ this.canvasSize = { width: PlotBoilerplate.DEFAULT_CANVAS_WIDTH, height: PlotBoilerplate.DEFAULT_CANVAS_HEIGHT };
405
+ var canvasElement = typeof config.canvas === "string" ? document.querySelector(config.canvas) : config.canvas;
406
+ if (typeof canvasElement === "undefined") {
407
+ throw "Cannot initialize PlotBoilerplate with a null canvas (element \"".concat(config.canvas, " not found).");
408
+ }
409
+ // Which renderer to use: Canvas2D, WebGL (experimental) or SVG?
410
+ if (canvasElement.tagName.toLowerCase() === "canvas") {
411
+ this.canvas = canvasElement;
412
+ this.eventCatcher = this.canvas;
413
+ if (this.config.enableGL && typeof drawgl_1.drawutilsgl === "undefined") {
414
+ console.warn("Cannot use webgl. Package was compiled without experimental gl support. Please use plotboilerplate-glsupport.min.js instead.");
415
+ console.warn("Disabling GL and falling back to Canvas2D.");
416
+ this.config.enableGL = false;
417
+ }
418
+ if (this.config.enableGL) {
419
+ // Override the case 'null' here. If GL is not supported, well then nothing works.
420
+ var ctx = this.canvas.getContext("webgl"); // webgl-experimental?
421
+ this.draw = new drawgl_1.drawutilsgl(ctx, false);
422
+ // PROBLEM: same instance of fill and draw when using WebGL.
423
+ // Shader program cannot be duplicated on the same context.
424
+ this.fill = this.draw.copyInstance(true);
425
+ console.warn("Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.");
426
+ }
427
+ else {
428
+ // Override the case 'null' here. If context creation is not supported, well then nothing works.
429
+ var ctx = this.canvas.getContext("2d");
430
+ this.draw = new draw_1.drawutils(ctx, false);
431
+ this.fill = new draw_1.drawutils(ctx, true);
432
+ }
433
+ }
434
+ else if (canvasElement.tagName.toLowerCase() === "svg") {
435
+ if (typeof drawutilssvg_1.drawutilssvg === "undefined")
436
+ throw "The svg draw library is not yet integrated part of PlotBoilerplate. Please include ./src/js/utils/helpers/drawutils.svg into your document.";
437
+ this.canvas = canvasElement;
438
+ this.draw = new drawutilssvg_1.drawutilssvg(this.canvas, new Vertex_1.Vertex(), // offset
439
+ new Vertex_1.Vertex(), // scale
440
+ this.canvasSize, false, // fillShapes=false
441
+ this.drawConfig, false // isSecondary=false
442
+ );
443
+ this.fill = this.draw.copyInstance(true); // fillShapes=true
444
+ if (this.canvas.parentElement) {
445
+ this.eventCatcher = document.createElement("div");
446
+ this.eventCatcher.style.position = "absolute";
447
+ this.eventCatcher.style.left = "0";
448
+ this.eventCatcher.style.top = "0";
449
+ this.eventCatcher.style.cursor = "pointer";
450
+ this.canvas.parentElement.style.position = "relative";
451
+ this.canvas.parentElement.appendChild(this.eventCatcher);
452
+ }
453
+ else {
454
+ this.eventCatcher = document.body;
455
+ }
456
+ }
457
+ else {
458
+ throw "Element is neither a canvas nor an svg element.";
459
+ }
460
+ // At this point the event cacher element is deinfed and located at highest elevation.
461
+ // Set `title` attribut?
462
+ if (config.title) {
463
+ this.eventCatcher.setAttribute("title", config.title);
464
+ }
465
+ this.draw.scale.set((_b = this.config.scaleX) !== null && _b !== void 0 ? _b : 1.0, this.config.scaleY);
466
+ this.fill.scale.set((_c = this.config.scaleX) !== null && _c !== void 0 ? _c : 1.0, this.config.scaleY);
467
+ this.vertices = [];
468
+ this.selectPolygon = null;
469
+ this.draggedElements = [];
470
+ this.drawables = [];
471
+ this.console = console;
472
+ this.hooks = {
473
+ // This is changable from the outside
474
+ saveFile: PlotBoilerplate._saveFile
475
+ };
476
+ var _self = this;
477
+ globalThis.addEventListener("resize", function () { return _self.resizeCanvas(); });
478
+ this.resizeCanvas();
479
+ if (config.autoDetectRetina) {
480
+ this._setToRetina();
481
+ }
482
+ this.installInputListeners();
483
+ // Apply the configured CSS scale.
484
+ this.updateCSSscale();
485
+ // Init
486
+ this.redraw();
487
+ // Gain focus
488
+ this.canvas.focus();
489
+ } // END constructor
490
+ /**
491
+ * This function opens a save-as file dialog and – once an output file is
492
+ * selected – stores the current canvas contents as an SVG image.
493
+ *
494
+ * It is the default hook for saving files and can be overwritten.
495
+ *
496
+ * @method _saveFile
497
+ * @instance
498
+ * @memberof PlotBoilerplate
499
+ * @return {void}
500
+ * @private
501
+ **/
502
+ PlotBoilerplate._saveFile = function (pb) {
503
+ // Create fake SVG node
504
+ var svgNode = document.createElementNS("http://www.w3.org/2000/svg", "svg");
505
+ // Draw everything to fake node.
506
+ var tosvgDraw = new drawutilssvg_1.drawutilssvg(svgNode, pb.draw.offset, pb.draw.scale, pb.canvasSize, false, // fillShapes=false
507
+ pb.drawConfig);
508
+ var tosvgFill = tosvgDraw.copyInstance(true); // fillShapes=true
509
+ tosvgDraw.beginDrawCycle(0);
510
+ tosvgFill.beginDrawCycle(0);
511
+ if (pb.config.preClear) {
512
+ pb.config.preClear();
513
+ }
514
+ tosvgDraw.clear(pb.config.backgroundColor || "white");
515
+ if (pb.config.preDraw) {
516
+ pb.config.preDraw(tosvgDraw, tosvgFill);
517
+ }
518
+ pb.drawAll(0, tosvgDraw, tosvgFill);
519
+ pb.drawVertices(0, tosvgDraw);
520
+ if (pb.config.postDraw)
521
+ pb.config.postDraw(tosvgDraw, tosvgFill);
522
+ tosvgDraw.endDrawCycle(0);
523
+ tosvgFill.endDrawCycle(0);
524
+ // Full support in all browsers \o/
525
+ // https://caniuse.com/xml-serializer
526
+ var serializer = new XMLSerializer();
527
+ var svgCode = serializer.serializeToString(svgNode);
528
+ // Add: '<?xml version="1.0" encoding="utf-8"?>\n' ?
529
+ var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>\n' + svgCode], { type: "image/svg;charset=utf-8" });
530
+ // See documentation for FileSaver.js for usage.
531
+ // https://github.com/eligrey/FileSaver.js
532
+ if (typeof globalThis["saveAs"] !== "function") {
533
+ throw "Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?";
534
+ }
535
+ var _saveAs = globalThis["saveAs"];
536
+ _saveAs(blob, "plotboilerplate.svg");
537
+ };
538
+ /**
539
+ * This function sets the canvas resolution to factor 2.0 (or the preferred pixel ratio of your device) for retina displays.
540
+ * Please not that in non-GL mode this might result in very slow rendering as the canvas buffer size may increase.
541
+ *
542
+ * @method _setToRetina
543
+ * @instance
544
+ * @memberof PlotBoilerplate
545
+ * @return {void}
546
+ * @private
547
+ **/
548
+ PlotBoilerplate.prototype._setToRetina = function () {
549
+ this.config.autoDetectRetina = true;
550
+ var pixelRatio = globalThis.devicePixelRatio || 1;
551
+ this.config.cssScaleX = this.config.cssScaleY = 1.0 / pixelRatio;
552
+ this.config.canvasWidthFactor = this.config.canvasHeightFactor = pixelRatio;
553
+ this.resizeCanvas();
554
+ this.updateCSSscale();
555
+ };
556
+ /**
557
+ * Set the current zoom and draw offset to fit the given bounds.
558
+ *
559
+ * This method currently restores the aspect zoom ratio.
560
+ *
561
+ **/
562
+ PlotBoilerplate.prototype.fitToView = function (bounds) {
563
+ var canvasCenter = new Vertex_1.Vertex(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);
564
+ var canvasRatio = this.canvasSize.width / this.canvasSize.height;
565
+ var ratio = bounds.width / bounds.height;
566
+ // Find the new draw offset
567
+ var center = new Vertex_1.Vertex(bounds.max.x - bounds.width / 2.0, bounds.max.y - bounds.height / 2.0)
568
+ .inv()
569
+ .addXY(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);
570
+ this.setOffset(center);
571
+ if (canvasRatio < ratio) {
572
+ var newUniformZoom = this.canvasSize.width / bounds.width;
573
+ this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);
574
+ }
575
+ else {
576
+ var newUniformZoom = this.canvasSize.height / bounds.height;
577
+ this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);
578
+ }
579
+ this.redraw();
580
+ };
581
+ /**
582
+ * Set the console for this instance.
583
+ *
584
+ * @method setConsole
585
+ * @param {Console} con - The new console object (default is globalThis.console).
586
+ * @instance
587
+ * @memberof PlotBoilerplate
588
+ * @return {void}
589
+ **/
590
+ PlotBoilerplate.prototype.setConsole = function (con) {
591
+ this.console = con;
592
+ };
593
+ /**
594
+ * Update the CSS scale for the canvas depending onf the cssScale{X,Y} settings.<br>
595
+ * <br>
596
+ * This function is usually only used inernally.
597
+ *
598
+ * @method updateCSSscale
599
+ * @instance
600
+ * @memberof PlotBoilerplate
601
+ * @return {void}
602
+ * @private
603
+ **/
604
+ PlotBoilerplate.prototype.updateCSSscale = function () {
605
+ var _b, _c, _d, _e;
606
+ if (this.config.cssUniformScale) {
607
+ PlotBoilerplate.utils.setCSSscale(this.canvas, (_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0, (_c = this.config.cssScaleX) !== null && _c !== void 0 ? _c : 1.0);
608
+ }
609
+ else {
610
+ PlotBoilerplate.utils.setCSSscale(this.canvas, (_d = this.config.cssScaleX) !== null && _d !== void 0 ? _d : 1.0, (_e = this.config.cssScaleY) !== null && _e !== void 0 ? _e : 1.0);
611
+ }
612
+ };
613
+ /**
614
+ * Adds a new content change listener to this instance. Adding duplicates is not possible.
615
+ *
616
+ * @param {PBContentChangeListener} listener - The listenre to add.
617
+ * @method addContentChangeListener
618
+ * @instance
619
+ * @memberof PlotBoilerplate
620
+ * @returns {void}
621
+ */
622
+ PlotBoilerplate.prototype.addContentChangeListener = function (listener) {
623
+ for (var i in this.contentChangeListeners) {
624
+ if (this.contentChangeListeners[i] === listener) {
625
+ return;
626
+ }
627
+ }
628
+ this.contentChangeListeners.push(listener);
629
+ };
630
+ /**
631
+ * Removes an existing content change listener from this instance.
632
+ *
633
+ * @param {PBContentChangeListener} listener - The listenre to add.
634
+ * @method removeContentChangeListener
635
+ * @instance
636
+ * @memberof PlotBoilerplate
637
+ * @returns {void}
638
+ */
639
+ PlotBoilerplate.prototype.removeContentChangeListener = function (listener) {
640
+ for (var i = 0; i < this.contentChangeListeners.length; i++) {
641
+ if (this.contentChangeListeners[i] === listener) {
642
+ this.contentChangeListeners.splice(i, 1);
643
+ return;
644
+ }
645
+ }
646
+ };
647
+ PlotBoilerplate.prototype._fireContentChanged = function (addedDrawables, removedDrawables) {
648
+ for (var i in this.contentChangeListeners) {
649
+ var listener = this.contentChangeListeners[i];
650
+ if (listener && typeof listener === "function") {
651
+ listener({
652
+ type: addedDrawables.length > 0 ? "DRAWABLES_ADDED" : "DRAWABLES_REMOVED",
653
+ addedDrawables: addedDrawables,
654
+ removedDrawables: removedDrawables
655
+ });
656
+ }
657
+ }
658
+ };
659
+ /**
660
+ * Add a drawable object.<br>
661
+ * <br>
662
+ * This must be either:<br>
663
+ * <pre>
664
+ * * a Vertex
665
+ * * a Line
666
+ * * a Vector
667
+ * * a VEllipse
668
+ * * a VEllipseSector
669
+ * * a Circle
670
+ * * a Polygon
671
+ * * a Triangle
672
+ * * a BezierPath
673
+ * * a BPImage
674
+ * </pre>
675
+ *
676
+ * @param {Drawable|Drawable[]} drawable - The drawable (of one of the allowed class instance) to add.
677
+ * @param {boolean} [redraw=true] - If true the function will trigger redraw after the drawable(s) was/were added.
678
+ * @method add
679
+ * @instance
680
+ * @memberof PlotBoilerplate
681
+ * @return {void}
682
+ **/
683
+ PlotBoilerplate.prototype.add = function (drawable, redraw, doNotFireEvent) {
684
+ if (Array.isArray(drawable)) {
685
+ var arr = drawable;
686
+ for (var i = 0; i < arr.length; i++) {
687
+ this.add(arr[i], false, doNotFireEvent);
688
+ }
689
+ // !doNotFireEvent && this._fireContentChanged(arr, []);
690
+ }
691
+ else {
692
+ var addedDrawables = [drawable];
693
+ if (drawable instanceof Vertex_1.Vertex) {
694
+ this.drawables.push(drawable);
695
+ this.vertices.push(drawable);
696
+ }
697
+ else if (drawable instanceof Line_1.Line) {
698
+ // Add some lines
699
+ this.drawables.push(drawable);
700
+ this.vertices.push(drawable.a);
701
+ this.vertices.push(drawable.b);
702
+ addedDrawables.push(drawable.a, drawable.b);
703
+ }
704
+ else if (drawable instanceof Vector_1.Vector) {
705
+ this.drawables.push(drawable);
706
+ this.vertices.push(drawable.a);
707
+ this.vertices.push(drawable.b);
708
+ addedDrawables.push(drawable.a, drawable.b);
709
+ drawable.a.listeners.addDragListener(function (event) {
710
+ drawable.b.add(event.params.dragAmount);
711
+ });
712
+ }
713
+ else if (drawable instanceof VEllipse_1.VEllipse) {
714
+ this.vertices.push(drawable.center);
715
+ this.vertices.push(drawable.axis);
716
+ addedDrawables.push(drawable.center, drawable.axis);
717
+ this.drawables.push(drawable);
718
+ drawable.center.listeners.addDragListener(function (event) {
719
+ drawable.axis.add(event.params.dragAmount);
720
+ });
721
+ }
722
+ else if (drawable instanceof VEllipseSector_1.VEllipseSector) {
723
+ this.vertices.push(drawable.ellipse.center);
724
+ this.vertices.push(drawable.ellipse.axis);
725
+ addedDrawables.push(drawable.ellipse.center, drawable.ellipse.axis);
726
+ this.drawables.push(drawable);
727
+ drawable.ellipse.center.listeners.addDragListener(function (event) {
728
+ drawable.ellipse.axis.add(event.params.dragAmount);
729
+ });
730
+ }
731
+ else if (drawable instanceof Circle_1.Circle) {
732
+ this.vertices.push(drawable.center);
733
+ addedDrawables.push(drawable.center);
734
+ this.drawables.push(drawable);
735
+ }
736
+ else if (drawable instanceof CircleSector_1.CircleSector) {
737
+ this.vertices.push(drawable.circle.center);
738
+ addedDrawables.push(drawable.circle.center);
739
+ this.drawables.push(drawable);
740
+ }
741
+ else if (drawable instanceof Polygon_1.Polygon) {
742
+ this.drawables.push(drawable);
743
+ for (var i = 0; i < drawable.vertices.length; i++) {
744
+ this.vertices.push(drawable.vertices[i]);
745
+ addedDrawables.push(drawable.vertices[i]);
746
+ }
747
+ }
748
+ else if (drawable instanceof Triangle_1.Triangle) {
749
+ this.drawables.push(drawable);
750
+ this.vertices.push(drawable.a);
751
+ this.vertices.push(drawable.b);
752
+ this.vertices.push(drawable.c);
753
+ addedDrawables.push(drawable.a, drawable.b, drawable.c);
754
+ }
755
+ else if (drawable instanceof BezierPath_1.BezierPath) {
756
+ this.drawables.push(drawable);
757
+ var bezierPath = drawable;
758
+ for (var i = 0; i < bezierPath.bezierCurves.length; i++) {
759
+ if (!drawable.adjustCircular && i == 0) {
760
+ this.vertices.push(bezierPath.bezierCurves[i].startPoint);
761
+ addedDrawables.push(bezierPath.bezierCurves[i].startPoint);
762
+ }
763
+ this.vertices.push(bezierPath.bezierCurves[i].endPoint);
764
+ this.vertices.push(bezierPath.bezierCurves[i].startControlPoint);
765
+ this.vertices.push(bezierPath.bezierCurves[i].endControlPoint);
766
+ addedDrawables.push(bezierPath.bezierCurves[i].endPoint, bezierPath.bezierCurves[i].startControlPoint, bezierPath.bezierCurves[i].endControlPoint);
767
+ bezierPath.bezierCurves[i].startControlPoint.attr.selectable = false;
768
+ bezierPath.bezierCurves[i].endControlPoint.attr.selectable = false;
769
+ }
770
+ PlotBoilerplate.utils.enableBezierPathAutoAdjust(drawable);
771
+ }
772
+ else if (drawable instanceof PBImage_1.PBImage) {
773
+ this.vertices.push(drawable.upperLeft);
774
+ this.vertices.push(drawable.lowerRight);
775
+ addedDrawables.push(drawable.upperLeft, drawable.lowerRight);
776
+ this.drawables.push(drawable);
777
+ // Todo: think about a IDragEvent interface
778
+ drawable.upperLeft.listeners.addDragListener(function (e) {
779
+ drawable.lowerRight.add(e.params.dragAmount);
780
+ });
781
+ drawable.lowerRight.attr.selectable = false;
782
+ }
783
+ else if (drawable instanceof PBText_1.PBText) {
784
+ this.vertices.push(drawable.anchor);
785
+ addedDrawables.push(drawable.anchor);
786
+ this.drawables.push(drawable);
787
+ drawable.anchor.attr.selectable = false;
788
+ }
789
+ else {
790
+ throw "Cannot add drawable of unrecognized type: " + typeof drawable + ".";
791
+ }
792
+ !doNotFireEvent && this._fireContentChanged(addedDrawables, []);
793
+ }
794
+ // This is a workaround for backwards compatibility when the 'redraw' param was not yet present.
795
+ if (redraw || typeof redraw == "undefined") {
796
+ this.redraw();
797
+ }
798
+ };
799
+ /**
800
+ * Remove a drawable object.<br>
801
+ * <br>
802
+ * This must be either:<br>
803
+ * <pre>
804
+ * * a Vertex
805
+ * * a Line
806
+ * * a Vector
807
+ * * a VEllipse
808
+ * * a Circle
809
+ * * a Polygon
810
+ * * a BezierPath
811
+ * * a BPImage
812
+ * * a Triangle
813
+ * </pre>
814
+ *
815
+ * @param {Drawable|Array<Drawable>} drawable - The drawable (of one of the allowed class instance) to remove.
816
+ * @param {boolean} [redraw=false]
817
+ * @param {removeWidth}
818
+ * @method remove
819
+ * @instance
820
+ * @memberof PlotBoilerplate
821
+ * @return {void}
822
+ **/
823
+ PlotBoilerplate.prototype.remove = function (drawable, redraw, removeWithVertices, doNotFireEvent) {
824
+ if (Array.isArray(drawable)) {
825
+ var removedDrawables_1 = [];
826
+ for (var i = 0; i < drawable.length; i++) {
827
+ if (this.remove(drawable[i], false, removeWithVertices, true)) {
828
+ removedDrawables_1.push(drawable[i]);
829
+ }
830
+ }
831
+ if (redraw) {
832
+ this.redraw();
833
+ }
834
+ !doNotFireEvent && this._fireContentChanged([], removedDrawables_1);
835
+ return removedDrawables_1.length > 0;
836
+ }
837
+ if (drawable instanceof Vertex_1.Vertex) {
838
+ var wasRemoved_1 = this.removeVertex(drawable, false, false);
839
+ if (redraw) {
840
+ this.redraw();
841
+ }
842
+ !doNotFireEvent && this._fireContentChanged([], [drawable]);
843
+ return wasRemoved_1;
844
+ }
845
+ var wasRemoved = false;
846
+ var removedDrawables = [];
847
+ for (var i = 0; i < this.drawables.length; i++) {
848
+ if (this.drawables[i] === drawable || this.drawables[i].uid === drawable.uid) {
849
+ this.drawables.splice(i, 1);
850
+ removedDrawables.push(drawable);
851
+ if (removeWithVertices) {
852
+ // Check if some listeners need to be removed
853
+ if (drawable instanceof Line_1.Line) {
854
+ // Add some lines
855
+ this.removeVertex(drawable.a, false, true);
856
+ this.removeVertex(drawable.b, false, true);
857
+ removedDrawables.push(drawable.a, drawable.b);
858
+ }
859
+ else if (drawable instanceof Vector_1.Vector) {
860
+ this.removeVertex(drawable.a, false, true);
861
+ this.removeVertex(drawable.b, false, true);
862
+ removedDrawables.push(drawable.a, drawable.b);
863
+ }
864
+ else if (drawable instanceof VEllipse_1.VEllipse) {
865
+ this.removeVertex(drawable.center, false, true);
866
+ this.removeVertex(drawable.axis, false, true);
867
+ removedDrawables.push(drawable.center, drawable.axis);
868
+ }
869
+ else if (drawable instanceof VEllipseSector_1.VEllipseSector) {
870
+ this.removeVertex(drawable.ellipse.center, false, true);
871
+ this.removeVertex(drawable.ellipse.axis, false, true);
872
+ removedDrawables.push(drawable.ellipse.center, drawable.ellipse.axis);
873
+ }
874
+ else if (drawable instanceof Circle_1.Circle) {
875
+ this.removeVertex(drawable.center, false, true);
876
+ }
877
+ else if (drawable instanceof CircleSector_1.CircleSector) {
878
+ this.removeVertex(drawable.circle.center, false, true);
879
+ removedDrawables.push(drawable.circle.center);
880
+ }
881
+ else if (drawable instanceof Polygon_1.Polygon) {
882
+ // for( var i in drawable.vertices )
883
+ for (var i = 0; i < drawable.vertices.length; i++) {
884
+ this.removeVertex(drawable.vertices[i], false, true);
885
+ removedDrawables.push(drawable.vertices[i]);
886
+ }
887
+ }
888
+ else if (drawable instanceof Triangle_1.Triangle) {
889
+ this.removeVertex(drawable.a, false, true);
890
+ this.removeVertex(drawable.b, false, true);
891
+ this.removeVertex(drawable.c, false, true);
892
+ removedDrawables.push(drawable.a, drawable.b, drawable.c);
893
+ }
894
+ else if (drawable instanceof BezierPath_1.BezierPath) {
895
+ for (var i = 0; i < drawable.bezierCurves.length; i++) {
896
+ this.removeVertex(drawable.bezierCurves[i].startPoint, false, true);
897
+ this.removeVertex(drawable.bezierCurves[i].startControlPoint, false, true);
898
+ this.removeVertex(drawable.bezierCurves[i].endControlPoint, false, true);
899
+ removedDrawables.push(drawable.bezierCurves[i].startPoint, drawable.bezierCurves[i].startControlPoint, drawable.bezierCurves[i].endControlPoint);
900
+ if (i + 1 == drawable.bezierCurves.length) {
901
+ this.removeVertex(drawable.bezierCurves[i].endPoint, false, true);
902
+ removedDrawables.push(drawable.bezierCurves[i].endPoint);
903
+ }
904
+ }
905
+ }
906
+ else if (drawable instanceof PBImage_1.PBImage) {
907
+ this.removeVertex(drawable.upperLeft, false, true);
908
+ this.removeVertex(drawable.lowerRight, false, true);
909
+ removedDrawables.push(drawable.upperLeft, drawable.lowerRight);
910
+ }
911
+ else if (drawable instanceof PBText_1.PBText) {
912
+ this.removeVertex(drawable.anchor, false, true);
913
+ removedDrawables.push(drawable.anchor);
914
+ }
915
+ } // END removeWithVertices
916
+ if (redraw) {
917
+ this.redraw();
918
+ }
919
+ !doNotFireEvent && this._fireContentChanged([], removedDrawables);
920
+ wasRemoved = true;
921
+ } // END if
922
+ } // END for
923
+ return wasRemoved;
924
+ };
925
+ /**
926
+ * Remove a vertex from the vertex list.<br>
927
+ *
928
+ * @param {Vertex} vert - The vertex to remove.
929
+ * @param {boolean} [redraw=false]
930
+ * @method removeVertex
931
+ * @instance
932
+ * @memberof PlotBoilerplate
933
+ * @return {boolean}
934
+ **/
935
+ PlotBoilerplate.prototype.removeVertex = function (vert, redraw, doNotFireEvent) {
936
+ for (var i = 0; i < this.vertices.length; i++) {
937
+ if (this.vertices[i] === vert) {
938
+ this.vertices.splice(i, 1);
939
+ if (redraw) {
940
+ this.redraw();
941
+ }
942
+ !doNotFireEvent && this._fireContentChanged([], [vert]);
943
+ return true;
944
+ }
945
+ }
946
+ return false;
947
+ };
948
+ /**
949
+ * Remove all elements.
950
+ *
951
+ * If you want to keep the vertices, pass `true`.
952
+ *
953
+ * @method removeAll
954
+ * @param {boolean=false} keepVertices
955
+ * @param {boolean=true} triggerRedraw - By default this method triggers the redraw routine; passing `false` will suppress redrawing.
956
+ * @instance
957
+ * @memberof PlotBoilerplate
958
+ * @return {void}
959
+ */
960
+ PlotBoilerplate.prototype.removeAll = function (keepVertices, triggerRedraw) {
961
+ var removedDrawables = this.drawables;
962
+ this.drawables = [];
963
+ if (!Boolean(keepVertices)) {
964
+ removedDrawables = removedDrawables.concat(this.vertices);
965
+ this.vertices = [];
966
+ }
967
+ if (triggerRedraw || typeof triggerRedraw === "undefined") {
968
+ this.redraw();
969
+ }
970
+ removedDrawables.length > 0 && this._fireContentChanged([], removedDrawables);
971
+ };
972
+ /**
973
+ * Find the vertex near the given position.
974
+ *
975
+ * The position is the absolute vertex position, not the x-y-coordinates on the canvas.
976
+ *
977
+ * @param {XYCoords} position - The position of the vertex to search for.
978
+ * @param {number} pixelTolerance - A radius around the position to include into the search.
979
+ * Note that the tolerance will be scaled up/down when zoomed.
980
+ * @return The vertex near the given position or undefined if none was found there.
981
+ **/
982
+ PlotBoilerplate.prototype.getVertexNear = function (pixelPosition, pixelTolerance) {
983
+ var _b, _c;
984
+ var p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min((_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0, (_c = this.config.cssScaleY) !== null && _c !== void 0 ? _c : 1.0));
985
+ if (p && p.typeName == "vertex") {
986
+ return this.vertices[p.vindex];
987
+ }
988
+ return undefined;
989
+ };
990
+ /**
991
+ * Draw the grid with the current config settings.<br>
992
+ *
993
+ * This function is usually only used internally.
994
+ *
995
+ * @method drawGrid
996
+ * @param {DrawLib} draw - The drawing library to use to draw lines.
997
+ * @private
998
+ * @instance
999
+ * @memberof PlotBoilerplate
1000
+ * @return {void}
1001
+ **/
1002
+ PlotBoilerplate.prototype.drawGrid = function (draw) {
1003
+ if (typeof draw === "undefined") {
1004
+ draw = this.draw;
1005
+ }
1006
+ var gScale = {
1007
+ x: (Grid_1.Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.x) * this.config.rasterScaleX) /
1008
+ this.config.cssScaleX,
1009
+ y: (Grid_1.Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.y) * this.config.rasterScaleY) /
1010
+ this.config.cssScaleY
1011
+ };
1012
+ var gSize = { width: this.grid.size.x * gScale.x, height: this.grid.size.y * gScale.y };
1013
+ var cs = { width: this.canvasSize.width / 2, height: this.canvasSize.height / 2 };
1014
+ var offset = this.draw.offset.clone().inv();
1015
+ // console.log( "drawGrid", gScale, gSize, cs, offset );
1016
+ offset.x =
1017
+ ((Math.round(offset.x + cs.width) / Math.round(gSize.width)) * gSize.width) / this.draw.scale.x +
1018
+ (((this.draw.offset.x - cs.width) / this.draw.scale.x) % gSize.width);
1019
+ offset.y =
1020
+ ((Math.round(offset.y + cs.height) / Math.round(gSize.height)) * gSize.height) / this.draw.scale.y +
1021
+ (((this.draw.offset.y - cs.height) / this.draw.scale.x) % gSize.height);
1022
+ if (this.drawConfig.drawGrid) {
1023
+ draw.setCurrentClassName(null);
1024
+ if (this.config.rasterGrid) {
1025
+ // TODO: move config member to drawConfig
1026
+ draw.setCurrentId("raster");
1027
+ draw.raster(offset, this.canvasSize.width / this.draw.scale.x, this.canvasSize.height / this.draw.scale.y, gSize.width, gSize.height, "rgba(0,128,255,0.125)");
1028
+ }
1029
+ else {
1030
+ draw.setCurrentId("grid");
1031
+ draw.grid(offset, this.canvasSize.width / this.draw.scale.x, this.canvasSize.height / this.draw.scale.y, gSize.width, gSize.height, "rgba(0,128,255,0.095)");
1032
+ }
1033
+ }
1034
+ };
1035
+ /**
1036
+ * Draw the origin with the current config settings.<br>
1037
+ *
1038
+ * This function is usually only used internally.
1039
+ *
1040
+ * @method drawOrigin
1041
+ * @param {DrawLib} draw - The drawing library to use to draw lines.
1042
+ * @private
1043
+ * @instance
1044
+ * @memberof PlotBoilerplate
1045
+ * @return {void}
1046
+ **/
1047
+ PlotBoilerplate.prototype.drawOrigin = function (draw) {
1048
+ // Add a crosshair to mark the origin
1049
+ draw.setCurrentId("origin");
1050
+ draw.crosshair({ x: 0, y: 0 }, 10, this.drawConfig.origin.color);
1051
+ };
1052
+ /**
1053
+ * This is just a tiny helper function to determine the render color of vertices.
1054
+ **/
1055
+ PlotBoilerplate.prototype._handleColor = function (h, color) {
1056
+ return h.attr.isSelected ? this.drawConfig.selectedVertex.color : h.attr.draggable ? color : "rgba(128,128,128,0.5)";
1057
+ };
1058
+ /**
1059
+ * Draw all drawables.
1060
+ *
1061
+ * This function is usually only used internally.
1062
+ *
1063
+ * @method drawDrawables
1064
+ * @param {number} renderTime - The current render time. It will be used to distinct
1065
+ * already draw vertices from non-draw-yet vertices.
1066
+ * @param {DrawLib} draw - The drawing library to use to draw lines.
1067
+ * @param {DrawLib} fill - The drawing library to use to fill areas.
1068
+ * @instance
1069
+ * @memberof PlotBoilerplate
1070
+ * @return {void}
1071
+ **/
1072
+ PlotBoilerplate.prototype.drawDrawables = function (renderTime, draw, fill) {
1073
+ for (var i in this.drawables) {
1074
+ var d = this.drawables[i];
1075
+ this.draw.setCurrentId(d.uid);
1076
+ this.fill.setCurrentId(d.uid);
1077
+ this.draw.setCurrentClassName(d.className);
1078
+ this.fill.setCurrentClassName(d.className);
1079
+ this.drawDrawable(d, renderTime, draw, fill);
1080
+ }
1081
+ };
1082
+ /**
1083
+ * Draw the given drawable.
1084
+ *
1085
+ * This function is usually only used internally.
1086
+ *
1087
+ * @method drawDrawable
1088
+ * @param {Drawable} d - The drawable to draw.
1089
+ * @param {number} renderTime - The current render time. It will be used to distinct
1090
+ * already draw vertices from non-draw-yet vertices.
1091
+ * @param {DrawLib} draw - The drawing library to use to draw lines.
1092
+ * @param {DrawLib} fill - The drawing library to use to fill areas.
1093
+ * @instance
1094
+ * @memberof PlotBoilerplate
1095
+ * @return {void}
1096
+ **/
1097
+ PlotBoilerplate.prototype.drawDrawable = function (d, renderTime, draw, fill) {
1098
+ if (d instanceof BezierPath_1.BezierPath) {
1099
+ var curveIndex = 0;
1100
+ for (var c in d.bezierCurves) {
1101
+ // Restore these settings again in each loop (will be overwritten)
1102
+ this.draw.setCurrentId("".concat(d.uid, "-").concat(curveIndex));
1103
+ this.fill.setCurrentId("".concat(d.uid, "-").concat(curveIndex));
1104
+ this.draw.setCurrentClassName(d.className);
1105
+ this.fill.setCurrentClassName(d.className);
1106
+ draw.cubicBezier(d.bezierCurves[c].startPoint, d.bezierCurves[c].endPoint, d.bezierCurves[c].startControlPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.color, this.drawConfig.bezier.lineWidth);
1107
+ if (this.drawConfig.drawBezierHandlePoints && this.drawConfig.drawHandlePoints) {
1108
+ if (d.bezierCurves[c].startPoint.attr.visible) {
1109
+ var df = this.drawConfig.bezier.pathVertex.fill ? fill : draw;
1110
+ df.setCurrentId("".concat(d.uid, "_h0"));
1111
+ df.setCurrentClassName("".concat(d.className, "-start-handle"));
1112
+ if (d.bezierCurves[c].startPoint.attr.bezierAutoAdjust) {
1113
+ df.squareHandle(d.bezierCurves[c].startPoint, 5, this._handleColor(d.bezierCurves[c].startPoint, this.drawConfig.bezier.pathVertex.color));
1114
+ }
1115
+ else {
1116
+ df.diamondHandle(d.bezierCurves[c].startPoint, 7, this._handleColor(d.bezierCurves[c].startPoint, this.drawConfig.bezier.pathVertex.color));
1117
+ }
1118
+ }
1119
+ d.bezierCurves[c].startPoint.attr.renderTime = renderTime;
1120
+ if (d.bezierCurves[c].endPoint.attr.visible) {
1121
+ var df = this.drawConfig.bezier.pathVertex.fill ? fill : draw;
1122
+ df.setCurrentId("".concat(d.uid, "_h0"));
1123
+ df.setCurrentClassName("".concat(d.className, "-start-handle"));
1124
+ if (d.bezierCurves[c].endPoint.attr.bezierAutoAdjust) {
1125
+ df.squareHandle(d.bezierCurves[c].endPoint, 5, this._handleColor(d.bezierCurves[c].endPoint, this.drawConfig.bezier.pathVertex.color));
1126
+ }
1127
+ else {
1128
+ df.diamondHandle(d.bezierCurves[c].endPoint, 7, this._handleColor(d.bezierCurves[c].endPoint, this.drawConfig.bezier.pathVertex.color));
1129
+ }
1130
+ }
1131
+ if (d.bezierCurves[c].startControlPoint.attr.visible) {
1132
+ var df = this.drawConfig.bezier.controlVertex.fill ? fill : draw;
1133
+ df.setCurrentId("".concat(d.uid, "_h2"));
1134
+ df.setCurrentClassName("".concat(d.className, "-start-control-handle"));
1135
+ df.circleHandle(d.bezierCurves[c].startControlPoint, 3, this._handleColor(d.bezierCurves[c].startControlPoint, this.drawConfig.bezier.controlVertex.color));
1136
+ }
1137
+ if (d.bezierCurves[c].endControlPoint.attr.visible) {
1138
+ var df = this.drawConfig.bezier.controlVertex.fill ? fill : draw;
1139
+ df.setCurrentId("".concat(d.uid, "_h3"));
1140
+ df.setCurrentClassName("".concat(d.className, "-end-control-handle"));
1141
+ df.circleHandle(d.bezierCurves[c].endControlPoint, 3, this._handleColor(d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.controlVertex.color));
1142
+ }
1143
+ d.bezierCurves[c].startPoint.attr.renderTime = renderTime;
1144
+ d.bezierCurves[c].endPoint.attr.renderTime = renderTime;
1145
+ d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;
1146
+ d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;
1147
+ }
1148
+ else {
1149
+ d.bezierCurves[c].startPoint.attr.renderTime = renderTime;
1150
+ d.bezierCurves[c].endPoint.attr.renderTime = renderTime;
1151
+ d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;
1152
+ d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;
1153
+ }
1154
+ if (this.drawConfig.drawBezierHandleLines && this.drawConfig.drawHandleLines) {
1155
+ draw.setCurrentId("".concat(d.uid, "_l0"));
1156
+ draw.setCurrentClassName("".concat(d.className, "-start-line"));
1157
+ draw.handleLine(d.bezierCurves[c].startPoint, d.bezierCurves[c].startControlPoint);
1158
+ draw.setCurrentId("".concat(d.uid, "_l1"));
1159
+ draw.setCurrentClassName("".concat(d.className, "-end-line"));
1160
+ draw.handleLine(d.bezierCurves[c].endPoint, d.bezierCurves[c].endControlPoint);
1161
+ }
1162
+ curveIndex++;
1163
+ } // END for
1164
+ }
1165
+ else if (d instanceof Polygon_1.Polygon) {
1166
+ draw.polygon(d, this.drawConfig.polygon.color, this.drawConfig.polygon.lineWidth);
1167
+ if (!this.drawConfig.drawHandlePoints) {
1168
+ for (var i in d.vertices) {
1169
+ d.vertices[i].attr.renderTime = renderTime;
1170
+ }
1171
+ }
1172
+ }
1173
+ else if (d instanceof Triangle_1.Triangle) {
1174
+ draw.polyline([d.a, d.b, d.c], false, this.drawConfig.triangle.color, this.drawConfig.triangle.lineWidth);
1175
+ if (!this.drawConfig.drawHandlePoints) {
1176
+ d.a.attr.renderTime = d.b.attr.renderTime = d.c.attr.renderTime = renderTime;
1177
+ }
1178
+ }
1179
+ else if (d instanceof VEllipse_1.VEllipse) {
1180
+ if (this.drawConfig.drawHandleLines) {
1181
+ draw.setCurrentId("".concat(d.uid, "_e0"));
1182
+ draw.setCurrentClassName("".concat(d.className, "-v-line"));
1183
+ draw.handleLine(d.center.clone().add(0, d.signedRadiusV()).rotate(d.rotation, d.center), d.axis); // , "#c8c8c8");
1184
+ draw.setCurrentId("".concat(d.uid, "_e1"));
1185
+ draw.setCurrentClassName("".concat(d.className, "-h-line"));
1186
+ draw.handleLine(d.center.clone().add(d.signedRadiusH(), 0).rotate(d.rotation, d.center), d.axis); // , "#c8c8c8");
1187
+ }
1188
+ draw.setCurrentId(d.uid);
1189
+ draw.setCurrentClassName("".concat(d.className));
1190
+ draw.ellipse(d.center,
1191
+ // Math.abs(d.axis.x-d.center.x), Math.abs(d.axis.y-d.center.y),
1192
+ d.radiusH(), d.radiusV(), this.drawConfig.ellipse.color, this.drawConfig.ellipse.lineWidth, d.rotation);
1193
+ if (!this.drawConfig.drawHandlePoints) {
1194
+ d.center.attr.renderTime = renderTime;
1195
+ d.axis.attr.renderTime = renderTime;
1196
+ }
1197
+ }
1198
+ else if (d instanceof VEllipseSector_1.VEllipseSector) {
1199
+ draw.setCurrentId(d.uid);
1200
+ draw.setCurrentClassName("".concat(d.className));
1201
+ var data = VEllipseSector_1.VEllipseSector.ellipseSectorUtils.describeSVGArc(d.ellipse.center.x, d.ellipse.center.y, d.ellipse.radiusH(), d.ellipse.radiusV(), d.startAngle, d.endAngle, d.ellipse.rotation, { moveToStart: true });
1202
+ draw.path(data, this.drawConfig.ellipseSector.color, this.drawConfig.ellipseSector.lineWidth);
1203
+ }
1204
+ else if (d instanceof Circle_1.Circle) {
1205
+ draw.circle(d.center, d.radius, this.drawConfig.circle.color, this.drawConfig.circle.lineWidth);
1206
+ }
1207
+ else if (d instanceof CircleSector_1.CircleSector) {
1208
+ draw.circleArc(d.circle.center, d.circle.radius, d.startAngle, d.endAngle, this.drawConfig.circleSector.color, this.drawConfig.circleSector.lineWidth);
1209
+ }
1210
+ else if (d instanceof Vertex_1.Vertex) {
1211
+ if (this.drawConfig.drawVertices && (!d.attr.selectable || !d.attr.draggable) && d.attr.visible) {
1212
+ // Draw as special point (grey)
1213
+ draw.circleHandle(d, 7, this.drawConfig.vertex.color);
1214
+ d.attr.renderTime = renderTime;
1215
+ }
1216
+ }
1217
+ else if (d instanceof Line_1.Line) {
1218
+ draw.line(d.a, d.b, this.drawConfig.line.color, this.drawConfig.line.lineWidth);
1219
+ if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)
1220
+ d.a.attr.renderTime = renderTime;
1221
+ if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)
1222
+ d.b.attr.renderTime = renderTime;
1223
+ }
1224
+ else if (d instanceof Vector_1.Vector) {
1225
+ draw.arrow(d.a, d.b, this.drawConfig.vector.color, this.drawConfig.vector.lineWidth);
1226
+ if (this.drawConfig.drawHandlePoints && d.b.attr.selectable && d.b.attr.visible) {
1227
+ draw.setCurrentId("".concat(d.uid, "_h0"));
1228
+ draw.setCurrentClassName("".concat(d.className, "-handle"));
1229
+ draw.circleHandle(d.b, 3, "#a8a8a8");
1230
+ }
1231
+ else {
1232
+ d.b.attr.renderTime = renderTime;
1233
+ }
1234
+ if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)
1235
+ d.a.attr.renderTime = renderTime;
1236
+ if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)
1237
+ d.b.attr.renderTime = renderTime;
1238
+ }
1239
+ else if (d instanceof PBImage_1.PBImage) {
1240
+ if (this.drawConfig.drawHandleLines) {
1241
+ draw.setCurrentId("".concat(d.uid, "_l0"));
1242
+ draw.setCurrentClassName("".concat(d.className, "-line"));
1243
+ draw.line(d.upperLeft, d.lowerRight, this.drawConfig.image.color, this.drawConfig.image.lineWidth);
1244
+ }
1245
+ fill.setCurrentId(d.uid);
1246
+ fill.image(d.image, d.upperLeft, d.lowerRight.clone().sub(d.upperLeft));
1247
+ if (this.drawConfig.drawHandlePoints) {
1248
+ draw.setCurrentId("".concat(d.uid, "_h0"));
1249
+ draw.setCurrentClassName("".concat(d.className, "-lower-right"));
1250
+ draw.circleHandle(d.lowerRight, 3, this.drawConfig.image.color);
1251
+ d.lowerRight.attr.renderTime = renderTime;
1252
+ }
1253
+ }
1254
+ else if (d instanceof PBText_1.PBText) {
1255
+ fill.setCurrentId(d.uid);
1256
+ fill.text(d.text, d.anchor.x, d.anchor.y, d);
1257
+ if (this.drawConfig.text.anchor) {
1258
+ draw.setCurrentId("".concat(d.uid, "_a0"));
1259
+ draw.setCurrentClassName("".concat(d.className, "-anchor"));
1260
+ (this.drawConfig.text.fill ? fill : draw).point(d.anchor, this.drawConfig.text.color);
1261
+ }
1262
+ d.anchor.attr.renderTime = renderTime;
1263
+ }
1264
+ else {
1265
+ console.error("Cannot draw object. Unknown class.");
1266
+ }
1267
+ draw.setCurrentClassName(null);
1268
+ draw.setCurrentId(null);
1269
+ fill.setCurrentClassName(null);
1270
+ fill.setCurrentId(null);
1271
+ };
1272
+ /**
1273
+ * Draw the select-polygon (if there is one).
1274
+ *
1275
+ * This function is usually only used internally.
1276
+ *
1277
+ * @method drawSelectPolygon
1278
+ * @private
1279
+ * @instance
1280
+ * @memberof PlotBoilerplate
1281
+ * @return {void}
1282
+ **/
1283
+ PlotBoilerplate.prototype.drawSelectPolygon = function (draw) {
1284
+ // Draw select polygon?
1285
+ if (this.selectPolygon != null && this.selectPolygon.vertices.length > 0) {
1286
+ draw.setCurrentId(this.selectPolygon.uid);
1287
+ draw.polygon(this.selectPolygon, "#888888");
1288
+ draw.crosshair(this.selectPolygon.vertices[0], 3, "#008888");
1289
+ }
1290
+ };
1291
+ /**
1292
+ * Draw all vertices that were not yet drawn with the given render time.<br>
1293
+ * <br>
1294
+ * This function is usually only used internally.
1295
+ *
1296
+ * @method drawVertices
1297
+ * @private
1298
+ * @param {number} renderTime - The current render time. It is used to distinct
1299
+ * already draw vertices from non-draw-yet vertices.
1300
+ * @instance
1301
+ * @memberof PlotBoilerplate
1302
+ * @return {void}
1303
+ **/
1304
+ PlotBoilerplate.prototype.drawVertices = function (renderTime, draw) {
1305
+ // Draw all vertices as small squares if they were not already drawn by other objects
1306
+ for (var i in this.vertices) {
1307
+ if (this.drawConfig.drawVertices && this.vertices[i].attr.renderTime != renderTime && this.vertices[i].attr.visible) {
1308
+ draw.setCurrentId(this.vertices[i].uid);
1309
+ draw.squareHandle(this.vertices[i], 5, this._handleColor(this.vertices[i], "rgb(0,128,192)"));
1310
+ this.vertices[i].attr.renderTime = renderTime;
1311
+ }
1312
+ }
1313
+ };
1314
+ /**
1315
+ * Trigger redrawing of all objects.<br>
1316
+ * <br>
1317
+ * Usually this function is automatically called when objects change.
1318
+ *
1319
+ * @method redraw
1320
+ * @instance
1321
+ * @memberof PlotBoilerplate
1322
+ * @return {void}
1323
+ **/
1324
+ PlotBoilerplate.prototype.redraw = function () {
1325
+ var renderTime = this.renderTime++;
1326
+ // Tell the drawing library that a new drawing cycle begins (required for the GL lib).
1327
+ this.draw.beginDrawCycle(renderTime);
1328
+ this.fill.beginDrawCycle(renderTime);
1329
+ if (this.config.preClear)
1330
+ this.config.preClear();
1331
+ this.clear();
1332
+ if (this.config.preDraw)
1333
+ this.config.preDraw(this.draw, this.fill);
1334
+ this.drawAll(renderTime, this.draw, this.fill);
1335
+ if (this.config.postDraw)
1336
+ this.config.postDraw(this.draw, this.fill);
1337
+ this.draw.endDrawCycle(renderTime);
1338
+ this.fill.endDrawCycle(renderTime);
1339
+ };
1340
+ /**
1341
+ * Draw all: drawables, grid, select-polygon and vertices.
1342
+ *
1343
+ * @method drawAll
1344
+ * @instance
1345
+ * @memberof PlotBoilerplate
1346
+ * @return {void}
1347
+ **/
1348
+ PlotBoilerplate.prototype.drawAll = function (renderTime, draw, fill) {
1349
+ if (this.config.drawRaster) {
1350
+ this.drawGrid(draw);
1351
+ }
1352
+ if (this.config.drawOrigin) {
1353
+ this.drawOrigin(draw);
1354
+ }
1355
+ this.drawDrawables(renderTime, draw, fill);
1356
+ this.drawVertices(renderTime, draw);
1357
+ this.drawSelectPolygon(draw);
1358
+ // Clear IDs and classnames (postDraw hook might draw somthing and the do not want
1359
+ // to interfered with that).
1360
+ draw.setCurrentId(null);
1361
+ draw.setCurrentClassName(null);
1362
+ }; // END redraw
1363
+ /**
1364
+ * This function clears the canvas with the configured background color.<br>
1365
+ * <br>
1366
+ * This function is usually only used internally.
1367
+ *
1368
+ * @method clear
1369
+ * @private
1370
+ * @instance
1371
+ * @memberof PlotBoilerplate
1372
+ * @return {void}
1373
+ **/
1374
+ PlotBoilerplate.prototype.clear = function () {
1375
+ // Note that elements might have an alpha channel. Clear the scene first.
1376
+ this.draw.clear(this.config.backgroundColor || "white");
1377
+ };
1378
+ /**
1379
+ * Clear the selection.<br>
1380
+ * <br>
1381
+ * This function is usually only used internally.
1382
+ *
1383
+ * @method clearSelection
1384
+ * @private
1385
+ * @param {boolean=} [redraw=false] - Indicates if the redraw function should be triggered.
1386
+ * @instance
1387
+ * @memberof PlotBoilerplate
1388
+ * @return {PlotBoilerplate} this
1389
+ **/
1390
+ PlotBoilerplate.prototype.clearSelection = function (redraw) {
1391
+ for (var i in this.vertices)
1392
+ this.vertices[i].attr.isSelected = false;
1393
+ if (redraw)
1394
+ this.redraw();
1395
+ return this;
1396
+ };
1397
+ /**
1398
+ * Get the current view port.
1399
+ *
1400
+ * @method viewport
1401
+ * @instance
1402
+ * @memberof PlotBoilerplate
1403
+ * @return {Bounds} The current viewport.
1404
+ **/
1405
+ PlotBoilerplate.prototype.viewport = function () {
1406
+ var _b, _c;
1407
+ return new Bounds_1.Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * ((_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0), this.canvasSize.height * ((_c = this.config.cssScaleY) !== null && _c !== void 0 ? _c : 1.0)));
1408
+ };
1409
+ /**
1410
+ * Trigger the saveFile.hook.
1411
+ *
1412
+ * @method saveFile
1413
+ * @instance
1414
+ * @memberof PlotBoilerplate
1415
+ * @return {void}
1416
+ **/
1417
+ PlotBoilerplate.prototype.saveFile = function () {
1418
+ this.hooks.saveFile(this);
1419
+ };
1420
+ /**
1421
+ * Internal helper function used to get 'float' properties from elements.
1422
+ * Used to determine border withs and paddings that were defined using CSS.
1423
+ */
1424
+ // TODO: this was moved to the DOM utils
1425
+ PlotBoilerplate.prototype.getFProp = function (elem, propName) {
1426
+ return parseFloat(globalThis.getComputedStyle(elem, null).getPropertyValue(propName));
1427
+ };
1428
+ /**
1429
+ * Get the available inner space of the given container.
1430
+ *
1431
+ * Size minus padding minus border.
1432
+ **/
1433
+ // TODO: this was moved to the DOM utils
1434
+ PlotBoilerplate.prototype.getAvailableContainerSpace = function () {
1435
+ var _self = this;
1436
+ var container = _self.canvas.parentNode; // Element | Document | DocumentFragment;
1437
+ _self.canvas.style.display = "none";
1438
+ var padding = this.getFProp(container, "padding") || 0, border = this.getFProp(_self.canvas, "border-width") || 0, pl = this.getFProp(container, "padding-left") || padding, pr = this.getFProp(container, "padding-right") || padding, pt = this.getFProp(container, "padding-top") || padding, pb = this.getFProp(container, "padding-bottom") || padding, bl = this.getFProp(_self.canvas, "border-left-width") || border, br = this.getFProp(_self.canvas, "border-right-width") || border, bt = this.getFProp(_self.canvas, "border-top-width") || border, bb = this.getFProp(_self.canvas, "border-bottom-width") || border;
1439
+ var w = container.clientWidth;
1440
+ var h = container.clientHeight;
1441
+ _self.canvas.style.display = "block";
1442
+ return { width: w - pl - pr - bl - br, height: h - pt - pb - bt - bb };
1443
+ };
1444
+ /**
1445
+ * This function resizes the canvas to the required settings (toggles fullscreen).<br>
1446
+ * <br>
1447
+ * This function is usually only used internally but feel free to call it if resizing required.
1448
+ *
1449
+ * @method resizeCanvas
1450
+ * @instance
1451
+ * @memberof PlotBoilerplate
1452
+ * @return {void}
1453
+ **/
1454
+ PlotBoilerplate.prototype.resizeCanvas = function () {
1455
+ var _this = this;
1456
+ var _b, _c, _d, _e, _f, _g;
1457
+ var _self = this;
1458
+ var _setSize = function (w, h) {
1459
+ var _b, _c;
1460
+ w *= (_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0;
1461
+ h *= (_c = _self.config.canvasHeightFactor) !== null && _c !== void 0 ? _c : 1.0;
1462
+ _self.canvasSize.width = w;
1463
+ _self.canvasSize.height = h;
1464
+ if (_self.canvas instanceof HTMLCanvasElement) {
1465
+ _self.canvas.width = w;
1466
+ _self.canvas.height = h;
1467
+ }
1468
+ else if (_self.canvas instanceof SVGElement) {
1469
+ _this.canvas.setAttribute("viewBox", "0 0 ".concat(w, " ").concat(h));
1470
+ _this.canvas.setAttribute("width", "".concat(w));
1471
+ _this.canvas.setAttribute("height", "".concat(h));
1472
+ _this.draw.setSize(_self.canvasSize); // No need to set size to this.fill (instance copy)
1473
+ _this.eventCatcher.style.width = "".concat(w, "px");
1474
+ _this.eventCatcher.style.height = "".concat(h, "px");
1475
+ }
1476
+ else {
1477
+ console.error("Error: cannot resize canvas element because it seems neither be a HTMLCanvasElement nor an SVGElement.");
1478
+ }
1479
+ if (_self.config.autoAdjustOffset) {
1480
+ // _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX = w*(_self.config.offsetAdjustXPercent/100);
1481
+ // _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY = h*(_self.config.offsetAdjustYPercent/100);
1482
+ _self.adjustOffset(false);
1483
+ }
1484
+ };
1485
+ if (_self.config.fullSize && !_self.config.fitToParent) {
1486
+ // Set editor size
1487
+ var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
1488
+ var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
1489
+ _self.canvas.style.position = "absolute";
1490
+ _self.canvas.style.width = ((_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0) * width + "px";
1491
+ _self.canvas.style.height = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * height + "px";
1492
+ _self.canvas.style.top = "0px";
1493
+ _self.canvas.style.left = "0px";
1494
+ _setSize(width, height);
1495
+ }
1496
+ else if (_self.config.fitToParent) {
1497
+ // Set editor size
1498
+ _self.canvas.style.position = "static";
1499
+ var space = this.getAvailableContainerSpace();
1500
+ _self.canvas.style.width = ((_d = _self.config.canvasWidthFactor) !== null && _d !== void 0 ? _d : 1.0) * space.width + "px";
1501
+ _self.canvas.style.height = ((_e = _self.config.canvasHeightFactor) !== null && _e !== void 0 ? _e : 1.0) * space.height + "px";
1502
+ _self.canvas.style.top = "";
1503
+ _self.canvas.style.left = "";
1504
+ _setSize(space.width, space.height);
1505
+ }
1506
+ else {
1507
+ _self.canvas.style.width = "";
1508
+ _self.canvas.style.height = "";
1509
+ _setSize((_f = _self.config.defaultCanvasWidth) !== null && _f !== void 0 ? _f : 1024, (_g = _self.config.defaultCanvasHeight) !== null && _g !== void 0 ? _g : 768);
1510
+ }
1511
+ if (_self.config.redrawOnResize)
1512
+ _self.redraw();
1513
+ };
1514
+ /**
1515
+ * Add all vertices inside the polygon to the current selection.<br>
1516
+ *
1517
+ * @method selectVerticesInPolygon
1518
+ * @param {Polygon} polygon - The polygonal selection area.
1519
+ * @instance
1520
+ * @memberof PlotBoilerplate
1521
+ * @return {void}
1522
+ **/
1523
+ PlotBoilerplate.prototype.selectVerticesInPolygon = function (polygon) {
1524
+ for (var i in this.vertices) {
1525
+ if (this.vertices[i].attr.selectable && polygon.containsVert(this.vertices[i]))
1526
+ this.vertices[i].attr.isSelected = true;
1527
+ }
1528
+ };
1529
+ /**
1530
+ * (Helper) Locates the point (index) at the passed position. Using an internal tolerance of 7 pixels.
1531
+ *
1532
+ * The result is an object { type : 'bpath', pindex, cindex, pid }
1533
+ *
1534
+ * Returns false if no point is near the passed position.
1535
+ *
1536
+ * @method locatePointNear
1537
+ * @param {Vertex} point - The polygonal selection area.
1538
+ * @param {number=} [tolerance=7] - The tolerance to use identtifying vertices.
1539
+ * @private
1540
+ * @return {IDraggable} Or false if none found.
1541
+ **/
1542
+ PlotBoilerplate.prototype.locatePointNear = function (point, tolerance) {
1543
+ var _self = this;
1544
+ if (typeof tolerance == "undefined")
1545
+ tolerance = 7;
1546
+ // Apply the zoom (the tolerant area should not shrink or grow when zooming)
1547
+ tolerance /= _self.draw.scale.x;
1548
+ // Search in vertices
1549
+ for (var vindex = 0; vindex < _self.vertices.length; vindex++) {
1550
+ var vert = _self.vertices[vindex];
1551
+ if ((vert.attr.draggable || vert.attr.selectable) && vert.distance(point) < tolerance) {
1552
+ // { type : 'vertex', vindex : vindex };
1553
+ return new PlotBoilerplate.Draggable(vert, PlotBoilerplate.Draggable.VERTEX).setVIndex(vindex);
1554
+ }
1555
+ }
1556
+ return null;
1557
+ };
1558
+ /**
1559
+ * Handle left-click event.<br>
1560
+ *
1561
+ * @method handleClick
1562
+ * @param {number} x - The click X position on the canvas.
1563
+ * @param {number} y - The click Y position on the canvas.
1564
+ * @private
1565
+ * @return {void}
1566
+ **/
1567
+ PlotBoilerplate.prototype.handleClick = function (e) {
1568
+ var _self = this;
1569
+ var point = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX || 1.0, _self.config.cssScaleY || 1.0));
1570
+ if (point) {
1571
+ _self.vertices[point.vindex].listeners.fireClickEvent(e);
1572
+ if (this.keyHandler && this.keyHandler.isDown("shift")) {
1573
+ if (point.typeName == "bpath") {
1574
+ var vert = _self.paths[point.pindex].bezierCurves[point.cindex].getPointByID(point.pid);
1575
+ if (vert.attr.selectable)
1576
+ vert.attr.isSelected = !vert.attr.isSelected;
1577
+ }
1578
+ else if (point.typeName == "vertex") {
1579
+ var vert = _self.vertices[point.vindex];
1580
+ if (vert.attr.selectable)
1581
+ vert.attr.isSelected = !vert.attr.isSelected;
1582
+ }
1583
+ _self.redraw();
1584
+ }
1585
+ else if (this.keyHandler && this.keyHandler.isDown("y")) {
1586
+ _self.vertices[point.vindex].attr.bezierAutoAdjust = !_self.vertices[point.vindex].attr.bezierAutoAdjust;
1587
+ _self.redraw();
1588
+ }
1589
+ }
1590
+ else if (_self.selectPolygon != null) {
1591
+ var vert = _self.transformMousePosition(e.params.pos.x, e.params.pos.y);
1592
+ _self.selectPolygon.vertices.push(new Vertex_1.Vertex(vert.x, vert.y));
1593
+ _self.redraw();
1594
+ }
1595
+ };
1596
+ /**
1597
+ * Transforms the given x-y-(mouse-)point to coordinates respecting the view offset
1598
+ * and the zoom settings.
1599
+ *
1600
+ * @method transformMousePosition
1601
+ * @param {number} x - The x position relative to the canvas.
1602
+ * @param {number} y - The y position relative to the canvas.
1603
+ * @instance
1604
+ * @memberof PlotBoilerplate
1605
+ * @return {XYCoords} A simple object <pre>{ x : Number, y : Number }</pre> with the transformed coordinates.
1606
+ **/
1607
+ PlotBoilerplate.prototype.transformMousePosition = function (x, y) {
1608
+ return {
1609
+ x: (x / this.config.cssScaleX - this.config.offsetX) / this.config.scaleX,
1610
+ y: (y / this.config.cssScaleY - this.config.offsetY) / this.config.scaleY
1611
+ };
1612
+ };
1613
+ /**
1614
+ * Revert a transformed mouse position back to canvas coordinates.
1615
+ *
1616
+ * This is the inverse function of `transformMousePosition`.
1617
+ *
1618
+ * @method revertMousePosition
1619
+ * @param {number} x - The x component of the position to revert.
1620
+ * @param {number} y - The y component of the position to revert.
1621
+ * @instance
1622
+ * @memberof PlotBoilerplate
1623
+ * @return {XYCoords} The canvas coordinates for the given position.
1624
+ **/
1625
+ PlotBoilerplate.prototype.revertMousePosition = function (x, y) {
1626
+ return { x: x / this.config.cssScaleX + this.config.offsetX, y: y / this.config.cssScaleY + this.config.offsetY };
1627
+ };
1628
+ /**
1629
+ * Determine if any elements are currently being dragged (on mouse move or touch move).
1630
+ *
1631
+ * @method getDraggedElementCount
1632
+ * @instance
1633
+ * @memberof PlotBoilerplate
1634
+ * @return {number} The number of elements that are currently being dragged.
1635
+ **/
1636
+ PlotBoilerplate.prototype.getDraggedElementCount = function () {
1637
+ return this.draggedElements.length;
1638
+ };
1639
+ /**
1640
+ * (Helper) The mouse-down handler.
1641
+ *
1642
+ * It selects vertices for dragging.
1643
+ *
1644
+ * @method mouseDownHandler.
1645
+ * @param {XMouseEvent} e - The event to handle
1646
+ * @private
1647
+ * @return {void}
1648
+ **/
1649
+ PlotBoilerplate.prototype.mouseDownHandler = function (e) {
1650
+ var _self = this;
1651
+ if (e.button != 0)
1652
+ return; // Only react on left mouse or touch events
1653
+ var draggablePoint = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
1654
+ if (!draggablePoint)
1655
+ return;
1656
+ // Drag all selected elements?
1657
+ if (draggablePoint.typeName == "vertex" && _self.vertices[draggablePoint.vindex].attr.isSelected) {
1658
+ // Multi drag
1659
+ // for( var i in _self.vertices ) {
1660
+ for (var i = 0; i < _self.vertices.length; i++) {
1661
+ if (_self.vertices[i].attr.isSelected) {
1662
+ _self.draggedElements.push(new PlotBoilerplate.Draggable(_self.vertices[i], PlotBoilerplate.Draggable.VERTEX).setVIndex(i));
1663
+ _self.vertices[i].listeners.fireDragStartEvent(e);
1664
+ }
1665
+ }
1666
+ }
1667
+ else {
1668
+ // Single drag
1669
+ if (!_self.vertices[draggablePoint.vindex].attr.draggable)
1670
+ return;
1671
+ _self.draggedElements.push(draggablePoint);
1672
+ if (draggablePoint.typeName == "bpath")
1673
+ _self.paths[draggablePoint.pindex].bezierCurves[draggablePoint.cindex]
1674
+ .getPointByID(draggablePoint.pid)
1675
+ .listeners.fireDragStartEvent(e);
1676
+ else if (draggablePoint.typeName == "vertex")
1677
+ _self.vertices[draggablePoint.vindex].listeners.fireDragStartEvent(e);
1678
+ }
1679
+ _self.redraw();
1680
+ };
1681
+ /**
1682
+ * The mouse-drag handler.
1683
+ *
1684
+ * It moves selected elements around or performs the panning if the ctrl-key if
1685
+ * hold down.
1686
+ *
1687
+ * @method mouseDragHandler.
1688
+ * @param {XMouseEvent} e - The event to handle
1689
+ * @private
1690
+ * @return {void}
1691
+ **/
1692
+ PlotBoilerplate.prototype.mouseDragHandler = function (e) {
1693
+ var _self = this;
1694
+ var oldDragAmount = { x: e.params.dragAmount.x, y: e.params.dragAmount.y };
1695
+ e.params.dragAmount.x /= _self.config.cssScaleX;
1696
+ e.params.dragAmount.y /= _self.config.cssScaleY;
1697
+ // Important note to: this.keyHandler.isDown('ctrl')
1698
+ // We should not use this for any input.
1699
+ // Reason: most browsers use [Ctrl]+[t] to create new browser tabs.
1700
+ // If so, the key-up event for [Ctrl] will be fired in the _new tab_,
1701
+ // not this one. So this tab will never receive any [Ctrl-down] events
1702
+ // until next keypress; the implication is, that [Ctrl] would still
1703
+ // considered to be pressed which is not true.
1704
+ if (this.keyHandler && (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar"))) {
1705
+ if (!this.config.enablePan) {
1706
+ return;
1707
+ }
1708
+ _self.setOffset(_self.draw.offset.clone().add(e.params.dragAmount));
1709
+ _self.redraw();
1710
+ }
1711
+ else {
1712
+ // Convert drag amount by scaling
1713
+ // Warning: this possibly invalidates the dragEvent for other listeners!
1714
+ // Rethink the solution when other features are added.
1715
+ e.params.dragAmount.x /= _self.draw.scale.x;
1716
+ e.params.dragAmount.y /= _self.draw.scale.y;
1717
+ for (var i in _self.draggedElements) {
1718
+ var p = _self.draggedElements[i];
1719
+ if (p.typeName == "bpath") {
1720
+ _self.paths[p.pindex].moveCurvePoint(p.cindex, p.pid, new Vertex_1.Vertex(e.params.dragAmount.x, e.params.dragAmount.y));
1721
+ _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEvent(e);
1722
+ }
1723
+ else if (p.typeName == "vertex") {
1724
+ if (!_self.vertices[p.vindex].attr.draggable)
1725
+ continue;
1726
+ _self.vertices[p.vindex].add(e.params.dragAmount);
1727
+ _self.vertices[p.vindex].listeners.fireDragEvent(e);
1728
+ }
1729
+ }
1730
+ }
1731
+ // Restore old event values!
1732
+ e.params.dragAmount.x = oldDragAmount.x;
1733
+ e.params.dragAmount.y = oldDragAmount.y;
1734
+ _self.redraw();
1735
+ };
1736
+ /**
1737
+ * The mouse-up handler.
1738
+ *
1739
+ * It clears the dragging-selection.
1740
+ *
1741
+ * @method mouseUpHandler.
1742
+ * @param {XMouseEvent} e - The event to handle
1743
+ * @private
1744
+ * @return {void}
1745
+ **/
1746
+ PlotBoilerplate.prototype.mouseUpHandler = function (e) {
1747
+ var _self = this;
1748
+ if (e.button != 0)
1749
+ return; // Only react on left mouse;
1750
+ if (!e.params.wasDragged) {
1751
+ _self.handleClick(e); // e.params.pos.x, e.params.pos.y );
1752
+ }
1753
+ for (var i in _self.draggedElements) {
1754
+ var p = _self.draggedElements[i];
1755
+ if (p.typeName == "bpath") {
1756
+ _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEndEvent(e);
1757
+ }
1758
+ else if (p.typeName == "vertex") {
1759
+ _self.vertices[p.vindex].listeners.fireDragEndEvent(e);
1760
+ }
1761
+ }
1762
+ _self.draggedElements = [];
1763
+ _self.redraw();
1764
+ };
1765
+ /**
1766
+ * The mouse-wheel handler.
1767
+ *
1768
+ * It performs the zooming.
1769
+ *
1770
+ * @method mouseWheelHandler.
1771
+ * @param {XMouseEvent} e - The event to handle
1772
+ * @private
1773
+ * @return {void}
1774
+ **/
1775
+ PlotBoilerplate.prototype.mouseWheelHandler = function (e) {
1776
+ if (!this.config.enableZoom) {
1777
+ return;
1778
+ }
1779
+ var zoomStep = 1.25; // Make configurable?
1780
+ // CHANGED replaced _self by this
1781
+ var _self = this;
1782
+ var we = e;
1783
+ if (we.deltaY < 0) {
1784
+ _self.setZoom(_self.config.scaleX * zoomStep, _self.config.scaleY * zoomStep, new Vertex_1.Vertex(e.params.pos.x, e.params.pos.y));
1785
+ }
1786
+ else if (we.deltaY > 0) {
1787
+ _self.setZoom(_self.config.scaleX / zoomStep, _self.config.scaleY / zoomStep, new Vertex_1.Vertex(e.params.pos.x, e.params.pos.y));
1788
+ }
1789
+ e.preventDefault();
1790
+ _self.redraw();
1791
+ };
1792
+ /**
1793
+ * Re-adjust the configured offset depending on the current canvas size and zoom (scaleX and scaleY).
1794
+ *
1795
+ * @method adjustOffset
1796
+ * @param {boolean=false} redraw - [optional] If set the canvas will redraw with the new offset (default=false).
1797
+ * @return {void}
1798
+ **/
1799
+ PlotBoilerplate.prototype.adjustOffset = function (redraw) {
1800
+ this.draw.offset.x =
1801
+ this.fill.offset.x =
1802
+ this.config.offsetX =
1803
+ this.canvasSize.width * (this.config.offsetAdjustXPercent / 100);
1804
+ this.draw.offset.y =
1805
+ this.fill.offset.y =
1806
+ this.config.offsetY =
1807
+ this.canvasSize.height * (this.config.offsetAdjustYPercent / 100);
1808
+ if (redraw) {
1809
+ this.redraw();
1810
+ }
1811
+ };
1812
+ /**
1813
+ * Set the new draw offset.
1814
+ *
1815
+ * Note: the function will not trigger any redraws.
1816
+ *
1817
+ * @param {Vertex} newOffset - The new draw offset to use.
1818
+ **/
1819
+ PlotBoilerplate.prototype.setOffset = function (newOffset) {
1820
+ this.draw.offset.set(newOffset);
1821
+ this.fill.offset.set(newOffset);
1822
+ this.config.offsetX = newOffset.x;
1823
+ this.config.offsetY = newOffset.y;
1824
+ };
1825
+ /**
1826
+ * Set a new zoom value (and re-adjust the draw offset).
1827
+ *
1828
+ * Note: the function will not trigger any redraws.
1829
+ *
1830
+ * @param {number} zoomFactorX - The new horizontal zoom value.
1831
+ * @param {number} zoomFactorY - The new vertical zoom value.
1832
+ * @param {Vertex} interactionPos - The position of mouse/touch interaction.
1833
+ **/
1834
+ PlotBoilerplate.prototype.setZoom = function (zoomFactorX, zoomFactorY, interactionPos) {
1835
+ var oldPos = this.transformMousePosition(interactionPos.x, interactionPos.y);
1836
+ this.draw.scale.x = this.fill.scale.x = this.config.scaleX = Math.max(zoomFactorX, 0.01);
1837
+ this.draw.scale.y = this.fill.scale.y = this.config.scaleY = Math.max(zoomFactorY, 0.01);
1838
+ var newPos = this.transformMousePosition(interactionPos.x, interactionPos.y);
1839
+ var newOffsetX = this.draw.offset.x + (newPos.x - oldPos.x) * this.draw.scale.x;
1840
+ var newOffsetY = this.draw.offset.y + (newPos.y - oldPos.y) * this.draw.scale.y;
1841
+ this.setOffset({ x: newOffsetX, y: newOffsetY });
1842
+ };
1843
+ PlotBoilerplate.prototype.installInputListeners = function () {
1844
+ var _this = this;
1845
+ var _self = this;
1846
+ if (this.config.enableMouse) {
1847
+ // Install a mouse handler on the canvas.
1848
+ new MouseHandler_1.MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas)
1849
+ .down(function (e) {
1850
+ _self.mouseDownHandler(e);
1851
+ })
1852
+ .drag(function (e) {
1853
+ _self.mouseDragHandler(e);
1854
+ })
1855
+ .up(function (e) {
1856
+ _self.mouseUpHandler(e);
1857
+ });
1858
+ }
1859
+ else {
1860
+ _self.console.log("Mouse interaction disabled.");
1861
+ }
1862
+ if (this.config.enableMouseWheel) {
1863
+ // Install a mouse handler on the canvas.
1864
+ new MouseHandler_1.MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas).wheel(function (e) {
1865
+ _self.mouseWheelHandler(e);
1866
+ });
1867
+ }
1868
+ else {
1869
+ _self.console.log("Mouse wheel interaction disabled.");
1870
+ }
1871
+ if (this.config.enableTouch) {
1872
+ // Install a touch handler on the canvas.
1873
+ var relPos_1 = function (pos) {
1874
+ var bounds = _self.canvas.getBoundingClientRect();
1875
+ return { x: pos.x - bounds.left, y: pos.y - bounds.top };
1876
+ };
1877
+ // Make PB work together with both, AlloyFinger as a esm module or a commonjs function.
1878
+ if (typeof globalThis["AlloyFinger"] === "function" ||
1879
+ typeof globalThis["createAlloyFinger"] === "function") {
1880
+ try {
1881
+ var touchMovePos = null;
1882
+ var touchDownPos = null;
1883
+ var draggedElement = null;
1884
+ var multiTouchStartScale = null;
1885
+ var clearTouch_1 = function () {
1886
+ touchMovePos = null;
1887
+ touchDownPos = null;
1888
+ draggedElement = null;
1889
+ multiTouchStartScale = null;
1890
+ _self.draggedElements = [];
1891
+ };
1892
+ var afProps = {
1893
+ // touchStart: (evt: TouchEvent) => {
1894
+ touchStart: function (evt) {
1895
+ if (evt.touches.length == 1) {
1896
+ touchMovePos = new Vertex_1.Vertex(relPos_1({ x: evt.touches[0].clientX, y: evt.touches[0].clientY }));
1897
+ touchDownPos = new Vertex_1.Vertex(relPos_1({ x: evt.touches[0].clientX, y: evt.touches[0].clientY }));
1898
+ draggedElement = _self.locatePointNear(_self.transformMousePosition(touchMovePos.x, touchMovePos.y), PlotBoilerplate.DEFAULT_TOUCH_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
1899
+ if (draggedElement && draggedElement.typeName == "vertex") {
1900
+ var draggingVertex = _self.vertices[draggedElement.vindex];
1901
+ var fakeEvent = {
1902
+ params: {
1903
+ isTouchEvent: true,
1904
+ dragAmount: { x: 0, y: 0 },
1905
+ wasDragged: false,
1906
+ mouseDownPos: touchDownPos.clone(),
1907
+ mouseDragPos: touchDownPos.clone(),
1908
+ vertex: draggingVertex
1909
+ }
1910
+ };
1911
+ _self.draggedElements = [draggedElement];
1912
+ draggingVertex.listeners.fireDragStartEvent(fakeEvent);
1913
+ }
1914
+ }
1915
+ },
1916
+ touchMove: function (evt) {
1917
+ if (evt.touches.length == 1 && draggedElement) {
1918
+ evt.preventDefault();
1919
+ evt.stopPropagation();
1920
+ if (!touchDownPos || !touchMovePos) {
1921
+ return;
1922
+ }
1923
+ var rel = relPos_1({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
1924
+ var trans = _self.transformMousePosition(rel.x, rel.y);
1925
+ var diff = new Vertex_1.Vertex(_self.transformMousePosition(touchMovePos.x, touchMovePos.y)).difference(trans);
1926
+ if (draggedElement.typeName == "vertex") {
1927
+ if (!_self.vertices[draggedElement.vindex].attr.draggable)
1928
+ return;
1929
+ _self.vertices[draggedElement.vindex].add(diff);
1930
+ var draggingVertex = _self.vertices[draggedElement.vindex];
1931
+ var fakeEvent = {
1932
+ isTouchEvent: true,
1933
+ params: {
1934
+ dragAmount: diff.clone(),
1935
+ wasDragged: true,
1936
+ mouseDownPos: touchDownPos.clone(),
1937
+ mouseDragPos: touchDownPos.clone().add(diff),
1938
+ vertex: draggingVertex
1939
+ }
1940
+ };
1941
+ draggingVertex.listeners.fireDragEvent(fakeEvent);
1942
+ _self.redraw();
1943
+ }
1944
+ touchMovePos = new Vertex_1.Vertex(rel);
1945
+ }
1946
+ else if (evt.touches.length == 2) {
1947
+ if (!_this.config.enablePan) {
1948
+ return;
1949
+ }
1950
+ // If at least two fingers touch and move, then change the draw offset (panning).
1951
+ evt.preventDefault();
1952
+ evt.stopPropagation();
1953
+ _self.setOffset(_self.draw.offset
1954
+ .clone()
1955
+ .addXY(evt.deltaX, evt.deltaY)); // Apply zoom?
1956
+ _self.redraw();
1957
+ }
1958
+ },
1959
+ touchEnd: function (evt) {
1960
+ // Note: e.touches.length is 0 here
1961
+ if (draggedElement && draggedElement.typeName == "vertex") {
1962
+ if (!touchDownPos) {
1963
+ return;
1964
+ }
1965
+ var draggingVertex = _self.vertices[draggedElement.vindex];
1966
+ var fakeEvent = {
1967
+ isTouchEvent: true,
1968
+ params: {
1969
+ dragAmount: { x: 0, y: 0 },
1970
+ wasDragged: false,
1971
+ mouseDownPos: touchDownPos.clone(),
1972
+ mouseDragPos: touchDownPos.clone(),
1973
+ vertex: draggingVertex
1974
+ }
1975
+ };
1976
+ // Check if vertex was moved
1977
+ if (touchMovePos && touchDownPos && touchDownPos.distance(touchMovePos) < 0.001) {
1978
+ // if( e.touches.length == 1 && diff.x == 0 && diff.y == 0 ) {
1979
+ draggingVertex.listeners.fireClickEvent(fakeEvent);
1980
+ }
1981
+ else {
1982
+ draggingVertex.listeners.fireDragEndEvent(fakeEvent);
1983
+ }
1984
+ }
1985
+ clearTouch_1();
1986
+ },
1987
+ touchCancel: function (evt) {
1988
+ clearTouch_1();
1989
+ },
1990
+ multipointStart: function (evt) {
1991
+ multiTouchStartScale = _self.draw.scale.clone();
1992
+ },
1993
+ multipointEnd: function (evt) {
1994
+ multiTouchStartScale = null;
1995
+ },
1996
+ pinch: function (evt) {
1997
+ if (!_this.config.enableZoom) {
1998
+ return;
1999
+ }
2000
+ var touchItem0 = evt.touches.item(0);
2001
+ var touchItem1 = evt.touches.item(1);
2002
+ if (!evt.touches || !multiTouchStartScale || !touchItem0 || !touchItem1) {
2003
+ return;
2004
+ }
2005
+ // For pinching there must be at least two touch items
2006
+ var fingerA = new Vertex_1.Vertex(touchItem0.clientX, touchItem0.clientY);
2007
+ var fingerB = new Vertex_1.Vertex(touchItem1.clientX, touchItem1.clientY);
2008
+ var center = new Line_1.Line(fingerA, fingerB).vertAt(0.5);
2009
+ _self.setZoom(multiTouchStartScale.x * evt.zoom, multiTouchStartScale.y * evt.zoom, center);
2010
+ _self.redraw();
2011
+ }
2012
+ }; // END afProps
2013
+ if (window["createAlloyFinger"]) {
2014
+ // window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
2015
+ var createAlloyFinger = window["createAlloyFinger"];
2016
+ createAlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
2017
+ }
2018
+ else {
2019
+ /* tslint:disable-next-line */
2020
+ new alloyfinger_typescript_1.default(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
2021
+ }
2022
+ }
2023
+ catch (e) {
2024
+ console.error("Failed to initialize AlloyFinger!");
2025
+ console.error(e);
2026
+ }
2027
+ }
2028
+ else if (globalThis["Touchy"] && typeof globalThis["Touchy"] == "function") {
2029
+ console.error("[Deprecation] Found Touchy which is not supported any more. Please use AlloyFinger instead.");
2030
+ // Convert absolute touch positions to relative DOM element position (relative to canvas)
2031
+ }
2032
+ else {
2033
+ console.warn("Cannot initialize the touch handler. AlloyFinger is missig. Did you include it?");
2034
+ }
2035
+ }
2036
+ else {
2037
+ _self.console.log("Touch interaction disabled.");
2038
+ }
2039
+ if (this.config.enableKeys) {
2040
+ // Install key handler
2041
+ this.keyHandler = new KeyHandler_1.KeyHandler({ trackAll: true })
2042
+ .down("escape", function () {
2043
+ _self.clearSelection(true);
2044
+ })
2045
+ .down("shift", function () {
2046
+ _self.selectPolygon = new Polygon_1.Polygon();
2047
+ _self.redraw();
2048
+ })
2049
+ .up("shift", function () {
2050
+ // Find and select vertices in the drawn area
2051
+ if (_self.selectPolygon == null)
2052
+ return;
2053
+ _self.selectVerticesInPolygon(_self.selectPolygon);
2054
+ _self.selectPolygon = null;
2055
+ _self.redraw();
2056
+ });
2057
+ } // END IF enableKeys?
2058
+ else {
2059
+ _self.console.log("Keyboard interaction disabled.");
2060
+ }
2061
+ };
2062
+ /**
2063
+ * Creates a control GUI (a dat.gui instance) for this
2064
+ * plot boilerplate instance.
2065
+ *
2066
+ * @method createGUI
2067
+ * @instance
2068
+ * @memberof PlotBoilerplate
2069
+ * @return {dat.gui.GUI}
2070
+ **/
2071
+ PlotBoilerplate.prototype.createGUI = function (props) {
2072
+ // This function moved to the helper utils.
2073
+ // We do not want to include the whole dat.GUI package.
2074
+ var utils = globalThis["utils"];
2075
+ // if (globalThis["utils"] && typeof globalThis["utils"].createGUI == "function") {
2076
+ // return (globalThis["utils" as keyof Object] as any as ({createGUI : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI })).createGUI(this, props);
2077
+ if (utils && typeof utils.createGUI === "function") {
2078
+ return (this._gui = utils.createGUI(this, props));
2079
+ }
2080
+ else {
2081
+ throw "Cannot create dat.GUI or lil-gui instance; did you load the ./utils/creategui helper function an the dat.GUI/lil-gui library?";
2082
+ }
2083
+ };
2084
+ /**
2085
+ * Retriebe the GUI once it was created. If the `createGUI` method was not called or failed to create any
2086
+ * GUI then null is returned.
2087
+ * @returns {GUI | null}
2088
+ */
2089
+ PlotBoilerplate.prototype.getGUI = function () {
2090
+ return this._gui;
2091
+ };
2092
+ var _a;
2093
+ /** @constant {number} */
2094
+ PlotBoilerplate.DEFAULT_CANVAS_WIDTH = 1024;
2095
+ /** @constant {number} */
2096
+ PlotBoilerplate.DEFAULT_CANVAS_HEIGHT = 768;
2097
+ /** @constant {number} */
2098
+ PlotBoilerplate.DEFAULT_CLICK_TOLERANCE = 8;
2099
+ /** @constant {number} */
2100
+ PlotBoilerplate.DEFAULT_TOUCH_TOLERANCE = 32;
2101
+ /**
2102
+ * A wrapper class for draggable items (mostly vertices).
2103
+ * @private
2104
+ **/
2105
+ PlotBoilerplate.Draggable = (_a = /** @class */ (function () {
2106
+ function class_1(item, typeName) {
2107
+ this.item = item;
2108
+ this.typeName = typeName;
2109
+ }
2110
+ class_1.prototype.isVertex = function () {
2111
+ return this.typeName == PlotBoilerplate.Draggable.VERTEX;
2112
+ };
2113
+ class_1.prototype.setVIndex = function (vindex) {
2114
+ this.vindex = vindex;
2115
+ return this;
2116
+ };
2117
+ return class_1;
2118
+ }()),
2119
+ __setFunctionName(_a, "Draggable"),
2120
+ _a.VERTEX = "vertex",
2121
+ _a);
2122
+ /**
2123
+ * A set of helper functions.
2124
+ **/
2125
+ PlotBoilerplate.utils = {
2126
+ /**
2127
+ * Merge the elements in the 'extension' object into the 'base' object based on
2128
+ * the keys of 'base'.
2129
+ *
2130
+ * @param {Object} base
2131
+ * @param {Object} extension
2132
+ * @return {Object} base extended by the new attributes.
2133
+ **/
2134
+ safeMergeByKeys: function (base, extension) {
2135
+ for (var k in extension) {
2136
+ if (!extension.hasOwnProperty(k)) {
2137
+ continue;
2138
+ }
2139
+ if (base.hasOwnProperty(k)) {
2140
+ var typ = typeof base[k];
2141
+ var extVal = extension[k];
2142
+ try {
2143
+ if (typ == "boolean") {
2144
+ if (typeof extVal === "string")
2145
+ base[k] = Boolean(!!JSON.parse(extVal));
2146
+ else
2147
+ base[k] = extVal;
2148
+ }
2149
+ else if (typ == "number") {
2150
+ if (typeof extVal === "string")
2151
+ base[k] = Number(JSON.parse(extVal) * 1);
2152
+ else
2153
+ base[k] = extension[k];
2154
+ }
2155
+ else if (typ == "function" && typeof extVal == "function") {
2156
+ base[k] = extension[k];
2157
+ }
2158
+ else {
2159
+ // Probably a sting
2160
+ base[k] = extension[k];
2161
+ }
2162
+ }
2163
+ catch (e) {
2164
+ console.error("error in key ", k, extVal, e);
2165
+ }
2166
+ }
2167
+ else {
2168
+ base[k] = extension[k];
2169
+ }
2170
+ }
2171
+ return base;
2172
+ },
2173
+ /*
2174
+ __safeMergeByKeys: <KeyType extends string | number | symbol, ValueType extends boolean | number | string | Function>(
2175
+ base: Record<KeyType, ValueType>,
2176
+ extension: Record<KeyType, string>
2177
+ ): Record<KeyType, ValueType> => {
2178
+ for (var k in extension) {
2179
+ if (!extension.hasOwnProperty(k)) continue;
2180
+ if (base.hasOwnProperty(k)) {
2181
+ var typ = typeof base[k];
2182
+ try {
2183
+ if (typ == "boolean") base[k] = !!JSON.parse(extension[k]);
2184
+ else if (typ == "number") base[k] = JSON.parse(extension[k]) * 1;
2185
+ else if (typ == "function" && typeof extension[k] == "function") base[k] = extension[k];
2186
+ else base[k] = extension[k];
2187
+ } catch (e) {
2188
+ console.error("error in key ", k, extension[k], e);
2189
+ }
2190
+ } else {
2191
+ base[k] = extension[k];
2192
+ }
2193
+ }
2194
+ return base;
2195
+ },
2196
+ *()
2197
+
2198
+ /**
2199
+ * A helper function to scale elements (usually the canvas) using CSS.
2200
+ *
2201
+ * transform-origin is at (0,0).
2202
+ *
2203
+ * @param {HTMLElement} element - The DOM element to scale.
2204
+ * @param {number} scaleX The - X scale factor.
2205
+ * @param {number} scaleY The - Y scale factor.
2206
+ * @return {void}
2207
+ **/
2208
+ setCSSscale: function (element, scaleX, scaleY) {
2209
+ // element.style["transform-origin"] = "0 0";
2210
+ element.style.transformOrigin = "0 0";
2211
+ if (scaleX == 1.0 && scaleY == 1.0) {
2212
+ // element.style.transform = null;
2213
+ element.style.removeProperty("transform");
2214
+ }
2215
+ else
2216
+ element.style.transform = "scale(" + scaleX + "," + scaleY + ")";
2217
+ },
2218
+ // A helper for fetching data from objects.
2219
+ fetch: {
2220
+ /**
2221
+ * A helper function to the the object property value specified by the given key.
2222
+ *
2223
+ * @param {any} object - The object to get the property's value from. Must not be null.
2224
+ * @param {string} key - The key of the object property (the name).
2225
+ * @param {any} fallback - A default value if the key does not exist.
2226
+ **/
2227
+ val: function (obj, key, fallback) {
2228
+ if (!obj.hasOwnProperty(key))
2229
+ return fallback;
2230
+ if (typeof obj[key] == "undefined")
2231
+ return fallback;
2232
+ return obj[key];
2233
+ },
2234
+ /**
2235
+ * A helper function to the the object property numeric value specified by the given key.
2236
+ *
2237
+ * @param {any} object - The object to get the property's value from. Must not be null.
2238
+ * @param {string} key - The key of the object property (the name).
2239
+ * @param {number} fallback - A default value if the key does not exist.
2240
+ * @return {number}
2241
+ **/
2242
+ num: function (obj, key, fallback) {
2243
+ if (!obj.hasOwnProperty(key))
2244
+ return fallback;
2245
+ if (typeof obj[key] === "number")
2246
+ return obj[key];
2247
+ else {
2248
+ try {
2249
+ return JSON.parse(obj[key]) * 1;
2250
+ }
2251
+ catch (e) {
2252
+ return fallback;
2253
+ }
2254
+ }
2255
+ },
2256
+ /**
2257
+ * A helper function to the the object property boolean value specified by the given key.
2258
+ *
2259
+ * @param {any} object - The object to get the property's value from. Must not be null.
2260
+ * @param {string} key - The key of the object property (the name).
2261
+ * @param {boolean} fallback - A default value if the key does not exist.
2262
+ * @return {boolean}
2263
+ **/
2264
+ bool: function (obj, key, fallback) {
2265
+ if (!obj.hasOwnProperty(key))
2266
+ return fallback;
2267
+ if (typeof obj[key] == "boolean")
2268
+ return obj[key];
2269
+ else {
2270
+ try {
2271
+ return !!JSON.parse(obj[key]);
2272
+ }
2273
+ catch (e) {
2274
+ return fallback;
2275
+ }
2276
+ }
2277
+ },
2278
+ /**
2279
+ * A helper function to the the object property function-value specified by the given key.
2280
+ *
2281
+ * @param {any} object - The object to get the property's value from. Must not be null.
2282
+ * @param {string} key - The key of the object property (the name).
2283
+ * @param {function} fallback - A default value if the key does not exist.
2284
+ * @return {function}
2285
+ **/
2286
+ func: function (obj, key, fallback) {
2287
+ if (!obj.hasOwnProperty(key))
2288
+ return fallback;
2289
+ if (typeof obj[key] !== "function")
2290
+ return fallback;
2291
+ return obj[key];
2292
+ }
2293
+ }, // END fetch
2294
+ /**
2295
+ * Installs vertex listeners to the path's vertices so that controlpoints
2296
+ * move with their path points when dragged.
2297
+ *
2298
+ * Bézier path points with attr.bezierAutoAdjust==true will have their
2299
+ * two control points audo-updated if moved, too (keep path connections smooth).
2300
+ *
2301
+ * @param {BezierPath} bezierPath - The path to use auto-adjustment for.
2302
+ **/
2303
+ enableBezierPathAutoAdjust: function (bezierPath) {
2304
+ for (var i = 0; i < bezierPath.bezierCurves.length; i++) {
2305
+ // This should be wrapped into the BezierPath implementation.
2306
+ bezierPath.bezierCurves[i].startPoint.listeners.addDragListener(function (e) {
2307
+ var cindex = bezierPath.locateCurveByStartPoint(e.params.vertex);
2308
+ bezierPath.bezierCurves[cindex].startPoint.addXY(-e.params.dragAmount.x, -e.params.dragAmount.y);
2309
+ bezierPath.moveCurvePoint(cindex * 1, bezierPath.START_POINT, e.params.dragAmount);
2310
+ bezierPath.updateArcLengths();
2311
+ });
2312
+ bezierPath.bezierCurves[i].startControlPoint.listeners.addDragListener(function (e) {
2313
+ var cindex = bezierPath.locateCurveByStartControlPoint(e.params.vertex);
2314
+ if (!bezierPath.bezierCurves[cindex].startPoint.attr.bezierAutoAdjust)
2315
+ return;
2316
+ bezierPath.adjustPredecessorControlPoint(cindex * 1, true, // obtain handle length?
2317
+ false // update arc lengths
2318
+ );
2319
+ bezierPath.updateArcLengths();
2320
+ });
2321
+ bezierPath.bezierCurves[i].endControlPoint.listeners.addDragListener(function (e) {
2322
+ var cindex = bezierPath.locateCurveByEndControlPoint(e.params.vertex);
2323
+ if (!bezierPath.bezierCurves[cindex % bezierPath.bezierCurves.length].endPoint.attr.bezierAutoAdjust)
2324
+ return;
2325
+ bezierPath.adjustSuccessorControlPoint(cindex * 1, true, // obtain handle length?
2326
+ false // update arc lengths
2327
+ );
2328
+ bezierPath.updateArcLengths();
2329
+ });
2330
+ if (i + 1 == bezierPath.bezierCurves.length) {
2331
+ // && !bezierPath.adjustCircular ) {
2332
+ // Move last control point with the end point (if not circular)
2333
+ bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint.listeners.addDragListener(function (e) {
2334
+ if (!bezierPath.adjustCircular) {
2335
+ var cindex = bezierPath.locateCurveByEndPoint(e.params.vertex);
2336
+ bezierPath.moveCurvePoint(cindex * 1, bezierPath.END_CONTROL_POINT, new Vertex_1.Vertex({ x: e.params.dragAmount.x, y: e.params.dragAmount.y }));
2337
+ }
2338
+ bezierPath.updateArcLengths();
2339
+ });
2340
+ }
2341
+ } // END for
2342
+ }
2343
+ }; // END utils
2344
+ return PlotBoilerplate;
2345
+ }()); // END class PlotBoilerplate
2346
+ exports.PlotBoilerplate = PlotBoilerplate;
2347
+ exports.default = PlotBoilerplate;
2348
+ //# sourceMappingURL=PlotBoilerplate.js.map