plotboilerplate 1.17.0 → 1.18.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 (81) hide show
  1. package/README.md +63 -6
  2. package/changelog.md +25 -0
  3. package/dist/index.esm.js +152 -28
  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 +155 -28
  10. package/dist/plotboilerplate.min.js +1 -1
  11. package/package.json +1 -1
  12. package/src/cjs/Bounds.d.ts +11 -0
  13. package/src/cjs/Bounds.js +14 -0
  14. package/src/cjs/Bounds.js.map +1 -1
  15. package/src/cjs/Circle.d.ts +36 -2
  16. package/src/cjs/Circle.js +81 -1
  17. package/src/cjs/Circle.js.map +1 -1
  18. package/src/cjs/MouseHandler.d.ts +3 -2
  19. package/src/cjs/MouseHandler.js +16 -14
  20. package/src/cjs/MouseHandler.js.map +1 -1
  21. package/src/cjs/PlotBoilerplate.d.ts +3 -1
  22. package/src/cjs/PlotBoilerplate.js +8 -1
  23. package/src/cjs/PlotBoilerplate.js.map +1 -1
  24. package/src/cjs/draw.d.ts +8 -2
  25. package/src/cjs/draw.js +23 -8
  26. package/src/cjs/draw.js.map +1 -1
  27. package/src/cjs/drawgl.d.ts +4 -2
  28. package/src/cjs/drawgl.js +5 -2
  29. package/src/cjs/drawgl.js.map +1 -1
  30. package/src/cjs/drawutilssvg.d.ts +4 -2
  31. package/src/cjs/drawutilssvg.js +8 -2
  32. package/src/cjs/drawutilssvg.js.map +1 -1
  33. package/src/cjs/interfaces/DrawLib.d.ts +3 -1
  34. package/src/cjs/interfaces/DrawLib.js +1 -0
  35. package/src/cjs/interfaces/DrawLib.js.map +1 -1
  36. package/src/cjs/interfaces/core.d.ts +2 -0
  37. package/src/cjs/interfaces/core.js +1 -0
  38. package/src/cjs/interfaces/core.js.map +1 -1
  39. package/src/cjs/utils/datastructures/Color.d.ts +3 -1
  40. package/src/cjs/utils/datastructures/Color.js +17 -6
  41. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  42. package/src/esm/Bounds.d.ts +11 -0
  43. package/src/esm/Bounds.js +14 -0
  44. package/src/esm/Bounds.js.map +1 -1
  45. package/src/esm/Circle.d.ts +36 -2
  46. package/src/esm/Circle.js +81 -1
  47. package/src/esm/Circle.js.map +1 -1
  48. package/src/esm/MouseHandler.d.ts +3 -2
  49. package/src/esm/MouseHandler.js +16 -14
  50. package/src/esm/MouseHandler.js.map +1 -1
  51. package/src/esm/PlotBoilerplate.d.ts +3 -1
  52. package/src/esm/PlotBoilerplate.js +8 -1
  53. package/src/esm/PlotBoilerplate.js.map +1 -1
  54. package/src/esm/draw.d.ts +8 -2
  55. package/src/esm/draw.js +22 -8
  56. package/src/esm/draw.js.map +1 -1
  57. package/src/esm/drawgl.d.ts +4 -2
  58. package/src/esm/drawgl.js +4 -2
  59. package/src/esm/drawgl.js.map +1 -1
  60. package/src/esm/drawutilssvg.d.ts +4 -2
  61. package/src/esm/drawutilssvg.js +7 -2
  62. package/src/esm/drawutilssvg.js.map +1 -1
  63. package/src/esm/interfaces/DrawLib.d.ts +3 -1
  64. package/src/esm/interfaces/DrawLib.js +1 -0
  65. package/src/esm/interfaces/DrawLib.js.map +1 -1
  66. package/src/esm/interfaces/core.d.ts +2 -0
  67. package/src/esm/interfaces/core.js +1 -0
  68. package/src/esm/interfaces/core.js.map +1 -1
  69. package/src/esm/utils/datastructures/Color.d.ts +3 -1
  70. package/src/esm/utils/datastructures/Color.js +17 -6
  71. package/src/esm/utils/datastructures/Color.js.map +1 -1
  72. package/src/ts/Bounds.ts +15 -0
  73. package/src/ts/Circle.ts +92 -2
  74. package/src/ts/MouseHandler.ts +16 -15
  75. package/src/ts/PlotBoilerplate.ts +8 -1
  76. package/src/ts/draw.ts +23 -8
  77. package/src/ts/drawgl.ts +4 -2
  78. package/src/ts/drawutilssvg.ts +7 -2
  79. package/src/ts/interfaces/DrawLib.ts +3 -1
  80. package/src/ts/interfaces/core.ts +3 -2
  81. package/src/ts/utils/datastructures/Color.ts +17 -6
