melonjs 10.2.0 → 10.3.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 +1 -1
  2. package/dist/melonjs.js +4435 -4283
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3348 -3833
  5. package/dist/melonjs.module.js +4025 -3920
  6. package/package.json +13 -14
  7. package/src/audio/audio.js +45 -45
  8. package/src/camera/camera2d.js +78 -101
  9. package/src/entity/draggable.js +21 -29
  10. package/src/entity/droptarget.js +24 -31
  11. package/src/entity/entity.js +34 -38
  12. package/src/game.js +8 -8
  13. package/src/{shapes → geometries}/ellipse.js +46 -46
  14. package/src/{shapes → geometries}/line.js +14 -14
  15. package/src/{shapes → geometries}/poly.js +103 -54
  16. package/src/{shapes → geometries}/rectangle.js +73 -120
  17. package/src/index.js +18 -19
  18. package/src/input/gamepad.js +20 -20
  19. package/src/input/input.js +3 -3
  20. package/src/input/keyboard.js +122 -124
  21. package/src/input/pointer.js +102 -62
  22. package/src/input/pointerevent.js +97 -42
  23. package/src/lang/deprecated.js +29 -18
  24. package/src/level/level.js +34 -26
  25. package/src/level/tiled/TMXGroup.js +12 -13
  26. package/src/level/tiled/TMXLayer.js +41 -42
  27. package/src/level/tiled/TMXObject.js +76 -70
  28. package/src/level/tiled/TMXTile.js +13 -15
  29. package/src/level/tiled/TMXTileMap.js +26 -25
  30. package/src/level/tiled/TMXTileset.js +14 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +5 -6
  32. package/src/level/tiled/TMXUtils.js +13 -11
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
  35. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
  36. package/src/level/tiled/renderer/TMXRenderer.js +18 -19
  37. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
  38. package/src/loader/loader.js +46 -40
  39. package/src/loader/loadingscreen.js +7 -7
  40. package/src/math/color.js +68 -88
  41. package/src/math/math.js +33 -33
  42. package/src/math/matrix2.js +70 -71
  43. package/src/math/matrix3.js +90 -91
  44. package/src/math/observable_vector2.js +91 -92
  45. package/src/math/observable_vector3.js +110 -106
  46. package/src/math/vector2.js +116 -104
  47. package/src/math/vector3.js +129 -110
  48. package/src/particles/emitter.js +116 -126
  49. package/src/particles/particle.js +4 -5
  50. package/src/particles/particlecontainer.js +2 -3
  51. package/src/physics/body.js +82 -83
  52. package/src/physics/bounds.js +64 -66
  53. package/src/physics/collision.js +21 -22
  54. package/src/physics/detector.js +13 -13
  55. package/src/physics/quadtree.js +26 -25
  56. package/src/physics/sat.js +21 -21
  57. package/src/physics/world.js +23 -22
  58. package/src/plugin/plugin.js +12 -13
  59. package/src/renderable/GUI.js +20 -26
  60. package/src/renderable/collectable.js +6 -7
  61. package/src/renderable/colorlayer.js +11 -12
  62. package/src/renderable/container.js +98 -81
  63. package/src/renderable/imagelayer.js +33 -35
  64. package/src/renderable/nineslicesprite.js +15 -16
  65. package/src/renderable/renderable.js +112 -111
  66. package/src/renderable/sprite.js +71 -58
  67. package/src/renderable/trigger.js +17 -19
  68. package/src/state/stage.js +14 -15
  69. package/src/state/state.js +78 -78
  70. package/src/system/device.js +137 -180
  71. package/src/system/event.js +116 -104
  72. package/src/system/pooling.js +15 -15
  73. package/src/system/save.js +9 -6
  74. package/src/system/timer.js +33 -33
  75. package/src/text/bitmaptext.js +39 -46
  76. package/src/text/bitmaptextdata.js +14 -15
  77. package/src/text/text.js +55 -58
  78. package/src/tweens/easing.js +5 -5
  79. package/src/tweens/interpolation.js +5 -5
  80. package/src/tweens/tween.js +49 -40
  81. package/src/utils/agent.js +12 -11
  82. package/src/utils/array.js +8 -8
  83. package/src/utils/file.js +7 -7
  84. package/src/utils/function.js +8 -8
  85. package/src/utils/string.js +19 -19
  86. package/src/utils/utils.js +23 -23
  87. package/src/video/canvas/canvas_renderer.js +127 -128
  88. package/src/video/renderer.js +69 -69
  89. package/src/video/texture.js +80 -82
  90. package/src/video/texture_cache.js +2 -4
  91. package/src/video/video.js +38 -38
  92. package/src/video/webgl/buffer/vertex.js +11 -3
  93. package/src/video/webgl/glshader.js +31 -32
  94. package/src/video/webgl/webgl_compositor.js +145 -127
  95. package/src/video/webgl/webgl_renderer.js +196 -175
