plotboilerplate 1.20.1 → 1.20.2

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 (70) hide show
  1. package/README.md +17 -1
  2. package/dist/index.esm.js +101 -50
  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 +102 -50
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +2 -1
  11. package/src/cjs/BezierPath.js +2 -3
  12. package/src/cjs/BezierPath.js.map +1 -1
  13. package/src/cjs/PlotBoilerplate.d.ts +7 -1
  14. package/src/cjs/PlotBoilerplate.js +76 -33
  15. package/src/cjs/PlotBoilerplate.js.map +1 -1
  16. package/src/cjs/Triangle.js +1 -0
  17. package/src/cjs/Triangle.js.map +1 -1
  18. package/src/cjs/draw.d.ts +6 -5
  19. package/src/cjs/draw.js +4 -3
  20. package/src/cjs/draw.js.map +1 -1
  21. package/src/cjs/drawgl.d.ts +7 -6
  22. package/src/cjs/drawgl.js +5 -4
  23. package/src/cjs/drawgl.js.map +1 -1
  24. package/src/cjs/drawutilssvg.d.ts +8 -6
  25. package/src/cjs/drawutilssvg.js +14 -7
  26. package/src/cjs/drawutilssvg.js.map +1 -1
  27. package/src/cjs/interfaces/DrawLib.d.ts +4 -3
  28. package/src/cjs/interfaces/DrawLib.js +1 -0
  29. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  30. package/src/cjs/interfaces/core.d.ts +33 -30
  31. package/src/cjs/interfaces/core.js +1 -0
  32. package/src/cjs/interfaces/core.js.map +1 -1
  33. package/src/cjs/utils/datastructures/Color.d.ts +3 -1
  34. package/src/cjs/utils/datastructures/Color.js +12 -1
  35. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  36. package/src/cjs/utils/module.js +4 -2
  37. package/src/esm/BezierPath.js +2 -3
  38. package/src/esm/BezierPath.js.map +1 -1
  39. package/src/esm/PlotBoilerplate.d.ts +7 -1
  40. package/src/esm/PlotBoilerplate.js +75 -33
  41. package/src/esm/PlotBoilerplate.js.map +1 -1
  42. package/src/esm/Triangle.js +1 -0
  43. package/src/esm/Triangle.js.map +1 -1
  44. package/src/esm/draw.d.ts +6 -5
  45. package/src/esm/draw.js +4 -3
  46. package/src/esm/draw.js.map +1 -1
  47. package/src/esm/drawgl.d.ts +7 -6
  48. package/src/esm/drawgl.js +5 -4
  49. package/src/esm/drawgl.js.map +1 -1
  50. package/src/esm/drawutilssvg.d.ts +8 -6
  51. package/src/esm/drawutilssvg.js +14 -7
  52. package/src/esm/drawutilssvg.js.map +1 -1
  53. package/src/esm/interfaces/DrawLib.d.ts +4 -3
  54. package/src/esm/interfaces/DrawLib.js +1 -0
  55. package/src/esm/interfaces/DrawLib.js.map +1 -1
  56. package/src/esm/interfaces/core.d.ts +33 -30
  57. package/src/esm/interfaces/core.js +1 -0
  58. package/src/esm/interfaces/core.js.map +1 -1
  59. package/src/esm/utils/datastructures/Color.d.ts +3 -1
  60. package/src/esm/utils/datastructures/Color.js +12 -1
  61. package/src/esm/utils/datastructures/Color.js.map +1 -1
  62. package/src/ts/BezierPath.ts +2 -3
  63. package/src/ts/PlotBoilerplate.ts +75 -32
  64. package/src/ts/Triangle.ts +2 -1
  65. package/src/ts/draw.ts +6 -5
  66. package/src/ts/drawgl.ts +9 -8
  67. package/src/ts/drawutilssvg.ts +23 -16
  68. package/src/ts/interfaces/DrawLib.ts +4 -3
  69. package/src/ts/interfaces/core.ts +33 -30
  70. package/src/ts/utils/datastructures/Color.ts +13 -1
