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/cjs/drawutilssvg.js
CHANGED
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
* @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
|
|
46
46
|
* @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
|
|
47
47
|
* @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
|
|
48
|
-
*
|
|
49
|
-
* @
|
|
48
|
+
* @modified 2024-01-30 Fixing an issue with immutable style sets; changes to the global draw config did not reflect here (do now).
|
|
49
|
+
* @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
|
|
50
|
+
* @version 1.6.9
|
|
50
51
|
**/
|
|
51
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
53
|
exports.drawutilssvg = void 0;
|
|
@@ -66,6 +67,10 @@ var RAD_TO_DEG = 180 / Math.PI;
|
|
|
66
67
|
* @requires XYCoords
|
|
67
68
|
*/
|
|
68
69
|
var drawutilssvg = /** @class */ (function () {
|
|
70
|
+
/**
|
|
71
|
+
* Passed from primary to secondary instance.
|
|
72
|
+
*/
|
|
73
|
+
//private nodeStyle: SVGStyleElement;
|
|
69
74
|
/**
|
|
70
75
|
* The constructor.
|
|
71
76
|
*
|
|
@@ -80,12 +85,13 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
80
85
|
* @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.
|
|
81
86
|
* @param {SVGGElement=} gNode - (optional) Primary and seconday instances share the same <g> node.
|
|
82
87
|
**/
|
|
83
|
-
function drawutilssvg(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs) {
|
|
88
|
+
function drawutilssvg(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs, nodeStyle) {
|
|
84
89
|
this.svgNode = svgNode;
|
|
85
90
|
this.offset = new Vertex_1.Vertex(0, 0).set(offset);
|
|
86
91
|
this.scale = new Vertex_1.Vertex(1, 1).set(scale);
|
|
87
92
|
this.fillShapes = fillShapes;
|
|
88
93
|
this.isSecondary = Boolean(isSecondary);
|
|
94
|
+
this.drawConfig = drawConfig;
|
|
89
95
|
this.drawlibConfiguration = {};
|
|
90
96
|
this.cache = new Map();
|
|
91
97
|
this.setSize(canvasSize);
|
|
@@ -97,6 +103,9 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
97
103
|
this.bufferGNode = bufferGNode;
|
|
98
104
|
this.nodeDefs = nodeDefs;
|
|
99
105
|
this.bufferedNodeDefs = bufferNodeDefs;
|
|
106
|
+
if (nodeStyle) {
|
|
107
|
+
this.nodeStyle = nodeStyle;
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
else {
|
|
102
111
|
this.addStyleDefs(drawConfig);
|
|
@@ -115,11 +124,19 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
115
124
|
drawutilssvg.prototype.addStyleDefs = function (drawConfig) {
|
|
116
125
|
this.nodeStyle = this.createSVGNode("style");
|
|
117
126
|
this.svgNode.appendChild(this.nodeStyle);
|
|
127
|
+
this.rebuildStyleDefs(drawConfig);
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* This method is required to re-define the global style defs. It is needed
|
|
131
|
+
* if any value in the DrawConfig changed in the meantime.
|
|
132
|
+
* @param drawConfig
|
|
133
|
+
*/
|
|
134
|
+
drawutilssvg.prototype.rebuildStyleDefs = function (drawConfig) {
|
|
118
135
|
// Which default styles to add? -> All from the DrawConfig.
|
|
119
136
|
// Compare with DrawConfig interface
|
|
120
137
|
var keys = {
|
|
121
|
-
|
|
122
|
-
"bezierPath": "BezierPath",
|
|
138
|
+
"bezier": "CubicBezierCurve",
|
|
139
|
+
//"bezierPath": "BezierPath", // TODO: is this correct?
|
|
123
140
|
"polygon": "Polygon",
|
|
124
141
|
"triangle": "Triangle",
|
|
125
142
|
"ellipse": "Ellipse",
|
|
@@ -134,14 +151,15 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
134
151
|
};
|
|
135
152
|
// Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)
|
|
136
153
|
var rules = [];
|
|
154
|
+
// console.log("drawConfig", drawConfig);
|
|
137
155
|
for (var k in keys) {
|
|
138
156
|
var className = keys[k];
|
|
139
157
|
var drawSettings = drawConfig[k];
|
|
140
158
|
if (drawSettings) {
|
|
141
|
-
rules.push("."
|
|
159
|
+
rules.push(".".concat(className, " { fill : none; stroke: ").concat(drawSettings.color, "; stroke-width: ").concat(drawSettings.lineWidth, "px }"));
|
|
142
160
|
}
|
|
143
161
|
else {
|
|
144
|
-
console.warn("Warning: your draw config is missing the key '"
|
|
162
|
+
console.warn("Warning: your draw config is missing the key '".concat(k, "' which is required."));
|
|
145
163
|
}
|
|
146
164
|
}
|
|
147
165
|
this.nodeStyle.innerHTML = rules.join("\n");
|
|
@@ -231,7 +249,8 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
231
249
|
node = this.createSVGNode(nodeName);
|
|
232
250
|
}
|
|
233
251
|
if (this.drawlibConfiguration.blendMode) {
|
|
234
|
-
node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
|
|
252
|
+
// node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
|
|
253
|
+
node.style["mix-blend-mode"](this.drawlibConfiguration.blendMode);
|
|
235
254
|
}
|
|
236
255
|
// if (this.lineDashEnabled && this.lineDash && this.lineDash.length > 0 && drawutilssvg.nodeSupportsLineDash(nodeName)) {
|
|
237
256
|
// node.setAttribute("stroke-dasharray", this.lineDash.join(" "));
|
|
@@ -295,7 +314,7 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
295
314
|
*/
|
|
296
315
|
drawutilssvg.prototype._addCSSClasses = function (node, className) {
|
|
297
316
|
if (this.curClassName) {
|
|
298
|
-
node.setAttribute("class", className
|
|
317
|
+
node.setAttribute("class", "".concat(className, " ").concat(this.curClassName));
|
|
299
318
|
}
|
|
300
319
|
else {
|
|
301
320
|
node.setAttribute("class", className);
|
|
@@ -305,9 +324,9 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
305
324
|
this._addCSSClasses(node, className);
|
|
306
325
|
node.setAttribute("fill", fillMode && color ? color : "none");
|
|
307
326
|
node.setAttribute("stroke", fillMode ? "none" : color || "none");
|
|
308
|
-
node.setAttribute("stroke-width", ""
|
|
327
|
+
node.setAttribute("stroke-width", "".concat(lineWidth || 1));
|
|
309
328
|
if (this.curId) {
|
|
310
|
-
node.setAttribute("id", ""
|
|
329
|
+
node.setAttribute("id", "".concat(this.curId)); // Maybe React-style 'key' would be better?
|
|
311
330
|
}
|
|
312
331
|
this.applyStrokeOpts(node, strokeOptions);
|
|
313
332
|
return node;
|
|
@@ -322,18 +341,18 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
322
341
|
*/
|
|
323
342
|
drawutilssvg.prototype.setSize = function (canvasSize) {
|
|
324
343
|
this.canvasSize = canvasSize;
|
|
325
|
-
this.svgNode.setAttribute("viewBox", "0 0 "
|
|
326
|
-
this.svgNode.setAttribute("width", ""
|
|
327
|
-
this.svgNode.setAttribute("height", ""
|
|
344
|
+
this.svgNode.setAttribute("viewBox", "0 0 ".concat(this.canvasSize.width, " ").concat(this.canvasSize.height));
|
|
345
|
+
this.svgNode.setAttribute("width", "".concat(this.canvasSize.width));
|
|
346
|
+
this.svgNode.setAttribute("height", "".concat(this.canvasSize.height));
|
|
328
347
|
};
|
|
329
348
|
/**
|
|
330
349
|
* Creates a 'shallow' (non deep) copy of this instance. This implies
|
|
331
350
|
* that under the hood the same gl context and gl program will be used.
|
|
332
351
|
*/
|
|
333
352
|
drawutilssvg.prototype.copyInstance = function (fillShapes) {
|
|
334
|
-
var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig – this will work as long as `isSecondary===true`
|
|
353
|
+
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`
|
|
335
354
|
true, // isSecondary
|
|
336
|
-
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);
|
|
355
|
+
this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs, this.nodeStyle);
|
|
337
356
|
return copy;
|
|
338
357
|
};
|
|
339
358
|
/**
|
|
@@ -346,20 +365,6 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
346
365
|
drawutilssvg.prototype.setConfiguration = function (configuration) {
|
|
347
366
|
this.drawlibConfiguration = configuration;
|
|
348
367
|
};
|
|
349
|
-
// /**
|
|
350
|
-
// * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
|
|
351
|
-
// *
|
|
352
|
-
// * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
|
|
353
|
-
// * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
|
|
354
|
-
// * for how line dashes work.
|
|
355
|
-
// *
|
|
356
|
-
// * @method
|
|
357
|
-
// * @param {Array<number> lineDashes - The line-dash array configuration.
|
|
358
|
-
// * @returns {void}
|
|
359
|
-
// */
|
|
360
|
-
// setLineDash(lineDashes: Array<number>) {
|
|
361
|
-
// this.lineDash = lineDashes;
|
|
362
|
-
// }
|
|
363
368
|
/**
|
|
364
369
|
* This method shouled be called each time the currently drawn `Drawable` changes.
|
|
365
370
|
* It is used by some libraries for identifying elemente on re-renders.
|
|
@@ -419,6 +424,7 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
419
424
|
* @instance
|
|
420
425
|
**/
|
|
421
426
|
drawutilssvg.prototype.endDrawCycle = function (renderTime) {
|
|
427
|
+
this.rebuildStyleDefs(this.drawConfig);
|
|
422
428
|
if (!this.isSecondary) {
|
|
423
429
|
// All elements are drawn into the buffer; they are NOT yet visible, not did the browser perform any
|
|
424
430
|
// layout updates.
|
|
@@ -451,7 +457,7 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
451
457
|
})
|
|
452
458
|
.join(" "));
|
|
453
459
|
if (strokeOptions.dashOffset) {
|
|
454
|
-
node.setAttribute("stroke-dashoffset", ""
|
|
460
|
+
node.setAttribute("stroke-dashoffset", "".concat(strokeOptions.dashOffset * this.scale.x));
|
|
455
461
|
}
|
|
456
462
|
}
|
|
457
463
|
};
|
|
@@ -587,13 +593,13 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
587
593
|
if (image.naturalWidth) {
|
|
588
594
|
var ratioX = size.x / image.naturalWidth;
|
|
589
595
|
var ratioY = size.y / image.naturalHeight;
|
|
590
|
-
node.setAttribute("width", ""
|
|
591
|
-
node.setAttribute("height", ""
|
|
596
|
+
node.setAttribute("width", "".concat(image.naturalWidth * _this.scale.x));
|
|
597
|
+
node.setAttribute("height", "".concat(image.naturalHeight * _this.scale.y));
|
|
592
598
|
node.setAttribute("display", null); // Dislay when loaded
|
|
593
599
|
// if (alpha) {
|
|
594
|
-
node.setAttribute("opacity", ""
|
|
600
|
+
node.setAttribute("opacity", "".concat(alpha));
|
|
595
601
|
// }
|
|
596
|
-
node.setAttribute("transform", "translate("
|
|
602
|
+
node.setAttribute("transform", "translate(".concat(_this._x(position.x), " ").concat(_this._y(position.y), ") scale(").concat(ratioX, " ").concat(ratioY, ")"));
|
|
597
603
|
}
|
|
598
604
|
};
|
|
599
605
|
image.addEventListener("load", function (event) {
|
|
@@ -601,8 +607,8 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
601
607
|
});
|
|
602
608
|
// Safari has a transform-origin bug.
|
|
603
609
|
// Use x=0, y=0 and translate/scale instead (see above)
|
|
604
|
-
node.setAttribute("x", ""
|
|
605
|
-
node.setAttribute("y", ""
|
|
610
|
+
node.setAttribute("x", "".concat(0));
|
|
611
|
+
node.setAttribute("y", "".concat(0));
|
|
606
612
|
node.setAttribute("display", "none"); // Hide before loaded
|
|
607
613
|
setImageSize(image);
|
|
608
614
|
node.setAttribute("href", image.src);
|
|
@@ -643,36 +649,36 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
643
649
|
// </image>
|
|
644
650
|
// ...
|
|
645
651
|
var clipPathNode = this.makeNode("clipPath");
|
|
646
|
-
var clipPathId = "clippath_"
|
|
652
|
+
var clipPathId = "clippath_".concat(UIDGenerator_1.UIDGenerator.next()); // TODO: use a better UUID generator here?
|
|
647
653
|
clipPathNode.setAttribute("id", clipPathId);
|
|
648
654
|
var gNode = this.makeNode("g");
|
|
649
655
|
var imageNode = this.makeNode("image");
|
|
650
|
-
imageNode.setAttribute("x", ""
|
|
651
|
-
imageNode.setAttribute("y", ""
|
|
652
|
-
imageNode.setAttribute("width", ""
|
|
653
|
-
imageNode.setAttribute("height", ""
|
|
656
|
+
imageNode.setAttribute("x", "".concat(this._x(rotatedScalingOrigin.x)));
|
|
657
|
+
imageNode.setAttribute("y", "".concat(this._y(rotatedScalingOrigin.y)));
|
|
658
|
+
imageNode.setAttribute("width", "".concat(textureSize.width));
|
|
659
|
+
imageNode.setAttribute("height", "".concat(textureSize.height));
|
|
654
660
|
imageNode.setAttribute("href", textureImage.src);
|
|
655
661
|
// imageNode.setAttribute("opacity", "0.5");
|
|
656
662
|
// SVG rotations in degrees
|
|
657
|
-
imageNode.setAttribute("transform", "rotate("
|
|
663
|
+
imageNode.setAttribute("transform", "rotate(".concat(rotation * RAD_TO_DEG, ", ").concat(this._x(rotatedScalingOrigin.x), ", ").concat(this._y(rotatedScalingOrigin.y), ")"));
|
|
658
664
|
var pathNode = this.makeNode("path");
|
|
659
665
|
var pathData = [];
|
|
660
666
|
if (polygon.vertices.length > 0) {
|
|
661
667
|
var self_1 = this;
|
|
662
|
-
pathData.push("M", ""
|
|
668
|
+
pathData.push("M", "".concat(this._x(polygon.vertices[0].x)), "".concat(this._y(polygon.vertices[0].y)));
|
|
663
669
|
for (var i = 1; i < polygon.vertices.length; i++) {
|
|
664
|
-
pathData.push("L", ""
|
|
670
|
+
pathData.push("L", "".concat(this._x(polygon.vertices[i].x)), "".concat(this._y(polygon.vertices[i].y)));
|
|
665
671
|
}
|
|
666
672
|
}
|
|
667
673
|
pathNode.setAttribute("d", pathData.join(" "));
|
|
668
674
|
clipPathNode.appendChild(pathNode);
|
|
669
675
|
this.bufferedNodeDefs.appendChild(clipPathNode);
|
|
670
676
|
gNode.appendChild(imageNode);
|
|
671
|
-
gNode.setAttribute("transform-origin", this._x(rotatedScalingOrigin.x)
|
|
672
|
-
gNode.setAttribute("transform", "scale("
|
|
677
|
+
gNode.setAttribute("transform-origin", "".concat(this._x(rotatedScalingOrigin.x), " ").concat(this._y(rotatedScalingOrigin.y)));
|
|
678
|
+
gNode.setAttribute("transform", "scale(".concat(this.scale.x, ", ").concat(this.scale.y, ")"));
|
|
673
679
|
var clipNode = this.makeNode("g");
|
|
674
680
|
clipNode.appendChild(gNode);
|
|
675
|
-
clipNode.setAttribute("clip-path", "url(#"
|
|
681
|
+
clipNode.setAttribute("clip-path", "url(#".concat(clipPathId, ")"));
|
|
676
682
|
// TODO: check if the image class is correct here or if we should use a 'clippedImage' class here
|
|
677
683
|
this._bindFillDraw(clipNode, "image", null, null); // No color, no lineWidth
|
|
678
684
|
return clipNode;
|
|
@@ -777,10 +783,10 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
777
783
|
*/
|
|
778
784
|
drawutilssvg.prototype.dot = function (p, color) {
|
|
779
785
|
var node = this.makeNode("line");
|
|
780
|
-
node.setAttribute("x1", ""
|
|
781
|
-
node.setAttribute("y1", ""
|
|
782
|
-
node.setAttribute("x2", ""
|
|
783
|
-
node.setAttribute("y2", ""
|
|
786
|
+
node.setAttribute("x1", "".concat(this._x(p.x)));
|
|
787
|
+
node.setAttribute("y1", "".concat(this._y(p.y)));
|
|
788
|
+
node.setAttribute("x2", "".concat(this._x(p.x)));
|
|
789
|
+
node.setAttribute("y2", "".concat(this._y(p.y)));
|
|
784
790
|
return this._bindFillDraw(node, "dot", color, 1);
|
|
785
791
|
};
|
|
786
792
|
/**
|
|
@@ -796,9 +802,9 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
796
802
|
drawutilssvg.prototype.point = function (p, color) {
|
|
797
803
|
var radius = 3;
|
|
798
804
|
var node = this.makeNode("circle");
|
|
799
|
-
node.setAttribute("cx", ""
|
|
800
|
-
node.setAttribute("cy", ""
|
|
801
|
-
node.setAttribute("r", ""
|
|
805
|
+
node.setAttribute("cx", "".concat(this._x(p.x)));
|
|
806
|
+
node.setAttribute("cy", "".concat(this._y(p.y)));
|
|
807
|
+
node.setAttribute("r", "".concat(radius));
|
|
802
808
|
return this._bindFillDraw(node, "point", color, 1);
|
|
803
809
|
};
|
|
804
810
|
/**
|
|
@@ -821,9 +827,9 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
821
827
|
// Todo: draw ellipse when scalex!=scaley
|
|
822
828
|
var node = this.makeNode("circle");
|
|
823
829
|
this.applyStrokeOpts(node, strokeOptions);
|
|
824
|
-
node.setAttribute("cx", ""
|
|
825
|
-
node.setAttribute("cy", ""
|
|
826
|
-
node.setAttribute("r", ""
|
|
830
|
+
node.setAttribute("cx", "".concat(this._x(center.x)));
|
|
831
|
+
node.setAttribute("cy", "".concat(this._y(center.y)));
|
|
832
|
+
node.setAttribute("r", "".concat(radius * this.scale.x)); // y?
|
|
827
833
|
return this._bindFillDraw(node, "circle", color, lineWidth || 1);
|
|
828
834
|
};
|
|
829
835
|
/**
|
|
@@ -871,12 +877,12 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
871
877
|
}
|
|
872
878
|
var node = this.makeNode("ellipse");
|
|
873
879
|
this.applyStrokeOpts(node, strokeOptions);
|
|
874
|
-
node.setAttribute("cx", ""
|
|
875
|
-
node.setAttribute("cy", ""
|
|
876
|
-
node.setAttribute("rx", ""
|
|
877
|
-
node.setAttribute("ry", ""
|
|
880
|
+
node.setAttribute("cx", "".concat(this._x(center.x)));
|
|
881
|
+
node.setAttribute("cy", "".concat(this._y(center.y)));
|
|
882
|
+
node.setAttribute("rx", "".concat(radiusX * this.scale.x));
|
|
883
|
+
node.setAttribute("ry", "".concat(radiusY * this.scale.y));
|
|
878
884
|
// node.setAttribute( 'style', `transform: rotate(${rotation} ${center.x} ${center.y})` );
|
|
879
|
-
node.setAttribute("transform", "rotate("
|
|
885
|
+
node.setAttribute("transform", "rotate(".concat((rotation * 180) / Math.PI, " ").concat(this._x(center.x), " ").concat(this._y(center.y), ")"));
|
|
880
886
|
return this._bindFillDraw(node, "ellipse", color, lineWidth || 1);
|
|
881
887
|
};
|
|
882
888
|
/**
|
|
@@ -898,10 +904,10 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
898
904
|
drawutilssvg.prototype.square = function (center, size, color, lineWidth, strokeOptions) {
|
|
899
905
|
var node = this.makeNode("rectangle");
|
|
900
906
|
this.applyStrokeOpts(node, strokeOptions);
|
|
901
|
-
node.setAttribute("x", ""
|
|
902
|
-
node.setAttribute("y", ""
|
|
903
|
-
node.setAttribute("width", ""
|
|
904
|
-
node.setAttribute("height", ""
|
|
907
|
+
node.setAttribute("x", "".concat(this._x(center.x - size / 2.0)));
|
|
908
|
+
node.setAttribute("y", "".concat(this._y(center.y - size / 2.0)));
|
|
909
|
+
node.setAttribute("width", "".concat(size * this.scale.x));
|
|
910
|
+
node.setAttribute("height", "".concat(size * this.scale.y));
|
|
905
911
|
return this._bindFillDraw(node, "square", color, lineWidth || 1);
|
|
906
912
|
};
|
|
907
913
|
/**
|
|
@@ -921,10 +927,10 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
921
927
|
drawutilssvg.prototype.rect = function (position, width, height, color, lineWidth, strokeOptions) {
|
|
922
928
|
var node = this.makeNode("rect");
|
|
923
929
|
this.applyStrokeOpts(node, strokeOptions);
|
|
924
|
-
node.setAttribute("x", ""
|
|
925
|
-
node.setAttribute("y", ""
|
|
926
|
-
node.setAttribute("width", ""
|
|
927
|
-
node.setAttribute("height", ""
|
|
930
|
+
node.setAttribute("x", "".concat(this._x(position.x)));
|
|
931
|
+
node.setAttribute("y", "".concat(this._y(position.y)));
|
|
932
|
+
node.setAttribute("width", "".concat(width * this.scale.x));
|
|
933
|
+
node.setAttribute("height", "".concat(height * this.scale.y));
|
|
928
934
|
return this._bindFillDraw(node, "rect", color, lineWidth || 1);
|
|
929
935
|
};
|
|
930
936
|
/**
|
|
@@ -1042,10 +1048,10 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1042
1048
|
*/
|
|
1043
1049
|
drawutilssvg.prototype.squareHandle = function (center, size, color) {
|
|
1044
1050
|
var node = this.makeNode("rect");
|
|
1045
|
-
node.setAttribute("x", ""
|
|
1046
|
-
node.setAttribute("y", ""
|
|
1047
|
-
node.setAttribute("width", ""
|
|
1048
|
-
node.setAttribute("height", ""
|
|
1051
|
+
node.setAttribute("x", "".concat(this._x(center.x) - size / 2.0));
|
|
1052
|
+
node.setAttribute("y", "".concat(this._y(center.y) - size / 2.0));
|
|
1053
|
+
node.setAttribute("width", "".concat(size));
|
|
1054
|
+
node.setAttribute("height", "".concat(size));
|
|
1049
1055
|
return this._bindFillDraw(node, "squareHandle", color, 1);
|
|
1050
1056
|
};
|
|
1051
1057
|
/**
|
|
@@ -1066,9 +1072,9 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1066
1072
|
drawutilssvg.prototype.circleHandle = function (center, radius, color) {
|
|
1067
1073
|
radius = radius || 3;
|
|
1068
1074
|
var node = this.makeNode("circle");
|
|
1069
|
-
node.setAttribute("cx", ""
|
|
1070
|
-
node.setAttribute("cy", ""
|
|
1071
|
-
node.setAttribute("r", ""
|
|
1075
|
+
node.setAttribute("cx", "".concat(this._x(center.x)));
|
|
1076
|
+
node.setAttribute("cy", "".concat(this._y(center.y)));
|
|
1077
|
+
node.setAttribute("r", "".concat(radius));
|
|
1072
1078
|
return this._bindFillDraw(node, "circleHandle", color, 1);
|
|
1073
1079
|
};
|
|
1074
1080
|
/**
|
|
@@ -1215,22 +1221,22 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1215
1221
|
: options.textAlign === "right" || options.textAlign === "end"
|
|
1216
1222
|
? "end"
|
|
1217
1223
|
: "start";
|
|
1218
|
-
var transformOrigin = this._x(x)
|
|
1219
|
-
var translate = "translate("
|
|
1224
|
+
var transformOrigin = "".concat(this._x(x), "px ").concat(this._y(y), "px");
|
|
1225
|
+
var translate = "translate(".concat(this._x(x), " ").concat(this._y(y) + lineHeight / 2, ")");
|
|
1220
1226
|
// Safari has a transform-origin/rotation bug.
|
|
1221
1227
|
// It's essential to use rotate(r,x,y) here. "rotate(r)"" with transform-origin(x,y) won't do the job.
|
|
1222
1228
|
// And rotate and translate cannot be used is combination on a text object.
|
|
1223
1229
|
// So wrap the text inside a <g>, translate the <g>, and rotate the text inside.
|
|
1224
|
-
var rotate = options.rotation ? "rotate("
|
|
1230
|
+
var rotate = options.rotation ? "rotate(".concat(options.rotation * RAD_TO_DEG, " 0 0)") : "";
|
|
1225
1231
|
var node = this.makeNode("g");
|
|
1226
1232
|
var curId = this.curId;
|
|
1227
1233
|
this.curId = curId + "_text";
|
|
1228
1234
|
var textNode = this.makeNode("text");
|
|
1229
1235
|
node.appendChild(textNode);
|
|
1230
1236
|
textNode.setAttribute("font-family", (_c = options.fontFamily) !== null && _c !== void 0 ? _c : ""); // May be undefined
|
|
1231
|
-
textNode.setAttribute("font-size", options.fontSize ? ""
|
|
1232
|
-
textNode.setAttribute("font-style", options.fontStyle ? ""
|
|
1233
|
-
textNode.setAttribute("font-weight", options.fontWeight ? ""
|
|
1237
|
+
textNode.setAttribute("font-size", options.fontSize ? "".concat(options.fontSize * this.scale.x) : "");
|
|
1238
|
+
textNode.setAttribute("font-style", options.fontStyle ? "".concat(options.fontStyle) : "");
|
|
1239
|
+
textNode.setAttribute("font-weight", options.fontWeight ? "".concat(options.fontWeight) : "");
|
|
1234
1240
|
textNode.setAttribute("text-anchor", textAlign);
|
|
1235
1241
|
textNode.setAttribute("transform-origin", "0 0");
|
|
1236
1242
|
textNode.setAttribute("transform", rotate);
|
|
@@ -1257,7 +1263,7 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1257
1263
|
drawutilssvg.prototype.label = function (text, x, y, rotation, color) {
|
|
1258
1264
|
var node = this.makeNode("text");
|
|
1259
1265
|
// For some strange reason SVG rotation transforms use degrees instead of radians
|
|
1260
|
-
node.setAttribute("transform", "translate("
|
|
1266
|
+
node.setAttribute("transform", "translate(".concat(x, ",").concat(y, "), rotate(").concat(((rotation || 0) / Math.PI) * 180, ")"));
|
|
1261
1267
|
node.setAttribute("font-family", "Arial");
|
|
1262
1268
|
node.setAttribute("font-size", "9pt");
|
|
1263
1269
|
node.setAttribute("font-style", "normal");
|
|
@@ -1314,8 +1320,8 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1314
1320
|
// Note that the background does not scale with the zoom level (always covers full element)
|
|
1315
1321
|
node.setAttribute("x", "0");
|
|
1316
1322
|
node.setAttribute("y", "0");
|
|
1317
|
-
node.setAttribute("width", ""
|
|
1318
|
-
node.setAttribute("height", ""
|
|
1323
|
+
node.setAttribute("width", "".concat(this.canvasSize.width));
|
|
1324
|
+
node.setAttribute("height", "".concat(this.canvasSize.height));
|
|
1319
1325
|
// Bind this special element into the document
|
|
1320
1326
|
this._bindFillDraw(node, this.curId, null, null);
|
|
1321
1327
|
node.setAttribute("fill", typeof color === "undefined" ? "none" : color);
|
|
@@ -1546,10 +1552,10 @@ var drawutilssvg = /** @class */ (function () {
|
|
|
1546
1552
|
*/
|
|
1547
1553
|
drawutilssvg.prototype.makeLineNode = function (zA, zB, color, lineWidth, strokeOptions, classNameOverride) {
|
|
1548
1554
|
var line = this.makeNode("line");
|
|
1549
|
-
line.setAttribute("x1", ""
|
|
1550
|
-
line.setAttribute("y1", ""
|
|
1551
|
-
line.setAttribute("x2", ""
|
|
1552
|
-
line.setAttribute("y2", ""
|
|
1555
|
+
line.setAttribute("x1", "".concat(this._x(zA.x)));
|
|
1556
|
+
line.setAttribute("y1", "".concat(this._y(zA.y)));
|
|
1557
|
+
line.setAttribute("x2", "".concat(this._x(zB.x)));
|
|
1558
|
+
line.setAttribute("y2", "".concat(this._y(zB.y)));
|
|
1553
1559
|
this._configureNode(line, classNameOverride !== null && classNameOverride !== void 0 ? classNameOverride : "line", this.fillShapes, color, lineWidth || 1, strokeOptions);
|
|
1554
1560
|
return line;
|
|
1555
1561
|
};
|