plotboilerplate 1.20.2 → 1.22.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 (169) hide show
  1. package/dist/index.esm.js +2012 -1366
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +1199 -541
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +3 -2
  10. package/src/cjs/BezierPath.d.ts +27 -49
  11. package/src/cjs/BezierPath.js +67 -234
  12. package/src/cjs/BezierPath.js.map +1 -1
  13. package/src/cjs/Bounds.d.ts +14 -1
  14. package/src/cjs/Bounds.js +21 -1
  15. package/src/cjs/Bounds.js.map +1 -1
  16. package/src/cjs/CubicBezierCurve.d.ts +70 -1
  17. package/src/cjs/CubicBezierCurve.js +130 -12
  18. package/src/cjs/CubicBezierCurve.js.map +1 -1
  19. package/src/cjs/Line.d.ts +2 -1
  20. package/src/cjs/Line.js +1 -0
  21. package/src/cjs/Line.js.map +1 -1
  22. package/src/cjs/PBText.d.ts +2 -1
  23. package/src/cjs/PBText.js +10 -9
  24. package/src/cjs/PBText.js.map +1 -1
  25. package/src/cjs/PlotBoilerplate.d.ts +4 -13
  26. package/src/cjs/PlotBoilerplate.js +61 -15
  27. package/src/cjs/PlotBoilerplate.js.map +1 -1
  28. package/src/cjs/Polygon.d.ts +47 -1
  29. package/src/cjs/Polygon.js +116 -1
  30. package/src/cjs/Polygon.js.map +1 -1
  31. package/src/cjs/VEllipse.js +1 -1
  32. package/src/cjs/VEllipse.js.map +1 -1
  33. package/src/cjs/Vector.d.ts +4 -4
  34. package/src/cjs/Vector.js +2 -2
  35. package/src/cjs/Vector.js.map +1 -1
  36. package/src/cjs/VertTuple.d.ts +2 -1
  37. package/src/cjs/VertTuple.js +4 -3
  38. package/src/cjs/VertTuple.js.map +1 -1
  39. package/src/cjs/Vertex.d.ts +14 -3
  40. package/src/cjs/Vertex.js +18 -3
  41. package/src/cjs/Vertex.js.map +1 -1
  42. package/src/cjs/draw.d.ts +154 -75
  43. package/src/cjs/draw.js +308 -137
  44. package/src/cjs/draw.js.map +1 -1
  45. package/src/cjs/drawgl.d.ts +87 -50
  46. package/src/cjs/drawgl.js +86 -31
  47. package/src/cjs/drawgl.js.map +1 -1
  48. package/src/cjs/drawutilssvg.d.ts +226 -53
  49. package/src/cjs/drawutilssvg.js +374 -92
  50. package/src/cjs/drawutilssvg.js.map +1 -1
  51. package/src/cjs/interfaces/DrawLib.d.ts +157 -79
  52. package/src/cjs/interfaces/DrawLib.js +6 -0
  53. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  54. package/src/cjs/interfaces/core.d.ts +13 -2
  55. package/src/cjs/interfaces/core.js +1 -0
  56. package/src/cjs/interfaces/core.js.map +1 -1
  57. package/src/cjs/utils/Params.d.ts +15 -0
  58. package/src/cjs/utils/Params.js +49 -0
  59. package/src/cjs/utils/Params.js.map +1 -0
  60. package/src/cjs/utils/algorithms/ContourLineDetection.d.ts +150 -0
  61. package/src/cjs/utils/algorithms/ContourLineDetection.js +367 -0
  62. package/src/cjs/utils/algorithms/ContourLineDetection.js.map +1 -0
  63. package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +21 -0
  64. package/src/cjs/utils/algorithms/clearDuplicateVertices.js +48 -0
  65. package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -0
  66. package/src/cjs/utils/creategui.js +16 -10
  67. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +47 -0
  68. package/src/cjs/utils/datastructures/DataGrid2d.js +20 -0
  69. package/src/cjs/utils/datastructures/DataGrid2d.js.map +1 -0
  70. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +65 -0
  71. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +84 -0
  72. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
  73. package/src/cjs/utils/datastructures/GenericPath.d.ts +14 -3
  74. package/src/cjs/utils/datastructures/GenericPath.js +20 -3
  75. package/src/cjs/utils/datastructures/GenericPath.js.map +1 -1
  76. package/src/cjs/utils/detectDarkMode.d.ts +10 -0
  77. package/src/cjs/utils/detectDarkMode.js +32 -0
  78. package/src/cjs/utils/detectDarkMode.js.map +1 -0
  79. package/src/esm/BezierPath.d.ts +27 -49
  80. package/src/esm/BezierPath.js +67 -234
  81. package/src/esm/BezierPath.js.map +1 -1
  82. package/src/esm/Bounds.d.ts +14 -1
  83. package/src/esm/Bounds.js +19 -1
  84. package/src/esm/Bounds.js.map +1 -1
  85. package/src/esm/CubicBezierCurve.d.ts +70 -1
  86. package/src/esm/CubicBezierCurve.js +130 -12
  87. package/src/esm/CubicBezierCurve.js.map +1 -1
  88. package/src/esm/Line.d.ts +2 -1
  89. package/src/esm/Line.js +1 -0
  90. package/src/esm/Line.js.map +1 -1
  91. package/src/esm/PBText.d.ts +2 -1
  92. package/src/esm/PBText.js +10 -9
  93. package/src/esm/PBText.js.map +1 -1
  94. package/src/esm/PlotBoilerplate.d.ts +4 -13
  95. package/src/esm/PlotBoilerplate.js +62 -16
  96. package/src/esm/PlotBoilerplate.js.map +1 -1
  97. package/src/esm/Polygon.d.ts +47 -1
  98. package/src/esm/Polygon.js +114 -1
  99. package/src/esm/Polygon.js.map +1 -1
  100. package/src/esm/VEllipse.js +1 -1
  101. package/src/esm/VEllipse.js.map +1 -1
  102. package/src/esm/Vector.d.ts +4 -4
  103. package/src/esm/Vector.js +2 -2
  104. package/src/esm/Vector.js.map +1 -1
  105. package/src/esm/VertTuple.d.ts +2 -1
  106. package/src/esm/VertTuple.js +4 -3
  107. package/src/esm/VertTuple.js.map +1 -1
  108. package/src/esm/Vertex.d.ts +14 -3
  109. package/src/esm/Vertex.js +18 -3
  110. package/src/esm/Vertex.js.map +1 -1
  111. package/src/esm/draw.d.ts +154 -75
  112. package/src/esm/draw.js +304 -135
  113. package/src/esm/draw.js.map +1 -1
  114. package/src/esm/drawgl.d.ts +87 -50
  115. package/src/esm/drawgl.js +86 -31
  116. package/src/esm/drawgl.js.map +1 -1
  117. package/src/esm/drawutilssvg.d.ts +226 -53
  118. package/src/esm/drawutilssvg.js +369 -92
  119. package/src/esm/drawutilssvg.js.map +1 -1
  120. package/src/esm/interfaces/DrawLib.d.ts +157 -79
  121. package/src/esm/interfaces/DrawLib.js +6 -0
  122. package/src/esm/interfaces/DrawLib.js.map +1 -1
  123. package/src/esm/interfaces/core.d.ts +13 -2
  124. package/src/esm/interfaces/core.js +1 -0
  125. package/src/esm/interfaces/core.js.map +1 -1
  126. package/src/esm/utils/Params.d.ts +15 -0
  127. package/src/esm/utils/Params.js +44 -0
  128. package/src/esm/utils/Params.js.map +1 -0
  129. package/src/esm/utils/algorithms/ContourLineDetection.d.ts +150 -0
  130. package/src/esm/utils/algorithms/ContourLineDetection.js +362 -0
  131. package/src/esm/utils/algorithms/ContourLineDetection.js.map +1 -0
  132. package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +21 -0
  133. package/src/esm/utils/algorithms/clearDuplicateVertices.js +44 -0
  134. package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -0
  135. package/src/esm/utils/datastructures/DataGrid2d.d.ts +47 -0
  136. package/src/esm/utils/datastructures/DataGrid2d.js +19 -0
  137. package/src/esm/utils/datastructures/DataGrid2d.js.map +1 -0
  138. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +65 -0
  139. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +79 -0
  140. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
  141. package/src/esm/utils/datastructures/GenericPath.d.ts +14 -3
  142. package/src/esm/utils/datastructures/GenericPath.js +20 -3
  143. package/src/esm/utils/datastructures/GenericPath.js.map +1 -1
  144. package/src/esm/utils/detectDarkMode.d.ts +10 -0
  145. package/src/esm/utils/detectDarkMode.js +28 -0
  146. package/src/esm/utils/detectDarkMode.js.map +1 -0
  147. package/src/ts/BezierPath.ts +72 -241
  148. package/src/ts/Bounds.ts +25 -1
  149. package/src/ts/CubicBezierCurve.ts +139 -12
  150. package/src/ts/Line.ts +2 -1
  151. package/src/ts/PBText.ts +10 -9
  152. package/src/ts/PlotBoilerplate.ts +56 -19
  153. package/src/ts/Polygon.ts +121 -1
  154. package/src/ts/VEllipse.ts +2 -2
  155. package/src/ts/Vector.ts +4 -4
  156. package/src/ts/VertTuple.ts +4 -3
  157. package/src/ts/Vertex.ts +20 -4
  158. package/src/ts/draw.ts +311 -115
  159. package/src/ts/drawgl.ts +133 -71
  160. package/src/ts/drawutilssvg.ts +543 -121
  161. package/src/ts/interfaces/DrawLib.ts +219 -83
  162. package/src/ts/interfaces/core.ts +14 -2
  163. package/src/ts/utils/Params.ts +47 -0
  164. package/src/ts/utils/algorithms/ContourLineDetection.ts +485 -0
  165. package/src/ts/utils/algorithms/clearDuplicateVertices.ts +49 -0
  166. package/src/ts/utils/datastructures/DataGrid2d.ts +54 -0
  167. package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +121 -0
  168. package/src/ts/utils/datastructures/GenericPath.ts +21 -3
  169. package/src/ts/utils/detectDarkMode.ts +30 -0
