plotboilerplate 1.26.0 → 1.27.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 (86) hide show
  1. package/README.md +2 -0
  2. package/dist/index.esm.js +33 -11
  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 +33 -11
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +6 -2
  11. package/src/cjs/PlotBoilerplate.d.ts +4 -3
  12. package/src/cjs/PlotBoilerplate.js +2 -1
  13. package/src/cjs/PlotBoilerplate.js.map +1 -1
  14. package/src/cjs/draw.d.ts +4 -2
  15. package/src/cjs/draw.js +9 -4
  16. package/src/cjs/draw.js.map +1 -1
  17. package/src/cjs/drawgl.d.ts +3 -2
  18. package/src/cjs/drawgl.js +2 -1
  19. package/src/cjs/drawgl.js.map +1 -1
  20. package/src/cjs/drawutilssvg.d.ts +9 -4
  21. package/src/cjs/drawutilssvg.js +20 -5
  22. package/src/cjs/drawutilssvg.js.map +1 -1
  23. package/src/cjs/interfaces/DrawLib.d.ts +2 -0
  24. package/src/cjs/interfaces/DrawLib.js +1 -0
  25. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  26. package/src/cjs/utils/WebColors.d.ts +2 -1
  27. package/src/cjs/utils/WebColors.js +14 -25
  28. package/src/cjs/utils/WebColors.js.map +1 -1
  29. package/src/cjs/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
  30. package/src/cjs/utils/algorithms/PolygonTesselationOutlines.js +269 -0
  31. package/src/cjs/utils/algorithms/PolygonTesselationOutlines.js.map +1 -0
  32. package/src/cjs/utils/datastructures/Color.js +0 -19
  33. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  34. package/src/cjs/utils/datastructures/ColorGradient.d.ts +2 -0
  35. package/src/cjs/utils/datastructures/ColorGradient.js +5 -0
  36. package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -1
  37. package/src/cjs/utils/datastructures/Girih.d.ts +38 -1
  38. package/src/cjs/utils/datastructures/Girih.js +71 -1
  39. package/src/cjs/utils/datastructures/Girih.js.map +1 -1
  40. package/src/cjs/utils/io/FileDrop.d.ts +2 -0
  41. package/src/cjs/utils/io/FileDrop.js +4 -0
  42. package/src/cjs/utils/io/FileDrop.js.map +1 -1
  43. package/src/esm/PlotBoilerplate.d.ts +4 -3
  44. package/src/esm/PlotBoilerplate.js +2 -1
  45. package/src/esm/PlotBoilerplate.js.map +1 -1
  46. package/src/esm/draw.d.ts +4 -2
  47. package/src/esm/draw.js +9 -4
  48. package/src/esm/draw.js.map +1 -1
  49. package/src/esm/drawgl.d.ts +3 -2
  50. package/src/esm/drawgl.js +2 -1
  51. package/src/esm/drawgl.js.map +1 -1
  52. package/src/esm/drawutilssvg.d.ts +9 -4
  53. package/src/esm/drawutilssvg.js +20 -5
  54. package/src/esm/drawutilssvg.js.map +1 -1
  55. package/src/esm/interfaces/DrawLib.d.ts +2 -0
  56. package/src/esm/interfaces/DrawLib.js +1 -0
  57. package/src/esm/interfaces/DrawLib.js.map +1 -1
  58. package/src/esm/utils/WebColors.d.ts +2 -1
  59. package/src/esm/utils/WebColors.js +14 -25
  60. package/src/esm/utils/WebColors.js.map +1 -1
  61. package/src/esm/utils/algorithms/PolygonTesselationOutlines.d.ts +145 -0
  62. package/src/esm/utils/algorithms/PolygonTesselationOutlines.js +262 -0
  63. package/src/esm/utils/algorithms/PolygonTesselationOutlines.js.map +1 -0
  64. package/src/esm/utils/datastructures/Color.js +0 -19
  65. package/src/esm/utils/datastructures/Color.js.map +1 -1
  66. package/src/esm/utils/datastructures/ColorGradient.d.ts +2 -0
  67. package/src/esm/utils/datastructures/ColorGradient.js +5 -0
  68. package/src/esm/utils/datastructures/ColorGradient.js.map +1 -1
  69. package/src/esm/utils/datastructures/Girih.d.ts +38 -1
  70. package/src/esm/utils/datastructures/Girih.js +71 -1
  71. package/src/esm/utils/datastructures/Girih.js.map +1 -1
  72. package/src/esm/utils/io/FileDrop.d.ts +2 -0
  73. package/src/esm/utils/io/FileDrop.js +4 -0
  74. package/src/esm/utils/io/FileDrop.js.map +1 -1
  75. package/src/ts/PlotBoilerplate.ts +4 -3
  76. package/src/ts/draw.ts +8 -3
  77. package/src/ts/drawgl.ts +3 -2
  78. package/src/ts/drawutilssvg.ts +27 -5
  79. package/src/ts/interfaces/DrawLib.ts +3 -0
  80. package/src/ts/utils/WebColors.ts +20 -33
  81. package/src/ts/utils/algorithms/PolygonTesselationOutlines.ts +296 -0
  82. package/src/ts/utils/datastructures/Color.ts +0 -19
  83. package/src/ts/utils/datastructures/ColorGradient.ts +6 -0
  84. package/src/ts/utils/datastructures/Girih.ts +78 -1
  85. package/src/ts/utils/datastructures/interfaces.ts +4 -4
  86. package/src/ts/utils/io/FileDrop.ts +5 -0