@@ -1746,6 +1746,20 @@ var Bounds = /** @class */ (function () {
1746
1746
  Bounds.prototype.toString = function () {
1747
1747
  return "{ min: " + this.min.toString() + ", max : " + this.max.toString() + ", width: " + this.width + ", height : " + this.height + " }";
1748
1748
  };
1749
+ /**
1750
+ * Clone this bounds object (create a deep clone).
1751
+ *
1752
+ * Note: the returned format might change in the future, so please do not
1753
+ * rely on the returned string format.
1754
+ *
1755
+ * @method clone
1756
+ * @instance
1757
+ * @memberof Bounds
1758
+ * @returns {string} Creates a deep clone of this bounds object. The returned object's `min` and `max` instances are `Vertex` instances.
1759
+ */
1760
+ // clone() {
1761
+ // return new Bounds(new Vertex(this.min.x, this.min.y), new Vertex(this.max.x, this.max.y));
1762
+ // }
1749
1763
  /**
1750
1764
  * Compute the minimal bounding box for a given set of vertices.
1751
1765
  *
@@ -1796,7 +1810,10 @@ exports.Bounds = Bounds;
1796
1810
  * @modified 2021-01-20 Added UID.
1797
1811
  * @modified 2022-02-02 Added the `destroy` method.
1798
1812
  * @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.
1799
- * @version 1.3.0
1813
+ * @modified 2022-08-15 Added the `containsPoint` function.
1814
+ * @modified 2022-08-23 Added the `lineIntersection` function.
1815
+ * @modified 2022-08-23 Added the `closestPoint` function.
1816
+ * @version 1.4.0
1800
1817
  **/
1801
1818
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1802
1819
  exports.Circle = void 0;
@@ -1833,6 +1850,18 @@ var Circle = /** @class */ (function () {
1833
1850
  this.center = center;
1834
1851
  this.radius = radius;
1835
1852
  }
1853
+ /**
1854
+ * Check if the given circle is fully contained inside this circle.
1855
+ *
1856
+ * @method containsPoint
1857
+ * @param {XYCoords} point - The point to check if it is contained in this circle.
1858
+ * @instance
1859
+ * @memberof Circle
1860
+ * @return {boolean} `true` if the given point is inside this circle.
1861
+ */
1862
+ Circle.prototype.containsPoint = function (point) {
1863
+ return this.center.distance(point) < this.radius;
1864
+ };
1836
1865
  /**
1837
1866
  * Check if the given circle is fully contained inside this circle.
1838
1867
  *
@@ -1944,6 +1973,71 @@ var Circle = /** @class */ (function () {
1944
1973
  var y4 = p2.y + (h * (p1.x - p0.x)) / d;
1945
1974
  return new Line_1.Line(new Vertex_1.Vertex(x3, y3), new Vertex_1.Vertex(x4, y4));
1946
1975
  };
1976
+ /**
1977
+ * Calculate the intersection points (if exists) with the given infinite line (defined by two points).
1978
+ *
1979
+ * @method lineIntersection
1980
+ * @instance
1981
+ * @memberof Circle
1982
+ * @param {Vertex} a- The first of the two points defining the line.
1983
+ * @param {Vertex} b - The second of the two points defining the line.
1984
+ * @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.
1985
+ **/
1986
+ Circle.prototype.lineIntersection = function (a, b) {
1987
+ // Based on the math from
1988
+ // https://mathworld.wolfram.com/Circle-LineIntersection.html
1989
+ var interA = new Vertex_1.Vertex();
1990
+ var interB = new Vertex_1.Vertex();
1991
+ // First do a transformation, because the calculation is based on a cicle at (0,0)
1992
+ var transA = new Vertex_1.Vertex(a).sub(this.center);
1993
+ var transB = new Vertex_1.Vertex(b).sub(this.center);
1994
+ var diff = transA.difference(transB);
1995
+ // There is a special case if diff.y=0, where the intersection is not calcuatable.
1996
+ // Use an non-zero epsilon here to approximate this case.
1997
+ // TODO for the future: find a better solution
1998
+ if (Math.abs(diff.y) === 0) {
1999
+ diff.y = 0.000001;
2000
+ }
2001
+ var dist = transA.distance(transB);
2002
+ var det = transA.x * transB.y - transA.y * transB.x;
2003
+ var distSquared = dist * dist;
2004
+ var radiusSquared = this.radius * this.radius;
2005
+ // Check if circle and line have an intersection at all
2006
+ if (radiusSquared * distSquared - det * det < 0) {
2007
+ return null;
2008
+ }
2009
+ var belowSqrt = this.radius * this.radius * dist * dist - det * det;
2010
+ var sqrt = Math.sqrt(belowSqrt);
2011
+ interA.x = (det * diff.y + Math.sign(diff.y) * diff.x * sqrt) / distSquared;
2012
+ interB.x = (det * diff.y - Math.sign(diff.y) * diff.x * sqrt) / distSquared;
2013
+ interA.y = (-det * diff.x + Math.abs(diff.y) * sqrt) / distSquared;
2014
+ interB.y = (-det * diff.x - Math.abs(diff.y) * sqrt) / distSquared;
2015
+ return new Line_1.Line(interA.add(this.center), interB.add(this.center));
2016
+ // return new Line(interA, interB);
2017
+ };
2018
+ /**
2019
+ * Calculate the closest point on the outline of this circle to the given point.
2020
+ *
2021
+ * @method closestPoint
2022
+ * @instance
2023
+ * @memberof Circle
2024
+ * @param {XYCoords} vert - The point to find the closest circle point for.
2025
+ * @return {Vertex} The closest point on this circle.
2026
+ **/
2027
+ Circle.prototype.closestPoint = function (vert) {
2028
+ var lineIntersection = this.lineIntersection(this.center, vert);
2029
+ if (!lineIntersection) {
2030
+ // Note: this case should not happen as a radial from the center always intersect this circle.
2031
+ return new Vertex_1.Vertex();
2032
+ }
2033
+ // Return closed of both
2034
+ if (lineIntersection.a.distance(vert) < lineIntersection.b.distance(vert)) {
2035
+ return lineIntersection.a;
2036
+ }
2037
+ else {
2038
+ return lineIntersection.b;
2039
+ }
2040
+ };
1947
2041
  /**
1948
2042
  * This function should invalidate any installed listeners and invalidate this object.
1949
2043
  * After calling this function the object might not hold valid data any more and
@@ -3423,7 +3517,8 @@ exports.Line = Line;
3423
3517
  * @modified 2020-10-04 Added extended JSDoc comments.
3424
3518
  * @modified 2020-11-25 Added the `isTouchEvent` param.
3425
3519
  * @modified 2021-01-10 The mouse handler is now also working with SVGElements.
3426
- * @version 1.2.0
3520
+ * @modified 2022-08-16 Fixed a bug in the mouse button detection.
3521
+ * @version 1.2.1
3427
3522
  *
3428
3523
  * @file MouseHandler
3429
3524
  * @public
@@ -3540,8 +3635,8 @@ var MouseHandler = /** @class */ (function () {
3540
3635
  // +-------------------------------------------------
3541
3636
  this.name = name;
3542
3637
  this.element = element;
3543
- this.mouseDownPos = null;
3544
- this.mouseDragPos = null;
3638
+ this.mouseDownPos = undefined;
3639
+ this.mouseDragPos = undefined;
3545
3640
  // this.mousePos = null;
3546
3641
  this.mouseButton = -1;
3547
3642
  this.listeners = {};
@@ -3610,26 +3705,27 @@ var MouseHandler = /** @class */ (function () {
3610
3705
  * @memberof MouseHandler
3611
3706
  * @instance
3612
3707
  * @private
3613
- * @param {MouseEvent} e - The mouse event to get the relative position for.
3708
+ * @param {MouseEvent} event - The mouse event to get the relative position for.
3614
3709
  * @param {string} eventName - The name of the firing event.
3615
3710
  * @return {XMouseEvent}
3616
3711
  */
3617
- MouseHandler.prototype.mkParams = function (e, eventName) {
3618
- var rel = this.relPos(e);
3619
- var xEvent = e;
3712
+ MouseHandler.prototype.mkParams = function (event, eventName) {
3713
+ var _a, _b;
3714
+ var rel = this.relPos(event);
3715
+ var xEvent = event;
3620
3716
  xEvent.params = {
3621
3717
  element: this.element,
3622
3718
  name: eventName,
3623
3719
  isTouchEvent: false,
3624
3720
  pos: rel,
3625
- button: this.mouseButton,
3626
- leftButton: this.mouseButton == 0,
3627
- middleButton: this.mouseButton == 1,
3628
- rightButton: this.mouseButton == 2,
3629
- mouseDownPos: this.mouseDownPos,
3630
- draggedFrom: this.mouseDragPos,
3721
+ button: event.button,
3722
+ leftButton: event.button === 0,
3723
+ middleButton: event.button === 1,
3724
+ rightButton: event.button === 2,
3725
+ mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },
3726
+ draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },
3631
3727
  wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),
3632
- dragAmount: this.mouseDownPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 }
3728
+ dragAmount: this.mouseDragPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 }
3633
3729
  };
3634
3730
  return xEvent;
3635
3731
  };
@@ -4041,7 +4137,8 @@ var __webpack_unused_export__;
4041
4137
  * @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.
4042
4138
  * @modified 2021-04-25 Extending `remove` to accept arrays of drawables.
4043
4139
  * @modified 2021-11-16 Adding the `PBText` drawable.
4044
- * @version 1.15.0
4140
+ * @modified 2022-08-01 Added `title` to the params.
4141
+ * @version 1.15.1
4045
4142
  *
4046
4143
  * @file PlotBoilerplate
4047
4144
  * @fileoverview The main class.
@@ -4156,6 +4253,7 @@ var PlotBoilerplate = /** @class */ (function () {
4156
4253
  * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).
4157
4254
  * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).
4158
4255
  * Note that changes from the postDraw hook might not be visible in the export.
4256
+ * @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.
4159
4257
  */
4160
4258
  function PlotBoilerplate(config) {
4161
4259
  /**
@@ -4371,6 +4469,11 @@ var PlotBoilerplate = /** @class */ (function () {
4371
4469
  else {
4372
4470
  throw "Element is neither a canvas nor an svg element.";
4373
4471
  }
4472
+ // At this point the event cacher element is deinfed and located at highest elevation.
4473
+ // Set `title` attribut?
4474
+ if (config.title) {
4475
+ this.eventCatcher.setAttribute("title", config.title);
4476
+ }
4374
4477
  this.draw.scale.set(this.config.scaleX, this.config.scaleY);
4375
4478
  this.fill.scale.set(this.config.scaleX, this.config.scaleY);
4376
4479
  this.vertices = [];
@@ -9179,7 +9282,12 @@ exports.VertexListeners = VertexListeners;
9179
9282
  * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
9180
9283
  * @modified 2022-02-03 Added the `cross(...)` function.
9181
9284
  * @modified 2022-03-27 Added the `texturedPoly` function.
9182
- * @version 1.12.0
9285
+ * @modified 2022-06-01 Tweaked the `polyline` function; lineWidth now scales with scale.x.
9286
+ * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
9287
+ * @modified 2022-08-23 Fixed a type issue in the `polyline` function.
9288
+ * @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.
9289
+ * @modified 2022-08-23 Fixed a type issue in the `path` function.
9290
+ * @version 1.12.3
9183
9291
  **/
9184
9292
  Object.defineProperty(exports, "__esModule", ({ value: true }));
9185
9293
  exports.drawutils = void 0;
@@ -9238,7 +9346,7 @@ var drawutils = /** @class */ (function () {
9238
9346
  * @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.
9239
9347
  */
9240
9348
  drawutils.prototype.setConfiguration = function (configuration) {
9241
- this.ctx.globalCompositeOperation = configuration.blendMode;
9349
+ this.ctx.globalCompositeOperation = configuration.blendMode || "source-over";
9242
9350
  };
9243
9351
  /**
9244
9352
  * This method shouled be called each time the currently drawn `Drawable` changes.
@@ -9321,16 +9429,19 @@ var drawutils = /** @class */ (function () {
9321
9429
  * @param {Image} image - The image object to draw.
9322
9430
  * @param {Vertex} position - The position to draw the the upper left corner at.
9323
9431
  * @param {Vertex} size - The x/y-size to draw the image with.
9432
+ * @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
9324
9433
  * @return {void}
9325
9434
  * @instance
9326
9435
  * @memberof drawutils
9327
9436
  **/
9328
- drawutils.prototype.image = function (image, position, size) {
9437
+ drawutils.prototype.image = function (image, position, size, alpha) {
9438
+ if (alpha === void 0) { alpha = 1.0; }
9329
9439
  if (!image.complete || !image.naturalWidth) {
9330
9440
  // Avoid drawing un-unloaded or broken images
9331
9441
  return;
9332
9442
  }
9333
9443
  this.ctx.save();
9444
+ this.ctx.globalAlpha = alpha;
9334
9445
  // Note that there is a Safari bug with the 3 or 5 params variant.
9335
9446
  // Only the 9-param varaint works.
9336
9447
  this.ctx.drawImage(image, 0, 0, image.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)
@@ -9941,11 +10052,12 @@ var drawutils = /** @class */ (function () {
9941
10052
  * @memberof drawutils
9942
10053
  */
9943
10054
  drawutils.prototype.polyline = function (vertices, isOpen, color, lineWidth) {
9944
- if (vertices.length <= 1)
10055
+ if (vertices.length <= 1) {
9945
10056
  return;
10057
+ }
9946
10058
  this.ctx.save();
9947
10059
  this.ctx.beginPath();
9948
- this.ctx.lineWidth = lineWidth || 1.0;
10060
+ this.ctx.lineWidth = (lineWidth || 1.0) * this.scale.x;
9949
10061
  this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);
9950
10062
  for (var i = 0; i < vertices.length; i++) {
9951
10063
  this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);
@@ -10062,14 +10174,20 @@ var drawutils = /** @class */ (function () {
10062
10174
  drawutils.prototype.path = function (pathData, color, lineWidth, options) {
10063
10175
  var d = options && options.inplace ? pathData : drawutilssvg_1.drawutilssvg.copyPathData(pathData);
10064
10176
  drawutilssvg_1.drawutilssvg.transformPathData(d, this.offset, this.scale);
10065
- this.ctx.strokeStyle = color;
10177
+ if (color) {
10178
+ this.ctx.strokeStyle = color;
10179
+ }
10066
10180
  this.ctx.lineWidth = lineWidth || 1;
10067
10181
  if (this.fillShapes) {
10068
- this.ctx.fillStyle = color;
10182
+ if (color) {
10183
+ this.ctx.fillStyle = color;
10184
+ }
10069
10185
  this.ctx.fill(new Path2D(d.join(" ")));
10070
10186
  }
10071
10187
  else {
10072
- this.ctx.strokeStyle = color;
10188
+ if (color) {
10189
+ this.ctx.strokeStyle = color;
10190
+ }
10073
10191
  this.ctx.stroke(new Path2D(d.join(" ")));
10074
10192
  }
10075
10193
  };
@@ -10123,7 +10241,8 @@ exports.drawutils = drawutils;
10123
10241
  * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.
10124
10242
  * @modified 2022-02-03 Added the `cross(...)` function.
10125
10243
  * @modified 2022-03-27 Added the `texturedPoly` function.
10126
- * @version 0.0.7
10244
+ * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
10245
+ * @version 0.0.8
10127
10246
  **/
10128
10247
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10129
10248
  exports.drawutilsgl = void 0;
@@ -10316,11 +10435,13 @@ var drawutilsgl = /** @class */ (function () {
10316
10435
  * @param {Image} image - The image object to draw.
10317
10436
  * @param {Vertex} position - The position to draw the the upper left corner at.
10318
10437
  * @param {Vertex} size - The x/y-size to draw the image with.
10438
+ * @param {number=0.0} alpha - (optional, default=0.0) The transparency (0.0=opaque, 1.0=transparent).
10319
10439
  * @return {void}
10320
10440
  * @instance
10321
10441
  * @memberof drawutils
10322
10442
  **/
10323
- drawutilsgl.prototype.image = function (image, position, size) {
10443
+ drawutilsgl.prototype.image = function (image, position, size, alpha) {
10444
+ if (alpha === void 0) { alpha = 0.0; }
10324
10445
  // NOT YET IMPLEMENTED
10325
10446
  };
10326
10447
  /**
@@ -10887,7 +11008,8 @@ var GLU = /** @class */ (function () {
10887
11008
  * @modified 2022-02-03 Added the `cross(...)` function.
10888
11009
  * @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.
10889
11010
  * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.
10890
- * @version 1.6.0
11011
+ * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.
11012
+ * @version 1.6.1
10891
11013
  **/
10892
11014
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10893
11015
  exports.drawutilssvg = void 0;
@@ -11275,12 +11397,14 @@ var drawutilssvg = /** @class */ (function () {
11275
11397
  * @param {Image} image - The image object to draw.
11276
11398
  * @param {Vertex} position - The position to draw the the upper left corner at.
11277
11399
  * @param {Vertex} size - The x/y-size to draw the image with.
11400
+ * @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).
11278
11401
  * @return {void}
11279
11402
  * @instance
11280
11403
  * @memberof drawutilssvg
11281
11404
  **/
11282
- drawutilssvg.prototype.image = function (image, position, size) {
11405
+ drawutilssvg.prototype.image = function (image, position, size, alpha) {
11283
11406
  var _this = this;
11407
+ if (alpha === void 0) { alpha = 1.0; }
11284
11408
  var node = this.makeNode("image");
11285
11409
  // We need to re-adjust the image if it was not yet fully loaded before.
11286
11410
  var setImageSize = function (image) {
@@ -11290,6 +11414,9 @@ var drawutilssvg = /** @class */ (function () {
11290
11414
  node.setAttribute("width", "" + image.naturalWidth * _this.scale.x);
11291
11415
  node.setAttribute("height", "" + image.naturalHeight * _this.scale.y);
11292
11416
  node.setAttribute("display", null); // Dislay when loaded
11417
+ // if (alpha) {
11418
+ node.setAttribute("opacity", "" + alpha);
11419
+ // }
11293
11420
  node.setAttribute("transform", "translate(" + _this._x(position.x) + " " + _this._y(position.y) + ") scale(" + ratioX + " " + ratioY + ")");
11294
11421
  }
11295
11422
  };