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