melonjs 10.8.0 → 10.9.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.
package/dist/melonjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v10.8.0
2
+ * melonJS Game Engine - v10.9.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -13600,8 +13600,8 @@
13600
13600
  function addMapping(id, mapping) {
13601
13601
  var expanded_id = id.replace(vendorProductRE, function (_, a, b) {
13602
13602
  return (
13603
- "000".substr(a.length - 1) + a + "-" +
13604
- "000".substr(b.length - 1) + b + "-"
13603
+ "000".slice(a.length - 1) + a + "-" +
13604
+ "000".slice(b.length - 1) + b + "-"
13605
13605
  );
13606
13606
  });
13607
13607
  var sparse_id = id.replace(vendorProductRE, function (_, a, b) {
@@ -14305,7 +14305,7 @@
14305
14305
  * A mask limits rendering elements to the shape and position of the given mask object.
14306
14306
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
14307
14307
  * @public
14308
- * @type {Rect|Polygon|Line|Ellipse}
14308
+ * @type {Rect|RoundRect|Polygon|Line|Ellipse}
14309
14309
  * @name mask
14310
14310
  * @default undefined
14311
14311
  * @memberof Renderable#
@@ -22490,6 +22490,103 @@
22490
22490
  this._radius = value;
22491
22491
  };
22492
22492
 
22493
+ /**
22494
+ * copy the position, size and radius of the given rounded rectangle into this one
22495
+ * @name copy
22496
+ * @memberof RoundRect.prototype
22497
+ * @function
22498
+ * @param {RoundRect} rrect source rounded rectangle
22499
+ * @returns {RoundRect} new rectangle
22500
+ */
22501
+ RoundRect.prototype.copy = function copy (rrect) {
22502
+ Rect.prototype.setShape.call(this, rrect.pos.x, rrect.pos.y, rrect.width, rrect.height);
22503
+ this.radius = rrect.radius;
22504
+ return this;
22505
+ };
22506
+
22507
+ /**
22508
+ * Returns true if the rounded rectangle contains the given point
22509
+ * @name contains
22510
+ * @memberof RoundRect.prototype
22511
+ * @function
22512
+ * @param {number} x x coordinate
22513
+ * @param {number} y y coordinate
22514
+ * @returns {boolean} true if contains
22515
+ */
22516
+
22517
+ /**
22518
+ * Returns true if the rounded rectangle contains the given point
22519
+ * @name contains
22520
+ * @memberof RoundRect.prototype
22521
+ * @function
22522
+ * @param {Vector2d} point
22523
+ * @returns {boolean} true if contains
22524
+ */
22525
+ RoundRect.prototype.contains = function contains () {
22526
+ var arg0 = arguments[0];
22527
+ var _x, _y;
22528
+ if (arguments.length === 2) {
22529
+ // x, y
22530
+ _x = arg0;
22531
+ _y = arguments[1];
22532
+ } else {
22533
+ if (arg0 instanceof Rect) {
22534
+ // good enough
22535
+ return Rect.prototype.contains.call(this, arg0);
22536
+ } else {
22537
+ // vector
22538
+ _x = arg0.x;
22539
+ _y = arg0.y;
22540
+ }
22541
+ }
22542
+
22543
+ // check whether point is outside the bounding box
22544
+ if (_x < this.left || _x >= this.right || _y < this.top || _y >= this.bottom) {
22545
+ return false; // outside bounding box
22546
+ }
22547
+
22548
+ // check whether point is within the bounding box minus radius
22549
+ if ((_x >= this.left + this.radius && _x <= this.right - this.radius) || (_y >= this.top + this.radius && _y <= this.bottom - this.radius)) {
22550
+ return true;
22551
+ }
22552
+
22553
+ // check whether point is in one of the rounded corner areas
22554
+ var tx, ty;
22555
+ var radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
22556
+ var radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
22557
+
22558
+ if (_x < this.left + radiusX && _y < this.top + radiusY) {
22559
+ tx = _x - this.left - radiusX;
22560
+ ty = _y - this.top - radiusY;
22561
+ } else if (_x > this.right - radiusX && _y < this.top + radiusY) {
22562
+ tx = _x - this.right + radiusX;
22563
+ ty = _y - this.top - radiusY;
22564
+ } else if (_x > this.right - radiusX && _y > this.bottom - radiusY) {
22565
+ tx = _x - this.right + radiusX;
22566
+ ty = _y - this.bottom + radiusY;
22567
+ } else if (_x < this.left + radiusX && _y > this.bottom - radiusY) {
22568
+ tx = _x - this.left - radiusX;
22569
+ ty = _y - this.bottom + radiusY;
22570
+ } else {
22571
+ return false; // inside and not within the rounded corner area
22572
+ }
22573
+
22574
+ // Pythagorean theorem.
22575
+ return ((tx * tx) + (ty * ty) <= (radiusX * radiusY));
22576
+ };
22577
+
22578
+ /**
22579
+ * check if this RoundRect is identical to the specified one
22580
+ * @name equals
22581
+ * @memberof RoundRect.prototype
22582
+ * @function
22583
+ * @param {RoundRect} rrect
22584
+ * @returns {boolean} true if equals
22585
+ */
22586
+ RoundRect.prototype.equals = function equals (rrect) {
22587
+ return Rect.prototype.equals.call(this, rrect) && this.radius === rrect.radius;
22588
+ };
22589
+
22493
22590
  /**
22494
22591
  * clone this RoundRect
22495
22592
  * @name clone
@@ -22498,7 +22595,7 @@
22498
22595
  * @returns {RoundRect} new RoundRect
22499
22596
  */
22500
22597
  RoundRect.prototype.clone = function clone () {
22501
- return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, this.radius);
22598
+ return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, radius);
22502
22599
  };
