melonjs 10.2.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Color from "./../../math/color.js";
|
|
2
2
|
import Renderer from "./../renderer.js";
|
|
3
3
|
import TextureCache from "./../texture_cache.js";
|
|
4
|
-
import Ellipse from "./../../
|
|
4
|
+
import Ellipse from "./../../geometries/ellipse.js";
|
|
5
5
|
import { createCanvas } from "./../video.js";
|
|
6
6
|
|
|
7
7
|
|
|
@@ -10,20 +10,19 @@ import { createCanvas } from "./../video.js";
|
|
|
10
10
|
* @classdesc
|
|
11
11
|
* a canvas renderer object
|
|
12
12
|
* @class CanvasRenderer
|
|
13
|
-
* @
|
|
14
|
-
* @
|
|
15
|
-
* @
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {Number} options.height The height of the canvas without scaling
|
|
13
|
+
* @augments me.Renderer
|
|
14
|
+
* @memberof me
|
|
15
|
+
* @param {object} options The renderer parameters
|
|
16
|
+
* @param {number} options.width The width of the canvas without scaling
|
|
17
|
+
* @param {number} options.height The height of the canvas without scaling
|
|
19
18
|
* @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 {
|
|
19
|
+
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
20
|
+
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
21
|
+
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
22
|
+
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
23
|
+
* @param {boolean} [options.textureSeamFix=true] enable the texture seam fix when rendering Tile when antiAlias is off for the canvasRenderer
|
|
24
|
+
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
25
|
+
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
27
26
|
*/
|
|
28
27
|
class CanvasRenderer extends Renderer {
|
|
29
28
|
|
|
@@ -63,7 +62,7 @@ class CanvasRenderer extends Renderer {
|
|
|
63
62
|
/**
|
|
64
63
|
* Reset context state
|
|
65
64
|
* @name reset
|
|
66
|
-
* @
|
|
65
|
+
* @memberof me.CanvasRenderer.prototype
|
|
67
66
|
* @function
|
|
68
67
|
*/
|
|
69
68
|
reset() {
|
|
@@ -74,7 +73,7 @@ class CanvasRenderer extends Renderer {
|
|
|
74
73
|
/**
|
|
75
74
|
* Reset the canvas transform to identity
|
|
76
75
|
* @name resetTransform
|
|
77
|
-
* @
|
|
76
|
+
* @memberof me.CanvasRenderer.prototype
|
|
78
77
|
* @function
|
|
79
78
|
*/
|
|
80
79
|
resetTransform() {
|
|
@@ -84,10 +83,10 @@ class CanvasRenderer extends Renderer {
|
|
|
84
83
|
/**
|
|
85
84
|
* Set a blend mode for the given context
|
|
86
85
|
* @name setBlendMode
|
|
87
|
-
* @
|
|
86
|
+
* @memberof me.CanvasRenderer.prototype
|
|
88
87
|
* @function
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
88
|
+
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
89
|
+
* @param {CanvasRenderingContext2D} [context]
|
|
91
90
|
*/
|
|
92
91
|
setBlendMode(mode, context) {
|
|
93
92
|
context = context || this.getContext();
|
|
@@ -113,7 +112,7 @@ class CanvasRenderer extends Renderer {
|
|
|
113
112
|
/**
|
|
114
113
|
* prepare the framebuffer for drawing a new frame
|
|
115
114
|
* @name clear
|
|
116
|
-
* @
|
|
115
|
+
* @memberof me.CanvasRenderer.prototype
|
|
117
116
|
* @function
|
|
118
117
|
*/
|
|
119
118
|
clear() {
|
|
@@ -125,7 +124,7 @@ class CanvasRenderer extends Renderer {
|
|
|
125
124
|
/**
|
|
126
125
|
* render the main framebuffer on screen
|
|
127
126
|
* @name flush
|
|
128
|
-
* @
|
|
127
|
+
* @memberof me.CanvasRenderer.prototype
|
|
129
128
|
* @function
|
|
130
129
|
*/
|
|
131
130
|
flush() {
|
|
@@ -137,16 +136,16 @@ class CanvasRenderer extends Renderer {
|
|
|
137
136
|
/**
|
|
138
137
|
* Clears the main framebuffer with the given color
|
|
139
138
|
* @name clearColor
|
|
140
|
-
* @
|
|
139
|
+
* @memberof me.CanvasRenderer.prototype
|
|
141
140
|
* @function
|
|
142
|
-
* @param {me.Color|
|
|
143
|
-
* @param {
|
|
141
|
+
* @param {me.Color|string} [color="#000000"] CSS color.
|
|
142
|
+
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
144
143
|
*/
|
|
145
|
-
clearColor(
|
|
144
|
+
clearColor(color = "#000000", opaque) {
|
|
146
145
|
this.save();
|
|
147
146
|
this.resetTransform();
|
|
148
147
|
this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over";
|
|
149
|
-
this.backBufferContext2D.fillStyle = (
|
|
148
|
+
this.backBufferContext2D.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
|
|
150
149
|
this.fillRect(0, 0, this.backBufferCanvas.width, this.backBufferCanvas.height);
|
|
151
150
|
this.restore();
|
|
152
151
|
}
|
|
@@ -154,12 +153,12 @@ class CanvasRenderer extends Renderer {
|
|
|
154
153
|
/**
|
|
155
154
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
156
155
|
* @name clearRect
|
|
157
|
-
* @
|
|
156
|
+
* @memberof me.CanvasRenderer.prototype
|
|
158
157
|
* @function
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
161
|
-
* @param {
|
|
162
|
-
* @param {
|
|
158
|
+
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
159
|
+
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
160
|
+
* @param {number} width The rectangle's width.
|
|
161
|
+
* @param {number} height The rectangle's height.
|
|
163
162
|
*/
|
|
164
163
|
clearRect(x, y, width, height) {
|
|
165
164
|
this.backBufferContext2D.clearRect(x, y, width, height);
|
|
@@ -168,11 +167,11 @@ class CanvasRenderer extends Renderer {
|
|
|
168
167
|
/**
|
|
169
168
|
* Create a pattern with the specified repetition
|
|
170
169
|
* @name createPattern
|
|
171
|
-
* @
|
|
170
|
+
* @memberof me.CanvasRenderer.prototype
|
|
172
171
|
* @function
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {
|
|
175
|
-
* @
|
|
172
|
+
* @param {Image} image Source image
|
|
173
|
+
* @param {string} repeat Define how the pattern should be repeated
|
|
174
|
+
* @returns {CanvasPattern}
|
|
176
175
|
* @see me.ImageLayer#repeat
|
|
177
176
|
* @example
|
|
178
177
|
* var tileable = renderer.createPattern(image, "repeat");
|
|
@@ -187,17 +186,17 @@ class CanvasRenderer extends Renderer {
|
|
|
187
186
|
/**
|
|
188
187
|
* Draw an image onto the main using the canvas api
|
|
189
188
|
* @name drawImage
|
|
190
|
-
* @
|
|
189
|
+
* @memberof me.CanvasRenderer.prototype
|
|
191
190
|
* @function
|
|
192
191
|
* @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 {
|
|
192
|
+
* @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.
|
|
193
|
+
* @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.
|
|
194
|
+
* @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.
|
|
195
|
+
* @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
|
|
196
|
+
* @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
197
|
+
* @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
198
|
+
* @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.
|
|
199
|
+
* @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
200
|
* @example
|
|
202
201
|
* // Position the image on the canvas:
|
|
203
202
|
* renderer.drawImage(image, dx, dy);
|
|
@@ -250,13 +249,13 @@ class CanvasRenderer extends Renderer {
|
|
|
250
249
|
/**
|
|
251
250
|
* Draw a pattern within the given rectangle.
|
|
252
251
|
* @name drawPattern
|
|
253
|
-
* @
|
|
252
|
+
* @memberof me.CanvasRenderer.prototype
|
|
254
253
|
* @function
|
|
255
254
|
* @param {CanvasPattern} pattern Pattern object
|
|
256
|
-
* @param {
|
|
257
|
-
* @param {
|
|
258
|
-
* @param {
|
|
259
|
-
* @param {
|
|
255
|
+
* @param {number} x
|
|
256
|
+
* @param {number} y
|
|
257
|
+
* @param {number} width
|
|
258
|
+
* @param {number} height
|
|
260
259
|
* @see me.CanvasRenderer#createPattern
|
|
261
260
|
*/
|
|
262
261
|
drawPattern(pattern, x, y, width, height) {
|
|
@@ -273,15 +272,15 @@ class CanvasRenderer extends Renderer {
|
|
|
273
272
|
/**
|
|
274
273
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
275
274
|
* @name strokeArc
|
|
276
|
-
* @
|
|
275
|
+
* @memberof me.CanvasRenderer.prototype
|
|
277
276
|
* @function
|
|
278
|
-
* @param {
|
|
279
|
-
* @param {
|
|
280
|
-
* @param {
|
|
281
|
-
* @param {
|
|
282
|
-
* @param {
|
|
283
|
-
* @param {
|
|
284
|
-
* @param {
|
|
277
|
+
* @param {number} x arc center point x-axis
|
|
278
|
+
* @param {number} y arc center point y-axis
|
|
279
|
+
* @param {number} radius
|
|
280
|
+
* @param {number} start start angle in radians
|
|
281
|
+
* @param {number} end end angle in radians
|
|
282
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
283
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
285
284
|
*/
|
|
286
285
|
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
287
286
|
var context = this.backBufferContext2D;
|
|
@@ -300,14 +299,14 @@ class CanvasRenderer extends Renderer {
|
|
|
300
299
|
/**
|
|
301
300
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
302
301
|
* @name fillArc
|
|
303
|
-
* @
|
|
302
|
+
* @memberof me.CanvasRenderer.prototype
|
|
304
303
|
* @function
|
|
305
|
-
* @param {
|
|
306
|
-
* @param {
|
|
307
|
-
* @param {
|
|
308
|
-
* @param {
|
|
309
|
-
* @param {
|
|
310
|
-
* @param {
|
|
304
|
+
* @param {number} x arc center point x-axis
|
|
305
|
+
* @param {number} y arc center point y-axis
|
|
306
|
+
* @param {number} radius
|
|
307
|
+
* @param {number} start start angle in radians
|
|
308
|
+
* @param {number} end end angle in radians
|
|
309
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
311
310
|
*/
|
|
312
311
|
fillArc(x, y, radius, start, end, antiClockwise) {
|
|
313
312
|
this.strokeArc(x, y, radius, start, end, antiClockwise || false, true);
|
|
@@ -316,13 +315,13 @@ class CanvasRenderer extends Renderer {
|
|
|
316
315
|
/**
|
|
317
316
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
318
317
|
* @name strokeEllipse
|
|
319
|
-
* @
|
|
318
|
+
* @memberof me.CanvasRenderer.prototype
|
|
320
319
|
* @function
|
|
321
|
-
* @param {
|
|
322
|
-
* @param {
|
|
323
|
-
* @param {
|
|
324
|
-
* @param {
|
|
325
|
-
* @param {
|
|
320
|
+
* @param {number} x ellipse center point x-axis
|
|
321
|
+
* @param {number} y ellipse center point y-axis
|
|
322
|
+
* @param {number} w horizontal radius of the ellipse
|
|
323
|
+
* @param {number} h vertical radius of the ellipse
|
|
324
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
326
325
|
*/
|
|
327
326
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
328
327
|
var context = this.backBufferContext2D;
|
|
@@ -359,12 +358,12 @@ class CanvasRenderer extends Renderer {
|
|
|
359
358
|
/**
|
|
360
359
|
* Fill an ellipse at the specified coordinates with given radius
|
|
361
360
|
* @name fillEllipse
|
|
362
|
-
* @
|
|
361
|
+
* @memberof me.CanvasRenderer.prototype
|
|
363
362
|
* @function
|
|
364
|
-
* @param {
|
|
365
|
-
* @param {
|
|
366
|
-
* @param {
|
|
367
|
-
* @param {
|
|
363
|
+
* @param {number} x ellipse center point x-axis
|
|
364
|
+
* @param {number} y ellipse center point y-axis
|
|
365
|
+
* @param {number} w horizontal radius of the ellipse
|
|
366
|
+
* @param {number} h vertical radius of the ellipse
|
|
368
367
|
*/
|
|
369
368
|
fillEllipse(x, y, w, h) {
|
|
370
369
|
this.strokeEllipse(x, y, w, h, true);
|
|
@@ -373,12 +372,12 @@ class CanvasRenderer extends Renderer {
|
|
|
373
372
|
/**
|
|
374
373
|
* Stroke a line of the given two points
|
|
375
374
|
* @name strokeLine
|
|
376
|
-
* @
|
|
375
|
+
* @memberof me.CanvasRenderer.prototype
|
|
377
376
|
* @function
|
|
378
|
-
* @param {
|
|
379
|
-
* @param {
|
|
380
|
-
* @param {
|
|
381
|
-
* @param {
|
|
377
|
+
* @param {number} startX the start x coordinate
|
|
378
|
+
* @param {number} startY the start y coordinate
|
|
379
|
+
* @param {number} endX the end x coordinate
|
|
380
|
+
* @param {number} endY the end y coordinate
|
|
382
381
|
*/
|
|
383
382
|
strokeLine(startX, startY, endX, endY) {
|
|
384
383
|
var context = this.backBufferContext2D;
|
|
@@ -397,12 +396,12 @@ class CanvasRenderer extends Renderer {
|
|
|
397
396
|
/**
|
|
398
397
|
* Fill a line of the given two points
|
|
399
398
|
* @name fillLine
|
|
400
|
-
* @
|
|
399
|
+
* @memberof me.CanvasRenderer.prototype
|
|
401
400
|
* @function
|
|
402
|
-
* @param {
|
|
403
|
-
* @param {
|
|
404
|
-
* @param {
|
|
405
|
-
* @param {
|
|
401
|
+
* @param {number} startX the start x coordinate
|
|
402
|
+
* @param {number} startY the start y coordinate
|
|
403
|
+
* @param {number} endX the end x coordinate
|
|
404
|
+
* @param {number} endY the end y coordinate
|
|
406
405
|
*/
|
|
407
406
|
fillLine(startX, startY, endX, endY) {
|
|
408
407
|
this.strokeLine(startX, startY, endX, endY);
|
|
@@ -411,10 +410,10 @@ class CanvasRenderer extends Renderer {
|
|
|
411
410
|
/**
|
|
412
411
|
* Stroke the given me.Polygon on the screen
|
|
413
412
|
* @name strokePolygon
|
|
414
|
-
* @
|
|
413
|
+
* @memberof me.CanvasRenderer.prototype
|
|
415
414
|
* @function
|
|
416
415
|
* @param {me.Polygon} poly the shape to draw
|
|
417
|
-
* @param {
|
|
416
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
418
417
|
*/
|
|
419
418
|
strokePolygon(poly, fill = false) {
|
|
420
419
|
var context = this.backBufferContext2D;
|
|
@@ -441,7 +440,7 @@ class CanvasRenderer extends Renderer {
|
|
|
441
440
|
/**
|
|
442
441
|
* Fill the given me.Polygon on the screen
|
|
443
442
|
* @name fillPolygon
|
|
444
|
-
* @
|
|
443
|
+
* @memberof me.CanvasRenderer.prototype
|
|
445
444
|
* @function
|
|
446
445
|
* @param {me.Polygon} poly the shape to draw
|
|
447
446
|
*/
|
|
@@ -452,13 +451,13 @@ class CanvasRenderer extends Renderer {
|
|
|
452
451
|
/**
|
|
453
452
|
* Stroke a rectangle at the specified coordinates
|
|
454
453
|
* @name strokeRect
|
|
455
|
-
* @
|
|
454
|
+
* @memberof me.CanvasRenderer.prototype
|
|
456
455
|
* @function
|
|
457
|
-
* @param {
|
|
458
|
-
* @param {
|
|
459
|
-
* @param {
|
|
460
|
-
* @param {
|
|
461
|
-
* @param {
|
|
456
|
+
* @param {number} x
|
|
457
|
+
* @param {number} y
|
|
458
|
+
* @param {number} width
|
|
459
|
+
* @param {number} height
|
|
460
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
462
461
|
*/
|
|
463
462
|
strokeRect(x, y, width, height, fill = false) {
|
|
464
463
|
if (fill === true ) {
|
|
@@ -475,12 +474,12 @@ class CanvasRenderer extends Renderer {
|
|
|
475
474
|
/**
|
|
476
475
|
* Draw a filled rectangle at the specified coordinates
|
|
477
476
|
* @name fillRect
|
|
478
|
-
* @
|
|
477
|
+
* @memberof me.CanvasRenderer.prototype
|
|
479
478
|
* @function
|
|
480
|
-
* @param {
|
|
481
|
-
* @param {
|
|
482
|
-
* @param {
|
|
483
|
-
* @param {
|
|
479
|
+
* @param {number} x
|
|
480
|
+
* @param {number} y
|
|
481
|
+
* @param {number} width
|
|
482
|
+
* @param {number} height
|
|
484
483
|
*/
|
|
485
484
|
fillRect(x, y, width, height) {
|
|
486
485
|
if (this.backBufferContext2D.globalAlpha < 1 / 255) {
|
|
@@ -494,9 +493,9 @@ class CanvasRenderer extends Renderer {
|
|
|
494
493
|
/**
|
|
495
494
|
* return a reference to the system 2d Context
|
|
496
495
|
* @name getContext
|
|
497
|
-
* @
|
|
496
|
+
* @memberof me.CanvasRenderer.prototype
|
|
498
497
|
* @function
|
|
499
|
-
* @
|
|
498
|
+
* @returns {CanvasRenderingContext2D}
|
|
500
499
|
*/
|
|
501
500
|
getContext() {
|
|
502
501
|
return this.backBufferContext2D;
|
|
@@ -514,7 +513,7 @@ class CanvasRenderer extends Renderer {
|
|
|
514
513
|
/**
|
|
515
514
|
* save the canvas context
|
|
516
515
|
* @name save
|
|
517
|
-
* @
|
|
516
|
+
* @memberof me.CanvasRenderer.prototype
|
|
518
517
|
* @function
|
|
519
518
|
*/
|
|
520
519
|
save() {
|
|
@@ -524,7 +523,7 @@ class CanvasRenderer extends Renderer {
|
|
|
524
523
|
/**
|
|
525
524
|
* restores the canvas context
|
|
526
525
|
* @name restore
|
|
527
|
-
* @
|
|
526
|
+
* @memberof me.CanvasRenderer.prototype
|
|
528
527
|
* @function
|
|
529
528
|
*/
|
|
530
529
|
restore() {
|
|
@@ -539,9 +538,9 @@ class CanvasRenderer extends Renderer {
|
|
|
539
538
|
/**
|
|
540
539
|
* rotates the canvas context
|
|
541
540
|
* @name rotate
|
|
542
|
-
* @
|
|
541
|
+
* @memberof me.CanvasRenderer.prototype
|
|
543
542
|
* @function
|
|
544
|
-
* @param {
|
|
543
|
+
* @param {number} angle in radians
|
|
545
544
|
*/
|
|
546
545
|
rotate(angle) {
|
|
547
546
|
this.backBufferContext2D.rotate(angle);
|
|
@@ -550,10 +549,10 @@ class CanvasRenderer extends Renderer {
|
|
|
550
549
|
/**
|
|
551
550
|
* scales the canvas context
|
|
552
551
|
* @name scale
|
|
553
|
-
* @
|
|
552
|
+
* @memberof me.CanvasRenderer.prototype
|
|
554
553
|
* @function
|
|
555
|
-
* @param {
|
|
556
|
-
* @param {
|
|
554
|
+
* @param {number} x
|
|
555
|
+
* @param {number} y
|
|
557
556
|
*/
|
|
558
557
|
scale(x, y) {
|
|
559
558
|
this.backBufferContext2D.scale(x, y);
|
|
@@ -563,9 +562,9 @@ class CanvasRenderer extends Renderer {
|
|
|
563
562
|
* Set the current fill & stroke style color.
|
|
564
563
|
* By default, or upon reset, the value is set to #000000.
|
|
565
564
|
* @name setColor
|
|
566
|
-
* @
|
|
565
|
+
* @memberof me.CanvasRenderer.prototype
|
|
567
566
|
* @function
|
|
568
|
-
* @param {Color|
|
|
567
|
+
* @param {me.Color|string} color css color value
|
|
569
568
|
*/
|
|
570
569
|
setColor(color) {
|
|
571
570
|
this.backBufferContext2D.strokeStyle =
|
|
@@ -579,20 +578,20 @@ class CanvasRenderer extends Renderer {
|
|
|
579
578
|
/**
|
|
580
579
|
* Set the global alpha on the canvas context
|
|
581
580
|
* @name setGlobalAlpha
|
|
582
|
-
* @
|
|
581
|
+
* @memberof me.CanvasRenderer.prototype
|
|
583
582
|
* @function
|
|
584
|
-
* @param {
|
|
583
|
+
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
585
584
|
*/
|
|
586
|
-
setGlobalAlpha(
|
|
587
|
-
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] =
|
|
585
|
+
setGlobalAlpha(alpha) {
|
|
586
|
+
this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
588
587
|
}
|
|
589
588
|
|
|
590
589
|
/**
|
|
591
590
|
* Set the line width on the context
|
|
592
591
|
* @name setLineWidth
|
|
593
|
-
* @
|
|
592
|
+
* @memberof me.CanvasRenderer.prototype
|
|
594
593
|
* @function
|
|
595
|
-
* @param {
|
|
594
|
+
* @param {number} width Line width
|
|
596
595
|
*/
|
|
597
596
|
setLineWidth(width) {
|
|
598
597
|
this.backBufferContext2D.lineWidth = width;
|
|
@@ -602,7 +601,7 @@ class CanvasRenderer extends Renderer {
|
|
|
602
601
|
* Reset (overrides) the renderer transformation matrix to the
|
|
603
602
|
* identity one, and then apply the given transformation matrix.
|
|
604
603
|
* @name setTransform
|
|
605
|
-
* @
|
|
604
|
+
* @memberof me.CanvasRenderer.prototype
|
|
606
605
|
* @function
|
|
607
606
|
* @param {me.Matrix2d} mat2d Matrix to transform by
|
|
608
607
|
*/
|
|
@@ -614,7 +613,7 @@ class CanvasRenderer extends Renderer {
|
|
|
614
613
|
/**
|
|
615
614
|
* Multiply given matrix into the renderer tranformation matrix
|
|
616
615
|
* @name transform
|
|
617
|
-
* @
|
|
616
|
+
* @memberof me.CanvasRenderer.prototype
|
|
618
617
|
* @function
|
|
619
618
|
* @param {me.Matrix2d} mat2d Matrix to transform by
|
|
620
619
|
*/
|
|
@@ -638,10 +637,10 @@ class CanvasRenderer extends Renderer {
|
|
|
638
637
|
/**
|
|
639
638
|
* Translates the context to the given position
|
|
640
639
|
* @name translate
|
|
641
|
-
* @
|
|
640
|
+
* @memberof me.CanvasRenderer.prototype
|
|
642
641
|
* @function
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
642
|
+
* @param {number} x
|
|
643
|
+
* @param {number} y
|
|
645
644
|
*/
|
|
646
645
|
translate(x, y) {
|
|
647
646
|
if (this.settings.subPixel === false) {
|
|
@@ -658,12 +657,12 @@ class CanvasRenderer extends Renderer {
|
|
|
658
657
|
* and restore it (with the restore() method) any time in the future.
|
|
659
658
|
* (<u>this is an experimental feature !</u>)
|
|
660
659
|
* @name clipRect
|
|
661
|
-
* @
|
|
660
|
+
* @memberof me.CanvasRenderer.prototype
|
|
662
661
|
* @function
|
|
663
|
-
* @param {
|
|
664
|
-
* @param {
|
|
665
|
-
* @param {
|
|
666
|
-
* @param {
|
|
662
|
+
* @param {number} x
|
|
663
|
+
* @param {number} y
|
|
664
|
+
* @param {number} width
|
|
665
|
+
* @param {number} height
|
|
667
666
|
*/
|
|
668
667
|
clipRect(x, y, width, height) {
|
|
669
668
|
var canvas = this.backBufferCanvas;
|
|
@@ -691,7 +690,7 @@ class CanvasRenderer extends Renderer {
|
|
|
691
690
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
692
691
|
* Mask are not preserved through renderer context save and restore.
|
|
693
692
|
* @name setMask
|
|
694
|
-
* @
|
|
693
|
+
* @memberof me.CanvasRenderer.prototype
|
|
695
694
|
* @function
|
|
696
695
|
* @param {me.Rect|me.Polygon|me.Line|me.Ellipse} [mask] the shape defining the mask to be applied
|
|
697
696
|
*/
|
|
@@ -740,7 +739,7 @@ class CanvasRenderer extends Renderer {
|
|
|
740
739
|
* disable (remove) the rendering mask set through setMask.
|
|
741
740
|
* @name clearMask
|
|
742
741
|
* @see me.CanvasRenderer#setMask
|
|
743
|
-
* @
|
|
742
|
+
* @memberof me.CanvasRenderer.prototype
|
|
744
743
|
* @function
|
|
745
744
|
*/
|
|
746
745
|
clearMask() {
|