plotboilerplate 1.22.0 → 1.23.1

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 (315) hide show
  1. package/README.md +2 -0
  2. package/dist/index.esm.js +240 -79
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +510 -340
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +7 -4
  11. package/src/cjs/BezierPath.js.map +1 -1
  12. package/src/cjs/Bounds.js +1 -1
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/Circle.js.map +1 -1
  15. package/src/cjs/CircleSector.d.ts +64 -1
  16. package/src/cjs/CircleSector.js +121 -1
  17. package/src/cjs/CircleSector.js.map +1 -1
  18. package/src/cjs/CubicBezierCurve.js +2 -2
  19. package/src/cjs/CubicBezierCurve.js.map +1 -1
  20. package/src/cjs/Grid.js.map +1 -1
  21. package/src/cjs/KeyHandler.d.ts +1 -1
  22. package/src/cjs/KeyHandler.js +13 -13
  23. package/src/cjs/KeyHandler.js.map +1 -1
  24. package/src/cjs/Line.js +2 -0
  25. package/src/cjs/Line.js.map +1 -1
  26. package/src/cjs/MouseHandler.d.ts +2 -2
  27. package/src/cjs/MouseHandler.js +7 -5
  28. package/src/cjs/MouseHandler.js.map +1 -1
  29. package/src/cjs/PlotBoilerplate.d.ts +17 -4
  30. package/src/cjs/PlotBoilerplate.js +95 -66
  31. package/src/cjs/PlotBoilerplate.js.map +1 -1
  32. package/src/cjs/Polygon.js.map +1 -1
  33. package/src/cjs/Triangle.js +1 -1
  34. package/src/cjs/Triangle.js.map +1 -1
  35. package/src/cjs/UIDGenerator.js +1 -1
  36. package/src/cjs/UIDGenerator.js.map +1 -1
  37. package/src/cjs/VEllipse.js.map +1 -1
  38. package/src/cjs/VEllipseSector.js +1 -1
  39. package/src/cjs/VEllipseSector.js.map +1 -1
  40. package/src/cjs/Vector.js +2 -0
  41. package/src/cjs/Vector.js.map +1 -1
  42. package/src/cjs/VertTuple.js.map +1 -1
  43. package/src/cjs/Vertex.d.ts +3 -2
  44. package/src/cjs/Vertex.js +13 -7
  45. package/src/cjs/Vertex.js.map +1 -1
  46. package/src/cjs/VertexAttr.d.ts +2 -1
  47. package/src/cjs/VertexAttr.js +2 -1
  48. package/src/cjs/VertexAttr.js.map +1 -1
  49. package/src/cjs/VertexListeners.d.ts +1 -1
  50. package/src/cjs/VertexListeners.js.map +1 -1
  51. package/src/cjs/draw.js +1 -1
  52. package/src/cjs/draw.js.map +1 -1
  53. package/src/cjs/drawgl.js.map +1 -1
  54. package/src/cjs/drawutilssvg.d.ts +17 -3
  55. package/src/cjs/drawutilssvg.js +97 -91
  56. package/src/cjs/drawutilssvg.js.map +1 -1
  57. package/src/cjs/geomutils.js +2 -2
  58. package/src/cjs/geomutils.js.map +1 -1
  59. package/src/cjs/index.js +5 -1
  60. package/src/cjs/index.js.map +1 -1
  61. package/src/cjs/interfaces/DrawLib.d.ts +2 -2
  62. package/src/cjs/interfaces/core.d.ts +3 -3
  63. package/src/cjs/interfaces/externals.d.ts +12 -0
  64. package/src/cjs/interfaces/index.js +5 -1
  65. package/src/cjs/interfaces/index.js.map +1 -1
  66. package/src/cjs/utils/InitializationObserver.d.ts +18 -0
  67. package/src/cjs/utils/InitializationObserver.js +56 -0
  68. package/src/cjs/utils/InitializationObserver.js.map +1 -0
  69. package/src/cjs/utils/NGons.d.ts +13 -0
  70. package/src/cjs/utils/NGons.js +36 -0
  71. package/src/cjs/utils/NGons.js.map +1 -0
  72. package/src/cjs/utils/Params.js.map +1 -1
  73. package/src/cjs/utils/WebColors.js.map +1 -1
  74. package/src/cjs/utils/WebColorsContrast.js +1 -1
  75. package/src/cjs/utils/WebColorsContrast.js.map +1 -1
  76. package/src/cjs/utils/algorithms/CatmullRomPath.js.map +1 -1
  77. package/src/cjs/utils/algorithms/CircleIntersections.d.ts +3 -2
  78. package/src/cjs/utils/algorithms/CircleIntersections.js +12 -20
  79. package/src/cjs/utils/algorithms/CircleIntersections.js.map +1 -1
  80. package/src/cjs/utils/algorithms/ContourLineDetection.js +5 -5
  81. package/src/cjs/utils/algorithms/ContourLineDetection.js.map +1 -1
  82. package/src/cjs/utils/algorithms/CubicSplinePath.js.map +1 -1
  83. package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
  84. package/src/cjs/utils/algorithms/Metaballs.d.ts +30 -0
  85. package/src/cjs/utils/algorithms/Metaballs.js +114 -0
  86. package/src/cjs/utils/algorithms/Metaballs.js.map +1 -0
  87. package/src/cjs/utils/algorithms/arrayResize.d.ts +8 -0
  88. package/src/cjs/utils/algorithms/arrayResize.js +24 -0
  89. package/src/cjs/utils/algorithms/arrayResize.js.map +1 -0
  90. package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  91. package/src/cjs/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
  92. package/src/cjs/utils/algorithms/convexHull.js.map +1 -1
  93. package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
  94. package/src/cjs/utils/algorithms/delaunay.js.map +1 -1
  95. package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
  96. package/src/cjs/utils/algorithms/detectPaths.js.map +1 -1
  97. package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  98. package/src/cjs/utils/algorithms/matrixFill.js +1 -1
  99. package/src/cjs/utils/algorithms/matrixFill.js.map +1 -1
  100. package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  101. package/src/cjs/utils/algorithms/sutherlandHodgman.js.map +1 -1
  102. package/src/cjs/utils/cloneVertexArray.js.map +1 -1
  103. package/src/cjs/utils/creategui.js +320 -244
  104. package/src/cjs/utils/dat.gui.arrowbounce.polyfill.js +74 -73
  105. package/src/cjs/utils/dat.gui.title.polyfill.js +9 -7
  106. package/src/cjs/utils/datastructures/CircularIntervalSet.js.map +1 -1
  107. package/src/cjs/utils/datastructures/Color.d.ts +2 -1
  108. package/src/cjs/utils/datastructures/Color.js +35 -16
  109. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  110. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +1 -1
  111. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
  112. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +1 -1
  113. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  114. package/src/cjs/utils/datastructures/GenericPath.js.map +1 -1
  115. package/src/cjs/utils/datastructures/Girih.d.ts +3 -2
  116. package/src/cjs/utils/datastructures/Girih.js +2 -1
  117. package/src/cjs/utils/datastructures/Girih.js.map +1 -1
  118. package/src/cjs/utils/datastructures/GirihBowtie.js +2 -0
  119. package/src/cjs/utils/datastructures/GirihBowtie.js.map +1 -1
  120. package/src/cjs/utils/datastructures/GirihDecagon.js +2 -0
  121. package/src/cjs/utils/datastructures/GirihDecagon.js.map +1 -1
  122. package/src/cjs/utils/datastructures/GirihHexagon.js +2 -0
  123. package/src/cjs/utils/datastructures/GirihHexagon.js.map +1 -1
  124. package/src/cjs/utils/datastructures/GirihPenroseRhombus.js +3 -1
  125. package/src/cjs/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
  126. package/src/cjs/utils/datastructures/GirihPentagon.js +2 -0
  127. package/src/cjs/utils/datastructures/GirihPentagon.js.map +1 -1
  128. package/src/cjs/utils/datastructures/GirihRhombus.js +2 -0
  129. package/src/cjs/utils/datastructures/GirihRhombus.js.map +1 -1
  130. package/src/cjs/utils/datastructures/GirihTile.js +4 -2
  131. package/src/cjs/utils/datastructures/GirihTile.js.map +1 -1
  132. package/src/cjs/utils/datastructures/Matrix4x4.js.map +1 -1
  133. package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
  134. package/src/cjs/utils/datastructures/interfaces.d.ts +3 -3
  135. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  136. package/src/cjs/utils/dom/getAvailableContainerSpace.js +1 -1
  137. package/src/cjs/utils/dom/getAvailableContainerSpace.js.map +1 -1
  138. package/src/cjs/utils/dom/guiSizeToggler.d.ts +17 -0
  139. package/src/cjs/utils/dom/guiSizeToggler.js +42 -0
  140. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -0
  141. package/src/cjs/utils/findInVertexArray.js.map +1 -1
  142. package/src/cjs/utils/gup.d.ts +8 -0
  143. package/src/cjs/utils/gup.js +8 -0
  144. package/src/cjs/utils/gup.js.map +1 -1
  145. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
  146. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +3 -2
  147. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  148. package/src/cjs/utils/helpers/CircleHelper.d.ts +38 -3
  149. package/src/cjs/utils/helpers/CircleHelper.js +51 -11
  150. package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
  151. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +47 -1
  152. package/src/cjs/utils/helpers/CircleSectorHelper.js +85 -14
  153. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  154. package/src/cjs/utils/io/FileDrop.d.ts +3 -3
  155. package/src/cjs/utils/io/FileDrop.js.map +1 -1
  156. package/src/cjs/utils/lil.gui.arrowbounce.polyfill.js +133 -0
  157. package/src/cjs/utils/lil.gui.title.polyfill.js +32 -0
  158. package/src/cjs/utils/parsers/OBJParser.d.ts +2 -2
  159. package/src/cjs/utils/parsers/OBJParser.js.map +1 -1
  160. package/src/cjs/utils/parsers/STLParser.d.ts +4 -3
  161. package/src/cjs/utils/parsers/STLParser.js +62 -12
  162. package/src/cjs/utils/parsers/STLParser.js.map +1 -1
  163. package/src/cjs/utils/parsers/svg/parseSVGPathData.js +1 -1
  164. package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -1
  165. package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -1
  166. package/src/cjs/utils/parsers/svg/types.d.ts +13 -13
  167. package/src/createDemoDrawables.js +48 -3
  168. package/src/esm/BezierPath.js.map +1 -1
  169. package/src/esm/Bounds.js.map +1 -1
  170. package/src/esm/Circle.js.map +1 -1
  171. package/src/esm/CircleSector.d.ts +64 -1
  172. package/src/esm/CircleSector.js +121 -1
  173. package/src/esm/CircleSector.js.map +1 -1
  174. package/src/esm/CubicBezierCurve.js.map +1 -1
  175. package/src/esm/Grid.js.map +1 -1
  176. package/src/esm/KeyHandler.d.ts +1 -1
  177. package/src/esm/KeyHandler.js +13 -13
  178. package/src/esm/KeyHandler.js.map +1 -1
  179. package/src/esm/Line.js.map +1 -1
  180. package/src/esm/MouseHandler.d.ts +2 -2
  181. package/src/esm/MouseHandler.js +4 -4
  182. package/src/esm/MouseHandler.js.map +1 -1
  183. package/src/esm/PlotBoilerplate.d.ts +17 -4
  184. package/src/esm/PlotBoilerplate.js +61 -32
  185. package/src/esm/PlotBoilerplate.js.map +1 -1
  186. package/src/esm/Polygon.js.map +1 -1
  187. package/src/esm/Triangle.js.map +1 -1
  188. package/src/esm/VEllipse.js.map +1 -1
  189. package/src/esm/VEllipseSector.js +1 -1
  190. package/src/esm/VEllipseSector.js.map +1 -1
  191. package/src/esm/Vector.js.map +1 -1
  192. package/src/esm/VertTuple.js.map +1 -1
  193. package/src/esm/Vertex.d.ts +3 -2
  194. package/src/esm/Vertex.js +9 -3
  195. package/src/esm/Vertex.js.map +1 -1
  196. package/src/esm/VertexAttr.d.ts +2 -1
  197. package/src/esm/VertexAttr.js +2 -1
  198. package/src/esm/VertexAttr.js.map +1 -1
  199. package/src/esm/VertexListeners.d.ts +1 -1
  200. package/src/esm/VertexListeners.js.map +1 -1
  201. package/src/esm/draw.js.map +1 -1
  202. package/src/esm/drawgl.js.map +1 -1
  203. package/src/esm/drawutilssvg.d.ts +17 -3
  204. package/src/esm/drawutilssvg.js +28 -22
  205. package/src/esm/drawutilssvg.js.map +1 -1
  206. package/src/esm/geomutils.js +2 -2
  207. package/src/esm/geomutils.js.map +1 -1
  208. package/src/esm/interfaces/DrawLib.d.ts +2 -2
  209. package/src/esm/interfaces/core.d.ts +3 -3
  210. package/src/esm/interfaces/externals.d.ts +12 -0
  211. package/src/esm/utils/InitializationObserver.d.ts +18 -0
  212. package/src/esm/utils/InitializationObserver.js +50 -0
  213. package/src/esm/utils/InitializationObserver.js.map +1 -0
  214. package/src/esm/utils/NGons.d.ts +13 -0
  215. package/src/esm/utils/NGons.js +33 -0
  216. package/src/esm/utils/NGons.js.map +1 -0
  217. package/src/esm/utils/Params.js.map +1 -1
  218. package/src/esm/utils/WebColors.js.map +1 -1
  219. package/src/esm/utils/algorithms/CatmullRomPath.js.map +1 -1
  220. package/src/esm/utils/algorithms/CircleIntersections.d.ts +3 -2
  221. package/src/esm/utils/algorithms/CircleIntersections.js +11 -19
  222. package/src/esm/utils/algorithms/CircleIntersections.js.map +1 -1
  223. package/src/esm/utils/algorithms/ContourLineDetection.js.map +1 -1
  224. package/src/esm/utils/algorithms/CubicSplinePath.js.map +1 -1
  225. package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
  226. package/src/esm/utils/algorithms/Metaballs.d.ts +30 -0
  227. package/src/esm/utils/algorithms/Metaballs.js +109 -0
  228. package/src/esm/utils/algorithms/Metaballs.js.map +1 -0
  229. package/src/esm/utils/algorithms/arrayResize.d.ts +8 -0
  230. package/src/esm/utils/algorithms/arrayResize.js +20 -0
  231. package/src/esm/utils/algorithms/arrayResize.js.map +1 -0
  232. package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -1
  233. package/src/esm/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
  234. package/src/esm/utils/algorithms/convexHull.js.map +1 -1
  235. package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
  236. package/src/esm/utils/algorithms/delaunay.js.map +1 -1
  237. package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
  238. package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
  239. package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
  240. package/src/esm/utils/algorithms/matrixFill.js.map +1 -1
  241. package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
  242. package/src/esm/utils/algorithms/sutherlandHodgman.js.map +1 -1
  243. package/src/esm/utils/cloneVertexArray.js.map +1 -1
  244. package/src/esm/utils/datastructures/CircularIntervalSet.js.map +1 -1
  245. package/src/esm/utils/datastructures/Color.d.ts +2 -1
  246. package/src/esm/utils/datastructures/Color.js +33 -14
  247. package/src/esm/utils/datastructures/Color.js.map +1 -1
  248. package/src/esm/utils/datastructures/DataGrid2d.d.ts +1 -1
  249. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
  250. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  251. package/src/esm/utils/datastructures/GenericPath.js.map +1 -1
  252. package/src/esm/utils/datastructures/Girih.d.ts +3 -2
  253. package/src/esm/utils/datastructures/Girih.js +2 -1
  254. package/src/esm/utils/datastructures/Girih.js.map +1 -1
  255. package/src/esm/utils/datastructures/GirihBowtie.js.map +1 -1
  256. package/src/esm/utils/datastructures/GirihDecagon.js.map +1 -1
  257. package/src/esm/utils/datastructures/GirihHexagon.js.map +1 -1
  258. package/src/esm/utils/datastructures/GirihPenroseRhombus.js +1 -1
  259. package/src/esm/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
  260. package/src/esm/utils/datastructures/GirihPentagon.js.map +1 -1
  261. package/src/esm/utils/datastructures/GirihRhombus.js.map +1 -1
  262. package/src/esm/utils/datastructures/GirihTile.js.map +1 -1
  263. package/src/esm/utils/datastructures/Matrix4x4.js.map +1 -1
  264. package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
  265. package/src/esm/utils/datastructures/interfaces.d.ts +3 -3
  266. package/src/esm/utils/detectDarkMode.js.map +1 -1
  267. package/src/esm/utils/dom/guiSizeToggler.d.ts +17 -0
  268. package/src/esm/utils/dom/guiSizeToggler.js +38 -0
  269. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -0
  270. package/src/esm/utils/findInVertexArray.js.map +1 -1
  271. package/src/esm/utils/gup.d.ts +8 -0
  272. package/src/esm/utils/gup.js +8 -0
  273. package/src/esm/utils/gup.js.map +1 -1
  274. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
  275. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +3 -2
  276. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  277. package/src/esm/utils/helpers/CircleHelper.d.ts +38 -3
  278. package/src/esm/utils/helpers/CircleHelper.js +51 -11
  279. package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
  280. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +47 -1
  281. package/src/esm/utils/helpers/CircleSectorHelper.js +85 -14
  282. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  283. package/src/esm/utils/io/FileDrop.d.ts +3 -3
  284. package/src/esm/utils/io/FileDrop.js.map +1 -1
  285. package/src/esm/utils/parsers/OBJParser.d.ts +2 -2
  286. package/src/esm/utils/parsers/OBJParser.js.map +1 -1
  287. package/src/esm/utils/parsers/STLParser.d.ts +4 -3
  288. package/src/esm/utils/parsers/STLParser.js +63 -13
  289. package/src/esm/utils/parsers/STLParser.js.map +1 -1
  290. package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -1
  291. package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -1
  292. package/src/esm/utils/parsers/svg/types.d.ts +13 -13
  293. package/src/index-gl.js +77 -85
  294. package/src/index.js +124 -129
  295. package/src/ts/CircleSector.ts +134 -3
  296. package/src/ts/PlotBoilerplate.ts +51 -14
  297. package/src/ts/Vertex.ts +8 -3
  298. package/src/ts/VertexAttr.ts +3 -2
  299. package/src/ts/drawutilssvg.ts +38 -25
  300. package/src/ts/geomutils.ts +60 -64
  301. package/src/ts/interfaces/DrawLib.ts +0 -15
  302. package/src/ts/interfaces/externals.ts +16 -0
  303. package/src/ts/utils/InitializationObserver.ts +63 -0
  304. package/src/ts/utils/NGons.ts +35 -0
  305. package/src/ts/utils/algorithms/CircleIntersections.ts +280 -288
  306. package/src/ts/utils/algorithms/Metaballs.ts +144 -0
  307. package/src/ts/utils/algorithms/arrayResize.ts +22 -0
  308. package/src/ts/utils/datastructures/Color.ts +39 -15
  309. package/src/ts/utils/datastructures/Girih.ts +9 -8
  310. package/src/ts/utils/dom/guiSizeToggler.ts +45 -0
  311. package/src/ts/utils/gup.ts +10 -2
  312. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +9 -8
  313. package/src/ts/utils/helpers/CircleHelper.ts +70 -22
  314. package/src/ts/utils/helpers/CircleSectorHelper.ts +101 -17
  315. package/src/ts/utils/parsers/STLParser.ts +50 -16
