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
package/README.md CHANGED
@@ -159,6 +159,8 @@ A full working demo repository about the [Usage with Typescript is here](https:/
159
159
 
160
160
  [Basic Setup in a Codepen.io demo](https://codepen.io/ikaroskappler/pen/ZEjamVb)
161
161
 
162
+ [Voronoi Diagram in a Codepen.io demo](https://codepen.io/ikaroskappler/pen/RNREmje)
163
+
162
164
  ### Screenshot
163
165
 
164
166
  ![Simple Demo](https://plotboilerplate.io/repo/screenshots/screenshot-20190220_3_simpledemo.png "The simple demo")
package/dist/index.esm.js CHANGED
@@ -6444,7 +6444,10 @@ CircleSector.circleSectorUtils = {
6444
6444
  * @modified 2024-03-10 Fixing some types for Typescript 5 compatibility.
6445
6445
  * @modified 2024-07-24 Caching custom style defs in a private buffer variable.
6446
6446
  * @modified 2025-11-14 Fixing a bug in the CSS `mix-blend-mode` property handling (caused a runtime error).
6447
- * @version 1.6.11
6447
+ * @modified 2026-01-04 Adding `lineJoin` attribute to the methods' `StrokeOptions` param.
6448
+ * @modified 2026-01-04 Fixing missing `strokeOptions` param in the `drawutilssvg.polygon` method.
6449
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
6450
+ * @version 1.7.0
6448
6451
  **/
6449
6452
  const RAD_TO_DEG = 180 / Math.PI;
6450
6453
  /**
@@ -6844,6 +6847,7 @@ class drawutilssvg {
6844
6847
  * @param {StrokeOptions=} strokeOptions -
6845
6848
  */
6846
6849
  applyStrokeOpts(node, strokeOptions) {
6850
+ // Set line dash options?
6847
6851
  if (strokeOptions &&
6848
6852
  strokeOptions.dashArray &&
6849
6853
  strokeOptions.dashArray.length > 0 &&
@@ -6857,6 +6861,10 @@ class drawutilssvg {
6857
6861
  node.setAttribute("stroke-dashoffset", `${strokeOptions.dashOffset * this.scale.x}`);
6858
6862
  }
6859
6863
  }
6864
+ // Set line join option?
6865
+ if (strokeOptions && strokeOptions.lineJoin && drawutilssvg.nodeSupportsLineJoin(node.tagName)) {
6866
+ node.setAttribute("stroke-linejoin", strokeOptions.lineJoin);
6867
+ }
6860
6868
  }
6861
6869
  _x(x) {
6862
6870
  return this.offset.x + this.scale.x * x;
@@ -7106,12 +7114,12 @@ class drawutilssvg {
7106
7114
  * @param {string} color - The CSS colot to draw the path with.
7107
7115
  * @param {number=1} lineWidth - (optional) The line width to use.
7108
7116
  * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
7109
- *
7117
+ * @param {boolean} isOpen - (optional) Set to tur if the path should not be closed.
7110
7118
  * @return {void}
7111
7119
  * @instance
7112
7120
  * @memberof drawutilssvg
7113
7121
  */
7114
- cubicBezierPath(path, color, lineWidth, strokeOptions) {
7122
+ cubicBezierPath(path, color, lineWidth, strokeOptions, isOpen) {
7115
7123
  const node = this.makeNode("path");
7116
7124
  this.applyStrokeOpts(node, strokeOptions);
7117
7125
  if (!path || path.length == 0) {
@@ -7129,6 +7137,9 @@ class drawutilssvg {
7129
7137
  endPoint = path[i + 2];
7130
7138
  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));
7131
7139
  }
7140
+ if (!isOpen) {
7141
+ d.push("Z");
7142
+ }
7132
7143
  node.setAttribute("d", d.join(" "));
7133
7144
  return this._bindFillDraw(node, "cubicBezierPath", color, lineWidth || 1);
7134
7145
  }
@@ -7565,12 +7576,13 @@ class drawutilssvg {
7565
7576
  * @param {Polygon} polygon - The polygon to draw.
7566
7577
  * @param {string} color - The CSS color to draw the polygon with.
7567
7578
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
7579
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
7568
7580
  * @return {void}
7569
7581
  * @instance
7570
7582
  * @memberof drawutilssvg
7571
7583
  */
7572
- polygon(polygon, color, lineWidth) {
7573
- return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);
7584
+ polygon(polygon, color, lineWidth, strokeOptions) {
7585
+ return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth, strokeOptions);
7574
7586
  }
7575
7587
  /**
7576
7588
  * Draw a polygon line (alternative function to the polygon).
@@ -7948,6 +7960,9 @@ class drawutilssvg {
7948
7960
  static nodeSupportsLineDash(nodeName) {
7949
7961
  return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
7950
7962
  }
7963
+ static nodeSupportsLineJoin(nodeName) {
7964
+ return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
7965
+ }
7951
7966
  /**
7952
7967
  * Creates a basic <line> node with start and end coordinates. The created node will not
7953
7968
  * be bound to any root node.
@@ -8132,7 +8147,9 @@ drawutilssvg.HEAD_XML = [
8132
8147
  * @modified 2023-09-30 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
8133
8148
  * @modified 2023-10-07 Adding the optional `arrowHeadBasePositionBuffer` param to the arrowHead(...) method.
8134
8149
  * @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.
8135
- * @version 1.13.0
8150
+ * @modified 2026-01-04 Adding `lineJoin` attribute to the `StrokeOptions`.
8151
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
8152
+ * @version 1.14.0
8136
8153
  **/
8137
8154
  // Todo: rename this class to Drawutils?
8138
8155
  /**
@@ -8165,13 +8182,14 @@ class drawutils {
8165
8182
  * @param {StrokeOptions=} strokeOptions -
8166
8183
  */
8167
8184
  applyStrokeOpts(strokeOptions) {
8168
- var _a, _b;
8185
+ var _a, _b, _c;
8169
8186
  this.ctx.setLineDash(((_a = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashArray) !== null && _a !== void 0 ? _a : []).map((dashArrayElem) => {
8170
8187
  // Note assume scale.x === scale.y
8171
8188
  // Invariant scale makes funny stuff anyway.
8172
8189
  return dashArrayElem * this.scale.x;
8173
8190
  }));
8174
8191
  this.ctx.lineDashOffset = ((_b = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.dashOffset) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
8192
+ this.ctx.lineJoin = (_c = strokeOptions === null || strokeOptions === void 0 ? void 0 : strokeOptions.lineJoin) !== null && _c !== void 0 ? _c : null;
8175
8193
  }
8176
8194
  // +---------------------------------------------------------------------------------
8177
8195
  // | This is the final helper function for drawing and filling stuff. It is not
@@ -8617,7 +8635,7 @@ class drawutils {
8617
8635
  * @instance
8618
8636
  * @memberof drawutils
8619
8637
  */
8620
- cubicBezierPath(path, color, lineWidth, strokeOptions) {
8638
+ cubicBezierPath(path, color, lineWidth, strokeOptions, isOpen) {
8621
8639
  if (!path || path.length == 0) {
8622
8640
  return;
8623
8641
  }
@@ -8635,7 +8653,9 @@ class drawutils {
8635
8653
  endPoint = path[i + 2];
8636
8654
  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);
8637
8655
  }
8638
- this.ctx.closePath();
8656
+ if (!isOpen) {
8657
+ this.ctx.closePath();
8658
+ }
8639
8659
  this.ctx.lineWidth = lineWidth || 1;
8640
8660
  this._fillOrDraw(color);
8641
8661
  this.ctx.restore();
@@ -9237,6 +9257,7 @@ drawutils.helpers = {
9237
9257
  * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
9238
9258
  * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
9239
9259
  * @modified 2023-09-29 Added the `lineDashes` attribute.
9260
+ * @modified 2026-03-18 Adding `isOpen` parameter to `cubicBezierPath` draw method.
9240
9261
  * @version 0.0.10
9241
9262
  **/
9242
9263
  /**
@@ -9549,7 +9570,7 @@ class drawutilsgl {
9549
9570
  * @instance
9550
9571
  * @memberof drawutils
9551
9572
  */
9552
- cubicBezierPath(path, color, lineWidth) {
9573
+ cubicBezierPath(path, color, lineWidth, strokeOptions, isOpen) {
9553
9574
  // NOT YET IMPLEMENTED
9554
9575
  }
9555
9576
  /**
@@ -12495,8 +12516,9 @@ VEllipseSector.ellipseSectorUtils = {
12495
12516
  * @modified 2025-05-07 Added `PlogBoilerplate.addContentChangeListener` and `.removeContentChangeListener`.
12496
12517
  * @modified 2025-05-07 Moving full vectors now by default when vector point a is moved.
12497
12518
  * @modified 2025-05-20 Applying `lineWith` parameter in the draw routine for vectors (had been missing).
12519
+ * @modified 2026-03-13 Changed visibility of `setZoom` and `setOffset` to public. There was no good reason to have the private.
12498
12520
  *
12499
- * @version 1.21.1
12521
+ * @version 1.21.2
12500
12522
  *
12501
12523
  * @file PlotBoilerplate
12502
12524
  * @fileoverview The main class.