@@ -1622,8 +1622,7 @@ var BezierPath = /** @class */ (function () {
1622
1622
  BezierPath.fromReducedList = function (pointArray, adjustCircular) {
1623
1623
  // Convert to object
1624
1624
  var bezierPath = new BezierPath(null); // No points yet
1625
- // var firstStartPoint: Vertex;
1626
- var startPoint;
1625
+ var startPoint = new Vertex_1.Vertex();
1627
1626
  var startControlPoint;
1628
1627
  var endControlPoint;
1629
1628
  var endPoint;
@@ -1645,7 +1644,7 @@ var BezierPath = /** @class */ (function () {
1645
1644
  startPoint = endPoint;
1646
1645
  i += 6;
1647
1646
  } while (i + 2 < pointArray.length);
1648
- bezierPath.adjustCircular = adjustCircular;
1647
+ bezierPath.adjustCircular = adjustCircular !== null && adjustCircular !== void 0 ? adjustCircular : false;
1649
1648
  if (adjustCircular) {
1650
1649
  bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint = bezierPath.bezierCurves[0].startPoint;
1651
1650
  }
@@ -4231,7 +4230,11 @@ var __webpack_unused_export__;
4231
4230
  * @modified 2022-10-25 Added the `origin` to the default draw config.
4232
4231
  * @modified 2022-11-06 Adding an XML declaration to the SVG export routine.
4233
4232
  * @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.
4234
- * @version 1.17.0
4233
+ * @modified 2023-02-04 Fixed a bug in the `drawDrawable` function; fill's current classname was not set.
4234
+ * @modified 2023-02-10 Fixing an issue of the `style.position` setting when `fitToParent=true` from `absolute` to `static` (default).
4235
+ * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
4236
+ * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
4237
+ * @version 1.17.2
4235
4238
  *
4236
4239
  * @file PlotBoilerplate
4237
4240
  * @fileoverview The main class.
@@ -4343,6 +4346,8 @@ var PlotBoilerplate = /** @class */ (function () {
4343
4346
  * @param {boolean=} [config.enableTouch=true] - Indicates if the application should handle touch events for you.
4344
4347
  * @param {boolean=} [config.enableKeys=true] - Indicates if the application should handle key events for you.
4345
4348
  * @param {boolean=} [config.enableMouseWheel=true] - Indicates if the application should handle mouse wheel events for you.
4349
+ * @param {boolean=} [config.enablePan=true] - (default true) Set to false if you want to disable panning completely.
4350
+ * @param {boolean=} [config.enableZoom=true] - (default true) Set to false if you want to disable zooming completely.
4346
4351
  * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
4347
4352
  * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
4348
4353
  * Note that changes from the postDraw hook might not be visible in the export.
@@ -4423,6 +4428,8 @@ var PlotBoilerplate = /** @class */ (function () {
4423
4428
  enableTouch: f.bool(config, "enableTouch", true),
4424
4429
  enableKeys: f.bool(config, "enableKeys", true),
4425
4430
  enableMouseWheel: f.bool(config, "enableMouseWheel", true),
4431
+ enableZoom: f.bool(config, "enableZoom", true),
4432
+ enablePan: f.bool(config, "enablePan", true),
4426
4433
  // Experimental (and unfinished)
4427
4434
  enableGL: f.bool(config, "enableGL", false)
4428
4435
  }; // END confog
@@ -5087,7 +5094,7 @@ var PlotBoilerplate = /** @class */ (function () {
5087
5094
  this.draw.setCurrentId(d.uid);
5088
5095
  this.fill.setCurrentId(d.uid);
5089
5096
  this.draw.setCurrentClassName(d.className);
5090
- this.draw.setCurrentClassName(d.className);
5097
+ this.fill.setCurrentClassName(d.className);
5091
5098
  this.drawDrawable(d, renderTime, draw, fill);
5092
5099
  }
5093
5100
  };
@@ -5108,7 +5115,13 @@ var PlotBoilerplate = /** @class */ (function () {
5108
5115
  **/
5109
5116
  PlotBoilerplate.prototype.drawDrawable = function (d, renderTime, draw, fill) {
5110
5117
  if (d instanceof BezierPath_1.BezierPath) {
5118
+ var curveIndex = 0;
5111
5119
  for (var c in d.bezierCurves) {
5120
+ // Restore these settings again in each loop (will be overwritten)
5121
+ this.draw.setCurrentId(d.uid + "-" + curveIndex);
5122
+ this.fill.setCurrentId(d.uid + "-" + curveIndex);
5123
+ this.draw.setCurrentClassName(d.className);
5124
+ this.fill.setCurrentClassName(d.className);
5112
5125
  draw.cubicBezier(d.bezierCurves[c].startPoint, d.bezierCurves[c].endPoint, d.bezierCurves[c].startControlPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.color, this.drawConfig.bezier.lineWidth);
5113
5126
  if (this.drawConfig.drawBezierHandlePoints && this.drawConfig.drawHandlePoints) {
5114
5127
  if (d.bezierCurves[c].startPoint.attr.visible) {
@@ -5165,7 +5178,8 @@ var PlotBoilerplate = /** @class */ (function () {
5165
5178
  draw.setCurrentClassName(d.className + "-end-line");
5166
5179
  draw.line(d.bezierCurves[c].endPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);
5167
5180
  }
5168
- }
5181
+ curveIndex++;
5182
+ } // END for
5169
5183
  }
5170
5184
  else if (d instanceof Polygon_1.Polygon) {
5171
5185
  draw.polygon(d, this.drawConfig.polygon.color, this.drawConfig.polygon.lineWidth);
@@ -5276,10 +5290,10 @@ var PlotBoilerplate = /** @class */ (function () {
5276
5290
  else {
5277
5291
  console.error("Cannot draw object. Unknown class.");
5278
5292
  }
5279
- draw.setCurrentClassName(undefined);
5280
- draw.setCurrentId(undefined);
5281
- fill.setCurrentClassName(undefined);
5282
- fill.setCurrentId(undefined);
5293
+ draw.setCurrentClassName(null);
5294
+ draw.setCurrentId(null);
5295
+ fill.setCurrentClassName(null);
5296
+ fill.setCurrentId(null);
5283
5297
  };
5284
5298
  /**
5285
5299
  * Draw the select-polygon (if there is one).
@@ -5369,8 +5383,8 @@ var PlotBoilerplate = /** @class */ (function () {
5369
5383
  this.drawSelectPolygon(draw);
5370
5384
  // Clear IDs and classnames (postDraw hook might draw somthing and the do not want
5371
5385
  // to interfered with that).
5372
- draw.setCurrentId(undefined);
5373
- draw.setCurrentClassName(undefined);
5386
+ draw.setCurrentId(null);
5387
+ draw.setCurrentClassName(null);
5374
5388
  }; // END redraw
5375
5389
  /**
5376
5390
  * This function clears the canvas with the configured background color.<br>
@@ -5507,7 +5521,7 @@ var PlotBoilerplate = /** @class */ (function () {
5507
5521
  }
5508
5522
  else if (_self.config.fitToParent) {
5509
5523
  // Set editor size
5510
- _self.canvas.style.position = "absolute";
5524
+ _self.canvas.style.position = "static";
5511
5525
  var space = this.getAvailableContainerSpace();
5512
5526
  _self.canvas.style.width = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * space.width + "px";
5513
5527
  _self.canvas.style.height = ((_d = _self.config.canvasHeightFactor) !== null && _d !== void 0 ? _d : 1.0) * space.height + "px";
@@ -5578,24 +5592,24 @@ var PlotBoilerplate = /** @class */ (function () {
5578
5592
  **/
5579
5593
  PlotBoilerplate.prototype.handleClick = function (e) {
5580
5594
  var _self = this;
5581
- var p = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
5582
- if (p) {
5583
- _self.vertices[p.vindex].listeners.fireClickEvent(e);
5595
+ var point = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX || 1.0, _self.config.cssScaleY || 1.0));
5596
+ if (point) {
5597
+ _self.vertices[point.vindex].listeners.fireClickEvent(e);
5584
5598
  if (this.keyHandler && this.keyHandler.isDown("shift")) {
5585
- if (p.typeName == "bpath") {
5586
- var vert = _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid);
5599
+ if (point.typeName == "bpath") {
5600
+ var vert = _self.paths[point.pindex].bezierCurves[point.cindex].getPointByID(point.pid);
5587
5601
  if (vert.attr.selectable)
5588
5602
  vert.attr.isSelected = !vert.attr.isSelected;
5589
5603
  }
5590
- else if (p.typeName == "vertex") {
5591
- var vert = _self.vertices[p.vindex];
5604
+ else if (point.typeName == "vertex") {
5605
+ var vert = _self.vertices[point.vindex];
5592
5606
  if (vert.attr.selectable)
5593
5607
  vert.attr.isSelected = !vert.attr.isSelected;
5594
5608
  }
5595
5609
  _self.redraw();
5596
5610
  }
5597
- else if (this.keyHandler.isDown("y")) {
5598
- _self.vertices[p.vindex].attr.bezierAutoAdjust = !_self.vertices[p.vindex].attr.bezierAutoAdjust;
5611
+ else if (this.keyHandler && this.keyHandler.isDown("y")) {
5612
+ _self.vertices[point.vindex].attr.bezierAutoAdjust = !_self.vertices[point.vindex].attr.bezierAutoAdjust;
5599
5613
  _self.redraw();
5600
5614
  }
5601
5615
  }
@@ -5662,11 +5676,11 @@ var PlotBoilerplate = /** @class */ (function () {
5662
5676
  var _self = this;
5663
5677
  if (e.button != 0)
5664
5678
  return; // Only react on left mouse or touch events
5665
- var p = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
5666
- if (!p)
5679
+ var draggablePoint = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));
5680
+ if (!draggablePoint)
5667
5681
  return;
5668
5682
  // Drag all selected elements?
5669
- if (p.typeName == "vertex" && _self.vertices[p.vindex].attr.isSelected) {
5683
+ if (draggablePoint.typeName == "vertex" && _self.vertices[draggablePoint.vindex].attr.isSelected) {
5670
5684
  // Multi drag
5671
5685
  // for( var i in _self.vertices ) {
5672
5686
  for (var i = 0; i < _self.vertices.length; i++) {
@@ -5678,13 +5692,15 @@ var PlotBoilerplate = /** @class */ (function () {
5678
5692
  }
5679
5693
  else {
5680
5694
  // Single drag
5681
- if (!_self.vertices[p.vindex].attr.draggable)
5695
+ if (!_self.vertices[draggablePoint.vindex].attr.draggable)
5682
5696
  return;
5683
- _self.draggedElements.push(p);
5684
- if (p.typeName == "bpath")
5685
- _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragStartEvent(e);
5686
- else if (p.typeName == "vertex")
5687
- _self.vertices[p.vindex].listeners.fireDragStartEvent(e);
5697
+ _self.draggedElements.push(draggablePoint);
5698
+ if (draggablePoint.typeName == "bpath")
5699
+ _self.paths[draggablePoint.pindex].bezierCurves[draggablePoint.cindex]
5700
+ .getPointByID(draggablePoint.pid)
5701
+ .listeners.fireDragStartEvent(e);
5702
+ else if (draggablePoint.typeName == "vertex")
5703
+ _self.vertices[draggablePoint.vindex].listeners.fireDragStartEvent(e);
5688
5704
  }
5689
5705
  _self.redraw();
5690
5706
  };
@@ -5711,7 +5727,10 @@ var PlotBoilerplate = /** @class */ (function () {
5711
5727
  // not this one. So this tab will never receive any [Ctrl-down] events
5712
5728
  // until next keypress; the implication is, that [Ctrl] would still
5713
5729
  // considered to be pressed which is not true.
5714
- if (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar")) {
5730
+ if (this.keyHandler && (this.keyHandler.isDown("alt") || this.keyHandler.isDown("spacebar"))) {
5731
+ if (!this.config.enablePan) {
5732
+ return;
5733
+ }
5715
5734
  _self.setOffset(_self.draw.offset.clone().add(e.params.dragAmount));
5716
5735
  _self.redraw();
5717
5736
  }
@@ -5780,6 +5799,9 @@ var PlotBoilerplate = /** @class */ (function () {
5780
5799
  * @return {void}
5781
5800
  **/
5782
5801
  PlotBoilerplate.prototype.mouseWheelHandler = function (e) {
5802
+ if (!this.config.enableZoom) {
5803
+ return;
5804
+ }
5783
5805
  var zoomStep = 1.25; // Make configurable?
5784
5806
  // CHANGED replaced _self by this
5785
5807
  var _self = this;
@@ -5845,6 +5867,7 @@ var PlotBoilerplate = /** @class */ (function () {
5845
5867
  this.setOffset({ x: newOffsetX, y: newOffsetY });
5846
5868
  };
5847
5869
  PlotBoilerplate.prototype.installInputListeners = function () {
5870
+ var _this = this;
5848
5871
  var _self = this;
5849
5872
  if (this.config.enableMouse) {
5850
5873
  // Install a mouse handler on the canvas.
@@ -5919,6 +5942,9 @@ var PlotBoilerplate = /** @class */ (function () {
5919
5942
  if (evt.touches.length == 1 && draggedElement) {
5920
5943
  evt.preventDefault();
5921
5944
  evt.stopPropagation();
5945
+ if (!touchDownPos || !touchMovePos) {
5946
+ return;
5947
+ }
5922
5948
  var rel = relPos_1({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });
5923
5949
  var trans = _self.transformMousePosition(rel.x, rel.y);
5924
5950
  var diff = new Vertex_1.Vertex(_self.transformMousePosition(touchMovePos.x, touchMovePos.y)).difference(trans);
@@ -5943,6 +5969,9 @@ var PlotBoilerplate = /** @class */ (function () {
5943
5969
  touchMovePos = new Vertex_1.Vertex(rel);
5944
5970
  }
5945
5971
  else if (evt.touches.length == 2) {
5972
+ if (!_this.config.enablePan) {
5973
+ return;
5974
+ }
5946
5975
  // If at least two fingers touch and move, then change the draw offset (panning).
5947
5976
  evt.preventDefault();
5948
5977
  evt.stopPropagation();
@@ -5955,6 +5984,9 @@ var PlotBoilerplate = /** @class */ (function () {
5955
5984
  touchEnd: function (evt) {
5956
5985
  // Note: e.touches.length is 0 here
5957
5986
  if (draggedElement && draggedElement.typeName == "vertex") {
5987
+ if (!touchDownPos) {
5988
+ return;
5989
+ }
5958
5990
  var draggingVertex = _self.vertices[draggedElement.vindex];
5959
5991
  var fakeEvent = {
5960
5992
  isTouchEvent: true,
@@ -5987,9 +6019,17 @@ var PlotBoilerplate = /** @class */ (function () {
5987
6019
  multiTouchStartScale = null;
5988
6020
  },
5989
6021
  pinch: function (evt) {
6022
+ if (!_this.config.enableZoom) {
6023
+ return;
6024
+ }
6025
+ var touchItem0 = evt.touches.item(0);
6026
+ var touchItem1 = evt.touches.item(1);
6027
+ if (!evt.touches || !multiTouchStartScale || !touchItem0 || !touchItem1) {
6028
+ return;
6029
+ }
5990
6030
  // For pinching there must be at least two touch items
5991
- var fingerA = new Vertex_1.Vertex(evt.touches.item(0).clientX, evt.touches.item(0).clientY);
5992
- var fingerB = new Vertex_1.Vertex(evt.touches.item(1).clientX, evt.touches.item(1).clientY);
6031
+ var fingerA = new Vertex_1.Vertex(touchItem0.clientX, touchItem0.clientY);
6032
+ var fingerB = new Vertex_1.Vertex(touchItem1.clientX, touchItem1.clientY);
5993
6033
  var center = new Line_1.Line(fingerA, fingerB).vertAt(0.5);
5994
6034
  _self.setZoom(multiTouchStartScale.x * evt.zoom, multiTouchStartScale.y * evt.zoom, center);
5995
6035
  _self.redraw();
@@ -6138,8 +6178,10 @@ var PlotBoilerplate = /** @class */ (function () {
6138
6178
  **/
6139
6179
  setCSSscale: function (element, scaleX, scaleY) {
6140
6180
  element.style["transform-origin"] = "0 0";
6141
- if (scaleX == 1.0 && scaleY == 1.0)
6142
- element.style.transform = null;
6181
+ if (scaleX == 1.0 && scaleY == 1.0) {
6182
+ // element.style.transform = null;
6183
+ element.style.removeProperty("transform");
6184
+ }
6143
6185
  else
6144
6186
  element.style.transform = "scale(" + scaleX + "," + scaleY + ")";
6145
6187
  },
@@ -7090,6 +7132,7 @@ var Triangle = /** @class */ (function () {
7090
7132
  var lineC = new Line_1.Line(this.c, this.a);
7091
7133
  var bisector1 = geomutils_1.geomutils.nsectAngle(this.b, this.a, this.c, 2)[0]; // bisector of first angle (in b)
7092
7134
  var bisector2 = geomutils_1.geomutils.nsectAngle(this.c, this.b, this.a, 2)[0]; // bisector of second angle (in c)
7135
+ // Cast to non-null here because we know there _is_ an intersection
7093
7136
  var intersection = bisector1.intersection(bisector2);
7094
7137
  // Find the closest points on one of the polygon lines (all have same distance by construction)
7095
7138
  var circleIntersA = lineA.getClosestPoint(intersection);
@@ -9467,7 +9510,8 @@ exports.VertexListeners = VertexListeners;
9467
9510
  * @modified 2022-08-23 Fixed a type issue in the `polyline` function.
9468
9511
  * @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.
9469
9512
  * @modified 2022-08-23 Fixed a type issue in the `path` function.
9470
- * @version 1.12.3
9513
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
9514
+ * @version 1.12.4
9471
9515
  **/
9472
9516
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9473
9517
  exports.drawutils = void 0;
@@ -9534,7 +9578,7 @@ var drawutils = /** @class */ (function () {
9534
9578
  *
9535
9579
  * @name setCurrentId
9536
9580
  * @method
9537
- * @param {UID} uid - A UID identifying the currently drawn element(s).
9581
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).
9538
9582
  **/
9539
9583
  drawutils.prototype.setCurrentId = function (uid) {
9540
9584
  // NOOP
@@ -9545,7 +9589,7 @@ var drawutils = /** @class */ (function () {
9545
9589
  *
9546
9590
  * @name setCurrentClassName
9547
9591
  * @method
9548
- * @param {string} className - A class name for further custom use cases.
9592
+ * @param {string|null} className - A class name for further custom use cases.
9549
9593
  **/
9550
9594
  drawutils.prototype.setCurrentClassName = function (className) {
9551
9595
  // NOOP
@@ -10422,7 +10466,8 @@ exports.drawutils = drawutils;
10422
10466
  * @modified 2022-02-03 Added the `cross(...)` function.
10423
10467
  * @modified 2022-03-27 Added the `texturedPoly` function.
10424
10468
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
10425
- * @version 0.0.8
10469
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
10470
+ * @version 0.0.9
10426
10471
  **/
10427
10472
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10428
10473
  exports.drawutilsgl = void 0;
@@ -10443,7 +10488,7 @@ var drawutilsgl = /** @class */ (function () {
10443
10488
  *
10444
10489
  * @constructor
10445
10490
  * @name drawutils
10446
- * @param {WebGLRenderingContext} context - The drawing context.
10491
+ * @param {WebGLRenderingContext|null} context - The drawing context.
10447
10492
  * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).
10448
10493
  **/
10449
10494
  function drawutilsgl(context, fillShapes) {
@@ -10525,7 +10570,7 @@ var drawutilsgl = /** @class */ (function () {
10525
10570
  *
10526
10571
  * @name setCurrentId
10527
10572
  * @method
10528
- * @param {UID} uid - A UID identifying the currently drawn element(s).es.
10573
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).es.
10529
10574
  **/
10530
10575
  drawutilsgl.prototype.setCurrentId = function (uid) {
10531
10576
  // NOOP
@@ -10537,7 +10582,7 @@ var drawutilsgl = /** @class */ (function () {
10537
10582
  *
10538
10583
  * @name setCurrentClassName
10539
10584
  * @method
10540
- * @param {string} className - A class name for further custom use cases.
10585
+ * @param {string|null} className - A class name for further custom use cases.
10541
10586
  **/
10542
10587
  drawutilsgl.prototype.setCurrentClassName = function (className) {
10543
10588
  // NOOP
@@ -11190,7 +11235,9 @@ var GLU = /** @class */ (function () {
11190
11235
  * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
11191
11236
  * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
11192
11237
  * @modified 2022-11-10 Tweaking some type issues.
11193
- * @version 1.6.2
11238
+ * @modified 2023-02-04 Fixed a typo in the CSS classname for cubic Bézier paths: cubicBezier (was cubierBezier).
11239
+ * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
11240
+ * @version 1.6.4
11194
11241
  **/
11195
11242
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11196
11243
  exports.drawutilssvg = void 0;
@@ -11228,7 +11275,7 @@ var drawutilssvg = /** @class */ (function () {
11228
11275
  this.offset = new Vertex_1.Vertex(0, 0).set(offset);
11229
11276
  this.scale = new Vertex_1.Vertex(1, 1).set(scale);
11230
11277
  this.fillShapes = fillShapes;
11231
- this.isSecondary = isSecondary;
11278
+ this.isSecondary = Boolean(isSecondary);
11232
11279
  this.drawlibConfiguration = {};
11233
11280
  this.cache = new Map();
11234
11281
  this.setSize(canvasSize);
@@ -11258,6 +11305,8 @@ var drawutilssvg = /** @class */ (function () {
11258
11305
  // Which default styles to add? -> All from the DrawConfig.
11259
11306
  // Compare with DrawConfig interface
11260
11307
  var keys = {
11308
+ // "bezier": "CubicBezierCurve", // TODO: is this correct?
11309
+ "bezierPath": "BezierPath",
11261
11310
  "polygon": "Polygon",
11262
11311
  "triangle": "Triangle",
11263
11312
  "ellipse": "Ellipse",
@@ -11323,6 +11372,9 @@ var drawutilssvg = /** @class */ (function () {
11323
11372
  * @param {string} nodeName - The expected node name.
11324
11373
  */
11325
11374
  drawutilssvg.prototype.findElement = function (key, nodeName) {
11375
+ if (!key) {
11376
+ return null;
11377
+ }
11326
11378
  var node = this.cache.get(key);
11327
11379
  if (node && node.nodeName.toUpperCase() === nodeName.toUpperCase()) {
11328
11380
  this.cache.delete(key);
@@ -11397,8 +11449,8 @@ var drawutilssvg = /** @class */ (function () {
11397
11449
  else {
11398
11450
  node.setAttribute("class", className);
11399
11451
  }
11400
- node.setAttribute("fill", this.fillShapes ? color : "none");
11401
- node.setAttribute("stroke", this.fillShapes ? "none" : color);
11452
+ node.setAttribute("fill", this.fillShapes && color ? color : "none");
11453
+ node.setAttribute("stroke", this.fillShapes ? "none" : color || "none");
11402
11454
  node.setAttribute("stroke-width", "" + (lineWidth || 1));
11403
11455
  if (this.curId) {
11404
11456
  node.setAttribute("id", "" + this.curId); // Maybe React-style 'key' would be better?
@@ -11449,7 +11501,7 @@ var drawutilssvg = /** @class */ (function () {
11449
11501
  *
11450
11502
  * @name setCurrentId
11451
11503
  * @method
11452
- * @param {UID} uid - A UID identifying the currently drawn element(s).
11504
+ * @param {UID|null} uid - A UID identifying the currently drawn element(s).
11453
11505
  * @instance
11454
11506
  * @memberof drawutilssvg
11455
11507
  **/
@@ -11462,7 +11514,7 @@ var drawutilssvg = /** @class */ (function () {
11462
11514
  *
11463
11515
  * @name setCurrentClassName
11464
11516
  * @method
11465
- * @param {string} className - A class name for further custom use cases.
11517
+ * @param {string|null} className - A class name for further custom use cases.
11466
11518
  * @instance
11467
11519
  * @memberof drawutilssvg
11468
11520
  **/
@@ -11715,7 +11767,7 @@ var drawutilssvg = /** @class */ (function () {
11715
11767
  this._y(endPoint.y)
11716
11768
  ];
11717
11769
  node.setAttribute("d", d.join(" "));
11718
- return this._bindFillDraw(node, "cubierBezier", color, lineWidth);
11770
+ return this._bindFillDraw(node, "cubicBezier", color, lineWidth);
11719
11771
  };
11720
11772
  /**
11721
11773
  * Draw the given (cubic) Bézier path.