@@ -8,7 +8,8 @@
8
8
  * @date 2020-03-30
9
9
  * @modified 2020-04-03 Added empty default global object 'utils'. Added createGUI as an optional child.
10
10
  * @modified 2023-09-29 Added try-catch for color attributes; invalid values might break construction of whole gui.
11
- * @version 1.0.2
11
+ * @modified 2024-06-25 Replacing dat.gui by equivalent lil-gui calls. Collapsing all lil-gui folders (are open by default).
12
+ * @version 1.1.0
12
13
  **/
13
14
  var utils = (globalThis.utils = globalThis.utils || {});
14
15
 
@@ -31,260 +32,335 @@ globalThis.utils.guiFolders = globalThis.utils.guiFolders || {};
31
32
  * @method createGUI
32
33
  * @memberof utils
33
34
  * @param {PlotBoilerplate} pb
34
- * @param {DatGuiProps} props
35
- * @return {dat.gui.GUI}
35
+ * @param {DatGuiProps|LilGuiProps} props
36
+ * @return {dat.gui.GUI|lil-gui.GUI|null}
36
37
  **/
37
- globalThis.utils.createGUI = function (pb, props) {
38
- var dummy = {
39
- resetOffset: function () {
40
- var viewport = pb.viewport();
41
- pb.setOffset({ x: (viewport.width / 2.0) * pb.draw.scale.x, y: (viewport.height / 2.0) * pb.draw.scale.y });
42
- pb.redraw();
43
- },
44
- resetScale: function () {
45
- pb.setZoom(1.0, 1.0, new Vertex(0, 0));
46
- pb.redraw();
38
+ globalThis.utils.createGUI = (function () {
39
+ var _tryGetGUIInstance = function (props) {
40
+ if (
41
+ globalThis.hasOwnProperty("lil") &&
42
+ typeof globalThis["lil"] == "object" &&
43
+ globalThis["lil"].hasOwnProperty("GUI") &&
44
+ typeof globalThis["lil"]["GUI"] == "function"
45
+ ) {
46
+ // console.log("Creating lil");
47
+ return new lil.GUI(props);
48
+ } else if (
49
+ globalThis.hasOwnProperty("dat") &&
50
+ typeof globalThis["dat"] == "object" &&
51
+ globalThis["dat"].hasOwnProperty("gui") &&
52
+ typeof globalThis["dat"]["gui"] == "object"
53
+ ) {
54
+ // console.log("Creating dat.gui");
55
+ return new dat.gui.GUI(props);
56
+ } else {
57
+ console.warn("Warning: cannot create GUI. Nor dat.gui not lil-gui seem present.");
58
+ return null;
47
59
  }
48
60
  };
49
61
 
50
- var _self = pb;
51
- var gui = new dat.gui.GUI(props);
52
- gui.remember(pb.config);
53
- var fold0 = gui.addFolder("Editor settings");
54
- var fold00 = fold0.addFolder("Canvas size");
55
- fold00
56
- .add(pb.config, "fullSize")
57
- .onChange(function () {
58
- _self.resizeCanvas();
59
- })
60
- .title("Toggles the fullpage mode.")
61
- .listen();
62
- fold00
63
- .add(pb.config, "fitToParent")
64
- .onChange(function () {
65
- _self.resizeCanvas();
66
- })
67
- .title("Toggles the fit-to-parent mode to fit to parent container (overrides fullsize).")
68
- .listen();
69
- fold00
70
- .add(pb.config, "defaultCanvasWidth")
71
- .min(1)
72
- .step(10)
73
- .onChange(function () {
74
- _self.resizeCanvas();
75
- })
76
- .title("Specifies the fallback width.");
77
- fold00
78
- .add(pb.config, "defaultCanvasHeight")
79
- .min(1)
80
- .step(10)
81
- .onChange(function () {
82
- _self.resizeCanvas();
83
- })
84
- .title("Specifies the fallback height.");
85
- fold00
86
- .add(pb.config, "canvasWidthFactor")
87
- .min(0.1)
88
- .step(0.1)
89
- .max(10)
90
- .onChange(function () {
91
- _self.resizeCanvas();
92
- })
93
- .title("Specifies a factor for the current width.")
94
- .listen();
95
- fold00
96
- .add(pb.config, "canvasHeightFactor")
97
- .min(0.1)
98
- .step(0.1)
99
- .max(10)
100
- .onChange(function () {
101
- _self.resizeCanvas();
102
- })
103
- .title("Specifies a factor for the current height.")
104
- .listen();
105
- fold00
106
- .add(pb.config, "cssScaleX")
107
- .min(0.01)
108
- .step(0.01)
109
- .max(1.0)
110
- .onChange(function () {
111
- if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
112
- _self.updateCSSscale();
113
- })
114
- .title("Specifies the visual x scale (CSS).")
115
- .listen();
116
- fold00
117
- .add(pb.config, "cssScaleY")
118
- .min(0.01)
119
- .step(0.01)
120
- .max(1.0)
121
- .onChange(function () {
122
- if (_self.config.cssUniformScale) _self.config.cssScaleX = _self.config.cssScaleY;
123
- _self.updateCSSscale();
124
- })
125
- .title("Specifies the visual y scale (CSS).")
126
- .listen();
127
- fold00
128
- .add(pb.config, "cssUniformScale")
129
- .onChange(function () {
130
- if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
131
- _self.updateCSSscale();
132
- })
133
- .title("CSS uniform scale (x-scale equlsa y-scale).");
134
- fold00.add(pb.config, "setToRetina").name("Set to highres fullsize").title("Set canvas to high-res retina resoultion (x2).");
62
+ var _tryDetectMobileDevice = function () {
63
+ return globalThis.hasOwnProperty("isMobileDevice") && typeof globalThis["isMobileDevice"] == "function" && isMobileDevice();
64
+ };
65
+
66
+ var _tryGetGUISizeToggler = function (gui, dummyConfig) {
67
+ if (!gui) {
68
+ return null;
69
+ }
70
+ if (globalThis.hasOwnProperty("guiSizeToggler") && typeof globalThis["guiSizeToggler"] == "function") {
71
+ return guiSizeToggler(gui, dummyConfig, { transformOrigin: "top right" });
72
+ } else {
73
+ console.warn("Warning: cannot create GUI's double size checkbox. guiSizeToggler is not present.");
74
+ return null;
75
+ }
76
+ };
77
+
78
+ var createGuiFun = function (pb, props) {
79
+ var dummy = {
80
+ resetOffset: function () {
81
+ var viewport = pb.viewport();
82
+ pb.setOffset({ x: (viewport.width / 2.0) * pb.draw.scale.x, y: (viewport.height / 2.0) * pb.draw.scale.y });
83
+ pb.redraw();
84
+ },
85
+ resetScale: function () {
86
+ pb.setZoom(1.0, 1.0, new Vertex(0, 0));
87
+ pb.redraw();
88
+ },
89
+ guiDoubleSize: false
90
+ };
91
+
92
+ // Try to initialise dat.gui (old demos) or lil-gui (new demos). They have the ~same~ signature.
93
+ var gui = _tryGetGUIInstance(props);
94
+ var mobileDevice = _tryDetectMobileDevice();
95
+ var guiSize = _tryGetGUISizeToggler(gui, dummy);
96
+ if (mobileDevice && guiSize) {
97
+ dummy.guiDoubleSize = true;
98
+ guiSize.update();
99
+ }
100
+
101
+ var _self = pb;
102
+ if (guiSize) {
103
+ gui
104
+ .add(dummy, "guiDoubleSize")
105
+ .name("doubleGUISize")
106
+ .onChange(function () {
107
+ guiSize.update();
108
+ });
109
+ }
110
+ var fold0 = gui.addFolder("Editor settings");
111
+ fold0.close(); // important only for lil-gui
112
+ var fold00 = fold0.addFolder("Canvas size");
113
+ fold00.close(); // important only for lil-gui
135
114
 
136
- var fold01 = fold0.addFolder("Draw settings");
137
- fold01
138
- .add(pb.drawConfig, "drawBezierHandlePoints")
139
- .onChange(function () {
140
- _self.redraw();
141
- })
142
- .title("Draw Bézier handle points.");
143
- fold01
144
- .add(pb.drawConfig, "drawBezierHandleLines")
145
- .onChange(function () {
146
- _self.redraw();
147
- })
148
- .title("Draw Bézier handle lines.");
149
- fold01
150
- .add(pb.drawConfig, "drawHandlePoints")
151
- .onChange(function () {
152
- _self.redraw();
153
- })
154
- .title("Draw handle points (overrides all other settings).");
155
- fold01
156
- .add(pb.drawConfig, "drawHandleLines")
157
- .onChange(function () {
158
- _self.redraw();
159
- })
160
- .title("Draw handle lines in general (overrides all other settings).");
161
- fold01
162
- .add(pb.drawConfig, "drawVertices")
163
- .onChange(function () {
164
- _self.redraw();
165
- })
166
- .title("Draw vertices in general.");
115
+ fold00
116
+ .add(pb.config, "fullSize")
117
+ .onChange(function () {
118
+ _self.resizeCanvas();
119
+ })
120
+ .title("Toggles the fullpage mode.")
121
+ .listen();
122
+ fold00
123
+ .add(pb.config, "fitToParent")
124
+ .onChange(function () {
125
+ _self.resizeCanvas();
126
+ })
127
+ .title("Toggles the fit-to-parent mode to fit to parent container (overrides fullsize).")
128
+ .listen();
129
+ fold00
130
+ .add(pb.config, "defaultCanvasWidth")
131
+ .min(1)
132
+ .step(10)
133
+ .onChange(function () {
134
+ _self.resizeCanvas();
135
+ })
136
+ .title("Specifies the fallback width.");
137
+ fold00
138
+ .add(pb.config, "defaultCanvasHeight")
139
+ .min(1)
140
+ .step(10)
141
+ .onChange(function () {
142
+ _self.resizeCanvas();
143
+ })
144
+ .title("Specifies the fallback height.");
145
+ fold00
146
+ .add(pb.config, "canvasWidthFactor")
147
+ .min(0.1)
148
+ .step(0.1)
149
+ .max(10)
150
+ .onChange(function () {
151
+ _self.resizeCanvas();
152
+ })
153
+ .title("Specifies a factor for the current width.")
154
+ .listen();
155
+ fold00
156
+ .add(pb.config, "canvasHeightFactor")
157
+ .min(0.1)
158
+ .step(0.1)
159
+ .max(10)
160
+ .onChange(function () {
161
+ _self.resizeCanvas();
162
+ })
163
+ .title("Specifies a factor for the current height.")
164
+ .listen();
165
+ fold00
166
+ .add(pb.config, "cssScaleX")
167
+ .min(0.01)
168
+ .step(0.01)
169
+ .max(1.0)
170
+ .onChange(function () {
171
+ if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
172
+ _self.updateCSSscale();
173
+ })
174
+ .title("Specifies the visual x scale (CSS).")
175
+ .listen();
176
+ fold00
177
+ .add(pb.config, "cssScaleY")
178
+ .min(0.01)
179
+ .step(0.01)
180
+ .max(1.0)
181
+ .onChange(function () {
182
+ if (_self.config.cssUniformScale) _self.config.cssScaleX = _self.config.cssScaleY;
183
+ _self.updateCSSscale();
184
+ })
185
+ .title("Specifies the visual y scale (CSS).")
186
+ .listen();
187
+ fold00
188
+ .add(pb.config, "cssUniformScale")
189
+ .onChange(function () {
190
+ if (_self.config.cssUniformScale) _self.config.cssScaleY = _self.config.cssScaleX;
191
+ _self.updateCSSscale();
192
+ })
193
+ .title("CSS uniform scale (x-scale equlsa y-scale).");
194
+ fold00.add(pb.config, "setToRetina").name("Set to highres fullsize").title("Set canvas to high-res retina resoultion (x2).");
167
195
 
168
- const fold0100 = fold01.addFolder("Colors and Lines");
169
- const _addDrawConfigElement = function (fold, basePath, conf) {
170
- for (var i in conf) {
171
- if (typeof conf[i] == "object") {
172
- if (conf[i].hasOwnProperty("color")) {
173
- try {
174
- fold
175
- .addColor(conf[i], "color")
176
- .onChange(function () {
177
- _self.redraw();
178
- })
179
- .name(basePath + i + ".color")
180
- .title(basePath + i + ".color")
181
- .listen();
182
- } catch (e) {
183
- console.error("[createGUI] Invalid color value, gui library cannot recognize.", conf[i]["color"]);
196
+ var fold01 = fold0.addFolder("Draw settings");
197
+ fold01.close(); // important only for lil-gui
198
+
199
+ fold01
200
+ .add(pb.drawConfig, "drawBezierHandlePoints")
201
+ .onChange(function () {
202
+ _self.redraw();
203
+ })
204
+ .title("Draw Bézier handle points.");
205
+ fold01
206
+ .add(pb.drawConfig, "drawBezierHandleLines")
207
+ .onChange(function () {
208
+ _self.redraw();
209
+ })
210
+ .title("Draw Bézier handle lines.");
211
+ fold01
212
+ .add(pb.drawConfig, "drawHandlePoints")
213
+ .onChange(function () {
214
+ _self.redraw();
215
+ })
216
+ .title("Draw handle points (overrides all other settings).");
217
+ fold01
218
+ .add(pb.drawConfig, "drawHandleLines")
219
+ .onChange(function () {
220
+ _self.redraw();
221
+ })
222
+ .title("Draw handle lines in general (overrides all other settings).");
223
+ fold01
224
+ .add(pb.drawConfig, "drawVertices")
225
+ .onChange(function () {
226
+ _self.redraw();
227
+ })
228
+ .title("Draw vertices in general.");
229
+
230
+ const fold0100 = fold01.addFolder("Colors and Lines");
231
+ fold0100.close(); // important only for lil-gui
232
+
233
+ const _addDrawConfigElement = function (fold, basePath, conf) {
234
+ for (var i in conf) {
235
+ if (typeof conf[i] == "object") {
236
+ if (conf[i].hasOwnProperty("color")) {
237
+ try {
238
+ fold
239
+ .addColor(conf[i], "color")
240
+ .onChange(function () {
241
+ _self.redraw();
242
+ })
243
+ .name(basePath + i + ".color")
244
+ .title(basePath + i + ".color")
245
+ .listen();
246
+ } catch (e) {
247
+ console.error("[createGUI] Invalid color value, gui library cannot recognize.", conf[i]["color"]);
248
+ }
184
249
  }
185
- }
186
- if (conf[i].hasOwnProperty("lineWidth"))
187
- fold
188
- .add(conf[i], "lineWidth")
189
- .min(1)
190
- .max(10)
191
- .step(1)
192
- .onChange(function () {
193
- _self.redraw();
194
- })
195
- .name(basePath + i + ".lineWidth")
196
- .title(basePath + i + ".lineWidth")
197
- .listen();
198
- for (var e in conf[i]) {
199
- if (conf[i].hasOwnProperty(e) && typeof conf[i][e] == "object") {
200
- // console.log(e);
201
- _addDrawConfigElement(fold, (basePath != "" ? basePath + "." : "") + i + "." + e, conf[i]);
250
+ // console.log("basePath", basePath, i, conf[i], conf[i].hasOwnProperty("lineWidth"));
251
+ if (conf[i].hasOwnProperty("lineWidth")) {
252
+ try {
253
+ // console.log("adding ", basePath, i);
254
+ fold
255
+ .add(conf[i], "lineWidth")
256
+ .min(1)
257
+ .max(10)
258
+ .step(1)
259
+ .onChange(function () {
260
+ _self.redraw();
261
+ })
262
+ .name(basePath + i + ".lineWidth")
263
+ .title(basePath + i + ".lineWidth")
264
+ .listen();
265
+ // console.log("adding 2", basePath, i);
266
+ } catch (e) {
267
+ console.error("[createGUI] Invalid lineWidth value, gui library cannot recognize.", conf[i]["lineWidth"]);
268
+ }
269
+ }
270
+ for (var e in conf[i]) {
271
+ if (conf[i].hasOwnProperty(e) && typeof conf[i][e] == "object") {
272
+ // console.log(e);
273
+ _addDrawConfigElement(fold, (basePath != "" ? basePath + "." : "") + i + "." + e, conf[i]);
274
+ }
202
275
  }
203
276
  }
204
277
  }
205
- }
206
- };
207
- _addDrawConfigElement(fold0100, "", pb.drawConfig);
278
+ };
279
+ _addDrawConfigElement(fold0100, "", pb.drawConfig);
208
280
 
209
- fold0
210
- .add(pb.config, "scaleX")
211
- .title("Scale x.")
212
- .min(0.01)
213
- .max(10.0)
214
- .step(0.01)
215
- .onChange(function () {
216
- _self.draw.scale.x = _self.fill.scale.x = _self.config.scaleX;
217
- _self.redraw();
218
- })
219
- .listen();
220
- fold0
221
- .add(pb.config, "scaleY")
222
- .title("Scale y.")
223
- .min(0.01)
224
- .max(10.0)
225
- .step(0.01)
226
- .onChange(function () {
227
- _self.draw.scale.y = _self.fill.scale.y = _self.config.scaleY;
228
- _self.redraw();
229
- })
230
- .listen();
231
- fold0
232
- .add(pb.config, "offsetX")
233
- .title("Offset x.")
234
- .step(10.0)
235
- .onChange(function () {
236
- _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX;
237
- _self.redraw();
238
- })
239
- .listen();
240
- fold0
241
- .add(pb.config, "offsetY")
242
- .title("Offset y.")
243
- .step(10.0)
244
- .onChange(function () {
245
- _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY;
246
- _self.redraw();
247
- })
248
- .listen();
249
- fold0
250
- .add(pb.config, "drawOrigin")
251
- .title("Draw the origin (0,0).")
252
- .onChange(function () {
253
- _self.redraw();
254
- })
255
- .listen();
256
- fold0
257
- .add(pb.config, "rasterGrid")
258
- .title("Draw a fine raster instead a full grid.")
259
- .onChange(function () {
260
- _self.redraw();
261
- })
262
- .listen();
263
- fold0
264
- .add(pb.config, "drawRaster")
265
- .title("If set to false no raster or grid will be drawn at all.")
266
- .onChange(function () {
267
- _self.redraw();
268
- })
269
- .listen();
270
- fold0.add(pb.config, "redrawOnResize").title("Automatically redraw the data if window or canvas is resized.").listen();
271
- fold0
272
- .addColor(pb.config, "backgroundColor")
273
- .onChange(function () {
274
- _self.redraw();
275
- })
276
- .title("Choose a background color.");
277
- fold0.add(dummy, "resetOffset").title("Reset the draw offset to (0,0).");
278
- fold0.add(dummy, "resetScale").title("Reset the draw scale to (1.,1.).");
281
+ fold0
282
+ .add(pb.config, "scaleX")
283
+ .title("Scale x.")
284
+ .min(0.01)
285
+ .max(10.0)
286
+ .step(0.01)
287
+ .onChange(function () {
288
+ _self.draw.scale.x = _self.fill.scale.x = _self.config.scaleX;
289
+ _self.redraw();
290
+ })
291
+ .listen();
292
+ fold0
293
+ .add(pb.config, "scaleY")
294
+ .title("Scale y.")
295
+ .min(0.01)
296
+ .max(10.0)
297
+ .step(0.01)
298
+ .onChange(function () {
299
+ _self.draw.scale.y = _self.fill.scale.y = _self.config.scaleY;
300
+ _self.redraw();
301
+ })
302
+ .listen();
303
+ fold0
304
+ .add(pb.config, "offsetX")
305
+ .title("Offset x.")
306
+ .step(10.0)
307
+ .onChange(function () {
308
+ _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX;
309
+ _self.redraw();
310
+ })
311
+ .listen();
312
+ fold0
313
+ .add(pb.config, "offsetY")
314
+ .title("Offset y.")
315
+ .step(10.0)
316
+ .onChange(function () {
317
+ _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY;
318
+ _self.redraw();
319
+ })
320
+ .listen();
321
+ fold0
322
+ .add(pb.config, "drawOrigin")
323
+ .title("Draw the origin (0,0).")
324
+ .onChange(function () {
325
+ _self.redraw();
326
+ })
327
+ .listen();
328
+ fold0
329
+ .add(pb.config, "rasterGrid")
330
+ .title("Draw a fine raster instead a full grid.")
331
+ .onChange(function () {
332
+ _self.redraw();
333
+ })
334
+ .listen();
335
+ fold0
336
+ .add(pb.config, "drawRaster")
337
+ .title("If set to false no raster or grid will be drawn at all.")
338
+ .onChange(function () {
339
+ _self.redraw();
340
+ })
341
+ .listen();
342
+ fold0.add(pb.config, "redrawOnResize").title("Automatically redraw the data if window or canvas is resized.").listen();
343
+ fold0
344
+ .addColor(pb.config, "backgroundColor")
345
+ .onChange(function () {
346
+ _self.redraw();
347
+ })
348
+ .title("Choose a background color.");
349
+ fold0.add(dummy, "resetOffset").title("Reset the draw offset to (0,0).");
350
+ fold0.add(dummy, "resetScale").title("Reset the draw scale to (1.,1.).");
279
351
 
280
- if (pb.config.enableSVGExport) {
281
- var foldExport = gui.addFolder("Export");
282
- foldExport.add(pb.config, "saveFile").name("SVG Image").title("Save as SVG.");
283
- globalThis.utils.guiFolders["editor_settings.export"] = foldExport;
284
- }
352
+ if (pb.config.enableSVGExport) {
353
+ var foldExport = gui.addFolder("Export");
354
+ foldExport.close(); // important only for lil-gui
355
+ foldExport.add(pb.config, "saveFile").name("SVG Image").title("Save as SVG.");
356
+ globalThis.utils.guiFolders["editor_settings.export"] = foldExport;
357
+ }
285
358
 
286
- globalThis.utils.guiFolders["editor_settings"] = fold0;
287
- globalThis.utils.guiFolders["draw_settings"] = fold01;
359
+ globalThis.utils.guiFolders["editor_settings"] = fold0;
360
+ globalThis.utils.guiFolders["draw_settings"] = fold01;
361
+
362
+ return gui;
363
+ };
288
364
 
289
- return gui;
290
- }; // END creategui
365
+ return createGuiFun;
366
+ })(); // END creategui