@@ -38,7 +38,15 @@
38
38
  * @modified 2022-11-10 Tweaking some type issues.
39
39
  * @modified 2023-02-04 Fixed a typo in the CSS classname for cubic Bézier paths: cubicBezier (was cubierBezier).
40
40
  * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.
41
- * @version 1.6.4
41
+ * @modified 2023-09-29 Added initialization checks for null parameters.
42
+ * @modified 2023-09-29 Added a missing implementation to the `drawurilssvg.do(XYCoords,string)` function. Didn't draw anything.
43
+ * @modified 2023-09-29 Downgrading all `Vertex` param type to the more generic `XYCoords` type in these render functions: line, arrow, texturedPoly, cubicBezier, cubicBezierPath, handle, handleLine, dot, point, circle, circleArc, ellipse, grid, raster.
44
+ * @modified 2023-09-29 Added the `headLength` parameter to the 'DrawLib.arrow()` function.
45
+ * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface.
46
+ * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface.
47
+ * @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline.
48
+ *
49
+ * @version 1.6.7
42
50
  **/
43
51
  Object.defineProperty(exports, "__esModule", { value: true });
44
52
  exports.drawutilssvg = void 0;
@@ -46,6 +54,7 @@ var CircleSector_1 = require("./CircleSector");
46
54
  var CubicBezierCurve_1 = require("./CubicBezierCurve");
47
55
  var Vertex_1 = require("./Vertex");
48
56
  var UIDGenerator_1 = require("./UIDGenerator");
57
+ var Vector_1 = require("./Vector");
49
58
  var RAD_TO_DEG = 180 / Math.PI;
