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/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The main script of the generic plotter.
|
|
3
3
|
*
|
|
4
4
|
* @requires PlotBoilerplate, MouseHandler, gup, dat.gui, draw
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @projectname Plotboilerplate.js
|
|
7
7
|
* @author Ikaros Kappler
|
|
8
8
|
* @date 2018-10-23
|
|
@@ -13,131 +13,126 @@
|
|
|
13
13
|
* @version 1.0.4
|
|
14
14
|
**/
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
window.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
})(window);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
16
|
+
(function (_context) {
|
|
17
|
+
"use strict";
|
|
18
|
+
|
|
19
|
+
window.initializePB = function () {
|
|
20
|
+
if (window.pbInitialized) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
window.pbInitialized = true;
|
|
24
|
+
// Fetch the GET params
|
|
25
|
+
let GUP = gup();
|
|
26
|
+
var isInitialized = false;
|
|
27
|
+
|
|
28
|
+
// All config params are optional.
|
|
29
|
+
var pb = new PlotBoilerplate(
|
|
30
|
+
PlotBoilerplate.utils.safeMergeByKeys(
|
|
31
|
+
{
|
|
32
|
+
canvas: document.getElementById("my-canvas"),
|
|
33
|
+
fullSize: true,
|
|
34
|
+
fitToParent: true,
|
|
35
|
+
scaleX: 1.0,
|
|
36
|
+
scaleY: 1.0,
|
|
37
|
+
rasterGrid: true,
|
|
38
|
+
drawOrigin: true,
|
|
39
|
+
rasterAdjustFactor: 2.0,
|
|
40
|
+
redrawOnResize: true,
|
|
41
|
+
defaultCanvasWidth: 1024,
|
|
42
|
+
defaultCanvasHeight: 768,
|
|
43
|
+
canvasWidthFactor: 1.0,
|
|
44
|
+
canvasHeightFactor: 1.0,
|
|
45
|
+
cssScaleX: 1.0,
|
|
46
|
+
cssScaleY: 1.0,
|
|
47
|
+
cssUniformScale: true,
|
|
48
|
+
autoAdjustOffset: true,
|
|
49
|
+
offsetAdjustXPercent: 50,
|
|
50
|
+
offsetAdjustYPercent: 50,
|
|
51
|
+
autoDetectRetina: false,
|
|
52
|
+
backgroundColor: "#ffffff",
|
|
53
|
+
enableMouse: true,
|
|
54
|
+
enableTouch: true,
|
|
55
|
+
enableKeys: true,
|
|
56
|
+
enableGL: false // experimental
|
|
57
|
+
},
|
|
58
|
+
GUP
|
|
59
|
+
)
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (typeof humane != "undefined") {
|
|
63
|
+
pb.setConsole({
|
|
64
|
+
warn: function () {
|
|
65
|
+
console.warn(arguments);
|
|
66
|
+
humane.log(arguments[0]);
|
|
67
|
+
},
|
|
68
|
+
log: function () {
|
|
69
|
+
console.log(arguments);
|
|
70
|
+
// humane.log(arguments[0]);
|
|
71
|
+
},
|
|
72
|
+
error: function () {
|
|
73
|
+
console.error(arguments);
|
|
74
|
+
humane.log(arguments[0]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
humane.log("plotboilerplate");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// +---------------------------------------------------------------------------------
|
|
81
|
+
// | Initialize dat.gui
|
|
82
|
+
// +-------------------------------
|
|
83
|
+
pb.createGUI();
|
|
84
|
+
|
|
85
|
+
// +---------------------------------------------------------------------------------
|
|
86
|
+
// | Add stats.
|
|
87
|
+
// +-------------------------------
|
|
88
|
+
var stats = {
|
|
89
|
+
mouseX: 0,
|
|
90
|
+
mouseY: 0
|
|
91
|
+
};
|
|
92
|
+
var uiStats = new UIStats(stats);
|
|
93
|
+
stats = uiStats.proxy;
|
|
94
|
+
uiStats.add("mouseX");
|
|
95
|
+
uiStats.add("mouseY");
|
|
96
|
+
|
|
97
|
+
// +---------------------------------------------------------------------------------
|
|
98
|
+
// | Add a mouse listener to track the mouse position.
|
|
99
|
+
// +-------------------------------
|
|
100
|
+
new MouseHandler(pb.eventCatcher).move(function (e) {
|
|
101
|
+
var relPos = pb.transformMousePosition(e.params.pos.x, e.params.pos.y);
|
|
102
|
+
stats.mouseX = relPos.x;
|
|
103
|
+
stats.mouseY = relPos.y;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Use a helper function to build all demo-drawables.
|
|
107
|
+
var drawables = createDemoDrawables(pb, "example-image.png", function () {
|
|
108
|
+
if (isInitialized) {
|
|
109
|
+
pb.redraw();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
pb.add(drawables);
|
|
113
|
+
|
|
114
|
+
// Retrieve desired drawables from the array.
|
|
115
|
+
var polygon = drawables[9];
|
|
116
|
+
var triangles = [drawables[17], drawables[18], drawables[19], drawables[20]];
|
|
117
|
+
|
|
118
|
+
function animate(time) {
|
|
119
|
+
polygon.rotate(0.01);
|
|
120
|
+
pb.redraw();
|
|
121
|
+
window.requestAnimationFrame(animate);
|
|
122
|
+
}
|
|
123
|
+
if (GUP.hasOwnProperty("animate") && PlotBoilerplate.utils.fetch.bool(GUP, "animate", true)) {
|
|
124
|
+
console.log("Staring animation");
|
|
125
|
+
animate(0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
pb.config.postDraw = function () {
|
|
129
|
+
for (var i in triangles) {
|
|
130
|
+
var circle = triangles[i].getIncircle();
|
|
131
|
+
pb.fill.circle(circle.center, circle.radius, "rgba(192,192,192,0.33)", 1.0);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
isInitialized = true;
|
|
135
|
+
}; // End initializePB
|
|
136
|
+
|
|
137
|
+
if (!window.pbPreventAutoLoad) window.addEventListener("load", window.initializePB);
|
|
138
|
+
})(window);
|
package/src/ts/CircleSector.ts
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
* @date 2020-12-17
|
|
4
4
|
* @modified 2021-01-20 Added UID.
|
|
5
5
|
* @modified 2021-02-26 Fixed an error in the svg-arc-calculation (case angle<90deg and anti-clockwise).
|
|
6
|
-
* @
|
|
6
|
+
* @modified 2024-01-30 Added a missing type in the `describeSVGArc` function.
|
|
7
|
+
* @modified 2024-03-01 Added the `getStartPoint` and `getEndPoint` methods.
|
|
8
|
+
* @modified 2024-03-08 Added the `containsAngle` method.
|
|
9
|
+
* @modified 2024-03-09 Added the `circleSectorIntersection` method to find coherent sector intersections..
|
|
10
|
+
* @modified 2024-03-09 Added the `angleAt` method to determine any angle at some ratio.
|
|
11
|
+
* @version 1.2.0
|
|
7
12
|
**/
|
|
8
13
|
|
|
9
14
|
import { Circle } from "./Circle";
|
|
15
|
+
import { Line } from "./Line";
|
|
10
16
|
import { UIDGenerator } from "./UIDGenerator";
|
|
11
|
-
import {
|
|
17
|
+
import { Vertex } from "./Vertex";
|
|
18
|
+
import { PathSegment, SVGPathParams, SVGSerializable, UID, XYCoords } from "./interfaces";
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* @classdesc A simple circle sector: circle, start- and end-angle.
|
|
@@ -80,10 +87,134 @@ export class CircleSector implements SVGSerializable {
|
|
|
80
87
|
this.endAngle = endAngle;
|
|
81
88
|
}
|
|
82
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Checks wether the given angle (must be inside 0 and PI*2) is contained inside this sector.
|
|
92
|
+
*
|
|
93
|
+
* @param {number} angle - The numeric angle to check.
|
|
94
|
+
* @method containsAngle
|
|
95
|
+
* @instance
|
|
96
|
+
* @memberof CircleSector
|
|
97
|
+
* @return {boolean} True if (and only if) this sector contains the given angle.
|
|
98
|
+
*/
|
|
99
|
+
containsAngle(angle: number) {
|
|
100
|
+
if (this.startAngle <= this.endAngle) {
|
|
101
|
+
return angle >= this.startAngle && angle < this.endAngle;
|
|
102
|
+
} else {
|
|
103
|
+
// startAngle > endAngle
|
|
104
|
+
return angle >= this.startAngle || angle < this.endAngle;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Get the angle inside this sector for a given ratio. 0.0 means startAngle, and 1.0 means endAngle.
|
|
110
|
+
*
|
|
111
|
+
* @param {number} t - The ratio inside [0..1].
|
|
112
|
+
* @method angleAt
|
|
113
|
+
* @instance
|
|
114
|
+
* @memberof CircleSector
|
|
115
|
+
* @return {number} The angle inside this sector at a given ratio.
|
|
116
|
+
*/
|
|
117
|
+
angleAt(t: number): number {
|
|
118
|
+
if (this.startAngle <= this.endAngle) {
|
|
119
|
+
const angleAtRatio: number = this.startAngle + (this.endAngle - this.startAngle) * t;
|
|
120
|
+
return angleAtRatio % (Math.PI * 2.0);
|
|
121
|
+
} else {
|
|
122
|
+
// startAngle > endAngle
|
|
123
|
+
const angleAtRatio: number = this.startAngle + (Math.PI * 2 - this.startAngle + this.endAngle) * t;
|
|
124
|
+
return angleAtRatio % (Math.PI * 2.0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get the sectors starting point (on the underlying circle, located at the start angle).
|
|
130
|
+
*
|
|
131
|
+
* @method getStartPoint
|
|
132
|
+
* @instance
|
|
133
|
+
* @memberof CircleSector
|
|
134
|
+
* @return {Vertex} The sector's stating point.
|
|
135
|
+
*/
|
|
136
|
+
getStartPoint(): Vertex {
|
|
137
|
+
return this.circle.vertAt(this.startAngle);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Get the sectors ending point (on the underlying circle, located at the end angle).
|
|
142
|
+
*
|
|
143
|
+
* @method getEndPoint
|
|
144
|
+
* @instance
|
|
145
|
+
* @memberof CircleSector
|
|
146
|
+
* @return {Vertex} The sector's ending point.
|
|
147
|
+
*/
|
|
148
|
+
getEndPoint(): Vertex {
|
|
149
|
+
return this.circle.vertAt(this.endAngle);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Calculate the intersection of this circle sector and some other sector.
|
|
154
|
+
*
|
|
155
|
+
* If the two sectors do not corerently intersect (when not both points of the
|
|
156
|
+
* radical line are containted in both source sectors) then null is returned.
|
|
157
|
+
*
|
|
158
|
+
* See demo/53-circle-sector-intersections for a geometric visualisation.
|
|
159
|
+
*
|
|
160
|
+
* @method circleSectorIntersection
|
|
161
|
+
* @instance
|
|
162
|
+
* @memberof CircleSector
|
|
163
|
+
* @return {CircleSector | null} The intersecion of both sectors or null if they don't intersect.
|
|
164
|
+
*/
|
|
165
|
+
circleSectorIntersection(sector: CircleSector): CircleSector | null {
|
|
166
|
+
const radicalLine: Line | null = this.circle.circleIntersection(sector.circle);
|
|
167
|
+
if (!radicalLine) {
|
|
168
|
+
// The circles to not intersect at all.
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
// Circles intersect. Check if this sector interval intersects, too.
|
|
172
|
+
const thisIntersectionAngleA = this.circle.center.angle(radicalLine.a);
|
|
173
|
+
const thisIntersectionAngleB = this.circle.center.angle(radicalLine.b);
|
|
174
|
+
// Is intersection inside this sector?
|
|
175
|
+
if (!this.containsAngle(thisIntersectionAngleA) || !this.containsAngle(thisIntersectionAngleB)) {
|
|
176
|
+
// At least one circle intersection point is not located in this sector.
|
|
177
|
+
// -> no valid intersection at all
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Circles intersect. Check if the passed sector interval intersects, too.
|
|
182
|
+
const thatIntersectionAngleA = sector.circle.center.angle(radicalLine.a);
|
|
183
|
+
const thatIntersectionAngleB = sector.circle.center.angle(radicalLine.b);
|
|
184
|
+
// Is intersection inside this sector?
|
|
185
|
+
if (!sector.containsAngle(thatIntersectionAngleA) || !sector.containsAngle(thatIntersectionAngleB)) {
|
|
186
|
+
// At least one circle intersection point is not located in this sector.
|
|
187
|
+
// -> no valid intersection at all
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// The radical line has no direction. Thus the resulting sector _might_ be in reverse order.
|
|
192
|
+
// Make a quick logical check: the center of the gap must still be located inside the result sector.
|
|
193
|
+
// If not: reverse result.
|
|
194
|
+
var gapSector = new CircleSector(this.circle, this.endAngle, this.startAngle);
|
|
195
|
+
var centerOfOriginalGap = gapSector.angleAt(0.5);
|
|
196
|
+
|
|
197
|
+
const resultSector = new CircleSector(
|
|
198
|
+
new Circle(this.circle.center.clone(), this.circle.radius),
|
|
199
|
+
thisIntersectionAngleA,
|
|
200
|
+
thisIntersectionAngleB
|
|
201
|
+
);
|
|
202
|
+
if (resultSector.containsAngle(centerOfOriginalGap)) {
|
|
203
|
+
resultSector.startAngle = thisIntersectionAngleB;
|
|
204
|
+
resultSector.endAngle = thisIntersectionAngleA;
|
|
205
|
+
}
|
|
206
|
+
return resultSector;
|
|
207
|
+
}
|
|
208
|
+
|
|
83
209
|
/**
|
|
84
210
|
* This function should invalidate any installed listeners and invalidate this object.
|
|
85
211
|
* After calling this function the object might not hold valid data any more and
|
|
86
212
|
* should not be used.
|
|
213
|
+
*
|
|
214
|
+
* @method destroy
|
|
215
|
+
* @instance
|
|
216
|
+
* @memberof CircleSector
|
|
217
|
+
* @return {void}
|
|
87
218
|
*/
|
|
88
219
|
destroy() {
|
|
89
220
|
this.circle.destroy();
|
|
@@ -161,7 +292,7 @@ export class CircleSector implements SVGSerializable {
|
|
|
161
292
|
sweepFlag = 1;
|
|
162
293
|
}
|
|
163
294
|
|
|
164
|
-
const pathData = [];
|
|
295
|
+
const pathData: SVGPathParams = [];
|
|
165
296
|
if (options.moveToStart) {
|
|
166
297
|
pathData.push("M", start.x, start.y);
|
|
167
298
|
}
|
|
@@ -389,7 +389,7 @@ export class PlotBoilerplate {
|
|
|
389
389
|
* Note that changes from the postDraw hook might not be visible in the export.
|
|
390
390
|
* @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
|
|
391
391
|
*/
|
|
392
|
-
constructor(config: PBParams) {
|
|
392
|
+
constructor(config: PBParams, drawConfig: DrawConfig) {
|
|
393
393
|
// This should be in some static block ...
|
|
394
394
|
VertexAttr.model = {
|
|
395
395
|
bezierAutoAdjust: false,
|
|
@@ -703,9 +703,10 @@ export class PlotBoilerplate {
|
|
|
703
703
|
var blob = new Blob(['<?xml version="1.0" encoding="utf-8"?>\n' + svgCode], { type: "image/svg;charset=utf-8" });
|
|
704
704
|
// See documentation for FileSaver.js for usage.
|
|
705
705
|
// https://github.com/eligrey/FileSaver.js
|
|
706
|
-
if (typeof globalThis["saveAs"] !== "function")
|
|
706
|
+
if (typeof globalThis["saveAs" as keyof Object] !== "function") {
|
|
707
707
|
throw "Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?";
|
|
708
|
-
|
|
708
|
+
}
|
|
709
|
+
var _saveAs : (blob:Blob, filename:string) => void = globalThis["saveAs" as keyof Object] as (blob:Blob, filename:string) => void;
|
|
709
710
|
_saveAs(blob, "plotboilerplate.svg");
|
|
710
711
|
}
|
|
711
712
|
|
|
@@ -2023,7 +2024,7 @@ export class PlotBoilerplate {
|
|
|
2023
2024
|
};
|
|
2024
2025
|
|
|
2025
2026
|
// Make PB work together with both, AlloyFinger as a esm module or a commonjs function.
|
|
2026
|
-
if (typeof globalThis["AlloyFinger"] === "function" || typeof globalThis["createAlloyFinger"] === "function") {
|
|
2027
|
+
if (typeof globalThis["AlloyFinger" as keyof Object] === "function" || typeof globalThis["createAlloyFinger" as keyof Object] === "function") {
|
|
2027
2028
|
try {
|
|
2028
2029
|
var touchMovePos: Vertex | undefined | null = null;
|
|
2029
2030
|
var touchDownPos: Vertex | undefined | null = null;
|
|
@@ -2159,8 +2160,10 @@ export class PlotBoilerplate {
|
|
|
2159
2160
|
_self.redraw();
|
|
2160
2161
|
}
|
|
2161
2162
|
} as unknown as AlloyFingerOptions; // END afProps
|
|
2162
|
-
if (window["createAlloyFinger"]) {
|
|
2163
|
-
window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
2163
|
+
if (window["createAlloyFinger" as keyof Object]) {
|
|
2164
|
+
// window["createAlloyFinger"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
2165
|
+
const createAlloyFinger = window["createAlloyFinger" as keyof Object] as (elem:HTMLElement|SVGElement, afProps:AlloyFingerOptions ) => void;
|
|
2166
|
+
createAlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
2164
2167
|
} else {
|
|
2165
2168
|
/* tslint:disable-next-line */
|
|
2166
2169
|
new AlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);
|
|
@@ -2169,7 +2172,7 @@ export class PlotBoilerplate {
|
|
|
2169
2172
|
console.error("Failed to initialize AlloyFinger!");
|
|
2170
2173
|
console.error(e);
|
|
2171
2174
|
}
|
|
2172
|
-
} else if (globalThis["Touchy"] && typeof globalThis["Touchy"] == "function") {
|
|
2175
|
+
} else if (globalThis["Touchy" as keyof Object] && typeof globalThis["Touchy" as keyof Object] == "function") {
|
|
2173
2176
|
console.error("[Deprecation] Found Touchy which is not supported any more. Please use AlloyFinger instead.");
|
|
2174
2177
|
// Convert absolute touch positions to relative DOM element position (relative to canvas)
|
|
2175
2178
|
} else {
|
|
@@ -2214,9 +2217,14 @@ export class PlotBoilerplate {
|
|
|
2214
2217
|
createGUI(props?: DatGuiProps): GUI {
|
|
2215
2218
|
// This function moved to the helper utils.
|
|
2216
2219
|
// We do not want to include the whole dat.GUI package.
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
+
const utils: {createGUI? : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI } | undefined = globalThis["utils" as keyof Object] as any as {createGUI? : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI } | undefined;
|
|
2221
|
+
// if (globalThis["utils"] && typeof globalThis["utils"].createGUI == "function") {
|
|
2222
|
+
// return (globalThis["utils" as keyof Object] as any as ({createGUI : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI })).createGUI(this, props);
|
|
2223
|
+
if (utils && typeof utils.createGUI === "function") {
|
|
2224
|
+
return utils.createGUI(this, props);
|
|
2225
|
+
} else {
|
|
2226
|
+
throw "Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?";
|
|
2227
|
+
}
|
|
2220
2228
|
}
|
|
2221
2229
|
|
|
2222
2230
|
/**
|
|
@@ -2301,7 +2309,8 @@ export class PlotBoilerplate {
|
|
|
2301
2309
|
* @return {void}
|
|
2302
2310
|
**/
|
|
2303
2311
|
setCSSscale: (element: HTMLElement | SVGElement, scaleX: number, scaleY: number): void => {
|
|
2304
|
-
element.style["transform-origin"] = "0 0";
|
|
2312
|
+
// element.style["transform-origin"] = "0 0";
|
|
2313
|
+
element.style.transformOrigin = "0 0";
|
|
2305
2314
|
if (scaleX == 1.0 && scaleY == 1.0) {
|
|
2306
2315
|
// element.style.transform = null;
|
|
2307
2316
|
element.style.removeProperty("transform");
|
package/src/ts/Vertex.ts
CHANGED
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
* @modified 2022-11-28 Added the `subXY`, `subX` and `subY` methods to the `Vertex` class.
|
|
32
32
|
* @modified 2023-09-29 Downgraded types for the `Vertex.utils.buildArrowHead` function (replacing Vertex params by more generic XYCoords type).
|
|
33
33
|
* @modified 2023-09-29 Added the `Vertex.abs()` method as it seems useful.
|
|
34
|
-
* @
|
|
34
|
+
* @modified 2024-03-08 Added the optional `precision` param to the `toString` method.
|
|
35
|
+
* @version 2.9.0
|
|
35
36
|
*
|
|
36
37
|
* @file Vertex
|
|
37
38
|
* @public
|
|
@@ -631,8 +632,12 @@ export class Vertex implements XYCoords, SVGSerializable {
|
|
|
631
632
|
* @instance
|
|
632
633
|
* @memberof Vertex
|
|
633
634
|
**/
|
|
634
|
-
toString(): string {
|
|
635
|
-
|
|
635
|
+
toString(precision?: number): string {
|
|
636
|
+
if (typeof precision === "undefined") {
|
|
637
|
+
return "(" + this.x + "," + this.y + ")";
|
|
638
|
+
} else {
|
|
639
|
+
return "(" + this.x.toFixed(precision) + "," + this.y.toFixed(precision) + ")";
|
|
640
|
+
}
|
|
636
641
|
}
|
|
637
642
|
|
|
638
643
|
/**
|
package/src/ts/VertexAttr.ts
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
|
|
@@ -76,7 +77,7 @@ export class VertexAttr implements IVertexAttr {
|
|
|
76
77
|
this.visible = true;
|
|
77
78
|
|
|
78
79
|
for( var key in VertexAttr.model )
|
|
79
|
-
this[key] = VertexAttr.model[key];
|
|
80
|
+
this[key as keyof VertexAttr] = VertexAttr.model[key as keyof IVertexAttr] as any as boolean;
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
|