plotboilerplate 1.19.0 → 1.20.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.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/dist/index.esm.js +81 -27
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +81 -39
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +1 -1
  11. package/src/cjs/Bounds.d.ts +4 -5
  12. package/src/cjs/Bounds.js +6 -8
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/PlotBoilerplate.d.ts +2 -1
  15. package/src/cjs/PlotBoilerplate.js +9 -3
  16. package/src/cjs/PlotBoilerplate.js.map +1 -1
  17. package/src/cjs/VEllipseSector.d.ts +4 -3
  18. package/src/cjs/VEllipseSector.js +15 -8
  19. package/src/cjs/VEllipseSector.js.map +1 -1
  20. package/src/cjs/Vertex.d.ts +33 -1
  21. package/src/cjs/Vertex.js +43 -1
  22. package/src/cjs/Vertex.js.map +1 -1
  23. package/src/cjs/drawutilssvg.d.ts +2 -1
  24. package/src/cjs/drawutilssvg.js +7 -19
  25. package/src/cjs/drawutilssvg.js.map +1 -1
  26. package/src/cjs/entry.js +1 -0
  27. package/src/cjs/interfaces/core.d.ts +3 -0
  28. package/src/cjs/interfaces/core.js +1 -0
  29. package/src/cjs/interfaces/core.js.map +1 -1
  30. package/src/cjs/utils/algorithms/detectPaths.d.ts +3 -2
  31. package/src/cjs/utils/creategui.js +7 -0
  32. package/src/cjs/utils/datastructures/Color.d.ts +1 -1
  33. package/src/cjs/utils/datastructures/Color.js +4 -2
  34. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  35. package/src/cjs/utils/io/FileDrop.d.ts +11 -1
  36. package/src/cjs/utils/io/FileDrop.js +41 -10
  37. package/src/cjs/utils/io/FileDrop.js.map +1 -1
  38. package/src/cjs/utils/parsers/svg/parseSVGPathData.d.ts +26 -0
  39. package/src/cjs/utils/parsers/svg/parseSVGPathData.js +463 -0
  40. package/src/cjs/utils/parsers/svg/parseSVGPathData.js.map +1 -0
  41. package/src/cjs/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
  42. package/src/cjs/utils/parsers/svg/splitSVGPathData.js +49 -0
  43. package/src/cjs/utils/parsers/svg/splitSVGPathData.js.map +1 -0
  44. package/src/cjs/utils/parsers/svg/types.d.ts +43 -0
  45. package/src/cjs/utils/parsers/svg/types.js +16 -0
  46. package/src/cjs/utils/parsers/svg/types.js.map +1 -0
  47. package/src/esm/Bounds.d.ts +4 -5
  48. package/src/esm/Bounds.js +6 -8
  49. package/src/esm/Bounds.js.map +1 -1
  50. package/src/esm/PlotBoilerplate.d.ts +2 -1
  51. package/src/esm/PlotBoilerplate.js +10 -4
  52. package/src/esm/PlotBoilerplate.js.map +1 -1
  53. package/src/esm/VEllipseSector.d.ts +4 -3
  54. package/src/esm/VEllipseSector.js +15 -8
  55. package/src/esm/VEllipseSector.js.map +1 -1
  56. package/src/esm/Vertex.d.ts +33 -1
  57. package/src/esm/Vertex.js +43 -1
  58. package/src/esm/Vertex.js.map +1 -1
  59. package/src/esm/drawutilssvg.d.ts +2 -1
  60. package/src/esm/drawutilssvg.js +7 -19
  61. package/src/esm/drawutilssvg.js.map +1 -1
  62. package/src/esm/entry.js +1 -0
  63. package/src/esm/interfaces/core.d.ts +3 -0
  64. package/src/esm/interfaces/core.js +1 -0
  65. package/src/esm/interfaces/core.js.map +1 -1
  66. package/src/esm/utils/algorithms/detectPaths.d.ts +3 -2
  67. package/src/esm/utils/algorithms/detectPaths.js.map +1 -1
  68. package/src/esm/utils/datastructures/Color.d.ts +1 -1
  69. package/src/esm/utils/datastructures/Color.js +4 -2
  70. package/src/esm/utils/datastructures/Color.js.map +1 -1
  71. package/src/esm/utils/io/FileDrop.d.ts +11 -1
  72. package/src/esm/utils/io/FileDrop.js +41 -10
  73. package/src/esm/utils/io/FileDrop.js.map +1 -1
  74. package/src/esm/utils/parsers/svg/parseSVGPathData.d.ts +26 -0
  75. package/src/esm/utils/parsers/svg/parseSVGPathData.js +459 -0
  76. package/src/esm/utils/parsers/svg/parseSVGPathData.js.map +1 -0
  77. package/src/esm/utils/parsers/svg/splitSVGPathData.d.ts +20 -0
  78. package/src/esm/utils/parsers/svg/splitSVGPathData.js +45 -0
  79. package/src/esm/utils/parsers/svg/splitSVGPathData.js.map +1 -0
  80. package/src/esm/utils/parsers/svg/types.d.ts +43 -0
  81. package/src/esm/utils/parsers/svg/types.js +15 -0
  82. package/src/esm/utils/parsers/svg/types.js.map +1 -0
  83. package/src/ts/Bounds.ts +6 -8
  84. package/src/ts/PlotBoilerplate.ts +11 -4
  85. package/src/ts/VEllipseSector.ts +22 -15
  86. package/src/ts/Vertex.ts +46 -1
  87. package/src/ts/drawutilssvg.ts +8 -19
  88. package/src/ts/interfaces/core.ts +3 -0
  89. package/src/ts/utils/algorithms/detectPaths.ts +1 -1
  90. package/src/ts/utils/datastructures/Color.ts +8 -4
  91. package/src/ts/utils/io/FileDrop.ts +51 -10
  92. package/src/ts/utils/parsers/svg/parseSVGPathData.ts +572 -0
  93. package/src/ts/utils/parsers/svg/splitSVGPathData.ts +50 -0
  94. package/src/ts/utils/parsers/svg/types.ts +70 -0