22503
22600
 
22504
22601
  Object.defineProperties( RoundRect.prototype, prototypeAccessors );
@@ -22607,7 +22704,7 @@
22607
22704
  * @classdesc
22608
22705
  * a simplified path2d implementation, supporting only one path
22609
22706
  */
22610
- var Path2D = function Path2D() {
22707
+ var Path2D$1 = function Path2D() {
22611
22708
  /**
22612
22709
  * the points defining the current path
22613
22710
  * @public
@@ -22637,7 +22734,7 @@
22637
22734
  * @memberof Path2D.prototype
22638
22735
  * @function
22639
22736
  */
22640
- Path2D.prototype.beginPath = function beginPath () {
22737
+ Path2D$1.prototype.beginPath = function beginPath () {
22641
22738
  // empty the cache and recycle all vectors
22642
22739
  this.points.forEach(function (point) {
22643
22740
  pool$1.push(point);
@@ -22653,7 +22750,7 @@
22653
22750
  * @memberof Path2D.prototype
22654
22751
  * @function
22655
22752
  */
22656
- Path2D.prototype.closePath = function closePath () {
22753
+ Path2D$1.prototype.closePath = function closePath () {
22657
22754
  var points = this.points;
22658
22755
  if (points.length > 1 && !points[points.length-1].equals(points[0])) {
22659
22756
  points.push(pool$1.pull("Vector2d", points[0].x, points[0].y));
@@ -22667,7 +22764,7 @@
22667
22764
  * @function
22668
22765
  * @returns {Vector2d[]}
22669
22766
  */
22670
- Path2D.prototype.triangulatePath = function triangulatePath () {
22767
+ Path2D$1.prototype.triangulatePath = function triangulatePath () {
22671
22768
  var i = 0;
22672
22769
  var points = this.points;
22673
22770
  var vertices = this.vertices;
@@ -22699,7 +22796,7 @@
22699
22796
  * @param {number} x the x-axis (horizontal) coordinate of the point.
22700
22797
  * @param {number} y the y-axis (vertical) coordinate of the point.
22701
22798
  */
22702
- Path2D.prototype.moveTo = function moveTo (x, y) {
22799
+ Path2D$1.prototype.moveTo = function moveTo (x, y) {
22703
22800
  this.points.push(pool$1.pull("Vector2d", x, y));
22704
22801
  };
22705
22802
 
@@ -22711,7 +22808,7 @@
22711
22808
  * @param {number} x the x-axis coordinate of the line's end point.
22712
22809
  * @param {number} y the y-axis coordinate of the line's end point.
22713
22810
  */
22714
- Path2D.prototype.lineTo = function lineTo (x, y) {
22811
+ Path2D$1.prototype.lineTo = function lineTo (x, y) {
22715
22812
  this.points.push(pool$1.pull("Vector2d", x, y));
22716
22813
  };
22717
22814
 
@@ -22728,7 +22825,7 @@
22728
22825
  * @param {number} endAngle the angle at which the arc ends in radians, measured from the positive x-axis.
22729
22826
  * @param {boolean} [anticlockwise=false] an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
22730
22827
  */
22731
- Path2D.prototype.arc = function arc (x, y, radius, startAngle, endAngle, anticlockwise) {
22828
+ Path2D$1.prototype.arc = function arc (x, y, radius, startAngle, endAngle, anticlockwise) {
22732
22829
  if ( anticlockwise === void 0 ) anticlockwise = false;
22733
22830
 
22734
22831
  var points = this.points;
@@ -22779,7 +22876,7 @@
22779
22876
  * @param {number} y the y-axis coordinate of the second control point.
22780
22877
  * @param {number} radius the arc's radius. Must be positive.
22781
22878
  */
22782
- Path2D.prototype.arcTo = function arcTo (x1, y1, x2, y2, radius) {
22879
+ Path2D$1.prototype.arcTo = function arcTo (x1, y1, x2, y2, radius) {
22783
22880
  var points = this.points;
22784
22881
  // based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
22785
22882
  var x0 = points[points.length-1].x, y0 = points[points.length-1].y;
@@ -22831,7 +22928,7 @@
22831
22928
  * @param {number} endAngle the angle at which the ellipse ends, measured clockwise from the positive x-axis and expressed in radians.
22832
22929
  * @param {boolean} [anticlockwise=false] an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
22833
22930
  */
22834
- Path2D.prototype.ellipse = function ellipse (x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
22931
+ Path2D$1.prototype.ellipse = function ellipse (x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
22835
22932
  if ( anticlockwise === void 0 ) anticlockwise = false;
22836
22933
 
22837
22934
  var points = this.points;
@@ -22889,7 +22986,7 @@
22889
22986
  * @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
22890
22987
  * @param {number} height the rectangle's height. Positive values are down, and negative are up.
22891
22988
  */
22892
- Path2D.prototype.rect = function rect (x, y, width, height) {
22989
+ Path2D$1.prototype.rect = function rect (x, y, width, height) {
22893
22990
  this.moveTo(x, y);
22894
22991
  this.lineTo(x + width, y);
22895
22992
  this.lineTo(x + width, y + height);
@@ -22908,7 +23005,7 @@
22908
23005
  * @param {number} height the rectangle's height. Positive values are down, and negative are up.
22909
23006
  * @param {number} radius the arc's radius to draw the borders. Must be positive.
22910
23007
  */
22911
- Path2D.prototype.roundRect = function roundRect (x, y, width, height, radius) {
23008
+ Path2D$1.prototype.roundRect = function roundRect (x, y, width, height, radius) {
22912
23009
  this.moveTo(x + radius, y);
22913
23010
  this.lineTo(x + width - radius, y);
22914
23011
  this.arcTo(x + width, y, x + width, y + radius, radius);
@@ -22949,7 +23046,7 @@
22949
23046
  * @type {Path2D}
22950
23047
  * @memberof Renderer#
22951
23048
  */
22952
- this.path2D = new Path2D();
23049
+ this.path2D = new Path2D$1();
22953
23050
 
22954
23051
  /**
22955
23052
  * @ignore
@@ -23237,13 +23334,19 @@
23237
23334
  * @param {boolean} [fill=false] fill the shape with the current color if true
23238
23335
  */
23239
23336
  Renderer.prototype.stroke = function stroke (shape, fill) {
23240
- if (shape instanceof RoundRect) {
23241
- this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
23242
- } else if (shape instanceof Rect || shape instanceof Bounds$1) {
23337
+ if (shape instanceof Rect || shape instanceof Bounds$1) {
23243
23338
  this.strokeRect(shape.left, shape.top, shape.width, shape.height, fill);
23244
- } else if (shape instanceof Line || shape instanceof Polygon) {
23339
+ return;
23340
+ }
23341
+ if (shape instanceof Line || shape instanceof Polygon) {
23245
23342
  this.strokePolygon(shape, fill);
23246
- } else if (shape instanceof Ellipse) {
23343
+ return;
23344
+ }
23345
+ if (shape instanceof RoundRect) {
23346
+ this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
23347
+ return;
23348
+ }
23349
+ if (shape instanceof Ellipse) {
23247
23350
  this.strokeEllipse(
23248
23351
  shape.pos.x,
23249
23352
  shape.pos.y,
@@ -23251,7 +23354,9 @@
23251
23354
  shape.radiusV.y,
23252
23355
  fill
23253
23356
  );
23357
+ return;
23254
23358
  }
23359
+ throw new Error("Invalid geometry for fill/stroke");
23255
23360
  };
23256
23361
 
23257
23362
  /**
@@ -23259,7 +23364,7 @@
23259
23364
  * @name fill
23260
23365
  * @memberof Renderer.prototype
23261
23366
  * @function
23262
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
23367
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
23263
23368
  */
23264
23369
  Renderer.prototype.fill = function fill (shape) {
23265
23370
  this.stroke(shape, true);
@@ -23301,7 +23406,7 @@
23301
23406
  * @name setMask
23302
23407
  * @memberof Renderer.prototype
23303
23408
  * @function
23304
- * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
23409
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
23305
23410
  */
23306
23411
  // eslint-disable-next-line no-unused-vars
23307
23412
  Renderer.prototype.setMask = function setMask (mask) {};
@@ -23878,20 +23983,7 @@
23878
23983
  var context = this.getContext();
23879
23984
 
23880
23985
  context.beginPath();
23881
- if (typeof context.roundRect === "function") {
23882
- //https://developer.chrome.com/blog/canvas2d/#round-rect
23883
- context.roundRect(x, y, width, height, radius);
23884
- } else {
23885
- context.moveTo(x + radius, y);
23886
- context.lineTo(x + width - radius, y);
23887
- context.arcTo(x + width, y, x + width, y + radius, radius);
23888
- context.lineTo(x + width, y + height - radius);
23889
- context.arcTo(x + width, y + height, x + width - radius, y + height, radius);
23890
- context.lineTo(x + radius, y + height);
23891
- context.arcTo(x, y + height, x, y + height - radius, radius);
23892
- context.lineTo(x, y + radius);
23893
- context.arcTo(x, y, x + radius, y, radius);
23894
- }
23986
+ context.roundRect(x, y, width, height, radius);
23895
23987
  context[fill === true ? "fill" : "stroke"]();
23896
23988
  };
23897
23989
 
@@ -24124,7 +24216,7 @@
24124
24216
  * @name setMask
24125
24217
  * @memberof CanvasRenderer.prototype
24126
24218
  * @function
24127
- * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
24219
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
24128
24220
  */
24129
24221
  CanvasRenderer.prototype.setMask = function setMask (mask) {
24130
24222
  var context = this.getContext();
@@ -24132,6 +24224,8 @@
24132
24224
 
24133
24225
  context.save();
24134
24226
 
24227
+ context.beginPath();
24228
+
24135
24229
  // https://github.com/melonjs/melonJS/issues/648
24136
24230
  if (mask instanceof Ellipse) {
24137
24231
  var hw = mask.radiusV.x,
@@ -24148,14 +24242,14 @@
24148
24242
  ymin = _y - ymagic,
24149
24243
  ymax = _y + ymagic;
24150
24244
 
24151
- context.beginPath();
24152
24245
  context.moveTo(_x, ty);
24153
24246
  context.bezierCurveTo(xmax, ty, rx, ymin, rx, _y);
24154
24247
  context.bezierCurveTo(rx, ymax, xmax, by, _x, by);
24155
24248
  context.bezierCurveTo(xmin, by, lx, ymax, lx, _y);
24156
24249
  context.bezierCurveTo(lx, ymin, xmin, ty, _x, ty);
24250
+ } else if (mask instanceof RoundRect) {
24251
+ context.roundRect(_x, _y, mask.width, mask.height, mask.radius);
24157
24252
  } else {
24158
- context.beginPath();
24159
24253
  context.moveTo(_x + mask.points[0].x, _y + mask.points[0].y);
24160
24254
  var point;
24161
24255
  for (var i = 1; i < mask.points.length; i++) {
@@ -24175,7 +24269,7 @@
24175
24269
  * @function
24176
24270
  */
24177
24271
  CanvasRenderer.prototype.clearMask = function clearMask () {
24178
- this.backBufferContext2D.restore();
24272
+ this.getContext().restore();
24179
24273
  };
24180
24274
 
24181
24275
  return CanvasRenderer;
@@ -30468,7 +30562,7 @@
30468
30562
  */
30469
30563
  return function (val) {
30470
30564
  var fnv = fn;
30471
- if (val.length && fn.substr(-1) !== "v") {
30565
+ if (val.length && fn.slice(-1) !== "v") {
30472
30566
  fnv += "v";
30473
30567
  }
30474
30568
  gl[fnv](locations[name], val);
@@ -32507,7 +32601,7 @@
32507
32601
  * @name setMask
32508
32602
  * @memberof WebGLRenderer.prototype
32509
32603
  * @function
32510
- * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
32604
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
32511
32605
  */
32512
32606
  WebGLRenderer.prototype.setMask = function setMask (mask) {
32513
32607
  var gl = this.gl;
@@ -33119,14 +33213,14 @@
33119
33213
  // never cache if a url is passed as parameter
33120
33214
  var index = url.indexOf("#");
33121
33215
  if (index !== -1) {
33122
- url = url.substr(index, url.length);
33216
+ url = url.slice(index, url.length);
33123
33217
  } else {
33124
33218
  return hash;
33125
33219
  }
33126
33220
  }
33127
33221
 
33128
33222
  // parse the url
33129
- url.substr(1).split("&").filter(function (value) {
33223
+ url.slice(1).split("&").filter(function (value) {
33130
33224
  return (value !== "");
33131
33225
  }).forEach(function (value) {
33132
33226
  var kv = value.split("=");
@@ -33482,6 +33576,256 @@
33482
33576
  globalThis.cancelAnimationFrame = cancelAnimationFrame;
33483
33577
  }
33484
33578
 
33579
+ /*
33580
+ * based on https://www.npmjs.com/package/canvas-roundrect-polyfill
33581
+ * @version 0.0.1
33582
+ */
33583
+ (function () {
33584
+
33585
+ /** @ignore */
33586
+ function roundRect(x, y, w, h, radii) {
33587
+
33588
+ if (!([x, y, w, h].every(function (input) { return Number.isFinite(input); }))) {
33589
+
33590
+ return;
33591
+
33592
+ }
33593
+
33594
+ radii = parseRadiiArgument(radii);
33595
+
33596
+ var upperLeft, upperRight, lowerRight, lowerLeft;
33597
+
33598
+ if (radii.length === 4) {
33599
+
33600
+ upperLeft = toCornerPoint(radii[0]);
33601
+ upperRight = toCornerPoint(radii[1]);
33602
+ lowerRight = toCornerPoint(radii[2]);
33603
+ lowerLeft = toCornerPoint(radii[3]);
33604
+
33605
+ } else if (radii.length === 3) {
33606
+
33607
+ upperLeft = toCornerPoint(radii[0]);
33608
+ upperRight = toCornerPoint(radii[1]);
33609
+ lowerLeft = toCornerPoint(radii[1]);
33610
+ lowerRight = toCornerPoint(radii[2]);
33611
+
33612
+ } else if (radii.length === 2) {
33613
+
33614
+ upperLeft = toCornerPoint(radii[0]);
33615
+ lowerRight = toCornerPoint(radii[0]);
33616
+ upperRight = toCornerPoint(radii[1]);
33617
+ lowerLeft = toCornerPoint(radii[1]);
33618
+
33619
+ } else if (radii.length === 1) {
33620
+
33621
+ upperLeft = toCornerPoint(radii[0]);
33622
+ upperRight = toCornerPoint(radii[0]);
33623
+ lowerRight = toCornerPoint(radii[0]);
33624
+ lowerLeft = toCornerPoint(radii[0]);
33625
+
33626
+ } else {
33627
+
33628
+ throw new Error(radii.length + " is not a valid size for radii sequence.");
33629
+
33630
+ }
33631
+
33632
+ var corners = [upperLeft, upperRight, lowerRight, lowerLeft];
33633
+ var negativeCorner = corners.find(function (ref) {
33634
+ var x = ref.x;
33635
+ var y = ref.y;
33636
+
33637
+ return x < 0 || y < 0;
33638
+ });
33639
+ //const negativeValue = negativeCorner?.x < 0 ? negativeCorner.x : negativeCorner?.y
33640
+
33641
+ if (corners.some(function (ref) {
33642
+ var x = ref.x;
33643
+ var y = ref.y;
33644
+
33645
+ return !Number.isFinite(x) || !Number.isFinite(y);
33646
+ })) {
33647
+
33648
+ return;
33649
+
33650
+ }
33651
+
33652
+ if (negativeCorner) {
33653
+
33654
+ throw new Error("Radius value " + negativeCorner + " is negative.");
33655
+
33656
+ }
33657
+
33658
+ fixOverlappingCorners(corners);
33659
+
33660
+ if (w < 0 && h < 0) {
33661
+
33662
+ this.moveTo(x - upperLeft.x, y);
33663
+ this.ellipse(x + w + upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI * 1.5, -Math.PI);
33664
+ this.ellipse(x + w + lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI / 2);
33665
+ this.ellipse(x - lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, 0);
33666
+ this.ellipse(x - upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2);
33667
+
33668
+ } else if (w < 0) {
33669
+
33670
+ this.moveTo(x - upperLeft.x, y);
33671
+ this.ellipse(x + w + upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, -Math.PI, 1);
33672
+ this.ellipse(x + w + lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI * 1.5, 1);
33673
+ this.ellipse(x - lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, 0, 1);
33674
+ this.ellipse(x - upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2, 1);
33675
+
33676
+ } else if (h < 0) {
33677
+
33678
+ this.moveTo(x + upperLeft.x, y);
33679
+ this.ellipse(x + w - upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, Math.PI / 2, 0, 1);
33680
+ this.ellipse(x + w - lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, -Math.PI / 2, 1);
33681
+ this.ellipse(x + lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, -Math.PI, 1);
33682
+ this.ellipse(x + upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, -Math.PI, -Math.PI * 1.5, 1);
33683
+
33684
+ } else {
33685
+
33686
+ this.moveTo(x + upperLeft.x, y);
33687
+ this.ellipse(x + w - upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, 0);
33688
+ this.ellipse(x + w - lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, Math.PI / 2);
33689
+ this.ellipse(x + lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, Math.PI);
33690
+ this.ellipse(x + upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, Math.PI, Math.PI * 1.5);
33691
+
33692
+ }
33693
+
33694
+ this.closePath();
33695
+ this.moveTo(x, y);
33696
+
33697
+ /** @ignore */
33698
+ function toDOMPointInit(value) {
33699
+
33700
+ var x = value.x;
33701
+ var y = value.y;
33702
+ var z = value.z;
33703
+ var w = value.w;
33704
+ return {x: x, y: y, z: z, w: w};
33705
+
33706
+ }
33707
+
33708
+ /** @ignore */
33709
+ function parseRadiiArgument(value) {
33710
+
33711
+ // https://webidl.spec.whatwg.org/#es-union
33712
+ // with 'optional (unrestricted double or DOMPointInit
33713
+ // or sequence<(unrestricted double or DOMPointInit)>) radii = 0'
33714
+ var type = typeof value;
33715
+
33716
+ if (type === "undefined" || value === null) {
33717
+
33718
+ return [0];
33719
+
33720
+ }
33721
+ if (type === "function") {
33722
+
33723
+ return [NaN];
33724
+
33725
+ }
33726
+ if (type === "object") {
33727
+
33728
+ if (typeof value[Symbol.iterator] === "function") {
33729
+
33730
+ return [].concat( value ).map(function (elem) {
33731
+ // https://webidl.spec.whatwg.org/#es-union
33732
+ // with '(unrestricted double or DOMPointInit)'
33733
+ var elemType = typeof elem;
33734
+ if (elemType === "undefined" || elem === null) {
33735
+ return 0;
33736
+ }
33737
+ if (elemType === "function") {
33738
+ return NaN;
33739
+ }
33740
+ if (elemType === "object") {
33741
+ return toDOMPointInit(elem);
33742
+ }
33743
+ return toUnrestrictedNumber(elem);
33744
+ });
33745
+
33746
+ }
33747
+
33748
+ return [toDOMPointInit(value)];
33749
+
33750
+ }
33751
+
33752
+ return [toUnrestrictedNumber(value)];
33753
+
33754
+ }
33755
+
33756
+ /** @ignore */
33757
+ function toUnrestrictedNumber(value) {
33758
+
33759
+ return +value;
33760
+
33761
+ }
33762
+
33763
+ /** @ignore */
33764
+ function toCornerPoint(value) {
33765
+
33766
+ var asNumber = toUnrestrictedNumber(value);
33767
+ if (Number.isFinite(asNumber)) {
33768
+
33769
+ return {
33770
+ x: asNumber,
33771
+ y: asNumber
33772
+ };
33773
+
33774
+ }
33775
+ if (Object(value) === value) {
33776
+
33777
+ return {
33778
+ x: toUnrestrictedNumber(value.x || 0),
33779
+ y: toUnrestrictedNumber(value.y || 0)
33780
+ };
33781
+
33782
+ }
33783
+
33784
+ return {
33785
+ x: NaN,
33786
+ y: NaN
33787
+ };
33788
+
33789
+ }
33790
+
33791
+ /** @ignore */
33792
+ function fixOverlappingCorners(corners) {
33793
+ var upperLeft = corners[0];
33794
+ var upperRight = corners[1];
33795
+ var lowerRight = corners[2];
33796
+ var lowerLeft = corners[3];
33797
+ var factors = [
33798
+ Math.abs(w) / (upperLeft.x + upperRight.x),
33799
+ Math.abs(h) / (upperRight.y + lowerRight.y),
33800
+ Math.abs(w) / (lowerRight.x + lowerLeft.x),
33801
+ Math.abs(h) / (upperLeft.y + lowerLeft.y)
33802
+ ];
33803
+ var minFactor = Math.min.apply(Math, factors);
33804
+ if (minFactor <= 1) {
33805
+ corners.forEach(function (radii) {
33806
+ radii.x *= minFactor;
33807
+ radii.y *= minFactor;
33808
+ });
33809
+ }
33810
+ }
33811
+ }
33812
+
33813
+ if (typeof Path2D.prototype.roundRect === "undefined") {
33814
+ Path2D.prototype.roundRect = roundRect;
33815
+ }
33816
+ if (globalThis.CanvasRenderingContext2D) {
33817
+ if (typeof globalThis.CanvasRenderingContext2D.prototype.roundRect === "undefined") {
33818
+ globalThis.CanvasRenderingContext2D.prototype.roundRect = roundRect;
33819
+ }
33820
+ }
33821
+ if (globalThis.OffscreenCanvasRenderingContext2D) {
33822
+ if (typeof globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect === "undefined") {
33823
+ globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect = roundRect;
33824
+ }
33825
+ }
33826
+
33827
+ })();
33828
+
33485
33829
  /**
33486
33830
  * This namespace is a container for all registered plugins.
33487
33831
  * @see plugin.register
@@ -33496,10 +33840,10 @@
33496
33840
  * this can be overridden by the plugin
33497
33841
  * @public
33498
33842
  * @type {string}
33499
- * @default "10.8.0"
33843
+ * @default "10.9.0"
33500
33844
  * @name plugin.Base#version
33501
33845
  */
33502
- this.version = "10.8.0";
33846
+ this.version = "10.9.0";
33503
33847
  };
33504
33848
 
33505
33849
  /**
@@ -37915,7 +38259,7 @@
37915
38259
  * @name version
37916
38260
  * @type {string}
37917
38261
  */
37918
- var version = "10.8.0";
38262
+ var version = "10.9.0";
37919
38263
 
37920
38264
 
37921
38265
  /**