plotboilerplate 1.12.10 → 1.13.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 (73) hide show
  1. package/README.md +4 -1
  2. package/changelog.md +13 -0
  3. package/dist/index.esm.js +220 -26
  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 +234 -25
  10. package/dist/plotboilerplate.min.js +1 -1
  11. package/package.json +1 -1
  12. package/src/cjs/PBText.d.ts +116 -0
  13. package/src/cjs/PBText.js +66 -0
  14. package/src/cjs/PBText.js.map +1 -0
  15. package/src/cjs/PlotBoilerplate.d.ts +2 -1
  16. package/src/cjs/PlotBoilerplate.js +27 -1
  17. package/src/cjs/PlotBoilerplate.js.map +1 -1
  18. package/src/cjs/draw.d.ts +30 -2
  19. package/src/cjs/draw.js +51 -6
  20. package/src/cjs/draw.js.map +1 -1
  21. package/src/cjs/drawgl.d.ts +29 -2
  22. package/src/cjs/drawgl.js +21 -4
  23. package/src/cjs/drawgl.js.map +1 -1
  24. package/src/cjs/drawutilssvg.d.ts +25 -7
  25. package/src/cjs/drawutilssvg.js +62 -14
  26. package/src/cjs/drawutilssvg.js.map +1 -1
  27. package/src/cjs/entry.js +1 -0
  28. package/src/cjs/index.d.ts +1 -0
  29. package/src/cjs/index.js +1 -0
  30. package/src/cjs/index.js.map +1 -1
  31. package/src/cjs/interfaces/DrawLib.d.ts +27 -6
  32. package/src/cjs/interfaces/DrawLib.js +3 -0
  33. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  34. package/src/cjs/interfaces/core.d.ts +9 -1
  35. package/src/cjs/interfaces/core.js +1 -0
  36. package/src/cjs/interfaces/core.js.map +1 -1
  37. package/src/esm/PBText.d.ts +116 -0
  38. package/src/esm/PBText.js +61 -0
  39. package/src/esm/PBText.js.map +1 -0
  40. package/src/esm/PlotBoilerplate.d.ts +2 -1
  41. package/src/esm/PlotBoilerplate.js +27 -1
  42. package/src/esm/PlotBoilerplate.js.map +1 -1
  43. package/src/esm/draw.d.ts +30 -2
  44. package/src/esm/draw.js +51 -6
  45. package/src/esm/draw.js.map +1 -1
  46. package/src/esm/drawgl.d.ts +29 -2
  47. package/src/esm/drawgl.js +21 -4
  48. package/src/esm/drawgl.js.map +1 -1
  49. package/src/esm/drawutilssvg.d.ts +25 -7
  50. package/src/esm/drawutilssvg.js +62 -14
  51. package/src/esm/drawutilssvg.js.map +1 -1
  52. package/src/esm/entry.js +1 -0
  53. package/src/esm/index.d.ts +1 -0
  54. package/src/esm/index.js +1 -0
  55. package/src/esm/index.js.map +1 -1
  56. package/src/esm/interfaces/DrawLib.d.ts +27 -6
  57. package/src/esm/interfaces/DrawLib.js +3 -0
  58. package/src/esm/interfaces/DrawLib.js.map +1 -1
  59. package/src/esm/interfaces/core.d.ts +9 -1
  60. package/src/esm/interfaces/core.js +1 -0
  61. package/src/esm/interfaces/core.js.map +1 -1
  62. package/src/ts/PBText.ts +147 -0
  63. package/src/ts/PlotBoilerplate.ts +24 -1
  64. package/src/ts/draw.ts +71 -8
  65. package/src/ts/drawgl.ts +48 -8
  66. package/src/ts/drawutilssvg.ts +94 -17
  67. package/src/ts/index.ts +1 -0
  68. package/src/ts/interfaces/DrawLib.ts +30 -4
  69. package/src/ts/interfaces/core.ts +9 -0
  70. package/src/ts/utils/algorithms/clearPolygonDuplicateVertices.ts~ +0 -5
  71. package/src/ts/utils/algorithms/findPolygonSelfIntersections.ts~ +0 -45
  72. package/src/ts/utils/algorithms/splitPolygonToNonIntersecting.ts~ +0 -113
  73. package/src/ts/utils/algorithms/sutherlandHodgman.ts~ +0 -88
@@ -3900,6 +3900,78 @@ exports.PBImage = PBImage;
3900
3900
 
3901
3901
  /***/ }),
3902
3902
 