@@ -15,22 +15,21 @@ import { isPowerOfTwo, nextPowerOfTwo, TAU } from "./../../math/math.js";
15
15
  * @classdesc
16
16
  * a WebGL renderer object
17
17
  * @class WebGLRenderer
18
- * @extends me.Renderer
19
- * @memberOf me
20
- * @constructor
21
- * @param {Object} options The renderer parameters
22
- * @param {Number} options.width The width of the canvas without scaling
23
- * @param {Number} options.height The height of the canvas without scaling
18
+ * @augments me.Renderer
19
+ * @memberof me
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
24
23
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
25
- * @param {Boolean} [options.doubleBuffering=false] Whether to enable double buffering
26
- * @param {Boolean} [options.antiAlias=false] Whether to enable anti-aliasing
27
- * @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.
28
- * @param {Boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
29
- * @param {Boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
30
- * @param {Boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
31
- * @param {String} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
32
- * @param {Number} [options.zoomX=width] The actual width of the canvas with scaling applied
33
- * @param {Number} [options.zoomY=height] The actual height of the canvas with scaling applied
24
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
25
+ * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
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.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
29
+ * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
30
+ * @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
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
34
33
  * @param {me.WebGLCompositor} [options.compositor] A class that implements the compositor API
35
34
  */
36
35
  class WebGLRenderer extends Renderer {
@@ -43,8 +42,8 @@ class WebGLRenderer extends Renderer {
43
42
  /**
44
43
  * The WebGL version used by this renderer (1 or 2)
45
44
  * @name WebGLVersion
46
- * @memberOf me.WebGLRenderer
47
- * @type {Number}
45
+ * @memberof me.WebGLRenderer
46
+ * @type {number}
48
47
  * @default 1
49
48
  * @readonly
50
49
  */
@@ -53,8 +52,8 @@ class WebGLRenderer extends Renderer {
53
52
  /**
54
53
  * The vendor string of the underlying graphics driver.
55
54
  * @name GPUVendor
56
- * @memberOf me.WebGLRenderer
57
- * @type {String}
55
+ * @memberof me.WebGLRenderer
56
+ * @type {string}
58
57
  * @default null
59
58
  * @readonly
60
59
  */
@@ -63,8 +62,8 @@ class WebGLRenderer extends Renderer {
63
62
  /**
64
63
  * The renderer string of the underlying graphics driver.
65
64
  * @name GPURenderer
66
- * @memberOf me.WebGLRenderer
67
- * @type {String}
65
+ * @memberof me.WebGLRenderer
66
+ * @type {string}
68
67
  * @default null
69
68
  * @readonly
70
69
  */
@@ -73,7 +72,7 @@ class WebGLRenderer extends Renderer {
73
72
  /**
74
73
  * The WebGL context
75
74
  * @name gl
76
- * @memberOf me.WebGLRenderer
75
+ * @memberof me.WebGLRenderer
77
76
  * type {WebGLRenderingContext}
78
77
  */
79
78
  this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
@@ -81,8 +80,8 @@ class WebGLRenderer extends Renderer {
81
80
  /**
82
81
  * Maximum number of texture unit supported under the current context
83
82
  * @name maxTextures
84
- * @memberOf me.WebGLRenderer
85
- * @type {Number}
83
+ * @memberof me.WebGLRenderer
84
+ * @type {number}
86
85
  * @readonly
87
86
  */
88
87
  this.maxTextures = this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS);
@@ -115,22 +114,31 @@ class WebGLRenderer extends Renderer {
115
114
  /**
116
115
  * The current transformation matrix used for transformations on the overall scene
117
116
  * @name currentTransform
118
- * @type me.Matrix2d
119
- * @memberOf me.WebGLRenderer#
117
+ * @type {me.Matrix2d}
118
+ * @memberof me.WebGLRenderer#
120
119
  */
121
120
  this.currentTransform = new Matrix2d();
122
121
 
123
122
  /**
124
123
  * The current compositor used by the renderer
125
124
  * @name currentCompositor
126
- * @type me.WebGLCompositor
127
- * @memberOf me.WebGLRenderer#
125
+ * @type {me.WebGLCompositor}
126
+ * @memberof me.WebGLRenderer#
128
127
  */
129
128
  this.currentCompositor = null;
130
129
 
131
- // Create a compositor
132
- var Compositor = this.settings.compositor || WebGLCompositor;
133
- this.setCompositor(new Compositor(this));
130
+ /**
131
+ * The list of active compositors
132
+ * @name compositors
133
+ * @type {Map}
134
+ * @memberof me.WebGLRenderer#
135
+ */
136
+ this.compositors = new Map();
137
+
138
+ // Create a default compositor
139
+ var compositor = new (this.settings.compositor || WebGLCompositor)(this);
140
+ this.compositors.set("default", compositor);
141
+ this.setCompositor(compositor);
134
142
 
135
143
 
136
144
  // default WebGL state(s)
@@ -172,17 +180,21 @@ class WebGLRenderer extends Renderer {
172
180
  /**
173
181
  * Reset context state
174
182
  * @name reset
175
- * @memberOf me.WebGLRenderer.prototype
183
+ * @memberof me.WebGLRenderer.prototype
176
184
  * @function
177
185
  */
178
186
  reset() {
179
187
  super.reset();
180
- if (this.isContextValid === false) {
181
- // on context lost/restore
182
- this.currentCompositor.init(this);
183
- } else {
184
- this.currentCompositor.reset();
185
- }
188
+
189
+ this.compositors.forEach((compositor) => {
190
+ if (this.isContextValid === false) {
191
+ // on context lost/restore
192
+ compositor.init(this);
193
+ } else {
194
+ compositor.reset();
195
+ }
196
+ });
197
+
186
198
  this.gl.disable(this.gl.SCISSOR_TEST);
187
199
  if (typeof this.fontContext2D !== "undefined" ) {
188
200
  this.createFontTexture(this.cache);
@@ -191,25 +203,37 @@ class WebGLRenderer extends Renderer {
191
203
  }
192
204
 
193
205
  /**
194
- * assign a compositor to this renderer
206
+ * set the active compositor for this renderer
195
207
  * @name setCompositor
196
208
  * @function
197
- * @param {WebGLCompositor} compositor a compositor instance
198
- * @memberOf me.WebGLRenderer.prototype
209
+ * @param {me.WebGLCompositor|string} compositor a compositor name or instance
210
+ * @memberof me.WebGLRenderer.prototype
199
211
  * @function
200
212
  */
201
- setCompositor(compositor) {
202
- if (this.currentCompositor !== null && this.currentCompositor !== compositor) {
203
- // flush the current compositor
204
- this.currentCompositor.flush();
213
+ setCompositor(compositor = "default") {
214
+
215
+ if (typeof compositor === "string") {
216
+ compositor = this.compositors.get(compositor);
217
+ }
218
+
219
+ if (typeof compositor === "undefined") {
220
+ throw new Error("Invalid WebGL Compositor");
221
+ }
222
+
223
+ if (this.currentCompositor !== compositor) {
224
+ if (this.currentCompositor !== null) {
225
+ // flush the current compositor
226
+ this.currentCompositor.flush();
227
+ }
228
+ // set given one as current
229
+ this.currentCompositor = compositor;
205
230
  }
206
- this.currentCompositor = compositor;
207
231
  }
208
232
 
209
233
  /**
210
234
  * Reset the gl transform to identity
211
235
  * @name resetTransform
212
- * @memberOf me.WebGLRenderer.prototype
236
+ * @memberof me.WebGLRenderer.prototype
213
237
  * @function
214
238
  */
215
239
  resetTransform() {
@@ -256,11 +280,11 @@ class WebGLRenderer extends Renderer {
256
280
  /**
257
281
  * Create a pattern with the specified repetition
258
282
  * @name createPattern
259
- * @memberOf me.WebGLRenderer.prototype
283
+ * @memberof me.WebGLRenderer.prototype
260
284
  * @function
261
- * @param {image} image Source image
262
- * @param {String} repeat Define how the pattern should be repeated
263
- * @return {me.Renderer.Texture}
285
+ * @param {Image} image Source image
286
+ * @param {string} repeat Define how the pattern should be repeated
287
+ * @returns {me.Renderer.Texture}
264
288
  * @see me.ImageLayer#repeat
265
289
  * @example
266
290
  * var tileable = renderer.createPattern(image, "repeat");
@@ -289,7 +313,7 @@ class WebGLRenderer extends Renderer {
289
313
  /**
290
314
  * Flush the compositor to the frame buffer
291
315
  * @name flush
292
- * @memberOf me.WebGLRenderer.prototype
316
+ * @memberof me.WebGLRenderer.prototype
293
317
  * @function
294
318
  */
295
319
  flush() {
@@ -299,23 +323,22 @@ class WebGLRenderer extends Renderer {
299
323
  /**
300
324
  * Clears the gl context with the given color.
301
325
  * @name clearColor
302
- * @memberOf me.WebGLRenderer.prototype
326
+ * @memberof me.WebGLRenderer.prototype
303
327
  * @function
304
- * @param {me.Color|String} [color] CSS color.
305
- * @param {Boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
328
+ * @param {me.Color|string} [color="#000000"] CSS color.
329
+ * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
306
330
  */
307
- clearColor(col, opaque) {
331
+ clearColor(color = "#000000", opaque = false) {
308
332
  var glArray;
309
333
 
310
- this.save();
311
-
312
- if (col instanceof Color) {
313
- glArray = col.toArray();
334
+ if (color instanceof Color) {
335
+ glArray = color.toArray();
314
336
  } else {
337
+ var _color = pool.pull("me.Color");
315
338
  // reuse temporary the renderer default color object
316
- glArray = this.getColor().parseCSS(col).toArray();
339
+ glArray = _color.parseCSS(color).toArray();
340
+ pool.push(_color);
317
341
  }
318
-
319
342
  // clear gl context with the specified color
320
343
  this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
321
344
  this.currentCompositor.clear();
@@ -323,25 +346,23 @@ class WebGLRenderer extends Renderer {
323
346
  // restore default clear Color black
324
347
  this.currentCompositor.clearColor(0.0, 0.0, 0.0, 0.0);
325
348
 
326
- this.restore();
327
349
  }
328
350
 
329
351
  /**
330
352
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
331
353
  * @name clearRect
332
- * @memberOf me.WebGLRenderer.prototype
354
+ * @memberof me.WebGLRenderer.prototype
333
355
  * @function
334
- * @param {Number} x x axis of the coordinate for the rectangle starting point.
335
- * @param {Number} y y axis of the coordinate for the rectangle starting point.
336
- * @param {Number} width The rectangle's width.
337
- * @param {Number} height The rectangle's height.
356
+ * @param {number} x x axis of the coordinate for the rectangle starting point.
357
+ * @param {number} y y axis of the coordinate for the rectangle starting point.
358
+ * @param {number} width The rectangle's width.
359
+ * @param {number} height The rectangle's height.
338
360
  */
339
361
  clearRect(x, y, width, height) {
340
- var color = this.currentColor.clone();
341
- this.currentColor.copy("#000000");
342
- this.fillRect(x, y, width, height);
343
- this.currentColor.copy(color);
344
- pool.push(color);
362
+ this.save();
363
+ this.clipRect(x, y, width, height);
364
+ this.clearColor();
365
+ this.restore();
345
366
  }
346
367
 
347
368
  /**
@@ -380,17 +401,17 @@ class WebGLRenderer extends Renderer {
380
401
  /**
381
402
  * Draw an image to the gl context
382
403
  * @name drawImage
383
- * @memberOf me.WebGLRenderer.prototype
404
+ * @memberof me.WebGLRenderer.prototype
384
405
  * @function
385
406
  * @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.
386
- * @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.
387
- * @param {Number} sy The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
388
- * @param {Number} sw The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.
389
- * @param {Number} sh The height of the sub-rectangle of the source image to draw into the destination context.
390
- * @param {Number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
391
- * @param {Number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
392
- * @param {Number} dWidth The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.
393
- * @param {Number} dHeight The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
407
+ * @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.
408
+ * @param {number} sy The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
409
+ * @param {number} sw The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.
410
+ * @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
411
+ * @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
412
+ * @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
413
+ * @param {number} dw The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.
414
+ * @param {number} dh The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
394
415
  * @example
395
416
  * // Position the image on the canvas:
396
417
  * renderer.drawImage(image, dx, dy);
@@ -433,13 +454,13 @@ class WebGLRenderer extends Renderer {
433
454
  /**
434
455
  * Draw a pattern within the given rectangle.
435
456
  * @name drawPattern
436
- * @memberOf me.WebGLRenderer.prototype
457
+ * @memberof me.WebGLRenderer.prototype
437
458
  * @function
438
459
  * @param {me.Renderer.Texture} pattern Pattern object
439
- * @param {Number} x
440
- * @param {Number} y
441
- * @param {Number} width
442
- * @param {Number} height
460
+ * @param {number} x
461
+ * @param {number} y
462
+ * @param {number} width
463
+ * @param {number} height
443
464
  * @see me.WebGLRenderer#createPattern
444
465
  */
445
466
  drawPattern(pattern, x, y, width, height) {
@@ -451,9 +472,9 @@ class WebGLRenderer extends Renderer {
451
472
  /**
452
473
  * return a reference to the screen canvas corresponding WebGL Context
453
474
  * @name getScreenContext
454
- * @memberOf me.WebGLRenderer.prototype
475
+ * @memberof me.WebGLRenderer.prototype
455
476
  * @function
456
- * @return {WebGLRenderingContext}
477
+ * @returns {WebGLRenderingContext}
457
478
  */
458
479
  getScreenContext() {
459
480
  return this.gl;
@@ -462,11 +483,11 @@ class WebGLRenderer extends Renderer {
462
483
  /**
463
484
  * Returns the WebGL Context object of the given Canvas
464
485
  * @name getContextGL
465
- * @memberOf me.WebGLRenderer.prototype
486
+ * @memberof me.WebGLRenderer.prototype
466
487
  * @function
467
- * @param {Canvas} canvas
468
- * @param {Boolean} [transparent=true] use false to disable transparency
469
- * @return {WebGLRenderingContext}
488
+ * @param {HTMLCanvasElement} canvas
489
+ * @param {boolean} [transparent=true] use false to disable transparency
490
+ * @returns {WebGLRenderingContext}
470
491
  */
471
492
  getContextGL(canvas, transparent) {
472
493
  if (typeof canvas === "undefined" || canvas === null) {
@@ -520,9 +541,9 @@ class WebGLRenderer extends Renderer {
520
541
  * Returns the WebGLContext instance for the renderer
521
542
  * return a reference to the system 2d Context
522
543
  * @name getContext
523
- * @memberOf me.WebGLRenderer.prototype
544
+ * @memberof me.WebGLRenderer.prototype
524
545
  * @function
525
- * @return {WebGLRenderingContext}
546
+ * @returns {WebGLRenderingContext}
526
547
  */
527
548
  getContext() {
528
549
  return this.gl;
@@ -531,9 +552,9 @@ class WebGLRenderer extends Renderer {
531
552
  /**
532
553
  * set a blend mode for the given context
533
554
  * @name setBlendMode
534
- * @memberOf me.WebGLRenderer.prototype
555
+ * @memberof me.WebGLRenderer.prototype
535
556
  * @function
536
- * @param {String} [mode="normal"] blend mode : "normal", "multiply"
557
+ * @param {string} [mode="normal"] blend mode : "normal", "multiply"
537
558
  * @param {WebGLRenderingContext} [gl]
538
559
  */
539
560
  setBlendMode(mode, gl) {
@@ -571,7 +592,7 @@ class WebGLRenderer extends Renderer {
571
592
  /**
572
593
  * restores the canvas context
573
594
  * @name restore
574
- * @memberOf me.WebGLRenderer.prototype
595
+ * @memberof me.WebGLRenderer.prototype
575
596
  * @function
576
597
  */
577
598
  restore() {
@@ -605,7 +626,7 @@ class WebGLRenderer extends Renderer {
605
626
  /**
606
627
  * saves the canvas context
607
628
  * @name save
608
- * @memberOf me.WebGLRenderer.prototype
629
+ * @memberof me.WebGLRenderer.prototype
609
630
  * @function
610
631
  */
611
632
  save() {
@@ -621,9 +642,9 @@ class WebGLRenderer extends Renderer {
621
642
  /**
622
643
  * rotates the uniform matrix
623
644
  * @name rotate
624
- * @memberOf me.WebGLRenderer.prototype
645
+ * @memberof me.WebGLRenderer.prototype
625
646
  * @function
626
- * @param {Number} angle in radians
647
+ * @param {number} angle in radians
627
648
  */
628
649
  rotate(angle) {
629
650
  this.currentTransform.rotate(angle);
@@ -632,10 +653,10 @@ class WebGLRenderer extends Renderer {
632
653
  /**
633
654
  * scales the uniform matrix
634
655
  * @name scale
635
- * @memberOf me.WebGLRenderer.prototype
656
+ * @memberof me.WebGLRenderer.prototype
636
657
  * @function
637
- * @param {Number} x
638
- * @param {Number} y
658
+ * @param {number} x
659
+ * @param {number} y
639
660
  */
640
661
  scale(x, y) {
641
662
  this.currentTransform.scale(x, y);
@@ -653,21 +674,21 @@ class WebGLRenderer extends Renderer {
653
674
  /**
654
675
  * Set the global alpha
655
676
  * @name setGlobalAlpha
656
- * @memberOf me.WebGLRenderer.prototype
677
+ * @memberof me.WebGLRenderer.prototype
657
678
  * @function
658
- * @param {Number} alpha 0.0 to 1.0 values accepted.
679
+ * @param {number} alpha 0.0 to 1.0 values accepted.
659
680
  */
660
- setGlobalAlpha(a) {
661
- this.currentColor.alpha = a;
681
+ setGlobalAlpha(alpha) {
682
+ this.currentColor.alpha = alpha;
662
683
  }
663
684
 
664
685
  /**
665
686
  * Set the current fill & stroke style color.
666
687
  * By default, or upon reset, the value is set to #000000.
667
688
  * @name setColor
668
- * @memberOf me.WebGLRenderer.prototype
689
+ * @memberof me.WebGLRenderer.prototype
669
690
  * @function
670
- * @param {me.Color|String} color css color string.
691
+ * @param {me.Color|string} color css color string.
671
692
  */
672
693
  setColor(color) {
673
694
  var alpha = this.currentColor.alpha;
@@ -678,9 +699,9 @@ class WebGLRenderer extends Renderer {
678
699
  /**
679
700
  * Set the line width
680
701
  * @name setLineWidth
681
- * @memberOf me.WebGLRenderer.prototype
702
+ * @memberof me.WebGLRenderer.prototype
682
703
  * @function
683
- * @param {Number} width Line width
704
+ * @param {number} width Line width
684
705
  */
685
706
  setLineWidth(width) {
686
707
  this.getScreenContext().lineWidth(width);
@@ -689,15 +710,15 @@ class WebGLRenderer extends Renderer {
689
710
  /**
690
711
  * Stroke an arc at the specified coordinates with given radius, start and end points
691
712
  * @name strokeArc
692
- * @memberOf me.WebGLRenderer.prototype
713
+ * @memberof me.WebGLRenderer.prototype
693
714
  * @function
694
- * @param {Number} x arc center point x-axis
695
- * @param {Number} y arc center point y-axis
696
- * @param {Number} radius
697
- * @param {Number} start start angle in radians
698
- * @param {Number} end end angle in radians
699
- * @param {Boolean} [antiClockwise=false] draw arc anti-clockwise
700
- * @param {Boolean} [fill=false]
715
+ * @param {number} x arc center point x-axis
716
+ * @param {number} y arc center point y-axis
717
+ * @param {number} radius
718
+ * @param {number} start start angle in radians
719
+ * @param {number} end end angle in radians
720
+ * @param {boolean} [antiClockwise=false] draw arc anti-clockwise
721
+ * @param {boolean} [fill=false]
701
722
  */
702
723
  strokeArc(x, y, radius, start, end, antiClockwise = false, fill) {
703
724
  if (fill === true ) {
@@ -733,14 +754,14 @@ class WebGLRenderer extends Renderer {
733
754
  /**
734
755
  * Fill an arc at the specified coordinates with given radius, start and end points
735
756
  * @name fillArc
736
- * @memberOf me.WebGLRenderer.prototype
757
+ * @memberof me.WebGLRenderer.prototype
737
758
  * @function
738
- * @param {Number} x arc center point x-axis
739
- * @param {Number} y arc center point y-axis
740
- * @param {Number} radius
741
- * @param {Number} start start angle in radians
742
- * @param {Number} end end angle in radians
743
- * @param {Boolean} [antiClockwise=false] draw arc anti-clockwise
759
+ * @param {number} x arc center point x-axis
760
+ * @param {number} y arc center point y-axis
761
+ * @param {number} radius
762
+ * @param {number} start start angle in radians
763
+ * @param {number} end end angle in radians
764
+ * @param {boolean} [antiClockwise=false] draw arc anti-clockwise
744
765
  */
745
766
  fillArc(x, y, radius, start, end /*, antiClockwise = false*/) {
746
767
  // XXX to be optimzed using a specific shader
@@ -776,13 +797,13 @@ class WebGLRenderer extends Renderer {
776
797
  /**
777
798
  * Stroke an ellipse at the specified coordinates with given radius
778
799
  * @name strokeEllipse
779
- * @memberOf me.WebGLRenderer.prototype
800
+ * @memberof me.WebGLRenderer.prototype
780
801
  * @function
781
- * @param {Number} x ellipse center point x-axis
782
- * @param {Number} y ellipse center point y-axis
783
- * @param {Number} w horizontal radius of the ellipse
784
- * @param {Number} h vertical radius of the ellipse
785
- * @param {Boolean} [fill=false] also fill the shape with the current color if true
802
+ * @param {number} x ellipse center point x-axis
803
+ * @param {number} y ellipse center point y-axis
804
+ * @param {number} w horizontal radius of the ellipse
805
+ * @param {number} h vertical radius of the ellipse
806
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
786
807
  */
787
808
  strokeEllipse(x, y, w, h, fill = false) {
788
809
  if (fill === true ) {
@@ -813,12 +834,12 @@ class WebGLRenderer extends Renderer {
813
834
  /**
814
835
  * Fill an ellipse at the specified coordinates with given radius
815
836
  * @name fillEllipse
816
- * @memberOf me.WebGLRenderer.prototype
837
+ * @memberof me.WebGLRenderer.prototype
817
838
  * @function
818
- * @param {Number} x ellipse center point x-axis
819
- * @param {Number} y ellipse center point y-axis
820
- * @param {Number} w horizontal radius of the ellipse
821
- * @param {Number} h vertical radius of the ellipse
839
+ * @param {number} x ellipse center point x-axis
840
+ * @param {number} y ellipse center point y-axis
841
+ * @param {number} w horizontal radius of the ellipse
842
+ * @param {number} h vertical radius of the ellipse
822
843
  */
823
844
  fillEllipse(x, y, w, h) {
824
845
  // XXX to be optimzed using a specific shader
@@ -848,12 +869,12 @@ class WebGLRenderer extends Renderer {
848
869
  /**
849
870
  * Stroke a line of the given two points
850
871
  * @name strokeLine
851
- * @memberOf me.WebGLRenderer.prototype
872
+ * @memberof me.WebGLRenderer.prototype
852
873
  * @function
853
- * @param {Number} startX the start x coordinate
854
- * @param {Number} startY the start y coordinate
855
- * @param {Number} endX the end x coordinate
856
- * @param {Number} endY the end y coordinate
874
+ * @param {number} startX the start x coordinate
875
+ * @param {number} startY the start y coordinate
876
+ * @param {number} endX the end x coordinate
877
+ * @param {number} endY the end y coordinate
857
878
  */
858
879
  strokeLine(startX, startY, endX, endY) {
859
880
  var points = this._glPoints;
@@ -868,12 +889,12 @@ class WebGLRenderer extends Renderer {
868
889
  /**
869
890
  * Fill a line of the given two points
870
891
  * @name fillLine
871
- * @memberOf me.WebGLRenderer.prototype
892
+ * @memberof me.WebGLRenderer.prototype
872
893
  * @function
873
- * @param {Number} startX the start x coordinate
874
- * @param {Number} startY the start y coordinate
875
- * @param {Number} endX the end x coordinate
876
- * @param {Number} endY the end y coordinate
894
+ * @param {number} startX the start x coordinate
895
+ * @param {number} startY the start y coordinate
896
+ * @param {number} endX the end x coordinate
897
+ * @param {number} endY the end y coordinate
877
898
  */
878
899
  fillLine(startX, startY, endX, endY) {
879
900
  this.strokeLine(startX, startY, endX, endY);
@@ -882,10 +903,10 @@ class WebGLRenderer extends Renderer {
882
903
  /**
883
904
  * Stroke a me.Polygon on the screen with a specified color
884
905
  * @name strokePolygon
885
- * @memberOf me.WebGLRenderer.prototype
906
+ * @memberof me.WebGLRenderer.prototype
886
907
  * @function
887
908
  * @param {me.Polygon} poly the shape to draw
888
- * @param {Boolean} [fill=false] also fill the shape with the current color if true
909
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
889
910
  */
890
911
  strokePolygon(poly, fill = false) {
891
912
  if (fill === true ) {
@@ -912,10 +933,10 @@ class WebGLRenderer extends Renderer {
912
933
  /**
913
934
  * Fill a me.Polygon on the screen
914
935
  * @name fillPolygon
915
- * @memberOf me.WebGLRenderer.prototype
936
+ * @memberof me.WebGLRenderer.prototype
916
937
  * @function
917
938
  * @param {me.Polygon} poly the shape to draw
918
- */
939
+ */
919
940
  fillPolygon(poly) {
920
941
  var points = poly.points;
921
942
  var glPoints = this._glPoints;
@@ -940,13 +961,13 @@ class WebGLRenderer extends Renderer {
940
961
  /**
941
962
  * Draw a stroke rectangle at the specified coordinates
942
963
  * @name strokeRect
943
- * @memberOf me.WebGLRenderer.prototype
964
+ * @memberof me.WebGLRenderer.prototype
944
965
  * @function
945
- * @param {Number} x
946
- * @param {Number} y
947
- * @param {Number} width
948
- * @param {Number} height
949
- * @param {Boolean} [fill=false] also fill the shape with the current color if true
966
+ * @param {number} x
967
+ * @param {number} y
968
+ * @param {number} width
969
+ * @param {number} height
970
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
950
971
  */
951
972
  strokeRect(x, y, width, height, fill = false) {
952
973
  if (fill === true ) {
@@ -968,12 +989,12 @@ class WebGLRenderer extends Renderer {
968
989
  /**
969
990
  * Draw a filled rectangle at the specified coordinates
970
991
  * @name fillRect
971
- * @memberOf me.WebGLRenderer.prototype
992
+ * @memberof me.WebGLRenderer.prototype
972
993
  * @function
973
- * @param {Number} x
974
- * @param {Number} y
975
- * @param {Number} width
976
- * @param {Number} height
994
+ * @param {number} x
995
+ * @param {number} y
996
+ * @param {number} width
997
+ * @param {number} height
977
998
  */
978
999
  fillRect(x, y, width, height) {
979
1000
  var glPoints = this._glPoints;
@@ -992,7 +1013,7 @@ class WebGLRenderer extends Renderer {
992
1013
  * Reset (overrides) the renderer transformation matrix to the
993
1014
  * identity one, and then apply the given transformation matrix.
994
1015
  * @name setTransform
995
- * @memberOf me.WebGLRenderer.prototype
1016
+ * @memberof me.WebGLRenderer.prototype
996
1017
  * @function
997
1018
  * @param {me.Matrix2d} mat2d Matrix to transform by
998
1019
  */
@@ -1004,7 +1025,7 @@ class WebGLRenderer extends Renderer {
1004
1025
  /**
1005
1026
  * Multiply given matrix into the renderer tranformation matrix
1006
1027
  * @name transform
1007
- * @memberOf me.WebGLRenderer.prototype
1028
+ * @memberof me.WebGLRenderer.prototype
1008
1029
  * @function
1009
1030
  * @param {me.Matrix2d} mat2d Matrix to transform by
1010
1031
  */
@@ -1022,10 +1043,10 @@ class WebGLRenderer extends Renderer {
1022
1043
  /**
1023
1044
  * Translates the uniform matrix by the given coordinates
1024
1045
  * @name translate
1025
- * @memberOf me.WebGLRenderer.prototype
1046
+ * @memberof me.WebGLRenderer.prototype
1026
1047
  * @function
1027
- * @param {Number} x
1028
- * @param {Number} y
1048
+ * @param {number} x
1049
+ * @param {number} y
1029
1050
  */
1030
1051
  translate(x, y) {
1031
1052
  var currentTransform = this.currentTransform;
@@ -1045,12 +1066,12 @@ class WebGLRenderer extends Renderer {
1045
1066
  * and restore it (with the restore() method) any time in the future.
1046
1067
  * (<u>this is an experimental feature !</u>)
1047
1068
  * @name clipRect
1048
- * @memberOf me.WebGLRenderer.prototype
1069
+ * @memberof me.WebGLRenderer.prototype
1049
1070
  * @function
1050
- * @param {Number} x
1051
- * @param {Number} y
1052
- * @param {Number} width
1053
- * @param {Number} height
1071
+ * @param {number} x
1072
+ * @param {number} y
1073
+ * @param {number} width
1074
+ * @param {number} height
1054
1075
  */
1055
1076
  clipRect(x, y, width, height) {
1056
1077
  var canvas = this.backBufferCanvas;
@@ -1093,7 +1114,7 @@ class WebGLRenderer extends Renderer {
1093
1114
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
1094
1115
  * Mask are not preserved through renderer context save and restore.
1095
1116
  * @name setMask
1096
- * @memberOf me.WebGLRenderer.prototype
1117
+ * @memberof me.WebGLRenderer.prototype
1097
1118
  * @function
1098
1119
  * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} [mask] the shape defining the mask to be applied
1099
1120
  */
@@ -1125,7 +1146,7 @@ class WebGLRenderer extends Renderer {
1125
1146
  * disable (remove) the rendering mask set through setMask.
1126
1147
  * @name clearMask
1127
1148
  * @see me.WebGLRenderer#setMask
1128
- * @memberOf me.WebGLRenderer.prototype
1149
+ * @memberof me.WebGLRenderer.prototype
1129
1150
  * @function
1130
1151
  */
1131
1152
  clearMask() {