50
59
  /**
51
60
  * @classdesc A helper class for basic SVG drawing operations. This class should
@@ -81,6 +90,9 @@ var drawutilssvg = /** @class */ (function () {
81
90
  this.cache = new Map();
82
91
  this.setSize(canvasSize);
83
92
  if (isSecondary) {
93
+ if (!gNode || !bufferGNode || !nodeDefs || !bufferNodeDefs) {
94
+ throw "Cannot create secondary svg draw lib with undefinde gNode|bufferGNode|nodeDefs|bufferNodeDefs.";
95
+ }
84
96
  this.gNode = gNode;
85
97
  this.bufferGNode = bufferGNode;
86
98
  this.nodeDefs = nodeDefs;
@@ -221,6 +233,9 @@ var drawutilssvg = /** @class */ (function () {
221
233
  if (this.drawlibConfiguration.blendMode) {
222
234
  node.style["mix-blend-mode"] = this.drawlibConfiguration.blendMode;
223
235
  }
236
+ // if (this.lineDashEnabled && this.lineDash && this.lineDash.length > 0 && drawutilssvg.nodeSupportsLineDash(nodeName)) {
237
+ // node.setAttribute("stroke-dasharray", this.lineDash.join(" "));
238
+ // }
224
239
  return node;
225
240
  };
226
241
  /**
@@ -243,23 +258,58 @@ var drawutilssvg = /** @class */ (function () {
243
258
  * @param {number=1} lineWidth - (optional) A line width to use for drawing (default is 1).
244
259
  * @return {SVGElement} The node itself (for chaining).
245
260
  */
246
- drawutilssvg.prototype._bindFillDraw = function (node, className, color, lineWidth) {
261
+ drawutilssvg.prototype._bindFillDraw = function (node, className, color, lineWidth, strokeOptions) {
262
+ this._configureNode(node, className, this.fillShapes, color, lineWidth, strokeOptions);
263
+ return this._bindNode(node, undefined);
264
+ };
265
+ /**
266
+ * Bind this given node to a parent. If no parent is passed then the global
267
+ * node buffer will be used.
268
+ *
269
+ * @method _bindNode
270
+ * @private
271
+ * @instance
272
+ * @memberof drawutilssvg
273
+ * @param {SVGElement} node - The SVG node to bind.
274
+ * @param {SVGElement=} bindingParent - (optional) You may pass node other than the glober buffer node.
275
+ * @returns {SVGElement} The passed node itself.
276
+ */
277
+ drawutilssvg.prototype._bindNode = function (node, bindingParent) {
278
+ if (!node.parentNode) {
279
+ // Attach to DOM only if not already attached
280
+ (bindingParent !== null && bindingParent !== void 0 ? bindingParent : this.bufferGNode).appendChild(node);
281
+ }
282
+ return node;
283
+ };
284
+ /**
285
+ * Add custom CSS class names and the globally defined CSS classname to the
286
+ * given node.
287
+ *
288
+ * @method addCSSClasses
289
+ * @private
290
+ * @instance
291
+ * @memberof drawutilssvg
292
+ * @param {SVGElement} node - The SVG node to bind.
293
+ * @param {string} className - The additional custom classname to add.
294
+ * @returns {void}
295
+ */
296
+ drawutilssvg.prototype._addCSSClasses = function (node, className) {
247
297
  if (this.curClassName) {
248
298
  node.setAttribute("class", className + " " + this.curClassName);
249
299
  }
250
300
  else {
251
301
  node.setAttribute("class", className);
252
302
  }
253
- node.setAttribute("fill", this.fillShapes && color ? color : "none");
254
- node.setAttribute("stroke", this.fillShapes ? "none" : color || "none");
303
+ };
304
+ drawutilssvg.prototype._configureNode = function (node, className, fillMode, color, lineWidth, strokeOptions) {
305
+ this._addCSSClasses(node, className);
306
+ node.setAttribute("fill", fillMode && color ? color : "none");
307
+ node.setAttribute("stroke", fillMode ? "none" : color || "none");
255
308
  node.setAttribute("stroke-width", "" + (lineWidth || 1));
256
309
  if (this.curId) {
257
310
  node.setAttribute("id", "" + this.curId); // Maybe React-style 'key' would be better?
258
311
  }
259
- if (!node.parentNode) {
260
- // Attach to DOM only if not already attached
261
- this.bufferGNode.appendChild(node);
262
- }
312
+ this.applyStrokeOpts(node, strokeOptions);
263
313
  return node;
264
314
  };
265
315
  /**
@@ -281,7 +331,7 @@ var drawutilssvg = /** @class */ (function () {
281
331
  * that under the hood the same gl context and gl program will be used.
282
332
  */
283
333
  drawutilssvg.prototype.copyInstance = function (fillShapes) {
284
- var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig
334
+ var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig – this will work as long as `isSecondary===true`
285
335
  true, // isSecondary
286
336
  this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);
287
337
  return copy;
@@ -296,6 +346,20 @@ var drawutilssvg = /** @class */ (function () {
296
346
  drawutilssvg.prototype.setConfiguration = function (configuration) {
297
347
  this.drawlibConfiguration = configuration;
298
348
  };
349
+ // /**
350
+ // * Set or clear the line-dash configuration. Pass `null` for un-dashed lines.
351
+ // *
352
+ // * See https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
353
+ // * and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash
354
+ // * for how line dashes work.
355
+ // *
356
+ // * @method
357
+ // * @param {Array<number> lineDashes - The line-dash array configuration.
358
+ // * @returns {void}
359
+ // */
360
+ // setLineDash(lineDashes: Array<number>) {
361
+ // this.lineDash = lineDashes;
362
+ // }
299
363
  /**
300
364
  * This method shouled be called each time the currently drawn `Drawable` changes.
301
365
  * It is used by some libraries for identifying elemente on re-renders.
@@ -370,6 +434,27 @@ var drawutilssvg = /** @class */ (function () {
370
434
  this.nodeDefs = this.bufferedNodeDefs;
371
435
  this.bufferedNodeDefs = tmpDefsNode;
372
436
  };
437
+ /**
438
+ * A private helper method to apply stroke options to the current
439
+ * context.
440
+ * @param {StrokeOptions=} strokeOptions -
441
+ */
442
+ drawutilssvg.prototype.applyStrokeOpts = function (node, strokeOptions) {
443
+ var _this = this;
444
+ if (strokeOptions &&
445
+ strokeOptions.dashArray &&
446
+ strokeOptions.dashArray.length > 0 &&
447
+ drawutilssvg.nodeSupportsLineDash(node.tagName)) {
448
+ node.setAttribute("stroke-dasharray", strokeOptions.dashArray
449
+ .map(function (dashArayElem) {
450
+ return dashArayElem * _this.scale.x;
451
+ })
452
+ .join(" "));
453
+ if (strokeOptions.dashOffset) {
454
+ node.setAttribute("stroke-dashoffset", "" + strokeOptions.dashOffset * this.scale.x);
455
+ }
456
+ }
457
+ };
373
458
  drawutilssvg.prototype._x = function (x) {
374
459
  return this.offset.x + this.scale.x * x;
375
460
  };
@@ -380,47 +465,104 @@ var drawutilssvg = /** @class */ (function () {
380
465
  * Draw the line between the given two points with the specified (CSS-) color.
381
466
  *
382
467
  * @method line
383
- * @param {Vertex} zA - The start point of the line.
384
- * @param {Vertex} zB - The end point of the line.
468
+ * @param {XYCoords} zA - The start point of the line.
469
+ * @param {XYCoords} zB - The end point of the line.
385
470
  * @param {string} color - Any valid CSS color string.
386
471
  * @param {number=1} lineWidth? - [optional] The line's width.
472
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
473
+ *
387
474
  * @return {void}
388
475
  * @instance
389
476
  * @memberof drawutilssvg
390
477
  **/
391
- drawutilssvg.prototype.line = function (zA, zB, color, lineWidth) {
392
- var line = this.makeNode("line");
393
- line.setAttribute("x1", "" + this._x(zA.x));
394
- line.setAttribute("y1", "" + this._y(zA.y));
395
- line.setAttribute("x2", "" + this._x(zB.x));
396
- line.setAttribute("y2", "" + this._y(zB.y));
397
- return this._bindFillDraw(line, "line", color, lineWidth || 1);
478
+ drawutilssvg.prototype.line = function (zA, zB, color, lineWidth, strokeOptions) {
479
+ // const line: SVGElement = this.makeNode("line");
480
+ // this.applyStrokeOpts(line, strokeOptions);
481
+ // line.setAttribute("x1", `${this._x(zA.x)}`);
482
+ // line.setAttribute("y1", `${this._y(zA.y)}`);
483
+ // line.setAttribute("x2", `${this._x(zB.x)}`);
484
+ // line.setAttribute("y2", `${this._y(zB.y)}`);
485
+ var line = this.makeLineNode(zA, zB, color, lineWidth, strokeOptions);
486
+ return this._bindFillDraw(line, "line", color, lineWidth || 1, strokeOptions);
398
487
  };
399
488
  /**
400
489
  * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
401
490
  *
402
491
  * @method arrow
403
- * @param {Vertex} zA - The start point of the arrow-line.
404
- * @param {Vertex} zB - The end point of the arrow-line.
492
+ * @param {XYCoords} zA - The start point of the arrow-line.
493
+ * @param {XYCoords} zB - The end point of the arrow-line.
405
494
  * @param {string} color - Any valid CSS color string.
406
495
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
496
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
497
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
498
+ *
407
499
  * @return {void}
408
500
  * @instance
409
501
  * @memberof drawutilssvg
410
502
  **/
411
- drawutilssvg.prototype.arrow = function (zA, zB, color, lineWidth) {
412
- var node = this.makeNode("path");
413
- var headlen = 8; // length of head in pixels
414
- var vertices = Vertex_1.Vertex.utils.buildArrowHead(zA, zB, headlen, this.scale.x, this.scale.y);
415
- var d = ["M", this._x(zA.x), this._y(zA.y)];
416
- for (var i = 0; i <= vertices.length; i++) {
417
- d.push("L");
418
- // Note: only use offset here (the vertices are already scaled)
419
- d.push(this.offset.x + vertices[i % vertices.length].x);
420
- d.push(this.offset.y + vertices[i % vertices.length].y);
421
- }
422
- node.setAttribute("d", d.join(" "));
423
- return this._bindFillDraw(node, "arrow", color, lineWidth || 1);
503
+ drawutilssvg.prototype.arrow = function (zA, zB, color, lineWidth, headLength, strokeOptions) {
504
+ if (headLength === void 0) { headLength = 8; }
505
+ var group = this.makeNode("g");
506
+ var arrowHeadBasePosition = { x: 0, y: 0 };
507
+ // Just create the child nodes, don't bind them to the root node.
508
+ var arrowHead = this.makeArrowHeadNode(zA, zB, color, lineWidth, headLength, undefined, arrowHeadBasePosition);
509
+ var line = this.makeLineNode(zA, arrowHeadBasePosition, color, lineWidth, strokeOptions);
510
+ group.appendChild(line);
511
+ group.appendChild(arrowHead);
512
+ this._addCSSClasses(group, "linear-arrow");
513
+ this._bindNode(group, undefined);
514
+ return group;
515
+ };
516
+ /**
517
+ * Draw a cubic Bézier curve and and an arrow at the end (endControlPoint) of the given line width the specified (CSS-) color and arrow size.
518
+ *
519
+ * @method cubicBezierArrow
520
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
521
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
522
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
523
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
524
+ * @param {string} color - The CSS color to draw the curve with.
525
+ * @param {number} lineWidth - (optional) The line width to use.
526
+ * @param {headLength=8} headLength - (optional) The length of the arrow head (default is 8 units).
527
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
528
+ *
529
+ * @return {void}
530
+ * @instance
531
+ * @memberof DrawLib
532
+ */
533
+ drawutilssvg.prototype.cubicBezierArrow = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth, headLength, strokeOptions) {
534
+ if (headLength === void 0) { headLength = 8; }
535
+ var group = this.makeNode("g");
536
+ // Just create the child nodes, don't bind them to the root node.
537
+ var arrowHeadBasePosition = new Vertex_1.Vertex(0, 0);
538
+ var arrowHead = this.makeArrowHeadNode(endControlPoint, endPoint, color, lineWidth, headLength, undefined, arrowHeadBasePosition);
539
+ var diff = arrowHeadBasePosition.difference(endPoint);
540
+ var bezier = this.makeCubicBezierNode(startPoint, { x: endPoint.x - diff.x, y: endPoint.y - diff.y }, startControlPoint, { x: endControlPoint.x - diff.x, y: endControlPoint.y - diff.y }, color, lineWidth, strokeOptions);
541
+ group.appendChild(bezier);
542
+ group.appendChild(arrowHead);
543
+ this._addCSSClasses(group, "cubicbezier-arrow");
544
+ this._bindNode(group, undefined);
545
+ return group;
546
+ };
547
+ /**
548
+ * Draw just an arrow head a the end of an imaginary line (zB) of the given line width the specified (CSS-) color and size.
549
+ *
550
+ * @method arrow
551
+ * @param {XYCoords} zA - The start point of the arrow-line.
552
+ * @param {XYCoords} zB - The end point of the arrow-line.
553
+ * @param {string} color - Any valid CSS color string.
554
+ * @param {number=1} lineWidth - (optional) The line width to use; default is 1.
555
+ * @param {number=8} headLength - (optional) The length of the arrow head (default is 8 pixels).
556
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
557
+ *
558
+ * @return {void}
559
+ * @instance
560
+ * @memberof DrawLib
561
+ **/
562
+ drawutilssvg.prototype.arrowHead = function (zA, zB, color, lineWidth, headLength, strokeOptions) {
563
+ if (headLength === void 0) { headLength = 8; }
564
+ var node = this.makeArrowHeadNode(zA, zB, color, lineWidth, headLength, strokeOptions);
565
+ return this._bindFillDraw(node, "arrowhead", color, lineWidth || 1, strokeOptions);
424
566
  };
425
567
  /**
426
568
  * Draw an image at the given position with the given size.<br>
@@ -429,8 +571,8 @@ var drawutilssvg = /** @class */ (function () {
429
571
  *
430
572
  * @method image
431
573
  * @param {Image} image - The image object to draw.
432
- * @param {Vertex} position - The position to draw the the upper left corner at.
433
- * @param {Vertex} size - The x/y-size to draw the image with.
574
+ * @param {XYCoords} position - The position to draw the the upper left corner at.
575
+ * @param {XYCoords} size - The x/y-size to draw the image with.
434
576
  * @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
435
577
  * @return {void}
436
578
  * @instance
@@ -475,16 +617,16 @@ var drawutilssvg = /** @class */ (function () {
475
617
  * @param {Image} textureImage - The image object to draw.
476
618
  * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
477
619
  * @param {Polygon} polygon - The polygon to use as clip path.
478
- * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
620
+ * @param {XYCoords} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
479
621
  * @param {number} rotation - The rotation to use for the polygon (and for the texture).
480
622
  * @return {void}
481
623
  * @instance
482
624
  * @memberof drawutilssvg
483
625
  **/
484
626
  drawutilssvg.prototype.texturedPoly = function (textureImage, textureSize, polygon, polygonPosition, rotation) {
485
- var basePolygonBounds = polygon.getBounds();
627
+ // const basePolygonBounds: Bounds = polygon.getBounds();
486
628
  var rotatedScalingOrigin = new Vertex_1.Vertex(textureSize.min).clone().rotate(rotation, polygonPosition);
487
- var rotationCenter = polygonPosition.clone().add(rotatedScalingOrigin.difference(textureSize.min).inv());
629
+ // const rotationCenter = polygonPosition.clone().add(rotatedScalingOrigin.difference(textureSize.min).inv());
488
630
  // Create something like this
489
631
  // ...
490
632
  // <defs>
@@ -539,36 +681,21 @@ var drawutilssvg = /** @class */ (function () {
539
681
  * Draw the given (cubic) bézier curve.
540
682
  *
541
683
  * @method cubicBezier
542
- * @param {Vertex} startPoint - The start point of the cubic Bézier curve
543
- * @param {Vertex} endPoint - The end point the cubic Bézier curve.
544
- * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.
545
- * @param {Vertex} endControlPoint - The end control point the cubic Bézier curve.
684
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
685
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
686
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
687
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
546
688
  * @param {string} color - The CSS color to draw the curve with.
547
689
  * @param {number} lineWidth - (optional) The line width to use.
690
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
691
+ *
548
692
  * @return {void}
549
693
  * @instance
550
694
  * @memberof drawutilssvg
551
695
  */
552
- drawutilssvg.prototype.cubicBezier = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {
553
- if (startPoint instanceof CubicBezierCurve_1.CubicBezierCurve) {
554
- return this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);
555
- }
556
- var node = this.makeNode("path");
557
- // Draw curve
558
- var d = [
559
- "M",
560
- this._x(startPoint.x),
561
- this._y(startPoint.y),
562
- "C",
563
- this._x(startControlPoint.x),
564
- this._y(startControlPoint.y),
565
- this._x(endControlPoint.x),
566
- this._y(endControlPoint.y),
567
- this._x(endPoint.x),
568
- this._y(endPoint.y)
569
- ];
570
- node.setAttribute("d", d.join(" "));
571
- return this._bindFillDraw(node, "cubicBezier", color, lineWidth);
696
+ drawutilssvg.prototype.cubicBezier = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth, strokeOptions) {
697
+ var node = this.makeCubicBezierNode(startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth, strokeOptions);
698
+ return this._bindNode(node, undefined);
572
699
  };
573
700
  /**
574
701
  * Draw the given (cubic) Bézier path.
@@ -578,17 +705,21 @@ var drawutilssvg = /** @class */ (function () {
578
705
  * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>
579
706
  *
580
707
  * @method cubicBezierPath
581
- * @param {Vertex[]} path - The cubic bezier path as described above.
708
+ * @param {XYCoords[]} path - The cubic bezier path as described above.
582
709
  * @param {string} color - The CSS colot to draw the path with.
583
710
  * @param {number=1} lineWidth - (optional) The line width to use.
711
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
712
+ *
584
713
  * @return {void}
585
714
  * @instance
586
715
  * @memberof drawutilssvg
587
716
  */
588
- drawutilssvg.prototype.cubicBezierPath = function (path, color, lineWidth) {
717
+ drawutilssvg.prototype.cubicBezierPath = function (path, color, lineWidth, strokeOptions) {
589
718
  var node = this.makeNode("path");
590
- if (!path || path.length == 0)
719
+ this.applyStrokeOpts(node, strokeOptions);
720
+ if (!path || path.length == 0) {
591
721
  return node;
722
+ }
592
723
  // Draw curve
593
724
  var d = ["M", this._x(path[0].x), this._y(path[0].y)];
594
725
  // Draw curve path
@@ -625,20 +756,20 @@ var drawutilssvg = /** @class */ (function () {
625
756
  * Draw a handle line (with a light grey).
626
757
  *
627
758
  * @method handleLine
628
- * @param {Vertex} startPoint - The start point to draw the handle at.
629
- * @param {Vertex} endPoint - The end point to draw the handle at.
759
+ * @param {XYCoords} startPoint - The start point to draw the handle at.
760
+ * @param {XYCoords} endPoint - The end point to draw the handle at.
630
761
  * @return {void}
631
762
  * @instance
632
763
  * @memberof drawutilssvg
633
764
  */
634
765
  drawutilssvg.prototype.handleLine = function (startPoint, endPoint) {
635
- this.line(startPoint, endPoint, "rgb(192,192,192)");
766
+ this.line(startPoint, endPoint, "rgb(128,128,128,0.5)");
636
767
  };
637
768
  /**
638
769
  * Draw a 1x1 dot with the specified (CSS-) color.
639
770
  *
640
771
  * @method dot
641
- * @param {Vertex} p - The position to draw the dot at.
772
+ * @param {XYCoords} p - The position to draw the dot at.
642
773
  * @param {string} color - The CSS color to draw the dot with.
643
774
  * @return {void}
644
775
  * @instance
@@ -646,13 +777,17 @@ var drawutilssvg = /** @class */ (function () {
646
777
  */
647
778
  drawutilssvg.prototype.dot = function (p, color) {
648
779
  var node = this.makeNode("line");
780
+ node.setAttribute("x1", "" + this._x(p.x));
781
+ node.setAttribute("y1", "" + this._y(p.y));
782
+ node.setAttribute("x2", "" + this._x(p.x));
783
+ node.setAttribute("y2", "" + this._y(p.y));
649
784
  return this._bindFillDraw(node, "dot", color, 1);
650
785
  };
651
786
  /**
652
787
  * Draw the given point with the specified (CSS-) color and radius 3.
653
788
  *
654
789
  * @method point
655
- * @param {Vertex} p - The position to draw the point at.
790
+ * @param {XYCoords} p - The position to draw the point at.
656
791
  * @param {string} color - The CSS color to draw the point with.
657
792
  * @return {void}
658
793
  * @instance
@@ -672,17 +807,20 @@ var drawutilssvg = /** @class */ (function () {
672
807
  * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.
673
808
  *
674
809
  * @method circle
675
- * @param {Vertex} center - The center of the circle.
810
+ * @param {XYCoords} center - The center of the circle.
676
811
  * @param {number} radius - The radius of the circle.
677
812
  * @param {string} color - The CSS color to draw the circle with.
678
813
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
814
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
815
+ *
679
816
  * @return {void}
680
817
  * @instance
681
818
  * @memberof drawutilssvg
682
819
  */
683
- drawutilssvg.prototype.circle = function (center, radius, color, lineWidth) {
820
+ drawutilssvg.prototype.circle = function (center, radius, color, lineWidth, strokeOptions) {
684
821
  // Todo: draw ellipse when scalex!=scaley
685
822
  var node = this.makeNode("circle");
823
+ this.applyStrokeOpts(node, strokeOptions);
686
824
  node.setAttribute("cx", "" + this._x(center.x));
687
825
  node.setAttribute("cy", "" + this._y(center.y));
688
826
  node.setAttribute("r", "" + radius * this.scale.x); // y?
@@ -692,17 +830,20 @@ var drawutilssvg = /** @class */ (function () {
692
830
  * Draw a circular arc (section of a circle) with the given CSS color.
693
831
  *
694
832
  * @method circleArc
695
- * @param {Vertex} center - The center of the circle.
833
+ * @param {XYCoords} center - The center of the circle.
696
834
  * @param {number} radius - The radius of the circle.
697
835
  * @param {number} startAngle - The angle to start at.
698
836
  * @param {number} endAngle - The angle to end at.
699
837
  * @param {string} color - The CSS color to draw the circle with.
838
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
839
+ *
700
840
  * @return {void}
701
841
  * @instance
702
842
  * @memberof drawutilssvg
703
843
  */
704
- drawutilssvg.prototype.circleArc = function (center, radius, startAngle, endAngle, color, lineWidth) {
844
+ drawutilssvg.prototype.circleArc = function (center, radius, startAngle, endAngle, color, lineWidth, strokeOptions) {
705
845
  var node = this.makeNode("path");
846
+ this.applyStrokeOpts(node, strokeOptions);
706
847
  var arcData = CircleSector_1.CircleSector.circleSectorUtils.describeSVGArc(this._x(center.x), this._y(center.y), radius * this.scale.x, // y?
707
848
  startAngle, endAngle);
708
849
  node.setAttribute("d", arcData.join(" "));
@@ -712,21 +853,24 @@ var drawutilssvg = /** @class */ (function () {
712
853
  * Draw an ellipse with the specified (CSS-) color and thw two radii.
713
854
  *
714
855
  * @method ellipse
715
- * @param {Vertex} center - The center of the ellipse.
856
+ * @param {XYCoords} center - The center of the ellipse.
716
857
  * @param {number} radiusX - The radius of the ellipse.
717
858
  * @param {number} radiusY - The radius of the ellipse.
718
859
  * @param {string} color - The CSS color to draw the ellipse with.
719
860
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
720
861
  * @param {number=} rotation - (optional, default=0) The rotation of the ellipse.
862
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
863
+ *
721
864
  * @return {void}
722
865
  * @instance
723
866
  * @memberof drawutilssvg
724
867
  */
725
- drawutilssvg.prototype.ellipse = function (center, radiusX, radiusY, color, lineWidth, rotation) {
868
+ drawutilssvg.prototype.ellipse = function (center, radiusX, radiusY, color, lineWidth, rotation, strokeOptions) {
726
869
  if (typeof rotation === "undefined") {
727
870
  rotation = 0.0;
728
871
  }
729
872
  var node = this.makeNode("ellipse");
873
+ this.applyStrokeOpts(node, strokeOptions);
730
874
  node.setAttribute("cx", "" + this._x(center.x));
731
875
  node.setAttribute("cy", "" + this._y(center.y));
732
876
  node.setAttribute("rx", "" + radiusX * this.scale.x);
@@ -742,15 +886,18 @@ var drawutilssvg = /** @class */ (function () {
742
886
  *
743
887
  * @method square
744
888
  * @param {XYCoords} center - The center of the square.
745
- * @param {Vertex} size - The size of the square.
889
+ * @param {number} size - The size of the square.
746
890
  * @param {string} color - The CSS color to draw the square with.
747
891
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
748
- * @return {void}
892
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
893
+ *
894
+ * @return {SVGElement}
749
895
  * @instance
750
896
  * @memberof drawutilssvg
751
897
  */
752
- drawutilssvg.prototype.square = function (center, size, color, lineWidth) {
898
+ drawutilssvg.prototype.square = function (center, size, color, lineWidth, strokeOptions) {
753
899
  var node = this.makeNode("rectangle");
900
+ this.applyStrokeOpts(node, strokeOptions);
754
901
  node.setAttribute("x", "" + this._x(center.x - size / 2.0));
755
902
  node.setAttribute("y", "" + this._y(center.y - size / 2.0));
756
903
  node.setAttribute("width", "" + size * this.scale.x);
@@ -765,9 +912,15 @@ var drawutilssvg = /** @class */ (function () {
765
912
  * @param {number} height - The height of the rectangle.
766
913
  * @param {string} color - The color to use.
767
914
  * @param {number=1} lineWidth - (optional) The line with to use (default is 1).
915
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
916
+ *
917
+ * @return {SVGElement}
918
+ * @instance
919
+ * @memberof drawutilssvg
768
920
  **/
769
- drawutilssvg.prototype.rect = function (position, width, height, color, lineWidth) {
921
+ drawutilssvg.prototype.rect = function (position, width, height, color, lineWidth, strokeOptions) {
770
922
  var node = this.makeNode("rect");
923
+ this.applyStrokeOpts(node, strokeOptions);
771
924
  node.setAttribute("x", "" + this._x(position.x));
772
925
  node.setAttribute("y", "" + this._y(position.y));
773
926
  node.setAttribute("width", "" + width * this.scale.x);
@@ -778,7 +931,7 @@ var drawutilssvg = /** @class */ (function () {
778
931
  * Draw a grid of horizontal and vertical lines with the given (CSS-) color.
779
932
  *
780
933
  * @method grid
781
- * @param {Vertex} center - The center of the grid.
934
+ * @param {XYCoords} center - The center of the grid.
782
935
  * @param {number} width - The total width of the grid (width/2 each to the left and to the right).
783
936
  * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).
784
937
  * @param {number} sizeX - The horizontal grid size.
@@ -812,7 +965,7 @@ var drawutilssvg = /** @class */ (function () {
812
965
  * This works analogue to the grid() function
813
966
  *
814
967
  * @method raster
815
- * @param {Vertex} center - The center of the raster.
968
+ * @param {XYCoords} center - The center of the raster.
816
969
  * @param {number} width - The total width of the raster (width/2 each to the left and to the right).
817
970
  * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).
818
971
  * @param {number} sizeX - The horizontal raster size.
@@ -845,8 +998,8 @@ var drawutilssvg = /** @class */ (function () {
845
998
  * as even shaped diamonds.
846
999
  *
847
1000
  * @method diamondHandle
848
- * @param {Vertex} center - The center of the diamond.
849
- * @param {Vertex} size - The x/y-size of the diamond.
1001
+ * @param {XYCoords} center - The center of the diamond.
1002
+ * @param {number} size - The x/y-size of the diamond.
850
1003
  * @param {string} color - The CSS color to draw the diamond with.
851
1004
  * @return {void}
852
1005
  * @instance
@@ -880,8 +1033,8 @@ var drawutilssvg = /** @class */ (function () {
880
1033
  * as even shaped squares.
881
1034
  *
882
1035
  * @method squareHandle
883
- * @param {Vertex} center - The center of the square.
884
- * @param {Vertex} size - The x/y-size of the square.
1036
+ * @param {XYCoords} center - The center of the square.
1037
+ * @param {XYCoords} size - The x/y-size of the square.
885
1038
  * @param {string} color - The CSS color to draw the square with.
886
1039
  * @return {void}
887
1040
  * @instance
@@ -903,7 +1056,7 @@ var drawutilssvg = /** @class */ (function () {
903
1056
  * as even shaped circles.
904
1057
  *
905
1058
  * @method circleHandle
906
- * @param {Vertex} center - The center of the circle.
1059
+ * @param {XYCoords} center - The center of the circle.
907
1060
  * @param {number} radius - The radius of the circle.
908
1061
  * @param {string} color - The CSS color to draw the circle with.
909
1062
  * @return {void}
@@ -1002,18 +1155,22 @@ var drawutilssvg = /** @class */ (function () {
1002
1155
  * Draw a polygon line (alternative function to the polygon).
1003
1156
  *
1004
1157
  * @method polyline
1005
- * @param {Vertex[]} vertices - The polygon vertices to draw.
1158
+ * @param {XYCoords[]} vertices - The polygon vertices to draw.
1006
1159
  * @param {boolan} isOpen - If true the polyline will not be closed at its end.
1007
1160
  * @param {string} color - The CSS color to draw the polygon with.
1008
1161
  * @param {number=} lineWidth - (optional) The line width to use; default is 1.
1162
+ * @param {StrokeOptions=} strokeOptions - (optional) Stroke settings to use.
1163
+ *
1009
1164
  * @return {void}
1010
1165
  * @instance
1011
1166
  * @memberof drawutilssvg
1012
1167
  */
1013
- drawutilssvg.prototype.polyline = function (vertices, isOpen, color, lineWidth) {
1168
+ drawutilssvg.prototype.polyline = function (vertices, isOpen, color, lineWidth, strokeOptions) {
1014
1169
  var node = this.makeNode("path");
1015
- if (vertices.length == 0)
1170
+ this.applyStrokeOpts(node, strokeOptions);
1171
+ if (vertices.length == 0) {
1016
1172
  return node;
1173
+ }
1017
1174
  // Draw curve
1018
1175
  var d = ["M", this._x(vertices[0].x), this._y(vertices[0].y)];
1019
1176
  var n = vertices.length;
@@ -1116,12 +1273,16 @@ var drawutilssvg = /** @class */ (function () {
1116
1273
  * @param {string=null} color - (optional) The color to draw this path with (default is null).
1117
1274
  * @param {number=1} lineWidth - (optional) the line width to use (default is 1).
1118
1275
  * @param {boolean=false} options.inplace - (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.
1276
+ * @param {number=} options.dashOffset - (optional) `See StrokeOptions`.
1277
+ * @param {number=[]} options.dashArray - (optional) `See StrokeOptions`.
1278
+ *
1119
1279
  * @instance
1120
1280
  * @memberof drawutils
1121
1281
  * @return {R} An instance representing the drawn path.
1122
1282
  */
1123
1283
  drawutilssvg.prototype.path = function (pathData, color, lineWidth, options) {
1124
1284
  var node = this.makeNode("path");
1285
+ this.applyStrokeOpts(node, options);
1125
1286
  // Transform the path: in-place (fast) or copy (slower)
1126
1287
  var d = options && options.inplace ? pathData : drawutilssvg.copyPathData(pathData);
1127
1288
  drawutilssvg.transformPathData(d, this.offset, this.scale);
@@ -1147,7 +1308,7 @@ var drawutilssvg = /** @class */ (function () {
1147
1308
  }
1148
1309
  // Add a covering rect with the given background color
1149
1310
  this.curId = "background";
1150
- this.curClassName = undefined;
1311
+ this.curClassName = null; // undefined;
1151
1312
  var node = this.makeNode("rect");
1152
1313
  // For some strange reason SVG rotation transforms use degrees instead of radians
1153
1314
  // Note that the background does not scale with the zoom level (always covers full element)
@@ -1159,7 +1320,7 @@ var drawutilssvg = /** @class */ (function () {
1159
1320
  this._bindFillDraw(node, this.curId, null, null);
1160
1321
  node.setAttribute("fill", typeof color === "undefined" ? "none" : color);
1161
1322
  // Clear the current ID again
1162
- this.curId = undefined;
1323
+ this.curId = null; // undefined;
1163
1324
  };
1164
1325
  /**
1165
1326
  * A private helper function to clear all SVG nodes from the &gt;g> node.
@@ -1364,6 +1525,127 @@ var drawutilssvg = /** @class */ (function () {
1364
1525
  }
1365
1526
  } // END while
1366
1527
  }; // END transformPathData
1528
+ drawutilssvg.nodeSupportsLineDash = function (nodeName) {
1529
+ return ["line", "path", "circle", "ellipse", "rectangle", "rect"].includes(nodeName);
1530
+ };
1531
+ /**
1532
+ * Creates a basic <line> node with start and end coordinates. The created node will not
1533
+ * be bound to any root node.
1534
+ *
1535
+ * @private
1536
+ * @method makeLineNode
1537
+ * @param {XYCoords} zA - The line's start position.
1538
+ * @param {XYCoords} zB - The line's start position.
1539
+ * @param {string} color - The CSS color to draw the point with.
1540
+ * @param {number=1} lineWidth - (optional) The line width to use.
1541
+ * @param {StrokeOptions=} strokeOptions - (optional) Additional stroke options to use.
1542
+ * @param {string=} classNameOverride - (optional) If nothing is passed the default classname 'path' will be used.
1543
+ * @return {SVGLineElement}
1544
+ * @instance
1545
+ * @memberof drawutilssvg
1546
+ */
1547
+ drawutilssvg.prototype.makeLineNode = function (zA, zB, color, lineWidth, strokeOptions, classNameOverride) {
1548
+ var line = this.makeNode("line");
1549
+ line.setAttribute("x1", "" + this._x(zA.x));
1550
+ line.setAttribute("y1", "" + this._y(zA.y));
1551
+ line.setAttribute("x2", "" + this._x(zB.x));
1552
+ line.setAttribute("y2", "" + this._y(zB.y));
1553
+ this._configureNode(line, classNameOverride !== null && classNameOverride !== void 0 ? classNameOverride : "line", this.fillShapes, color, lineWidth || 1, strokeOptions);
1554
+ return line;
1555
+ };
1556
+ /**
1557
+ * Creates a basic <path> node with given path string data. The created node will not
1558
+ * be bound to any root node.
1559
+ *
1560
+ * @private
1561
+ * @method makePathNode
1562
+ * @param {string} pathString - The path data (must be a valid path data string).
1563
+ * @param {string} color - The CSS color to draw the point with.
1564
+ * @param {number=1} lineWidth - (optional) The line width to use.
1565
+ * @param {StrokeOptions=} strokeOptions - (optional) Additional stroke options to use.
1566
+ * @param {string=} classNameOverride - (optional) If nothing is passed the default classname 'path' will be used.
1567
+ * @return {SVGPathElement}
1568
+ * @instance
1569
+ * @memberof drawutilssvg
1570
+ */
1571
+ drawutilssvg.prototype.makePathNode = function (pathString, color, lineWidth, strokeOptions, classNameOverride) {
1572
+ var path = this.makeNode("path");
1573
+ path.setAttribute("d", pathString);
1574
+ this._configureNode(path, classNameOverride !== null && classNameOverride !== void 0 ? classNameOverride : "path", this.fillShapes, color, lineWidth || 1, strokeOptions);
1575
+ return path;
1576
+ };
1577
+ /**
1578
+ * Creates a basic arrow head node (<path> node) at the end of the given line coordinates. The created node will not
1579
+ * be bound to any root node.
1580
+ *
1581
+ * @private
1582
+ * @method makeArrowHeadNode
1583
+ * @param {string} pathString - The path data (must be a valid path data string).
1584
+ * @param {string} color - The CSS color to draw the point with.
1585
+ * @param {number=1} lineWidth - (optional) The line width to use.
1586
+ * @param {number=8} headLength - (optional) The length of the arrow head; if none is specified then the head will be 8 absolute units long.
1587
+ * @param {StrokeOptions=} strokeOptions - (optional) Additional stroke options to use.
1588
+ * @param {XYCoords=} arrowHeadBasePositionBuffer - (optional) If not null, then this position will contain the arrow head's start point (after execution). Some sort of OUT variable.
1589
+ * @return {SVGPathElement}
1590
+ * @instance
1591
+ * @memberof drawutilssvg
1592
+ */
1593
+ drawutilssvg.prototype.makeArrowHeadNode = function (zA, zB, color, lineWidth, headLength, strokeOptions, arrowHeadBasePositionBuffer) {
1594
+ if (headLength === void 0) { headLength = 8; }
1595
+ var vertices = Vector_1.Vector.utils.buildArrowHead(zA, zB, headLength, this.scale.x, this.scale.y);
1596
+ var d = ["M", this.offset.x + vertices[0].x, this.offset.y + vertices[0].y];
1597
+ if (arrowHeadBasePositionBuffer) {
1598
+ arrowHeadBasePositionBuffer.x = vertices[0].x / this.scale.x;
1599
+ arrowHeadBasePositionBuffer.y = vertices[0].y / this.scale.y;
1600
+ }
1601
+ for (var i = 1; i <= vertices.length; i++) {
1602
+ d.push("L");
1603
+ // Note: only use offset here (the vertices are already scaled)
1604
+ d.push(this.offset.x + vertices[i % vertices.length].x);
1605
+ d.push(this.offset.y + vertices[i % vertices.length].y);
1606
+ }
1607
+ var node = this.makePathNode(d.join(" "), color, lineWidth, strokeOptions, "arrowhead");
1608
+ return node;
1609
+ };
1610
+ /**
1611
+ * Creates a basic cubic Bézier path node (<path> node) with the given cubic Bézier data. The created node will not
1612
+ * be bound to any root node.
1613
+ *
1614
+ * @private
1615
+ * @method makeCubicBezierNode
1616
+ * @param {XYCoords} startPoint - The start point of the cubic Bézier curve
1617
+ * @param {XYCoords} endPoint - The end point the cubic Bézier curve.
1618
+ * @param {XYCoords} startControlPoint - The start control point the cubic Bézier curve.
1619
+ * @param {XYCoords} endControlPoint - The end control point the cubic Bézier curve.
1620
+ * @param {string} color - The CSS color to draw the point with.
1621
+ * @param {number=1} lineWidth - (optional) The line width to use.
1622
+ * @param {StrokeOptions=} strokeOptions - (optional) Additional stroke options to use.
1623
+ * @param {string=} classNameOverride - (optional) If nothing is passed the default classname 'path' will be used.
1624
+ * @param {XYCoords=} arrowHeadBasePositionBuffer - (optional) If not null, then this position will contain the arrow head's start point (after execution). Some sort of OUT variable.
1625
+ * @return {SVGPathElement}
1626
+ * @instance
1627
+ * @memberof drawutilssvg
1628
+ */
1629
+ drawutilssvg.prototype.makeCubicBezierNode = function (startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth, strokeOptions) {
1630
+ if (startPoint instanceof CubicBezierCurve_1.CubicBezierCurve) {
1631
+ return this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);
1632
+ }
1633
+ // Draw curve
1634
+ var d = [
1635
+ "M",
1636
+ this._x(startPoint.x),
1637
+ this._y(startPoint.y),
1638
+ "C",
1639
+ this._x(startControlPoint.x),
1640
+ this._y(startControlPoint.y),
1641
+ this._x(endControlPoint.x),
1642
+ this._y(endControlPoint.y),
1643
+ this._x(endPoint.x),
1644
+ this._y(endPoint.y)
1645
+ ];
1646
+ var node = this.makePathNode(d.join(" "), color, lineWidth, strokeOptions, "cubicBezier");
1647
+ return node;
1648
+ };
1367
1649
  drawutilssvg.HEAD_XML = [
1368
1650
  '<?xml version="1.0" encoding="UTF-8" standalone="no"?>',
1369
1651
  '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" ',