3903
+ /***/ 196:
3904
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3905
+
3906
+
3907
+ /**
3908
+ * @author Ikaros Kappler
3909
+ * @date 2021-11-16
3910
+ * @version 1.0.0
3911
+ **/
3912
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
3913
+ exports.PBText = void 0;
3914
+ var UIDGenerator_1 = __webpack_require__(197);
3915
+ var Vertex_1 = __webpack_require__(421);
3916
+ /**
3917
+ * @classdesc A simple text element: position, fontSize, fontFamily, color, textAlign, lineHeight and rotation.
3918
+ *
3919
+ * @requires FontOptions
3920
+ * @requires FontSize
3921
+ * @requires FontStyle
3922
+ * @requires FontWeight
3923
+ * @requires Vertex
3924
+ * @requires SVGSerializale
3925
+ * @requires UID
3926
+ * @requires UIDGenerator
3927
+ **/
3928
+ var PBText = /** @class */ (function () {
3929
+ /**
3930
+ * Create a new circle with given center point and radius.
3931
+ *
3932
+ * @constructor
3933
+ * @name Circle
3934
+ * @param {Vertex} center - The center point of the circle.
3935
+ * @param {number} radius - The radius of the circle.
3936
+ */
3937
+ function PBText(text, anchor, options) {
3938
+ /**
3939
+ * Required to generate proper CSS classes and other class related IDs.
3940
+ **/
3941
+ this.className = "PBText";
3942
+ this.uid = UIDGenerator_1.UIDGenerator.next();
3943
+ this.text = text;
3944
+ this.anchor = anchor !== null && anchor !== void 0 ? anchor : new Vertex_1.Vertex();
3945
+ this.color = options.color;
3946
+ this.fontFamily = options.fontFamily;
3947
+ this.fontSize = options.fontSize;
3948
+ this.fontStyle = options.fontStyle;
3949
+ this.fontWeight = options.fontWeight;
3950
+ this.lineHeight = options.lineHeight;
3951
+ this.textAlign = options.textAlign;
3952
+ this.rotation = options.rotation;
3953
+ }
3954
+ /**
3955
+ * Create an SVG representation of this circle.
3956
+ *
3957
+ * @deprecated DEPRECATION Please use the drawutilssvg library and an XMLSerializer instead.
3958
+ * @method toSVGString
3959
+ * @param {object=} options - An optional set of options, like 'className'.
3960
+ * @return {string} A string representing the SVG code for this vertex.
3961
+ * @instance
3962
+ * @memberof Circle
3963
+ */
3964
+ PBText.prototype.toSVGString = function (options) {
3965
+ console.warn("[PBText.toSVGString()] This function is not implemented as it defines a deprecated method. Use the 'drawutilssvg.text()' method instead.");
3966
+ return "";
3967
+ };
3968
+ return PBText;
3969
+ }()); // END class
3970
+ exports.PBText = PBText;
3971
+ //# sourceMappingURL=PBText.js.map
3972
+
3973
+ /***/ }),
3974
+
3903
3975
  /***/ 919:
3904
3976
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
3905
3977
 
@@ -3980,7 +4052,8 @@ var __webpack_unused_export__;
3980
4052
  * @modified 2021-03-03 Added the `VEllipseSector` drawable.
3981
4053
  * @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
3982
4054
  * @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
3983
- * @version 1.14.0
4055
+ * @modified 2021-11-16 Adding the `PBText` drawable.
4056
+ * @version 1.15.0
3984
4057
  *
3985
4058
  * @file PlotBoilerplate
3986
4059
  * @fileoverview The main class.
@@ -4008,6 +4081,7 @@ var VEllipseSector_1 = __webpack_require__(965);
4008
4081
  var Vector_1 = __webpack_require__(73);
4009
4082
  var Vertex_1 = __webpack_require__(421);
4010
4083
  var VertexAttr_1 = __webpack_require__(861);
4084
+ var PBText_1 = __webpack_require__(196);
4011
4085
  /**
4012
4086
  * @classdesc The main class of the PlotBoilerplate.
4013
4087
  *
@@ -4246,6 +4320,12 @@ var PlotBoilerplate = /** @class */ (function () {
4246
4320
  image: {
4247
4321
  color: "#a8a8a8",
4248
4322
  lineWidth: 1
4323
+ },
4324
+ text: {
4325
+ color: "rgba(192,0,128,0.5)",
4326
+ lineWidth: 1,
4327
+ fill: true,
4328
+ anchor: true
4249
4329
  }
4250
4330
  }; // END drawConfig
4251
4331
  // +---------------------------------------------------------------------------------
@@ -4553,6 +4633,11 @@ var PlotBoilerplate = /** @class */ (function () {
4553
4633
  });
4554
4634
  drawable.lowerRight.attr.selectable = false;
4555
4635
  }