@@ -270,7 +270,9 @@ exports.Vector = Vector;
270
270
  * @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
271
271
  * @modified 2023-10-07 Adding the optional `arrowHeadBasePositionBuffer` param to the arrowHead(...) method.
272
272
  * @modified 2024-09-13 Remoed the scaling of `lineWidth` in the `polygon` and `polyline` methods. This makes no sense here and doesn't match up with the behavior of other line functions.
273
- * @version 1.13.0
273
+ * @modified 2026-01-04 Adding `lineJoin` attribute to the `StrokeOptions`.
274
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
275
+ * @version 1.14.0
274
276
  **/
275
277
  Object.defineProperty(exports, "__esModule", ({ value: true }));
276
278
  exports.drawutils = void 0;
@@ -310,13 +312,14 @@ var drawutils = /** @class */ (function () {
310
312
  */
311
313
  drawutils.prototype.applyStrokeOpts = function (strokeOptions) {
312
314
  var _this = this;
313
- var _a, _b;
315
+ var _a, _b, _c;
314
316
  this.ctx.setLineDash(((_a = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashArray) !== null && _a !== void 0 ? _a : []).map(function (dashArrayElem) {
315
317
  // Note assume scale.x === scale.y
316
318
  // Invariant scale makes funny stuff anyway.
317
319
  return dashArrayElem * _this.scale.x;
318
320
  }));
319
321
  this.ctx.lineDashOffset = ((_b = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashOffset) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
322
+ this.ctx.lineJoin = (_c = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.lineJoin) !== null && _c !== void 0 ? _c : null;
320
323
  };
321
324
  // +---------------------------------------------------------------------------------
322
325
  // | This is the final helper function for drawing and filling stuff. It is not
@@ -765,7 +768,7 @@ var drawutils = /** @class */ (function () {
765
768
  * @instance
766
769
  * @memberof drawutils
767
770
  */
768
- drawutils.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions) {
771
+ drawutils.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions, isOpen) {
769
772
  if (!path || path.length == 0) {
770
773
  return;
771
774
  }
@@ -783,7 +786,9 @@ var drawutils = /** @class */ (function () {
783
786
  endPoint = path[i + 2];
784
787
  this.ctx.bezierCurveTo(this.offset.x + startControlPoint.x * this.scale.x, this.offset.y + startControlPoint.y * this.scale.y, this.offset.x + endControlPoint.x * this.scale.x, this.offset.y + endControlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);
785
788
  }
786
- this.ctx.closePath();
789
+ if (!isOpen) {
790
+ this.ctx.closePath();
791
+ }
787
792
  this.ctx.lineWidth = lineWidth || 1;
788
793
  this._fillOrDraw(color);
789
794
  this.ctx.restore();
@@ -2435,6 +2440,7 @@ exports.CircleSector = CircleSector;
2435
2440
  * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
2436
2441
  * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
2437
2442
  * @modified 2023-09-29 Added the `lineDashes` attribute.
2443
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
2438
2444
  * @version 0.0.10
2439
2445
  **/
2440
2446
  Object.defineProperty(exports, "__esModule", ({ value: true }));
@@ -2751,7 +2757,7 @@ var drawutilsgl = /** @class */ (function () {
2751
2757
  * @instance
2752
2758
  * @memberof drawutils
2753
2759
  */
2754
- drawutilsgl.prototype.cubicBezierPath = function (path, color, lineWidth) {
2760
+ drawutilsgl.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions, isOpen) {
2755
2761
  // NOT YET IMPLEMENTED
2756
2762
  };
2757
2763
  /**
@@ -3494,7 +3500,10 @@ exports.geomutils = {
3494
3500
  * @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
3495
3501
  * @modified 2024-07-24 Caching custom style defs in a private buffer variable.
3496
3502
  * @modified 2025-11-14 Fixing a bug in the CSS `mix-blend-mode` property handling (caused a runtime error).
3497
- * @version 1.6.11
3503
+ * @modified 2026-01-04 Adding `lineJoin` attribute to the methods' `StrokeOptions` param.
3504
+ * @modified 2026-01-04 Fixing missing `strokeOptions` param in the `drawutilssvg.polygon` method.
3505
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
3506
+ * @version 1.7.0
3498
3507
  **/
3499
3508
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3500
3509
  exports.drawutilssvg = void 0;
@@ -3902,6 +3911,7 @@ var drawutilssvg = /** @class */ (function () {
3902
3911
  */
3903
3912
  drawutilssvg.prototype.applyStrokeOpts = function (node, strokeOptions) {
3904
3913
  var _this = this;
3914
+ // Set line dash options?
3905
3915
  if (strokeOptions &&
3906
3916
  strokeOptions.dashArray &&
3907
3917
  strokeOptions.dashArray.length > 0 &&
@@ -3915,6 +3925,10 @@ var drawutilssvg = /** @class */ (function () {
3915
3925
  node.setAttribute("stroke-dashoffset", "".concat(strokeOptions.dashOffset * this.scale.x));
3916
3926
  }
3917
3927
  }
3928
+ // Set line join option?
3929
+ if (strokeOptions && strokeOptions.lineJoin && drawutilssvg.nodeSupportsLineJoin(node.tagName)) {
3930
+ node.setAttribute("stroke-linejoin", strokeOptions.lineJoin);
3931
+ }
3918
3932
  };
3919
3933
  drawutilssvg.prototype._x = function (x) {
3920
3934
  return this.offset.x + this.scale.x * x;
@@ -4170,12 +4184,12 @@ var drawutilssvg = /** @class */ (function () {
4170
4184
  * @param {string} color - The CSS colot to draw the path with.
4171
4185
  * @param {number=1} lineWidth - (optional) The line width to use.
4172
4186
  * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
4173
- *
4187
+ * @param {boolean} isOpen - (optional) Set to tur if the path should not be closed.
4174
4188
  * @return {void}
4175
4189
  * @instance
4176
4190
  * @memberof drawutilssvg
4177
4191
  */
4178
- drawutilssvg.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions) {
4192
+ drawutilssvg.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions, isOpen) {
4179
4193
  var node = this.makeNode("path");
4180
4194
  this.applyStrokeOpts(node, strokeOptions);
4181
4195
  if (!path || path.length == 0) {
@@ -4193,6 +4207,9 @@ var drawutilssvg = /** @class */ (function () {
4193
4207
  endPoint = path[i + 2];
4194
4208
  d.push("C", this._x(startControlPoint.x), this._y(startControlPoint.y), this._x(endControlPoint.x), this._y(endControlPoint.y), this._x(endPoint.x), this._y(endPoint.y));
4195
4209
  }
4210
+ if (!isOpen) {
4211
+ d.push("Z");
4212
+ }
4196
4213
  node.setAttribute("d", d.join(" "));
4197
4214
  return this._bindFillDraw(node, "cubicBezierPath", color, lineWidth || 1);
4198
4215
  };
@@ -4629,12 +4646,13 @@ var drawutilssvg = /** @class */ (function () {
4629
4646
  * @param {Polygon} polygon - The polygon to draw.
4630
4647
  * @param {string} color - The CSS color to draw the polygon with.
4631
4648
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
4649
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
4632
4650
  * @return {void}
4633
4651
  * @instance
4634
4652
  * @memberof drawutilssvg
4635
4653
  */
4636
- drawutilssvg.prototype.polygon = function (polygon, color, lineWidth) {
4637
- return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);
4654
+ drawutilssvg.prototype.polygon = function (polygon, color, lineWidth, strokeOptions) {
4655
+ return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth, strokeOptions);
4638
4656
  };
4639
4657
  /**
4640
4658
  * Draw a polygon line (alternative function to the polygon).
@@ -5013,6 +5031,9 @@ var drawutilssvg = /** @class */ (function () {
5013
5031
  drawutilssvg.nodeSupportsLineDash = function (nodeName) {
5014
5032
  return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
5015
5033
  };
5034
+ drawutilssvg.nodeSupportsLineJoin = function (nodeName) {
5035
+ return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
5036
+ };
5016
5037
  /**
5017
5038
  * Creates a basic <line> node with start and end coordinates. The created node will not
5018
5039
  * be bound to any root node.
@@ -5747,8 +5768,9 @@ exports.KeyHandler = KeyHandler;
5747
5768
  * @modified 2025-05-07 Added `PlogBoilerplate.addContentChangeListener` and `.removeContentChangeListener`.
5748
5769
  * @modified 2025-05-07 Moving full vectors now by default when vector point a is moved.
5749
5770
  * @modified 2025-05-20 Applying `lineWith` parameter in the draw routine for vectors (had been missing).
5771
+ * @modified 2026-03-13 Changed visibility of `setZoom` and `setOffset` to public. There was no good reason to have the private.
5750
5772
  *
5751
- * @version 1.21.1
5773
+ * @version 1.21.2
5752
5774
  *
5753
5775
  * @file PlotBoilerplate
5754
5776
  * @fileoverview The main class.