melonjs 10.2.1 → 10.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/melonjs.js +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
package/src/utils/array.js
CHANGED
|
@@ -13,8 +13,8 @@ import {random as mathRandom, weightedRandom as mathWeightedRandom} from "./../m
|
|
|
13
13
|
* @memberOf me.utils.array
|
|
14
14
|
* @name remove
|
|
15
15
|
* @param {Array} arr array from which to remove an object
|
|
16
|
-
* @param {
|
|
17
|
-
* @
|
|
16
|
+
* @param {object} obj to be removed
|
|
17
|
+
* @returns {Array} the modified Array
|
|
18
18
|
* var arr = [ "foo", "bar", "baz" ];
|
|
19
19
|
* // remove "foo" from the array
|
|
20
20
|
* me.utils.array.remove(arr, "foo");
|
|
@@ -34,7 +34,7 @@ export function remove(arr, obj) {
|
|
|
34
34
|
* @memberOf me.utils.array
|
|
35
35
|
* @name random
|
|
36
36
|
* @param {Array} arr array to pick a element
|
|
37
|
-
* @
|
|
37
|
+
* @returns {any} random member of array
|
|
38
38
|
* @example
|
|
39
39
|
* // Select a random array element
|
|
40
40
|
* var arr = [ "foo", "bar", "baz" ];
|
|
@@ -51,7 +51,7 @@ export function random(arr) {
|
|
|
51
51
|
* @memberOf me.utils.array
|
|
52
52
|
* @name weightedRandom
|
|
53
53
|
* @param {Array} arr array to pick a element
|
|
54
|
-
* @
|
|
54
|
+
* @returns {any} random member of array
|
|
55
55
|
*/
|
|
56
56
|
export function weightedRandom(arr) {
|
|
57
57
|
return arr[mathWeightedRandom(0, arr.length)];
|
package/src/utils/file.js
CHANGED
|
@@ -16,8 +16,8 @@ const REMOVE_EXT = /\.[^\.]*$/;
|
|
|
16
16
|
* @function
|
|
17
17
|
* @memberOf me.utils.file
|
|
18
18
|
* @name getBasename
|
|
19
|
-
* @param {
|
|
20
|
-
* @
|
|
19
|
+
* @param {string} path path containing the filename
|
|
20
|
+
* @returns {string} the base name without path information.
|
|
21
21
|
*/
|
|
22
22
|
export function getBasename(path) {
|
|
23
23
|
return path.replace(REMOVE_PATH, "").replace(REMOVE_EXT, "");
|
|
@@ -29,8 +29,8 @@ export function getBasename(path) {
|
|
|
29
29
|
* @function
|
|
30
30
|
* @memberOf me.utils.file
|
|
31
31
|
* @name getExtension
|
|
32
|
-
* @param {
|
|
33
|
-
* @
|
|
32
|
+
* @param {string} path path containing the filename
|
|
33
|
+
* @returns {string} filename extension.
|
|
34
34
|
*/
|
|
35
35
|
export function getExtension(path) {
|
|
36
36
|
return path.substring(path.lastIndexOf(".") + 1, path.length);
|
package/src/utils/function.js
CHANGED
|
@@ -4,17 +4,16 @@
|
|
|
4
4
|
* @memberOf me
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Executes a function as soon as the interpreter is idle (stack empty).
|
|
10
9
|
* @public
|
|
11
10
|
* @function
|
|
12
11
|
* @memberOf me.utils.function
|
|
13
12
|
* @name defer
|
|
14
|
-
* @param {Function}
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {Function} func The function to be deferred.
|
|
14
|
+
* @param {object} thisArg The value to be passed as the this parameter to the target function when the deferred function is called
|
|
16
15
|
* @param {...*} [args] Optional additional arguments to carry for the function.
|
|
17
|
-
* @
|
|
16
|
+
* @returns {number} id that can be used to clear the deferred function using
|
|
18
17
|
* clearTimeout
|
|
19
18
|
* @example
|
|
20
19
|
* // execute myFunc() when the stack is empty,
|
|
@@ -33,8 +32,9 @@ export function defer(func, thisArg, ...args) {
|
|
|
33
32
|
* @memberOf me.utils.function
|
|
34
33
|
* @name throttle
|
|
35
34
|
* @param {Function} fn the function to be throttled.
|
|
36
|
-
* @param {
|
|
35
|
+
* @param {number} delay The delay in ms
|
|
37
36
|
* @param {no_trailing} no_trailing disable the execution on the trailing edge
|
|
37
|
+
* @returns {Function} the function that will be throttled
|
|
38
38
|
*/
|
|
39
39
|
export function throttle(fn, delay, no_trailing) {
|
|
40
40
|
var last = window.performance.now(), deferTimer;
|
package/src/utils/string.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* @function
|
|
12
12
|
* @memberOf me.utils.string
|
|
13
13
|
* @name capitalize
|
|
14
|
-
* @param {
|
|
15
|
-
* @
|
|
14
|
+
* @param {string} str the string to be capitalized
|
|
15
|
+
* @returns {string} the capitalized string
|
|
16
16
|
*/
|
|
17
17
|
export function capitalize(str) {
|
|
18
18
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -24,8 +24,8 @@ export function capitalize(str) {
|
|
|
24
24
|
* @function
|
|
25
25
|
* @memberOf me.utils.string
|
|
26
26
|
* @name trimLeft
|
|
27
|
-
* @param {
|
|
28
|
-
* @
|
|
27
|
+
* @param {string} str the string to be trimmed
|
|
28
|
+
* @returns {string} trimmed string
|
|
29
29
|
*/
|
|
30
30
|
export function trimLeft(str) {
|
|
31
31
|
return str.replace(/^\s+/, "");
|
|
@@ -37,8 +37,8 @@ export function trimLeft(str) {
|
|
|
37
37
|
* @function
|
|
38
38
|
* @memberOf me.utils.string
|
|
39
39
|
* @name trimRight
|
|
40
|
-
* @param {
|
|
41
|
-
* @
|
|
40
|
+
* @param {string} str the string to be trimmed
|
|
41
|
+
* @returns {string} trimmed string
|
|
42
42
|
*/
|
|
43
43
|
export function trimRight(str) {
|
|
44
44
|
return str.replace(/\s+$/, "");
|
|
@@ -50,8 +50,8 @@ export function trimRight(str) {
|
|
|
50
50
|
* @function
|
|
51
51
|
* @memberOf me.utils.string
|
|
52
52
|
* @name isNumeric
|
|
53
|
-
* @param {
|
|
54
|
-
* @
|
|
53
|
+
* @param {string} str the string to be tested
|
|
54
|
+
* @returns {boolean} true if string contains only digits
|
|
55
55
|
*/
|
|
56
56
|
export function isNumeric(str) {
|
|
57
57
|
if (typeof str === "string") {
|
|
@@ -66,8 +66,8 @@ export function isNumeric(str) {
|
|
|
66
66
|
* @function
|
|
67
67
|
* @memberOf me.utils.string
|
|
68
68
|
* @name isBoolean
|
|
69
|
-
* @param {
|
|
70
|
-
* @
|
|
69
|
+
* @param {string} str the string to be tested
|
|
70
|
+
* @returns {boolean} true if the string is either true or false
|
|
71
71
|
*/
|
|
72
72
|
export function isBoolean(str) {
|
|
73
73
|
var trimmed = str.trim();
|
|
@@ -80,8 +80,8 @@ export function isBoolean(str) {
|
|
|
80
80
|
* @function
|
|
81
81
|
* @memberOf me.utils.string
|
|
82
82
|
* @name toHex
|
|
83
|
-
* @param {
|
|
84
|
-
* @
|
|
83
|
+
* @param {string} str the string to be converted
|
|
84
|
+
* @returns {string} the converted hexadecimal value
|
|
85
85
|
*/
|
|
86
86
|
export function toHex(str) {
|
|
87
87
|
var res = "", c = 0;
|
package/src/utils/utils.js
CHANGED
|
@@ -31,20 +31,20 @@ var utils = {
|
|
|
31
31
|
* @function
|
|
32
32
|
* @memberOf me.utils
|
|
33
33
|
* @name getPixels
|
|
34
|
-
* @param {
|
|
35
|
-
* @
|
|
34
|
+
* @param {HTMLImageElement|HTMLCanvasElement} image Image to read
|
|
35
|
+
* @returns {ImageData} ImageData object
|
|
36
36
|
*/
|
|
37
|
-
getPixels : function (
|
|
38
|
-
if (
|
|
37
|
+
getPixels : function (image) {
|
|
38
|
+
if (image instanceof HTMLImageElement) {
|
|
39
39
|
var _context = CanvasRenderer.getContext2d(
|
|
40
|
-
createCanvas(
|
|
40
|
+
createCanvas(image.width, image.height)
|
|
41
41
|
);
|
|
42
|
-
_context.drawImage(
|
|
43
|
-
return _context.getImageData(0, 0,
|
|
42
|
+
_context.drawImage(image, 0, 0);
|
|
43
|
+
return _context.getImageData(0, 0, image.width, image.height);
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
46
|
// canvas !
|
|
47
|
-
return
|
|
47
|
+
return image.getContext("2d").getImageData(0, 0, image.width, image.height);
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
|
|
@@ -54,9 +54,9 @@ var utils = {
|
|
|
54
54
|
* @function
|
|
55
55
|
* @memberOf me.utils
|
|
56
56
|
* @name checkVersion
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
57
|
+
* @param {string} first First version string to compare
|
|
58
|
+
* @param {string} [second=me.version] Second version string to compare
|
|
59
|
+
* @returns {number} comparison result <br>< 0 : first < second<br>
|
|
60
60
|
* 0 : first == second<br>
|
|
61
61
|
* > 0 : first > second
|
|
62
62
|
* @example
|
|
@@ -87,14 +87,14 @@ var utils = {
|
|
|
87
87
|
* @function
|
|
88
88
|
* @memberOf me.utils
|
|
89
89
|
* @name getUriFragment
|
|
90
|
-
* @param {
|
|
91
|
-
* @
|
|
92
|
-
* @property {
|
|
93
|
-
* @property {
|
|
94
|
-
* @property {
|
|
95
|
-
* @property {
|
|
96
|
-
* @property {
|
|
97
|
-
* @property {
|
|
90
|
+
* @param {string} [url=document.location] an optional params string or URL containing fragment (hash) params to be parsed
|
|
91
|
+
* @returns {object} an object representing the deserialized params string.
|
|
92
|
+
* @property {boolean} [hitbox=false] draw the hitbox in the debug panel (if enabled)
|
|
93
|
+
* @property {boolean} [velocity=false] draw the entities velocity in the debug panel (if enabled)
|
|
94
|
+
* @property {boolean} [quadtree=false] draw the quadtree in the debug panel (if enabled)
|
|
95
|
+
* @property {boolean} [webgl=false] force the renderer to WebGL
|
|
96
|
+
* @property {boolean} [debug=false] display the debug panel (if preloaded)
|
|
97
|
+
* @property {string} [debugToggleKey="s"] show/hide the debug panel (if preloaded)
|
|
98
98
|
* @example
|
|
99
99
|
* // http://www.example.com/index.html#debug&hitbox=true&mytag=value
|
|
100
100
|
* var UriFragment = me.utils.getUriFragment();
|
|
@@ -13,17 +13,17 @@ import { createCanvas } from "./../video.js";
|
|
|
13
13
|
* @extends me.Renderer
|
|
14
14
|
* @memberOf me
|
|
15
15
|
* @constructor
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
16
|
+
* @param {object} options The renderer parameters
|
|
17
|
+
* @param {number} options.width The width of the canvas without scaling
|
|
18
|
+
* @param {number} options.height The height of the canvas without scaling
|
|
19
19
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
20
|
+
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
21
|
+
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
22
|
+
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
23
|
+
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
24
|
+
* @param {boolean} [options.textureSeamFix=true] enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
|
|
25
|
+
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
26
|
+
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
27
27
|
*/
|
|
28
28
|
class CanvasRenderer extends Renderer {
|
|
29
29
|
|
|
@@ -86,8 +86,8 @@ class CanvasRenderer extends Renderer {
|
|
|
86
86
|
* @name setBlendMode
|
|
87
87
|
* @memberOf me.CanvasRenderer.prototype
|
|
88
88
|
* @function
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
89
|
+
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
90
|
+
* @param {CanvasRenderingContext2D} [context]
|
|
91
91
|
*/
|
|
92
92
|
setBlendMode(mode, context) {
|
|
93
93
|
context = context || this.getContext();
|
|
@@ -139,14 +139,14 @@ class CanvasRenderer extends Renderer {
|
|
|
139
139
|
* @name clearColor
|
|
140
140
|
* @memberOf me.CanvasRenderer.prototype
|
|
141
141
|
* @function
|
|
142
|
-
* @param {me.Color|
|
|
143
|
-
* @param {
|
|
142
|
+
* @param {me.Color|string} color CSS color.
|
|
143
|
+
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
144
144
|
*/
|
|
145
|
-
clearColor(
|
|
145
|
+
clearColor(color, opaque) {
|
|
146
146
|
this.save();
|
|
147
147
|
this.resetTransform();
|
|
148
148
|
this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over";
|
|
149
|
-
this.backBufferContext2D.fillStyle = (
|
|
149
|
+
this.backBufferContext2D.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
|
|
150
150
|
this.fillRect(0, 0, this.backBufferCanvas.width, this.backBufferCanvas.height);
|
|
151
151
|
this.restore();
|
|
152
152
|
}
|
|
@@ -156,10 +156,10 @@ class CanvasRenderer extends Renderer {
|
|
|
156
156
|
* @name clearRect
|
|
157
157
|
* @memberOf me.CanvasRenderer.prototype
|
|
158
158
|
* @function
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
161
|
-
* @param {
|
|
162
|
-
* @param {
|
|
159
|
+
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
160
|
+
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
161
|
+
* @param {number} width The rectangle's width.
|
|
162
|
+
* @param {number} height The rectangle's height.
|
|
163
163
|
*/
|
|
164
164
|
clearRect(x, y, width, height) {
|
|
165
165
|
this.backBufferContext2D.clearRect(x, y, width, height);
|
|
@@ -170,9 +170,9 @@ class CanvasRenderer extends Renderer {
|
|
|
170
170
|
* @name createPattern
|
|
171
171
|
* @memberOf me.CanvasRenderer.prototype
|
|
172
172
|
* @function
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {
|
|
175
|
-
* @
|
|
173
|
+
* @param {Image} image Source image
|
|
174
|
+
* @param {string} repeat Define how the pattern should be repeated
|
|
175
|
+
* @returns {CanvasPattern}
|
|
176
176
|
* @see me.ImageLayer#repeat
|
|
177
177
|
* @example
|
|
178
178
|
* var tileable = renderer.createPattern(image, "repeat");
|
|
@@ -190,14 +190,14 @@ class CanvasRenderer extends Renderer {
|
|
|
190
190
|
* @memberOf me.CanvasRenderer.prototype
|
|
191
191
|
* @function
|
|
192
192
|
* @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
|
|
193
|
-
* @param {
|
|
194
|
-
* @param {
|
|
195
|
-
* @param {
|
|
196
|
-
* @param {
|
|
197
|
-
* @param {
|
|
198
|
-
* @param {
|
|
199
|
-
* @param {
|
|
200
|
-
* @param {
|
|
193
|
+
* @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.
|
|
194
|
+
* @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.
|
|
195
|
+
* @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.
|
|
196
|
+
* @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
|
|
197
|
+
* @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
198
|
+
* @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
199
|
+
* @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.
|
|
200
|
+
* @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.
|
|
201
201
|
* @example
|
|
202
202
|
* // Position the image on the canvas:
|
|
203
203
|
* renderer.drawImage(image, dx, dy);
|
|
@@ -253,10 +253,10 @@ class CanvasRenderer extends Renderer {
|
|
|
253
253
|
* @memberOf me.CanvasRenderer.prototype
|
|
254
254
|
* @function
|
|
255
255
|
* @param {CanvasPattern} pattern Pattern object
|
|
256
|
-
* @param {
|
|
257
|
-
* @param {
|
|
258
|
-
* @param {
|
|
259
|
-
* @param {
|
|
256
|
+
* @param {number} x
|
|
257
|
+
* @param {number} y
|
|
258
|
+
* @param {number} width
|
|
259
|
+
* @param {number} height
|
|
260
260
|
* @see me.CanvasRenderer#createPattern
|
|
261
261
|
*/
|
|
262
262
|
drawPattern(pattern, x, y, width, height) {
|
|
@@ -275,13 +275,13 @@ class CanvasRenderer extends Renderer {
|
|
|
275
275
|
* @name strokeArc
|
|
276
276
|
* @memberOf me.CanvasRenderer.prototype
|
|
277
277
|
* @function
|
|
278
|
-
* @param {
|
|
279
|
-
* @param {
|
|
280
|
-
* @param {
|
|
281
|
-
* @param {
|
|
282
|
-
* @param {
|
|
283
|
-
* @param {
|
|
284
|
-
* @param {
|
|
278
|
+
* @param {number} x arc center point x-axis
|
|
279
|
+
* @param {number} y arc center point y-axis
|
|
280
|
+
* @param {number} radius
|
|
281
|
+
* @param {number} start start angle in radians
|
|
282
|
+
* @param {number} end end angle in radians
|
|
283
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
284
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
285
285
|
*/
|
|
286
286
|
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
287
287
|
var context = this.backBufferContext2D;
|
|
@@ -302,12 +302,12 @@ class CanvasRenderer extends Renderer {
|
|
|
302
302
|
* @name fillArc
|
|
303
303
|
* @memberOf me.CanvasRenderer.prototype
|
|
304
304
|
* @function
|
|
305
|
-
* @param {
|
|
306
|
-
* @param {
|
|
307
|
-
* @param {
|
|
308
|
-
* @param {
|
|
309
|
-
* @param {
|
|
310
|
-
* @param {
|
|
305
|
+
* @param {number} x arc center point x-axis
|
|
306
|
+
* @param {number} y arc center point y-axis
|
|
307
|
+
* @param {number} radius
|
|
308
|
+
* @param {number} start start angle in radians
|
|
309
|
+
* @param {number} end end angle in radians
|
|
310
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
311
311
|
*/
|
|
312
312
|
fillArc(x, y, radius, start, end, antiClockwise) {
|
|
313
313
|
this.strokeArc(x, y, radius, start, end, antiClockwise || false, true);
|
|
@@ -318,11 +318,11 @@ class CanvasRenderer extends Renderer {
|
|
|
318
318
|
* @name strokeEllipse
|
|
319
319
|
* @memberOf me.CanvasRenderer.prototype
|
|
320
320
|
* @function
|
|
321
|
-
* @param {
|
|
322
|
-
* @param {
|
|
323
|
-
* @param {
|
|
324
|
-
* @param {
|
|
325
|
-
* @param {
|
|
321
|
+
* @param {number} x ellipse center point x-axis
|
|
322
|
+
* @param {number} y ellipse center point y-axis
|
|
323
|
+
* @param {number} w horizontal radius of the ellipse
|
|
324
|
+
* @param {number} h vertical radius of the ellipse
|
|
325
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
326
326
|
*/
|
|
327
327
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
328
328
|
var context = this.backBufferContext2D;
|
|
@@ -361,10 +361,10 @@ class CanvasRenderer extends Renderer {
|
|
|
361
361
|
* @name fillEllipse
|
|
362
362
|
* @memberOf me.CanvasRenderer.prototype
|
|
363
363
|
* @function
|
|
364
|
-
* @param {
|
|
365
|
-
* @param {
|
|
366
|
-
* @param {
|
|
367
|
-
* @param {
|
|
364
|
+
* @param {number} x ellipse center point x-axis
|
|
365
|
+
* @param {number} y ellipse center point y-axis
|
|
366
|
+
* @param {number} w horizontal radius of the ellipse
|
|
367
|
+
* @param {number} h vertical radius of the ellipse
|
|
368
368
|
*/
|
|
369
369
|
fillEllipse(x, y, w, h) {
|
|
370
370
|
this.strokeEllipse(x, y, w, h, true);
|
|
@@ -375,10 +375,10 @@ class CanvasRenderer extends Renderer {
|
|
|
375
375
|
* @name strokeLine
|
|
376
376
|
* @memberOf me.CanvasRenderer.prototype
|
|
377
377
|
* @function
|
|
378
|
-
* @param {
|
|
379
|
-
* @param {
|
|
380
|
-
* @param {
|
|
381
|
-
* @param {
|
|
378
|
+
* @param {number} startX the start x coordinate
|
|
379
|
+
* @param {number} startY the start y coordinate
|
|
380
|
+
* @param {number} endX the end x coordinate
|
|
381
|
+
* @param {number} endY the end y coordinate
|
|
382
382
|
*/
|
|
383
383
|
strokeLine(startX, startY, endX, endY) {
|
|
384
384
|
var context = this.backBufferContext2D;
|
|
@@ -399,10 +399,10 @@ class CanvasRenderer extends Renderer {
|
|
|
399
399
|
* @name fillLine
|
|
400
400
|
* @memberOf me.CanvasRenderer.prototype
|
|
401
401
|
* @function
|
|
402
|
-
* @param {
|
|
403
|
-
* @param {
|
|
404
|
-
* @param {
|
|
405
|
-
* @param {
|
|
402
|
+
* @param {number} startX the start x coordinate
|
|
403
|
+
* @param {number} startY the start y coordinate
|
|
404
|
+
* @param {number} endX the end x coordinate
|
|
405
|
+
* @param {number} endY the end y coordinate
|
|
406
406
|
*/
|
|
407
407
|
fillLine(startX, startY, endX, endY) {
|
|
408
408
|
this.strokeLine(startX, startY, endX, endY);
|
|
@@ -414,7 +414,7 @@ class CanvasRenderer extends Renderer {
|
|
|
414
414
|
* @memberOf me.CanvasRenderer.prototype
|
|
415
415
|
* @function
|
|
416
416
|
* @param {me.Polygon} poly the shape to draw
|
|
417
|
-
* @param {
|
|
417
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
418
418
|
*/
|
|
419
419
|
strokePolygon(poly, fill = false) {
|
|
420
420
|
var context = this.backBufferContext2D;
|
|
@@ -454,11 +454,11 @@ class CanvasRenderer extends Renderer {
|
|
|
454
454
|
* @name strokeRect
|
|
455
455
|
* @memberOf me.CanvasRenderer.prototype
|
|
456
456
|
* @function
|
|
457
|
-
* @param {
|
|
458
|
-
* @param {
|
|
459
|
-
* @param {
|
|
460
|
-
* @param {
|
|
461
|
-
* @param {
|
|
457
|
+
* @param {number} x
|
|
458
|
+
* @param {number} y
|
|
459
|
+
* @param {number} width
|
|
460
|
+
* @param {number} height
|
|
461
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
462
462
|
*/
|
|
463
463
|
strokeRect(x, y, width, height, fill = false) {
|
|
464
464
|
if (fill === true ) {
|
|
@@ -477,10 +477,10 @@ class CanvasRenderer extends Renderer {
|
|
|
477
477
|
* @name fillRect
|
|
478
478
|
* @memberOf me.CanvasRenderer.prototype
|
|
479
479
|
* @function
|
|
480
|
-
* @param {
|
|
481
|
-
* @param {
|
|
482
|
-
* @param {
|
|
483
|
-
* @param {
|
|
480
|
+
* @param {number} x
|
|
481
|
+
* @param {number} y
|
|
482
|
+
* @param {number} width
|
|
483
|
+
* @param {number} height
|
|
484
484
|
*/
|
|
485
485
|
fillRect(x, y, width, height) {
|
|
486
486
|
if (this.backBufferContext2D.globalAlpha < 1 / 255) {
|
|
@@ -496,7 +496,7 @@ class CanvasRenderer extends Renderer {
|
|
|
496
496
|
* @name getContext
|
|
497
497
|
* @memberOf me.CanvasRenderer.prototype
|
|
498
498
|
* @function
|
|
499
|
-
* @
|
|
499
|
+
* @returns {CanvasRenderingContext2D}
|
|
500
500
|
*/
|
|
501
501
|
getContext() {
|
|
502
502
|
return this.backBufferContext2D;
|
|
@@ -541,7 +541,7 @@ class CanvasRenderer extends Renderer {
|
|
|
541
541
|
* @name rotate
|
|
542
542
|
* @memberOf me.CanvasRenderer.prototype
|
|
543
543
|
* @function
|
|
544
|
-
* @param {
|
|
544
|
+
* @param {number} angle in radians
|
|
545
545
|
*/
|
|
546
546
|
rotate(angle) {
|
|
547
547
|
this.backBufferContext2D.rotate(angle);
|
|
@@ -552,8 +552,8 @@ class CanvasRenderer extends Renderer {
|
|
|
552
552
|
* @name scale
|
|
553
553
|
* @memberOf me.CanvasRenderer.prototype
|
|
554
554
|
* @function
|
|
555
|
-
* @param {
|
|
556
|
-
* @param {
|
|
555
|
+
* @param {number} x
|
|
556
|
+
* @param {number} y
|
|
557
557
|
*/
|
|
558
558
|
scale(x, y) {
|
|
559
559
|
this.backBufferContext2D.scale(x, y);
|
|
@@ -565,7 +565,7 @@ class CanvasRenderer extends Renderer {
|
|
|
565
565
|
* @name setColor
|
|
566
566
|
* @memberOf me.CanvasRenderer.prototype
|
|
567
567
|
* @function
|
|
568
|
-
* @param {Color|
|
|
568
|
+
* @param {me.Color|string} color css color value
|
|
569
569
|
*/
|
|
570
570
|
setColor(color) {
|
|
571
571
|
this.backBufferContext2D.strokeStyle =
|
|
@@ -581,10 +581,10 @@ class CanvasRenderer extends Renderer {
|
|
|
581
581
|
* @name setGlobalAlpha
|
|
582
582
|
* @memberOf me.CanvasRenderer.prototype
|
|
583
583
|
* @function
|
|
584
|
-
* @param {
|
|
584
|
+
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
585
585
|
*/
|
|
586
|
-
setGlobalAlpha(
|
|
587
|
-
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] =
|
|
586
|
+
setGlobalAlpha(alpha) {
|
|
587
|
+
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
/**
|
|
@@ -592,7 +592,7 @@ class CanvasRenderer extends Renderer {
|
|
|
592
592
|
* @name setLineWidth
|
|
593
593
|
* @memberOf me.CanvasRenderer.prototype
|
|
594
594
|
* @function
|
|
595
|
-
* @param {
|
|
595
|
+
* @param {number} width Line width
|
|
596
596
|
*/
|
|
597
597
|
setLineWidth(width) {
|
|
598
598
|
this.backBufferContext2D.lineWidth = width;
|
|
@@ -640,8 +640,8 @@ class CanvasRenderer extends Renderer {
|
|
|
640
640
|
* @name translate
|
|
641
641
|
* @memberOf me.CanvasRenderer.prototype
|
|
642
642
|
* @function
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
643
|
+
* @param {number} x
|
|
644
|
+
* @param {number} y
|
|
645
645
|
*/
|
|
646
646
|
translate(x, y) {
|
|
647
647
|
if (this.settings.subPixel === false) {
|
|
@@ -660,10 +660,10 @@ class CanvasRenderer extends Renderer {
|
|
|
660
660
|
* @name clipRect
|
|
661
661
|
* @memberOf me.CanvasRenderer.prototype
|
|
662
662
|
* @function
|
|
663
|
-
* @param {
|
|
664
|
-
* @param {
|
|
665
|
-
* @param {
|
|
666
|
-
* @param {
|
|
663
|
+
* @param {number} x
|
|
664
|
+
* @param {number} y
|
|
665
|
+
* @param {number} width
|
|
666
|
+
* @param {number} height
|
|
667
667
|
*/
|
|
668
668
|
clipRect(x, y, width, height) {
|
|
669
669
|
var canvas = this.backBufferCanvas;
|