@@ -1683,7 +1683,8 @@ exports.BezierPath = BezierPath;
1683
1683
  * @modified 2021-06-21 (mid-summer) Added `getCenter` method.
1684
1684
  * @modified 2022-02-01 Added the `toString` function.
1685
1685
  * @modified 2022-10-09 Added the `fromDimension` function.
1686
- * @version 1.5.0
1686
+ * @modified 2022-11-28 Added the `clone` method.
1687
+ * @version 1.6.0
1687
1688
  **/
1688
1689
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1689
1690
  exports.Bounds = void 0;
@@ -1750,17 +1751,14 @@ var Bounds = /** @class */ (function () {
1750
1751
  /**
1751
1752
  * Clone this bounds object (create a deep clone).
1752
1753
  *
1753
- * Note: the returned format might change in the future, so please do not
1754
- * rely on the returned string format.
1755
- *
1756
1754
  * @method clone
1757
1755
  * @instance
1758
1756
  * @memberof Bounds
1759
- * @returns {string} Creates a deep clone of this bounds object. The returned object's `min` and `max` instances are `Vertex` instances.
1757
+ * @returns {Bounds} Creates a deep clone of this bounds object.
1760
1758
  */
1761
- // clone() {
1762
- // return new Bounds(new Vertex(this.min.x, this.min.y), new Vertex(this.max.x, this.max.y));
1763
- // }
1759
+ Bounds.prototype.clone = function () {
1760
+ return new Bounds({ x: this.min.x, y: this.min.y }, { x: this.max.x, y: this.max.y });
1761
+ };
1764
1762
  /**
1765
1763
  * Compute the minimal bounding box for a given set of vertices.
1766
1764
  *
@@ -4232,7 +4230,8 @@ var __webpack_unused_export__;
4232
4230
  * @modified 2022-08-01 Added `title` to the params.
4233
4231
  * @modified 2022-10-25 Added the `origin` to the default draw config.
4234
4232
  * @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
4235
- * @version 1.16.0
4233
+ * @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.
4234
+ * @version 1.17.0
4236
4235
  *
4237
4236
  * @file PlotBoilerplate
4238
4237
  * @fileoverview The main class.
@@ -4390,6 +4389,7 @@ var PlotBoilerplate = /** @class */ (function () {
4390
4389
  offsetX: f.num(config, "offsetX", 0.0),
4391
4390
  offsetY: f.num(config, "offsetY", 0.0),
4392
4391
  rasterGrid: f.bool(config, "rasterGrid", true),
4392
+ drawRaster: f.bool(config, "drawRaster", true),
4393
4393
  rasterScaleX: f.num(config, "rasterScaleX", 1.0),
4394
4394
  rasterScaleY: f.num(config, "rasterScaleY", 1.0),
4395
4395
  rasterAdjustFactor: f.num(config, "rasterAdjustdFactror", 2.0),
@@ -4440,6 +4440,7 @@ var PlotBoilerplate = /** @class */ (function () {
4440
4440
  drawHandleLines: f.bool(config, "drawHandleLines", true),
4441
4441
  drawHandlePoints: f.bool(config, "drawHandlePoints", true),
4442
4442
  drawGrid: f.bool(config, "drawGrid", true),
4443
+ drawRaster: f.bool(config, "drawRaster", true),
4443
4444
  bezier: {
4444
4445
  color: "#00a822",
4445
4446
  lineWidth: 2,
@@ -5357,9 +5358,12 @@ var PlotBoilerplate = /** @class */ (function () {
5357
5358
  * @return {void}
5358
5359
  **/
5359
5360
  PlotBoilerplate.prototype.drawAll = function (renderTime, draw, fill) {
5360
- this.drawGrid(draw);
5361
- if (this.config.drawOrigin)
5361
+ if (this.config.drawRaster) {
5362
+ this.drawGrid(draw);
5363
+ }
5364
+ if (this.config.drawOrigin) {
5362
5365
  this.drawOrigin(draw);
5366
+ }
5363
5367
  this.drawDrawables(renderTime, draw, fill);
5364
5368
  this.drawVertices(renderTime, draw);
5365
5369
  this.drawSelectPolygon(draw);
@@ -7635,10 +7639,11 @@ exports.VEllipse = VEllipse;
7635
7639
  * Implementation of elliptic sectors.
7636
7640
  * Note that sectors are constructed in clockwise direction.
7637
7641
  *
7638
- * @author Ikaros Kappler
7639
- * @date 2021-02-26
7642
+ * @author Ikaros Kappler
7643
+ * @date 2021-02-26
7640
7644
  * @modified 2022-02-02 Added the `destroy` method.
7641
- * @version 1.1.0
7645
+ * @modified 2022-11-01 Tweaked the `endpointToCenterParameters` function to handle negative values, too, without errors.
7646
+ * @version 1.1.1
7642
7647
  */
7643
7648
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7644
7649
  exports.VEllipseSector = void 0;
@@ -7722,10 +7727,14 @@ var VEllipseSector = /** @class */ (function () {
7722
7727
  var intersection = startTangent.intersection(endTangent);
7723
7728
  // What if intersection is undefined?
7724
7729
  // --> This *can* not happen if segmentCount > 2 and height and width of the ellipse are not zero.
7725
- var startDiff = startPoint.difference(intersection);
7726
- var endDiff = endPoint.difference(intersection);
7727
- var curve = new CubicBezierCurve_1.CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().add(startDiff.scale(threshold)), endPoint.clone().add(endDiff.scale(threshold)));
7728
- curves.push(curve);
7730
+ if (intersection) {
7731
+ // It's VERY LIKELY hat this ALWAYS happens; it's just a typesave variant.
7732
+ // Intersection cannot be null.
7733
+ var startDiff = startPoint.difference(intersection);
7734
+ var endDiff = endPoint.difference(intersection);
7735
+ var curve = new CubicBezierCurve_1.CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().add(startDiff.scale(threshold)), endPoint.clone().add(endDiff.scale(threshold)));
7736
+ curves.push(curve);
7737
+ }
7729
7738
  }
7730
7739
  startPoint = endPoint;
7731
7740
  curAngle = nextAngle;
@@ -7888,7 +7897,8 @@ var VEllipseSector = /** @class */ (function () {
7888
7897
  }
7889
7898
  // Step 2 + 3: compute center
7890
7899
  var sign = fa === fs ? -1 : 1;
7891
- var M = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;
7900
+ // const M: number = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;
7901
+ var M = sqrt(Math.abs((prx * pry - prx * py - pry * px) / (prx * py + pry * px))) * sign;
7892
7902
  var _cx = (M * (rx * y)) / ry;
7893
7903
  var _cy = (M * (-ry * x)) / rx;
7894
7904
  var cx = cosphi * _cx - sinphi * _cy + (x1 + x2) / 2;
@@ -7897,6 +7907,7 @@ var VEllipseSector = /** @class */ (function () {
7897
7907
  var center = new Vertex_1.Vertex(cx, cy);
7898
7908
  var axis = center.clone().addXY(rx, ry);
7899
7909
  var ellipse = new VEllipse_1.VEllipse(center, axis, 0);
7910
+ // console.log("VELLIPSE::::::", ellipse);
7900
7911
  ellipse.rotate(phi);
7901
7912
  var startAngle = new Line_1.Line(ellipse.center, new Vertex_1.Vertex(x1, y1)).angle();
7902
7913
  var endAngle = new Line_1.Line(ellipse.center, new Vertex_1.Vertex(x2, y2)).angle();
@@ -8449,7 +8460,8 @@ exports.VertTuple = VertTuple;
8449
8460
  * @modified 2022-01-31 Added `Vertex.utils.arrayToJSON`.
8450
8461
  * @modified 2022-02-02 Added the `destroy` method.
8451
8462
  * @modified 2022-02-02 Cleared the `Vertex.toSVGString` function (deprecated). Use `drawutilssvg` instead.
8452
- * @version 2.7.0
8463
+ * @modified 2022-11-28 Added the `subXY`, `subX` and `subY` methods to the `Vertex` class.
8464
+ * @version 2.8.0
8453
8465
  *
8454
8466
  * @file Vertex
8455
8467
  * @public
@@ -8723,6 +8735,47 @@ var Vertex = /** @class */ (function () {
8723
8735
  }
8724
8736
  return this;
8725
8737
  };
8738
+ /**
8739
+ * Substract the passed amounts from the x- and y- components of this vertex.
8740
+ *
8741
+ * @method subXY
8742
+ * @param {number} x - The amount to substract from x.
8743
+ * @param {number} y - The amount to substract from y.
8744
+ * @return {Vertex} this
8745
+ * @instance
8746
+ * @memberof Vertex
8747
+ **/
8748
+ Vertex.prototype.subXY = function (amountX, amountY) {
8749
+ this.x -= amountX;
8750
+ this.y -= amountY;
8751
+ return this;
8752
+ };
8753
+ /**
8754
+ * Substract the passed amounts from the x-component of this vertex.
8755
+ *
8756
+ * @method addX
8757
+ * @param {number} x - The amount to substract from x.
8758
+ * @return {Vertex} this
8759
+ * @instance
8760
+ * @memberof Vertex
8761
+ **/
8762
+ Vertex.prototype.subX = function (amountX) {
8763
+ this.x -= amountX;
8764
+ return this;
8765
+ };
8766
+ /**
8767
+ * Substract the passed amounts from the y-component of this vertex.
8768
+ *
8769
+ * @method subY
8770
+ * @param {number} y - The amount to substract from y.
8771
+ * @return {Vertex} this
8772
+ * @instance
8773
+ * @memberof Vertex
8774
+ **/
8775
+ Vertex.prototype.subY = function (amountY) {
8776
+ this.y -= amountY;
8777
+ return this;
8778
+ };
8726
8779
  /**
8727
8780
  * Check if this vertex equals the passed one.
8728
8781
  * <br>
@@ -11136,7 +11189,8 @@ var GLU = /** @class */ (function () {
11136
11189
  * @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.
11137
11190
  * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
11138
11191
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
11139
- * @version 1.6.1
11192
+ * @modified 2022-11-10 Tweaking some type issues.
11193
+ * @version 1.6.2
11140
11194
  **/
11141
11195
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11142
11196
  exports.drawutilssvg = void 0;
@@ -12138,7 +12192,7 @@ var drawutilssvg = /** @class */ (function () {
12138
12192
  * @memberof drawutils
12139
12193
  */
12140
12194
  drawutilssvg.prototype.text = function (text, x, y, options) {
12141
- var _a, _b;
12195
+ var _a, _b, _c;
12142
12196
  options = options || {};
12143
12197
  var color = options.color || "black";
12144
12198
  var lineHeight = ((_b = (_a = options.lineHeight) !== null && _a !== void 0 ? _a : options.fontSize) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
@@ -12163,10 +12217,10 @@ var drawutilssvg = /** @class */ (function () {
12163
12217
  this.curId = curId + "_text";
12164
12218
  var textNode = this.makeNode("text");
12165
12219
  node.appendChild(textNode);
12166
- textNode.setAttribute("font-family", options.fontFamily); // May be undefined
12167
- textNode.setAttribute("font-size", options.fontSize ? "" + options.fontSize * this.scale.x : null);
12168
- textNode.setAttribute("font-style", options.fontStyle ? "" + options.fontStyle : null);
12169
- textNode.setAttribute("font-weight", options.fontWeight ? "" + options.fontWeight : null);
12220
+ textNode.setAttribute("font-family", (_c = options.fontFamily) !== null && _c !== void 0 ? _c : ""); // May be undefined
12221
+ textNode.setAttribute("font-size", options.fontSize ? "" + options.fontSize * this.scale.x : "");
12222
+ textNode.setAttribute("font-style", options.fontStyle ? "" + options.fontStyle : "");
12223
+ textNode.setAttribute("font-weight", options.fontWeight ? "" + options.fontWeight : "");
12170
12224
  textNode.setAttribute("text-anchor", textAlign);
12171
12225
  textNode.setAttribute("transform-origin", "0 0");
12172
12226
  textNode.setAttribute("transform", rotate);
@@ -12318,19 +12372,6 @@ var drawutilssvg = /** @class */ (function () {
12318
12372
  var _sy = function (index) {
12319
12373
  data[index] = scale.y * Number(data[index]);
12320
12374
  };
12321
- var stx = function (value) {
12322
- return offset.x + scale.x * value;
12323
- };
12324
- var sty = function (value) {
12325
- return offset.y + scale.y * value;
12326
- };
12327
- // scale only {x,y}
12328
- var sx = function (value) {
12329
- return scale.x * value;
12330
- };
12331
- var sy = function (value) {
12332
- return scale.y * value;
12333
- };
12334
12375
  var i = 0;
12335
12376
  var lastPoint = { x: NaN, y: NaN };
12336
12377
  // "save last point"
@@ -12642,6 +12683,7 @@ globalThis.BezierPath = __webpack_require__(126).BezierPath;
12642
12683
  globalThis.Polygon = __webpack_require__(661).Polygon;
12643
12684
  globalThis.Triangle = __webpack_require__(212).Triangle;
12644
12685
  globalThis.VEllipse = __webpack_require__(112).VEllipse;
12686
+ globalThis.VEllipseSector = __webpack_require__(965).VEllipseSector;
12645
12687
  globalThis.Circle = __webpack_require__(913).Circle;
12646
12688
  globalThis.CircleSector = __webpack_require__(946).CircleSector;
12647
12689
  globalThis.PBImage = __webpack_require__(699).PBImage;