melonjs 13.1.1 → 13.2.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v13.1.1
2
+ * melonJS Game Engine - v13.2.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -2971,7 +2971,7 @@ class Color {
2971
2971
  * @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
2972
2972
  * @returns {number}
2973
2973
  */
2974
- toUint32(alpha = this.alpha) {
2974
+ toUint32(alpha = 1.0) {
2975
2975
  var ur = this.r & 0xff;
2976
2976
  var ug = this.g & 0xff;
2977
2977
  var ub = this.b & 0xff;
@@ -6524,56 +6524,38 @@ class GLShader {
6524
6524
 
6525
6525
  /**
6526
6526
  * the active gl rendering context
6527
- * @public
6528
6527
  * @type {WebGLRenderingContext}
6529
- * @name gl
6530
- * @memberof GLShader
6531
6528
  */
6532
6529
  this.gl = gl;
6533
6530
 
6534
6531
  /**
6535
6532
  * the vertex shader source code
6536
- * @public
6537
6533
  * @type {string}
6538
- * @name vertex
6539
- * @memberof GLShader
6540
6534
  */
6541
6535
  this.vertex = setPrecision(minify(vertex), precision || getMaxShaderPrecision(this.gl));
6542
6536
 
6543
6537
  /**
6544
6538
  * the fragment shader source code
6545
- * @public
6546
6539
  * @type {string}
6547
- * @name vertex
6548
- * @memberof GLShader
6549
6540
  */
6550
6541
  this.fragment = setPrecision(minify(fragment), precision || getMaxShaderPrecision(this.gl));
6551
6542
 
6552
6543
  /**
6553
6544
  * the location attributes of the shader
6554
- * @public
6555
6545
  * @type {GLint[]}
6556
- * @name attributes
6557
- * @memberof GLShader
6558
6546
  */
6559
6547
  this.attributes = extractAttributes(this.gl, this);
6560
6548
 
6561
6549
 
6562
6550
  /**
6563
6551
  * a reference to the shader program (once compiled)
6564
- * @public
6565
6552
  * @type {WebGLProgram}
6566
- * @name program
6567
- * @memberof GLShader
6568
6553
  */
6569
6554
  this.program = compileProgram(this.gl, this.vertex, this.fragment, this.attributes);
6570
6555
 
6571
6556
  /**
6572
6557
  * the uniforms of the shader
6573
- * @public
6574
6558
  * @type {object}
6575
- * @name uniforms
6576
- * @memberof GLShader
6577
6559
  */
6578
6560
  this.uniforms = extractUniforms(this.gl, this);
6579
6561
 
@@ -6583,8 +6565,6 @@ class GLShader {
6583
6565
 
6584
6566
  /**
6585
6567
  * Installs this shader program as part of current rendering state
6586
- * @name bind
6587
- * @memberof GLShader
6588
6568
  */
6589
6569
  bind() {
6590
6570
  this.gl.useProgram(this.program);
@@ -6592,8 +6572,6 @@ class GLShader {
6592
6572
 
6593
6573
  /**
6594
6574
  * returns the location of an attribute variable in this shader program
6595
- * @name getAttribLocation
6596
- * @memberof GLShader
6597
6575
  * @param {string} name the name of the attribute variable whose location to get.
6598
6576
  * @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
6599
6577
  */
@@ -6608,8 +6586,6 @@ class GLShader {
6608
6586
 
6609
6587
  /**
6610
6588
  * Set the uniform to the given value
6611
- * @name setUniform
6612
- * @memberof GLShader
6613
6589
  * @param {string} name the uniform name
6614
6590
  * @param {object|Float32Array} value the value to assign to that uniform
6615
6591
  * @example
@@ -6630,8 +6606,6 @@ class GLShader {
6630
6606
 
6631
6607
  /**
6632
6608
  * activate the given vertex attribute for this shader
6633
- * @name setVertexAttributes
6634
- * @memberof GLShader
6635
6609
  * @param {WebGLRenderingContext} gl the current WebGL rendering context
6636
6610
  * @param {object[]} attributes an array of vertex attributes
6637
6611
  * @param {number} vertexByteSize the size of a single vertex in bytes
@@ -6653,8 +6627,6 @@ class GLShader {
6653
6627
 
6654
6628
  /**
6655
6629
  * destroy this shader objects resources (program, attributes, uniforms)
6656
- * @name destroy
6657
- * @memberof GLShader
6658
6630
  */
6659
6631
  destroy() {
6660
6632
  this.uniforms = null;
@@ -6856,44 +6828,37 @@ class WebGLCompositor {
6856
6828
 
6857
6829
  /**
6858
6830
  * a reference to the active WebGL shader
6859
- * @name activeShader
6860
- * @memberof WebGLCompositor
6861
6831
  * @type {GLShader}
6862
6832
  */
6863
6833
  this.activeShader = null;
6864
6834
 
6865
6835
  /**
6866
6836
  * primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
6867
- * @name mode
6868
- * @see WebGLCompositor
6869
- * @memberof WebGLCompositor
6837
+ * @type {number}
6870
6838
  * @default gl.TRIANGLES
6871
6839
  */
6872
6840
  this.mode = gl.TRIANGLES;
6873
6841
 
6874
6842
  /**
6875
6843
  * an array of vertex attribute properties
6876
- * @name attributes
6877
6844
  * @see WebGLCompositor.addAttribute
6878
- * @memberof WebGLCompositor
6845
+ * @type {Array}
6879
6846
  */
6880
6847
  this.attributes = [];
6881
6848
 
6882
6849
  /**
6883
6850
  * the size of a single vertex in bytes
6884
6851
  * (will automatically be calculated as attributes definitions are added)
6885
- * @name vertexByteSize
6886
6852
  * @see WebGLCompositor.addAttribute
6887
- * @memberof WebGLCompositor
6853
+ * @type {number}
6888
6854
  */
6889
6855
  this.vertexByteSize = 0;
6890
6856
 
6891
6857
  /**
6892
6858
  * the size of a single vertex in floats
6893
6859
  * (will automatically be calculated as attributes definitions are added)
6894
- * @name vertexSize
6895
6860
  * @see WebGLCompositor.addAttribute
6896
- * @memberof WebGLCompositor
6861
+ * @type {number}
6897
6862
  */
6898
6863
  this.vertexSize = 0;
6899
6864
 
@@ -6954,8 +6919,6 @@ class WebGLCompositor {
6954
6919
 
6955
6920
  /**
6956
6921
  * add vertex attribute property definition to the compositor
6957
- * @name addAttribute
6958
- * @memberof WebGLCompositor
6959
6922
  * @param {string} name name of the attribute in the vertex shader
6960
6923
  * @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
6961
6924
  * @param {GLenum} type data type of each component in the array
@@ -7001,8 +6964,6 @@ class WebGLCompositor {
7001
6964
 
7002
6965
  /**
7003
6966
  * Sets the viewport
7004
- * @name setViewport
7005
- * @memberof WebGLCompositor
7006
6967
  * @param {number} x x position of viewport
7007
6968
  * @param {number} y y position of viewport
7008
6969
  * @param {number} w width of viewport
@@ -7014,8 +6975,6 @@ class WebGLCompositor {
7014
6975
 
7015
6976
  /**
7016
6977
  * Create a WebGL texture from an image
7017
- * @name createTexture2D
7018
- * @memberof WebGLCompositor
7019
6978
  * @param {number} unit Destination texture unit
7020
6979
  * @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
7021
6980
  * @param {number} filter gl.LINEAR or gl.NEAREST
@@ -7058,8 +7017,6 @@ class WebGLCompositor {
7058
7017
 
7059
7018
  /**
7060
7019
  * delete the given WebGL texture
7061
- * @name bindTexture2D
7062
- * @memberof WebGLCompositor
7063
7020
  * @param {WebGLTexture} [texture] a WebGL texture to delete
7064
7021
  * @param {number} [unit] Texture unit to delete
7065
7022
  */
@@ -7070,8 +7027,6 @@ class WebGLCompositor {
7070
7027
 
7071
7028
  /**
7072
7029
  * returns the WebGL texture associated to the given texture unit
7073
- * @name bindTexture2D
7074
- * @memberof WebGLCompositor
7075
7030
  * @param {number} unit Texture unit to which a texture is bound
7076
7031
  * @returns {WebGLTexture} texture a WebGL texture
7077
7032
  */
@@ -7081,8 +7036,6 @@ class WebGLCompositor {
7081
7036
 
7082
7037
  /**
7083
7038
  * assign the given WebGL texture to the current batch
7084
- * @name bindTexture2D
7085
- * @memberof WebGLCompositor
7086
7039
  * @param {WebGLTexture} texture a WebGL texture
7087
7040
  * @param {number} unit Texture unit to which the given texture is bound
7088
7041
  */
@@ -7108,8 +7061,6 @@ class WebGLCompositor {
7108
7061
 
7109
7062
  /**
7110
7063
  * unbind the given WebGL texture, forcing it to be reuploaded
7111
- * @name unbindTexture2D
7112
- * @memberof WebGLCompositor
7113
7064
  * @param {WebGLTexture} [texture] a WebGL texture
7114
7065
  * @param {number} [unit] a WebGL texture
7115
7066
  * @returns {number} unit the unit number that was associated with the given texture
@@ -7154,8 +7105,6 @@ class WebGLCompositor {
7154
7105
 
7155
7106
  /**
7156
7107
  * set/change the current projection matrix
7157
- * @name setProjection
7158
- * @memberof WebGLCompositor
7159
7108
  * @param {Matrix3d} matrix
7160
7109
  */
7161
7110
  setProjection(matrix) {
@@ -7164,9 +7113,7 @@ class WebGLCompositor {
7164
7113
 
7165
7114
  /**
7166
7115
  * Select the shader to use for compositing
7167
- * @name useShader
7168
7116
  * @see GLShader
7169
- * @memberof WebGLCompositor
7170
7117
  * @param {GLShader} shader a reference to a GLShader instance
7171
7118
  */
7172
7119
  useShader(shader) {
@@ -7181,8 +7128,6 @@ class WebGLCompositor {
7181
7128
 
7182
7129
  /**
7183
7130
  * Add a textured quad
7184
- * @name addQuad
7185
- * @memberof WebGLCompositor
7186
7131
  * @param {TextureAtlas} texture Source texture atlas
7187
7132
  * @param {number} x Destination x-coordinate
7188
7133
  * @param {number} y Destination y-coordinate
@@ -7238,7 +7183,6 @@ class WebGLCompositor {
7238
7183
  /**
7239
7184
  * Flush batched texture operations to the GPU
7240
7185
  * @param {number} [mode=gl.TRIANGLES] the GL drawing mode
7241
- * @memberof WebGLCompositor
7242
7186
  */
7243
7187
  flush(mode = this.mode) {
7244
7188
  var vertex = this.vertexBuffer;
@@ -7264,8 +7208,6 @@ class WebGLCompositor {
7264
7208
 
7265
7209
  /**
7266
7210
  * Draw an array of vertices
7267
- * @name drawVertices
7268
- * @memberof WebGLCompositor
7269
7211
  * @param {GLenum} mode primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
7270
7212
  * @param {Vector2d[]} verts vertices
7271
7213
  * @param {number} [vertexCount=verts.length] amount of points defined in the points array
@@ -7292,25 +7234,26 @@ class WebGLCompositor {
7292
7234
  }
7293
7235
 
7294
7236
  /**
7295
- * Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
7296
- * @name clearColor
7297
- * @memberof WebGLCompositor
7298
- * @param {number} [r=0] - the red color value used when the color buffers are cleared
7299
- * @param {number} [g=0] - the green color value used when the color buffers are cleared
7300
- * @param {number} [b=0] - the blue color value used when the color buffers are cleared
7301
- * @param {number} [a=0] - the alpha color value used when the color buffers are cleared
7237
+ * Clear the frame buffer
7238
+ * @param {number} [alpha = 0.0] - the alpha value used when clearing the framebuffer
7302
7239
  */
7303
- clearColor(r, g, b, a) {
7304
- this.gl.clearColor(r, g, b, a);
7240
+ clear(alpha = 0) {
7241
+ var gl = this.gl;
7242
+ gl.clearColor(0, 0, 0, alpha);
7243
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
7305
7244
  }
7306
7245
 
7307
7246
  /**
7308
- * Clear the frame buffer
7309
- * @name clear
7310
- * @memberof WebGLCompositor
7247
+ * Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
7248
+ * @param {number} [r = 0] - the red color value used when the color buffers are cleared
7249
+ * @param {number} [g = 0] - the green color value used when the color buffers are cleared
7250
+ * @param {number} [b = 0] - the blue color value used when the color buffers are cleared
7251
+ * @param {number} [a = 0] - the alpha color value used when the color buffers are cleared
7311
7252
  */
7312
- clear() {
7313
- this.gl.clear(this.gl.COLOR_BUFFER_BIT);
7253
+ clearColor(r = 0, g = 0, b = 0, a = 0) {
7254
+ var gl = this.gl;
7255
+ gl.clearColor(r, g, b, a);
7256
+ gl.clear(gl.COLOR_BUFFER_BIT);
7314
7257
  }
7315
7258
  }
7316
7259
 
@@ -9619,17 +9562,18 @@ class Bounds {
9619
9562
  * add the given point to the bounds definition.
9620
9563
  * @name addPoint
9621
9564
  * @memberof Bounds
9622
- * @param {Vector2d} v
9623
- * @param {Matrix2d} [m] an optional transform to apply to the given point
9565
+ * @param {Vector2d|Point} point the point to be added to the bounds
9566
+ * @param {Matrix2d} [m] an optional transform to apply to the given point (only if the given point is a vector)
9624
9567
  */
9625
- addPoint(v, m) {
9626
- if (typeof m !== "undefined") {
9627
- v = m.apply(v);
9568
+ addPoint(point, m) {
9569
+ if ((typeof m !== "undefined") && (typeof point.rotate === "function")) {
9570
+ // only Vectors object have a rotate function
9571
+ point = m.apply(point);
9628
9572
  }
9629
- this.min.x = Math.min(this.min.x, v.x);
9630
- this.max.x = Math.max(this.max.x, v.x);
9631
- this.min.y = Math.min(this.min.y, v.y);
9632
- this.max.y = Math.max(this.max.y, v.y);
9573
+ this.min.x = Math.min(this.min.x, point.x);
9574
+ this.max.x = Math.max(this.max.x, point.x);
9575
+ this.min.y = Math.min(this.min.y, point.y);
9576
+ this.max.y = Math.max(this.max.y, point.y);
9633
9577
  }
9634
9578
 
9635
9579
  /**
@@ -10118,6 +10062,86 @@ class Path2D {
10118
10062
  }
10119
10063
  }
10120
10064
 
10065
+ /**
10066
+ * @classdesc
10067
+ * represents a point in a 2d space
10068
+ */
10069
+ class Point {
10070
+ constructor(x = 0, y = 0) {
10071
+ /**
10072
+ * the position of the point on the horizontal axis
10073
+ * @public
10074
+ * @type {Number}
10075
+ * @default 0
10076
+ */
10077
+ this.x = x;
10078
+
10079
+ /**
10080
+ * the position of the point on the vertical axis
10081
+ * @public
10082
+ * @type {Number}
10083
+ * @default 0
10084
+ */
10085
+ this.y = y;
10086
+ }
10087
+
10088
+ /** @ignore */
10089
+ onResetEvent(x = 0, y = 0) {
10090
+ this.set(x, y);
10091
+ }
10092
+
10093
+ /**
10094
+ * set the Point x and y properties to the given values
10095
+ * @param {number} x
10096
+ * @param {number} y
10097
+ * @returns {Point} Reference to this object for method chaining
10098
+ */
10099
+ set(x = 0, y = 0) {
10100
+ this.x = x;
10101
+ this.y = y;
10102
+ return this;
10103
+ }
10104
+
10105
+ /**
10106
+ * return true if the two points are the same
10107
+ * @name equals
10108
+ * @memberof Point
10109
+ * @method
10110
+ * @param {Point} point
10111
+ * @returns {boolean}
10112
+ */
10113
+ /**
10114
+ * return true if this point is equal to the given values
10115
+ * @name equals
10116
+ * @memberof Point
10117
+ * @param {number} x
10118
+ * @param {number} y
10119
+ * @returns {boolean}
10120
+ */
10121
+ equals() {
10122
+ var _x, _y;
10123
+ if (arguments.length === 2) {
10124
+ // x, y
10125
+ _x = arguments[0];
10126
+ _y = arguments[1];
10127
+ } else {
10128
+ // point
10129
+ _x = arguments[0].x;
10130
+ _y = arguments[0].y;
10131
+ }
10132
+ return ((this.x === _x) && (this.y === _y));
10133
+ }
10134
+
10135
+ /**
10136
+ * clone this Point
10137
+ * @name clone
10138
+ * @returns {Point} new Point
10139
+ */
10140
+ clone() {
10141
+ return new Point(this.x, this.y);
10142
+ }
10143
+ }
10144
+
10121
10145
  /**
10122
10146
  * @classdesc
10123
10147
  * a base renderer object
@@ -10130,7 +10154,8 @@ class Renderer {
10130
10154
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
10131
10155
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
10132
10156
  * @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.
10133
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
10157
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
10158
+ * @param {boolean} [options.premultipliedAlpha=true] in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
10134
10159
  * @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
10135
10160
  * @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
10136
10161
  * @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
@@ -10141,26 +10166,20 @@ class Renderer {
10141
10166
  /**
10142
10167
  * The given constructor options
10143
10168
  * @public
10144
- * @name settings
10145
- * @memberof Renderer#
10146
10169
  * @type {object}
10147
10170
  */
10148
10171
  this.settings = options;
10149
10172
 
10150
10173
  /**
10151
10174
  * true if the current rendering context is valid
10152
- * @name isContextValid
10153
- * @memberof Renderer#
10154
10175
  * @default true
10155
- * type {boolean}
10176
+ * @type {boolean}
10156
10177
  */
10157
10178
  this.isContextValid = true;
10158
10179
 
10159
10180
  /**
10160
10181
  * The Path2D instance used by the renderer to draw primitives
10161
- * @name path2D
10162
10182
  * @type {Path2D}
10163
- * @memberof Renderer#
10164
10183
  */
10165
10184
  this.path2D = new Path2D();
10166
10185
 
@@ -10212,22 +10231,16 @@ class Renderer {
10212
10231
 
10213
10232
  /**
10214
10233
  * prepare the framebuffer for drawing a new frame
10215
- * @name clear
10216
- * @memberof Renderer
10217
10234
  */
10218
10235
  clear() {}
10219
10236
 
10220
10237
  /**
10221
10238
  * render the main framebuffer on screen
10222
- * @name flush
10223
- * @memberof Renderer
10224
10239
  */
10225
10240
  flush() {}
10226
10241
 
10227
10242
  /**
10228
10243
  * Reset context state
10229
- * @name reset
10230
- * @memberof Renderer
10231
10244
  */
10232
10245
  reset() {
10233
10246
  this.resetTransform();
@@ -10244,8 +10257,6 @@ class Renderer {
10244
10257
 
10245
10258
  /**
10246
10259
  * return a reference to the canvas which this renderer draws to
10247
- * @name getCanvas
10248
- * @memberof Renderer
10249
10260
  * @returns {HTMLCanvasElement}
10250
10261
  */
10251
10262
  getCanvas() {
@@ -10255,8 +10266,6 @@ class Renderer {
10255
10266
 
10256
10267
  /**
10257
10268
  * return a reference to this renderer canvas corresponding Context
10258
- * @name getContext
10259
- * @memberof Renderer
10260
10269
  * @returns {CanvasRenderingContext2D|WebGLRenderingContext}
10261
10270
  */
10262
10271
  getContext() {
@@ -10265,8 +10274,6 @@ class Renderer {
10265
10274
 
10266
10275
  /**
10267
10276
  * returns the current blend mode for this renderer
10268
- * @name getBlendMode
10269
- * @memberof Renderer
10270
10277
  * @returns {string} blend mode
10271
10278
  */
10272
10279
  getBlendMode() {
@@ -10276,8 +10283,6 @@ class Renderer {
10276
10283
  /**
10277
10284
  * Returns the 2D Context object of the given Canvas<br>
10278
10285
  * Also configures anti-aliasing and blend modes based on constructor options.
10279
- * @name getContext2d
10280
- * @memberof Renderer
10281
10286
  * @param {HTMLCanvasElement} canvas
10282
10287
  * @param {boolean} [transparent=true] use false to disable transparency
10283
10288
  * @returns {CanvasRenderingContext2D}
@@ -10313,8 +10318,6 @@ class Renderer {
10313
10318
 
10314
10319
  /**
10315
10320
  * return the width of the system Canvas
10316
- * @name getWidth
10317
- * @memberof Renderer
10318
10321
  * @returns {number}
10319
10322
  */
10320
10323
  getWidth() {
@@ -10323,8 +10326,6 @@ class Renderer {
10323
10326
 
10324
10327
  /**
10325
10328
  * return the height of the system Canvas
10326
- * @name getHeight
10327
- * @memberof Renderer
10328
10329
  * @returns {number} height of the system Canvas
10329
10330
  */
10330
10331
  getHeight() {
@@ -10333,8 +10334,6 @@ class Renderer {
10333
10334
 
10334
10335
  /**
10335
10336
  * get the current fill & stroke style color.
10336
- * @name getColor
10337
- * @memberof Renderer
10338
10337
  * @returns {Color} current global color
10339
10338
  */
10340
10339
  getColor() {
@@ -10343,8 +10342,6 @@ class Renderer {
10343
10342
 
10344
10343
  /**
10345
10344
  * return the current global alpha
10346
- * @name globalAlpha
10347
- * @memberof Renderer
10348
10345
  * @returns {number}
10349
10346
  */
10350
10347
  globalAlpha() {
@@ -10353,8 +10350,6 @@ class Renderer {
10353
10350
 
10354
10351
  /**
10355
10352
  * check if the given rect or bounds overlaps with the renderer screen coordinates
10356
- * @name overlaps
10357
- * @memberof Renderer
10358
10353
  * @param {Rect|Bounds} bounds
10359
10354
  * @returns {boolean} true if overlaps
10360
10355
  */
@@ -10368,8 +10363,6 @@ class Renderer {
10368
10363
 
10369
10364
  /**
10370
10365
  * resizes the system canvas
10371
- * @name resize
10372
- * @memberof Renderer
10373
10366
  * @param {number} width new width of the canvas
10374
10367
  * @param {number} height new height of the canvas
10375
10368
  */
@@ -10389,8 +10382,6 @@ class Renderer {
10389
10382
 
10390
10383
  /**
10391
10384
  * enable/disable image smoothing (scaling interpolation) for the given context
10392
- * @name setAntiAlias
10393
- * @memberof Renderer
10394
10385
  * @param {CanvasRenderingContext2D} context
10395
10386
  * @param {boolean} [enable=false]
10396
10387
  */
@@ -10418,8 +10409,6 @@ class Renderer {
10418
10409
 
10419
10410
  /**
10420
10411
  * set/change the current projection matrix (WebGL only)
10421
- * @name setProjection
10422
- * @memberof Renderer
10423
10412
  * @param {Matrix3d} matrix
10424
10413
  */
10425
10414
  setProjection(matrix) {
@@ -10428,8 +10417,6 @@ class Renderer {
10428
10417
 
10429
10418
  /**
10430
10419
  * stroke the given shape
10431
- * @name stroke
10432
- * @memberof Renderer
10433
10420
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
10434
10421
  * @param {boolean} [fill=false] fill the shape with the current color if true
10435
10422
  */
@@ -10456,6 +10443,10 @@ class Renderer {
10456
10443
  );
10457
10444
  return;
10458
10445
  }
10446
+ if (shape instanceof Point) {
10447
+ this.strokePoint(shape.x, shape.y);
10448
+ return;
10449
+ }
10459
10450
  throw new Error("Invalid geometry for fill/stroke");
10460
10451
  }
10461
10452
 
@@ -10471,8 +10462,6 @@ class Renderer {
10471
10462
 
10472
10463
  /**
10473
10464
  * tint the given image or canvas using the given color
10474
- * @name tint
10475
- * @memberof Renderer
10476
10465
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
10477
10466
  * @param {Color|string} color the color that will be used to tint the image
10478
10467
  * @param {string} [mode="multiply"] the composition mode used to tint the image
@@ -10501,8 +10490,6 @@ class Renderer {
10501
10490
  * A mask limits rendering elements to the shape and position of the given mask object.
10502
10491
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
10503
10492
  * Mask are not preserved through renderer context save and restore.
10504
- * @name setMask
10505
- * @memberof Renderer
10506
10493
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
10507
10494
  * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
10508
10495
  */
@@ -10511,16 +10498,12 @@ class Renderer {
10511
10498
 
10512
10499
  /**
10513
10500
  * disable (remove) the rendering mask set through setMask.
10514
- * @name clearMask
10515
10501
  * @see Renderer#setMask
10516
- * @memberof Renderer
10517
10502
  */
10518
10503
  clearMask() {}
10519
10504
 
10520
10505
  /**
10521
10506
  * set a coloring tint for sprite based renderables
10522
- * @name setTint
10523
- * @memberof Renderer
10524
10507
  * @param {Color} tint the tint color
10525
10508
  * @param {number} [alpha] an alpha value to be applied to the tint
10526
10509
  */
@@ -10532,9 +10515,7 @@ class Renderer {
10532
10515
 
10533
10516
  /**
10534
10517
  * clear the rendering tint set through setTint.
10535
- * @name clearTint
10536
10518
  * @see Renderer#setTint
10537
- * @memberof Renderer
10538
10519
  */
10539
10520
  clearTint() {
10540
10521
  // reset to default
@@ -18045,21 +18026,14 @@ class Renderable extends Rect {
18045
18026
 
18046
18027
  /**
18047
18028
  * If true then physic collision and input events will not impact this renderable
18048
- * @public
18049
18029
  * @type {boolean}
18050
18030
  * @default true
18051
- * @name isKinematic
18052
- * @memberof Renderable
18053
18031
  */
18054
18032
  this.isKinematic = true;
18055
18033
 
18056
18034
  /**
18057
18035
  * the renderable physic body
18058
- * @public
18059
18036
  * @type {Body}
18060
- * @see Body
18061
- * @name body
18062
- * @memberof Renderable#
18063
18037
  * @example
18064
18038
  * // define a new Player Class
18065
18039
  * class PlayerEntity extends me.Sprite {
@@ -18097,10 +18071,7 @@ class Renderable extends Rect {
18097
18071
  if (typeof this.currentTransform === "undefined") {
18098
18072
  /**
18099
18073
  * the renderable default transformation matrix
18100
- * @public
18101
18074
  * @type {Matrix2d}
18102
- * @name currentTransform
18103
- * @memberof Renderable#
18104
18075
  */
18105
18076
  this.currentTransform = pool.pull("Matrix2d");
18106
18077
  }
@@ -18110,20 +18081,14 @@ class Renderable extends Rect {
18110
18081
  * (G)ame (U)nique (Id)entifier" <br>
18111
18082
  * a GUID will be allocated for any renderable object added <br>
18112
18083
  * to an object container (including the `me.game.world` container)
18113
- * @public
18114
18084
  * @type {string}
18115
- * @name GUID
18116
- * @memberof Renderable
18117
18085
  */
18118
18086
  this.GUID = undefined;
18119
18087
 
18120
18088
  /**
18121
18089
  * an event handler that is called when the renderable leave or enter a camera viewport
18122
- * @public
18123
18090
  * @type {Function}
18124
18091
  * @default undefined
18125
- * @name onVisibilityChange
18126
- * @memberof Renderable#
18127
18092
  * @example
18128
18093
  * this.onVisibilityChange = function(inViewport) {
18129
18094
  * if (inViewport === true) {
@@ -18135,42 +18100,30 @@ class Renderable extends Rect {
18135
18100
 
18136
18101
  /**
18137
18102
  * Whether the renderable object will always update, even when outside of the viewport<br>
18138
- * @public
18139
18103
  * @type {boolean}
18140
18104
  * @default false
18141
- * @name alwaysUpdate
18142
- * @memberof Renderable
18143
18105
  */
18144
18106
  this.alwaysUpdate = false;
18145
18107
 
18146
18108
  /**
18147
18109
  * Whether to update this object when the game is paused.
18148
- * @public
18149
18110
  * @type {boolean}
18150
18111
  * @default false
18151
- * @name updateWhenPaused
18152
- * @memberof Renderable
18153
18112
  */
18154
18113
  this.updateWhenPaused = false;
18155
18114
 
18156
18115
  /**
18157
18116
  * make the renderable object persistent over level changes<br>
18158
- * @public
18159
18117
  * @type {boolean}
18160
18118
  * @default false
18161
- * @name isPersistent
18162
- * @memberof Renderable
18163
18119
  */
18164
18120
  this.isPersistent = false;
18165
18121
 
18166
18122
  /**
18167
18123
  * If true, this renderable will be rendered using screen coordinates,
18168
18124
  * as opposed to world coordinates. Use this, for example, to define UI elements.
18169
- * @public
18170
18125
  * @type {boolean}
18171
18126
  * @default false
18172
- * @name floating
18173
- * @memberof Renderable
18174
18127
  */
18175
18128
  this.floating = false;
18176
18129
 
@@ -18185,11 +18138,8 @@ class Renderable extends Rect {
18185
18138
  * <br>
18186
18139
  * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
18187
18140
  * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
18188
- * @public
18189
18141
  * @type {ObservableVector2d}
18190
18142
  * @default <0.5,0.5>
18191
- * @name anchorPoint
18192
- * @memberof Renderable#
18193
18143
  */
18194
18144
  this.anchorPoint = pool.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
18195
18145
  }
@@ -18197,11 +18147,8 @@ class Renderable extends Rect {
18197
18147
  /**
18198
18148
  * When enabled, an object container will automatically apply
18199
18149
  * any defined transformation before calling the child draw method.
18200
- * @public
18201
18150
  * @type {boolean}
18202
18151
  * @default true
18203
- * @name autoTransform
18204
- * @memberof Renderable
18205
18152
  * @example
18206
18153
  * // enable "automatic" transformation when the object is activated
18207
18154
  * onActivateEvent: function () {
@@ -18221,30 +18168,23 @@ class Renderable extends Rect {
18221
18168
  * Set to zero if you do not wish an object to be drawn
18222
18169
  * @see Renderable#setOpacity
18223
18170
  * @see Renderable#getOpacity
18224
- * @public
18225
18171
  * @type {number}
18226
18172
  * @default 1.0
18227
- * @name Renderable#alpha
18228
18173
  */
18229
18174
  this.alpha = 1.0;
18230
18175
 
18231
18176
  /**
18232
18177
  * a reference to the parent object that contains this renderable
18233
- * @public
18234
18178
  * @type {Container|Entity}
18235
18179
  * @default undefined
18236
- * @name Renderable#ancestor
18237
18180
  */
18238
18181
  this.ancestor = undefined;
18239
18182
 
18240
18183
  /**
18241
18184
  * A mask limits rendering elements to the shape and position of the given mask object.
18242
18185
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
18243
- * @public
18244
18186
  * @type {Rect|RoundRect|Polygon|Line|Ellipse}
18245
- * @name mask
18246
18187
  * @default undefined
18247
- * @memberof Renderable#
18248
18188
  * @example
18249
18189
  * // apply a mask in the shape of a Star
18250
18190
  * myNPCSprite.mask = new me.Polygon(myNPCSprite.width / 2, 0, [
@@ -18263,40 +18203,19 @@ class Renderable extends Rect {
18263
18203
  */
18264
18204
  this.mask = undefined;
18265
18205
 
18266
- /**
18267
- * define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
18268
- * @public
18269
- * @type {Color}
18270
- * @name tint
18271
- * @default (255, 255, 255)
18272
- * @memberof Renderable#
18273
- * @example
18274
- * // add a red tint to this renderable
18275
- * this.tint.setColor(255, 128, 128);
18276
- * // remove the tint
18277
- * this.tint.setColor(255, 255, 255);
18278
- */
18279
- this.tint = pool.pull("Color", 255, 255, 255, 1.0);
18280
-
18281
18206
  /**
18282
18207
  * the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
18283
- * @public
18284
18208
  * @type {string}
18285
- * @name blendMode
18286
18209
  * @default "normal"
18287
18210
  * @see CanvasRenderer#setBlendMode
18288
18211
  * @see WebGLRenderer#setBlendMode
18289
- * @memberof Renderable#
18290
18212
  */
18291
18213
  this.blendMode = "normal";
18292
18214
 
18293
18215
  /**
18294
18216
  * The name of the renderable
18295
- * @public
18296
18217
  * @type {string}
18297
- * @name name
18298
18218
  * @default ""
18299
- * @memberof Renderable
18300
18219
  */
18301
18220
  this.name = "";
18302
18221
 
@@ -18307,8 +18226,6 @@ class Renderable extends Rect {
18307
18226
  * Position of the Renderable relative to its parent container
18308
18227
  * @public
18309
18228
  * @type {ObservableVector3d}
18310
- * @name pos
18311
- * @memberof Renderable#
18312
18229
  */
18313
18230
  this.pos = pool.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
18314
18231
  }
@@ -18316,9 +18233,7 @@ class Renderable extends Rect {
18316
18233
  /**
18317
18234
  * when true the renderable will be redrawn during the next update cycle
18318
18235
  * @type {boolean}
18319
- * @name isDirty
18320
18236
  * @default false
18321
- * @memberof Renderable#
18322
18237
  */
18323
18238
  this.isDirty = false;
18324
18239
 
@@ -18337,23 +18252,45 @@ class Renderable extends Rect {
18337
18252
 
18338
18253
  /**
18339
18254
  * Whether the renderable object is floating, or contained in a floating container
18340
- * @public
18341
18255
  * @see Renderable#floating
18342
18256
  * @type {boolean}
18343
- * @name isFloating
18344
- * @memberof Renderable
18345
18257
  */
18346
18258
  get isFloating() {
18347
18259
  return this.floating === true || (typeof this.ancestor !== "undefined" && this.ancestor.floating === true);
18348
18260
  }
18349
18261
 
18262
+ /**
18263
+ * define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
18264
+ * @type {Color}
18265
+ * @default (255, 255, 255)
18266
+ * @example
18267
+ * // add a red tint to this renderable
18268
+ * this.tint.setColor(255, 128, 128);
18269
+ * // remove the tint
18270
+ * this.tint.setColor(255, 255, 255);
18271
+ */
18272
+ get tint() {
18273
+ if (typeof this._tint === "undefined") {
18274
+ this._tint = pool.pull("Color", 255, 255, 255, 1.0);
18275
+ }
18276
+ return this._tint;
18277
+ }
18278
+ set tint(value) {
18279
+ if (typeof this._tint === "undefined") {
18280
+ this._tint = pool.pull("Color", 255, 255, 255, 1.0);
18281
+ }
18282
+ if (value instanceof Color) {
18283
+ this._tint.copy(value);
18284
+ } else {
18285
+ // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
18286
+ this._tint.parseCSS(value);
18287
+ }
18288
+ }
18289
+
18350
18290
  /**
18351
18291
  * Whether the renderable object is visible and within the viewport
18352
- * @public
18353
18292
  * @type {boolean}
18354
18293
  * @default false
18355
- * @name inViewport
18356
- * @memberof Renderable
18357
18294
  */
18358
18295
  get inViewport() {
18359
18296
  return this._inViewport;
@@ -18372,8 +18309,6 @@ class Renderable extends Rect {
18372
18309
  * @public
18373
18310
  * @see Renderable#flipX
18374
18311
  * @type {boolean}
18375
- * @name isFlippedX
18376
- * @memberof Renderable
18377
18312
  */
18378
18313
  get isFlippedX() {
18379
18314
  return this._flip.x === true;
@@ -18384,8 +18319,6 @@ class Renderable extends Rect {
18384
18319
  * @public
18385
18320
  * @see Renderable#flipY
18386
18321
  * @type {boolean}
18387
- * @name isFlippedY
18388
- * @memberof Renderable
18389
18322
  */
18390
18323
  get isFlippedY() {
18391
18324
  return this._flip.y === true;
@@ -18393,8 +18326,6 @@ class Renderable extends Rect {
18393
18326
 
18394
18327
  /**
18395
18328
  * returns the bounding box for this renderable
18396
- * @name getBounds
18397
- * @memberof Renderable
18398
18329
  * @returns {Bounds} bounding box Rectangle object
18399
18330
  */
18400
18331
  getBounds() {
@@ -18413,8 +18344,6 @@ class Renderable extends Rect {
18413
18344
 
18414
18345
  /**
18415
18346
  * get the renderable alpha channel value<br>
18416
- * @name getOpacity
18417
- * @memberof Renderable
18418
18347
  * @returns {number} current opacity value between 0 and 1
18419
18348
  */
18420
18349
  getOpacity() {
@@ -18423,8 +18352,6 @@ class Renderable extends Rect {
18423
18352
 
18424
18353
  /**
18425
18354
  * set the renderable alpha channel value<br>
18426
- * @name setOpacity
18427
- * @memberof Renderable
18428
18355
  * @param {number} alpha opacity value between 0.0 and 1.0
18429
18356
  */
18430
18357
  setOpacity(alpha) {
@@ -18441,8 +18368,6 @@ class Renderable extends Rect {
18441
18368
  /**
18442
18369
  * flip the renderable on the horizontal axis (around the center of the renderable)
18443
18370
  * @see Matrix2d#scaleX
18444
- * @name flipX
18445
- * @memberof Renderable
18446
18371
  * @param {boolean} [flip=true] `true` to flip this renderable.
18447
18372
  * @returns {Renderable} Reference to this object for method chaining
18448
18373
  */
@@ -18455,8 +18380,6 @@ class Renderable extends Rect {
18455
18380
  /**
18456
18381
  * flip the renderable on the vertical axis (around the center of the renderable)
18457
18382
  * @see Matrix2d#scaleY
18458
- * @name flipY
18459
- * @memberof Renderable
18460
18383
  * @param {boolean} [flip=true] `true` to flip this renderable.
18461
18384
  * @returns {Renderable} Reference to this object for method chaining
18462
18385
  */
@@ -18468,8 +18391,6 @@ class Renderable extends Rect {
18468
18391
 
18469
18392
  /**
18470
18393
  * multiply the renderable currentTransform with the given matrix
18471
- * @name transform
18472
- * @memberof Renderable
18473
18394
  * @see Renderable#currentTransform
18474
18395
  * @param {Matrix2d} m the transformation matrix
18475
18396
  * @returns {Renderable} Reference to this object for method chaining
@@ -18484,8 +18405,6 @@ class Renderable extends Rect {
18484
18405
 
18485
18406
  /**
18486
18407
  * return the angle to the specified target
18487
- * @name angleTo
18488
- * @memberof Renderable
18489
18408
  * @param {Renderable|Vector2d|Vector3d} target
18490
18409
  * @returns {number} angle in radians
18491
18410
  */
@@ -18507,8 +18426,6 @@ class Renderable extends Rect {
18507
18426
 
18508
18427
  /**
18509
18428
  * return the distance to the specified target
18510
- * @name distanceTo
18511
- * @memberof Renderable
18512
18429
  * @param {Renderable|Vector2d|Vector3d} target
18513
18430
  * @returns {number} distance
18514
18431
  */
@@ -18530,8 +18447,6 @@ class Renderable extends Rect {
18530
18447
 
18531
18448
  /**
18532
18449
  * Rotate this renderable towards the given target.
18533
- * @name lookAt
18534
- * @memberof Renderable
18535
18450
  * @param {Renderable|Vector2d|Vector3d} target the renderable or position to look at
18536
18451
  * @returns {Renderable} Reference to this object for method chaining
18537
18452
  */
@@ -18553,8 +18468,6 @@ class Renderable extends Rect {
18553
18468
 
18554
18469
  /**
18555
18470
  * Rotate this renderable by the specified angle (in radians).
18556
- * @name rotate
18557
- * @memberof Renderable
18558
18471
  * @param {number} angle The angle to rotate (in radians)
18559
18472
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
18560
18473
  * @returns {Renderable} Reference to this object for method chaining
@@ -18574,8 +18487,6 @@ class Renderable extends Rect {
18574
18487
  * when rendering. It does not scale the object itself. For example if the renderable
18575
18488
  * is an image, the image.width and image.height properties are unaltered but the currentTransform
18576
18489
  * member will be changed.
18577
- * @name scale
18578
- * @memberof Renderable
18579
18490
  * @param {number} x a number representing the abscissa of the scaling vector.
18580
18491
  * @param {number} [y=x] a number representing the ordinate of the scaling vector.
18581
18492
  * @returns {Renderable} Reference to this object for method chaining
@@ -18589,8 +18500,6 @@ class Renderable extends Rect {
18589
18500
 
18590
18501
  /**
18591
18502
  * scale the renderable around his anchor point
18592
- * @name scaleV
18593
- * @memberof Renderable
18594
18503
  * @param {Vector2d} v scaling vector
18595
18504
  * @returns {Renderable} Reference to this object for method chaining
18596
18505
  */
@@ -18600,11 +18509,7 @@ class Renderable extends Rect {
18600
18509
  }
18601
18510
 
18602
18511
  /**
18603
- * update function. <br>
18604
- * automatically called by the game manager {@link game}
18605
- * @name update
18606
- * @memberof Renderable
18607
- * @protected
18512
+ * update function (automatically called by melonJS).
18608
18513
  * @param {number} dt time since the last update in milliseconds.
18609
18514
  * @returns {boolean} true if the renderable is dirty
18610
18515
  */
@@ -18615,8 +18520,6 @@ class Renderable extends Rect {
18615
18520
  /**
18616
18521
  * update the bounding box for this shape.
18617
18522
  * @ignore
18618
- * @name updateBounds
18619
- * @memberof Renderable
18620
18523
  * @returns {Bounds} this shape bounding box Rectangle object
18621
18524
  */
18622
18525
  updateBounds() {
@@ -18628,8 +18531,6 @@ class Renderable extends Rect {
18628
18531
  /**
18629
18532
  * update the renderable's bounding rect (private)
18630
18533
  * @ignore
18631
- * @name updateBoundsPos
18632
- * @memberof Renderable
18633
18534
  */
18634
18535
  updateBoundsPos(newX, newY) {
18635
18536
  var bounds = this.getBounds();
@@ -18660,8 +18561,6 @@ class Renderable extends Rect {
18660
18561
 
18661
18562
  /**
18662
18563
  * return the renderable absolute position in the game world
18663
- * @name getAbsolutePosition
18664
- * @memberof Renderable
18665
18564
  * @returns {Vector2d}
18666
18565
  */
18667
18566
  getAbsolutePosition() {
@@ -18679,8 +18578,6 @@ class Renderable extends Rect {
18679
18578
  /**
18680
18579
  * called when the anchor point value is changed
18681
18580
  * @private
18682
- * @name onAnchorUpdate
18683
- * @memberof Renderable
18684
18581
  * @param {number} x the new X value to be set for the anchor
18685
18582
  * @param {number} y the new Y value to be set for the anchor
18686
18583
  */
@@ -18693,12 +18590,10 @@ class Renderable extends Rect {
18693
18590
  }
18694
18591
 
18695
18592
  /**
18696
- * prepare the rendering context before drawing
18697
- * (apply defined transforms, anchor point). <br>
18698
- * automatically called by the game manager {@link game}
18699
- * @name preDraw
18700
- * @memberof Renderable
18701
- * @protected
18593
+ * Prepare the rendering context before drawing (automatically called by melonJS).
18594
+ * This will apply any defined transforms, anchor point, tint or blend mode and translate the context accordingly to this renderable position.
18595
+ * @see Renderable#draw
18596
+ * @see Renderable#postDraw
18702
18597
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
18703
18598
  */
18704
18599
  preDraw(renderer) {
@@ -18749,10 +18644,15 @@ class Renderable extends Rect {
18749
18644
  }
18750
18645
 
18751
18646
  /**
18752
- * draw this renderable (automatically called by melonJS)
18753
- * @name draw
18754
- * @memberof Renderable
18755
- * @protected
18647
+ * Draw this renderable (automatically called by melonJS).
18648
+ * All draw operations for renderable are made respectively
18649
+ * to the position or transforms set or applied by the preDraw method.
18650
+ * The main draw loop will first call preDraw() to prepare the context for drawing the renderable,
18651
+ * then draw() to draw the renderable, and finally postDraw() to clear the context.
18652
+ * If you override this method, be mindful about the drawing logic; for example if you draw a shape
18653
+ * from the draw method, you should make sure that your draw it at the 0, 0 coordinates.
18654
+ * @see Renderable#preDraw
18655
+ * @see Renderable#postDraw
18756
18656
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
18757
18657
  * @param {Camera2d} [viewport] the viewport to (re)draw
18758
18658
  */
@@ -18761,11 +18661,9 @@ class Renderable extends Rect {
18761
18661
  }
18762
18662
 
18763
18663
  /**
18764
- * restore the rendering context after drawing. <br>
18765
- * automatically called by the game manager {@link game}
18766
- * @name postDraw
18767
- * @memberof Renderable
18768
- * @protected
18664
+ * restore the rendering context after drawing (automatically called by melonJS).
18665
+ * @see Renderable#preDraw
18666
+ * @see Renderable#draw
18769
18667
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
18770
18668
  */
18771
18669
  postDraw(renderer) {
@@ -18787,8 +18685,6 @@ class Renderable extends Rect {
18787
18685
  /**
18788
18686
  * onCollision callback, triggered in case of collision,
18789
18687
  * when this renderable body is colliding with another one
18790
- * @name onCollision
18791
- * @memberof Renderable
18792
18688
  * @param {ResponseObject} response the collision response object
18793
18689
  * @param {Renderable} other the other renderable touching this one (a reference to response.a or response.b)
18794
18690
  * @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
@@ -18840,9 +18736,9 @@ class Renderable extends Rect {
18840
18736
  this.mask = undefined;
18841
18737
  }
18842
18738
 
18843
- if (typeof this.tint !== "undefined") {
18844
- pool.push(this.tint);
18845
- this.tint = undefined;
18739
+ if (typeof this._tint !== "undefined") {
18740
+ pool.push(this._tint);
18741
+ this._tint = undefined;
18846
18742
  }
18847
18743
 
18848
18744
  this.ancestor = undefined;
@@ -18863,8 +18759,6 @@ class Renderable extends Rect {
18863
18759
  /**
18864
18760
  * OnDestroy Notification function<br>
18865
18761
  * Called by engine before deleting the object
18866
- * @name onDestroyEvent
18867
- * @memberof Renderable
18868
18762
  */
18869
18763
  onDestroyEvent() {
18870
18764
  // to be extended !
@@ -19707,7 +19601,7 @@ var collision = {
19707
19601
  class Body {
19708
19602
  /**
19709
19603
  * @param {Renderable} ancestor the parent object this body is attached to
19710
- * @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Bounds|Bounds[]|object} [shapes] a initial shape, list of shapes, or JSON object defining the body
19604
+ * @param {Rect|Rect[]|Polygon|Polygon[]|Line|Line[]|Ellipse|Ellipse[]|Point|Point[]|Bounds|Bounds[]|object} [shapes] a initial shape, list of shapes, or JSON object defining the body
19711
19605
  * @param {Function} [onBodyUpdate] callback for when the body is updated (e.g. add/remove shapes)
19712
19606
  */
19713
19607
  constructor(ancestor, shapes, onBodyUpdate) {
@@ -19734,7 +19628,7 @@ class Body {
19734
19628
  /**
19735
19629
  * The collision shapes of the body
19736
19630
  * @ignore
19737
- * @type {Polygon[]|Line[]|Ellipse[]}
19631
+ * @type {Polygon[]|Line[]|Ellipse[]|Point|Point[]}
19738
19632
  */
19739
19633
  this.shapes = [];
19740
19634
  }
@@ -19926,7 +19820,7 @@ class Body {
19926
19820
  /**
19927
19821
  * add a collision shape to this body <br>
19928
19822
  * (note: me.Rect objects will be converted to me.Polygon before being added)
19929
- * @param {Rect|Polygon|Line|Ellipse|Bounds|object} shape a shape or JSON object
19823
+ * @param {Rect|Polygon|Line|Ellipse|Point|Point[]|Bounds|object} shape a shape or JSON object
19930
19824
  * @returns {number} the shape array length
19931
19825
  * @example
19932
19826
  * // add a rectangle shape
@@ -19961,6 +19855,12 @@ class Body {
19961
19855
  // update the body bounds
19962
19856
  this.bounds.add(shape.points);
19963
19857
  this.bounds.translate(shape.pos);
19858
+ } else if (shape instanceof Point) {
19859
+ if (!this.shapes.includes(shape)) {
19860
+ // see removeShape
19861
+ this.shapes.push(shape);
19862
+ }
19863
+ this.bounds.addPoint(shape);
19964
19864
  } else {
19965
19865
  // JSON object
19966
19866
  this.fromJSON(shape);
@@ -24446,8 +24346,10 @@ class CanvasRenderer extends Renderer {
24446
24346
  * @memberof CanvasRenderer
24447
24347
  */
24448
24348
  clear() {
24449
- if (this.settings.transparent) {
24450
- this.clearColor("rgba(0,0,0,0)", true);
24349
+ if (this.settings.transparent === false) {
24350
+ var canvas = this.getCanvas();
24351
+ var context = this.getContext();
24352
+ context.clearRect(0, 0, canvas.width, canvas.height);
24451
24353
  }
24452
24354
  }
24453
24355
 
@@ -24458,13 +24360,14 @@ class CanvasRenderer extends Renderer {
24458
24360
  * @param {Color|string} [color="#000000"] CSS color.
24459
24361
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
24460
24362
  */
24461
- clearColor(color = "#000000", opaque) {
24363
+ clearColor(color = "#000000", opaque = false) {
24462
24364
  var canvas = this.getCanvas();
24463
24365
  var context = this.getContext();
24464
24366
 
24465
24367
  this.save();
24466
24368
  this.resetTransform();
24467
- context.globalCompositeOperation = opaque ? "copy" : "source-over";
24369
+ context.globalAlpha = 1;
24370
+ context.globalCompositeOperation = opaque === true ? "copy" : "source-over";
24468
24371
  context.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
24469
24372
  this.fillRect(0, 0, canvas.width, canvas.height);
24470
24373
  this.restore();
@@ -24826,6 +24729,30 @@ class CanvasRenderer extends Renderer {
24826
24729
  this.strokeRoundRect(x, y, width, height, radius, true);
24827
24730
  }
24828
24731
 
24732
+ /**
24733
+ * Stroke a Point at the specified coordinates
24734
+ * @name strokePoint
24735
+ * @memberof CanvasRenderer
24736
+ * @param {number} x
24737
+ * @param {number} y
24738
+ */
24739
+ strokePoint(x, y) {
24740
+ this.strokeLine(x, y, x + 1, y + 1);
24741
+ }
24742
+
24743
+ /**
24744
+ * Draw a a point at the specified coordinates
24745
+ * @name fillPoint
24746
+ * @memberof CanvasRenderer
24747
+ * @param {number} x
24748
+ * @param {number} y
24749
+ * @param {number} width
24750
+ * @param {number} height
24751
+ */
24752
+ fillPoint(x, y) {
24753
+ this.strokePoint(x, y);
24754
+ }
24755
+
24829
24756
  /**
24830
24757
  * return a reference to the font 2d Context
24831
24758
  * @ignore
@@ -27036,7 +26963,7 @@ class TMXObject {
27036
26963
  this.type = settings.type;
27037
26964
 
27038
26965
  /**
27039
- * the åobject class
26966
+ * the object class
27040
26967
  * @public
27041
26968
  * @type {string}
27042
26969
  * @name class
@@ -27099,6 +27026,15 @@ class TMXObject {
27099
27026
  */
27100
27027
  this.isEllipse = false;
27101
27028
 
27029
+ /**
27030
+ * if true, the object is a Point
27031
+ * @public
27032
+ * @type {boolean}
27033
+ * @name isPoint
27034
+ * @memberof TMXObject
27035
+ */
27036
+ this.isPoint = false;
27037
+
27102
27038
  /**
27103
27039
  * if true, the object is a Polygon
27104
27040
  * @public
@@ -27122,12 +27058,14 @@ class TMXObject {
27122
27058
  this.setTile(map.tilesets);
27123
27059
  }
27124
27060
  else {
27125
- if (typeof(settings.ellipse) !== "undefined") {
27061
+ if (typeof settings.ellipse !== "undefined") {
27126
27062
  this.isEllipse = true;
27127
- } else if (typeof(settings.polygon) !== "undefined") {
27063
+ } else if (typeof settings.point !== "undefined") {
27064
+ this.isPoint = true;
27065
+ } else if (typeof settings.polygon !== "undefined") {
27128
27066
  this.points = settings.polygon;
27129
27067
  this.isPolygon = true;
27130
- } else if (typeof(settings.polyline) !== "undefined") {
27068
+ } else if (typeof settings.polyline !== "undefined") {
27131
27069
  this.points = settings.polyline;
27132
27070
  this.isPolyLine = true;
27133
27071
  }
@@ -27201,8 +27139,9 @@ class TMXObject {
27201
27139
  this.width,
27202
27140
  this.height
27203
27141
  )).rotate(this.rotation));
27142
+ } else if (this.isPoint === true) {
27143
+ shapes.push(pool.pull("Point", this.x, this.y));
27204
27144
  } else {
27205
-
27206
27145
  // add a polygon
27207
27146
  if (this.isPolygon === true) {
27208
27147
  var _polygon = pool.pull("Polygon", 0, 0, this.points);
@@ -27211,10 +27150,8 @@ class TMXObject {
27211
27150
  throw new Error("collision polygones in Tiled should be defined as Convex");
27212
27151
  }
27213
27152
  shapes.push(_polygon.rotate(this.rotation));
27214
- }
27215
27153
 
27216
- // add a polyline
27217
- else if (this.isPolyLine === true) {
27154
+ } else if (this.isPolyLine === true) {
27218
27155
  var p = this.points;
27219
27156
  var p1, p2;
27220
27157
  var segments = p.length - 1;
@@ -27246,7 +27183,9 @@ class TMXObject {
27246
27183
  // Apply isometric projection
27247
27184
  if (this.orientation === "isometric") {
27248
27185
  for (i = 0; i < shapes.length; i++) {
27249
- shapes[i].toIso();
27186
+ if (typeof shapes[i].toIso === "function") {
27187
+ shapes[i].toIso();
27188
+ }
27250
27189
  }
27251
27190
  }
27252
27191
 
@@ -29233,7 +29172,12 @@ class Sprite extends Renderable {
29233
29172
  }
29234
29173
 
29235
29174
  if (typeof (settings.tint) !== "undefined") {
29236
- this.tint.setColor(settings.tint);
29175
+ if (settings.tint instanceof Color) {
29176
+ this.tint.copy(settings.tint);
29177
+ } else {
29178
+ // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
29179
+ this.tint.parseCSS(settings.tint);
29180
+ }
29237
29181
  }
29238
29182
 
29239
29183
  // set the sprite name if specified
@@ -30777,7 +30721,8 @@ class WebGLRenderer extends Renderer {
30777
30721
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
30778
30722
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
30779
30723
  * @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.
30780
- * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
30724
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
30725
+ * @param {boolean} [options.premultipliedAlpha=true] in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
30781
30726
  * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
30782
30727
  * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
30783
30728
  * @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.
@@ -30792,8 +30737,6 @@ class WebGLRenderer extends Renderer {
30792
30737
 
30793
30738
  /**
30794
30739
  * The WebGL version used by this renderer (1 or 2)
30795
- * @name WebGLVersion
30796
- * @memberof WebGLRenderer#
30797
30740
  * @type {number}
30798
30741
  * @default 1
30799
30742
  * @readonly
@@ -30802,8 +30745,6 @@ class WebGLRenderer extends Renderer {
30802
30745
 
30803
30746
  /**
30804
30747
  * The vendor string of the underlying graphics driver.
30805
- * @name GPUVendor
30806
- * @memberof WebGLRenderer#
30807
30748
  * @type {string}
30808
30749
  * @default null
30809
30750
  * @readonly
@@ -30812,8 +30753,6 @@ class WebGLRenderer extends Renderer {
30812
30753
 
30813
30754
  /**
30814
30755
  * The renderer string of the underlying graphics driver.
30815
- * @name GPURenderer
30816
- * @memberof WebGLRenderer#
30817
30756
  * @type {string}
30818
30757
  * @default null
30819
30758
  * @readonly
@@ -30823,15 +30762,12 @@ class WebGLRenderer extends Renderer {
30823
30762
  /**
30824
30763
  * The WebGL context
30825
30764
  * @name gl
30826
- * @memberof WebGLRenderer
30827
30765
  * @type {WebGLRenderingContext}
30828
30766
  */
30829
30767
  this.context = this.gl = this.getContextGL(this.getCanvas(), options.transparent);
30830
30768
 
30831
30769
  /**
30832
30770
  * Maximum number of texture unit supported under the current context
30833
- * @name maxTextures
30834
- * @memberof WebGLRenderer#
30835
30771
  * @type {number}
30836
30772
  * @readonly
30837
30773
  */
@@ -30859,25 +30795,19 @@ class WebGLRenderer extends Renderer {
30859
30795
 
30860
30796
  /**
30861
30797
  * The current transformation matrix used for transformations on the overall scene
30862
- * @name currentTransform
30863
30798
  * @type {Matrix2d}
30864
- * @memberof WebGLRenderer#
30865
30799
  */
30866
30800
  this.currentTransform = new Matrix2d();
30867
30801
 
30868
30802
  /**
30869
30803
  * The current compositor used by the renderer
30870
- * @name currentCompositor
30871
30804
  * @type {WebGLCompositor}
30872
- * @memberof WebGLRenderer#
30873
30805
  */
30874
30806
  this.currentCompositor = null;
30875
30807
 
30876
30808
  /**
30877
30809
  * The list of active compositors
30878
- * @name compositors
30879
30810
  * @type {Map<WebGLCompositor>}
30880
- * @memberof WebGLRenderer#
30881
30811
  */
30882
30812
  this.compositors = new Map();
30883
30813
 
@@ -30923,8 +30853,6 @@ class WebGLRenderer extends Renderer {
30923
30853
 
30924
30854
  /**
30925
30855
  * Reset context state
30926
- * @name reset
30927
- * @memberof WebGLRenderer
30928
30856
  */
30929
30857
  reset() {
30930
30858
  super.reset();
@@ -30947,9 +30875,7 @@ class WebGLRenderer extends Renderer {
30947
30875
 
30948
30876
  /**
30949
30877
  * set the active compositor for this renderer
30950
- * @name setCompositor
30951
30878
  * @param {WebGLCompositor|string} compositor a compositor name or instance
30952
- * @memberof WebGLRenderer
30953
30879
  */
30954
30880
  setCompositor(compositor = "default") {
30955
30881
 
@@ -30973,8 +30899,6 @@ class WebGLRenderer extends Renderer {
30973
30899
 
30974
30900
  /**
30975
30901
  * Reset the gl transform to identity
30976
- * @name resetTransform
30977
- * @memberof WebGLRenderer
30978
30902
  */
30979
30903
  resetTransform() {
30980
30904
  this.currentTransform.identity();
@@ -31019,8 +30943,6 @@ class WebGLRenderer extends Renderer {
31019
30943
 
31020
30944
  /**
31021
30945
  * Create a pattern with the specified repetition
31022
- * @name createPattern
31023
- * @memberof WebGLRenderer
31024
30946
  * @param {Image} image Source image
31025
30947
  * @param {string} repeat Define how the pattern should be repeated
31026
30948
  * @returns {TextureAtlas}
@@ -31051,8 +30973,6 @@ class WebGLRenderer extends Renderer {
31051
30973
 
31052
30974
  /**
31053
30975
  * Flush the compositor to the frame buffer
31054
- * @name flush
31055
- * @memberof WebGLRenderer
31056
30976
  */
31057
30977
  flush() {
31058
30978
  this.currentCompositor.flush();
@@ -31060,8 +30980,6 @@ class WebGLRenderer extends Renderer {
31060
30980
 
31061
30981
  /**
31062
30982
  * set/change the current projection matrix (WebGL only)
31063
- * @name setProjection
31064
- * @memberof WebGLRenderer
31065
30983
  * @param {Matrix3d} matrix
31066
30984
  */
31067
30985
  setProjection(matrix) {
@@ -31069,10 +30987,15 @@ class WebGLRenderer extends Renderer {
31069
30987
  this.currentCompositor.setProjection(matrix);
31070
30988
  }
31071
30989
 
30990
+ /**
30991
+ * prepare the framebuffer for drawing a new frame
30992
+ */
30993
+ clear() {
30994
+ this.currentCompositor.clear(this.settings.transparent ? 0.0 : 1.0);
30995
+ }
30996
+
31072
30997
  /**
31073
30998
  * Clears the gl context with the given color.
31074
- * @name clearColor
31075
- * @memberof WebGLRenderer
31076
30999
  * @param {Color|string} [color="#000000"] CSS color.
31077
31000
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
31078
31001
  */
@@ -31089,17 +31012,10 @@ class WebGLRenderer extends Renderer {
31089
31012
  }
31090
31013
  // clear gl context with the specified color
31091
31014
  this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
31092
- this.currentCompositor.clear();
31093
-
31094
- // restore default clear Color black
31095
- this.currentCompositor.clearColor(0.0, 0.0, 0.0, 0.0);
31096
-
31097
31015
  }
31098
31016
 
31099
31017
  /**
31100
31018
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
31101
- * @name clearRect
31102
- * @memberof WebGLRenderer
31103
31019
  * @param {number} x x axis of the coordinate for the rectangle starting point.
31104
31020
  * @param {number} y y axis of the coordinate for the rectangle starting point.
31105
31021
  * @param {number} width The rectangle's width.
@@ -31133,7 +31049,7 @@ class WebGLRenderer extends Renderer {
31133
31049
  uvs[1],
31134
31050
  uvs[2],
31135
31051
  uvs[3],
31136
- this.currentTint.toUint32()
31052
+ this.currentTint.toUint32(this.getGlobalAlpha())
31137
31053
  );
31138
31054
 
31139
31055
  // Clear font context2D
@@ -31147,8 +31063,6 @@ class WebGLRenderer extends Renderer {
31147
31063
 
31148
31064
  /**
31149
31065
  * Draw an image to the gl context
31150
- * @name drawImage
31151
- * @memberof WebGLRenderer
31152
31066
  * @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.
31153
31067
  * @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.
31154
31068
  * @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.
@@ -31194,13 +31108,11 @@ class WebGLRenderer extends Renderer {
31194
31108
 
31195
31109
  var texture = this.cache.get(image);
31196
31110
  var uvs = texture.getUVs(sx + "," + sy + "," + sw + "," + sh);
31197
- this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
31111
+ this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
31198
31112
  }
31199
31113
 
31200
31114
  /**
31201
31115
  * Draw a pattern within the given rectangle.
31202
- * @name drawPattern
31203
- * @memberof WebGLRenderer
31204
31116
  * @param {TextureAtlas} pattern Pattern object
31205
31117
  * @param {number} x
31206
31118
  * @param {number} y
@@ -31210,18 +31122,16 @@ class WebGLRenderer extends Renderer {
31210
31122
  */
31211
31123
  drawPattern(pattern, x, y, width, height) {
31212
31124
  var uvs = pattern.getUVs("0,0," + width + "," + height);
31213
- this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
31125
+ this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
31214
31126
  }
31215
31127
 
31216
31128
  /**
31217
- * Returns the WebGL Context object of the given Canvas
31218
- * @name getContextGL
31219
- * @memberof WebGLRenderer
31129
+ * Returns the WebGL Context object of the given canvas element
31220
31130
  * @param {HTMLCanvasElement} canvas
31221
- * @param {boolean} [transparent=true] use false to disable transparency
31131
+ * @param {boolean} [transparent=false] use true to enable transparency
31222
31132
  * @returns {WebGLRenderingContext}
31223
31133
  */
31224
- getContextGL(canvas, transparent) {
31134
+ getContextGL(canvas, transparent = false) {
31225
31135
  if (typeof canvas === "undefined" || canvas === null) {
31226
31136
  throw new Error(
31227
31137
  "You must pass a canvas element in order to create " +
@@ -31229,17 +31139,13 @@ class WebGLRenderer extends Renderer {
31229
31139
  );
31230
31140
  }
31231
31141
 
31232
- if (typeof transparent !== "boolean") {
31233
- transparent = true;
31234
- }
31235
-
31236
31142
  var attr = {
31237
31143
  alpha : transparent,
31238
31144
  antialias : this.settings.antiAlias,
31239
31145
  depth : false,
31240
31146
  stencil: true,
31241
31147
  preserveDrawingBuffer : false,
31242
- premultipliedAlpha: transparent,
31148
+ premultipliedAlpha: transparent ? this.settings.premultipliedAlpha : false,
31243
31149
  powerPreference: this.settings.powerPreference,
31244
31150
  failIfMajorPerformanceCaveat : this.settings.failIfMajorPerformanceCaveat
31245
31151
  };
@@ -31272,8 +31178,6 @@ class WebGLRenderer extends Renderer {
31272
31178
  /**
31273
31179
  * Returns the WebGLContext instance for the renderer
31274
31180
  * return a reference to the system 2d Context
31275
- * @name getContext
31276
- * @memberof WebGLRenderer
31277
31181
  * @returns {WebGLRenderingContext}
31278
31182
  */
31279
31183
  getContext() {
@@ -31291,9 +31195,7 @@ class WebGLRenderer extends Renderer {
31291
31195
  * <img src="images/lighter-blendmode.png" width="510"/> <br>
31292
31196
  * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
31293
31197
  * <img src="images/screen-blendmode.png" width="510"/> <br>
31294
- * @name setBlendMode
31295
31198
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
31296
- * @memberof WebGLRenderer
31297
31199
  * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
31298
31200
  * @param {WebGLRenderingContext} [gl]
31299
31201
  */
@@ -31342,8 +31244,6 @@ class WebGLRenderer extends Renderer {
31342
31244
 
31343
31245
  /**
31344
31246
  * restores the canvas context
31345
- * @name restore
31346
- * @memberof WebGLRenderer
31347
31247
  */
31348
31248
  restore() {
31349
31249
  // do nothing if there is no saved states
@@ -31377,8 +31277,6 @@ class WebGLRenderer extends Renderer {
31377
31277
 
31378
31278
  /**
31379
31279
  * saves the canvas context
31380
- * @name save
31381
- * @memberof WebGLRenderer
31382
31280
  */
31383
31281
  save() {
31384
31282
  this._colorStack.push(this.currentColor.clone());
@@ -31394,8 +31292,6 @@ class WebGLRenderer extends Renderer {
31394
31292
 
31395
31293
  /**
31396
31294
  * rotates the uniform matrix
31397
- * @name rotate
31398
- * @memberof WebGLRenderer
31399
31295
  * @param {number} angle in radians
31400
31296
  */
31401
31297
  rotate(angle) {
@@ -31404,8 +31300,6 @@ class WebGLRenderer extends Renderer {
31404
31300
 
31405
31301
  /**
31406
31302
  * scales the uniform matrix
31407
- * @name scale
31408
- * @memberof WebGLRenderer
31409
31303
  * @param {number} x
31410
31304
  * @param {number} y
31411
31305
  */
@@ -31424,8 +31318,6 @@ class WebGLRenderer extends Renderer {
31424
31318
 
31425
31319
  /**
31426
31320
  * Set the global alpha
31427
- * @name setGlobalAlpha
31428
- * @memberof WebGLRenderer
31429
31321
  * @param {number} alpha 0.0 to 1.0 values accepted.
31430
31322
  */
31431
31323
  setGlobalAlpha(alpha) {
@@ -31434,8 +31326,6 @@ class WebGLRenderer extends Renderer {
31434
31326
 
31435
31327
  /**
31436
31328
  * Return the global alpha
31437
- * @name getGlobalAlpha
31438
- * @memberof WebGLRenderer
31439
31329
  * @returns {number} global alpha value
31440
31330
  */
31441
31331
  getGlobalAlpha() {
@@ -31445,8 +31335,6 @@ class WebGLRenderer extends Renderer {
31445
31335
  /**
31446
31336
  * Set the current fill & stroke style color.
31447
31337
  * By default, or upon reset, the value is set to #000000.
31448
- * @name setColor
31449
- * @memberof WebGLRenderer
31450
31338
  * @param {Color|string} color css color string.
31451
31339
  */
31452
31340
  setColor(color) {
@@ -31457,8 +31345,6 @@ class WebGLRenderer extends Renderer {
31457
31345
 
31458
31346
  /**
31459
31347
  * Set the line width
31460
- * @name setLineWidth
31461
- * @memberof WebGLRenderer
31462
31348
  * @param {number} width Line width
31463
31349
  */
31464
31350
  setLineWidth(width) {
@@ -31467,8 +31353,6 @@ class WebGLRenderer extends Renderer {
31467
31353
 
31468
31354
  /**
31469
31355
  * Stroke an arc at the specified coordinates with given radius, start and end points
31470
- * @name strokeArc
31471
- * @memberof WebGLRenderer
31472
31356
  * @param {number} x arc center point x-axis
31473
31357
  * @param {number} y arc center point y-axis
31474
31358
  * @param {number} radius
@@ -31494,8 +31378,6 @@ class WebGLRenderer extends Renderer {
31494
31378
 
31495
31379
  /**
31496
31380
  * Fill an arc at the specified coordinates with given radius, start and end points
31497
- * @name fillArc
31498
- * @memberof WebGLRenderer
31499
31381
  * @param {number} x arc center point x-axis
31500
31382
  * @param {number} y arc center point y-axis
31501
31383
  * @param {number} radius
@@ -31509,8 +31391,6 @@ class WebGLRenderer extends Renderer {
31509
31391
 
31510
31392
  /**
31511
31393
  * Stroke an ellipse at the specified coordinates with given radius
31512
- * @name strokeEllipse
31513
- * @memberof WebGLRenderer
31514
31394
  * @param {number} x ellipse center point x-axis
31515
31395
  * @param {number} y ellipse center point y-axis
31516
31396
  * @param {number} w horizontal radius of the ellipse
@@ -31534,8 +31414,6 @@ class WebGLRenderer extends Renderer {
31534
31414
 
31535
31415
  /**
31536
31416
  * Fill an ellipse at the specified coordinates with given radius
31537
- * @name fillEllipse
31538
- * @memberof WebGLRenderer
31539
31417
  * @param {number} x ellipse center point x-axis
31540
31418
  * @param {number} y ellipse center point y-axis
31541
31419
  * @param {number} w horizontal radius of the ellipse
@@ -31547,8 +31425,6 @@ class WebGLRenderer extends Renderer {
31547
31425
 
31548
31426
  /**
31549
31427
  * Stroke a line of the given two points
31550
- * @name strokeLine
31551
- * @memberof WebGLRenderer
31552
31428
  * @param {number} startX the start x coordinate
31553
31429
  * @param {number} startY the start y coordinate
31554
31430
  * @param {number} endX the end x coordinate
@@ -31568,8 +31444,6 @@ class WebGLRenderer extends Renderer {
31568
31444
 
31569
31445
  /**
31570
31446
  * Fill a line of the given two points
31571
- * @name fillLine
31572
- * @memberof WebGLRenderer
31573
31447
  * @param {number} startX the start x coordinate
31574
31448
  * @param {number} startY the start y coordinate
31575
31449
  * @param {number} endX the end x coordinate
@@ -31581,8 +31455,6 @@ class WebGLRenderer extends Renderer {
31581
31455
 
31582
31456
  /**
31583
31457
  * Stroke a me.Polygon on the screen with a specified color
31584
- * @name strokePolygon
31585
- * @memberof WebGLRenderer
31586
31458
  * @param {Polygon} poly the shape to draw
31587
31459
  * @param {boolean} [fill=false] also fill the shape with the current color if true
31588
31460
  */
@@ -31612,8 +31484,6 @@ class WebGLRenderer extends Renderer {
31612
31484
 
31613
31485
  /**
31614
31486
  * Fill a me.Polygon on the screen
31615
- * @name fillPolygon
31616
- * @memberof WebGLRenderer
31617
31487
  * @param {Polygon} poly the shape to draw
31618
31488
  */
31619
31489
  fillPolygon(poly) {
@@ -31622,8 +31492,6 @@ class WebGLRenderer extends Renderer {
31622
31492
 
31623
31493
  /**
31624
31494
  * Draw a stroke rectangle at the specified coordinates
31625
- * @name strokeRect
31626
- * @memberof WebGLRenderer
31627
31495
  * @param {number} x
31628
31496
  * @param {number} y
31629
31497
  * @param {number} width
@@ -31646,8 +31514,6 @@ class WebGLRenderer extends Renderer {
31646
31514
 
31647
31515
  /**
31648
31516
  * Draw a filled rectangle at the specified coordinates
31649
- * @name fillRect
31650
- * @memberof WebGLRenderer
31651
31517
  * @param {number} x
31652
31518
  * @param {number} y
31653
31519
  * @param {number} width
@@ -31659,8 +31525,6 @@ class WebGLRenderer extends Renderer {
31659
31525
 
31660
31526
  /**
31661
31527
  * Stroke a rounded rectangle at the specified coordinates
31662
- * @name strokeRoundRect
31663
- * @memberof WebGLRenderer
31664
31528
  * @param {number} x
31665
31529
  * @param {number} y
31666
31530
  * @param {number} width
@@ -31685,8 +31549,6 @@ class WebGLRenderer extends Renderer {
31685
31549
 
31686
31550
  /**
31687
31551
  * Draw a rounded filled rectangle at the specified coordinates
31688
- * @name fillRoundRect
31689
- * @memberof WebGLRenderer
31690
31552
  * @param {number} x
31691
31553
  * @param {number} y
31692
31554
  * @param {number} width
@@ -31697,11 +31559,29 @@ class WebGLRenderer extends Renderer {
31697
31559
  this.strokeRoundRect(x, y, width, height, radius, true);
31698
31560
  }
31699
31561
 
31562
+ /**
31563
+ * Stroke a Point at the specified coordinates
31564
+ * @param {number} x
31565
+ * @param {number} y
31566
+ */
31567
+ strokePoint(x, y) {
31568
+ this.strokeLine(x, y, x + 1, y + 1);
31569
+ }
31570
+
31571
+ /**
31572
+ * Draw a a point at the specified coordinates
31573
+ * @param {number} x
31574
+ * @param {number} y
31575
+ * @param {number} width
31576
+ * @param {number} height
31577
+ */
31578
+ fillPoint(x, y) {
31579
+ this.strokePoint(x, y);
31580
+ }
31581
+
31700
31582
  /**
31701
31583
  * Reset (overrides) the renderer transformation matrix to the
31702
31584
  * identity one, and then apply the given transformation matrix.
31703
- * @name setTransform
31704
- * @memberof WebGLRenderer
31705
31585
  * @param {Matrix2d} mat2d Matrix to transform by
31706
31586
  */
31707
31587
  setTransform(mat2d) {
@@ -31711,8 +31591,6 @@ class WebGLRenderer extends Renderer {
31711
31591
 
31712
31592
  /**
31713
31593
  * Multiply given matrix into the renderer tranformation matrix
31714
- * @name transform
31715
- * @memberof WebGLRenderer
31716
31594
  * @param {Matrix2d} mat2d Matrix to transform by
31717
31595
  */
31718
31596
  transform(mat2d) {
@@ -31728,8 +31606,6 @@ class WebGLRenderer extends Renderer {
31728
31606
 
31729
31607
  /**
31730
31608
  * Translates the uniform matrix by the given coordinates
31731
- * @name translate
31732
- * @memberof WebGLRenderer
31733
31609
  * @param {number} x
31734
31610
  * @param {number} y
31735
31611
  */
@@ -31750,8 +31626,6 @@ class WebGLRenderer extends Renderer {
31750
31626
  * You can however save the current region using the save(),
31751
31627
  * and restore it (with the restore() method) any time in the future.
31752
31628
  * (<u>this is an experimental feature !</u>)
31753
- * @name clipRect
31754
- * @memberof WebGLRenderer
31755
31629
  * @param {number} x
31756
31630
  * @param {number} y
31757
31631
  * @param {number} width
@@ -31797,8 +31671,6 @@ class WebGLRenderer extends Renderer {
31797
31671
  * A mask limits rendering elements to the shape and position of the given mask object.
31798
31672
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
31799
31673
  * Mask are not preserved through renderer context save and restore.
31800
- * @name setMask
31801
- * @memberof WebGLRenderer
31802
31674
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
31803
31675
  * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
31804
31676
  */
@@ -31812,8 +31684,6 @@ class WebGLRenderer extends Renderer {
31812
31684
  // Enable and setup GL state to write to stencil buffer
31813
31685
  gl.enable(gl.STENCIL_TEST);
31814
31686
  gl.clear(gl.STENCIL_BUFFER_BIT);
31815
-
31816
-
31817
31687
  }
31818
31688
 
31819
31689
  this.maskLevel++;
@@ -31842,9 +31712,7 @@ class WebGLRenderer extends Renderer {
31842
31712
 
31843
31713
  /**
31844
31714
  * disable (remove) the rendering mask set through setMask.
31845
- * @name clearMask
31846
31715
  * @see WebGLRenderer#setMask
31847
- * @memberof WebGLRenderer
31848
31716
  */
31849
31717
  clearMask() {
31850
31718
  if (this.maskLevel > 0) {
@@ -31873,6 +31741,7 @@ var settings = {
31873
31741
  scale : 1.0,
31874
31742
  scaleMethod : "manual",
31875
31743
  transparent : false,
31744
+ premultipliedAlpha: true,
31876
31745
  blendMode : "normal",
31877
31746
  antiAlias : false,
31878
31747
  failIfMajorPerformanceCaveat : true,
@@ -33010,10 +32879,10 @@ class BasePlugin {
33010
32879
  * this can be overridden by the plugin
33011
32880
  * @public
33012
32881
  * @type {string}
33013
- * @default "13.1.1"
32882
+ * @default "13.2.0"
33014
32883
  * @name plugin.Base#version
33015
32884
  */
33016
- this.version = "13.1.1";
32885
+ this.version = "13.2.0";
33017
32886
  }
33018
32887
  }
33019
32888
 
@@ -34256,7 +34125,7 @@ class TextMetrics extends Bounds {
34256
34125
  this.width = this.height = 0;
34257
34126
 
34258
34127
  for (var i = 0; i < strings.length; i++) {
34259
- this.width = Math.max(this.lineWidth(strings[i].trimRight(), context), this.width);
34128
+ this.width = Math.max(this.lineWidth(strings[i].trimEnd(), context), this.width);
34260
34129
  this.height += this.lineHeight();
34261
34130
  }
34262
34131
  this.width = Math.ceil(this.width);
@@ -34731,7 +34600,7 @@ class Text extends Renderable {
34731
34600
  setContextStyle(context, this, stroke);
34732
34601
 
34733
34602
  for (var i = 0; i < text.length; i++) {
34734
- var string = text[i].trimRight();
34603
+ var string = text[i].trimEnd();
34735
34604
  // draw the string
34736
34605
  context[stroke ? "strokeText" : "fillText"](string, x, y);
34737
34606
  // add leading space
@@ -34876,12 +34745,7 @@ class BitmapText extends Renderable {
34876
34745
 
34877
34746
  // apply given fillstyle
34878
34747
  if (typeof settings.fillStyle !== "undefined") {
34879
- if (settings.fillStyle instanceof Color) {
34880
- this.fillStyle.setColor(settings.fillStyle);
34881
- } else {
34882
- // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
34883
- this.fillStyle.parseCSS(settings.fillStyle);
34884
- }
34748
+ this.fillStyle = settings.fillStyle;
34885
34749
  }
34886
34750
 
34887
34751
  // update anchorPoint if provided
@@ -34954,7 +34818,12 @@ class BitmapText extends Renderable {
34954
34818
  return this.tint;
34955
34819
  }
34956
34820
  set fillStyle(value) {
34957
- this.tint = value;
34821
+ if (value instanceof Color) {
34822
+ this.tint.copy(value);
34823
+ } else {
34824
+ // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
34825
+ this.tint.parseCSS(value);
34826
+ }
34958
34827
  }
34959
34828
 
34960
34829
  /**
@@ -35011,7 +34880,7 @@ class BitmapText extends Renderable {
35011
34880
 
35012
34881
  for (var i = 0; i < this._text.length; i++) {
35013
34882
  x = lX;
35014
- var string = this._text[i].trimRight();
34883
+ var string = this._text[i].trimEnd();
35015
34884
  // adjust x pos based on alignment value
35016
34885
  var stringWidth = this.metrics.lineWidth(string);
35017
34886
  switch (this.textAlign) {
@@ -37822,7 +37691,7 @@ Renderer.prototype.getScreenContext = function() {
37822
37691
  * @name version
37823
37692
  * @type {string}
37824
37693
  */
37825
- const version = "13.1.1";
37694
+ const version = "13.2.0";
37826
37695
 
37827
37696
 
37828
37697
  /**
@@ -37881,6 +37750,7 @@ function boot() {
37881
37750
  pool.register("me.RoundRect", RoundRect, true);
37882
37751
  pool.register("me.Polygon", Polygon, true);
37883
37752
  pool.register("me.Line", Line, true);
37753
+ pool.register("me.Point", Point, true);
37884
37754
  pool.register("me.Ellipse", Ellipse, true);
37885
37755
  pool.register("me.Bounds", Bounds, true);
37886
37756
 
@@ -37910,6 +37780,7 @@ function boot() {
37910
37780
  pool.register("RoundRect", RoundRect, true);
37911
37781
  pool.register("Polygon", Polygon, true);
37912
37782
  pool.register("Line", Line, true);
37783
+ pool.register("Point", Point, true);
37913
37784
  pool.register("Ellipse", Ellipse, true);
37914
37785
  pool.register("Bounds", Bounds, true);
37915
37786
  pool.register("CanvasTexture", CanvasTexture, true);
@@ -37933,4 +37804,4 @@ onReady(function () {
37933
37804
  }
37934
37805
  });
37935
37806
 
37936
- export { BitmapText, BitmapTextData, Body, Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Light2d, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state, timer, utils, version, video, warning };
37807
+ export { BitmapText, BitmapTextData, Body, Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Light2d, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Point, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, RoundRect, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state, timer, utils, version, video, warning };