plotboilerplate 1.16.0 → 1.17.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 (173) hide show
  1. package/README.md +1 -0
  2. package/changelog.md +26 -1
  3. package/dist/index.esm.js +355 -441
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.esm.min.js +1 -1
  6. package/dist/index.esm.min.js.map +1 -1
  7. package/dist/plotboilerplate.browser.min.js +1 -1
  8. package/dist/plotboilerplate.browser.min.js.map +1 -1
  9. package/dist/plotboilerplate.js +357 -345
  10. package/dist/plotboilerplate.min.js +1 -1
  11. package/package.json +1 -1
  12. package/src/cjs/BezierPath.d.ts +0 -14
  13. package/src/cjs/BezierPath.js +0 -26
  14. package/src/cjs/BezierPath.js.map +1 -1
  15. package/src/cjs/Bounds.d.ts +22 -1
  16. package/src/cjs/Bounds.js +24 -1
  17. package/src/cjs/Bounds.js.map +1 -1
  18. package/src/cjs/Circle.d.ts +0 -13
  19. package/src/cjs/Circle.js +0 -23
  20. package/src/cjs/Circle.js.map +1 -1
  21. package/src/cjs/CircleSector.d.ts +0 -13
  22. package/src/cjs/CircleSector.js +0 -27
  23. package/src/cjs/CircleSector.js.map +1 -1
  24. package/src/cjs/CubicBezierCurve.d.ts +0 -15
  25. package/src/cjs/CubicBezierCurve.js +0 -36
  26. package/src/cjs/CubicBezierCurve.js.map +1 -1
  27. package/src/cjs/Line.d.ts +0 -14
  28. package/src/cjs/Line.js +0 -26
  29. package/src/cjs/Line.js.map +1 -1
  30. package/src/cjs/PBImage.d.ts +0 -13
  31. package/src/cjs/PBImage.js +0 -14
  32. package/src/cjs/PBImage.js.map +1 -1
  33. package/src/cjs/PBText.d.ts +0 -13
  34. package/src/cjs/PBText.js +0 -14
  35. package/src/cjs/PBText.js.map +1 -1
  36. package/src/cjs/Polygon.d.ts +9 -15
  37. package/src/cjs/Polygon.js +12 -39
  38. package/src/cjs/Polygon.js.map +1 -1
  39. package/src/cjs/Triangle.d.ts +0 -13
  40. package/src/cjs/Triangle.js +0 -37
  41. package/src/cjs/Triangle.js.map +1 -1
  42. package/src/cjs/VEllipse.d.ts +0 -10
  43. package/src/cjs/VEllipse.js +0 -21
  44. package/src/cjs/VEllipse.js.map +1 -1
  45. package/src/cjs/Vector.d.ts +0 -14
  46. package/src/cjs/Vector.js +0 -36
  47. package/src/cjs/Vector.js.map +1 -1
  48. package/src/cjs/Vertex.d.ts +0 -14
  49. package/src/cjs/Vertex.js +0 -25
  50. package/src/cjs/Vertex.js.map +1 -1
  51. package/src/cjs/draw.d.ts +41 -2
  52. package/src/cjs/draw.js +140 -3
  53. package/src/cjs/draw.js.map +1 -1
  54. package/src/cjs/drawgl.d.ts +38 -2
  55. package/src/cjs/drawgl.js +41 -2
  56. package/src/cjs/drawgl.js.map +1 -1
  57. package/src/cjs/drawutilssvg.d.ts +66 -3
  58. package/src/cjs/drawutilssvg.js +140 -15
  59. package/src/cjs/drawutilssvg.js.map +1 -1
  60. package/src/cjs/index.d.ts +0 -1
  61. package/src/cjs/index.js +0 -1
  62. package/src/cjs/index.js.map +1 -1
  63. package/src/cjs/interfaces/DrawLib.d.ts +61 -26
  64. package/src/cjs/interfaces/DrawLib.js +2 -0
  65. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  66. package/src/cjs/interfaces/core.d.ts +0 -12
  67. package/src/cjs/module.d.ts +1 -3
  68. package/src/cjs/module.js +2 -5
  69. package/src/cjs/module.js.map +1 -1
  70. package/src/cjs/utils/creategui.js +16 -2
  71. package/src/cjs/utils/datastructures/Girih.d.ts +5 -0
  72. package/src/cjs/utils/datastructures/Girih.js +18 -14
  73. package/src/cjs/utils/datastructures/Girih.js.map +1 -1
  74. package/src/cjs/utils/datastructures/GirihPenroseRhombus.js +42 -25
  75. package/src/cjs/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
  76. package/src/cjs/utils/datastructures/GirihTile.js +2 -13
  77. package/src/cjs/utils/datastructures/GirihTile.js.map +1 -1
  78. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +2 -1
  79. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +9 -18
  80. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  81. package/src/esm/BezierPath.d.ts +0 -14
  82. package/src/esm/BezierPath.js +0 -26
  83. package/src/esm/BezierPath.js.map +1 -1
  84. package/src/esm/Bounds.d.ts +22 -1
  85. package/src/esm/Bounds.js +24 -1
  86. package/src/esm/Bounds.js.map +1 -1
  87. package/src/esm/Circle.d.ts +0 -13
  88. package/src/esm/Circle.js +0 -23
  89. package/src/esm/Circle.js.map +1 -1
  90. package/src/esm/CircleSector.d.ts +0 -13
  91. package/src/esm/CircleSector.js +0 -27
  92. package/src/esm/CircleSector.js.map +1 -1
  93. package/src/esm/CubicBezierCurve.d.ts +0 -15
  94. package/src/esm/CubicBezierCurve.js +0 -36
  95. package/src/esm/CubicBezierCurve.js.map +1 -1
  96. package/src/esm/Line.d.ts +0 -14
  97. package/src/esm/Line.js +0 -26
  98. package/src/esm/Line.js.map +1 -1
  99. package/src/esm/PBImage.d.ts +0 -13
  100. package/src/esm/PBImage.js +0 -14
  101. package/src/esm/PBImage.js.map +1 -1
  102. package/src/esm/PBText.d.ts +0 -13
  103. package/src/esm/PBText.js +0 -14
  104. package/src/esm/PBText.js.map +1 -1
  105. package/src/esm/Polygon.d.ts +9 -15
  106. package/src/esm/Polygon.js +12 -39
  107. package/src/esm/Polygon.js.map +1 -1
  108. package/src/esm/Triangle.d.ts +0 -13
  109. package/src/esm/Triangle.js +0 -37
  110. package/src/esm/Triangle.js.map +1 -1
  111. package/src/esm/VEllipse.d.ts +0 -10
  112. package/src/esm/VEllipse.js +0 -21
  113. package/src/esm/VEllipse.js.map +1 -1
  114. package/src/esm/Vector.d.ts +0 -14
  115. package/src/esm/Vector.js +0 -36
  116. package/src/esm/Vector.js.map +1 -1
  117. package/src/esm/Vertex.d.ts +0 -14
  118. package/src/esm/Vertex.js +0 -25
  119. package/src/esm/Vertex.js.map +1 -1
  120. package/src/esm/draw.d.ts +41 -2
  121. package/src/esm/draw.js +139 -3
  122. package/src/esm/draw.js.map +1 -1
  123. package/src/esm/drawgl.d.ts +38 -2
  124. package/src/esm/drawgl.js +41 -2
  125. package/src/esm/drawgl.js.map +1 -1
  126. package/src/esm/drawutilssvg.d.ts +66 -3
  127. package/src/esm/drawutilssvg.js +140 -15
  128. package/src/esm/drawutilssvg.js.map +1 -1
  129. package/src/esm/index.d.ts +0 -1
  130. package/src/esm/index.js +0 -1
  131. package/src/esm/index.js.map +1 -1
  132. package/src/esm/interfaces/DrawLib.d.ts +61 -26
  133. package/src/esm/interfaces/DrawLib.js +2 -0
  134. package/src/esm/interfaces/DrawLib.js.map +1 -1
  135. package/src/esm/interfaces/core.d.ts +0 -12
  136. package/src/esm/module.d.ts +1 -3
  137. package/src/esm/module.js +5 -4
  138. package/src/esm/module.js.map +1 -1
  139. package/src/esm/utils/datastructures/Girih.d.ts +5 -0
  140. package/src/esm/utils/datastructures/Girih.js +18 -14
  141. package/src/esm/utils/datastructures/Girih.js.map +1 -1
  142. package/src/esm/utils/datastructures/GirihPenroseRhombus.js +42 -25
  143. package/src/esm/utils/datastructures/GirihPenroseRhombus.js.map +1 -1
  144. package/src/esm/utils/datastructures/GirihTile.js +2 -13
  145. package/src/esm/utils/datastructures/GirihTile.js.map +1 -1
  146. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +2 -1
  147. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +9 -18
  148. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  149. package/src/ts/BezierPath.ts +0 -29
  150. package/src/ts/Bounds.ts +25 -1
  151. package/src/ts/Circle.ts +0 -26
  152. package/src/ts/CircleSector.ts +0 -30
  153. package/src/ts/CubicBezierCurve.ts +0 -39
  154. package/src/ts/Line.ts +0 -29
  155. package/src/ts/PBImage.ts +0 -15
  156. package/src/ts/PBText.ts +0 -17
  157. package/src/ts/Polygon.ts +16 -42
  158. package/src/ts/Triangle.ts +0 -40
  159. package/src/ts/VEllipse.ts +0 -24
  160. package/src/ts/Vector.ts +0 -40
  161. package/src/ts/Vertex.ts +0 -28
  162. package/src/ts/draw.ts +192 -3
  163. package/src/ts/drawgl.ts +44 -2
  164. package/src/ts/drawutilssvg.ts +181 -15
  165. package/src/ts/index.ts +0 -1
  166. package/src/ts/interfaces/DrawLib.ts +69 -26
  167. package/src/ts/interfaces/core.ts +0 -11
  168. package/src/ts/module.ts +2 -4
  169. package/src/ts/utils/datastructures/Girih.ts +204 -209
  170. package/src/ts/utils/datastructures/GirihPenroseRhombus.ts +170 -152
  171. package/src/ts/utils/datastructures/GirihTile.ts +394 -419
  172. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +9 -18
  173. package/src/ts/SVGBuilder.ts +0 -109
