melonjs 10.2.2 → 10.4.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 (95) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +2907 -3383
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3620 -4528
  5. package/dist/melonjs.module.js +3210 -3331
  6. package/package.json +19 -19
  7. package/src/audio/audio.js +30 -31
  8. package/src/camera/camera2d.js +47 -58
  9. package/src/entity/draggable.js +11 -21
  10. package/src/entity/droptarget.js +12 -22
  11. package/src/entity/entity.js +32 -38
  12. package/src/game.js +21 -22
  13. package/src/{shapes → geometries}/ellipse.js +40 -47
  14. package/src/{shapes → geometries}/line.js +9 -12
  15. package/src/{shapes → geometries}/poly.js +100 -53
  16. package/src/{shapes → geometries}/rectangle.js +42 -45
  17. package/src/index.js +9 -20
  18. package/src/input/gamepad.js +11 -10
  19. package/src/input/input.js +2 -3
  20. package/src/input/keyboard.js +113 -113
  21. package/src/input/pointer.js +61 -29
  22. package/src/input/pointerevent.js +92 -29
  23. package/src/lang/deprecated.js +44 -14
  24. package/src/level/level.js +23 -24
  25. package/src/level/tiled/TMXGroup.js +7 -9
  26. package/src/level/tiled/TMXLayer.js +30 -33
  27. package/src/level/tiled/TMXObject.js +59 -53
  28. package/src/level/tiled/TMXTile.js +18 -19
  29. package/src/level/tiled/TMXTileMap.js +38 -46
  30. package/src/level/tiled/TMXTileset.js +12 -16
  31. package/src/level/tiled/TMXTilesetGroup.js +9 -10
  32. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
  33. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
  34. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
  35. package/src/level/tiled/renderer/TMXRenderer.js +24 -26
  36. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
  37. package/src/loader/loader.js +17 -16
  38. package/src/loader/loadingscreen.js +8 -10
  39. package/src/math/color.js +47 -67
  40. package/src/math/math.js +15 -16
  41. package/src/math/matrix2.js +53 -59
  42. package/src/math/matrix3.js +56 -63
  43. package/src/math/observable_vector2.js +87 -77
  44. package/src/math/observable_vector3.js +97 -80
  45. package/src/math/vector2.js +107 -97
  46. package/src/math/vector3.js +116 -100
  47. package/src/particles/emitter.js +66 -76
  48. package/src/particles/particle.js +4 -6
  49. package/src/particles/particlecontainer.js +2 -4
  50. package/src/physics/body.js +47 -146
  51. package/src/physics/bounds.js +48 -50
  52. package/src/physics/collision.js +13 -14
  53. package/src/physics/detector.js +14 -14
  54. package/src/physics/quadtree.js +18 -21
  55. package/src/physics/sat.js +30 -30
  56. package/src/physics/world.js +24 -29
  57. package/src/plugin/plugin.js +11 -15
  58. package/src/renderable/GUI.js +41 -47
  59. package/src/renderable/collectable.js +5 -10
  60. package/src/renderable/colorlayer.js +10 -15
  61. package/src/renderable/container.js +87 -73
  62. package/src/renderable/imagelayer.js +25 -32
  63. package/src/renderable/nineslicesprite.js +41 -42
  64. package/src/renderable/renderable.js +113 -124
  65. package/src/renderable/sprite.js +62 -69
  66. package/src/renderable/trigger.js +26 -32
  67. package/src/state/stage.js +13 -18
  68. package/src/state/state.js +26 -27
  69. package/src/system/device.js +76 -133
  70. package/src/system/event.js +81 -70
  71. package/src/system/pooling.js +11 -12
  72. package/src/system/save.js +3 -4
  73. package/src/system/timer.js +19 -20
  74. package/src/text/bitmaptext.js +57 -55
  75. package/src/text/bitmaptextdata.js +10 -11
  76. package/src/text/glyph.js +3 -0
  77. package/src/text/text.js +49 -55
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +1 -1
  80. package/src/tweens/tween.js +44 -46
  81. package/src/utils/agent.js +3 -4
  82. package/src/utils/array.js +4 -5
  83. package/src/utils/file.js +3 -4
  84. package/src/utils/function.js +4 -5
  85. package/src/utils/string.js +7 -9
  86. package/src/utils/utils.js +4 -5
  87. package/src/video/canvas/canvas_renderer.js +60 -62
  88. package/src/video/renderer.js +53 -58
  89. package/src/video/texture.js +98 -112
  90. package/src/video/texture_cache.js +4 -6
  91. package/src/video/video.js +16 -17
  92. package/src/video/webgl/buffer/vertex.js +2 -2
  93. package/src/video/webgl/glshader.js +37 -39
  94. package/src/video/webgl/webgl_compositor.js +128 -110
  95. package/src/video/webgl/webgl_renderer.js +126 -106
