plotboilerplate 1.22.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 +222 -76
- 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 +492 -337
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +5 -4
- 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.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.js.map +1 -1
- 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.js +5 -5
- package/src/cjs/utils/algorithms/ContourLineDetection.js.map +1 -1
- 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.js.map +1 -1
- 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 +1 -1
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +1 -1
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- 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.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.js.map +1 -1
- 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.js.map +1 -1
- 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.js.map +1 -1
- 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 +1 -1
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +2 -2
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
- 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/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/algorithms/CircleIntersections.ts +280 -288
- package/src/ts/utils/algorithms/Metaballs.ts +144 -0
- package/src/ts/utils/algorithms/arrayResize.ts +22 -0
- package/src/ts/utils/datastructures/Color.ts +39 -15
- 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/README.md
CHANGED
|
@@ -556,6 +556,8 @@ new MouseHandler(document.getElementById("mycanvas"))
|
|
|
556
556
|
- [girih-tiles-spatial.jpg from Lund University, Architecture, Spatial Experiments, 2016.](https://spatialexperiments.wordpress.com/2016/09/19/islamic-geometry/girih-tiles-4/)
|
|
557
557
|
- [Josh Frank's regular expression for parsing SVG path data.](https://javascript.plainenglish.io/june-3-parsing-and-validating-svg-paths-with-regex-7bd0e245115)
|
|
558
558
|
- [Rick Moore for the useful javascript-synthesizer howto](https://medium.com/geekculture/building-a-modular-synth-with-web-audio-api-and-javascript-d38ccdeca9ea)
|
|
559
|
+
- [marked Markdown compiler](https://marked.js.org/) by Christopher Jeffrey.
|
|
560
|
+
- [Interactive Visualization of Molecular Surface Dynamics](https://www.computer.org/csdl/journal/tg/2009/06/ttg2009061391/13rRUwInvsI) for the illustration image which inspired the metaballs demo.
|
|
559
561
|
|
|
560
562
|
## Todos
|
|
561
563
|
|
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.
|
|
@@ -4440,7 +4447,12 @@ Circle.circleUtils = {
|
|
|
4440
4447
|
* @date 2020-12-17
|
|
4441
4448
|
* @modified 2021-01-20 Added UID.
|
|
4442
4449
|
* @modified 2021-02-26 Fixed an error in the svg-arc-calculation (case angle<90deg and anti-clockwise).
|
|
4443
|
-
* @
|
|
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
|
|
4444
4456
|
**/
|
|
4445
4457
|
/**
|
|
4446
4458
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
@@ -4471,10 +4483,124 @@ class CircleSector {
|
|
|
4471
4483
|
this.startAngle = startAngle;
|
|
4472
4484
|
this.endAngle = endAngle;
|
|
4473
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
|
+
}
|
|
4474
4595
|
/**
|
|
4475
4596
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
4476
4597
|
* After calling this function the object might not hold valid data any more and
|
|
4477
4598
|
* should not be used.
|
|
4599
|
+
*
|
|
4600
|
+
* @method destroy
|
|
4601
|
+
* @instance
|
|
4602
|
+
* @memberof CircleSector
|
|
4603
|
+
* @return {void}
|
|
4478
4604
|
*/
|
|
4479
4605
|
destroy() {
|
|
4480
4606
|
this.circle.destroy();
|
|
@@ -4583,8 +4709,9 @@ CircleSector.circleSectorUtils = {
|
|
|
4583
4709
|
* @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
|
|
4584
4710
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
4585
4711
|
* @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
|
|
4586
|
-
*
|
|
4587
|
-
* @
|
|
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
|
|
4588
4715
|
**/
|
|
4589
4716
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
4590
4717
|
/**
|
|
@@ -4597,6 +4724,10 @@ const RAD_TO_DEG = 180 / Math.PI;
|
|
|
4597
4724
|
* @requires XYCoords
|
|
4598
4725
|
*/
|
|
4599
4726
|
class drawutilssvg {
|
|
4727
|
+
/**
|
|
4728
|
+
* Passed from primary to secondary instance.
|
|
4729
|
+
*/
|
|
4730
|
+
//private nodeStyle: SVGStyleElement;
|
|
4600
4731
|
/**
|
|
4601
4732
|
* The constructor.
|
|
4602
4733
|
*
|
|
@@ -4611,12 +4742,13 @@ class drawutilssvg {
|
|
|
4611
4742
|
* @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.
|
|
4612
4743
|
* @param {SVGGElement=} gNode - (optional) Primary and seconday instances share the same <g> node.
|
|
4613
4744
|
**/
|
|
4614
|
-
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) {
|
|
4615
4746
|
this.svgNode = svgNode;
|
|
4616
4747
|
this.offset = new Vertex(0, 0).set(offset);
|
|
4617
4748
|
this.scale = new Vertex(1, 1).set(scale);
|
|
4618
4749
|
this.fillShapes = fillShapes;
|
|
4619
4750
|
this.isSecondary = Boolean(isSecondary);
|
|
4751
|
+
this.drawConfig = drawConfig;
|
|
4620
4752
|
this.drawlibConfiguration = {};
|
|
4621
4753
|
this.cache = new Map();
|
|
4622
4754
|
this.setSize(canvasSize);
|
|
@@ -4628,6 +4760,9 @@ class drawutilssvg {
|
|
|
4628
4760
|
this.bufferGNode = bufferGNode;
|
|
4629
4761
|
this.nodeDefs = nodeDefs;
|
|
4630
4762
|
this.bufferedNodeDefs = bufferNodeDefs;
|
|
4763
|
+
if (nodeStyle) {
|
|
4764
|
+
this.nodeStyle = nodeStyle;
|
|
4765
|
+
}
|
|
4631
4766
|
}
|
|
4632
4767
|
else {
|
|
4633
4768
|
this.addStyleDefs(drawConfig);
|
|
@@ -4646,11 +4781,19 @@ class drawutilssvg {
|
|
|
4646
4781
|
addStyleDefs(drawConfig) {
|
|
4647
4782
|
this.nodeStyle = this.createSVGNode("style");
|
|
4648
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) {
|
|
4649
4792
|
// Which default styles to add? -> All from the DrawConfig.
|
|
4650
4793
|
// Compare with DrawConfig interface
|
|
4651
4794
|
const keys = {
|
|
4652
|
-
|
|
4653
|
-
"bezierPath": "BezierPath",
|
|
4795
|
+
"bezier": "CubicBezierCurve",
|
|
4796
|
+
//"bezierPath": "BezierPath", // TODO: is this correct?
|
|
4654
4797
|
"polygon": "Polygon",
|
|
4655
4798
|
"triangle": "Triangle",
|
|
4656
4799
|
"ellipse": "Ellipse",
|
|
@@ -4665,6 +4808,7 @@ class drawutilssvg {
|
|
|
4665
4808
|
};
|
|
4666
4809
|
// Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)
|
|
4667
4810
|
const rules = [];
|
|
4811
|
+
// console.log("drawConfig", drawConfig);
|
|
4668
4812
|
for (var k in keys) {
|
|
4669
4813
|
const className = keys[k];
|
|
4670
4814
|
const drawSettings = drawConfig[k];
|
|
@@ -4762,7 +4906,8 @@ class drawutilssvg {
|
|
|
4762
4906
|
node = this.createSVGNode(nodeName);
|
|
4763
4907
|
}
|
|
4764
4908
|
if (this.drawlibConfiguration.blendMode) {
|
|
4765
|
-
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);
|
|
4766
4911
|
}
|
|
4767
4912
|
// if (this.lineDashEnabled && this.lineDash && this.lineDash.length > 0 && drawutilssvg.nodeSupportsLineDash(nodeName)) {
|
|
4768
4913
|
// node.setAttribute("stroke-dasharray", this.lineDash.join(" "));
|
|
@@ -4862,9 +5007,9 @@ class drawutilssvg {
|
|
|
4862
5007
|
* that under the hood the same gl context and gl program will be used.
|
|
4863
5008
|
*/
|
|
4864
5009
|
copyInstance(fillShapes) {
|
|
4865
|
-
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`
|
|
4866
5011
|
true, // isSecondary
|
|
4867
|
-
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);
|
|
5012
|
+
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs, this.nodeStyle);
|
|
4868
5013
|
return copy;
|
|
4869
5014
|
}
|
|
4870
5015
|
/**
|
|
@@ -4877,20 +5022,6 @@ class drawutilssvg {
|
|
|
4877
5022
|
setConfiguration(configuration) {
|
|
4878
5023
|
this.drawlibConfiguration = configuration;
|
|
4879
5024
|
}
|
|
4880
|
-
// /**
|
|
4881
|
-
// * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
|
|
4882
|
-
// *
|
|
4883
|
-
// * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
|
|
4884
|
-
// * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
4885
|
-
// * for how line dashes work.
|
|
4886
|
-
// *
|
|
4887
|
-
// * @method
|
|
4888
|
-
// * @param {Array<number> lineDashes - The line-dash array configuration.
|
|
4889
|
-
// * @returns {void}
|
|
4890
|
-
// */
|
|
4891
|
-
// setLineDash(lineDashes: Array<number>) {
|
|
4892
|
-
// this.lineDash = lineDashes;
|
|
4893
|
-
// }
|
|
4894
5025
|
/**
|
|
4895
5026
|
* This method shouled be called each time the currently drawn `Drawable` changes.
|
|
4896
5027
|
* It is used by some libraries for identifying elemente on re-renders.
|
|
@@ -4950,6 +5081,7 @@ class drawutilssvg {
|
|
|
4950
5081
|
* @instance
|
|
4951
5082
|
**/
|
|
4952
5083
|
endDrawCycle(renderTime) {
|
|
5084
|
+
this.rebuildStyleDefs(this.drawConfig);
|
|
4953
5085
|
if (!this.isSecondary) {
|
|
4954
5086
|
// All elements are drawn into the buffer; they are NOT yet visible, not did the browser perform any
|
|
4955
5087
|
// layout updates.
|
|
@@ -8556,14 +8688,14 @@ const geomutils = {
|
|
|
8556
8688
|
if (insideAngle < 0)
|
|
8557
8689
|
insideAngle = 2 * Math.PI + insideAngle;
|
|
8558
8690
|
if (!clockwise)
|
|
8559
|
-
insideAngle = (2 * Math.PI - insideAngle) *
|
|
8691
|
+
insideAngle = (2 * Math.PI - insideAngle) * -1;
|
|
8560
8692
|
// Scale the rotated lines to the max leg length (looks better)
|
|
8561
8693
|
const lineLength = Math.max(lineAB.length(), lineAC.length());
|
|
8562
8694
|
const scaleFactor = lineLength / lineAB.length();
|
|
8563
8695
|
var result = [];
|
|
8564
8696
|
for (var i = 1; i < n; i++) {
|
|
8565
8697
|
// Compute the i-th inner sector line
|
|
8566
|
-
result.push(new Line(pA, pB.clone().rotate(
|
|
8698
|
+
result.push(new Line(pA, pB.clone().rotate(-i * (insideAngle / n), pA)).scale(scaleFactor));
|
|
8567
8699
|
}
|
|
8568
8700
|
return result;
|
|
8569
8701
|
},
|
|
@@ -8918,7 +9050,7 @@ class KeyHandler {
|
|
|
8918
9050
|
*/
|
|
8919
9051
|
// prettier-ignore
|
|
8920
9052
|
KeyHandler.KEY_CODES = {
|
|
8921
|
-
'break': 3,
|
|
9053
|
+
'break': 3, // alternate: 19
|
|
8922
9054
|
'backspace': 8,
|
|
8923
9055
|
// 'delete' : 8, // alternate: 46
|
|
8924
9056
|
'tab': 9,
|
|
@@ -8934,12 +9066,12 @@ KeyHandler.KEY_CODES = {
|
|
|
8934
9066
|
'hanja': 25,
|
|
8935
9067
|
'escape': 27,
|
|
8936
9068
|
'conversion': 28,
|
|
8937
|
-
'non-conversion': 29,
|
|
9069
|
+
'non-conversion': 29, // alternate: 235?
|
|
8938
9070
|
'spacebar': 32,
|
|
8939
9071
|
'pageup': 33,
|
|
8940
9072
|
'pagedown': 34,
|
|
8941
9073
|
'end': 35,
|
|
8942
|
-
'home': 36,
|
|
9074
|
+
'home': 36, // alternate: 172?
|
|
8943
9075
|
'leftarrow': 37,
|
|
8944
9076
|
'uparrow': 38,
|
|
8945
9077
|
'rightarrow': 39,
|
|
@@ -8949,7 +9081,7 @@ KeyHandler.KEY_CODES = {
|
|
|
8949
9081
|
'execute': 43,
|
|
8950
9082
|
'printscreen': 44,
|
|
8951
9083
|
'insert': 45,
|
|
8952
|
-
'delete': 46,
|
|
9084
|
+
'delete': 46, // alternate: 8
|
|
8953
9085
|
'help': 47,
|
|
8954
9086
|
'0': 48,
|
|
8955
9087
|
'1': 49,
|
|
@@ -8995,11 +9127,11 @@ KeyHandler.KEY_CODES = {
|
|
|
8995
9127
|
'y': 89,
|
|
8996
9128
|
'z': 90,
|
|
8997
9129
|
'windows': 91,
|
|
8998
|
-
'leftcommand': 91,
|
|
9130
|
+
'leftcommand': 91, // left ⌘
|
|
8999
9131
|
'chromebooksearch': 91,
|
|
9000
9132
|
'rightwindowkey': 92,
|
|
9001
9133
|
'windowsmenu': 93,
|
|
9002
|
-
'rightcommant': 93,
|
|
9134
|
+
'rightcommant': 93, // right ⌘
|
|
9003
9135
|
'sleep': 95,
|
|
9004
9136
|
'numpad0': 96,
|
|
9005
9137
|
'numpad1': 97,
|
|
@@ -9013,7 +9145,7 @@ KeyHandler.KEY_CODES = {
|
|
|
9013
9145
|
'numpad9': 105,
|
|
9014
9146
|
'multiply': 106,
|
|
9015
9147
|
'add': 107,
|
|
9016
|
-
'numpadperiod': 108,
|
|
9148
|
+
'numpadperiod': 108, // firefox, 194 on chrome
|
|
9017
9149
|
'subtract': 109,
|
|
9018
9150
|
'decimalpoint': 110,
|
|
9019
9151
|
'divide': 111,
|
|
@@ -9052,11 +9184,11 @@ KeyHandler.KEY_CODES = {
|
|
|
9052
9184
|
'pagebackward': 166,
|
|
9053
9185
|
'pageforward': 167,
|
|
9054
9186
|
'refresh': 168,
|
|
9055
|
-
'closingparen': 169,
|
|
9187
|
+
'closingparen': 169, // (AZERTY)
|
|
9056
9188
|
'*': 170,
|
|
9057
9189
|
'~+*': 171,
|
|
9058
9190
|
// 'home' : 172,
|
|
9059
|
-
'minus': 173,
|
|
9191
|
+
'minus': 173, // firefox
|
|
9060
9192
|
// 'mute' : 173,
|
|
9061
9193
|
// 'unmute' : 173,
|
|
9062
9194
|
'decreasevolumelevel': 174,
|
|
@@ -9066,8 +9198,8 @@ KeyHandler.KEY_CODES = {
|
|
|
9066
9198
|
'stop': 178,
|
|
9067
9199
|
'play/pause': 179,
|
|
9068
9200
|
'email': 180,
|
|
9069
|
-
'mute': 181,
|
|
9070
|
-
'unmute': 181,
|
|
9201
|
+
'mute': 181, // firefox, alternate: 173
|
|
9202
|
+
'unmute': 181, // alternate: 173?
|
|
9071
9203
|
//'decreasevolumelevel' 182 // firefox
|
|
9072
9204
|
//'increasevolumelevel' 183 // firefox
|
|
9073
9205
|
'semicolon': 186,
|
|
@@ -9077,7 +9209,7 @@ KeyHandler.KEY_CODES = {
|
|
|
9077
9209
|
'dash': 189,
|
|
9078
9210
|
'period': 190,
|
|
9079
9211
|
'forwardslash': 191,
|
|
9080
|
-
'ç': 191,
|
|
9212
|
+
'ç': 191, // 231 alternate?
|
|
9081
9213
|
'grave accent': 192,
|
|
9082
9214
|
//'ñ' 192,
|
|
9083
9215
|
'æ': 192,
|
|
@@ -9106,7 +9238,7 @@ KeyHandler.KEY_CODES = {
|
|
|
9106
9238
|
'half-width': 243,
|
|
9107
9239
|
'full-width': 243,
|
|
9108
9240
|
'kanji': 244,
|
|
9109
|
-
'unlocktrackpad': 251,
|
|
9241
|
+
'unlocktrackpad': 251, // Chrome/Edge
|
|
9110
9242
|
'toggletouchpad': 255
|
|
9111
9243
|
};
|
|
9112
9244
|
|
|
@@ -9303,10 +9435,10 @@ class MouseHandler {
|
|
|
9303
9435
|
name: eventName,
|
|
9304
9436
|
isTouchEvent: false,
|
|
9305
9437
|
pos: rel,
|
|
9306
|
-
button: event.button,
|
|
9307
|
-
leftButton: event.button === 0,
|
|
9308
|
-
middleButton: event.button === 1,
|
|
9309
|
-
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,
|
|
9310
9442
|
mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },
|
|
9311
9443
|
draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },
|
|
9312
9444
|
wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),
|
|
@@ -10554,7 +10686,7 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10554
10686
|
const r2d = 180 / Math.PI;
|
|
10555
10687
|
pathData.push("A", radiusH, radiusV, rotation * r2d, largeArcFlag, sweepFlag, end.x, end.y);
|
|
10556
10688
|
return pathData;
|
|
10557
|
-
},
|
|
10689
|
+
}, // END function describeSVGArc
|
|
10558
10690
|
/**
|
|
10559
10691
|
* Helper function to find second-kind elliptic angles, so that the euclidean distance along the the
|
|
10560
10692
|
* elliptic sector is the same for all.
|
|
@@ -10766,6 +10898,10 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10766
10898
|
* @fileoverview The main class.
|
|
10767
10899
|
* @public
|
|
10768
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
|
+
};
|
|
10769
10905
|
var _a;
|
|
10770
10906
|
/**
|
|
10771
10907
|
* @classdesc The main class of the PlotBoilerplate.
|
|
@@ -10857,8 +10993,8 @@ class PlotBoilerplate {
|
|
|
10857
10993
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
10858
10994
|
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
10859
10995
|
*/
|
|
10860
|
-
constructor(config) {
|
|
10861
|
-
var
|
|
10996
|
+
constructor(config, drawConfig) {
|
|
10997
|
+
var _b, _c;
|
|
10862
10998
|
/**
|
|
10863
10999
|
* A discrete timestamp to identify single render cycles.
|
|
10864
11000
|
* Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines
|
|
@@ -10932,8 +11068,8 @@ class PlotBoilerplate {
|
|
|
10932
11068
|
enableTouch: f.bool(config, "enableTouch", true),
|
|
10933
11069
|
enableKeys: f.bool(config, "enableKeys", true),
|
|
10934
11070
|
enableMouseWheel: f.bool(config, "enableMouseWheel", true),
|
|
10935
|
-
enableZoom: f.bool(config, "enableZoom", true),
|
|
10936
|
-
enablePan: f.bool(config, "enablePan", true),
|
|
11071
|
+
enableZoom: f.bool(config, "enableZoom", true), // default=true
|
|
11072
|
+
enablePan: f.bool(config, "enablePan", true), // default=true
|
|
10937
11073
|
// Experimental (and unfinished)
|
|
10938
11074
|
enableGL: f.bool(config, "enableGL", false)
|
|
10939
11075
|
}; // END confog
|
|
@@ -11093,8 +11229,8 @@ class PlotBoilerplate {
|
|
|
11093
11229
|
if (config.title) {
|
|
11094
11230
|
this.eventCatcher.setAttribute("title", config.title);
|
|
11095
11231
|
}
|
|
11096
|
-
this.draw.scale.set((
|
|
11097
|
-
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);
|
|
11098
11234
|
this.vertices = [];
|
|
11099
11235
|
this.selectPolygon = null;
|
|
11100
11236
|
this.draggedElements = [];
|
|
@@ -11160,8 +11296,9 @@ class PlotBoilerplate {
|
|
|
11160
11296
|
var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>\n' + svgCode], { type: "image/svg;charset=utf-8" });
|
|
11161
11297
|
// See documentation for FileSaver.js for usage.
|
|
11162
11298
|
// https://github.com/eligrey/FileSaver.js
|
|
11163
|
-
if (typeof globalThis["saveAs"] !== "function")
|
|
11299
|
+
if (typeof globalThis["saveAs"] !== "function") {
|
|
11164
11300
|
throw "Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?";
|
|
11301
|
+
}
|
|
11165
11302
|
var _saveAs = globalThis["saveAs"];
|
|
11166
11303
|
_saveAs(blob, "plotboilerplate.svg");
|
|
11167
11304
|
}
|
|
@@ -11232,12 +11369,12 @@ class PlotBoilerplate {
|
|
|
11232
11369
|
* @private
|
|
11233
11370
|
**/
|
|
11234
11371
|
updateCSSscale() {
|
|
11235
|
-
var
|
|
11372
|
+
var _b, _c, _d, _e;
|
|
11236
11373
|
if (this.config.cssUniformScale) {
|
|
11237
|
-
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);
|
|
11238
11375
|
}
|
|
11239
11376
|
else {
|
|
11240
|
-
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);
|
|
11241
11378
|
}
|
|
11242
11379
|
}
|
|
11243
11380
|
/**
|
|
@@ -11510,8 +11647,8 @@ class PlotBoilerplate {
|
|
|
11510
11647
|
* @return The vertex near the given position or undefined if none was found there.
|
|
11511
11648
|
**/
|
|
11512
11649
|
getVertexNear(pixelPosition, pixelTolerance) {
|
|
11513
|
-
var
|
|
11514
|
-
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));
|
|
11515
11652
|
if (p && p.typeName == "vertex") {
|
|
11516
11653
|
return this.vertices[p.vindex];
|
|
11517
11654
|
}
|
|
@@ -11940,8 +12077,8 @@ class PlotBoilerplate {
|
|
|
11940
12077
|
* @return {Bounds} The current viewport.
|
|
11941
12078
|
**/
|
|
11942
12079
|
viewport() {
|
|
11943
|
-
var
|
|
11944
|
-
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)));
|
|
11945
12082
|
}
|
|
11946
12083
|
/**
|
|
11947
12084
|
* Trigger the saveFile.hook.
|
|
@@ -11989,12 +12126,12 @@ class PlotBoilerplate {
|
|
|
11989
12126
|
* @return {void}
|
|
11990
12127
|
**/
|
|
11991
12128
|
resizeCanvas() {
|
|
11992
|
-
var
|
|
12129
|
+
var _b, _c, _d, _e, _f, _g;
|
|
11993
12130
|
const _self = this;
|
|
11994
12131
|
const _setSize = (w, h) => {
|
|
11995
|
-
var
|
|
11996
|
-
w *= (
|
|
11997
|
-
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;
|
|
11998
12135
|
_self.canvasSize.width = w;
|
|
11999
12136
|
_self.canvasSize.height = h;
|
|
12000
12137
|
if (_self.canvas instanceof HTMLCanvasElement) {
|
|
@@ -12023,8 +12160,8 @@ class PlotBoilerplate {
|
|
|
12023
12160
|
var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
12024
12161
|
var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
12025
12162
|
_self.canvas.style.position = "absolute";
|
|
12026
|
-
_self.canvas.style.width = ((
|
|
12027
|
-
_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";
|
|
12028
12165
|
_self.canvas.style.top = "0px";
|
|
12029
12166
|
_self.canvas.style.left = "0px";
|
|
12030
12167
|
_setSize(width, height);
|
|
@@ -12033,8 +12170,8 @@ class PlotBoilerplate {
|
|
|
12033
12170
|
// Set editor size
|
|
12034
12171
|
_self.canvas.style.position = "static";
|
|
12035
12172
|
const space = this.getAvailableContainerSpace();
|
|
12036
|
-
_self.canvas.style.width = ((
|
|
12037
|
-
_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";
|
|
12038
12175
|
_self.canvas.style.top = "";
|
|
12039
12176
|
_self.canvas.style.left = "";
|
|
12040
12177
|
_setSize(space.width, space.height);
|
|
@@ -12042,7 +12179,7 @@ class PlotBoilerplate {
|
|
|
12042
12179
|
else {
|
|
12043
12180
|
_self.canvas.style.width = "";
|
|
12044
12181
|
_self.canvas.style.height = "";
|
|
12045
|
-
_setSize((
|
|
12182
|
+
_setSize((_f = _self.config.defaultCanvasWidth) !== null && _f !== void 0 ? _f : 1024, (_g = _self.config.defaultCanvasHeight) !== null && _g !== void 0 ? _g : 768);
|
|
12046
12183
|
}
|
|
12047
12184
|
if (_self.config.redrawOnResize)
|
|
12048
12185
|
_self.redraw();
|
|
@@ -12545,7 +12682,9 @@ class PlotBoilerplate {
|
|
|
12545
12682
|
}
|
|
12546
12683
|
}; // END afProps
|
|
12547
12684
|
if (window["createAlloyFinger"]) {
|
|
12548
|
-
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);
|
|
12549
12688
|
}
|
|
12550
12689
|
else {
|
|
12551
12690
|
/* tslint:disable-next-line */
|
|
@@ -12603,10 +12742,15 @@ class PlotBoilerplate {
|
|
|
12603
12742
|
createGUI(props) {
|
|
12604
12743
|
// This function moved to the helper utils.
|
|
12605
12744
|
// We do not want to include the whole dat.GUI package.
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
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 {
|
|
12609
12752
|
throw "Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?";
|
|
12753
|
+
}
|
|
12610
12754
|
}
|
|
12611
12755
|
} // END class PlotBoilerplate
|
|
12612
12756
|
/** @constant {number} */
|
|
@@ -12634,6 +12778,7 @@ PlotBoilerplate.Draggable = (_a = class {
|
|
|
12634
12778
|
return this;
|
|
12635
12779
|
}
|
|
12636
12780
|
},
|
|
12781
|
+
__setFunctionName(_a, "Draggable"),
|
|
12637
12782
|
_a.VERTEX = "vertex",
|
|
12638
12783
|
_a);
|
|
12639
12784
|
/**
|
|
@@ -12723,7 +12868,8 @@ PlotBoilerplate.utils = {
|
|
|
12723
12868
|
* @return {void}
|
|
12724
12869
|
**/
|
|
12725
12870
|
setCSSscale: (element, scaleX, scaleY) => {
|
|
12726
|
-
element.style["transform-origin"] = "0 0";
|
|
12871
|
+
// element.style["transform-origin"] = "0 0";
|
|
12872
|
+
element.style.transformOrigin = "0 0";
|
|
12727
12873
|
if (scaleX == 1.0 && scaleY == 1.0) {
|
|
12728
12874
|
// element.style.transform = null;
|
|
12729
12875
|
element.style.removeProperty("transform");
|
|
@@ -12806,7 +12952,7 @@ PlotBoilerplate.utils = {
|
|
|
12806
12952
|
return fallback;
|
|
12807
12953
|
return obj[key];
|
|
12808
12954
|
}
|
|
12809
|
-
},
|
|
12955
|
+
}, // END fetch
|
|
12810
12956
|
/**
|
|
12811
12957
|
* Installs vertex listeners to the path's vertices so that controlpoints
|
|
12812
12958
|
* move with their path points when dragged.
|