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 +393 -49
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +24 -137
- package/dist/melonjs.module.js +367 -39
- package/package.json +5 -5
- package/src/geometries/roundrect.js +98 -1
- package/src/input/gamepad.js +2 -2
- package/src/polyfill/index.js +1 -0
- package/src/polyfill/roundrect.js +235 -0
- package/src/renderable/renderable.js +1 -1
- package/src/utils/utils.js +2 -2
- package/src/video/canvas/canvas_renderer.js +8 -18
- package/src/video/renderer.js +15 -7
- package/src/video/webgl/utils/uniforms.js +1 -1
- package/src/video/webgl/webgl_renderer.js +1 -1
package/dist/melonjs.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
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
|
|
@@ -13515,8 +13515,8 @@ var leadingZeroRE = /^0+/;
|
|
|
13515
13515
|
function addMapping(id, mapping) {
|
|
13516
13516
|
var expanded_id = id.replace(vendorProductRE, function (_, a, b) {
|
|
13517
13517
|
return (
|
|
13518
|
-
"000".
|
|
13519
|
-
"000".
|
|
13518
|
+
"000".slice(a.length - 1) + a + "-" +
|
|
13519
|
+
"000".slice(b.length - 1) + b + "-"
|
|
13520
13520
|
);
|
|
13521
13521
|
});
|
|
13522
13522
|
var sparse_id = id.replace(vendorProductRE, function (_, a, b) {
|
|
@@ -14226,7 +14226,7 @@ class Renderable extends Rect {
|
|
|
14226
14226
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
14227
14227
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
14228
14228
|
* @public
|
|
14229
|
-
* @type {Rect|Polygon|Line|Ellipse}
|
|
14229
|
+
* @type {Rect|RoundRect|Polygon|Line|Ellipse}
|
|
14230
14230
|
* @name mask
|
|
14231
14231
|
* @default undefined
|
|
14232
14232
|
* @memberof Renderable#
|
|
@@ -22409,6 +22409,103 @@ class RoundRect extends Rect {
|
|
|
22409
22409
|
this._radius = value;
|
|
22410
22410
|
}
|
|
22411
22411
|
|
|
22412
|
+
/**
|
|
22413
|
+
* copy the position, size and radius of the given rounded rectangle into this one
|
|
22414
|
+
* @name copy
|
|
22415
|
+
* @memberof RoundRect.prototype
|
|
22416
|
+
* @function
|
|
22417
|
+
* @param {RoundRect} rrect source rounded rectangle
|
|
22418
|
+
* @returns {RoundRect} new rectangle
|
|
22419
|
+
*/
|
|
22420
|
+
copy(rrect) {
|
|
22421
|
+
super.setShape(rrect.pos.x, rrect.pos.y, rrect.width, rrect.height);
|
|
22422
|
+
this.radius = rrect.radius;
|
|
22423
|
+
return this;
|
|
22424
|
+
}
|
|
22425
|
+
|
|
22426
|
+
/**
|
|
22427
|
+
* Returns true if the rounded rectangle contains the given point
|
|
22428
|
+
* @name contains
|
|
22429
|
+
* @memberof RoundRect.prototype
|
|
22430
|
+
* @function
|
|
22431
|
+
* @param {number} x x coordinate
|
|
22432
|
+
* @param {number} y y coordinate
|
|
22433
|
+
* @returns {boolean} true if contains
|
|
22434
|
+
*/
|
|
22435
|
+
|
|
22436
|
+
/**
|
|
22437
|
+
* Returns true if the rounded rectangle contains the given point
|
|
22438
|
+
* @name contains
|
|
22439
|
+
* @memberof RoundRect.prototype
|
|
22440
|
+
* @function
|
|
22441
|
+
* @param {Vector2d} point
|
|
22442
|
+
* @returns {boolean} true if contains
|
|
22443
|
+
*/
|
|
22444
|
+
contains() {
|
|
22445
|
+
var arg0 = arguments[0];
|
|
22446
|
+
var _x, _y;
|
|
22447
|
+
if (arguments.length === 2) {
|
|
22448
|
+
// x, y
|
|
22449
|
+
_x = arg0;
|
|
22450
|
+
_y = arguments[1];
|
|
22451
|
+
} else {
|
|
22452
|
+
if (arg0 instanceof Rect) {
|
|
22453
|
+
// good enough
|
|
22454
|
+
return super.contains(arg0);
|
|
22455
|
+
} else {
|
|
22456
|
+
// vector
|
|
22457
|
+
_x = arg0.x;
|
|
22458
|
+
_y = arg0.y;
|
|
22459
|
+
}
|
|
22460
|
+
}
|
|
22461
|
+
|
|
22462
|
+
// check whether point is outside the bounding box
|
|
22463
|
+
if (_x < this.left || _x >= this.right || _y < this.top || _y >= this.bottom) {
|
|
22464
|
+
return false; // outside bounding box
|
|
22465
|
+
}
|
|
22466
|
+
|
|
22467
|
+
// check whether point is within the bounding box minus radius
|
|
22468
|
+
if ((_x >= this.left + this.radius && _x <= this.right - this.radius) || (_y >= this.top + this.radius && _y <= this.bottom - this.radius)) {
|
|
22469
|
+
return true;
|
|
22470
|
+
}
|
|
22471
|
+
|
|
22472
|
+
// check whether point is in one of the rounded corner areas
|
|
22473
|
+
var tx, ty;
|
|
22474
|
+
var radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
|
|
22475
|
+
var radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
|
|
22476
|
+
|
|
22477
|
+
if (_x < this.left + radiusX && _y < this.top + radiusY) {
|
|
22478
|
+
tx = _x - this.left - radiusX;
|
|
22479
|
+
ty = _y - this.top - radiusY;
|
|
22480
|
+
} else if (_x > this.right - radiusX && _y < this.top + radiusY) {
|
|
22481
|
+
tx = _x - this.right + radiusX;
|
|
22482
|
+
ty = _y - this.top - radiusY;
|
|
22483
|
+
} else if (_x > this.right - radiusX && _y > this.bottom - radiusY) {
|
|
22484
|
+
tx = _x - this.right + radiusX;
|
|
22485
|
+
ty = _y - this.bottom + radiusY;
|
|
22486
|
+
} else if (_x < this.left + radiusX && _y > this.bottom - radiusY) {
|
|
22487
|
+
tx = _x - this.left - radiusX;
|
|
22488
|
+
ty = _y - this.bottom + radiusY;
|
|
22489
|
+
} else {
|
|
22490
|
+
return false; // inside and not within the rounded corner area
|
|
22491
|
+
}
|
|
22492
|
+
|
|
22493
|
+
// Pythagorean theorem.
|
|
22494
|
+
return ((tx * tx) + (ty * ty) <= (radiusX * radiusY));
|
|
22495
|
+
}
|
|
22496
|
+
|
|
22497
|
+
/**
|
|
22498
|
+
* check if this RoundRect is identical to the specified one
|
|
22499
|
+
* @name equals
|
|
22500
|
+
* @memberof RoundRect.prototype
|
|
22501
|
+
* @function
|
|
22502
|
+
* @param {RoundRect} rrect
|
|
22503
|
+
* @returns {boolean} true if equals
|
|
22504
|
+
*/
|
|
22505
|
+
equals(rrect) {
|
|
22506
|
+
return super.equals(rrect) && this.radius === rrect.radius;
|
|
22507
|
+
}
|
|
22508
|
+
|
|
22412
22509
|
/**
|
|
22413
22510
|
* clone this RoundRect
|
|
22414
22511
|
* @name clone
|
|
@@ -22417,7 +22514,7 @@ class RoundRect extends Rect {
|
|
|
22417
22514
|
* @returns {RoundRect} new RoundRect
|
|
22418
22515
|
*/
|
|
22419
22516
|
clone() {
|
|
22420
|
-
return new RoundRect(this.pos.x, this.pos.y, this.width, this.height,
|
|
22517
|
+
return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, radius);
|
|
22421
22518
|
}
|
|
22422
22519
|
}
|
|
22423
22520
|
|
|
@@ -22532,7 +22629,7 @@ class Line extends Polygon {
|
|
|
22532
22629
|
* @classdesc
|
|
22533
22630
|
* a simplified path2d implementation, supporting only one path
|
|
22534
22631
|
*/
|
|
22535
|
-
class Path2D {
|
|
22632
|
+
class Path2D$1 {
|
|
22536
22633
|
constructor() {
|
|
22537
22634
|
/**
|
|
22538
22635
|
* the points defining the current path
|
|
@@ -22888,7 +22985,7 @@ class Renderer {
|
|
|
22888
22985
|
* @type {Path2D}
|
|
22889
22986
|
* @memberof Renderer#
|
|
22890
22987
|
*/
|
|
22891
|
-
this.path2D = new Path2D();
|
|
22988
|
+
this.path2D = new Path2D$1();
|
|
22892
22989
|
|
|
22893
22990
|
/**
|
|
22894
22991
|
* @ignore
|
|
@@ -23176,13 +23273,19 @@ class Renderer {
|
|
|
23176
23273
|
* @param {boolean} [fill=false] fill the shape with the current color if true
|
|
23177
23274
|
*/
|
|
23178
23275
|
stroke(shape, fill) {
|
|
23179
|
-
if (shape instanceof
|
|
23180
|
-
this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
|
|
23181
|
-
} else if (shape instanceof Rect || shape instanceof Bounds$1) {
|
|
23276
|
+
if (shape instanceof Rect || shape instanceof Bounds$1) {
|
|
23182
23277
|
this.strokeRect(shape.left, shape.top, shape.width, shape.height, fill);
|
|
23183
|
-
|
|
23278
|
+
return;
|
|
23279
|
+
}
|
|
23280
|
+
if (shape instanceof Line || shape instanceof Polygon) {
|
|
23184
23281
|
this.strokePolygon(shape, fill);
|
|
23185
|
-
|
|
23282
|
+
return;
|
|
23283
|
+
}
|
|
23284
|
+
if (shape instanceof RoundRect) {
|
|
23285
|
+
this.strokeRoundRect(shape.left, shape.top, shape.width, shape.height, shape.radius, fill);
|
|
23286
|
+
return;
|
|
23287
|
+
}
|
|
23288
|
+
if (shape instanceof Ellipse) {
|
|
23186
23289
|
this.strokeEllipse(
|
|
23187
23290
|
shape.pos.x,
|
|
23188
23291
|
shape.pos.y,
|
|
@@ -23190,7 +23293,9 @@ class Renderer {
|
|
|
23190
23293
|
shape.radiusV.y,
|
|
23191
23294
|
fill
|
|
23192
23295
|
);
|
|
23296
|
+
return;
|
|
23193
23297
|
}
|
|
23298
|
+
throw new Error("Invalid geometry for fill/stroke");
|
|
23194
23299
|
}
|
|
23195
23300
|
|
|
23196
23301
|
/**
|
|
@@ -23198,7 +23303,7 @@ class Renderer {
|
|
|
23198
23303
|
* @name fill
|
|
23199
23304
|
* @memberof Renderer.prototype
|
|
23200
23305
|
* @function
|
|
23201
|
-
* @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
23306
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
23202
23307
|
*/
|
|
23203
23308
|
fill(shape) {
|
|
23204
23309
|
this.stroke(shape, true);
|
|
@@ -23240,7 +23345,7 @@ class Renderer {
|
|
|
23240
23345
|
* @name setMask
|
|
23241
23346
|
* @memberof Renderer.prototype
|
|
23242
23347
|
* @function
|
|
23243
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
23348
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
23244
23349
|
*/
|
|
23245
23350
|
// eslint-disable-next-line no-unused-vars
|
|
23246
23351
|
setMask(mask) {}
|
|
@@ -23810,20 +23915,7 @@ class CanvasRenderer extends Renderer {
|
|
|
23810
23915
|
var context = this.getContext();
|
|
23811
23916
|
|
|
23812
23917
|
context.beginPath();
|
|
23813
|
-
|
|
23814
|
-
//https://developer.chrome.com/blog/canvas2d/#round-rect
|
|
23815
|
-
context.roundRect(x, y, width, height, radius);
|
|
23816
|
-
} else {
|
|
23817
|
-
context.moveTo(x + radius, y);
|
|
23818
|
-
context.lineTo(x + width - radius, y);
|
|
23819
|
-
context.arcTo(x + width, y, x + width, y + radius, radius);
|
|
23820
|
-
context.lineTo(x + width, y + height - radius);
|
|
23821
|
-
context.arcTo(x + width, y + height, x + width - radius, y + height, radius);
|
|
23822
|
-
context.lineTo(x + radius, y + height);
|
|
23823
|
-
context.arcTo(x, y + height, x, y + height - radius, radius);
|
|
23824
|
-
context.lineTo(x, y + radius);
|
|
23825
|
-
context.arcTo(x, y, x + radius, y, radius);
|
|
23826
|
-
}
|
|
23918
|
+
context.roundRect(x, y, width, height, radius);
|
|
23827
23919
|
context[fill === true ? "fill" : "stroke"]();
|
|
23828
23920
|
}
|
|
23829
23921
|
|
|
@@ -24056,7 +24148,7 @@ class CanvasRenderer extends Renderer {
|
|
|
24056
24148
|
* @name setMask
|
|
24057
24149
|
* @memberof CanvasRenderer.prototype
|
|
24058
24150
|
* @function
|
|
24059
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
24151
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
24060
24152
|
*/
|
|
24061
24153
|
setMask(mask) {
|
|
24062
24154
|
var context = this.getContext();
|
|
@@ -24064,6 +24156,8 @@ class CanvasRenderer extends Renderer {
|
|
|
24064
24156
|
|
|
24065
24157
|
context.save();
|
|
24066
24158
|
|
|
24159
|
+
context.beginPath();
|
|
24160
|
+
|
|
24067
24161
|
// https://github.com/melonjs/melonJS/issues/648
|
|
24068
24162
|
if (mask instanceof Ellipse) {
|
|
24069
24163
|
var hw = mask.radiusV.x,
|
|
@@ -24080,14 +24174,14 @@ class CanvasRenderer extends Renderer {
|
|
|
24080
24174
|
ymin = _y - ymagic,
|
|
24081
24175
|
ymax = _y + ymagic;
|
|
24082
24176
|
|
|
24083
|
-
context.beginPath();
|
|
24084
24177
|
context.moveTo(_x, ty);
|
|
24085
24178
|
context.bezierCurveTo(xmax, ty, rx, ymin, rx, _y);
|
|
24086
24179
|
context.bezierCurveTo(rx, ymax, xmax, by, _x, by);
|
|
24087
24180
|
context.bezierCurveTo(xmin, by, lx, ymax, lx, _y);
|
|
24088
24181
|
context.bezierCurveTo(lx, ymin, xmin, ty, _x, ty);
|
|
24182
|
+
} else if (mask instanceof RoundRect) {
|
|
24183
|
+
context.roundRect(_x, _y, mask.width, mask.height, mask.radius);
|
|
24089
24184
|
} else {
|
|
24090
|
-
context.beginPath();
|
|
24091
24185
|
context.moveTo(_x + mask.points[0].x, _y + mask.points[0].y);
|
|
24092
24186
|
var point;
|
|
24093
24187
|
for (var i = 1; i < mask.points.length; i++) {
|
|
@@ -24107,7 +24201,7 @@ class CanvasRenderer extends Renderer {
|
|
|
24107
24201
|
* @function
|
|
24108
24202
|
*/
|
|
24109
24203
|
clearMask() {
|
|
24110
|
-
this.
|
|
24204
|
+
this.getContext().restore();
|
|
24111
24205
|
}
|
|
24112
24206
|
|
|
24113
24207
|
}
|
|
@@ -30398,7 +30492,7 @@ function extractUniforms(gl, shader) {
|
|
|
30398
30492
|
*/
|
|
30399
30493
|
return function (val) {
|
|
30400
30494
|
var fnv = fn;
|
|
30401
|
-
if (val.length && fn.
|
|
30495
|
+
if (val.length && fn.slice(-1) !== "v") {
|
|
30402
30496
|
fnv += "v";
|
|
30403
30497
|
}
|
|
30404
30498
|
gl[fnv](locations[name], val);
|
|
@@ -32448,7 +32542,7 @@ class WebGLRenderer extends Renderer {
|
|
|
32448
32542
|
* @name setMask
|
|
32449
32543
|
* @memberof WebGLRenderer.prototype
|
|
32450
32544
|
* @function
|
|
32451
|
-
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
32545
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
32452
32546
|
*/
|
|
32453
32547
|
setMask(mask) {
|
|
32454
32548
|
var gl = this.gl;
|
|
@@ -33054,14 +33148,14 @@ var utils = {
|
|
|
33054
33148
|
// never cache if a url is passed as parameter
|
|
33055
33149
|
var index = url.indexOf("#");
|
|
33056
33150
|
if (index !== -1) {
|
|
33057
|
-
url = url.
|
|
33151
|
+
url = url.slice(index, url.length);
|
|
33058
33152
|
} else {
|
|
33059
33153
|
return hash;
|
|
33060
33154
|
}
|
|
33061
33155
|
}
|
|
33062
33156
|
|
|
33063
33157
|
// parse the url
|
|
33064
|
-
url.
|
|
33158
|
+
url.slice(1).split("&").filter(function (value) {
|
|
33065
33159
|
return (value !== "");
|
|
33066
33160
|
}).forEach(function (value) {
|
|
33067
33161
|
var kv = value.split("=");
|
|
@@ -33407,6 +33501,240 @@ if (!requestAnimationFrame || !cancelAnimationFrame) {
|
|
|
33407
33501
|
globalThis.cancelAnimationFrame = cancelAnimationFrame;
|
|
33408
33502
|
}
|
|
33409
33503
|
|
|
33504
|
+
/*
|
|
33505
|
+
* based on https://www.npmjs.com/package/canvas-roundrect-polyfill
|
|
33506
|
+
* @version 0.0.1
|
|
33507
|
+
*/
|
|
33508
|
+
(() => {
|
|
33509
|
+
|
|
33510
|
+
/** @ignore */
|
|
33511
|
+
function roundRect(x, y, w, h, radii) {
|
|
33512
|
+
|
|
33513
|
+
if (!([x, y, w, h].every((input) => Number.isFinite(input)))) {
|
|
33514
|
+
|
|
33515
|
+
return;
|
|
33516
|
+
|
|
33517
|
+
}
|
|
33518
|
+
|
|
33519
|
+
radii = parseRadiiArgument(radii);
|
|
33520
|
+
|
|
33521
|
+
let upperLeft, upperRight, lowerRight, lowerLeft;
|
|
33522
|
+
|
|
33523
|
+
if (radii.length === 4) {
|
|
33524
|
+
|
|
33525
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33526
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33527
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
33528
|
+
lowerLeft = toCornerPoint(radii[3]);
|
|
33529
|
+
|
|
33530
|
+
} else if (radii.length === 3) {
|
|
33531
|
+
|
|
33532
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33533
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33534
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
33535
|
+
lowerRight = toCornerPoint(radii[2]);
|
|
33536
|
+
|
|
33537
|
+
} else if (radii.length === 2) {
|
|
33538
|
+
|
|
33539
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33540
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
33541
|
+
upperRight = toCornerPoint(radii[1]);
|
|
33542
|
+
lowerLeft = toCornerPoint(radii[1]);
|
|
33543
|
+
|
|
33544
|
+
} else if (radii.length === 1) {
|
|
33545
|
+
|
|
33546
|
+
upperLeft = toCornerPoint(radii[0]);
|
|
33547
|
+
upperRight = toCornerPoint(radii[0]);
|
|
33548
|
+
lowerRight = toCornerPoint(radii[0]);
|
|
33549
|
+
lowerLeft = toCornerPoint(radii[0]);
|
|
33550
|
+
|
|
33551
|
+
} else {
|
|
33552
|
+
|
|
33553
|
+
throw new Error(radii.length + " is not a valid size for radii sequence.");
|
|
33554
|
+
|
|
33555
|
+
}
|
|
33556
|
+
|
|
33557
|
+
const corners = [upperLeft, upperRight, lowerRight, lowerLeft];
|
|
33558
|
+
const negativeCorner = corners.find(({x, y}) => x < 0 || y < 0);
|
|
33559
|
+
//const negativeValue = negativeCorner?.x < 0 ? negativeCorner.x : negativeCorner?.y
|
|
33560
|
+
|
|
33561
|
+
if (corners.some(({x, y}) => !Number.isFinite(x) || !Number.isFinite(y))) {
|
|
33562
|
+
|
|
33563
|
+
return;
|
|
33564
|
+
|
|
33565
|
+
}
|
|
33566
|
+
|
|
33567
|
+
if (negativeCorner) {
|
|
33568
|
+
|
|
33569
|
+
throw new Error("Radius value " + negativeCorner + " is negative.");
|
|
33570
|
+
|
|
33571
|
+
}
|
|
33572
|
+
|
|
33573
|
+
fixOverlappingCorners(corners);
|
|
33574
|
+
|
|
33575
|
+
if (w < 0 && h < 0) {
|
|
33576
|
+
|
|
33577
|
+
this.moveTo(x - upperLeft.x, y);
|
|
33578
|
+
this.ellipse(x + w + upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI * 1.5, -Math.PI);
|
|
33579
|
+
this.ellipse(x + w + lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI / 2);
|
|
33580
|
+
this.ellipse(x - lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, 0);
|
|
33581
|
+
this.ellipse(x - upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2);
|
|
33582
|
+
|
|
33583
|
+
} else if (w < 0) {
|
|
33584
|
+
|
|
33585
|
+
this.moveTo(x - upperLeft.x, y);
|
|
33586
|
+
this.ellipse(x + w + upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
33587
|
+
this.ellipse(x + w + lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
33588
|
+
this.ellipse(x - lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, 0, 1);
|
|
33589
|
+
this.ellipse(x - upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, 0, -Math.PI / 2, 1);
|
|
33590
|
+
|
|
33591
|
+
} else if (h < 0) {
|
|
33592
|
+
|
|
33593
|
+
this.moveTo(x + upperLeft.x, y);
|
|
33594
|
+
this.ellipse(x + w - upperRight.x, y - upperRight.y, upperRight.x, upperRight.y, 0, Math.PI / 2, 0, 1);
|
|
33595
|
+
this.ellipse(x + w - lowerRight.x, y + h + lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, -Math.PI / 2, 1);
|
|
33596
|
+
this.ellipse(x + lowerLeft.x, y + h + lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, -Math.PI / 2, -Math.PI, 1);
|
|
33597
|
+
this.ellipse(x + upperLeft.x, y - upperLeft.y, upperLeft.x, upperLeft.y, 0, -Math.PI, -Math.PI * 1.5, 1);
|
|
33598
|
+
|
|
33599
|
+
} else {
|
|
33600
|
+
|
|
33601
|
+
this.moveTo(x + upperLeft.x, y);
|
|
33602
|
+
this.ellipse(x + w - upperRight.x, y + upperRight.y, upperRight.x, upperRight.y, 0, -Math.PI / 2, 0);
|
|
33603
|
+
this.ellipse(x + w - lowerRight.x, y + h - lowerRight.y, lowerRight.x, lowerRight.y, 0, 0, Math.PI / 2);
|
|
33604
|
+
this.ellipse(x + lowerLeft.x, y + h - lowerLeft.y, lowerLeft.x, lowerLeft.y, 0, Math.PI / 2, Math.PI);
|
|
33605
|
+
this.ellipse(x + upperLeft.x, y + upperLeft.y, upperLeft.x, upperLeft.y, 0, Math.PI, Math.PI * 1.5);
|
|
33606
|
+
|
|
33607
|
+
}
|
|
33608
|
+
|
|
33609
|
+
this.closePath();
|
|
33610
|
+
this.moveTo(x, y);
|
|
33611
|
+
|
|
33612
|
+
/** @ignore */
|
|
33613
|
+
function toDOMPointInit(value) {
|
|
33614
|
+
|
|
33615
|
+
const {x, y, z, w} = value;
|
|
33616
|
+
return {x, y, z, w};
|
|
33617
|
+
|
|
33618
|
+
}
|
|
33619
|
+
|
|
33620
|
+
/** @ignore */
|
|
33621
|
+
function parseRadiiArgument(value) {
|
|
33622
|
+
|
|
33623
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
33624
|
+
// with 'optional (unrestricted double or DOMPointInit
|
|
33625
|
+
// or sequence<(unrestricted double or DOMPointInit)>) radii = 0'
|
|
33626
|
+
const type = typeof value;
|
|
33627
|
+
|
|
33628
|
+
if (type === "undefined" || value === null) {
|
|
33629
|
+
|
|
33630
|
+
return [0];
|
|
33631
|
+
|
|
33632
|
+
}
|
|
33633
|
+
if (type === "function") {
|
|
33634
|
+
|
|
33635
|
+
return [NaN];
|
|
33636
|
+
|
|
33637
|
+
}
|
|
33638
|
+
if (type === "object") {
|
|
33639
|
+
|
|
33640
|
+
if (typeof value[Symbol.iterator] === "function") {
|
|
33641
|
+
|
|
33642
|
+
return [...value].map((elem) => {
|
|
33643
|
+
// https://webidl.spec.whatwg.org/#es-union
|
|
33644
|
+
// with '(unrestricted double or DOMPointInit)'
|
|
33645
|
+
const elemType = typeof elem;
|
|
33646
|
+
if (elemType === "undefined" || elem === null) {
|
|
33647
|
+
return 0;
|
|
33648
|
+
}
|
|
33649
|
+
if (elemType === "function") {
|
|
33650
|
+
return NaN;
|
|
33651
|
+
}
|
|
33652
|
+
if (elemType === "object") {
|
|
33653
|
+
return toDOMPointInit(elem);
|
|
33654
|
+
}
|
|
33655
|
+
return toUnrestrictedNumber(elem);
|
|
33656
|
+
});
|
|
33657
|
+
|
|
33658
|
+
}
|
|
33659
|
+
|
|
33660
|
+
return [toDOMPointInit(value)];
|
|
33661
|
+
|
|
33662
|
+
}
|
|
33663
|
+
|
|
33664
|
+
return [toUnrestrictedNumber(value)];
|
|
33665
|
+
|
|
33666
|
+
}
|
|
33667
|
+
|
|
33668
|
+
/** @ignore */
|
|
33669
|
+
function toUnrestrictedNumber(value) {
|
|
33670
|
+
|
|
33671
|
+
return +value;
|
|
33672
|
+
|
|
33673
|
+
}
|
|
33674
|
+
|
|
33675
|
+
/** @ignore */
|
|
33676
|
+
function toCornerPoint(value) {
|
|
33677
|
+
|
|
33678
|
+
const asNumber = toUnrestrictedNumber(value);
|
|
33679
|
+
if (Number.isFinite(asNumber)) {
|
|
33680
|
+
|
|
33681
|
+
return {
|
|
33682
|
+
x: asNumber,
|
|
33683
|
+
y: asNumber
|
|
33684
|
+
};
|
|
33685
|
+
|
|
33686
|
+
}
|
|
33687
|
+
if (Object(value) === value) {
|
|
33688
|
+
|
|
33689
|
+
return {
|
|
33690
|
+
x: toUnrestrictedNumber(value.x || 0),
|
|
33691
|
+
y: toUnrestrictedNumber(value.y || 0)
|
|
33692
|
+
};
|
|
33693
|
+
|
|
33694
|
+
}
|
|
33695
|
+
|
|
33696
|
+
return {
|
|
33697
|
+
x: NaN,
|
|
33698
|
+
y: NaN
|
|
33699
|
+
};
|
|
33700
|
+
|
|
33701
|
+
}
|
|
33702
|
+
|
|
33703
|
+
/** @ignore */
|
|
33704
|
+
function fixOverlappingCorners(corners) {
|
|
33705
|
+
const [upperLeft, upperRight, lowerRight, lowerLeft] = corners;
|
|
33706
|
+
const factors = [
|
|
33707
|
+
Math.abs(w) / (upperLeft.x + upperRight.x),
|
|
33708
|
+
Math.abs(h) / (upperRight.y + lowerRight.y),
|
|
33709
|
+
Math.abs(w) / (lowerRight.x + lowerLeft.x),
|
|
33710
|
+
Math.abs(h) / (upperLeft.y + lowerLeft.y)
|
|
33711
|
+
];
|
|
33712
|
+
const minFactor = Math.min(...factors);
|
|
33713
|
+
if (minFactor <= 1) {
|
|
33714
|
+
corners.forEach((radii) => {
|
|
33715
|
+
radii.x *= minFactor;
|
|
33716
|
+
radii.y *= minFactor;
|
|
33717
|
+
});
|
|
33718
|
+
}
|
|
33719
|
+
}
|
|
33720
|
+
}
|
|
33721
|
+
|
|
33722
|
+
if (typeof Path2D.prototype.roundRect === "undefined") {
|
|
33723
|
+
Path2D.prototype.roundRect = roundRect;
|
|
33724
|
+
}
|
|
33725
|
+
if (globalThis.CanvasRenderingContext2D) {
|
|
33726
|
+
if (typeof globalThis.CanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
33727
|
+
globalThis.CanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
33728
|
+
}
|
|
33729
|
+
}
|
|
33730
|
+
if (globalThis.OffscreenCanvasRenderingContext2D) {
|
|
33731
|
+
if (typeof globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect === "undefined") {
|
|
33732
|
+
globalThis.OffscreenCanvasRenderingContext2D.prototype.roundRect = roundRect;
|
|
33733
|
+
}
|
|
33734
|
+
}
|
|
33735
|
+
|
|
33736
|
+
})();
|
|
33737
|
+
|
|
33410
33738
|
/**
|
|
33411
33739
|
* This namespace is a container for all registered plugins.
|
|
33412
33740
|
* @see plugin.register
|
|
@@ -33423,10 +33751,10 @@ class BasePlugin {
|
|
|
33423
33751
|
* this can be overridden by the plugin
|
|
33424
33752
|
* @public
|
|
33425
33753
|
* @type {string}
|
|
33426
|
-
* @default "10.
|
|
33754
|
+
* @default "10.9.0"
|
|
33427
33755
|
* @name plugin.Base#version
|
|
33428
33756
|
*/
|
|
33429
|
-
this.version = "10.
|
|
33757
|
+
this.version = "10.9.0";
|
|
33430
33758
|
}
|
|
33431
33759
|
}
|
|
33432
33760
|
|
|
@@ -37963,7 +38291,7 @@ class DroptargetEntity extends DropTarget {
|
|
|
37963
38291
|
* @name version
|
|
37964
38292
|
* @type {string}
|
|
37965
38293
|
*/
|
|
37966
|
-
const version = "10.
|
|
38294
|
+
const version = "10.9.0";
|
|
37967
38295
|
|
|
37968
38296
|
|
|
37969
38297
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.9.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"keywords": [
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
67
67
|
"@rollup/plugin-replace": "^4.0.0",
|
|
68
68
|
"@types/offscreencanvas": "^2019.6.4",
|
|
69
|
-
"cheerio": "^1.0.0-rc.
|
|
69
|
+
"cheerio": "^1.0.0-rc.11",
|
|
70
70
|
"del-cli": "^4.0.1",
|
|
71
|
-
"eslint": "^8.
|
|
72
|
-
"eslint-plugin-jsdoc": "^39.
|
|
71
|
+
"eslint": "^8.16.0",
|
|
72
|
+
"eslint-plugin-jsdoc": "^39.3.0",
|
|
73
73
|
"jasmine-core": "^4.1.1",
|
|
74
74
|
"jsdoc": "^3.6.10",
|
|
75
75
|
"karma": "^6.3.20",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"karma-jasmine": "^5.0.1",
|
|
80
80
|
"karma-nyan-reporter": "0.2.5",
|
|
81
81
|
"qs": "^6.10.3",
|
|
82
|
-
"rollup": "^2.
|
|
82
|
+
"rollup": "^2.74.1",
|
|
83
83
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
84
84
|
"rollup-plugin-string": "^3.0.0",
|
|
85
85
|
"terser": "^5.13.1",
|