@@ -1,7 +1,7 @@
1
1
  import Color from "./../../math/color.js";
2
2
  import Renderer from "./../renderer.js";
3
3
  import TextureCache from "./../texture_cache.js";
4
- import Ellipse from "./../../shapes/ellipse.js";
4
+ import Ellipse from "./../../geometries/ellipse.js";
5
5
  import { createCanvas } from "./../video.js";
6
6
 
7
7
 
@@ -9,24 +9,22 @@ import { createCanvas } from "./../video.js";
9
9
  /**
10
10
  * @classdesc
11
11
  * a canvas renderer object
12
- * @class CanvasRenderer
13
- * @extends me.Renderer
14
- * @memberOf me
15
- * @constructor
16
- * @param {object} options The renderer parameters
17
- * @param {number} options.width The width of the canvas without scaling
18
- * @param {number} options.height The height of the canvas without scaling
19
- * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
20
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
21
- * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
22
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
23
- * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
24
- * @param {boolean} [options.textureSeamFix=true] enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
25
- * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
26
- * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
12
+ * @augments Renderer
27
13
  */
28
14
  class CanvasRenderer extends Renderer {
29
-
15
+ /**
16
+ * @param {object} options The renderer parameters
17
+ * @param {number} options.width The width of the canvas without scaling
18
+ * @param {number} options.height The height of the canvas without scaling
19
+ * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
20
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
21
+ * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
22
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
23
+ * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
24
+ * @param {boolean} [options.textureSeamFix=true] enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
25
+ * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
26
+ * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
27
+ */
30
28
  constructor(options) {
31
29
  // parent constructor
32
30
  super(options);
@@ -63,7 +61,7 @@ class CanvasRenderer extends Renderer {
63
61
  /**
64
62
  * Reset context state
65
63
  * @name reset
66
- * @memberOf me.CanvasRenderer.prototype
64
+ * @memberof CanvasRenderer.prototype
67
65
  * @function
68
66
  */
69
67
  reset() {
@@ -74,7 +72,7 @@ class CanvasRenderer extends Renderer {
74
72
  /**
75
73
  * Reset the canvas transform to identity
76
74
  * @name resetTransform
77
- * @memberOf me.CanvasRenderer.prototype
75
+ * @memberof CanvasRenderer.prototype
78
76
  * @function
79
77
  */
80
78
  resetTransform() {
@@ -84,7 +82,7 @@ class CanvasRenderer extends Renderer {
84
82
  /**
85
83
  * Set a blend mode for the given context
86
84
  * @name setBlendMode
87
- * @memberOf me.CanvasRenderer.prototype
85
+ * @memberof CanvasRenderer.prototype
88
86
  * @function
89
87
  * @param {string} [mode="normal"] blend mode : "normal", "multiply"
90
88
  * @param {CanvasRenderingContext2D} [context]
@@ -113,7 +111,7 @@ class CanvasRenderer extends Renderer {
113
111
  /**
114
112
  * prepare the framebuffer for drawing a new frame
115
113
  * @name clear
116
- * @memberOf me.CanvasRenderer.prototype
114
+ * @memberof CanvasRenderer.prototype
117
115
  * @function
118
116
  */
119
117
  clear() {
@@ -125,7 +123,7 @@ class CanvasRenderer extends Renderer {
125
123
  /**
126
124
  * render the main framebuffer on screen
127
125
  * @name flush
128
- * @memberOf me.CanvasRenderer.prototype
126
+ * @memberof CanvasRenderer.prototype
129
127
  * @function
130
128
  */
131
129
  flush() {
@@ -137,12 +135,12 @@ class CanvasRenderer extends Renderer {
137
135
  /**
138
136
  * Clears the main framebuffer with the given color
139
137
  * @name clearColor
140
- * @memberOf me.CanvasRenderer.prototype
138
+ * @memberof CanvasRenderer.prototype
141
139
  * @function
142
- * @param {me.Color|string} color CSS color.
140
+ * @param {Color|string} [color="#000000"] CSS color.
143
141
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
144
142
  */
145
- clearColor(color, opaque) {
143
+ clearColor(color = "#000000", opaque) {
146
144
  this.save();
147
145
  this.resetTransform();
148
146
  this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over";
@@ -154,7 +152,7 @@ class CanvasRenderer extends Renderer {
154
152
  /**
155
153
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
156
154
  * @name clearRect
157
- * @memberOf me.CanvasRenderer.prototype
155
+ * @memberof CanvasRenderer.prototype
158
156
  * @function
159
157
  * @param {number} x x axis of the coordinate for the rectangle starting point.
160
158
  * @param {number} y y axis of the coordinate for the rectangle starting point.
@@ -168,12 +166,12 @@ class CanvasRenderer extends Renderer {
168
166
  /**
169
167
  * Create a pattern with the specified repetition
170
168
  * @name createPattern
171
- * @memberOf me.CanvasRenderer.prototype
169
+ * @memberof CanvasRenderer.prototype
172
170
  * @function
173
171
  * @param {Image} image Source image
174
172
  * @param {string} repeat Define how the pattern should be repeated
175
173
  * @returns {CanvasPattern}
176
- * @see me.ImageLayer#repeat
174
+ * @see ImageLayer#repeat
177
175
  * @example
178
176
  * var tileable = renderer.createPattern(image, "repeat");
179
177
  * var horizontal = renderer.createPattern(image, "repeat-x");
@@ -187,7 +185,7 @@ class CanvasRenderer extends Renderer {
187
185
  /**
188
186
  * Draw an image onto the main using the canvas api
189
187
  * @name drawImage
190
- * @memberOf me.CanvasRenderer.prototype
188
+ * @memberof CanvasRenderer.prototype
191
189
  * @function
192
190
  * @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
193
191
  * @param {number} sx The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
@@ -250,14 +248,14 @@ class CanvasRenderer extends Renderer {
250
248
  /**
251
249
  * Draw a pattern within the given rectangle.
252
250
  * @name drawPattern
253
- * @memberOf me.CanvasRenderer.prototype
251
+ * @memberof CanvasRenderer.prototype
254
252
  * @function
255
253
  * @param {CanvasPattern} pattern Pattern object
256
254
  * @param {number} x
257
255
  * @param {number} y
258
256
  * @param {number} width
259
257
  * @param {number} height
260
- * @see me.CanvasRenderer#createPattern
258
+ * @see CanvasRenderer#createPattern
261
259
  */
262
260
  drawPattern(pattern, x, y, width, height) {
263
261
  if (this.backBufferContext2D.globalAlpha < 1 / 255) {
@@ -273,7 +271,7 @@ class CanvasRenderer extends Renderer {
273
271
  /**
274
272
  * Stroke an arc at the specified coordinates with given radius, start and end points
275
273
  * @name strokeArc
276
- * @memberOf me.CanvasRenderer.prototype
274
+ * @memberof CanvasRenderer.prototype
277
275
  * @function
278
276
  * @param {number} x arc center point x-axis
279
277
  * @param {number} y arc center point y-axis
@@ -300,7 +298,7 @@ class CanvasRenderer extends Renderer {
300
298
  /**
301
299
  * Fill an arc at the specified coordinates with given radius, start and end points
302
300
  * @name fillArc
303
- * @memberOf me.CanvasRenderer.prototype
301
+ * @memberof CanvasRenderer.prototype
304
302
  * @function
305
303
  * @param {number} x arc center point x-axis
306
304
  * @param {number} y arc center point y-axis
@@ -316,7 +314,7 @@ class CanvasRenderer extends Renderer {
316
314
  /**
317
315
  * Stroke an ellipse at the specified coordinates with given radius
318
316
  * @name strokeEllipse
319
- * @memberOf me.CanvasRenderer.prototype
317
+ * @memberof CanvasRenderer.prototype
320
318
  * @function
321
319
  * @param {number} x ellipse center point x-axis
322
320
  * @param {number} y ellipse center point y-axis
@@ -359,7 +357,7 @@ class CanvasRenderer extends Renderer {
359
357
  /**
360
358
  * Fill an ellipse at the specified coordinates with given radius
361
359
  * @name fillEllipse
362
- * @memberOf me.CanvasRenderer.prototype
360
+ * @memberof CanvasRenderer.prototype
363
361
  * @function
364
362
  * @param {number} x ellipse center point x-axis
365
363
  * @param {number} y ellipse center point y-axis
@@ -373,7 +371,7 @@ class CanvasRenderer extends Renderer {
373
371
  /**
374
372
  * Stroke a line of the given two points
375
373
  * @name strokeLine
376
- * @memberOf me.CanvasRenderer.prototype
374
+ * @memberof CanvasRenderer.prototype
377
375
  * @function
378
376
  * @param {number} startX the start x coordinate
379
377
  * @param {number} startY the start y coordinate
@@ -397,7 +395,7 @@ class CanvasRenderer extends Renderer {
397
395
  /**
398
396
  * Fill a line of the given two points
399
397
  * @name fillLine
400
- * @memberOf me.CanvasRenderer.prototype
398
+ * @memberof CanvasRenderer.prototype
401
399
  * @function
402
400
  * @param {number} startX the start x coordinate
403
401
  * @param {number} startY the start y coordinate
@@ -411,9 +409,9 @@ class CanvasRenderer extends Renderer {
411
409
  /**
412
410
  * Stroke the given me.Polygon on the screen
413
411
  * @name strokePolygon
414
- * @memberOf me.CanvasRenderer.prototype
412
+ * @memberof CanvasRenderer.prototype
415
413
  * @function
416
- * @param {me.Polygon} poly the shape to draw
414
+ * @param {Polygon} poly the shape to draw
417
415
  * @param {boolean} [fill=false] also fill the shape with the current color if true
418
416
  */
419
417
  strokePolygon(poly, fill = false) {
@@ -441,9 +439,9 @@ class CanvasRenderer extends Renderer {
441
439
  /**
442
440
  * Fill the given me.Polygon on the screen
443
441
  * @name fillPolygon
444
- * @memberOf me.CanvasRenderer.prototype
442
+ * @memberof CanvasRenderer.prototype
445
443
  * @function
446
- * @param {me.Polygon} poly the shape to draw
444
+ * @param {Polygon} poly the shape to draw
447
445
  */
448
446
  fillPolygon(poly) {
449
447
  this.strokePolygon(poly, true);
@@ -452,7 +450,7 @@ class CanvasRenderer extends Renderer {
452
450
  /**
453
451
  * Stroke a rectangle at the specified coordinates
454
452
  * @name strokeRect
455
- * @memberOf me.CanvasRenderer.prototype
453
+ * @memberof CanvasRenderer.prototype
456
454
  * @function
457
455
  * @param {number} x
458
456
  * @param {number} y
@@ -475,7 +473,7 @@ class CanvasRenderer extends Renderer {
475
473
  /**
476
474
  * Draw a filled rectangle at the specified coordinates
477
475
  * @name fillRect
478
- * @memberOf me.CanvasRenderer.prototype
476
+ * @memberof CanvasRenderer.prototype
479
477
  * @function
480
478
  * @param {number} x
481
479
  * @param {number} y
@@ -494,7 +492,7 @@ class CanvasRenderer extends Renderer {
494
492
  /**
495
493
  * return a reference to the system 2d Context
496
494
  * @name getContext
497
- * @memberOf me.CanvasRenderer.prototype
495
+ * @memberof CanvasRenderer.prototype
498
496
  * @function
499
497
  * @returns {CanvasRenderingContext2D}
500
498
  */
@@ -514,7 +512,7 @@ class CanvasRenderer extends Renderer {
514
512
  /**
515
513
  * save the canvas context
516
514
  * @name save
517
- * @memberOf me.CanvasRenderer.prototype
515
+ * @memberof CanvasRenderer.prototype
518
516
  * @function
519
517
  */
520
518
  save() {
@@ -524,7 +522,7 @@ class CanvasRenderer extends Renderer {
524
522
  /**
525
523
  * restores the canvas context
526
524
  * @name restore
527
- * @memberOf me.CanvasRenderer.prototype
525
+ * @memberof CanvasRenderer.prototype
528
526
  * @function
529
527
  */
530
528
  restore() {
@@ -539,7 +537,7 @@ class CanvasRenderer extends Renderer {
539
537
  /**
540
538
  * rotates the canvas context
541
539
  * @name rotate
542
- * @memberOf me.CanvasRenderer.prototype
540
+ * @memberof CanvasRenderer.prototype
543
541
  * @function
544
542
  * @param {number} angle in radians
545
543
  */
@@ -550,7 +548,7 @@ class CanvasRenderer extends Renderer {
550
548
  /**
551
549
  * scales the canvas context
552
550
  * @name scale
553
- * @memberOf me.CanvasRenderer.prototype
551
+ * @memberof CanvasRenderer.prototype
554
552
  * @function
555
553
  * @param {number} x
556
554
  * @param {number} y
@@ -563,9 +561,9 @@ class CanvasRenderer extends Renderer {
563
561
  * Set the current fill & stroke style color.
564
562
  * By default, or upon reset, the value is set to #000000.
565
563
  * @name setColor
566
- * @memberOf me.CanvasRenderer.prototype
564
+ * @memberof CanvasRenderer.prototype
567
565
  * @function
568
- * @param {me.Color|string} color css color value
566
+ * @param {Color|string} color css color value
569
567
  */
570
568
  setColor(color) {
571
569
  this.backBufferContext2D.strokeStyle =
@@ -579,7 +577,7 @@ class CanvasRenderer extends Renderer {
579
577
  /**
580
578
  * Set the global alpha on the canvas context
581
579
  * @name setGlobalAlpha
582
- * @memberOf me.CanvasRenderer.prototype
580
+ * @memberof CanvasRenderer.prototype
583
581
  * @function
584
582
  * @param {number} alpha 0.0 to 1.0 values accepted.
585
583
  */
@@ -590,7 +588,7 @@ class CanvasRenderer extends Renderer {
590
588
  /**
591
589
  * Set the line width on the context
592
590
  * @name setLineWidth
593
- * @memberOf me.CanvasRenderer.prototype
591
+ * @memberof CanvasRenderer.prototype
594
592
  * @function
595
593
  * @param {number} width Line width
596
594
  */
@@ -602,9 +600,9 @@ class CanvasRenderer extends Renderer {
602
600
  * Reset (overrides) the renderer transformation matrix to the
603
601
  * identity one, and then apply the given transformation matrix.
604
602
  * @name setTransform
605
- * @memberOf me.CanvasRenderer.prototype
603
+ * @memberof CanvasRenderer.prototype
606
604
  * @function
607
- * @param {me.Matrix2d} mat2d Matrix to transform by
605
+ * @param {Matrix2d} mat2d Matrix to transform by
608
606
  */
609
607
  setTransform(mat2d) {
610
608
  this.resetTransform();
@@ -614,9 +612,9 @@ class CanvasRenderer extends Renderer {
614
612
  /**
615
613
  * Multiply given matrix into the renderer tranformation matrix
616
614
  * @name transform
617
- * @memberOf me.CanvasRenderer.prototype
615
+ * @memberof CanvasRenderer.prototype
618
616
  * @function
619
- * @param {me.Matrix2d} mat2d Matrix to transform by
617
+ * @param {Matrix2d} mat2d Matrix to transform by
620
618
  */
621
619
  transform(mat2d) {
622
620
  var m = mat2d.toArray(),
@@ -638,7 +636,7 @@ class CanvasRenderer extends Renderer {
638
636
  /**
639
637
  * Translates the context to the given position
640
638
  * @name translate
641
- * @memberOf me.CanvasRenderer.prototype
639
+ * @memberof CanvasRenderer.prototype
642
640
  * @function
643
641
  * @param {number} x
644
642
  * @param {number} y
@@ -658,7 +656,7 @@ class CanvasRenderer extends Renderer {
658
656
  * and restore it (with the restore() method) any time in the future.
659
657
  * (<u>this is an experimental feature !</u>)
660
658
  * @name clipRect
661
- * @memberOf me.CanvasRenderer.prototype
659
+ * @memberof CanvasRenderer.prototype
662
660
  * @function
663
661
  * @param {number} x
664
662
  * @param {number} y
@@ -691,9 +689,9 @@ class CanvasRenderer extends Renderer {
691
689
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
692
690
  * Mask are not preserved through renderer context save and restore.
693
691
  * @name setMask
694
- * @memberOf me.CanvasRenderer.prototype
692
+ * @memberof CanvasRenderer.prototype
695
693
  * @function
696
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} [mask] the shape defining the mask to be applied
694
+ * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
697
695
  */
698
696
  setMask(mask) {
699
697
  var context = this.backBufferContext2D;
@@ -739,8 +737,8 @@ class CanvasRenderer extends Renderer {
739
737
  /**
740
738
  * disable (remove) the rendering mask set through setMask.
741
739
  * @name clearMask
742
- * @see me.CanvasRenderer#setMask
743
- * @memberOf me.CanvasRenderer.prototype
740
+ * @see CanvasRenderer#setMask
741
+ * @memberof CanvasRenderer.prototype
744
742
  * @function
745
743
  */
746
744
  clearMask() {
@@ -4,41 +4,38 @@ import { createCanvas, renderer } from "./video.js";
4
4
  import * as event from "./../system/event.js";
5
5
  import device from "./../system/device.js";
6
6
  import { setPrefixed } from "./../utils/agent.js";
7
- import { Texture } from "./texture.js";
8
- import Rect from "./../shapes/rectangle.js";
9
- import Ellipse from "./../shapes/ellipse.js";
10
- import Polygon from "./../shapes/poly.js";
11
- import Line from "./../shapes/line.js";
7
+ import Rect from "./../geometries/rectangle.js";
8
+ import Ellipse from "./../geometries/ellipse.js";
9
+ import Polygon from "./../geometries/poly.js";
10
+ import Line from "./../geometries/line.js";
12
11
  import Bounds from "./../physics/bounds.js";
13
12
 
14
13
  /**
15
14
  * @classdesc
16
15
  * a base renderer object
17
- * @class Renderer
18
- * @memberOf me
19
- * @constructor
20
- * @param {object} options The renderer parameters
21
- * @param {number} options.width The width of the canvas without scaling
22
- * @param {number} options.height The height of the canvas without scaling
23
- * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
24
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
25
- * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
26
- * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
27
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
28
- * @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
29
- * @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
30
- * @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
31
- * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
32
- * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
33
16
  */
34
17
  class Renderer {
35
-
18
+ /**
19
+ * @param {object} options The renderer parameters
20
+ * @param {number} options.width The width of the canvas without scaling
21
+ * @param {number} options.height The height of the canvas without scaling
22
+ * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
23
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
24
+ * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
25
+ * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
26
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
27
+ * @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
28
+ * @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
29
+ * @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
30
+ * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
31
+ * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
32
+ */
36
33
  constructor(options) {
37
34
  /**
38
35
  * The given constructor options
39
36
  * @public
40
37
  * @name settings
41
- * @memberOf me.Renderer#
38
+ * @memberof Renderer#
42
39
  * @enum {object}
43
40
  */
44
41
  this.settings = options;
@@ -46,7 +43,7 @@ class Renderer {
46
43
  /**
47
44
  * true if the current rendering context is valid
48
45
  * @name isContextValid
49
- * @memberOf me.Renderer
46
+ * @memberof Renderer
50
47
  * @default true
51
48
  * type {boolean}
52
49
  */
@@ -91,8 +88,6 @@ class Renderer {
91
88
  // default uvOffset
92
89
  this.uvOffset = 0;
93
90
 
94
- this.Texture = Texture;
95
-
96
91
  // reset the instantiated renderer on game reset
97
92
  event.on(event.GAME_RESET, () => {
98
93
  renderer.reset();
@@ -104,7 +99,7 @@ class Renderer {
104
99
  /**
105
100
  * prepare the framebuffer for drawing a new frame
106
101
  * @name clear
107
- * @memberOf me.Renderer.prototype
102
+ * @memberof Renderer.prototype
108
103
  * @function
109
104
  */
110
105
  clear() {}
@@ -112,7 +107,7 @@ class Renderer {
112
107
  /**
113
108
  * Reset context state
114
109
  * @name reset
115
- * @memberOf me.Renderer.prototype
110
+ * @memberof Renderer.prototype
116
111
  * @function
117
112
  */
118
113
  reset() {
@@ -130,7 +125,7 @@ class Renderer {
130
125
  /**
131
126
  * return a reference to the system canvas
132
127
  * @name getCanvas
133
- * @memberOf me.Renderer.prototype
128
+ * @memberof Renderer.prototype
134
129
  * @function
135
130
  * @returns {HTMLCanvasElement}
136
131
  */
@@ -141,7 +136,7 @@ class Renderer {
141
136
  /**
142
137
  * return a reference to the screen canvas
143
138
  * @name getScreenCanvas
144
- * @memberOf me.Renderer.prototype
139
+ * @memberof Renderer.prototype
145
140
  * @function
146
141
  * @returns {HTMLCanvasElement}
147
142
  */
@@ -153,7 +148,7 @@ class Renderer {
153
148
  * return a reference to the screen canvas corresponding 2d Context<br>
154
149
  * (will return buffered context if double buffering is enabled, or a reference to the Screen Context)
155
150
  * @name getScreenContext
156
- * @memberOf me.Renderer.prototype
151
+ * @memberof Renderer.prototype
157
152
  * @function
158
153
  * @returns {CanvasRenderingContext2D}
159
154
  */
@@ -164,7 +159,7 @@ class Renderer {
164
159
  /**
165
160
  * returns the current blend mode for this renderer
166
161
  * @name getBlendMode
167
- * @memberOf me.Renderer.prototype
162
+ * @memberof Renderer.prototype
168
163
  * @function
169
164
  * @returns {string} blend mode
170
165
  */
@@ -176,7 +171,7 @@ class Renderer {
176
171
  * Returns the 2D Context object of the given Canvas<br>
177
172
  * Also configures anti-aliasing and blend modes based on constructor options.
178
173
  * @name getContext2d
179
- * @memberOf me.Renderer.prototype
174
+ * @memberof Renderer.prototype
180
175
  * @function
181
176
  * @param {HTMLCanvasElement} canvas
182
177
  * @param {boolean} [transparent=true] use false to disable transparency
@@ -214,7 +209,7 @@ class Renderer {
214
209
  /**
215
210
  * return the width of the system Canvas
216
211
  * @name getWidth
217
- * @memberOf me.Renderer.prototype
212
+ * @memberof Renderer.prototype
218
213
  * @function
219
214
  * @returns {number}
220
215
  */
@@ -225,7 +220,7 @@ class Renderer {
225
220
  /**
226
221
  * return the height of the system Canvas
227
222
  * @name getHeight
228
- * @memberOf me.Renderer.prototype
223
+ * @memberof Renderer.prototype
229
224
  * @function
230
225
  * @returns {number} height of the system Canvas
231
226
  */
@@ -236,9 +231,9 @@ class Renderer {
236
231
  /**
237
232
  * get the current fill & stroke style color.
238
233
  * @name getColor
239
- * @memberOf me.Renderer.prototype
234
+ * @memberof Renderer.prototype
240
235
  * @function
241
- * @returns {me.Color} current global color
236
+ * @returns {Color} current global color
242
237
  */
243
238
  getColor() {
244
239
  return this.currentColor;
@@ -247,7 +242,7 @@ class Renderer {
247
242
  /**
248
243
  * return the current global alpha
249
244
  * @name globalAlpha
250
- * @memberOf me.Renderer.prototype
245
+ * @memberof Renderer.prototype
251
246
  * @function
252
247
  * @returns {number}
253
248
  */
@@ -258,9 +253,9 @@ class Renderer {
258
253
  /**
259
254
  * check if the given rect or bounds overlaps with the renderer screen coordinates
260
255
  * @name overlaps
261
- * @memberOf me.Renderer.prototype
256
+ * @memberof Renderer.prototype
262
257
  * @function
263
- * @param {me.Rect|me.Bounds} bounds
258
+ * @param {Rect|Bounds} bounds
264
259
  * @returns {boolean} true if overlaps
265
260
  */
266
261
  overlaps(bounds) {
@@ -274,7 +269,7 @@ class Renderer {
274
269
  /**
275
270
  * resizes the system canvas
276
271
  * @name resize
277
- * @memberOf me.Renderer.prototype
272
+ * @memberof Renderer.prototype
278
273
  * @function
279
274
  * @param {number} width new width of the canvas
280
275
  * @param {number} height new height of the canvas
@@ -295,7 +290,7 @@ class Renderer {
295
290
  /**
296
291
  * enable/disable image smoothing (scaling interpolation) for the given context
297
292
  * @name setAntiAlias
298
- * @memberOf me.Renderer.prototype
293
+ * @memberof Renderer.prototype
299
294
  * @function
300
295
  * @param {CanvasRenderingContext2D} context
301
296
  * @param {boolean} [enable=false]
@@ -325,9 +320,9 @@ class Renderer {
325
320
  /**
326
321
  * set/change the current projection matrix (WebGL only)
327
322
  * @name setProjection
328
- * @memberOf me.Renderer.prototype
323
+ * @memberof Renderer.prototype
329
324
  * @function
330
- * @param {me.Matrix3d} matrix
325
+ * @param {Matrix3d} matrix
331
326
  */
332
327
  setProjection(matrix) {
333
328
  this.projectionMatrix.copy(matrix);
@@ -336,9 +331,9 @@ class Renderer {
336
331
  /**
337
332
  * stroke the given shape
338
333
  * @name stroke
339
- * @memberOf me.Renderer.prototype
334
+ * @memberof Renderer.prototype
340
335
  * @function
341
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} shape a shape object to stroke
336
+ * @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
342
337
  * @param {boolean} [fill=false] fill the shape with the current color if true
343
338
  */
344
339
  stroke(shape, fill) {
@@ -360,10 +355,10 @@ class Renderer {
360
355
  /**
361
356
  * tint the given image or canvas using the given color
362
357
  * @name tint
363
- * @memberOf me.Renderer.prototype
358
+ * @memberof Renderer.prototype
364
359
  * @function
365
360
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
366
- * @param {me.Color|string} color the color that will be used to tint the image
361
+ * @param {Color|string} color the color that will be used to tint the image
367
362
  * @param {string} [mode="multiply"] the composition mode used to tint the image
368
363
  * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
369
364
  */
@@ -389,9 +384,9 @@ class Renderer {
389
384
  /**
390
385
  * fill the given shape
391
386
  * @name fill
392
- * @memberOf me.Renderer.prototype
387
+ * @memberof Renderer.prototype
393
388
  * @function
394
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} shape a shape object to fill
389
+ * @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
395
390
  */
396
391
  fill(shape) {
397
392
  this.stroke(shape, true);
@@ -402,9 +397,9 @@ class Renderer {
402
397
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
403
398
  * Mask are not preserved through renderer context save and restore.
404
399
  * @name setMask
405
- * @memberOf me.Renderer.prototype
400
+ * @memberof Renderer.prototype
406
401
  * @function
407
- * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} [mask] the shape defining the mask to be applied
402
+ * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
408
403
  */
409
404
  // eslint-disable-next-line no-unused-vars
410
405
  setMask(mask) {}
@@ -412,8 +407,8 @@ class Renderer {
412
407
  /**
413
408
  * disable (remove) the rendering mask set through setMask.
414
409
  * @name clearMask
415
- * @see me.Renderer#setMask
416
- * @memberOf me.Renderer.prototype
410
+ * @see Renderer#setMask
411
+ * @memberof Renderer.prototype
417
412
  * @function
418
413
  */
419
414
  clearMask() {}
@@ -421,9 +416,9 @@ class Renderer {
421
416
  /**
422
417
  * set a coloring tint for sprite based renderables
423
418
  * @name setTint
424
- * @memberOf me.Renderer.prototype
419
+ * @memberof Renderer.prototype
425
420
  * @function
426
- * @param {me.Color} tint the tint color
421
+ * @param {Color} tint the tint color
427
422
  * @param {number} [alpha] an alpha value to be applied to the tint
428
423
  */
429
424
  setTint(tint, alpha = tint.alpha) {
@@ -435,8 +430,8 @@ class Renderer {
435
430
  /**
436
431
  * clear the rendering tint set through setTint.
437
432
  * @name clearTint
438
- * @see me.Renderer#setTint
439
- * @memberOf me.Renderer.prototype
433
+ * @see Renderer#setTint
434
+ * @memberof Renderer.prototype
440
435
  * @function
441
436
  */
442
437
  clearTint() {