plotboilerplate 1.21.0 → 1.23.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/README.md +2 -0
- package/dist/index.esm.js +252 -77
- 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 +522 -338
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +7 -5
- package/src/cjs/BezierPath.js.map +1 -1
- package/src/cjs/Bounds.js +1 -1
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/Circle.js.map +1 -1
- package/src/cjs/CircleSector.d.ts +64 -1
- package/src/cjs/CircleSector.js +121 -1
- package/src/cjs/CircleSector.js.map +1 -1
- package/src/cjs/CubicBezierCurve.js +2 -2
- package/src/cjs/CubicBezierCurve.js.map +1 -1
- package/src/cjs/Grid.js.map +1 -1
- package/src/cjs/KeyHandler.d.ts +1 -1
- package/src/cjs/KeyHandler.js +13 -13
- package/src/cjs/KeyHandler.js.map +1 -1
- package/src/cjs/Line.js +2 -0
- package/src/cjs/Line.js.map +1 -1
- package/src/cjs/MouseHandler.d.ts +2 -2
- package/src/cjs/MouseHandler.js +7 -5
- package/src/cjs/MouseHandler.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +1 -1
- package/src/cjs/PlotBoilerplate.js +77 -63
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/Polygon.d.ts +13 -1
- package/src/cjs/Polygon.js +30 -1
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/Triangle.js +1 -1
- package/src/cjs/Triangle.js.map +1 -1
- package/src/cjs/UIDGenerator.js +1 -1
- package/src/cjs/UIDGenerator.js.map +1 -1
- package/src/cjs/VEllipse.js.map +1 -1
- package/src/cjs/VEllipseSector.js +1 -1
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vector.js +2 -0
- package/src/cjs/Vector.js.map +1 -1
- package/src/cjs/VertTuple.js.map +1 -1
- package/src/cjs/Vertex.d.ts +3 -2
- package/src/cjs/Vertex.js +13 -7
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/VertexAttr.d.ts +2 -1
- package/src/cjs/VertexAttr.js +2 -1
- package/src/cjs/VertexAttr.js.map +1 -1
- package/src/cjs/VertexListeners.d.ts +1 -1
- package/src/cjs/VertexListeners.js.map +1 -1
- package/src/cjs/draw.js +1 -1
- package/src/cjs/draw.js.map +1 -1
- package/src/cjs/drawgl.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +17 -3
- package/src/cjs/drawutilssvg.js +97 -91
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/geomutils.js +2 -2
- package/src/cjs/geomutils.js.map +1 -1
- package/src/cjs/index.js +5 -1
- package/src/cjs/index.js.map +1 -1
- package/src/cjs/interfaces/DrawLib.d.ts +2 -2
- package/src/cjs/interfaces/core.d.ts +3 -3
- package/src/cjs/interfaces/index.js +5 -1
- package/src/cjs/interfaces/index.js.map +1 -1
- 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 +15 -0
- package/src/cjs/utils/Params.js +49 -0
- package/src/cjs/utils/Params.js.map +1 -0
- package/src/cjs/utils/WebColors.js.map +1 -1
- package/src/cjs/utils/WebColorsContrast.js +1 -1
- package/src/cjs/utils/WebColorsContrast.js.map +1 -1
- package/src/cjs/utils/algorithms/CatmullRomPath.js.map +1 -1
- package/src/cjs/utils/algorithms/CircleIntersections.d.ts +3 -2
- package/src/cjs/utils/algorithms/CircleIntersections.js +12 -20
- package/src/cjs/utils/algorithms/CircleIntersections.js.map +1 -1
- 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.js.map +1 -1
- package/src/cjs/utils/algorithms/HobbyPath.js.map +1 -1
- 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/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/clearDuplicateVertices.d.ts +21 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js +48 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -0
- package/src/cjs/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
- package/src/cjs/utils/algorithms/convexHull.js.map +1 -1
- package/src/cjs/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/cjs/utils/algorithms/delaunay.js.map +1 -1
- package/src/cjs/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/cjs/utils/algorithms/detectPaths.js.map +1 -1
- package/src/cjs/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/cjs/utils/algorithms/matrixFill.js +1 -1
- package/src/cjs/utils/algorithms/matrixFill.js.map +1 -1
- package/src/cjs/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/cjs/utils/algorithms/sutherlandHodgman.js.map +1 -1
- package/src/cjs/utils/cloneVertexArray.js.map +1 -1
- package/src/cjs/utils/creategui.js +20 -12
- package/src/cjs/utils/datastructures/CircularIntervalSet.js.map +1 -1
- package/src/cjs/utils/datastructures/Color.d.ts +2 -1
- package/src/cjs/utils/datastructures/Color.js +35 -16
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/datastructures/DataGrid2d.d.ts +47 -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/DataGrid2dListAdapter.d.ts +65 -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 +14 -3
- package/src/cjs/utils/datastructures/GenericPath.js +20 -3
- package/src/cjs/utils/datastructures/GenericPath.js.map +1 -1
- package/src/cjs/utils/datastructures/Girih.d.ts +3 -2
- package/src/cjs/utils/datastructures/Girih.js +2 -1
- package/src/cjs/utils/datastructures/Girih.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihBowtie.js +2 -0
- package/src/cjs/utils/datastructures/GirihBowtie.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihDecagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihDecagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihHexagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihHexagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihPenroseRhombus.js +3 -1
- package/src/cjs/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihPentagon.js +2 -0
- package/src/cjs/utils/datastructures/GirihPentagon.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihRhombus.js +2 -0
- package/src/cjs/utils/datastructures/GirihRhombus.js.map +1 -1
- package/src/cjs/utils/datastructures/GirihTile.js +4 -2
- package/src/cjs/utils/datastructures/GirihTile.js.map +1 -1
- package/src/cjs/utils/datastructures/Matrix4x4.js.map +1 -1
- package/src/cjs/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/cjs/utils/datastructures/interfaces.d.ts +3 -3
- package/src/cjs/utils/detectDarkMode.js.map +1 -1
- package/src/cjs/utils/dom/getAvailableContainerSpace.js +1 -1
- package/src/cjs/utils/dom/getAvailableContainerSpace.js.map +1 -1
- package/src/cjs/utils/findInVertexArray.js.map +1 -1
- package/src/cjs/utils/gup.d.ts +8 -0
- package/src/cjs/utils/gup.js +8 -0
- package/src/cjs/utils/gup.js.map +1 -1
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +3 -2
- package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleHelper.d.ts +38 -3
- package/src/cjs/utils/helpers/CircleHelper.js +51 -11
- package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +47 -1
- package/src/cjs/utils/helpers/CircleSectorHelper.js +85 -14
- package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/cjs/utils/io/FileDrop.d.ts +3 -3
- package/src/cjs/utils/io/FileDrop.js.map +1 -1
- package/src/cjs/utils/parsers/OBJParser.d.ts +2 -2
- package/src/cjs/utils/parsers/OBJParser.js.map +1 -1
- package/src/cjs/utils/parsers/STLParser.d.ts +4 -3
- package/src/cjs/utils/parsers/STLParser.js +62 -12
- package/src/cjs/utils/parsers/STLParser.js.map +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/cjs/utils/parsers/svg/types.d.ts +13 -13
- package/src/createDemoDrawables.js +48 -3
- package/src/esm/BezierPath.js.map +1 -1
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/Circle.js.map +1 -1
- package/src/esm/CircleSector.d.ts +64 -1
- package/src/esm/CircleSector.js +121 -1
- package/src/esm/CircleSector.js.map +1 -1
- package/src/esm/CubicBezierCurve.js.map +1 -1
- package/src/esm/Grid.js.map +1 -1
- package/src/esm/KeyHandler.d.ts +1 -1
- package/src/esm/KeyHandler.js +13 -13
- package/src/esm/KeyHandler.js.map +1 -1
- package/src/esm/Line.js.map +1 -1
- package/src/esm/MouseHandler.d.ts +2 -2
- package/src/esm/MouseHandler.js +4 -4
- package/src/esm/MouseHandler.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +1 -1
- package/src/esm/PlotBoilerplate.js +43 -29
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/Polygon.d.ts +13 -1
- package/src/esm/Polygon.js +30 -1
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/Triangle.js.map +1 -1
- package/src/esm/VEllipse.js.map +1 -1
- package/src/esm/VEllipseSector.js +1 -1
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vector.js.map +1 -1
- package/src/esm/VertTuple.js.map +1 -1
- package/src/esm/Vertex.d.ts +3 -2
- package/src/esm/Vertex.js +9 -3
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/VertexAttr.d.ts +2 -1
- package/src/esm/VertexAttr.js +2 -1
- package/src/esm/VertexAttr.js.map +1 -1
- package/src/esm/VertexListeners.d.ts +1 -1
- package/src/esm/VertexListeners.js.map +1 -1
- package/src/esm/draw.js.map +1 -1
- package/src/esm/drawgl.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +17 -3
- package/src/esm/drawutilssvg.js +28 -22
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/geomutils.js +2 -2
- package/src/esm/geomutils.js.map +1 -1
- package/src/esm/interfaces/DrawLib.d.ts +2 -2
- package/src/esm/interfaces/core.d.ts +3 -3
- package/src/esm/utils/NGons.d.ts +13 -0
- package/src/esm/utils/NGons.js +33 -0
- package/src/esm/utils/NGons.js.map +1 -0
- package/src/esm/utils/Params.d.ts +15 -0
- package/src/esm/utils/Params.js +44 -0
- package/src/esm/utils/Params.js.map +1 -0
- package/src/esm/utils/WebColors.js.map +1 -1
- package/src/esm/utils/algorithms/CatmullRomPath.js.map +1 -1
- package/src/esm/utils/algorithms/CircleIntersections.d.ts +3 -2
- package/src/esm/utils/algorithms/CircleIntersections.js +11 -19
- package/src/esm/utils/algorithms/CircleIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/ContourLineDetection.d.ts +150 -0
- package/src/esm/utils/algorithms/ContourLineDetection.js +362 -0
- package/src/esm/utils/algorithms/ContourLineDetection.js.map +1 -0
- package/src/esm/utils/algorithms/CubicSplinePath.js.map +1 -1
- package/src/esm/utils/algorithms/HobbyPath.js.map +1 -1
- package/src/esm/utils/algorithms/Metaballs.d.ts +30 -0
- package/src/esm/utils/algorithms/Metaballs.js +109 -0
- package/src/esm/utils/algorithms/Metaballs.js.map +1 -0
- package/src/esm/utils/algorithms/arrayResize.d.ts +8 -0
- package/src/esm/utils/algorithms/arrayResize.js +20 -0
- package/src/esm/utils/algorithms/arrayResize.js.map +1 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +21 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.js +44 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -0
- package/src/esm/utils/algorithms/clearPolygonDuplicateVertices.js.map +1 -1
- package/src/esm/utils/algorithms/convexHull.js.map +1 -1
- package/src/esm/utils/algorithms/convexPolygonIncircle.js.map +1 -1
- package/src/esm/utils/algorithms/delaunay.js.map +1 -1
- package/src/esm/utils/algorithms/delaunay2voronoi.js.map +1 -1
- package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
- package/src/esm/utils/algorithms/findPolygonSelfIntersections.js.map +1 -1
- package/src/esm/utils/algorithms/matrixFill.js.map +1 -1
- package/src/esm/utils/algorithms/splitPolygonToNonIntersecting.js.map +1 -1
- package/src/esm/utils/algorithms/sutherlandHodgman.js.map +1 -1
- package/src/esm/utils/cloneVertexArray.js.map +1 -1
- package/src/esm/utils/datastructures/CircularIntervalSet.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +2 -1
- package/src/esm/utils/datastructures/Color.js +33 -14
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/datastructures/DataGrid2d.d.ts +47 -0
- package/src/esm/utils/datastructures/DataGrid2d.js +19 -0
- package/src/esm/utils/datastructures/DataGrid2d.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +65 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +79 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
- package/src/esm/utils/datastructures/GenericPath.d.ts +14 -3
- package/src/esm/utils/datastructures/GenericPath.js +20 -3
- package/src/esm/utils/datastructures/GenericPath.js.map +1 -1
- package/src/esm/utils/datastructures/Girih.d.ts +3 -2
- package/src/esm/utils/datastructures/Girih.js +2 -1
- package/src/esm/utils/datastructures/Girih.js.map +1 -1
- package/src/esm/utils/datastructures/GirihBowtie.js.map +1 -1
- package/src/esm/utils/datastructures/GirihDecagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihHexagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihPenroseRhombus.js +1 -1
- package/src/esm/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
- package/src/esm/utils/datastructures/GirihPentagon.js.map +1 -1
- package/src/esm/utils/datastructures/GirihRhombus.js.map +1 -1
- package/src/esm/utils/datastructures/GirihTile.js.map +1 -1
- package/src/esm/utils/datastructures/Matrix4x4.js.map +1 -1
- package/src/esm/utils/datastructures/VoronoiCell.js.map +1 -1
- package/src/esm/utils/datastructures/interfaces.d.ts +3 -3
- package/src/esm/utils/detectDarkMode.js.map +1 -1
- package/src/esm/utils/findInVertexArray.js.map +1 -1
- package/src/esm/utils/gup.d.ts +8 -0
- package/src/esm/utils/gup.js +8 -0
- package/src/esm/utils/gup.js.map +1 -1
- package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +6 -5
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js +3 -2
- package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleHelper.d.ts +38 -3
- package/src/esm/utils/helpers/CircleHelper.js +51 -11
- package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
- package/src/esm/utils/helpers/CircleSectorHelper.d.ts +47 -1
- package/src/esm/utils/helpers/CircleSectorHelper.js +85 -14
- package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
- package/src/esm/utils/io/FileDrop.d.ts +3 -3
- package/src/esm/utils/io/FileDrop.js.map +1 -1
- package/src/esm/utils/parsers/OBJParser.d.ts +2 -2
- package/src/esm/utils/parsers/OBJParser.js.map +1 -1
- package/src/esm/utils/parsers/STLParser.d.ts +4 -3
- package/src/esm/utils/parsers/STLParser.js +63 -13
- package/src/esm/utils/parsers/STLParser.js.map +1 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -1
- package/src/esm/utils/parsers/svg/types.d.ts +13 -13
- package/src/index-gl.js +77 -85
- package/src/index.js +124 -129
- package/src/ts/CircleSector.ts +134 -3
- package/src/ts/PlotBoilerplate.ts +20 -11
- package/src/ts/Polygon.ts +31 -1
- package/src/ts/Vertex.ts +8 -3
- package/src/ts/VertexAttr.ts +3 -2
- package/src/ts/drawutilssvg.ts +38 -25
- package/src/ts/geomutils.ts +60 -64
- package/src/ts/interfaces/DrawLib.ts +0 -15
- package/src/ts/utils/NGons.ts +35 -0
- package/src/ts/utils/Params.ts +47 -0
- package/src/ts/utils/algorithms/CircleIntersections.ts +280 -288
- package/src/ts/utils/algorithms/ContourLineDetection.ts +485 -0
- package/src/ts/utils/algorithms/Metaballs.ts +144 -0
- package/src/ts/utils/algorithms/arrayResize.ts +22 -0
- package/src/ts/utils/algorithms/clearDuplicateVertices.ts +49 -0
- package/src/ts/utils/datastructures/Color.ts +39 -15
- package/src/ts/utils/datastructures/DataGrid2d.ts +54 -0
- package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +121 -0
- package/src/ts/utils/datastructures/GenericPath.ts +21 -3
- package/src/ts/utils/datastructures/Girih.ts +9 -8
- package/src/ts/utils/gup.ts +10 -2
- package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +9 -8
- package/src/ts/utils/helpers/CircleHelper.ts +70 -22
- package/src/ts/utils/helpers/CircleSectorHelper.ts +101 -17
- package/src/ts/utils/parsers/STLParser.ts +50 -16
package/dist/index.esm.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* @modified 2019-03-20 Added JSDoc tags.
|
|
7
7
|
* @modified 2020-02-29 Added the 'selectable' attribute.
|
|
8
8
|
* @modified 2020-03-23 Ported to Typescript from JS.
|
|
9
|
-
* @
|
|
9
|
+
* @modified 2024-03-10 Fixed some types for Typescript 5 compatibility.
|
|
10
|
+
* @version 1.1.2
|
|
10
11
|
*
|
|
11
12
|
* @file VertexAttr
|
|
12
13
|
* @public
|
|
@@ -360,7 +361,8 @@ class VertexListeners {
|
|
|
360
361
|
* @modified 2022-11-28 Added the `subXY`, `subX` and `subY` methods to the `Vertex` class.
|
|
361
362
|
* @modified 2023-09-29 Downgraded types for the `Vertex.utils.buildArrowHead` function (replacing Vertex params by more generic XYCoords type).
|
|
362
363
|
* @modified 2023-09-29 Added the `Vertex.abs()` method as it seems useful.
|
|
363
|
-
* @
|
|
364
|
+
* @modified 2024-03-08 Added the optional `precision` param to the `toString` method.
|
|
365
|
+
* @version 2.9.0
|
|
364
366
|
*
|
|
365
367
|
* @file Vertex
|
|
366
368
|
* @public
|
|
@@ -897,8 +899,13 @@ class Vertex {
|
|
|
897
899
|
* @instance
|
|
898
900
|
* @memberof Vertex
|
|
899
901
|
**/
|
|
900
|
-
toString() {
|
|
901
|
-
|
|
902
|
+
toString(precision) {
|
|
903
|
+
if (typeof precision === "undefined") {
|
|
904
|
+
return "(" + this.x + "," + this.y + ")";
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
return "(" + this.x.toFixed(precision) + "," + this.y.toFixed(precision) + ")";
|
|
908
|
+
}
|
|
902
909
|
}
|
|
903
910
|
/**
|
|
904
911
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
@@ -1444,7 +1451,8 @@ class Line extends VertTuple {
|
|
|
1444
1451
|
* @modified 2023-09-25 Added the `Polygon.getInterpolationPolygon(number)` function.
|
|
1445
1452
|
* @modified 2023-09-25 Added the `Polygon.lineIntersections(Line,boolean)` function.
|
|
1446
1453
|
* @modified 2023-09-29 Added the `Polygon.closestLineIntersection(Line,boolean)` function.
|
|
1447
|
-
* @
|
|
1454
|
+
* @modified 2023-11-24 Added the `Polygon.containsPolygon(Polygon)' function.
|
|
1455
|
+
* @version 1.12.0
|
|
1448
1456
|
*
|
|
1449
1457
|
* @file Polygon
|
|
1450
1458
|
* @public
|
|
@@ -1553,6 +1561,34 @@ class Polygon {
|
|
|
1553
1561
|
}
|
|
1554
1562
|
return inside;
|
|
1555
1563
|
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Check if the passed polygon is completly contained inside this polygon.
|
|
1566
|
+
*
|
|
1567
|
+
* This means:
|
|
1568
|
+
* - all polygon's vertices must be inside this polygon.
|
|
1569
|
+
* - the polygon has no edge intersections with this polygon.
|
|
1570
|
+
*
|
|
1571
|
+
* @param {Polygon} polygon - The polygon to check if contained.
|
|
1572
|
+
* @return {boolean}
|
|
1573
|
+
*/
|
|
1574
|
+
containsPolygon(polygon) {
|
|
1575
|
+
for (var i = 0; i < polygon.vertices.length; i++) {
|
|
1576
|
+
if (!this.containsVert(polygon.vertices[i])) {
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
// All vertices are inside; check for intersections
|
|
1581
|
+
const lineSegment = new Line(new Vertex(), new Vertex());
|
|
1582
|
+
for (var i = 0; i < polygon.vertices.length; i++) {
|
|
1583
|
+
lineSegment.a.set(polygon.vertices[i]);
|
|
1584
|
+
lineSegment.b.set(polygon.vertices[(i + 1) % polygon.vertices.length]);
|
|
1585
|
+
if (this.lineIntersections(lineSegment, true).length > 0) {
|
|
1586
|
+
// Current segment has intersection(s) with this polygon.
|
|
1587
|
+
return false;
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
return true;
|
|
1591
|
+
}
|
|
1556
1592
|
/**
|
|
1557
1593
|
* Calculate the area of the given polygon (unsigned).
|
|
1558
1594
|
*
|
|
@@ -4411,7 +4447,12 @@ Circle.circleUtils = {
|
|
|
4411
4447
|
* @date 2020-12-17
|
|
4412
4448
|
* @modified 2021-01-20 Added UID.
|
|
4413
4449
|
* @modified 2021-02-26 Fixed an error in the svg-arc-calculation (case angle<90deg and anti-clockwise).
|
|
4414
|
-
* @
|
|
4450
|
+
* @modified 2024-01-30 Added a missing type in the `describeSVGArc` function.
|
|
4451
|
+
* @modified 2024-03-01 Added the `getStartPoint` and `getEndPoint` methods.
|
|
4452
|
+
* @modified 2024-03-08 Added the `containsAngle` method.
|
|
4453
|
+
* @modified 2024-03-09 Added the `circleSectorIntersection` method to find coherent sector intersections..
|
|
4454
|
+
* @modified 2024-03-09 Added the `angleAt` method to determine any angle at some ratio.
|
|
4455
|
+
* @version 1.2.0
|
|
4415
4456
|
**/
|
|
4416
4457
|
/**
|
|
4417
4458
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
@@ -4442,10 +4483,124 @@ class CircleSector {
|
|
|
4442
4483
|
this.startAngle = startAngle;
|
|
4443
4484
|
this.endAngle = endAngle;
|
|
4444
4485
|
}
|
|
4486
|
+
/**
|
|
4487
|
+
* Checks wether the given angle (must be inside 0 and PI*2) is contained inside this sector.
|
|
4488
|
+
*
|
|
4489
|
+
* @param {number} angle - The numeric angle to check.
|
|
4490
|
+
* @method containsAngle
|
|
4491
|
+
* @instance
|
|
4492
|
+
* @memberof CircleSector
|
|
4493
|
+
* @return {boolean} True if (and only if) this sector contains the given angle.
|
|
4494
|
+
*/
|
|
4495
|
+
containsAngle(angle) {
|
|
4496
|
+
if (this.startAngle <= this.endAngle) {
|
|
4497
|
+
return angle >= this.startAngle && angle < this.endAngle;
|
|
4498
|
+
}
|
|
4499
|
+
else {
|
|
4500
|
+
// startAngle > endAngle
|
|
4501
|
+
return angle >= this.startAngle || angle < this.endAngle;
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
/**
|
|
4505
|
+
* Get the angle inside this sector for a given ratio. 0.0 means startAngle, and 1.0 means endAngle.
|
|
4506
|
+
*
|
|
4507
|
+
* @param {number} t - The ratio inside [0..1].
|
|
4508
|
+
* @method angleAt
|
|
4509
|
+
* @instance
|
|
4510
|
+
* @memberof CircleSector
|
|
4511
|
+
* @return {number} The angle inside this sector at a given ratio.
|
|
4512
|
+
*/
|
|
4513
|
+
angleAt(t) {
|
|
4514
|
+
if (this.startAngle <= this.endAngle) {
|
|
4515
|
+
const angleAtRatio = this.startAngle + (this.endAngle - this.startAngle) * t;
|
|
4516
|
+
return angleAtRatio % (Math.PI * 2.0);
|
|
4517
|
+
}
|
|
4518
|
+
else {
|
|
4519
|
+
// startAngle > endAngle
|
|
4520
|
+
const angleAtRatio = this.startAngle + (Math.PI * 2 - this.startAngle + this.endAngle) * t;
|
|
4521
|
+
return angleAtRatio % (Math.PI * 2.0);
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
/**
|
|
4525
|
+
* Get the sectors starting point (on the underlying circle, located at the start angle).
|
|
4526
|
+
*
|
|
4527
|
+
* @method getStartPoint
|
|
4528
|
+
* @instance
|
|
4529
|
+
* @memberof CircleSector
|
|
4530
|
+
* @return {Vertex} The sector's stating point.
|
|
4531
|
+
*/
|
|
4532
|
+
getStartPoint() {
|
|
4533
|
+
return this.circle.vertAt(this.startAngle);
|
|
4534
|
+
}
|
|
4535
|
+
/**
|
|
4536
|
+
* Get the sectors ending point (on the underlying circle, located at the end angle).
|
|
4537
|
+
*
|
|
4538
|
+
* @method getEndPoint
|
|
4539
|
+
* @instance
|
|
4540
|
+
* @memberof CircleSector
|
|
4541
|
+
* @return {Vertex} The sector's ending point.
|
|
4542
|
+
*/
|
|
4543
|
+
getEndPoint() {
|
|
4544
|
+
return this.circle.vertAt(this.endAngle);
|
|
4545
|
+
}
|
|
4546
|
+
/**
|
|
4547
|
+
* Calculate the intersection of this circle sector and some other sector.
|
|
4548
|
+
*
|
|
4549
|
+
* If the two sectors do not corerently intersect (when not both points of the
|
|
4550
|
+
* radical line are containted in both source sectors) then null is returned.
|
|
4551
|
+
*
|
|
4552
|
+
* See demo/53-circle-sector-intersections for a geometric visualisation.
|
|
4553
|
+
*
|
|
4554
|
+
* @method circleSectorIntersection
|
|
4555
|
+
* @instance
|
|
4556
|
+
* @memberof CircleSector
|
|
4557
|
+
* @return {CircleSector | null} The intersecion of both sectors or null if they don't intersect.
|
|
4558
|
+
*/
|
|
4559
|
+
circleSectorIntersection(sector) {
|
|
4560
|
+
const radicalLine = this.circle.circleIntersection(sector.circle);
|
|
4561
|
+
if (!radicalLine) {
|
|
4562
|
+
// The circles to not intersect at all.
|
|
4563
|
+
return null;
|
|
4564
|
+
}
|
|
4565
|
+
// Circles intersect. Check if this sector interval intersects, too.
|
|
4566
|
+
const thisIntersectionAngleA = this.circle.center.angle(radicalLine.a);
|
|
4567
|
+
const thisIntersectionAngleB = this.circle.center.angle(radicalLine.b);
|
|
4568
|
+
// Is intersection inside this sector?
|
|
4569
|
+
if (!this.containsAngle(thisIntersectionAngleA) || !this.containsAngle(thisIntersectionAngleB)) {
|
|
4570
|
+
// At least one circle intersection point is not located in this sector.
|
|
4571
|
+
// -> no valid intersection at all
|
|
4572
|
+
return null;
|
|
4573
|
+
}
|
|
4574
|
+
// Circles intersect. Check if the passed sector interval intersects, too.
|
|
4575
|
+
const thatIntersectionAngleA = sector.circle.center.angle(radicalLine.a);
|
|
4576
|
+
const thatIntersectionAngleB = sector.circle.center.angle(radicalLine.b);
|
|
4577
|
+
// Is intersection inside this sector?
|
|
4578
|
+
if (!sector.containsAngle(thatIntersectionAngleA) || !sector.containsAngle(thatIntersectionAngleB)) {
|
|
4579
|
+
// At least one circle intersection point is not located in this sector.
|
|
4580
|
+
// -> no valid intersection at all
|
|
4581
|
+
return null;
|
|
4582
|
+
}
|
|
4583
|
+
// The radical line has no direction. Thus the resulting sector _might_ be in reverse order.
|
|
4584
|
+
// Make a quick logical check: the center of the gap must still be located inside the result sector.
|
|
4585
|
+
// If not: reverse result.
|
|
4586
|
+
var gapSector = new CircleSector(this.circle, this.endAngle, this.startAngle);
|
|
4587
|
+
var centerOfOriginalGap = gapSector.angleAt(0.5);
|
|
4588
|
+
const resultSector = new CircleSector(new Circle(this.circle.center.clone(), this.circle.radius), thisIntersectionAngleA, thisIntersectionAngleB);
|
|
4589
|
+
if (resultSector.containsAngle(centerOfOriginalGap)) {
|
|
4590
|
+
resultSector.startAngle = thisIntersectionAngleB;
|
|
4591
|
+
resultSector.endAngle = thisIntersectionAngleA;
|
|
4592
|
+
}
|
|
4593
|
+
return resultSector;
|
|
4594
|
+
}
|
|
4445
4595
|
/**
|
|
4446
4596
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
4447
4597
|
* After calling this function the object might not hold valid data any more and
|
|
4448
4598
|
* should not be used.
|
|
4599
|
+
*
|
|
4600
|
+
* @method destroy
|
|
4601
|
+
* @instance
|
|
4602
|
+
* @memberof CircleSector
|
|
4603
|
+
* @return {void}
|
|
4449
4604
|
*/
|
|
4450
4605
|
destroy() {
|
|
4451
4606
|
this.circle.destroy();
|
|
@@ -4554,8 +4709,9 @@ CircleSector.circleSectorUtils = {
|
|
|
4554
4709
|
* @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
|
|
4555
4710
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
4556
4711
|
* @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
|
|
4557
|
-
*
|
|
4558
|
-
* @
|
|
4712
|
+
* @modified 2024-01-30 Fixing an issue with immutable style sets; changes to the global draw config did not reflect here (do now).
|
|
4713
|
+
* @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
|
|
4714
|
+
* @version 1.6.9
|
|
4559
4715
|
**/
|
|
4560
4716
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
4561
4717
|
/**
|
|
@@ -4568,6 +4724,10 @@ const RAD_TO_DEG = 180 / Math.PI;
|
|
|
4568
4724
|
* @requires XYCoords
|
|
4569
4725
|
*/
|
|
4570
4726
|
class drawutilssvg {
|
|
4727
|
+
/**
|
|
4728
|
+
* Passed from primary to secondary instance.
|
|
4729
|
+
*/
|
|
4730
|
+
//private nodeStyle: SVGStyleElement;
|
|
4571
4731
|
/**
|
|
4572
4732
|
* The constructor.
|
|
4573
4733
|
*
|
|
@@ -4582,12 +4742,13 @@ class drawutilssvg {
|
|
|
4582
4742
|
* @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.
|
|
4583
4743
|
* @param {SVGGElement=} gNode - (optional) Primary and seconday instances share the same <g> node.
|
|
4584
4744
|
**/
|
|
4585
|
-
constructor(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs) {
|
|
4745
|
+
constructor(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs, nodeStyle) {
|
|
4586
4746
|
this.svgNode = svgNode;
|
|
4587
4747
|
this.offset = new Vertex(0, 0).set(offset);
|
|
4588
4748
|
this.scale = new Vertex(1, 1).set(scale);
|
|
4589
4749
|
this.fillShapes = fillShapes;
|
|
4590
4750
|
this.isSecondary = Boolean(isSecondary);
|
|
4751
|
+
this.drawConfig = drawConfig;
|
|
4591
4752
|
this.drawlibConfiguration = {};
|
|
4592
4753
|
this.cache = new Map();
|
|
4593
4754
|
this.setSize(canvasSize);
|
|
@@ -4599,6 +4760,9 @@ class drawutilssvg {
|
|
|
4599
4760
|
this.bufferGNode = bufferGNode;
|
|
4600
4761
|
this.nodeDefs = nodeDefs;
|
|
4601
4762
|
this.bufferedNodeDefs = bufferNodeDefs;
|
|
4763
|
+
if (nodeStyle) {
|
|
4764
|
+
this.nodeStyle = nodeStyle;
|
|
4765
|
+
}
|
|
4602
4766
|
}
|
|
4603
4767
|
else {
|
|
4604
4768
|
this.addStyleDefs(drawConfig);
|
|
@@ -4617,11 +4781,19 @@ class drawutilssvg {
|
|
|
4617
4781
|
addStyleDefs(drawConfig) {
|
|
4618
4782
|
this.nodeStyle = this.createSVGNode("style");
|
|
4619
4783
|
this.svgNode.appendChild(this.nodeStyle);
|
|
4784
|
+
this.rebuildStyleDefs(drawConfig);
|
|
4785
|
+
}
|
|
4786
|
+
/**
|
|
4787
|
+
* This method is required to re-define the global style defs. It is needed
|
|
4788
|
+
* if any value in the DrawConfig changed in the meantime.
|
|
4789
|
+
* @param drawConfig
|
|
4790
|
+
*/
|
|
4791
|
+
rebuildStyleDefs(drawConfig) {
|
|
4620
4792
|
// Which default styles to add? -> All from the DrawConfig.
|
|
4621
4793
|
// Compare with DrawConfig interface
|
|
4622
4794
|
const keys = {
|
|
4623
|
-
|
|
4624
|
-
"bezierPath": "BezierPath",
|
|
4795
|
+
"bezier": "CubicBezierCurve",
|
|
4796
|
+
//"bezierPath": "BezierPath", // TODO: is this correct?
|
|
4625
4797
|
"polygon": "Polygon",
|
|
4626
4798
|
"triangle": "Triangle",
|
|
4627
4799
|
"ellipse": "Ellipse",
|
|
@@ -4636,6 +4808,7 @@ class drawutilssvg {
|
|
|
4636
4808
|
};
|
|
4637
4809
|
// Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)
|
|
4638
4810
|
const rules = [];
|
|
4811
|
+
// console.log("drawConfig", drawConfig);
|
|
4639
4812
|
for (var k in keys) {
|
|
4640
4813
|
const className = keys[k];
|
|
4641
4814
|
const drawSettings = drawConfig[k];
|
|
@@ -4733,7 +4906,8 @@ class drawutilssvg {
|
|
|
4733
4906
|
node = this.createSVGNode(nodeName);
|
|
4734
4907
|
}
|
|
4735
4908
|
if (this.drawlibConfiguration.blendMode) {
|
|
4736
|
-
node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
|
|
4909
|
+
// node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
|
|
4910
|
+
node.style["mix-blend-mode"](this.drawlibConfiguration.blendMode);
|
|
4737
4911
|
}
|
|
4738
4912
|
// if (this.lineDashEnabled && this.lineDash && this.lineDash.length > 0 && drawutilssvg.nodeSupportsLineDash(nodeName)) {
|
|
4739
4913
|
// node.setAttribute("stroke-dasharray", this.lineDash.join(" "));
|
|
@@ -4833,9 +5007,9 @@ class drawutilssvg {
|
|
|
4833
5007
|
* that under the hood the same gl context and gl program will be used.
|
|
4834
5008
|
*/
|
|
4835
5009
|
copyInstance(fillShapes) {
|
|
4836
|
-
var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig – this will work as long as `isSecondary===true`
|
|
5010
|
+
var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, this.drawConfig, // null as any as DrawConfig, // no DrawConfig – this will work as long as `isSecondary===true`
|
|
4837
5011
|
true, // isSecondary
|
|
4838
|
-
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);
|
|
5012
|
+
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs, this.nodeStyle);
|
|
4839
5013
|
return copy;
|
|
4840
5014
|
}
|
|
4841
5015
|
/**
|
|
@@ -4848,20 +5022,6 @@ class drawutilssvg {
|
|
|
4848
5022
|
setConfiguration(configuration) {
|
|
4849
5023
|
this.drawlibConfiguration = configuration;
|
|
4850
5024
|
}
|
|
4851
|
-
// /**
|
|
4852
|
-
// * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
|
|
4853
|
-
// *
|
|
4854
|
-
// * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
|
|
4855
|
-
// * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
4856
|
-
// * for how line dashes work.
|
|
4857
|
-
// *
|
|
4858
|
-
// * @method
|
|
4859
|
-
// * @param {Array<number> lineDashes - The line-dash array configuration.
|
|
4860
|
-
// * @returns {void}
|
|
4861
|
-
// */
|
|
4862
|
-
// setLineDash(lineDashes: Array<number>) {
|
|
4863
|
-
// this.lineDash = lineDashes;
|
|
4864
|
-
// }
|
|
4865
5025
|
/**
|
|
4866
5026
|
* This method shouled be called each time the currently drawn `Drawable` changes.
|
|
4867
5027
|
* It is used by some libraries for identifying elemente on re-renders.
|
|
@@ -4921,6 +5081,7 @@ class drawutilssvg {
|
|
|
4921
5081
|
* @instance
|
|
4922
5082
|
**/
|
|
4923
5083
|
endDrawCycle(renderTime) {
|
|
5084
|
+
this.rebuildStyleDefs(this.drawConfig);
|
|
4924
5085
|
if (!this.isSecondary) {
|
|
4925
5086
|
// All elements are drawn into the buffer; they are NOT yet visible, not did the browser perform any
|
|
4926
5087
|
// layout updates.
|
|
@@ -8527,14 +8688,14 @@ const geomutils = {
|
|
|
8527
8688
|
if (insideAngle < 0)
|
|
8528
8689
|
insideAngle = 2 * Math.PI + insideAngle;
|
|
8529
8690
|
if (!clockwise)
|
|
8530
|
-
insideAngle = (2 * Math.PI - insideAngle) *
|
|
8691
|
+
insideAngle = (2 * Math.PI - insideAngle) * -1;
|
|
8531
8692
|
// Scale the rotated lines to the max leg length (looks better)
|
|
8532
8693
|
const lineLength = Math.max(lineAB.length(), lineAC.length());
|
|
8533
8694
|
const scaleFactor = lineLength / lineAB.length();
|
|
8534
8695
|
var result = [];
|
|
8535
8696
|
for (var i = 1; i < n; i++) {
|
|
8536
8697
|
// Compute the i-th inner sector line
|
|
8537
|
-
result.push(new Line(pA, pB.clone().rotate(
|
|
8698
|
+
result.push(new Line(pA, pB.clone().rotate(-i * (insideAngle / n), pA)).scale(scaleFactor));
|
|
8538
8699
|
}
|
|
8539
8700
|
return result;
|
|
8540
8701
|
},
|
|
@@ -8889,7 +9050,7 @@ class KeyHandler {
|
|
|
8889
9050
|
*/
|
|
8890
9051
|
// prettier-ignore
|
|
8891
9052
|
KeyHandler.KEY_CODES = {
|
|
8892
|
-
'break': 3,
|
|
9053
|
+
'break': 3, // alternate: 19
|
|
8893
9054
|
'backspace': 8,
|
|
8894
9055
|
// 'delete' : 8, // alternate: 46
|
|
8895
9056
|
'tab': 9,
|
|
@@ -8905,12 +9066,12 @@ KeyHandler.KEY_CODES = {
|
|
|
8905
9066
|
'hanja': 25,
|
|
8906
9067
|
'escape': 27,
|
|
8907
9068
|
'conversion': 28,
|
|
8908
|
-
'non-conversion': 29,
|
|
9069
|
+
'non-conversion': 29, // alternate: 235?
|
|
8909
9070
|
'spacebar': 32,
|
|
8910
9071
|
'pageup': 33,
|
|
8911
9072
|
'pagedown': 34,
|
|
8912
9073
|
'end': 35,
|
|
8913
|
-
'home': 36,
|
|
9074
|
+
'home': 36, // alternate: 172?
|
|
8914
9075
|
'leftarrow': 37,
|
|
8915
9076
|
'uparrow': 38,
|
|
8916
9077
|
'rightarrow': 39,
|
|
@@ -8920,7 +9081,7 @@ KeyHandler.KEY_CODES = {
|
|
|
8920
9081
|
'execute': 43,
|
|
8921
9082
|
'printscreen': 44,
|
|
8922
9083
|
'insert': 45,
|
|
8923
|
-
'delete': 46,
|
|
9084
|
+
'delete': 46, // alternate: 8
|
|
8924
9085
|
'help': 47,
|
|
8925
9086
|
'0': 48,
|
|
8926
9087
|
'1': 49,
|
|
@@ -8966,11 +9127,11 @@ KeyHandler.KEY_CODES = {
|
|
|
8966
9127
|
'y': 89,
|
|
8967
9128
|
'z': 90,
|
|
8968
9129
|
'windows': 91,
|
|
8969
|
-
'leftcommand': 91,
|
|
9130
|
+
'leftcommand': 91, // left ⌘
|
|
8970
9131
|
'chromebooksearch': 91,
|
|
8971
9132
|
'rightwindowkey': 92,
|
|
8972
9133
|
'windowsmenu': 93,
|
|
8973
|
-
'rightcommant': 93,
|
|
9134
|
+
'rightcommant': 93, // right ⌘
|
|
8974
9135
|
'sleep': 95,
|
|
8975
9136
|
'numpad0': 96,
|
|
8976
9137
|
'numpad1': 97,
|
|
@@ -8984,7 +9145,7 @@ KeyHandler.KEY_CODES = {
|
|
|
8984
9145
|
'numpad9': 105,
|
|
8985
9146
|
'multiply': 106,
|
|
8986
9147
|
'add': 107,
|
|
8987
|
-
'numpadperiod': 108,
|
|
9148
|
+
'numpadperiod': 108, // firefox, 194 on chrome
|
|
8988
9149
|
'subtract': 109,
|
|
8989
9150
|
'decimalpoint': 110,
|
|
8990
9151
|
'divide': 111,
|
|
@@ -9023,11 +9184,11 @@ KeyHandler.KEY_CODES = {
|
|
|
9023
9184
|
'pagebackward': 166,
|
|
9024
9185
|
'pageforward': 167,
|
|
9025
9186
|
'refresh': 168,
|
|
9026
|
-
'closingparen': 169,
|
|
9187
|
+
'closingparen': 169, // (AZERTY)
|
|
9027
9188
|
'*': 170,
|
|
9028
9189
|
'~+*': 171,
|
|
9029
9190
|
// 'home' : 172,
|
|
9030
|
-
'minus': 173,
|
|
9191
|
+
'minus': 173, // firefox
|
|
9031
9192
|
// 'mute' : 173,
|
|
9032
9193
|
// 'unmute' : 173,
|
|
9033
9194
|
'decreasevolumelevel': 174,
|
|
@@ -9037,8 +9198,8 @@ KeyHandler.KEY_CODES = {
|
|
|
9037
9198
|
'stop': 178,
|
|
9038
9199
|
'play/pause': 179,
|
|
9039
9200
|
'email': 180,
|
|
9040
|
-
'mute': 181,
|
|
9041
|
-
'unmute': 181,
|
|
9201
|
+
'mute': 181, // firefox, alternate: 173
|
|
9202
|
+
'unmute': 181, // alternate: 173?
|
|
9042
9203
|
//'decreasevolumelevel' 182 // firefox
|
|
9043
9204
|
//'increasevolumelevel' 183 // firefox
|
|
9044
9205
|
'semicolon': 186,
|
|
@@ -9048,7 +9209,7 @@ KeyHandler.KEY_CODES = {
|
|
|
9048
9209
|
'dash': 189,
|
|
9049
9210
|
'period': 190,
|
|
9050
9211
|
'forwardslash': 191,
|
|
9051
|
-
'ç': 191,
|
|
9212
|
+
'ç': 191, // 231 alternate?
|
|
9052
9213
|
'grave accent': 192,
|
|
9053
9214
|
//'ñ' 192,
|
|
9054
9215
|
'æ': 192,
|
|
@@ -9077,7 +9238,7 @@ KeyHandler.KEY_CODES = {
|
|
|
9077
9238
|
'half-width': 243,
|
|
9078
9239
|
'full-width': 243,
|
|
9079
9240
|
'kanji': 244,
|
|
9080
|
-
'unlocktrackpad': 251,
|
|
9241
|
+
'unlocktrackpad': 251, // Chrome/Edge
|
|
9081
9242
|
'toggletouchpad': 255
|
|
9082
9243
|
};
|
|
9083
9244
|
|
|
@@ -9274,10 +9435,10 @@ class MouseHandler {
|
|
|
9274
9435
|
name: eventName,
|
|
9275
9436
|
isTouchEvent: false,
|
|
9276
9437
|
pos: rel,
|
|
9277
|
-
button: event.button,
|
|
9278
|
-
leftButton: event.button === 0,
|
|
9279
|
-
middleButton: event.button === 1,
|
|
9280
|
-
rightButton: event.button === 2,
|
|
9438
|
+
button: event.button, // this.mouseButton,
|
|
9439
|
+
leftButton: event.button === 0, // this.mouseButton === 0,
|
|
9440
|
+
middleButton: event.button === 1, // this.mouseButton === 1,
|
|
9441
|
+
rightButton: event.button === 2, // this.mouseButton === 2,
|
|
9281
9442
|
mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },
|
|
9282
9443
|
draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },
|
|
9283
9444
|
wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),
|
|
@@ -10525,7 +10686,7 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10525
10686
|
const r2d = 180 / Math.PI;
|
|
10526
10687
|
pathData.push("A", radiusH, radiusV, rotation * r2d, largeArcFlag, sweepFlag, end.x, end.y);
|
|
10527
10688
|
return pathData;
|
|
10528
|
-
},
|
|
10689
|
+
}, // END function describeSVGArc
|
|
10529
10690
|
/**
|
|
10530
10691
|
* Helper function to find second-kind elliptic angles, so that the euclidean distance along the the
|
|
10531
10692
|
* elliptic sector is the same for all.
|
|
@@ -10737,6 +10898,10 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10737
10898
|
* @fileoverview The main class.
|
|
10738
10899
|
* @public
|
|
10739
10900
|
**/
|
|
10901
|
+
var __setFunctionName = (undefined && undefined.__setFunctionName) || function (f, name, prefix) {
|
|
10902
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
10903
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
10904
|
+
};
|
|
10740
10905
|
var _a;
|
|
10741
10906
|
/**
|
|
10742
10907
|
* @classdesc The main class of the PlotBoilerplate.
|
|
@@ -10828,8 +10993,8 @@ class PlotBoilerplate {
|
|
|
10828
10993
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
10829
10994
|
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
10830
10995
|
*/
|
|
10831
|
-
constructor(config) {
|
|
10832
|
-
var
|
|
10996
|
+
constructor(config, drawConfig) {
|
|
10997
|
+
var _b, _c;
|
|
10833
10998
|
/**
|
|
10834
10999
|
* A discrete timestamp to identify single render cycles.
|
|
10835
11000
|
* Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines
|
|
@@ -10903,8 +11068,8 @@ class PlotBoilerplate {
|
|
|
10903
11068
|
enableTouch: f.bool(config, "enableTouch", true),
|
|
10904
11069
|
enableKeys: f.bool(config, "enableKeys", true),
|
|
10905
11070
|
enableMouseWheel: f.bool(config, "enableMouseWheel", true),
|
|
10906
|
-
enableZoom: f.bool(config, "enableZoom", true),
|
|
10907
|
-
enablePan: f.bool(config, "enablePan", true),
|
|
11071
|
+
enableZoom: f.bool(config, "enableZoom", true), // default=true
|
|
11072
|
+
enablePan: f.bool(config, "enablePan", true), // default=true
|
|
10908
11073
|
// Experimental (and unfinished)
|
|
10909
11074
|
enableGL: f.bool(config, "enableGL", false)
|
|
10910
11075
|
}; // END confog
|
|
@@ -11064,8 +11229,8 @@ class PlotBoilerplate {
|
|
|
11064
11229
|
if (config.title) {
|
|
11065
11230
|
this.eventCatcher.setAttribute("title", config.title);
|
|
11066
11231
|
}
|
|
11067
|
-
this.draw.scale.set((
|
|
11068
|
-
this.fill.scale.set((
|
|
11232
|
+
this.draw.scale.set((_b = this.config.scaleX) !== null && _b !== void 0 ? _b : 1.0, this.config.scaleY);
|
|
11233
|
+
this.fill.scale.set((_c = this.config.scaleX) !== null && _c !== void 0 ? _c : 1.0, this.config.scaleY);
|
|
11069
11234
|
this.vertices = [];
|
|
11070
11235
|
this.selectPolygon = null;
|
|
11071
11236
|
this.draggedElements = [];
|
|
@@ -11131,8 +11296,9 @@ class PlotBoilerplate {
|
|
|
11131
11296
|
var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>\n' + svgCode], { type: "image/svg;charset=utf-8" });
|
|
11132
11297
|
// See documentation for FileSaver.js for usage.
|
|
11133
11298
|
// https://github.com/eligrey/FileSaver.js
|
|
11134
|
-
if (typeof globalThis["saveAs"] !== "function")
|
|
11299
|
+
if (typeof globalThis["saveAs"] !== "function") {
|
|
11135
11300
|
throw "Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?";
|
|
11301
|
+
}
|
|
11136
11302
|
var _saveAs = globalThis["saveAs"];
|
|
11137
11303
|
_saveAs(blob, "plotboilerplate.svg");
|
|
11138
11304
|
}
|
|
@@ -11203,12 +11369,12 @@ class PlotBoilerplate {
|
|
|
11203
11369
|
* @private
|
|
11204
11370
|
**/
|
|
11205
11371
|
updateCSSscale() {
|
|
11206
|
-
var
|
|
11372
|
+
var _b, _c, _d, _e;
|
|
11207
11373
|
if (this.config.cssUniformScale) {
|
|
11208
|
-
PlotBoilerplate.utils.setCSSscale(this.canvas, (
|
|
11374
|
+
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);
|
|
11209
11375
|
}
|
|
11210
11376
|
else {
|
|
11211
|
-
PlotBoilerplate.utils.setCSSscale(this.canvas, (
|
|
11377
|
+
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);
|
|
11212
11378
|
}
|
|
11213
11379
|
}
|
|
11214
11380
|
/**
|
|
@@ -11481,8 +11647,8 @@ class PlotBoilerplate {
|
|
|
11481
11647
|
* @return The vertex near the given position or undefined if none was found there.
|
|
11482
11648
|
**/
|
|
11483
11649
|
getVertexNear(pixelPosition, pixelTolerance) {
|
|
11484
|
-
var
|
|
11485
|
-
const p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min((
|
|
11650
|
+
var _b, _c;
|
|
11651
|
+
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));
|
|
11486
11652
|
if (p && p.typeName == "vertex") {
|
|
11487
11653
|
return this.vertices[p.vindex];
|
|
11488
11654
|
}
|
|
@@ -11911,8 +12077,8 @@ class PlotBoilerplate {
|
|
|
11911
12077
|
* @return {Bounds} The current viewport.
|
|
11912
12078
|
**/
|
|
11913
12079
|
viewport() {
|
|
11914
|
-
var
|
|
11915
|
-
return new Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * ((
|
|
12080
|
+
var _b, _c;
|
|
12081
|
+
return new Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * ((_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0), this.canvasSize.height * ((_c = this.config.cssScaleY) !== null && _c !== void 0 ? _c : 1.0)));
|
|
11916
12082
|
}
|
|
11917
12083
|
/**
|
|
11918
12084
|
* Trigger the saveFile.hook.
|
|
@@ -11960,12 +12126,12 @@ class PlotBoilerplate {
|
|
|
11960
12126
|
* @return {void}
|
|
11961
12127
|
**/
|
|
11962
12128
|
resizeCanvas() {
|
|
11963
|
-
var
|
|
12129
|
+
var _b, _c, _d, _e, _f, _g;
|
|
11964
12130
|
const _self = this;
|
|
11965
12131
|
const _setSize = (w, h) => {
|
|
11966
|
-
var
|
|
11967
|
-
w *= (
|
|
11968
|
-
h *= (
|
|
12132
|
+
var _b, _c;
|
|
12133
|
+
w *= (_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0;
|
|
12134
|
+
h *= (_c = _self.config.canvasHeightFactor) !== null && _c !== void 0 ? _c : 1.0;
|
|
11969
12135
|
_self.canvasSize.width = w;
|
|
11970
12136
|
_self.canvasSize.height = h;
|
|
11971
12137
|
if (_self.canvas instanceof HTMLCanvasElement) {
|
|
@@ -11994,8 +12160,8 @@ class PlotBoilerplate {
|
|
|
11994
12160
|
var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
11995
12161
|
var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
11996
12162
|
_self.canvas.style.position = "absolute";
|
|
11997
|
-
_self.canvas.style.width = ((
|
|
11998
|
-
_self.canvas.style.height = ((
|
|
12163
|
+
_self.canvas.style.width = ((_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0) * width + "px";
|
|
12164
|
+
_self.canvas.style.height = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * height + "px";
|
|
11999
12165
|
_self.canvas.style.top = "0px";
|
|
12000
12166
|
_self.canvas.style.left = "0px";
|
|
12001
12167
|
_setSize(width, height);
|
|
@@ -12004,8 +12170,8 @@ class PlotBoilerplate {
|
|
|
12004
12170
|
// Set editor size
|
|
12005
12171
|
_self.canvas.style.position = "static";
|
|
12006
12172
|
const space = this.getAvailableContainerSpace();
|
|
12007
|
-
_self.canvas.style.width = ((
|
|
12008
|
-
_self.canvas.style.height = ((
|
|
12173
|
+
_self.canvas.style.width = ((_d = _self.config.canvasWidthFactor) !== null && _d !== void 0 ? _d : 1.0) * space.width + "px";
|
|
12174
|
+
_self.canvas.style.height = ((_e = _self.config.canvasHeightFactor) !== null && _e !== void 0 ? _e : 1.0) * space.height + "px";
|
|
12009
12175
|
_self.canvas.style.top = "";
|
|
12010
12176
|
_self.canvas.style.left = "";
|
|
12011
12177
|
_setSize(space.width, space.height);
|
|
@@ -12013,7 +12179,7 @@ class PlotBoilerplate {
|
|
|
12013
12179
|
else {
|
|
12014
12180
|
_self.canvas.style.width = "";
|
|
12015
12181
|
_self.canvas.style.height = "";
|
|
12016
|
-
_setSize((
|
|
12182
|
+
_setSize((_f = _self.config.defaultCanvasWidth) !== null && _f !== void 0 ? _f : 1024, (_g = _self.config.defaultCanvasHeight) !== null && _g !== void 0 ? _g : 768);
|
|
12017
12183
|
}
|
|
12018
12184
|
if (_self.config.redrawOnResize)
|
|
12019
12185
|
_self.redraw();
|
|
@@ -12516,7 +12682,9 @@ class PlotBoilerplate {
|
|
|
12516
12682
|
}
|
|
12517
12683
|
}; // END afProps
|
|
12518
12684
|
if (window["createAlloyFinger"]) {
|
|
12519
|
-
window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
12685
|
+
// window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
12686
|
+
const createAlloyFinger = window["createAlloyFinger"];
|
|
12687
|
+
createAlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
12520
12688
|
}
|
|
12521
12689
|
else {
|
|
12522
12690
|
/* tslint:disable-next-line */
|
|
@@ -12574,10 +12742,15 @@ class PlotBoilerplate {
|
|
|
12574
12742
|
createGUI(props) {
|
|
12575
12743
|
// This function moved to the helper utils.
|
|
12576
12744
|
// We do not want to include the whole dat.GUI package.
|
|
12577
|
-
|
|
12578
|
-
|
|
12579
|
-
|
|
12745
|
+
const utils = globalThis["utils"];
|
|
12746
|
+
// if (globalThis["utils"] && typeof globalThis["utils"].createGUI == "function") {
|
|
12747
|
+
// return (globalThis["utils" as keyof Object] as any as ({createGUI : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI })).createGUI(this, props);
|
|
12748
|
+
if (utils && typeof utils.createGUI === "function") {
|
|
12749
|
+
return utils.createGUI(this, props);
|
|
12750
|
+
}
|
|
12751
|
+
else {
|
|
12580
12752
|
throw "Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?";
|
|
12753
|
+
}
|
|
12581
12754
|
}
|
|
12582
12755
|
} // END class PlotBoilerplate
|
|
12583
12756
|
/** @constant {number} */
|
|
@@ -12605,6 +12778,7 @@ PlotBoilerplate.Draggable = (_a = class {
|
|
|
12605
12778
|
return this;
|
|
12606
12779
|
}
|
|
12607
12780
|
},
|
|
12781
|
+
__setFunctionName(_a, "Draggable"),
|
|
12608
12782
|
_a.VERTEX = "vertex",
|
|
12609
12783
|
_a);
|
|
12610
12784
|
/**
|
|
@@ -12694,7 +12868,8 @@ PlotBoilerplate.utils = {
|
|
|
12694
12868
|
* @return {void}
|
|
12695
12869
|
**/
|
|
12696
12870
|
setCSSscale: (element, scaleX, scaleY) => {
|
|
12697
|
-
element.style["transform-origin"] = "0 0";
|
|
12871
|
+
// element.style["transform-origin"] = "0 0";
|
|
12872
|
+
element.style.transformOrigin = "0 0";
|
|
12698
12873
|
if (scaleX == 1.0 && scaleY == 1.0) {
|
|
12699
12874
|
// element.style.transform = null;
|
|
12700
12875
|
element.style.removeProperty("transform");
|
|
@@ -12777,7 +12952,7 @@ PlotBoilerplate.utils = {
|
|
|
12777
12952
|
return fallback;
|
|
12778
12953
|
return obj[key];
|
|
12779
12954
|
}
|
|
12780
|
-
},
|
|
12955
|
+
}, // END fetch
|
|
12781
12956
|
/**
|
|
12782
12957
|
* Installs vertex listeners to the path's vertices so that controlpoints
|
|
12783
12958
|
* move with their path points when dragged.
|