melonjs 10.9.0 → 10.12.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/LICENSE.md +1 -1
- package/README.md +32 -25
- package/dist/melonjs.js +1635 -2383
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +929 -1504
- package/dist/melonjs.module.js +1581 -2344
- package/package.json +18 -18
- package/src/audio/audio.js +0 -1
- package/src/camera/camera2d.js +1 -16
- package/src/entity/entity.js +6 -11
- package/src/game.js +2 -2
- package/src/geometries/ellipse.js +19 -28
- package/src/geometries/line.js +5 -8
- package/src/geometries/path2d.js +14 -24
- package/src/geometries/poly.js +29 -47
- package/src/geometries/rectangle.js +25 -37
- package/src/geometries/roundrect.js +8 -12
- package/src/index.js +7 -2
- package/src/input/gamepad.js +3 -14
- package/src/input/keyboard.js +1 -9
- package/src/input/pointer.js +0 -1
- package/src/input/pointerevent.js +14 -23
- package/src/lang/deprecated.js +9 -6
- package/src/level/level.js +0 -9
- package/src/level/tiled/TMXGroup.js +0 -4
- package/src/level/tiled/TMXLayer.js +0 -8
- package/src/level/tiled/TMXObject.js +0 -3
- package/src/level/tiled/TMXTile.js +4 -5
- package/src/level/tiled/TMXTileMap.js +1 -7
- package/src/level/tiled/TMXTileset.js +0 -5
- package/src/level/tiled/TMXTilesetGroup.js +1 -4
- package/src/level/tiled/TMXUtils.js +1 -4
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -7
- package/src/loader/loader.js +0 -11
- package/src/loader/loadingscreen.js +16 -5
- package/src/math/color.js +10 -30
- package/src/math/math.js +0 -10
- package/src/math/matrix2.js +12 -27
- package/src/math/matrix3.js +1 -22
- package/src/math/observable_vector2.js +0 -29
- package/src/math/observable_vector3.js +0 -29
- package/src/math/vector2.js +3 -40
- package/src/math/vector3.js +4 -41
- package/src/particles/emitter.js +11 -12
- package/src/physics/body.js +4 -5
- package/src/physics/bounds.js +5 -19
- package/src/physics/collision.js +1 -13
- package/src/physics/detector.js +6 -56
- package/src/physics/quadtree.js +0 -7
- package/src/physics/response.js +48 -0
- package/src/physics/sat.js +4 -4
- package/src/physics/world.js +0 -4
- package/src/plugin/plugin.js +0 -2
- package/src/polyfill/roundrect.js +4 -2
- package/src/renderable/GUI.js +11 -14
- package/src/renderable/collectable.js +1 -0
- package/src/renderable/colorlayer.js +9 -7
- package/src/renderable/container.js +38 -64
- package/src/renderable/dragndrop.js +1 -10
- package/src/renderable/imagelayer.js +8 -12
- package/src/renderable/light2d.js +118 -0
- package/src/renderable/renderable.js +27 -48
- package/src/renderable/sprite.js +17 -29
- package/src/renderable/trigger.js +10 -3
- package/src/state/stage.js +72 -6
- package/src/state/state.js +22 -23
- package/src/system/device.js +14 -53
- package/src/system/event.js +11 -0
- package/src/system/pooling.js +20 -9
- package/src/system/save.js +9 -11
- package/src/system/timer.js +239 -218
- package/src/text/bitmaptextdata.js +1 -4
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +25 -24
- package/src/text/textmetrics.js +0 -2
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +2 -2
- package/src/tweens/tween.js +1 -13
- package/src/utils/agent.js +1 -3
- package/src/utils/array.js +0 -3
- package/src/utils/file.js +0 -2
- package/src/utils/function.js +0 -2
- package/src/utils/string.js +0 -6
- package/src/utils/utils.js +0 -3
- package/src/video/canvas/canvas_renderer.js +73 -90
- package/src/video/renderer.js +34 -49
- package/src/video/{texture.js → texture/atlas.js} +10 -8
- package/src/video/{texture_cache.js → texture/cache.js} +4 -5
- package/src/video/texture/canvas_texture.js +99 -0
- package/src/video/video.js +3 -3
- package/src/video/webgl/glshader.js +0 -5
- package/src/video/webgl/utils/uniforms.js +3 -6
- package/src/video/webgl/webgl_compositor.js +0 -14
- package/src/video/webgl/webgl_renderer.js +73 -97
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.12.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"keywords": [
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"name": "Olivier Biot",
|
|
36
36
|
"email": "contact@melonjs.org"
|
|
37
37
|
},
|
|
38
|
+
"funding": "https://github.com/sponsors/melonjs",
|
|
38
39
|
"engines": {
|
|
39
40
|
"node": ">= 12"
|
|
40
41
|
},
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
"dist/melonjs.min.js",
|
|
47
48
|
"dist/melonjs.module.js",
|
|
48
49
|
"dist/melonjs.module.d.ts",
|
|
49
|
-
"plugins/",
|
|
50
50
|
"src/",
|
|
51
51
|
"package.json",
|
|
52
52
|
"README.md",
|
|
@@ -55,44 +55,44 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@teppeis/multimaps": "^2.0.0",
|
|
58
|
-
"core-js": "^3.
|
|
58
|
+
"core-js": "^3.23.1",
|
|
59
59
|
"earcut": "2.2.3",
|
|
60
60
|
"eventemitter3": "^4.0.7",
|
|
61
61
|
"howler": "2.2.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
+
"@melonjs/webdoc-theme": "^1.1.1",
|
|
64
65
|
"@rollup/plugin-buble": "^0.21.3",
|
|
65
66
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
66
67
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
67
68
|
"@rollup/plugin-replace": "^4.0.0",
|
|
68
|
-
"@types/offscreencanvas": "^2019.
|
|
69
|
-
"
|
|
69
|
+
"@types/offscreencanvas": "^2019.7.0",
|
|
70
|
+
"@webdoc/cli": "^1.6.6",
|
|
70
71
|
"del-cli": "^4.0.1",
|
|
71
|
-
"eslint": "^8.
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"jsdoc": "^3.6.10",
|
|
75
|
-
"karma": "^6.3.20",
|
|
72
|
+
"eslint": "^8.18.0",
|
|
73
|
+
"jasmine-core": "^4.2.0",
|
|
74
|
+
"karma": "^6.4.0",
|
|
76
75
|
"karma-chrome-launcher": "^3.1.1",
|
|
77
76
|
"karma-coverage": "^2.2.0",
|
|
78
77
|
"karma-html-detailed-reporter": "^2.1.0",
|
|
79
|
-
"karma-jasmine": "^5.0
|
|
78
|
+
"karma-jasmine": "^5.1.0",
|
|
80
79
|
"karma-nyan-reporter": "0.2.5",
|
|
81
|
-
"
|
|
82
|
-
"rollup": "^2.74.1",
|
|
80
|
+
"rollup": "^2.75.6",
|
|
83
81
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
84
82
|
"rollup-plugin-string": "^3.0.0",
|
|
85
|
-
"terser": "^5.
|
|
86
|
-
"typescript": "^4.
|
|
83
|
+
"terser": "^5.14.1",
|
|
84
|
+
"typescript": "^4.7.4"
|
|
87
85
|
},
|
|
88
86
|
"scripts": {
|
|
89
87
|
"build": "npm run lint && rollup -c --silent",
|
|
90
88
|
"dist": " npm run build && npm run minify && mkdirp dist && cp -f build/*.js dist/ && npm run types",
|
|
91
89
|
"minify": "terser build/melonjs.js --compress --mangle --comments '/(?:^!|@(?:license|preserve|cc_on))/' --output build/melonjs.min.js",
|
|
92
90
|
"lint": "eslint src rollup.config.js",
|
|
93
|
-
"test": "npm run
|
|
94
|
-
"
|
|
95
|
-
"
|
|
91
|
+
"test": "npm run test-node && karma start tests/karma.conf.cjs",
|
|
92
|
+
"test-node": "node build/melonjs.module.js",
|
|
93
|
+
"doc": "mkdirp docs && webdoc --quiet --site-root docs -R README.md",
|
|
94
|
+
"serve": "python3 -m http.server",
|
|
95
|
+
"prepublishOnly": "npm run dist && npm run test",
|
|
96
96
|
"clean": "del-cli --force build/*.js dist/*.js dist/*.d.ts docs src/**/*.d.ts",
|
|
97
97
|
"types": "tsc dist/melonjs.module.js --declaration --allowJs --emitDeclarationOnly"
|
|
98
98
|
}
|
package/src/audio/audio.js
CHANGED
package/src/camera/camera2d.js
CHANGED
|
@@ -14,7 +14,7 @@ import { world } from "./../game.js";
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
// some ref shortcut
|
|
17
|
-
|
|
17
|
+
const MIN = Math.min, MAX = Math.max;
|
|
18
18
|
|
|
19
19
|
var targetV = new Vector2d();
|
|
20
20
|
|
|
@@ -207,7 +207,6 @@ class Camera2d extends Renderable {
|
|
|
207
207
|
* reset the camera position to specified coordinates
|
|
208
208
|
* @name reset
|
|
209
209
|
* @memberof Camera2d
|
|
210
|
-
* @function
|
|
211
210
|
* @param {number} [x=0]
|
|
212
211
|
* @param {number} [y=0]
|
|
213
212
|
*/
|
|
@@ -238,7 +237,6 @@ class Camera2d extends Renderable {
|
|
|
238
237
|
* @name setDeadzone
|
|
239
238
|
* @see Camera2d.follow
|
|
240
239
|
* @memberof Camera2d
|
|
241
|
-
* @function
|
|
242
240
|
* @param {number} w deadzone width
|
|
243
241
|
* @param {number} h deadzone height
|
|
244
242
|
*/
|
|
@@ -266,7 +264,6 @@ class Camera2d extends Renderable {
|
|
|
266
264
|
* resize the camera
|
|
267
265
|
* @name resize
|
|
268
266
|
* @memberof Camera2d
|
|
269
|
-
* @function
|
|
270
267
|
* @param {number} w new width of the camera
|
|
271
268
|
* @param {number} h new height of the camera
|
|
272
269
|
* @returns {Camera2d} this camera
|
|
@@ -298,7 +295,6 @@ class Camera2d extends Renderable {
|
|
|
298
295
|
* the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
|
|
299
296
|
* @name setBounds
|
|
300
297
|
* @memberof Camera2d
|
|
301
|
-
* @function
|
|
302
298
|
* @param {number} x world left limit
|
|
303
299
|
* @param {number} y world top limit
|
|
304
300
|
* @param {number} w world width limit
|
|
@@ -317,7 +313,6 @@ class Camera2d extends Renderable {
|
|
|
317
313
|
* (this will put the camera center around the given target)
|
|
318
314
|
* @name follow
|
|
319
315
|
* @memberof Camera2d
|
|
320
|
-
* @function
|
|
321
316
|
* @param {Renderable|Vector2d} target renderable or position vector to follow
|
|
322
317
|
* @param {number} [axis=me.game.viewport.AXIS.BOTH] Which axis to follow (see {@link Camera2d.AXIS})
|
|
323
318
|
* @param {number} [damping=1] default damping value
|
|
@@ -359,7 +354,6 @@ class Camera2d extends Renderable {
|
|
|
359
354
|
* unfollow the current target
|
|
360
355
|
* @name unfollow
|
|
361
356
|
* @memberof Camera2d
|
|
362
|
-
* @function
|
|
363
357
|
*/
|
|
364
358
|
unfollow() {
|
|
365
359
|
this.target = null;
|
|
@@ -371,7 +365,6 @@ class Camera2d extends Renderable {
|
|
|
371
365
|
* @name move
|
|
372
366
|
* @memberof Camera2d
|
|
373
367
|
* @see Camera2d.focusOn
|
|
374
|
-
* @function
|
|
375
368
|
* @param {number} x
|
|
376
369
|
* @param {number} y
|
|
377
370
|
* @example
|
|
@@ -387,7 +380,6 @@ class Camera2d extends Renderable {
|
|
|
387
380
|
* @name moveTo
|
|
388
381
|
* @memberof Camera2d
|
|
389
382
|
* @see Camera2d.focusOn
|
|
390
|
-
* @function
|
|
391
383
|
* @param {number} x
|
|
392
384
|
* @param {number} y
|
|
393
385
|
*/
|
|
@@ -511,7 +503,6 @@ class Camera2d extends Renderable {
|
|
|
511
503
|
* shake the camera
|
|
512
504
|
* @name shake
|
|
513
505
|
* @memberof Camera2d
|
|
514
|
-
* @function
|
|
515
506
|
* @param {number} intensity maximum offset that the screen can be moved
|
|
516
507
|
* while shaking
|
|
517
508
|
* @param {number} duration expressed in milliseconds
|
|
@@ -536,7 +527,6 @@ class Camera2d extends Renderable {
|
|
|
536
527
|
* screen is filled with the specified color and slowly goes back to normal
|
|
537
528
|
* @name fadeOut
|
|
538
529
|
* @memberof Camera2d
|
|
539
|
-
* @function
|
|
540
530
|
* @param {Color|string} color a CSS color value
|
|
541
531
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
542
532
|
* @param {Function} [onComplete] callback once effect is over
|
|
@@ -562,7 +552,6 @@ class Camera2d extends Renderable {
|
|
|
562
552
|
* fade to the specified color
|
|
563
553
|
* @name fadeIn
|
|
564
554
|
* @memberof Camera2d
|
|
565
|
-
* @function
|
|
566
555
|
* @param {Color|string} color a CSS color value
|
|
567
556
|
* @param {number} [duration=1000] expressed in milliseconds
|
|
568
557
|
* @param {Function} [onComplete] callback once effect is over
|
|
@@ -585,7 +574,6 @@ class Camera2d extends Renderable {
|
|
|
585
574
|
* set the camera position around the specified object
|
|
586
575
|
* @name focusOn
|
|
587
576
|
* @memberof Camera2d
|
|
588
|
-
* @function
|
|
589
577
|
* @param {Renderable} target the renderable to focus the camera on
|
|
590
578
|
*/
|
|
591
579
|
focusOn(target) {
|
|
@@ -600,7 +588,6 @@ class Camera2d extends Renderable {
|
|
|
600
588
|
* check if the specified renderable is in the camera
|
|
601
589
|
* @name isVisible
|
|
602
590
|
* @memberof Camera2d
|
|
603
|
-
* @function
|
|
604
591
|
* @param {Renderable} obj to be checked against
|
|
605
592
|
* @param {boolean} [floating = obj.floating] if visibility check should be done against screen coordinates
|
|
606
593
|
* @returns {boolean}
|
|
@@ -619,7 +606,6 @@ class Camera2d extends Renderable {
|
|
|
619
606
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
620
607
|
* @name localToWorld
|
|
621
608
|
* @memberof Camera2d
|
|
622
|
-
* @function
|
|
623
609
|
* @param {number} x
|
|
624
610
|
* @param {number} y
|
|
625
611
|
* @param {number} [v] an optional vector object where to set the
|
|
@@ -640,7 +626,6 @@ class Camera2d extends Renderable {
|
|
|
640
626
|
* convert the given world coordinates into "local" (screen) coordinates
|
|
641
627
|
* @name worldToLocal
|
|
642
628
|
* @memberof Camera2d
|
|
643
|
-
* @function
|
|
644
629
|
* @param {number} x
|
|
645
630
|
* @param {number} y
|
|
646
631
|
* @param {number} [v] an optional vector object where to set the
|
package/src/entity/entity.js
CHANGED
|
@@ -95,7 +95,7 @@ class Entity extends Renderable {
|
|
|
95
95
|
/**
|
|
96
96
|
* the entity body object
|
|
97
97
|
* @public
|
|
98
|
-
* @
|
|
98
|
+
* @member {Body}
|
|
99
99
|
* @name body
|
|
100
100
|
* @memberof Entity
|
|
101
101
|
*/
|
|
@@ -158,7 +158,6 @@ class Entity extends Renderable {
|
|
|
158
158
|
* @ignore
|
|
159
159
|
* @name onBodyUpdate
|
|
160
160
|
* @memberof Entity
|
|
161
|
-
* @function
|
|
162
161
|
* @param {Body} body the body whose bounds to update
|
|
163
162
|
*/
|
|
164
163
|
onBodyUpdate(body) {
|
|
@@ -189,24 +188,21 @@ class Entity extends Renderable {
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
/**
|
|
192
|
-
*
|
|
193
|
-
* not to be called by the end user<br>
|
|
194
|
-
* called by the game manager on each game loop
|
|
191
|
+
* draw this entity (automatically called by melonJS)
|
|
195
192
|
* @name draw
|
|
196
193
|
* @memberof Entity
|
|
197
|
-
* @function
|
|
198
194
|
* @protected
|
|
199
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
200
|
-
* @param {
|
|
195
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
196
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
201
197
|
*/
|
|
202
|
-
draw(renderer,
|
|
198
|
+
draw(renderer, viewport) {
|
|
203
199
|
var renderable = this.renderable;
|
|
204
200
|
if (renderable instanceof Renderable) {
|
|
205
201
|
// predraw (apply transforms)
|
|
206
202
|
renderable.preDraw(renderer);
|
|
207
203
|
|
|
208
204
|
// draw the object
|
|
209
|
-
renderable.draw(renderer,
|
|
205
|
+
renderable.draw(renderer, viewport);
|
|
210
206
|
|
|
211
207
|
// postdraw (clean-up);
|
|
212
208
|
renderable.postDraw(renderer);
|
|
@@ -233,7 +229,6 @@ class Entity extends Renderable {
|
|
|
233
229
|
* Called by engine before deleting the object
|
|
234
230
|
* @name onDeactivateEvent
|
|
235
231
|
* @memberof Entity
|
|
236
|
-
* @function
|
|
237
232
|
*/
|
|
238
233
|
onDeactivateEvent() {
|
|
239
234
|
if (this.renderable && this.renderable.onDeactivateEvent) {
|
package/src/game.js
CHANGED
|
@@ -5,9 +5,9 @@ import state from "./state/state.js";
|
|
|
5
5
|
import World from "./physics/world.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* game represents your current game, it contains all the objects,
|
|
9
9
|
* tilemap layers, current viewport, collision map, etc...<br>
|
|
10
|
-
*
|
|
10
|
+
* game is also responsible for updating (each frame) the object status and draw them.
|
|
11
11
|
* @namespace game
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ class Ellipse {
|
|
|
17
17
|
* @public
|
|
18
18
|
* @type {Vector2d}
|
|
19
19
|
* @name pos
|
|
20
|
-
* @memberof Ellipse
|
|
20
|
+
* @memberof Ellipse
|
|
21
21
|
*/
|
|
22
22
|
this.pos = pool.pull("Vector2d");
|
|
23
23
|
|
|
@@ -32,7 +32,7 @@ class Ellipse {
|
|
|
32
32
|
* @public
|
|
33
33
|
* @type {number}
|
|
34
34
|
* @name radius
|
|
35
|
-
* @memberof Ellipse
|
|
35
|
+
* @memberof Ellipse
|
|
36
36
|
*/
|
|
37
37
|
this.radius = NaN;
|
|
38
38
|
|
|
@@ -41,7 +41,7 @@ class Ellipse {
|
|
|
41
41
|
* @public
|
|
42
42
|
* @type {Vector2d}
|
|
43
43
|
* @name radiusV
|
|
44
|
-
* @memberof Ellipse
|
|
44
|
+
* @memberof Ellipse
|
|
45
45
|
*/
|
|
46
46
|
this.radiusV = pool.pull("Vector2d");
|
|
47
47
|
|
|
@@ -50,7 +50,7 @@ class Ellipse {
|
|
|
50
50
|
* @public
|
|
51
51
|
* @type {Vector2d}
|
|
52
52
|
* @name radiusSq
|
|
53
|
-
* @memberof Ellipse
|
|
53
|
+
* @memberof Ellipse
|
|
54
54
|
*/
|
|
55
55
|
this.radiusSq = pool.pull("Vector2d");
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ class Ellipse {
|
|
|
59
59
|
* @public
|
|
60
60
|
* @type {Vector2d}
|
|
61
61
|
* @name ratio
|
|
62
|
-
* @memberof Ellipse
|
|
62
|
+
* @memberof Ellipse
|
|
63
63
|
*/
|
|
64
64
|
this.ratio = pool.pull("Vector2d");
|
|
65
65
|
|
|
@@ -76,8 +76,7 @@ class Ellipse {
|
|
|
76
76
|
/**
|
|
77
77
|
* set new value to the Ellipse shape
|
|
78
78
|
* @name setShape
|
|
79
|
-
* @memberof Ellipse
|
|
80
|
-
* @function
|
|
79
|
+
* @memberof Ellipse
|
|
81
80
|
* @param {number} x the center x coordinate of the ellipse
|
|
82
81
|
* @param {number} y the center y coordinate of the ellipse
|
|
83
82
|
* @param {number} w width (diameter) of the ellipse
|
|
@@ -106,8 +105,7 @@ class Ellipse {
|
|
|
106
105
|
/**
|
|
107
106
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
108
107
|
* @name rotate
|
|
109
|
-
* @memberof Ellipse
|
|
110
|
-
* @function
|
|
108
|
+
* @memberof Ellipse
|
|
111
109
|
* @param {number} angle The angle to rotate (in radians)
|
|
112
110
|
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
113
111
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
@@ -123,8 +121,7 @@ class Ellipse {
|
|
|
123
121
|
/**
|
|
124
122
|
* Scale this Ellipse by the specified scalar.
|
|
125
123
|
* @name scale
|
|
126
|
-
* @memberof Ellipse
|
|
127
|
-
* @function
|
|
124
|
+
* @memberof Ellipse
|
|
128
125
|
* @param {number} x
|
|
129
126
|
* @param {number} [y=x]
|
|
130
127
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
@@ -142,8 +139,7 @@ class Ellipse {
|
|
|
142
139
|
/**
|
|
143
140
|
* Scale this Ellipse by the specified vector.
|
|
144
141
|
* @name scale
|
|
145
|
-
* @memberof Ellipse
|
|
146
|
-
* @function
|
|
142
|
+
* @memberof Ellipse
|
|
147
143
|
* @param {Vector2d} v
|
|
148
144
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
149
145
|
*/
|
|
@@ -154,12 +150,11 @@ class Ellipse {
|
|
|
154
150
|
/**
|
|
155
151
|
* apply the given transformation matrix to this ellipse
|
|
156
152
|
* @name transform
|
|
157
|
-
* @memberof Ellipse
|
|
158
|
-
* @function
|
|
153
|
+
* @memberof Ellipse
|
|
159
154
|
* @param {Matrix2d} matrix the transformation matrix
|
|
160
155
|
* @returns {Polygon} Reference to this object for method chaining
|
|
161
156
|
*/
|
|
162
|
-
transform(
|
|
157
|
+
transform(matrix) { // eslint-disable-line no-unused-vars
|
|
163
158
|
// TODO
|
|
164
159
|
return this;
|
|
165
160
|
}
|
|
@@ -167,8 +162,8 @@ class Ellipse {
|
|
|
167
162
|
/**
|
|
168
163
|
* translate the circle/ellipse by the specified offset
|
|
169
164
|
* @name translate
|
|
170
|
-
* @memberof Ellipse
|
|
171
|
-
* @
|
|
165
|
+
* @memberof Ellipse
|
|
166
|
+
* @method
|
|
172
167
|
* @param {number} x x offset
|
|
173
168
|
* @param {number} y y offset
|
|
174
169
|
* @returns {Ellipse} this ellipse
|
|
@@ -176,8 +171,7 @@ class Ellipse {
|
|
|
176
171
|
/**
|
|
177
172
|
* translate the circle/ellipse by the specified vector
|
|
178
173
|
* @name translate
|
|
179
|
-
* @memberof Ellipse
|
|
180
|
-
* @function
|
|
174
|
+
* @memberof Ellipse
|
|
181
175
|
* @param {Vector2d} v vector offset
|
|
182
176
|
* @returns {Ellipse} this ellipse
|
|
183
177
|
*/
|
|
@@ -204,8 +198,8 @@ class Ellipse {
|
|
|
204
198
|
/**
|
|
205
199
|
* check if this circle/ellipse contains the specified point
|
|
206
200
|
* @name contains
|
|
207
|
-
* @
|
|
208
|
-
* @
|
|
201
|
+
* @method
|
|
202
|
+
* @memberof Ellipse
|
|
209
203
|
* @param {Vector2d} point
|
|
210
204
|
* @returns {boolean} true if contains
|
|
211
205
|
*/
|
|
@@ -213,8 +207,7 @@ class Ellipse {
|
|
|
213
207
|
/**
|
|
214
208
|
* check if this circle/ellipse contains the specified point
|
|
215
209
|
* @name contains
|
|
216
|
-
* @memberof Ellipse
|
|
217
|
-
* @function
|
|
210
|
+
* @memberof Ellipse
|
|
218
211
|
* @param {number} x x coordinate
|
|
219
212
|
* @param {number} y y coordinate
|
|
220
213
|
* @returns {boolean} true if contains
|
|
@@ -245,8 +238,7 @@ class Ellipse {
|
|
|
245
238
|
/**
|
|
246
239
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
247
240
|
* @name getBounds
|
|
248
|
-
* @memberof Ellipse
|
|
249
|
-
* @function
|
|
241
|
+
* @memberof Ellipse
|
|
250
242
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
251
243
|
*/
|
|
252
244
|
getBounds() {
|
|
@@ -259,8 +251,7 @@ class Ellipse {
|
|
|
259
251
|
/**
|
|
260
252
|
* clone this Ellipse
|
|
261
253
|
* @name clone
|
|
262
|
-
* @memberof Ellipse
|
|
263
|
-
* @function
|
|
254
|
+
* @memberof Ellipse
|
|
264
255
|
* @returns {Ellipse} new Ellipse
|
|
265
256
|
*/
|
|
266
257
|
clone() {
|
package/src/geometries/line.js
CHANGED
|
@@ -15,8 +15,8 @@ class Line extends Polygon {
|
|
|
15
15
|
/**
|
|
16
16
|
* Returns true if the Line contains the given point
|
|
17
17
|
* @name contains
|
|
18
|
-
* @memberof Line
|
|
19
|
-
* @
|
|
18
|
+
* @memberof Line
|
|
19
|
+
* @method
|
|
20
20
|
* @param {Vector2d} point
|
|
21
21
|
* @returns {boolean} true if contains
|
|
22
22
|
*/
|
|
@@ -24,8 +24,7 @@ class Line extends Polygon {
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns true if the Line contains the given point
|
|
26
26
|
* @name contains
|
|
27
|
-
* @memberof Line
|
|
28
|
-
* @function
|
|
27
|
+
* @memberof Line
|
|
29
28
|
* @param {number} x x coordinate
|
|
30
29
|
* @param {number} y y coordinate
|
|
31
30
|
* @returns {boolean} true if contains
|
|
@@ -58,8 +57,7 @@ class Line extends Polygon {
|
|
|
58
57
|
* Computes the calculated collision edges and normals.
|
|
59
58
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
60
59
|
* @name recalc
|
|
61
|
-
* @memberof Line
|
|
62
|
-
* @function
|
|
60
|
+
* @memberof Line
|
|
63
61
|
* @returns {Line} this instance for objecf chaining
|
|
64
62
|
*/
|
|
65
63
|
recalc() {
|
|
@@ -94,8 +92,7 @@ class Line extends Polygon {
|
|
|
94
92
|
/**
|
|
95
93
|
* clone this line segment
|
|
96
94
|
* @name clone
|
|
97
|
-
* @memberof Line
|
|
98
|
-
* @function
|
|
95
|
+
* @memberof Line
|
|
99
96
|
* @returns {Line} new Line
|
|
100
97
|
*/
|
|
101
98
|
clone() {
|
package/src/geometries/path2d.js
CHANGED
|
@@ -34,8 +34,7 @@ class Path2D {
|
|
|
34
34
|
/**
|
|
35
35
|
* begin a new path
|
|
36
36
|
* @name beginPath
|
|
37
|
-
* @memberof Path2D
|
|
38
|
-
* @function
|
|
37
|
+
* @memberof Path2D
|
|
39
38
|
*/
|
|
40
39
|
beginPath() {
|
|
41
40
|
// empty the cache and recycle all vectors
|
|
@@ -50,8 +49,7 @@ class Path2D {
|
|
|
50
49
|
* It tries to draw a straight line from the current point to the start.
|
|
51
50
|
* If the shape has already been closed or has only one point, this function does nothing.
|
|
52
51
|
* @name closePath
|
|
53
|
-
* @memberof Path2D
|
|
54
|
-
* @function
|
|
52
|
+
* @memberof Path2D
|
|
55
53
|
*/
|
|
56
54
|
closePath() {
|
|
57
55
|
var points = this.points;
|
|
@@ -63,8 +61,7 @@ class Path2D {
|
|
|
63
61
|
/**
|
|
64
62
|
* triangulate the shape defined by this path into an array of triangles
|
|
65
63
|
* @name triangulatePath
|
|
66
|
-
* @memberof Path2D
|
|
67
|
-
* @function
|
|
64
|
+
* @memberof Path2D
|
|
68
65
|
* @returns {Vector2d[]}
|
|
69
66
|
*/
|
|
70
67
|
triangulatePath() {
|
|
@@ -94,8 +91,7 @@ class Path2D {
|
|
|
94
91
|
/**
|
|
95
92
|
* moves the starting point of the current path to the (x, y) coordinates.
|
|
96
93
|
* @name moveTo
|
|
97
|
-
* @memberof Path2D
|
|
98
|
-
* @function
|
|
94
|
+
* @memberof Path2D
|
|
99
95
|
* @param {number} x the x-axis (horizontal) coordinate of the point.
|
|
100
96
|
* @param {number} y the y-axis (vertical) coordinate of the point.
|
|
101
97
|
*/
|
|
@@ -106,8 +102,7 @@ class Path2D {
|
|
|
106
102
|
/**
|
|
107
103
|
* connects the last point in the current patch to the (x, y) coordinates with a straight line.
|
|
108
104
|
* @name lineTo
|
|
109
|
-
* @memberof Path2D
|
|
110
|
-
* @function
|
|
105
|
+
* @memberof Path2D
|
|
111
106
|
* @param {number} x the x-axis coordinate of the line's end point.
|
|
112
107
|
* @param {number} y the y-axis coordinate of the line's end point.
|
|
113
108
|
*/
|
|
@@ -119,8 +114,7 @@ class Path2D {
|
|
|
119
114
|
* adds an arc to the current path which is centered at (x, y) position with the given radius,
|
|
120
115
|
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
|
|
121
116
|
* @name arc
|
|
122
|
-
* @memberof Path2D
|
|
123
|
-
* @function
|
|
117
|
+
* @memberof Path2D
|
|
124
118
|
* @param {number} x the horizontal coordinate of the arc's center.
|
|
125
119
|
* @param {number} y the vertical coordinate of the arc's center.
|
|
126
120
|
* @param {number} radius the arc's radius. Must be positive.
|
|
@@ -169,12 +163,11 @@ class Path2D {
|
|
|
169
163
|
/**
|
|
170
164
|
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
171
165
|
* @name arcTo
|
|
172
|
-
* @memberof Path2D
|
|
173
|
-
* @
|
|
174
|
-
* @param {number}
|
|
175
|
-
* @param {number}
|
|
176
|
-
* @param {number}
|
|
177
|
-
* @param {number} y the y-axis coordinate of the second control point.
|
|
166
|
+
* @memberof Path2D
|
|
167
|
+
* @param {number} x1 the x-axis coordinate of the first control point.
|
|
168
|
+
* @param {number} y1 the y-axis coordinate of the first control point.
|
|
169
|
+
* @param {number} x2 the x-axis coordinate of the second control point.
|
|
170
|
+
* @param {number} y2 the y-axis coordinate of the second control point.
|
|
178
171
|
* @param {number} radius the arc's radius. Must be positive.
|
|
179
172
|
*/
|
|
180
173
|
arcTo(x1, y1, x2, y2, radius) {
|
|
@@ -218,8 +211,7 @@ class Path2D {
|
|
|
218
211
|
* adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
|
|
219
212
|
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
|
|
220
213
|
* @name ellipse
|
|
221
|
-
* @memberof Path2D
|
|
222
|
-
* @function
|
|
214
|
+
* @memberof Path2D
|
|
223
215
|
* @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
|
|
224
216
|
* @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
|
|
225
217
|
* @param {number} radiusX the ellipse's major-axis radius. Must be non-negative.
|
|
@@ -278,8 +270,7 @@ class Path2D {
|
|
|
278
270
|
/**
|
|
279
271
|
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|
|
280
272
|
* @name rect
|
|
281
|
-
* @memberof Path2D
|
|
282
|
-
* @function
|
|
273
|
+
* @memberof Path2D
|
|
283
274
|
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
284
275
|
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
285
276
|
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|
|
@@ -296,8 +287,7 @@ class Path2D {
|
|
|
296
287
|
/**
|
|
297
288
|
* adds an rounded rectangle to the current path.
|
|
298
289
|
* @name roundRect
|
|
299
|
-
* @memberof Path2D
|
|
300
|
-
* @function
|
|
290
|
+
* @memberof Path2D
|
|
301
291
|
* @param {number} x the x-axis coordinate of the rectangle's starting point.
|
|
302
292
|
* @param {number} y the y-axis coordinate of the rectangle's starting point.
|
|
303
293
|
* @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
|