4636
+ else if (drawable instanceof PBText_1.PBText) {
4637
+ this.vertices.push(drawable.anchor);
4638
+ this.drawables.push(drawable);
4639
+ drawable.anchor.attr.selectable = false;
4640
+ }
4556
4641
  else {
4557
4642
  throw "Cannot add drawable of unrecognized type: " + typeof drawable + ".";
4558
4643
  }
@@ -4651,6 +4736,9 @@ var PlotBoilerplate = /** @class */ (function () {
4651
4736
  this.removeVertex(drawable.upperLeft, false);
4652
4737
  this.removeVertex(drawable.lowerRight, false);
4653
4738
  }
4739
+ else if (drawable instanceof PBText_1.PBText) {
4740
+ this.removeVertex(drawable.anchor, false);
4741
+ }
4654
4742
  } // END removeWithVertices
4655
4743
  if (redraw) {
4656
4744
  this.redraw();
@@ -4976,6 +5064,16 @@ var PlotBoilerplate = /** @class */ (function () {
4976
5064
  d.lowerRight.attr.renderTime = renderTime;
4977
5065
  }
4978
5066
  }
5067
+ else if (d instanceof PBText_1.PBText) {
5068
+ fill.setCurrentId(d.uid);
5069
+ fill.text(d.text, d.anchor.x, d.anchor.y, d);
5070
+ if (this.drawConfig.text.anchor) {
5071
+ draw.setCurrentId(d.uid + "_a0");
5072
+ draw.setCurrentClassName(d.className + "-anchor");
5073
+ (this.drawConfig.text.fill ? fill : draw).point(d.anchor, this.drawConfig.text.color);
5074
+ }
5075
+ d.anchor.attr.renderTime = renderTime;
5076
+ }
4979
5077
  else {
4980
5078
  console.error("Cannot draw object. Unknown class.");
4981
5079
  }
@@ -9070,7 +9168,9 @@ exports.VertexListeners = VertexListeners;
9070
9168
  * @modified 2021-02-22 Added the `path` drawing function to draw SVG path data.
9071
9169
  * @modified 2021-03-31 Added the `endDrawCycle` function from `DrawLib`.
9072
9170
  * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.
9073
- * @version 1.9.0
9171
+ * @modified 2021-11-12 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.
9172
+ * @modified 2021-11-19 Added the `color` param to the `label(...)` function.
9173
+ * @version 1.10.0
9074
9174
  **/
9075
9175
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9076
9176
  exports.drawutils = void 0;
@@ -9730,20 +9830,62 @@ var drawutils = /** @class */ (function () {
9730
9830
  this.ctx.setLineDash([]);
9731
9831
  this.ctx.restore();
9732
9832
  };
9833
+ /**
9834
+ * Draw a text at the given relative position.
9835
+ *
9836
+ * @method text
9837
+ * @param {string} text - The text to draw.
9838
+ * @param {number} x - The x-position to draw the text at.
9839
+ * @param {number} y - The y-position to draw the text at.
9840
+ * @param {string=} options.color - The Color to use.
9841
+ * @param {string=} options.fontFamily - The font family to use.
9842
+ * @param {number=} options.fontSize - The font size (in pixels) to use.
9843
+ * @param {FontStyle=} options.fontStyle - The font style to use.
9844
+ * @param {FontWeight=} options.fontWeight - The font weight to use.
9845
+ * @param {number=} options.lineHeight - The line height (in pixels) to use.
9846
+ * @param {number=} options.rotation - The (optional) rotation in radians.
9847
+ * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `"left" || "right" || "center" || "start" || "end"`.
9848
+ * @return {void}
9849
+ * @instance
9850
+ * @memberof drawutils
9851
+ */
9733
9852
  drawutils.prototype.text = function (text, x, y, options) {
9853
+ // See https://stackoverflow.com/a/23523697
9854
+ var _a, _b, _c;
9734
9855
  options = options || {};
9735
9856
  this.ctx.save();
9736
- x = this.offset.x + x * this.scale.x;
9737
- y = this.offset.y + y * this.scale.y;
9857
+ var relX = this.offset.x + x * this.scale.x;
9858
+ var relY = this.offset.y + y * this.scale.y;
9738
9859
  var color = options.color || "black";
9860
+ if (options.fontSize || options.fontFamily) {
9861
+ // Scaling of text only works in uniform mode
9862
+ this.ctx.font =
9863
+ (options.fontWeight ? options.fontWeight + " " : "") +
9864
+ (options.fontStyle ? options.fontStyle + " " : "") +
9865
+ (options.fontSize ? options.fontSize * this.scale.x + "px " : " ") +
9866
+ (options.fontFamily
9867
+ ? options.fontFamily.indexOf(" ") === -1
9868
+ ? options.fontFamily
9869
+ : "\"" + options.fontFamily + "\""
9870
+ : "Arial");
9871
+ }
9872
+ if (options.textAlign) {
9873
+ this.ctx.textAlign = options.textAlign;
9874
+ }
9875
+ var rotation = (_a = options.rotation) !== null && _a !== void 0 ? _a : 0.0;
9876
+ var lineHeight = ((_c = (_b = options.lineHeight) !== null && _b !== void 0 ? _b : options.fontSize) !== null && _c !== void 0 ? _c : 0) * this.scale.x;
9877
+ this.ctx.translate(relX, relY);
9878
+ this.ctx.rotate(rotation);
9739
9879
  if (this.fillShapes) {
9740
9880
  this.ctx.fillStyle = color;
9741
- this.ctx.fillText(text, x, y);
9881
+ this.ctx.fillText(text, 0, lineHeight / 2);
9742
9882
  }
9743
9883
  else {
9744
9884
  this.ctx.strokeStyle = color;
9745
- this.ctx.strokeText(text, x, y);
9885
+ this.ctx.strokeText(text, 0, lineHeight / 2);
9746
9886
  }
9887
+ // this.ctx.translate(-relX, -relY);
9888
+ // this.ctx.rotate(-rotation); // is this necessary before 'restore()'?
9747
9889
  this.ctx.restore();
9748
9890
  };
9749
9891
  /**
@@ -9763,8 +9905,9 @@ var drawutils = /** @class */ (function () {
9763
9905
  */
9764
9906
  drawutils.prototype.label = function (text, x, y, rotation, color) {
9765
9907
  this.ctx.save();
9908
+ this.ctx.font = "lighter 9pt Arial";
9766
9909
  this.ctx.translate(x, y);
9767
- if (typeof rotation != "undefined")
9910
+ if (typeof rotation !== "undefined")
9768
9911
  this.ctx.rotate(rotation);
9769
9912
  this.ctx.fillStyle = color || "black";
9770
9913
  if (this.fillShapes) {
@@ -10385,6 +10528,25 @@ var drawutilsgl = /** @class */ (function () {
10385
10528
  drawutilsgl.prototype.polyline = function (vertices, isOpen, color, lineWidth) {
10386
10529
  // NOT YET IMPLEMENTED
10387
10530
  };
10531
+ /**
10532
+ * Draw a text at the given relative position.
10533
+ *
10534
+ * @method text
10535
+ * @param {string} text - The text to draw.
10536
+ * @param {number} x - The x-position to draw the text at.
10537
+ * @param {number} y - The y-position to draw the text at.
10538
+ * @param {string=} options.color - The Color to use.
10539
+ * @param {string=} options.fontFamily - The font family to use.
10540
+ * @param {number=} options.fontSize - The font size (in pixels) to use.
10541
+ * @param {FontStyle=} options.fontStyle - The font style to use.
10542
+ * @param {FontWeight=} options.fontWeight - The font weight to use.
10543
+ * @param {number=} options.lineHeight - The line height (in pixels) to use.
10544
+ * @param {number=} options.rotation - The (optional) rotation in radians.
10545
+ * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `"left" || "right" || "center" || "start" || "end"`.
10546
+ * @return {void}
10547
+ * @instance
10548
+ * @memberof drawutils
10549
+ */
10388
10550
  drawutilsgl.prototype.text = function (text, x, y, options) {
10389
10551
  // NOT YET IMPLEMENTED
10390
10552
  };
@@ -10396,14 +10558,12 @@ var drawutilsgl = /** @class */ (function () {
10396
10558
  * @param {number} x - The x-position to draw the text at.
10397
10559
  * @param {number} y - The y-position to draw the text at.
10398
10560
  * @param {number=} rotation - The (aoptional) rotation in radians.
10561
+ * @param {string="black"} color - The color to use (default is black).
10399
10562
  * @return {void}
10400
10563
  * @instance
10401
10564
  * @memberof drawutils
10402
10565
  */
10403
- // +---------------------------------------------------------------------------------
10404
- // | Draw a non-scaling text label at the given position.
10405
- // +-------------------------------
10406
- drawutilsgl.prototype.label = function (text, x, y, rotation) {
10566
+ drawutilsgl.prototype.label = function (text, x, y, rotation, color) {
10407
10567
  // NOT YET IMPLEMENTED
10408
10568
  };
10409
10569
  /**
@@ -10538,13 +10698,17 @@ var GLU = /** @class */ (function () {
10538
10698
  * @modified 2021-03-31 Added 'ellipseSector' the the class names.
10539
10699
  * @modified 2021-03-31 Implemented buffering using a buffer <g> node and the beginDrawCycle and endDrawCycle methods.
10540
10700
  * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.
10541
- * @version 1.3.0
10701
+ * @modified 2021-11-15 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.
10702
+ * @modified 2021-11-19 Fixing the `label(text,x,y)` position.
10703
+ * @modified 2021-11-19 Added the `color` param to the `label(...)` function.
10704
+ * @version 1.4.0
10542
10705
  **/
10543
10706
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10544
10707
  exports.drawutilssvg = void 0;
10545
10708
  var CircleSector_1 = __webpack_require__(946);
10546
10709
  var CubicBezierCurve_1 = __webpack_require__(510);
10547
10710
  var Vertex_1 = __webpack_require__(421);
10711
+ var RAD_TO_DEG = 180 / Math.PI;
10548
10712
  /**
10549
10713
  * @classdesc A helper class for basic SVG drawing operations. This class should
10550
10714
  * be compatible to the default 'draw' class.
@@ -10604,7 +10768,8 @@ var drawutilssvg = /** @class */ (function () {
10604
10768
  "vertex": "Vertex",
10605
10769
  "line": "Line",
10606
10770
  "vector": "Vector",
10607
- "image": "Image"
10771
+ "image": "Image",
10772
+ "text": "Text"
10608
10773
  };
10609
10774
  // Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)
10610
10775
  var rules = [];
@@ -11385,27 +11550,65 @@ var drawutilssvg = /** @class */ (function () {
11385
11550
  if (!isOpen)
11386
11551
  d.push("Z");
11387
11552
  node.setAttribute("d", d.join(" "));
11388
- return this._bindFillDraw(node, "polyline", color, lineWidth || 1);
11553
+ return this._bindFillDraw(node, "polygon", color, lineWidth || 1);
11389
11554
  };
11390
11555
  /**
11391
- * Draw a text label at the given relative position.
11556
+ * Draw a text at the given relative position.
11392
11557
  *
11393
- * @method label
11558
+ * @method text
11394
11559
  * @param {string} text - The text to draw.
11395
11560
  * @param {number} x - The x-position to draw the text at.
11396
11561
  * @param {number} y - The y-position to draw the text at.
11397
- * @param {number=} rotation - The (optional) rotation in radians.
11562
+ * @param {string=} options.color - The Color to use.
11563
+ * @param {string=} options.fontFamily - The font family to use.
11564
+ * @param {number=} options.fontSize - The font size (in pixels) to use.
11565
+ * @param {FontStyle=} options.fontStyle - The font style to use.
11566
+ * @param {FontWeight=} options.fontWeight - The font weight to use.
11567
+ * @param {number=} options.lineHeight - The line height (in pixels) to use.
11568
+ * @param {number=} options.rotation - The (optional) rotation in radians.
11569
+ * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `"left" || "right" || "center" || "start" || "end"`.
11398
11570
  * @return {void}
11399
11571
  * @instance
11400
- * @memberof drawutilssvg
11572
+ * @memberof drawutils
11401
11573
  */
11402
11574
  drawutilssvg.prototype.text = function (text, x, y, options) {
11575
+ var _a, _b;
11403
11576
  options = options || {};
11404
11577
  var color = options.color || "black";
11405
- var node = this.makeNode("text");
11406
- node.setAttribute("x", "" + this._x(x));
11407
- node.setAttribute("y", "" + this._y(y));
11408
- node.innerHTML = text;
11578
+ var lineHeight = ((_b = (_a = options.lineHeight) !== null && _a !== void 0 ? _a : options.fontSize) !== null && _b !== void 0 ? _b : 0) * this.scale.x;
11579
+ // https://www.w3.org/TR/SVG/text.html#TextAnchorProperty
11580
+ // start | middle | end
11581
+ var textAlign = options.textAlign === "left" || options.textAlign === "start"
11582
+ ? "start"
11583
+ : options.textAlign === "center"
11584
+ ? "middle"
11585
+ : options.textAlign === "right" || options.textAlign === "end"
11586
+ ? "end"
11587
+ : "start";
11588
+ var transformOrigin = this._x(x) + "px " + this._y(y) + "px";
11589
+ var translate = "translate(" + this._x(x) + " " + (this._y(y) + lineHeight / 2) + ")";
11590
+ // Safari has a transform-origin/rotation bug.
11591
+ // It's essential to use rotate(r,x,y) here. "rotate(r)"" with transform-origin(x,y) won't do the job.
11592
+ // And rotate and translate cannot be used is combination on a text object.
11593
+ // So wrap the text inside a <g>, translate the <g>, and rotate the text inside.
11594
+ var rotate = options.rotation ? "rotate(" + options.rotation * RAD_TO_DEG + " 0 0)" : "";
11595
+ var node = this.makeNode("g");
11596
+ var curId = this.curId;
11597
+ this.curId = curId + "_text";
11598
+ var textNode = this.makeNode("text");
11599
+ node.appendChild(textNode);
11600
+ textNode.setAttribute("font-family", options.fontFamily); // May be undefined
11601
+ textNode.setAttribute("font-size", options.fontSize ? "" + options.fontSize * this.scale.x : null);
11602
+ textNode.setAttribute("font-style", options.fontStyle ? "" + options.fontStyle : null);
11603
+ textNode.setAttribute("font-weight", options.fontWeight ? "" + options.fontWeight : null);
11604
+ textNode.setAttribute("text-anchor", textAlign);
11605
+ textNode.setAttribute("transform-origin", "0 0");
11606
+ textNode.setAttribute("transform", rotate);
11607
+ node.setAttribute("transform-origin", transformOrigin);
11608
+ node.setAttribute("transform", translate);
11609
+ textNode.innerHTML = text;
11610
+ // Restore old ID
11611
+ this.curId = curId;
11409
11612
  return this._bindFillDraw(node, "text", color, 1);
11410
11613
  };
11411
11614
  /**
@@ -11416,16 +11619,21 @@ var drawutilssvg = /** @class */ (function () {
11416
11619
  * @param {number} x - The x-position to draw the text at.
11417
11620
  * @param {number} y - The y-position to draw the text at.
11418
11621
  * @param {number=} rotation - The (optional) rotation in radians.
11622
+ * @param {string="black"} color - The color to use (default is black).
11419
11623
  * @return {void}
11420
11624
  * @instance
11421
11625
  * @memberof drawutilssvg
11422
11626
  */
11423
- drawutilssvg.prototype.label = function (text, x, y, rotation) {
11627
+ drawutilssvg.prototype.label = function (text, x, y, rotation, color) {
11424
11628
  var node = this.makeNode("text");
11425
11629
  // For some strange reason SVG rotation transforms use degrees instead of radians
11426
- node.setAttribute("transform", "translate(" + this.offset.x + "," + this.offset.y + "), rotate(" + (rotation / Math.PI) * 180 + ")");
11630
+ node.setAttribute("transform", "translate(" + x + "," + y + "), rotate(" + ((rotation || 0) / Math.PI) * 180 + ")");
11631
+ node.setAttribute("font-family", "Arial");
11632
+ node.setAttribute("font-size", "9pt");
11633
+ node.setAttribute("font-style", "normal");
11634
+ node.setAttribute("font-weight", "lighter");
11427
11635
  node.innerHTML = text;
11428
- return this._bindFillDraw(node, "label", "black", null);
11636
+ return this._bindFillDraw(node, "label", color || "black", null);
11429
11637
  };
11430
11638
  /**
11431
11639
  * Draw an SVG-like path given by the specified path data.
@@ -11876,6 +12084,7 @@ globalThis.VEllipse = __webpack_require__(112).VEllipse;
11876
12084
  globalThis.Circle = __webpack_require__(913).Circle;
11877
12085
  globalThis.CircleSector = __webpack_require__(946).CircleSector;
11878
12086
  globalThis.PBImage = __webpack_require__(699).PBImage;
12087
+ globalThis.PBText = __webpack_require__(196).PBText;
11879
12088
  globalThis.MouseHandler = __webpack_require__(293).MouseHandler;
11880
12089
  globalThis.KeyHandler = __webpack_require__(909).KeyHandler;
11881
12090
  globalThis.drawutils = __webpack_require__(149).drawutils;