plotboilerplate 1.19.0 → 1.20.1
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 -1
- package/dist/index.esm.js +81 -27
- 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 +81 -39
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +1 -1
- package/src/cjs/Bounds.d.ts +4 -5
- package/src/cjs/Bounds.js +6 -8
- package/src/cjs/Bounds.js.map +1 -1
- package/src/cjs/PlotBoilerplate.d.ts +2 -1
- package/src/cjs/PlotBoilerplate.js +9 -3
- package/src/cjs/PlotBoilerplate.js.map +1 -1
- package/src/cjs/VEllipseSector.d.ts +4 -3
- package/src/cjs/VEllipseSector.js +15 -8
- package/src/cjs/VEllipseSector.js.map +1 -1
- package/src/cjs/Vertex.d.ts +33 -1
- package/src/cjs/Vertex.js +43 -1
- package/src/cjs/Vertex.js.map +1 -1
- package/src/cjs/drawutilssvg.d.ts +2 -1
- package/src/cjs/drawutilssvg.js +7 -19
- package/src/cjs/drawutilssvg.js.map +1 -1
- package/src/cjs/entry.js +1 -0
- package/src/cjs/interfaces/core.d.ts +3 -0
- package/src/cjs/interfaces/core.js +1 -0
- package/src/cjs/interfaces/core.js.map +1 -1
- package/src/cjs/utils/algorithms/detectPaths.d.ts +3 -2
- package/src/cjs/utils/creategui.js +7 -0
- package/src/cjs/utils/datastructures/Color.d.ts +1 -1
- package/src/cjs/utils/datastructures/Color.js +4 -2
- package/src/cjs/utils/datastructures/Color.js.map +1 -1
- package/src/cjs/utils/io/FileDrop.d.ts +11 -1
- package/src/cjs/utils/io/FileDrop.js +41 -10
- package/src/cjs/utils/io/FileDrop.js.map +1 -1
- package/src/cjs/utils/parsers/svg/parseSVGPathData.d.ts +27 -0
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js +486 -0
- package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js +53 -0
- package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -0
- package/src/cjs/utils/parsers/svg/types.d.ts +63 -0
- package/src/cjs/utils/parsers/svg/types.js +17 -0
- package/src/cjs/utils/parsers/svg/types.js.map +1 -0
- package/src/esm/Bounds.d.ts +4 -5
- package/src/esm/Bounds.js +6 -8
- package/src/esm/Bounds.js.map +1 -1
- package/src/esm/PlotBoilerplate.d.ts +2 -1
- package/src/esm/PlotBoilerplate.js +10 -4
- package/src/esm/PlotBoilerplate.js.map +1 -1
- package/src/esm/VEllipseSector.d.ts +4 -3
- package/src/esm/VEllipseSector.js +15 -8
- package/src/esm/VEllipseSector.js.map +1 -1
- package/src/esm/Vertex.d.ts +33 -1
- package/src/esm/Vertex.js +43 -1
- package/src/esm/Vertex.js.map +1 -1
- package/src/esm/drawutilssvg.d.ts +2 -1
- package/src/esm/drawutilssvg.js +7 -19
- package/src/esm/drawutilssvg.js.map +1 -1
- package/src/esm/entry.js +1 -0
- package/src/esm/interfaces/core.d.ts +3 -0
- package/src/esm/interfaces/core.js +1 -0
- package/src/esm/interfaces/core.js.map +1 -1
- package/src/esm/utils/algorithms/detectPaths.d.ts +3 -2
- package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
- package/src/esm/utils/datastructures/Color.d.ts +1 -1
- package/src/esm/utils/datastructures/Color.js +4 -2
- package/src/esm/utils/datastructures/Color.js.map +1 -1
- package/src/esm/utils/io/FileDrop.d.ts +11 -1
- package/src/esm/utils/io/FileDrop.js +41 -10
- package/src/esm/utils/io/FileDrop.js.map +1 -1
- package/src/esm/utils/parsers/svg/parseSVGPathData.d.ts +27 -0
- package/src/esm/utils/parsers/svg/parseSVGPathData.js +482 -0
- package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.js +49 -0
- package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -0
- package/src/esm/utils/parsers/svg/types.d.ts +63 -0
- package/src/esm/utils/parsers/svg/types.js +16 -0
- package/src/esm/utils/parsers/svg/types.js.map +1 -0
- package/src/ts/Bounds.ts +6 -8
- package/src/ts/PlotBoilerplate.ts +11 -4
- package/src/ts/VEllipseSector.ts +22 -15
- package/src/ts/Vertex.ts +46 -1
- package/src/ts/drawutilssvg.ts +8 -19
- package/src/ts/interfaces/core.ts +3 -0
- package/src/ts/utils/algorithms/detectPaths.ts +1 -1
- package/src/ts/utils/datastructures/Color.ts +8 -4
- package/src/ts/utils/io/FileDrop.ts +51 -10
- package/src/ts/utils/parsers/svg/parseSVGPathData.ts +631 -0
- package/src/ts/utils/parsers/svg/splitSVGPathData.ts +54 -0
- package/src/ts/utils/parsers/svg/types.ts +90 -0
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ often use for the visualization of 2D geometries. Basic features are
|
|
|
58
58
|
- drag and select elements
|
|
59
59
|
- keyboard interaction customizable
|
|
60
60
|
|
|
61
|
-
The compressed library has
|
|
61
|
+
The compressed library has 135kb.
|
|
62
62
|
|
|
63
63
|
## Install the package via npm
|
|
64
64
|
|
|
@@ -542,6 +542,7 @@ new MouseHandler(document.getElementById("mycanvas"))
|
|
|
542
542
|
- [jburkardt](https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html "jburkardt") for the obj test files.
|
|
543
543
|
- [@veltman](https://noahveltman.com/) for the awesome [geometric skeletonization article](https://observablehq.com/@veltman/centerline-labeling)
|
|
544
544
|
- [girih-tiles-spatial.jpg from Lund University, Architecture, Spatial Experiments, 2016.](https://spatialexperiments.wordpress.com/2016/09/19/islamic-geometry/girih-tiles-4/)
|
|
545
|
+
- [https://javascript.plainenglish.io/june-3-parsing-and-validating-svg-paths-with-regex-7bd0e245115] Josh Frank's regular expression for parsing SVG path data.
|
|
545
546
|
|
|
546
547
|
## Todos
|
|
547
548
|
|
package/dist/index.esm.js
CHANGED
|
@@ -357,7 +357,8 @@ class VertexListeners {
|
|
|
357
357
|
* @modified 2022-01-31 Added `Vertex.utils.arrayToJSON`.
|
|
358
358
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
359
359
|
* @modified 2022-02-02 Cleared the `Vertex.toSVGString` function (deprecated). Use `drawutilssvg` instead.
|
|
360
|
-
* @
|
|
360
|
+
* @modified 2022-11-28 Added the `subXY`, `subX` and `subY` methods to the `Vertex` class.
|
|
361
|
+
* @version 2.8.0
|
|
361
362
|
*
|
|
362
363
|
* @file Vertex
|
|
363
364
|
* @public
|
|
@@ -626,6 +627,47 @@ class Vertex {
|
|
|
626
627
|
}
|
|
627
628
|
return this;
|
|
628
629
|
}
|
|
630
|
+
/**
|
|
631
|
+
* Substract the passed amounts from the x- and y- components of this vertex.
|
|
632
|
+
*
|
|
633
|
+
* @method subXY
|
|
634
|
+
* @param {number} x - The amount to substract from x.
|
|
635
|
+
* @param {number} y - The amount to substract from y.
|
|
636
|
+
* @return {Vertex} this
|
|
637
|
+
* @instance
|
|
638
|
+
* @memberof Vertex
|
|
639
|
+
**/
|
|
640
|
+
subXY(amountX, amountY) {
|
|
641
|
+
this.x -= amountX;
|
|
642
|
+
this.y -= amountY;
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Substract the passed amounts from the x-component of this vertex.
|
|
647
|
+
*
|
|
648
|
+
* @method addX
|
|
649
|
+
* @param {number} x - The amount to substract from x.
|
|
650
|
+
* @return {Vertex} this
|
|
651
|
+
* @instance
|
|
652
|
+
* @memberof Vertex
|
|
653
|
+
**/
|
|
654
|
+
subX(amountX) {
|
|
655
|
+
this.x -= amountX;
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Substract the passed amounts from the y-component of this vertex.
|
|
660
|
+
*
|
|
661
|
+
* @method subY
|
|
662
|
+
* @param {number} y - The amount to substract from y.
|
|
663
|
+
* @return {Vertex} this
|
|
664
|
+
* @instance
|
|
665
|
+
* @memberof Vertex
|
|
666
|
+
**/
|
|
667
|
+
subY(amountY) {
|
|
668
|
+
this.y -= amountY;
|
|
669
|
+
return this;
|
|
670
|
+
}
|
|
629
671
|
/**
|
|
630
672
|
* Check if this vertex equals the passed one.
|
|
631
673
|
* <br>
|
|
@@ -1413,7 +1455,8 @@ Polygon.utils = {
|
|
|
1413
1455
|
* @modified 2021-06-21 (mid-summer) Added `getCenter` method.
|
|
1414
1456
|
* @modified 2022-02-01 Added the `toString` function.
|
|
1415
1457
|
* @modified 2022-10-09 Added the `fromDimension` function.
|
|
1416
|
-
* @
|
|
1458
|
+
* @modified 2022-11-28 Added the `clone` method.
|
|
1459
|
+
* @version 1.6.0
|
|
1417
1460
|
**/
|
|
1418
1461
|
/**
|
|
1419
1462
|
* @classdesc A bounds class with min and max values. Implementing IBounds.
|
|
@@ -1476,17 +1519,14 @@ class Bounds {
|
|
|
1476
1519
|
/**
|
|
1477
1520
|
* Clone this bounds object (create a deep clone).
|
|
1478
1521
|
*
|
|
1479
|
-
* Note: the returned format might change in the future, so please do not
|
|
1480
|
-
* rely on the returned string format.
|
|
1481
|
-
*
|
|
1482
1522
|
* @method clone
|
|
1483
1523
|
* @instance
|
|
1484
1524
|
* @memberof Bounds
|
|
1485
|
-
* @returns {
|
|
1525
|
+
* @returns {Bounds} Creates a deep clone of this bounds object.
|
|
1486
1526
|
*/
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1527
|
+
clone() {
|
|
1528
|
+
return new Bounds({ x: this.min.x, y: this.min.y }, { x: this.max.x, y: this.max.y });
|
|
1529
|
+
}
|
|
1490
1530
|
/**
|
|
1491
1531
|
* Compute the minimal bounding box for a given set of vertices.
|
|
1492
1532
|
*
|
|
@@ -4434,7 +4474,8 @@ CircleSector.circleSectorUtils = {
|
|
|
4434
4474
|
* @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.
|
|
4435
4475
|
* @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
|
|
4436
4476
|
* @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
|
|
4437
|
-
* @
|
|
4477
|
+
* @modified 2022-11-10 Tweaking some type issues.
|
|
4478
|
+
* @version 1.6.2
|
|
4438
4479
|
**/
|
|
4439
4480
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
4440
4481
|
/**
|
|
@@ -5427,7 +5468,7 @@ class drawutilssvg {
|
|
|
5427
5468
|
* @memberof drawutils
|
|
5428
5469
|
*/
|
|
5429
5470
|
text(text, x, y, options) {
|
|
5430
|
-
var _a, _b;
|
|
5471
|
+
var _a, _b, _c;
|
|
5431
5472
|
options = options || {};
|
|
5432
5473
|
const color = options.color || "black";
|
|
5433
5474
|
const lineHeight = ((_b = (_a = options.lineHeight) !== null && _a !== void 0 ? _a : options.fontSize) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
|
|
@@ -5452,10 +5493,10 @@ class drawutilssvg {
|
|
|
5452
5493
|
this.curId = curId + "_text";
|
|
5453
5494
|
const textNode = this.makeNode("text");
|
|
5454
5495
|
node.appendChild(textNode);
|
|
5455
|
-
textNode.setAttribute("font-family", options.fontFamily); // May be undefined
|
|
5456
|
-
textNode.setAttribute("font-size", options.fontSize ? `${options.fontSize * this.scale.x}` :
|
|
5457
|
-
textNode.setAttribute("font-style", options.fontStyle ? `${options.fontStyle}` :
|
|
5458
|
-
textNode.setAttribute("font-weight", options.fontWeight ? `${options.fontWeight}` :
|
|
5496
|
+
textNode.setAttribute("font-family", (_c = options.fontFamily) !== null && _c !== void 0 ? _c : ""); // May be undefined
|
|
5497
|
+
textNode.setAttribute("font-size", options.fontSize ? `${options.fontSize * this.scale.x}` : "");
|
|
5498
|
+
textNode.setAttribute("font-style", options.fontStyle ? `${options.fontStyle}` : "");
|
|
5499
|
+
textNode.setAttribute("font-weight", options.fontWeight ? `${options.fontWeight}` : "");
|
|
5459
5500
|
textNode.setAttribute("text-anchor", textAlign);
|
|
5460
5501
|
textNode.setAttribute("transform-origin", "0 0");
|
|
5461
5502
|
textNode.setAttribute("transform", rotate);
|
|
@@ -9756,10 +9797,11 @@ VEllipse.utils = {
|
|
|
9756
9797
|
* Implementation of elliptic sectors.
|
|
9757
9798
|
* Note that sectors are constructed in clockwise direction.
|
|
9758
9799
|
*
|
|
9759
|
-
* @author
|
|
9760
|
-
* @date
|
|
9800
|
+
* @author Ikaros Kappler
|
|
9801
|
+
* @date 2021-02-26
|
|
9761
9802
|
* @modified 2022-02-02 Added the `destroy` method.
|
|
9762
|
-
* @
|
|
9803
|
+
* @modified 2022-11-01 Tweaked the `endpointToCenterParameters` function to handle negative values, too, without errors.
|
|
9804
|
+
* @version 1.1.1
|
|
9763
9805
|
*/
|
|
9764
9806
|
/**
|
|
9765
9807
|
* @classdesc A class for elliptic sectors.
|
|
@@ -9835,10 +9877,14 @@ class VEllipseSector {
|
|
|
9835
9877
|
let intersection = startTangent.intersection(endTangent);
|
|
9836
9878
|
// What if intersection is undefined?
|
|
9837
9879
|
// --> This *can* not happen if segmentCount > 2 and height and width of the ellipse are not zero.
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9880
|
+
if (intersection) {
|
|
9881
|
+
// It's VERY LIKELY hat this ALWAYS happens; it's just a typesave variant.
|
|
9882
|
+
// Intersection cannot be null.
|
|
9883
|
+
let startDiff = startPoint.difference(intersection);
|
|
9884
|
+
let endDiff = endPoint.difference(intersection);
|
|
9885
|
+
let curve = new CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().add(startDiff.scale(threshold)), endPoint.clone().add(endDiff.scale(threshold)));
|
|
9886
|
+
curves.push(curve);
|
|
9887
|
+
}
|
|
9842
9888
|
}
|
|
9843
9889
|
startPoint = endPoint;
|
|
9844
9890
|
curAngle = nextAngle;
|
|
@@ -10002,7 +10048,8 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10002
10048
|
}
|
|
10003
10049
|
// Step 2 + 3: compute center
|
|
10004
10050
|
const sign = fa === fs ? -1 : 1;
|
|
10005
|
-
const M = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;
|
|
10051
|
+
// const M: number = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;
|
|
10052
|
+
const M = sqrt(Math.abs((prx * pry - prx * py - pry * px) / (prx * py + pry * px))) * sign;
|
|
10006
10053
|
const _cx = (M * (rx * y)) / ry;
|
|
10007
10054
|
const _cy = (M * (-ry * x)) / rx;
|
|
10008
10055
|
const cx = cosphi * _cx - sinphi * _cy + (x1 + x2) / 2;
|
|
@@ -10011,6 +10058,7 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10011
10058
|
const center = new Vertex(cx, cy);
|
|
10012
10059
|
const axis = center.clone().addXY(rx, ry);
|
|
10013
10060
|
const ellipse = new VEllipse(center, axis, 0);
|
|
10061
|
+
// console.log("VELLIPSE::::::", ellipse);
|
|
10014
10062
|
ellipse.rotate(phi);
|
|
10015
10063
|
const startAngle = new Line(ellipse.center, new Vertex(x1, y1)).angle();
|
|
10016
10064
|
const endAngle = new Line(ellipse.center, new Vertex(x2, y2)).angle();
|
|
@@ -10097,7 +10145,8 @@ VEllipseSector.ellipseSectorUtils = {
|
|
|
10097
10145
|
* @modified 2022-08-01 Added `title` to the params.
|
|
10098
10146
|
* @modified 2022-10-25 Added the `origin` to the default draw config.
|
|
10099
10147
|
* @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
|
|
10100
|
-
* @
|
|
10148
|
+
* @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.
|
|
10149
|
+
* @version 1.17.0
|
|
10101
10150
|
*
|
|
10102
10151
|
* @file PlotBoilerplate
|
|
10103
10152
|
* @fileoverview The main class.
|
|
@@ -10233,6 +10282,7 @@ class PlotBoilerplate {
|
|
|
10233
10282
|
offsetX: f.num(config, "offsetX", 0.0),
|
|
10234
10283
|
offsetY: f.num(config, "offsetY", 0.0),
|
|
10235
10284
|
rasterGrid: f.bool(config, "rasterGrid", true),
|
|
10285
|
+
drawRaster: f.bool(config, "drawRaster", true),
|
|
10236
10286
|
rasterScaleX: f.num(config, "rasterScaleX", 1.0),
|
|
10237
10287
|
rasterScaleY: f.num(config, "rasterScaleY", 1.0),
|
|
10238
10288
|
rasterAdjustFactor: f.num(config, "rasterAdjustdFactror", 2.0),
|
|
@@ -10283,6 +10333,7 @@ class PlotBoilerplate {
|
|
|
10283
10333
|
drawHandleLines: f.bool(config, "drawHandleLines", true),
|
|
10284
10334
|
drawHandlePoints: f.bool(config, "drawHandlePoints", true),
|
|
10285
10335
|
drawGrid: f.bool(config, "drawGrid", true),
|
|
10336
|
+
drawRaster: f.bool(config, "drawRaster", true),
|
|
10286
10337
|
bezier: {
|
|
10287
10338
|
color: "#00a822",
|
|
10288
10339
|
lineWidth: 2,
|
|
@@ -10835,7 +10886,7 @@ class PlotBoilerplate {
|
|
|
10835
10886
|
**/
|
|
10836
10887
|
getVertexNear(pixelPosition, pixelTolerance) {
|
|
10837
10888
|
var _a, _b;
|
|
10838
|
-
|
|
10889
|
+
const p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min((_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0, (_b = this.config.cssScaleY) !== null && _b !== void 0 ? _b : 1.0));
|
|
10839
10890
|
if (p && p.typeName == "vertex") {
|
|
10840
10891
|
return this.vertices[p.vindex];
|
|
10841
10892
|
}
|
|
@@ -11200,9 +11251,12 @@ class PlotBoilerplate {
|
|
|
11200
11251
|
* @return {void}
|
|
11201
11252
|
**/
|
|
11202
11253
|
drawAll(renderTime, draw, fill) {
|
|
11203
|
-
this.
|
|
11204
|
-
|
|
11254
|
+
if (this.config.drawRaster) {
|
|
11255
|
+
this.drawGrid(draw);
|
|
11256
|
+
}
|
|
11257
|
+
if (this.config.drawOrigin) {
|
|
11205
11258
|
this.drawOrigin(draw);
|
|
11259
|
+
}
|
|
11206
11260
|
this.drawDrawables(renderTime, draw, fill);
|
|
11207
11261
|
this.drawVertices(renderTime, draw);
|
|
11208
11262
|
this.drawSelectPolygon(draw);
|