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