@@ -1443,32 +1443,6 @@ var BezierPath = /** @class */ (function () {
1443
1443
  }
1444
1444
  return true;
1445
1445
  };
1446
- /**
1447
- * Create a <pre>&lt;path&gt;</pre> SVG representation of this bézier curve.
1448
- *
1449
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
1450
- * @method toSVGString
1451
- * @param {object=} [options={}] - Like options.className
1452
- * @param {string=} [options.className] - The classname to use for the SVG item.
1453
- * @instance
1454
- * @memberof BezierPath
1455
- * @return {string} The SVG string.
1456
- **/
1457
- BezierPath.prototype.toSVGString = function (options) {
1458
- // options = options || {};
1459
- // var buffer: Array<string> = [];
1460
- // buffer.push("<path");
1461
- // if (options.className) buffer.push(' class="' + options.className + '"');
1462
- // buffer.push(' d="');
1463
- // for (var c = 0; c < this.bezierCurves.length; c++) {
1464
- // if (c > 0) buffer.push(" ");
1465
- // buffer.push(this.bezierCurves[c].toSVGPathData());
1466
- // }
1467
- // buffer.push('" />');
1468
- // return buffer.join("");
1469
- console.warn("[Deprecation] Warning: the BezierPath.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
1470
- return "";
1471
- };
1472
1446
  /**
1473
1447
  * This function should invalidate any installed listeners and invalidate this object.
1474
1448
  * After calling this function the object might not hold valid data any more and
@@ -1707,7 +1681,8 @@ exports.BezierPath = BezierPath;
1707
1681
  * @modified 2020-11-19 Set min, max, width and height to private.
1708
1682
  * @modified 2021-02-02 Added the `toPolygon` method.
1709
1683
  * @modified 2021-06-21 (mid-summer) Added `getCenter` method.
1710
- * @version 1.3.0
1684
+ * @modified 2022-02-01 Added the `toString` function.
1685
+ * @version 1.4.0
1711
1686
  **/
1712
1687
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1713
1688
  exports.Bounds = void 0;
@@ -1746,9 +1721,31 @@ var Bounds = /** @class */ (function () {
1746
1721
  Bounds.prototype.toPolygon = function () {
1747
1722
  return new Polygon_1.Polygon([new Vertex_1.Vertex(this.min), new Vertex_1.Vertex(this.max.x, this.min.y), new Vertex_1.Vertex(this.max), new Vertex_1.Vertex(this.min.x, this.max.y)], false);
1748
1723
  };
1724
+ /**
1725
+ * Get the center of this boinding box.
1726
+ *
1727
+ * @method getCenter
1728
+ * @instance
1729
+ * @memberof Bounds
1730
+ * @returns {Vertex} The center of these bounds.
1731
+ */
1749
1732
  Bounds.prototype.getCenter = function () {
1750
1733
  return new Vertex_1.Vertex(this.min.x + (this.max.x - this.min.x) / 2.0, this.min.y + (this.max.y - this.min.y) / 2);
1751
1734
  };
1735
+ /**
1736
+ * Convert these bounds to a human readable form.
1737
+ *
1738
+ * Note: the returned format might change in the future, so please do not
1739
+ * rely on the returned string format.
1740
+ *
1741
+ * @method toString
1742
+ * @instance
1743
+ * @memberof Bounds
1744
+ * @returns {string} Get these bounds in a human readable form.
1745
+ */
1746
+ Bounds.prototype.toString = function () {
1747
+ return "{ min: " + this.min.toString() + ", max : " + this.max.toString() + ", width: " + this.width + ", height : " + this.height + " }";
1748
+ };
1752
1749
  /**
1753
1750
  * Compute the minimal bounding box for a given set of vertices.
1754
1751
  *
@@ -1947,29 +1944,6 @@ var Circle = /** @class */ (function () {
1947
1944
  var y4 = p2.y + (h * (p1.x - p0.x)) / d;
1948
1945
  return new Line_1.Line(new Vertex_1.Vertex(x3, y3), new Vertex_1.Vertex(x4, y4));
1949
1946
  };
1950
- /**
1951
- * Create an SVG representation of this circle.
1952
- *
1953
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
1954
- * @method toSVGString
1955
- * @param {object=} options - An optional set of options, like 'className'.
1956
- * @return {string} A string representing the SVG code for this vertex.
1957
- * @instance
1958
- * @memberof Circle
1959
- */
1960
- Circle.prototype.toSVGString = function (options) {
1961
- // options = options || {};
1962
- // var buffer: Array<string> = [];
1963
- // buffer.push("<circle");
1964
- // if (options.className) buffer.push(' class="' + options.className + '"');
1965
- // buffer.push(' cx="' + this.center.x + '"');
1966
- // buffer.push(' cy="' + this.center.y + '"');
1967
- // buffer.push(' r="' + this.radius + '"');
1968
- // buffer.push(" />");
1969
- // return buffer.join("");
1970
- console.warn("[Deprecation] Warning: the Circle.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
1971
- return "";
1972
- };
1973
1947
  /**
1974
1948
  * This function should invalidate any installed listeners and invalidate this object.
1975
1949
  * After calling this function the object might not hold valid data any more and
@@ -2036,33 +2010,6 @@ var CircleSector = /** @class */ (function () {
2036
2010
  this.startAngle = startAngle;
2037
2011
  this.endAngle = endAngle;
2038
2012
  }
2039
- /**
2040
- * Create an SVG representation of this circle.
2041
- *
2042
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
2043
- * @method toSVGString
2044
- * @param {object=} options - An optional set of options, like 'className'.
2045
- * @return {string} A string representing the SVG code for this vertex.
2046
- * @instance
2047
- * @memberof Circle
2048
- */
2049
- CircleSector.prototype.toSVGString = function (options) {
2050
- // options = options || {};
2051
- // var buffer: Array<string> = [];
2052
- // buffer.push("<path ");
2053
- // if (options.className) buffer.push(' class="' + options.className + '"');
2054
- // const data: SVGPathParams = CircleSector.circleSectorUtils.describeSVGArc(
2055
- // this.circle.center.x,
2056
- // this.circle.center.y,
2057
- // this.circle.radius,
2058
- // this.startAngle,
2059
- // this.endAngle
2060
- // );
2061
- // buffer.push(' d="' + data.join(" ") + '" />');
2062
- // return buffer.join("");
2063
- console.warn("[Deprecation] Warning: the CircleSector.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
2064
- return "";
2065
- };
2066
2013
  /**
2067
2014
  * This function should invalidate any installed listeners and invalidate this object.
2068
2015
  * After calling this function the object might not hold valid data any more and
@@ -2706,42 +2653,6 @@ var CubicBezierCurve = /** @class */ (function () {
2706
2653
  */
2707
2654
  return obj instanceof CubicBezierCurve;
2708
2655
  };
2709
- /**
2710
- * Create an SVG path data representation of this bézier curve.
2711
- *
2712
- * Path data string format is:<br>
2713
- * <pre>'M x0 y1 C dx0 dy1 dx1 dy1 x1 x2'</pre><br>
2714
- * or in other words<br>
2715
- * <pre>'M startoint.x startPoint.y C startControlPoint.x startControlPoint.y endControlPoint.x endControlPoint.y endPoint.x endPoint.y'</pre>
2716
- *
2717
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
2718
- * @method toSVGPathData
2719
- * @instance
2720
- * @memberof CubicBezierCurve
2721
- * @return {string} The SVG path data string.
2722
- **/
2723
- CubicBezierCurve.prototype.toSVGPathData = function () {
2724
- // var buffer: Array<string> = [];
2725
- // buffer.push("M ");
2726
- // buffer.push(this.startPoint.x.toString());
2727
- // buffer.push(" ");
2728
- // buffer.push(this.startPoint.y.toString());
2729
- // buffer.push(" C ");
2730
- // buffer.push(this.startControlPoint.x.toString());
2731
- // buffer.push(" ");
2732
- // buffer.push(this.startControlPoint.y.toString());
2733
- // buffer.push(" ");
2734
- // buffer.push(this.endControlPoint.x.toString());
2735
- // buffer.push(" ");
2736
- // buffer.push(this.endControlPoint.y.toString());
2737
- // buffer.push(" ");
2738
- // buffer.push(this.endPoint.x.toString());
2739
- // buffer.push(" ");
2740
- // buffer.push(this.endPoint.y.toString());
2741
- // return buffer.join("");
2742
- console.warn("[Deprecation] Warning: the CubicBezierCurve.toSVGPathData method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
2743
- return "";
2744
- };
2745
2656
  /**
2746
2657
  * Convert this curve to a JSON string.
2747
2658
  *
@@ -3482,32 +3393,6 @@ var Line = /** @class */ (function (_super) {
3482
3393
  // if we cast these lines infinitely in both directions, they intersect here:
3483
3394
  return new Vertex_1.Vertex(x, y);
3484
3395
  };
3485
- /**
3486
- * Create an SVG representation of this line.
3487
- *
3488
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
3489
- * @method toSVGString
3490
- * @param {options} p - A set of options, like the 'classname' to use
3491
- * for the line object.
3492
- * @return {string} The SVG string representing this line.
3493
- * @instance
3494
- * @memberof Line
3495
- **/
3496
- Line.prototype.toSVGString = function (options) {
3497
- // options = options || {};
3498
- // var buffer = [];
3499
- // buffer.push( '<line' );
3500
- // if( options.className )
3501
- // buffer.push( ' class="' + options.className + '"' );
3502
- // buffer.push( ' x1="' + this.a.x + '"' );
3503
- // buffer.push( ' y1="' + this.a.y + '"' );
3504
- // buffer.push( ' x2="' + this.b.x + '"' );
3505
- // buffer.push( ' y2="' + this.b.y + '"' );
3506
- // buffer.push( ' />' );
3507
- // return buffer.join('');
3508
- console.warn("[Deprecation] Warning: the Line.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
3509
- return "";
3510
- };
3511
3396
  return Line;
3512
3397
  }(VertTuple_1.VertTuple));
3513
3398
  exports.Line = Line;
@@ -3990,20 +3875,6 @@ var PBImage = /** @class */ (function () {
3990
3875
  this.upperLeft = upperLeft;
3991
3876
  this.lowerRight = lowerRight;
3992
3877
  }
3993
- /**
3994
- * Convert this vertex to SVG code.
3995
- *
3996
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
3997
- * @method toSVGString
3998
- * @param {object=} options - An optional set of options, like 'className'.
3999
- * @return {string} A string representing the SVG code for this vertex.
4000
- * @instance
4001
- * @memberof PBImage
4002
- **/
4003
- PBImage.prototype.toSVGString = function (options) {
4004
- console.warn("PBImage is not yet SVG serializable. Returning empty SVG string.");
4005
- return "";
4006
- };
4007
3878
  /**
4008
3879
  * This function should invalidate any installed listeners and invalidate this object.
4009
3880
  * After calling this function the object might not hold valid data any more and
@@ -4073,20 +3944,6 @@ var PBText = /** @class */ (function () {
4073
3944
  this.textAlign = options.textAlign;
4074
3945
  this.rotation = options.rotation;
4075
3946
  }
4076
- /**
4077
- * Create an SVG representation of this circle.
4078
- *
4079
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
4080
- * @method toSVGString
4081
- * @param {object=} options - An optional set of options, like 'className'.
4082
- * @return {string} A string representing the SVG code for this vertex.
4083
- * @instance
4084
- * @memberof Circle
4085
- */
4086
- PBText.prototype.toSVGString = function (options) {
4087
- console.warn("[PBText.toSVGString()] This function is not implemented as it defines a deprecated method. Use the 'drawutilssvg.text()' method instead.");
4088
- return "";
4089
- };
4090
3947
  /**
4091
3948
  * This function should invalidate any installed listeners and invalidate this object.
4092
3949
  * After calling this function the object might not hold valid data any more and
@@ -6234,7 +6091,8 @@ __webpack_unused_export__ = PlotBoilerplate;
6234
6091
  * @modified 2021-12-16 Added the `getEvenDistributionPolygon()` function.
6235
6092
  * @modified 2022-02-02 Added the `destroy` method.
6236
6093
  * @modified 2022-02-02 Cleared the `Polygon.toSVGString` function (deprecated). Use `drawutilssvg` instead.
6237
- * @version 1.9.0
6094
+ * @modified 2022-03-08 Added the `Polygon.clone()` function.
6095
+ * @version 1.10.0
6238
6096
  *
6239
6097
  * @file Polygon
6240
6098
  * @public
@@ -6318,9 +6176,9 @@ var Polygon = /** @class */ (function () {
6318
6176
  * @memberof Polygon
6319
6177
  * @return {Polygon} this for chaining
6320
6178
  **/
6321
- Polygon.prototype.move = function (vert) {
6179
+ Polygon.prototype.move = function (amount) {
6322
6180
  for (var i in this.vertices) {
6323
- this.vertices[i].add(vert);
6181
+ this.vertices[i].add(amount);
6324
6182
  }
6325
6183
  return this;
6326
6184
  };
@@ -6499,6 +6357,14 @@ var Polygon = /** @class */ (function () {
6499
6357
  Polygon.prototype.getBounds = function () {
6500
6358
  return Bounds_1.Bounds.computeFromVertices(this.vertices);
6501
6359
  };
6360
+ /**
6361
+ * Create a deep copy of this polygon.
6362
+ *
6363
+ * @return {Polygon} The cloned polygon.
6364
+ */
6365
+ Polygon.prototype.clone = function () {
6366
+ return new Polygon(this.vertices.map(function (vert) { return vert.clone(); }), this.isOpen);
6367
+ };
6502
6368
  /**
6503
6369
  * Convert this polygon to a sequence of quadratic Bézier curves.<br>
6504
6370
  * <br>
@@ -6635,42 +6501,6 @@ var Polygon = /** @class */ (function () {
6635
6501
  }
6636
6502
  return BezierPath_1.BezierPath.fromArray(pathdata);
6637
6503
  };
6638
- /**
6639
- * Create an SVG representation of this polygon.
6640
- *
6641
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
6642
- * @method toSVGString
6643
- * @param {object=} options - An optional set of options, like 'className'.
6644
- * @return {string} The SVG string.
6645
- * @instance
6646
- * @memberof Polygon
6647
- **/
6648
- Polygon.prototype.toSVGString = function (options) {
6649
- // options = options || {};
6650
- // var buffer: Array<string> = [];
6651
- // buffer.push("<path");
6652
- // if (options.className) buffer.push(' class="' + options.className + '"');
6653
- // buffer.push(' d="');
6654
- // if (this.vertices.length > 0) {
6655
- // buffer.push("M ");
6656
- // buffer.push(this.vertices[0].x.toString());
6657
- // buffer.push(" ");
6658
- // buffer.push(this.vertices[0].y.toString());
6659
- // for (var i = 1; i < this.vertices.length; i++) {
6660
- // buffer.push(" L ");
6661
- // buffer.push(this.vertices[i].x.toString());
6662
- // buffer.push(" ");
6663
- // buffer.push(this.vertices[i].y.toString());
6664
- // }
6665
- // if (!this.isOpen) {
6666
- // buffer.push(" Z");
6667
- // }
6668
- // }
6669
- // buffer.push('" />');
6670
- // return buffer.join("");
6671
- console.warn("[Deprecation] Warning: the Polygon.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
6672
- return "";
6673
- };
6674
6504
  /**
6675
6505
  * This function should invalidate any installed listeners and invalidate this object.
6676
6506
  * After calling this function the object might not hold valid data any more and
@@ -7087,43 +6917,6 @@ var Triangle = /** @class */ (function () {
7087
6917
  Triangle.prototype.toString = function () {
7088
6918
  return "{ a : " + this.a.toString() + ", b : " + this.b.toString() + ", c : " + this.c.toString() + "}";
7089
6919
  };
7090
- /**
7091
- * Create an SVG representation of this triangle.
7092
- *
7093
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
7094
- * @method toSVGString
7095
- * @param {object=} options - An optional set of options, like 'className'.
7096
- * @return {string} The SVG string.
7097
- * @instance
7098
- * @memberof Triangle
7099
- **/
7100
- Triangle.prototype.toSVGString = function (options) {
7101
- // options = options || {};
7102
- // var buffer = [];
7103
- // buffer.push("<path");
7104
- // if (options.className) buffer.push(' class="' + options.className + '"');
7105
- // buffer.push(' d="');
7106
- // var vertices = [this.a, this.b, this.c];
7107
- // if (vertices.length > 0) {
7108
- // buffer.push("M ");
7109
- // buffer.push(vertices[0].x);
7110
- // buffer.push(" ");
7111
- // buffer.push(vertices[0].y);
7112
- // for (var i = 1; i < vertices.length; i++) {
7113
- // buffer.push(" L ");
7114
- // buffer.push(vertices[i].x);
7115
- // buffer.push(" ");
7116
- // buffer.push(vertices[i].y);
7117
- // }
7118
- // //if( !this.isOpen ) {
7119
- // buffer.push(" Z");
7120
- // //}
7121
- // }
7122
- // buffer.push('" />');
7123
- // return buffer.join("");
7124
- console.warn("[Deprecation] Warning: the Triangle.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
7125
- return "";
7126
- };
7127
6920
  /**
7128
6921
  * This function should invalidate any installed listeners and invalidate this object.
7129
6922
  * After calling this function the object might not hold valid data any more and
@@ -7549,27 +7342,6 @@ var VEllipse = /** @class */ (function () {
7549
7342
  }
7550
7343
  return curves;
7551
7344
  };
7552
- /**
7553
- * Create an SVG representation of this ellipse.
7554
- *
7555
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
7556
- * @param {object} options { className?:string }
7557
- * @return string The SVG string
7558
- */
7559
- VEllipse.prototype.toSVGString = function (options) {
7560
- // options = options || {};
7561
- // var buffer: Array<string> = [];
7562
- // buffer.push("<ellipse");
7563
- // if (options.className) buffer.push(' class="' + options.className + '"');
7564
- // buffer.push(' cx="' + this.center.x + '"');
7565
- // buffer.push(' cy="' + this.center.y + '"');
7566
- // buffer.push(' rx="' + this.axis.x + '"');
7567
- // buffer.push(' ry="' + this.axis.y + '"');
7568
- // buffer.push(" />");
7569
- // return buffer.join("");
7570
- console.warn("[Deprecation] Warning: the VEllipse.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
7571
- return "";
7572
- };
7573
7345
  /**
7574
7346
  * This function should invalidate any installed listeners and invalidate this object.
7575
7347
  * After calling this function the object might not hold valid data any more and
@@ -8055,42 +7827,6 @@ var Vector = /** @class */ (function (_super) {
8055
7827
  // if we cast these lines infinitely in both directions, they intersect here:
8056
7828
  return new Vertex_1.Vertex(this.a.x + a * (this.b.x - this.a.x), this.a.y + a * (this.b.y - this.a.y));
8057
7829
  };
8058
- /**
8059
- * Create an SVG representation of this line.
8060
- *
8061
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
8062
- * @method toSVGString
8063
- * @override
8064
- * @param {object=} options - A set of options, like 'className'.
8065
- * @return {string} The SVG string representation.
8066
- * @instance
8067
- * @memberof Vector
8068
- **/
8069
- Vector.prototype.toSVGString = function (options) {
8070
- // options = options || {};
8071
- // var buffer = [];
8072
- // var vertices = Vector.utils.buildArrowHead(this.a, this.b, 8, 1.0, 1.0);
8073
- // buffer.push("<g");
8074
- // if (options.className) buffer.push(' class="' + options.className + '"');
8075
- // buffer.push(">");
8076
- // buffer.push(" <line");
8077
- // buffer.push(' x1="' + this.a.x + '"');
8078
- // buffer.push(' y1="' + this.a.y + '"');
8079
- // buffer.push(' x2="' + vertices[0].x + '"');
8080
- // buffer.push(' y2="' + vertices[0].y + '"');
8081
- // buffer.push(" />");
8082
- // // Add arrow head
8083
- // buffer.push(' <polygon points="');
8084
- // for (var i = 0; i < vertices.length; i++) {
8085
- // if (i > 0) buffer.push(" ");
8086
- // buffer.push("" + vertices[i].x + "," + vertices[i].y);
8087
- // }
8088
- // buffer.push('"/>');
8089
- // buffer.push("</g>");
8090
- // return buffer.join("");
8091
- console.warn("[Deprecation] Warning: the Vector.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
8092
- return "";
8093
- };
8094
7830
  Vector.utils = {
8095
7831
  /**
8096
7832
  * Generate a four-point arrow head, starting at the vector end minus the
@@ -8974,31 +8710,6 @@ var Vertex = /** @class */ (function () {
8974
8710
  Vertex.prototype.toString = function () {
8975
8711
  return "(" + this.x + "," + this.y + ")";
8976
8712
  };
8977
- /**
8978
- * Convert this vertex to SVG code.
8979
- *
8980
- * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
8981
- * @method toSVGString
8982
- * @param {object=} options - An optional set of options, like 'className'.
8983
- * @return {string} A string representing the SVG code for this vertex.
8984
- * @instance
8985
- * @memberof Vertex
8986
- * @deprecated
8987
- **/
8988
- Vertex.prototype.toSVGString = function (options) {
8989
- // options = options || {};
8990
- // var buffer = [];
8991
- // buffer.push("<circle");
8992
- // if (options.className) buffer.push(' class="' + options.className + '"');
8993
- // buffer.push(' cx="' + this.x + '"');
8994
- // buffer.push(' cy="' + this.y + '"');
8995
- // buffer.push(' r="2"');
8996
- // buffer.push(" />");
8997
- // return buffer.join("");
8998
- console.warn("[Deprecation] Warning: the Vertex.toSVGString method is deprecated and does not return and valid SVG data any more. Please use `drawutilssvg` instead.");
8999
- return "";
9000
- };
9001
- // END Vertex
9002
8713
  /**
9003
8714
  * This function should invalidate any installed listeners and invalidate this object.
9004
8715
  * After calling this function the object might not hold valid data any more and
@@ -9465,7 +9176,10 @@ exports.VertexListeners = VertexListeners;
9465
9176
  * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.
9466
9177
  * @modified 2021-11-12 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.
9467
9178
  * @modified 2021-11-19 Added the `color` param to the `label(...)` function.
9468
- * @version 1.10.0
9179
+ * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
9180
+ * @modified 2022-02-03 Added the `cross(...)` function.
9181
+ * @modified 2022-03-27 Added the `texturedPoly` function.
9182
+ * @version 1.12.0
9469
9183
  **/
9470
9184
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9471
9185
  exports.drawutils = void 0;
@@ -9624,6 +9338,97 @@ var drawutils = /** @class */ (function () {
9624
9338
  this.offset.x + position.x * this.scale.x, this.offset.y + position.y * this.scale.y, size.x * this.scale.x, size.y * this.scale.y);
9625
9339
  this.ctx.restore();
9626
9340
  };
9341
+ /**
9342
+ * Draw an image at the given position with the given size.<br>
9343
+ * <br>
9344
+ * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
9345
+ *
9346
+ * @method texturedPoly
9347
+ * @param {Image} textureImage - The image object to draw.
9348
+ * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
9349
+ * @param {Polygon} polygon - The polygon to use as clip path.
9350
+ * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
9351
+ * @param {number} rotation - The rotation to use for the polygon (and for the texture).
9352
+ * @param {XYCoords={x:0,y:0}} rotationCenter - (optional) The rotational center; default is center of bounding box.
9353
+ * @return {void}
9354
+ * @instance
9355
+ * @memberof drawutils
9356
+ **/
9357
+ drawutils.prototype.texturedPoly = function (textureImage, textureSize, polygon, polygonPosition, rotation) {
9358
+ var basePolygonBounds = polygon.getBounds();
9359
+ var targetCenterDifference = polygonPosition.clone().difference(basePolygonBounds.getCenter());
9360
+ // var rotationalOffset = rotationCenter ? polygonPosition.difference(rotationCenter) : { x: 0, y: 0 };
9361
+ // var rotationalOffset = { x: 0, y: 0 };
9362
+ var tileCenter = basePolygonBounds.getCenter().sub(targetCenterDifference);
9363
+ // Get the position offset of the polygon
9364
+ var targetTextureSize = new Vertex_1.Vertex(textureSize.width, textureSize.height);
9365
+ // var targetTextureOffset = new Vertex(-textureSize.width / 2, -textureSize.height / 2).sub(targetCenterDifference);
9366
+ var targetTextureOffset = new Vertex_1.Vertex(textureSize.min.x, textureSize.min.y).sub(polygonPosition);
9367
+ this.ctx.save();
9368
+ // this.ctx.translate(this.offset.x + rotationCenter.x * this.scale.x, this.offset.y + rotationCenter.y * this.scale.y);
9369
+ this.ctx.translate(this.offset.x + polygonPosition.x * this.scale.x, this.offset.y + polygonPosition.y * this.scale.y);
9370
+ drawutils.helpers.clipPoly(this.ctx, {
9371
+ x: -polygonPosition.x * this.scale.x,
9372
+ y: -polygonPosition.y * this.scale.y
9373
+ }, this.scale, polygon.vertices);
9374
+ this.ctx.scale(this.scale.x, this.scale.y);
9375
+ this.ctx.rotate(rotation);
9376
+ this.ctx.drawImage(textureImage, 0, 0, textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)
9377
+ textureImage.naturalHeight - 1, // To avoid errors substract 1 here.
9378
+ targetTextureOffset.x, // * this.scale.x,
9379
+ targetTextureOffset.y, // * this.scale.y,
9380
+ targetTextureSize.x, // * this.scale.x,
9381
+ targetTextureSize.y // * this.scale.y
9382
+ );
9383
+ this.ctx.restore();
9384
+ };
9385
+ drawutils.prototype._texturedPoly = function (textureImage, textureSize, polygon, polygonPosition, rotation, rotationCenter) {
9386
+ if (rotationCenter === void 0) { rotationCenter = { x: 0, y: 0 }; }
9387
+ var basePolygonBounds = polygon.getBounds();
9388
+ var targetCenterDifference = polygonPosition.clone().difference(basePolygonBounds.getCenter());
9389
+ var rotationalOffset = rotationCenter ? polygonPosition.difference(rotationCenter) : { x: 0, y: 0 };
9390
+ // var rotationalOffset = { x: 0, y: 0 };
9391
+ var tileCenter = basePolygonBounds.getCenter().sub(targetCenterDifference);
9392
+ // Get the position offset of the polygon
9393
+ var targetTextureSize = new Vertex_1.Vertex(textureSize.width, textureSize.height);
9394
+ var targetTextureOffset = new Vertex_1.Vertex(-textureSize.width / 2, -textureSize.height / 2).sub(targetCenterDifference);
9395
+ this.ctx.save();
9396
+ // this.ctx.translate(
9397
+ // this.offset.x + (tileCenter.x - rotationalOffset.x * 0 + targetTextureOffset.x * 0.0) * this.scale.x,
9398
+ // this.offset.y + (tileCenter.y - rotationalOffset.y * 0 + targetTextureOffset.y * 0.0) * this.scale.y
9399
+ // );
9400
+ this.ctx.translate(this.offset.x + (tileCenter.x - rotationalOffset.x * 0 + targetTextureOffset.x * 0.0) * this.scale.x, this.offset.y + (tileCenter.y - rotationalOffset.y * 0 + targetTextureOffset.y * 0.0) * this.scale.y);
9401
+ this.ctx.rotate(rotation);
9402
+ drawutils.helpers.clipPoly(this.ctx, {
9403
+ x: (-targetCenterDifference.x * 1 - tileCenter.x - rotationalOffset.x) * this.scale.x,
9404
+ y: (-targetCenterDifference.y * 1 - tileCenter.y - rotationalOffset.y) * this.scale.y
9405
+ }, this.scale, polygon.vertices);
9406
+ this.ctx.drawImage(textureImage, 0, 0, textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)
9407
+ textureImage.naturalHeight - 1, // To avoid errors substract 1 here.
9408
+ (-polygonPosition.x + targetTextureOffset.x * 1 - rotationalOffset.x * 1) * this.scale.x, (-polygonPosition.y + targetTextureOffset.y * 1 - rotationalOffset.y * 1) * this.scale.y, targetTextureSize.x * this.scale.x, targetTextureSize.y * this.scale.y);
9409
+ // const scaledTextureSize = new Bounds(
9410
+ // new Vertex(
9411
+ // -polygonPosition.x + targetTextureOffset.x - rotationalOffset.x,
9412
+ // -polygonPosition.y + targetTextureOffset.y - rotationalOffset.y
9413
+ // ).scaleXY(this.scale, rotationCenter),
9414
+ // new Vertex(
9415
+ // -polygonPosition.x + targetTextureOffset.x - rotationalOffset.x + targetTextureSize.x,
9416
+ // -polygonPosition.y + targetTextureOffset.y - rotationalOffset.y + targetTextureSize.y
9417
+ // ).scaleXY(this.scale, rotationCenter)
9418
+ // );
9419
+ // this.ctx.drawImage(
9420
+ // textureImage,
9421
+ // 0,
9422
+ // 0,
9423
+ // textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)
9424
+ // textureImage.naturalHeight - 1, // To avoid errors substract 1 here.
9425
+ // scaledTextureSize.min.x,
9426
+ // scaledTextureSize.min.y,
9427
+ // scaledTextureSize.width,
9428
+ // scaledTextureSize.height
9429
+ // );
9430
+ this.ctx.restore();
9431
+ };
9627
9432
  /**
9628
9433
  * Draw a rectangle.
9629
9434
  *
@@ -10064,11 +9869,12 @@ var drawutils = /** @class */ (function () {
10064
9869
  * @param {XYCoords} center - The center of the crosshair.
10065
9870
  * @param {number} radius - The radius of the crosshair.
10066
9871
  * @param {string} color - The CSS color to draw the crosshair with.
9872
+ * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
10067
9873
  * @return {void}
10068
9874
  * @instance
10069
9875
  * @memberof drawutils
10070
9876
  */
10071
- drawutils.prototype.crosshair = function (center, radius, color) {
9877
+ drawutils.prototype.crosshair = function (center, radius, color, lineWidth) {
10072
9878
  this.ctx.save();
10073
9879
  this.ctx.beginPath();
10074
9880
  this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y);
@@ -10076,7 +9882,34 @@ var drawutils = /** @class */ (function () {
10076
9882
  this.ctx.moveTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y - radius);
10077
9883
  this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y + radius);
10078
9884
  this.ctx.strokeStyle = color;
10079
- this.ctx.lineWidth = 0.5;
9885
+ this.ctx.lineWidth = lineWidth || 0.5;
9886
+ this.ctx.stroke();
9887
+ this.ctx.closePath();
9888
+ this.ctx.restore();
9889
+ };
9890
+ /**
9891
+ * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>
9892
+ * <br>
9893
+ * Note that the x's radius will not be affected by scaling.
9894
+ *
9895
+ * @method crosshair
9896
+ * @param {XYCoords} center - The center of the crosshair.
9897
+ * @param {number} radius - The radius of the crosshair.
9898
+ * @param {string} color - The CSS color to draw the crosshair with.
9899
+ * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
9900
+ * @return {void}
9901
+ * @instance
9902
+ * @memberof drawutils
9903
+ */
9904
+ drawutils.prototype.cross = function (center, radius, color, lineWidth) {
9905
+ this.ctx.save();
9906
+ this.ctx.beginPath();
9907
+ this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y - radius);
9908
+ this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y + radius);
9909
+ this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y + radius);
9910
+ this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y - radius);
9911
+ this.ctx.strokeStyle = color;
9912
+ this.ctx.lineWidth = lineWidth || 1.0;
10080
9913
  this.ctx.stroke();
10081
9914
  this.ctx.closePath();
10082
9915
  this.ctx.restore();
@@ -10253,6 +10086,21 @@ var drawutils = /** @class */ (function () {
10253
10086
  this.ctx.fillStyle = color;
10254
10087
  this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
10255
10088
  };
10089
+ drawutils.helpers = {
10090
+ // A helper function to define the clipping path.
10091
+ // This could be a candidate for the draw library.
10092
+ clipPoly: function (ctx, offset, scale, vertices) {
10093
+ ctx.beginPath();
10094
+ // Set clip mask
10095
+ ctx.moveTo(offset.x + vertices[0].x * scale.x, offset.y + vertices[0].y * scale.y);
10096
+ for (var i = 1; i < vertices.length; i++) {
10097
+ var vert = vertices[i];
10098
+ ctx.lineTo(offset.x + vert.x * scale.x, offset.y + vert.y * scale.y);
10099
+ }
10100
+ ctx.closePath();
10101
+ ctx.clip();
10102
+ }
10103
+ };
10256
10104
  return drawutils;
10257
10105
  }());
10258
10106
  exports.drawutils = drawutils;
@@ -10272,7 +10120,10 @@ exports.drawutils = drawutils;
10272
10120
  * @modified 2020-10-15 Re-added the text() function.
10273
10121
  * @modified 2021-01-24 Added the `setCurrentId` function.
10274
10122
  * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.
10275
- * @version 0.0.5
10123
+ * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
10124
+ * @modified 2022-02-03 Added the `cross(...)` function.
10125
+ * @modified 2022-03-27 Added the `texturedPoly` function.
10126
+ * @version 0.0.7
10276
10127
  **/
10277
10128
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10278
10129
  exports.drawutilsgl = void 0;
@@ -10472,6 +10323,24 @@ var drawutilsgl = /** @class */ (function () {
10472
10323
  drawutilsgl.prototype.image = function (image, position, size) {
10473
10324
  // NOT YET IMPLEMENTED
10474
10325
  };
10326
+ /**
10327
+ * Draw an image at the given position with the given size.<br>
10328
+ * <br>
10329
+ * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
10330
+ *
10331
+ * @method texturedPoly
10332
+ * @param {Image} textureImage - The image object to draw.
10333
+ * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
10334
+ * @param {Polygon} polygon - The polygon to use as clip path.
10335
+ * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
10336
+ * @param {number} rotation - The rotation to use for the polygon (and for the texture).
10337
+ * @return {void}
10338
+ * @instance
10339
+ * @memberof drawutilsgl
10340
+ **/
10341
+ drawutilsgl.prototype.texturedPoly = function (textureImage, textureSize, polygon, polygonPosition, rotation) {
10342
+ // NOT YET IMPLEMENTED
10343
+ };
10475
10344
  // +---------------------------------------------------------------------------------
10476
10345
  // | This is the final helper function for drawing and filling stuff. It is not
10477
10346
  // | intended to be used from the outside.
@@ -10753,11 +10622,29 @@ var drawutilsgl = /** @class */ (function () {
10753
10622
  * @param {XYCoords} center - The center of the crosshair.
10754
10623
  * @param {number} radius - The radius of the crosshair.
10755
10624
  * @param {string} color - The CSS color to draw the crosshair with.
10625
+ * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
10756
10626
  * @return {void}
10757
10627
  * @instance
10758
10628
  * @memberof drawutils
10759
10629
  */
10760
- drawutilsgl.prototype.crosshair = function (center, radius, color) {
10630
+ drawutilsgl.prototype.crosshair = function (center, radius, color, lineWidth) {
10631
+ // NOT YET IMPLEMENTED
10632
+ };
10633
+ /**
10634
+ * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>
10635
+ * <br>
10636
+ * Note that the x's radius will not be affected by scaling.
10637
+ *
10638
+ * @method crosshair
10639
+ * @param {XYCoords} center - The center of the crosshair.
10640
+ * @param {number} radius - The radius of the crosshair.
10641
+ * @param {string} color - The CSS color to draw the crosshair with.
10642
+ * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
10643
+ * @return {void}
10644
+ * @instance
10645
+ * @memberof drawutils
10646
+ */
10647
+ drawutilsgl.prototype.cross = function (center, radius, color, lineWidth) {
10761
10648
  // NOT YET IMPLEMENTED
10762
10649
  };
10763
10650
  /**
@@ -10996,13 +10883,18 @@ var GLU = /** @class */ (function () {
10996
10883
  * @modified 2021-11-15 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.
10997
10884
  * @modified 2021-11-19 Fixing the `label(text,x,y)` position.
10998
10885
  * @modified 2021-11-19 Added the `color` param to the `label(...)` function.
10999
- * @version 1.4.0
10886
+ * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
10887
+ * @modified 2022-02-03 Added the `cross(...)` function.
10888
+ * @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.
10889
+ * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
10890
+ * @version 1.6.0
11000
10891
  **/
11001
10892
  Object.defineProperty(exports, "__esModule", ({ value: true }));
11002
10893
  exports.drawutilssvg = void 0;
11003
10894
  var CircleSector_1 = __webpack_require__(946);
11004
10895
  var CubicBezierCurve_1 = __webpack_require__(510);
11005
10896
  var Vertex_1 = __webpack_require__(421);
10897
+ var UIDGenerator_1 = __webpack_require__(197);
11006
10898
  var RAD_TO_DEG = 180 / Math.PI;
11007
10899
  /**
11008
10900
  * @classdesc A helper class for basic SVG drawing operations. This class should
@@ -11028,7 +10920,7 @@ var drawutilssvg = /** @class */ (function () {
11028
10920
  * @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.
11029
10921
  * @param {SVGGElement=} gNode - (optional) Primary and seconday instances share the same &lt;g> node.
11030
10922
  **/
11031
- function drawutilssvg(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode) {
10923
+ function drawutilssvg(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs) {
11032
10924
  this.svgNode = svgNode;
11033
10925
  this.offset = new Vertex_1.Vertex(0, 0).set(offset);
11034
10926
  this.scale = new Vertex_1.Vertex(1, 1).set(scale);
@@ -11040,14 +10932,23 @@ var drawutilssvg = /** @class */ (function () {
11040
10932
  if (isSecondary) {
11041
10933
  this.gNode = gNode;
11042
10934
  this.bufferGNode = bufferGNode;
10935
+ this.nodeDefs = nodeDefs;
10936
+ this.bufferedNodeDefs = bufferNodeDefs;
11043
10937
  }
11044
10938
  else {
11045
10939
  this.addStyleDefs(drawConfig);
10940
+ this.addDefsNode();
11046
10941
  this.gNode = this.createSVGNode("g");
11047
10942
  this.bufferGNode = this.createSVGNode("g");
11048
10943
  this.svgNode.appendChild(this.gNode);
11049
10944
  }
11050
10945
  }
10946
+ /**
10947
+ * Adds a default style defintion based on the passed DrawConfig.
10948
+ * Twaek the draw config to change default colors or line thicknesses.
10949
+ *
10950
+ * @param {DrawConfig} drawConfig
10951
+ */
11051
10952
  drawutilssvg.prototype.addStyleDefs = function (drawConfig) {
11052
10953
  this.nodeStyle = this.createSVGNode("style");
11053
10954
  this.svgNode.appendChild(this.nodeStyle);
@@ -11080,6 +10981,15 @@ var drawutilssvg = /** @class */ (function () {
11080
10981
  }
11081
10982
  this.nodeStyle.innerHTML = rules.join("\n");
11082
10983
  };
10984
+ /**
10985
+ * Adds the internal <defs> node.
10986
+ */
10987
+ drawutilssvg.prototype.addDefsNode = function () {
10988
+ this.nodeDefs = this.createSVGNode("defs");
10989
+ // this.svgNode.appendChild(this.nodeDefs);
10990
+ this.bufferedNodeDefs = this.createSVGNode("defs");
10991
+ this.svgNode.appendChild(this.nodeDefs);
10992
+ };
11083
10993
  /**
11084
10994
  * This is a simple way to include custom CSS class mappings to the style defs of the generated SVG.
11085
10995
  *
@@ -11217,7 +11127,7 @@ var drawutilssvg = /** @class */ (function () {
11217
11127
  drawutilssvg.prototype.copyInstance = function (fillShapes) {
11218
11128
  var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig
11219
11129
  true, // isSecondary
11220
- this.gNode, this.bufferGNode);
11130
+ this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);
11221
11131
  return copy;
11222
11132
  };
11223
11133
  /**
@@ -11294,11 +11204,15 @@ var drawutilssvg = /** @class */ (function () {
11294
11204
  // layout updates.
11295
11205
  // Replace the old <g>-node with the buffer node.
11296
11206
  // https://stackoverflow.com/questions/27442464/how-to-update-a-svg-image-without-seeing-a-blinking
11207
+ this.svgNode.replaceChild(this.bufferedNodeDefs, this.nodeDefs);
11297
11208
  this.svgNode.replaceChild(this.bufferGNode, this.gNode);
11298
11209
  }
11299
- var tmp = this.gNode;
11210
+ var tmpGNode = this.gNode;
11300
11211
  this.gNode = this.bufferGNode;
11301
- this.bufferGNode = tmp;
11212
+ this.bufferGNode = tmpGNode;
11213
+ var tmpDefsNode = this.nodeDefs;
11214
+ this.nodeDefs = this.bufferedNodeDefs;
11215
+ this.bufferedNodeDefs = tmpDefsNode;
11302
11216
  };
11303
11217
  drawutilssvg.prototype._x = function (x) {
11304
11218
  return this.offset.x + this.scale.x * x;
@@ -11391,6 +11305,75 @@ var drawutilssvg = /** @class */ (function () {
11391
11305
  node.setAttribute("href", image.src);
11392
11306
  return this._bindFillDraw(node, "image", null, null);
11393
11307
  };
11308
+ /**
11309
+ * Draw an image at the given position with the given size.<br>
11310
+ * <br>
11311
+ * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.
11312
+ *
11313
+ * @method texturedPoly
11314
+ * @param {Image} textureImage - The image object to draw.
11315
+ * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.
11316
+ * @param {Polygon} polygon - The polygon to use as clip path.
11317
+ * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.
11318
+ * @param {number} rotation - The rotation to use for the polygon (and for the texture).
11319
+ * @return {void}
11320
+ * @instance
11321
+ * @memberof drawutilssvg
11322
+ **/
11323
+ drawutilssvg.prototype.texturedPoly = function (textureImage, textureSize, polygon, polygonPosition, rotation) {
11324
+ var basePolygonBounds = polygon.getBounds();
11325
+ var rotatedScalingOrigin = new Vertex_1.Vertex(textureSize.min).clone().rotate(rotation, polygonPosition);
11326
+ var rotationCenter = polygonPosition.clone().add(rotatedScalingOrigin.difference(textureSize.min).inv());
11327
+ // Create something like this
11328
+ // ...
11329
+ // <defs>
11330
+ // <clipPath id="shape">
11331
+ // <path fill="none" d="..."/>
11332
+ // </clipPath>
11333
+ // </defs>
11334
+ // ...
11335
+ // <g clip-path="url(#shape)">
11336
+ // <g transform="scale(...)">
11337
+ // <image width="643" height="643" transform="rotate(...)" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/222579/beagle400.jpg" >
11338
+ // </g>
11339
+ // </g>
11340
+ // </image>
11341
+ // ...
11342
+ var clipPathNode = this.makeNode("clipPath");
11343
+ var clipPathId = "clippath_" + UIDGenerator_1.UIDGenerator.next(); // TODO: use a better UUID generator here?
11344
+ clipPathNode.setAttribute("id", clipPathId);
11345
+ var gNode = this.makeNode("g");
11346
+ var imageNode = this.makeNode("image");
11347
+ imageNode.setAttribute("x", "" + this._x(rotatedScalingOrigin.x));
11348
+ imageNode.setAttribute("y", "" + this._y(rotatedScalingOrigin.y));
11349
+ imageNode.setAttribute("width", "" + textureSize.width);
11350
+ imageNode.setAttribute("height", "" + textureSize.height);
11351
+ imageNode.setAttribute("href", textureImage.src);
11352
+ // imageNode.setAttribute("opacity", "0.5");
11353
+ // SVG rotations in degrees
11354
+ imageNode.setAttribute("transform", "rotate(" + rotation * RAD_TO_DEG + ", " + this._x(rotatedScalingOrigin.x) + ", " + this._y(rotatedScalingOrigin.y) + ")");
11355
+ var pathNode = this.makeNode("path");
11356
+ var pathData = [];
11357
+ if (polygon.vertices.length > 0) {
11358
+ var self_1 = this;
11359
+ pathData.push("M", "" + this._x(polygon.vertices[0].x), "" + this._y(polygon.vertices[0].y));
11360
+ for (var i = 1; i < polygon.vertices.length; i++) {
11361
+ pathData.push("L", "" + this._x(polygon.vertices[i].x), "" + this._y(polygon.vertices[i].y));
11362
+ }
11363
+ }
11364
+ pathNode.setAttribute("d", pathData.join(" "));
11365
+ clipPathNode.appendChild(pathNode);
11366
+ this.bufferedNodeDefs.appendChild(clipPathNode);
11367
+ gNode.appendChild(imageNode);
11368
+ gNode.setAttribute("transform-origin", this._x(rotatedScalingOrigin.x) + " " + this._y(rotatedScalingOrigin.y));
11369
+ gNode.setAttribute("transform", "scale(" + this.scale.x + ", " + this.scale.y + ")");
11370
+ var clipNode = this.makeNode("g");
11371
+ clipNode.appendChild(gNode);
11372
+ clipNode.setAttribute("clip-path", "url(#" + clipPathId + ")");
11373
+ // TODO: check if the image class is correct here or if we should use a 'clippedImage' class here
11374
+ this._bindFillDraw(clipNode, "image", null, null); // No color, no lineWidth
11375
+ return clipNode;
11376
+ };
11394
11377
  /**
11395
11378
  * Draw the given (cubic) bézier curve.
11396
11379
  *
@@ -11783,11 +11766,12 @@ var drawutilssvg = /** @class */ (function () {
11783
11766
  * @param {XYCoords} center - The center of the crosshair.
11784
11767
  * @param {number} radius - The radius of the crosshair.
11785
11768
  * @param {string} color - The CSS color to draw the crosshair with.
11769
+ * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.
11786
11770
  * @return {void}
11787
11771
  * @instance
11788
11772
  * @memberof drawutilssvg
11789
11773
  */
11790
- drawutilssvg.prototype.crosshair = function (center, radius, color) {
11774
+ drawutilssvg.prototype.crosshair = function (center, radius, color, lineWidth) {
11791
11775
  var node = this.makeNode("path");
11792
11776
  var d = [
11793
11777
  "M",
@@ -11804,7 +11788,40 @@ var drawutilssvg = /** @class */ (function () {
11804
11788
  this._y(center.y) + radius
11805
11789
  ];
11806
11790
  node.setAttribute("d", d.join(" "));
11807
- return this._bindFillDraw(node, "crosshair", color, 0.5);
11791
+ return this._bindFillDraw(node, "crosshair", color, lineWidth || 0.5);
11792
+ };
11793
+ /**
11794
+ * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>
11795
+ * <br>
11796
+ * Note that the x's radius will not be affected by scaling.
11797
+ *
11798
+ * @method crosshair
11799
+ * @param {XYCoords} center - The center of the crosshair.
11800
+ * @param {number} radius - The radius of the crosshair.
11801
+ * @param {string} color - The CSS color to draw the crosshair with.
11802
+ * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.
11803
+ * @return {void}
11804
+ * @instance
11805
+ * @memberof drawutils
11806
+ */
11807
+ drawutilssvg.prototype.cross = function (center, radius, color, lineWidth) {
11808
+ var node = this.makeNode("path");
11809
+ var d = [
11810
+ "M",
11811
+ this._x(center.x) - radius,
11812
+ this._y(center.y) - radius,
11813
+ "L",
11814
+ this._x(center.x) + radius,
11815
+ this._y(center.y) + radius,
11816
+ "M",
11817
+ this._x(center.x) - radius,
11818
+ this._y(center.y) + radius,
11819
+ "L",
11820
+ this._x(center.x) + radius,
11821
+ this._y(center.y) - radius
11822
+ ];
11823
+ node.setAttribute("d", d.join(" "));
11824
+ return this._bindFillDraw(node, "cross", color, lineWidth || 1.0);
11808
11825
  };
11809
11826
  /**
11810
11827
  * Draw a polygon.
@@ -11967,14 +11984,6 @@ var drawutilssvg = /** @class */ (function () {
11967
11984
  if (this.isSecondary) {
11968
11985
  return;
11969
11986
  }
11970
- // // Clearing an SVG is equivalent to removing all its child elements.
11971
- // for (var i = 0; i < this.gNode.childNodes.length; i++) {
11972
- // // Hide all nodes here. Don't throw them away.
11973
- // // We can probably re-use them in the next draw cycle.
11974
- // var child: SVGElement = this.gNode.childNodes[i] as SVGElement;
11975
- // this.cache.set(child.getAttribute("id"), child);
11976
- // }
11977
- // this.removeAllChildNodes();
11978
11987
  // Add a covering rect with the given background color
11979
11988
  this.curId = "background";
11980
11989
  this.curClassName = undefined;
@@ -12000,6 +12009,9 @@ var drawutilssvg = /** @class */ (function () {
12000
12009
  while (this.bufferGNode.lastChild) {
12001
12010
  this.bufferGNode.removeChild(this.bufferGNode.lastChild);
12002
12011
  }
12012
+ while (this.bufferedNodeDefs.lastChild) {
12013
+ this.bufferedNodeDefs.removeChild(this.bufferedNodeDefs.lastChild);
12014
+ }
12003
12015
  };
12004
12016
  /**
12005
12017
  * Create a new and empty `SVGElement` &lt;svg&gt; in the svg-namespace.