melonjs 14.0.2 → 14.1.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 +2 -0
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
- package/dist/melonjs.mjs/_virtual/howler.js +10 -0
- package/dist/melonjs.mjs/_virtual/index.js +10 -0
- package/dist/melonjs.mjs/_virtual/index2.js +10 -0
- package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
- package/dist/melonjs.mjs/application/application.js +240 -0
- package/dist/melonjs.mjs/audio/audio.js +536 -0
- package/dist/melonjs.mjs/camera/camera2d.js +732 -0
- package/dist/melonjs.mjs/entity/entity.js +248 -0
- package/dist/melonjs.mjs/game.js +29 -0
- package/dist/melonjs.mjs/geometries/ellipse.js +275 -0
- package/dist/melonjs.mjs/geometries/line.js +116 -0
- package/dist/melonjs.mjs/geometries/path2d.js +319 -0
- package/dist/melonjs.mjs/geometries/point.js +89 -0
- package/dist/melonjs.mjs/geometries/poly.js +500 -0
- package/dist/melonjs.mjs/geometries/rectangle.js +375 -0
- package/dist/melonjs.mjs/geometries/roundrect.js +168 -0
- package/dist/melonjs.mjs/index.js +248 -0
- package/dist/melonjs.mjs/input/gamepad.js +501 -0
- package/dist/melonjs.mjs/input/input.js +26 -0
- package/dist/melonjs.mjs/input/keyboard.js +470 -0
- package/dist/melonjs.mjs/input/pointer.js +393 -0
- package/dist/melonjs.mjs/input/pointerevent.js +818 -0
- package/dist/melonjs.mjs/lang/deprecated.js +157 -0
- package/dist/melonjs.mjs/level/level.js +297 -0
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +448 -0
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +194 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +639 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +311 -0
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +83 -0
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +506 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +220 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +157 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +125 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +109 -0
- package/dist/melonjs.mjs/loader/loader.js +801 -0
- package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
- package/dist/melonjs.mjs/math/color.js +618 -0
- package/dist/melonjs.mjs/math/math.js +218 -0
- package/dist/melonjs.mjs/math/matrix2.js +503 -0
- package/dist/melonjs.mjs/math/matrix3.js +681 -0
- package/dist/melonjs.mjs/math/observable_vector2.js +471 -0
- package/dist/melonjs.mjs/math/observable_vector3.js +561 -0
- package/dist/melonjs.mjs/math/vector2.js +528 -0
- package/dist/melonjs.mjs/math/vector3.js +569 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
- package/dist/melonjs.mjs/particles/emitter.js +267 -0
- package/dist/melonjs.mjs/particles/particle.js +188 -0
- package/dist/melonjs.mjs/particles/settings.js +319 -0
- package/dist/melonjs.mjs/physics/body.js +704 -0
- package/dist/melonjs.mjs/physics/bounds.js +460 -0
- package/dist/melonjs.mjs/physics/collision.js +132 -0
- package/dist/melonjs.mjs/physics/detector.js +194 -0
- package/dist/melonjs.mjs/physics/quadtree.js +391 -0
- package/dist/melonjs.mjs/physics/response.js +57 -0
- package/dist/melonjs.mjs/physics/sat.js +483 -0
- package/dist/melonjs.mjs/physics/world.js +221 -0
- package/dist/melonjs.mjs/plugin/plugin.js +141 -0
- package/dist/melonjs.mjs/renderable/collectable.js +62 -0
- package/dist/melonjs.mjs/renderable/colorlayer.js +80 -0
- package/dist/melonjs.mjs/renderable/container.js +1018 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
- package/dist/melonjs.mjs/renderable/imagelayer.js +306 -0
- package/dist/melonjs.mjs/renderable/light2d.js +156 -0
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +247 -0
- package/dist/melonjs.mjs/renderable/renderable.js +783 -0
- package/dist/melonjs.mjs/renderable/sprite.js +654 -0
- package/dist/melonjs.mjs/renderable/trigger.js +157 -0
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +213 -0
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +226 -0
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +128 -0
- package/dist/melonjs.mjs/state/stage.js +237 -0
- package/dist/melonjs.mjs/state/state.js +596 -0
- package/dist/melonjs.mjs/system/device.js +909 -0
- package/dist/melonjs.mjs/system/dom.js +78 -0
- package/dist/melonjs.mjs/system/event.js +537 -0
- package/dist/melonjs.mjs/system/platform.js +41 -0
- package/dist/melonjs.mjs/system/pooling.js +209 -0
- package/dist/melonjs.mjs/system/save.js +157 -0
- package/dist/melonjs.mjs/system/timer.js +286 -0
- package/dist/melonjs.mjs/text/bitmaptext.js +364 -0
- package/dist/melonjs.mjs/text/bitmaptextdata.js +199 -0
- package/dist/melonjs.mjs/text/glyph.js +66 -0
- package/dist/melonjs.mjs/text/text.js +453 -0
- package/dist/melonjs.mjs/text/textmetrics.js +176 -0
- package/dist/melonjs.mjs/text/textstyle.js +23 -0
- package/dist/melonjs.mjs/tweens/easing.js +336 -0
- package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
- package/dist/melonjs.mjs/tweens/tween.js +480 -0
- package/dist/melonjs.mjs/utils/agent.js +76 -0
- package/dist/melonjs.mjs/utils/array.js +63 -0
- package/dist/melonjs.mjs/utils/file.js +42 -0
- package/dist/melonjs.mjs/utils/function.js +70 -0
- package/dist/melonjs.mjs/utils/string.js +82 -0
- package/dist/melonjs.mjs/utils/utils.js +173 -0
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +807 -0
- package/dist/melonjs.mjs/video/renderer.js +411 -0
- package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
- package/dist/melonjs.mjs/video/texture/cache.js +143 -0
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
- package/dist/melonjs.mjs/video/video.js +462 -0
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +143 -0
- package/dist/melonjs.mjs/video/webgl/glshader.js +168 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
- package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
- package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +495 -0
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1036 -0
- package/dist/melonjs.module.d.ts +1163 -1163
- package/dist/melonjs.module.js +1903 -3274
- package/package.json +22 -17
- package/src/application/application.js +3 -3
- package/src/audio/audio.js +32 -32
- package/src/camera/camera2d.js +31 -31
- package/src/entity/entity.js +17 -17
- package/src/geometries/ellipse.js +16 -16
- package/src/geometries/line.js +5 -5
- package/src/geometries/path2d.js +32 -32
- package/src/geometries/poly.js +15 -15
- package/src/geometries/rectangle.js +18 -18
- package/src/geometries/roundrect.js +8 -8
- package/src/input/gamepad.js +15 -15
- package/src/input/keyboard.js +12 -12
- package/src/input/pointer.js +6 -6
- package/src/input/pointerevent.js +12 -12
- package/src/lang/deprecated.js +12 -12
- package/src/level/level.js +25 -25
- package/src/level/tiled/TMXLayer.js +22 -22
- package/src/level/tiled/TMXTile.js +5 -5
- package/src/level/tiled/TMXTileMap.js +6 -6
- package/src/level/tiled/TMXTileset.js +2 -2
- package/src/level/tiled/TMXUtils.js +5 -5
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +19 -19
- package/src/loader/loader.js +20 -20
- package/src/math/color.js +20 -20
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +16 -16
- package/src/math/matrix3.js +25 -25
- package/src/math/observable_vector2.js +14 -14
- package/src/math/observable_vector3.js +16 -16
- package/src/math/vector2.js +9 -9
- package/src/math/vector3.js +10 -10
- package/src/particles/emitter.js +6 -6
- package/src/particles/particle.js +2 -2
- package/src/physics/body.js +28 -28
- package/src/physics/bounds.js +8 -8
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +6 -6
- package/src/physics/quadtree.js +11 -11
- package/src/physics/sat.js +31 -31
- package/src/physics/world.js +5 -5
- package/src/plugin/plugin.js +5 -5
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +5 -5
- package/src/renderable/container.js +21 -21
- package/src/renderable/dragndrop.js +14 -14
- package/src/renderable/imagelayer.js +13 -13
- package/src/renderable/light2d.js +3 -3
- package/src/renderable/nineslicesprite.js +16 -16
- package/src/renderable/renderable.js +23 -23
- package/src/renderable/sprite.js +28 -28
- package/src/renderable/trigger.js +15 -15
- package/src/renderable/ui/uibaseelement.js +7 -7
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +13 -13
- package/src/state/stage.js +7 -7
- package/src/state/state.js +17 -17
- package/src/system/device.js +11 -11
- package/src/system/event.js +10 -10
- package/src/system/pooling.js +9 -9
- package/src/system/save.js +2 -2
- package/src/system/timer.js +10 -10
- package/src/text/bitmaptext.js +18 -18
- package/src/text/bitmaptextdata.js +2 -2
- package/src/text/text.js +23 -23
- package/src/text/textmetrics.js +8 -8
- package/src/tweens/tween.js +19 -19
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +6 -6
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +70 -70
- package/src/video/renderer.js +26 -26
- package/src/video/texture/atlas.js +22 -22
- package/src/video/texture/canvas_texture.js +9 -9
- package/src/video/video.js +17 -17
- package/src/video/webgl/glshader.js +10 -10
- package/src/video/webgl/webgl_compositor.js +41 -41
- package/src/video/webgl/webgl_renderer.js +75 -75
|
@@ -14,16 +14,16 @@ import * as event from "./../../system/event.js";
|
|
|
14
14
|
*/
|
|
15
15
|
class CanvasRenderer extends Renderer {
|
|
16
16
|
/**
|
|
17
|
-
* @param {object} options The renderer parameters
|
|
18
|
-
* @param {number} options.width The width of the canvas without scaling
|
|
19
|
-
* @param {number} options.height The height of the canvas without scaling
|
|
20
|
-
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
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
|
|
17
|
+
* @param {object} options - The renderer parameters
|
|
18
|
+
* @param {number} options.width - The width of the canvas without scaling
|
|
19
|
+
* @param {number} options.height - The height of the canvas without scaling
|
|
20
|
+
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
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
|
constructor(options) {
|
|
29
29
|
// parent constructor
|
|
@@ -91,7 +91,7 @@ class CanvasRenderer extends Renderer {
|
|
|
91
91
|
* @name setBlendMode
|
|
92
92
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
93
93
|
* @memberof CanvasRenderer
|
|
94
|
-
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "additive", "screen"
|
|
94
|
+
* @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter, "additive", "screen"
|
|
95
95
|
* @param {CanvasRenderingContext2D} [context]
|
|
96
96
|
*/
|
|
97
97
|
setBlendMode(mode = "normal", context) {
|
|
@@ -135,8 +135,8 @@ class CanvasRenderer extends Renderer {
|
|
|
135
135
|
* Clears the main framebuffer with the given color
|
|
136
136
|
* @name clearColor
|
|
137
137
|
* @memberof CanvasRenderer
|
|
138
|
-
* @param {Color|string} [color="#000000"] CSS color.
|
|
139
|
-
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
138
|
+
* @param {Color|string} [color="#000000"] - CSS color.
|
|
139
|
+
* @param {boolean} [opaque=false] - Allow transparency [default] or clear the surface completely [true]
|
|
140
140
|
*/
|
|
141
141
|
clearColor(color = "#000000", opaque = false) {
|
|
142
142
|
var canvas = this.getCanvas();
|
|
@@ -155,10 +155,10 @@ class CanvasRenderer extends Renderer {
|
|
|
155
155
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
156
156
|
* @name clearRect
|
|
157
157
|
* @memberof CanvasRenderer
|
|
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.
|
|
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.
|
|
162
162
|
*/
|
|
163
163
|
clearRect(x, y, width, height) {
|
|
164
164
|
this.getContext().clearRect(x, y, width, height);
|
|
@@ -168,8 +168,8 @@ class CanvasRenderer extends Renderer {
|
|
|
168
168
|
* Create a pattern with the specified repetition
|
|
169
169
|
* @name createPattern
|
|
170
170
|
* @memberof CanvasRenderer
|
|
171
|
-
* @param {Image} image Source image
|
|
172
|
-
* @param {string} repeat Define how the pattern should be repeated
|
|
171
|
+
* @param {Image} image - Source image
|
|
172
|
+
* @param {string} repeat - Define how the pattern should be repeated
|
|
173
173
|
* @returns {CanvasPattern}
|
|
174
174
|
* @see ImageLayer#repeat
|
|
175
175
|
* @example
|
|
@@ -186,15 +186,15 @@ class CanvasRenderer extends Renderer {
|
|
|
186
186
|
* Draw an image onto the main using the canvas api
|
|
187
187
|
* @name drawImage
|
|
188
188
|
* @memberof CanvasRenderer
|
|
189
|
-
* @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.
|
|
190
|
-
* @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.
|
|
191
|
-
* @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.
|
|
192
|
-
* @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.
|
|
193
|
-
* @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
|
|
194
|
-
* @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
195
|
-
* @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
196
|
-
* @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.
|
|
197
|
-
* @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.
|
|
189
|
+
* @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.
|
|
190
|
+
* @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.
|
|
191
|
+
* @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.
|
|
192
|
+
* @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.
|
|
193
|
+
* @param {number} sh - The height of the sub-rectangle of the source image to draw into the destination context.
|
|
194
|
+
* @param {number} dx - The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
195
|
+
* @param {number} dy - The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
196
|
+
* @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.
|
|
197
|
+
* @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.
|
|
198
198
|
* @example
|
|
199
199
|
* // Position the image on the canvas:
|
|
200
200
|
* renderer.drawImage(image, dx, dy);
|
|
@@ -249,7 +249,7 @@ class CanvasRenderer extends Renderer {
|
|
|
249
249
|
* Draw a pattern within the given rectangle.
|
|
250
250
|
* @name drawPattern
|
|
251
251
|
* @memberof CanvasRenderer
|
|
252
|
-
* @param {CanvasPattern} pattern Pattern object
|
|
252
|
+
* @param {CanvasPattern} pattern - Pattern object
|
|
253
253
|
* @param {number} x
|
|
254
254
|
* @param {number} y
|
|
255
255
|
* @param {number} width
|
|
@@ -272,13 +272,13 @@ class CanvasRenderer extends Renderer {
|
|
|
272
272
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
273
273
|
* @name strokeArc
|
|
274
274
|
* @memberof CanvasRenderer
|
|
275
|
-
* @param {number} x arc center point x-axis
|
|
276
|
-
* @param {number} y arc center point y-axis
|
|
275
|
+
* @param {number} x - arc center point x-axis
|
|
276
|
+
* @param {number} y - arc center point y-axis
|
|
277
277
|
* @param {number} radius
|
|
278
|
-
* @param {number} start start angle in radians
|
|
279
|
-
* @param {number} end end angle in radians
|
|
280
|
-
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
281
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
278
|
+
* @param {number} start - start angle in radians
|
|
279
|
+
* @param {number} end - end angle in radians
|
|
280
|
+
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
281
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
282
282
|
*/
|
|
283
283
|
strokeArc(x, y, radius, start, end, antiClockwise, fill = false) {
|
|
284
284
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -298,12 +298,12 @@ class CanvasRenderer extends Renderer {
|
|
|
298
298
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
299
299
|
* @name fillArc
|
|
300
300
|
* @memberof CanvasRenderer
|
|
301
|
-
* @param {number} x arc center point x-axis
|
|
302
|
-
* @param {number} y arc center point y-axis
|
|
301
|
+
* @param {number} x - arc center point x-axis
|
|
302
|
+
* @param {number} y - arc center point y-axis
|
|
303
303
|
* @param {number} radius
|
|
304
|
-
* @param {number} start start angle in radians
|
|
305
|
-
* @param {number} end end angle in radians
|
|
306
|
-
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
304
|
+
* @param {number} start - start angle in radians
|
|
305
|
+
* @param {number} end - end angle in radians
|
|
306
|
+
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
307
307
|
*/
|
|
308
308
|
fillArc(x, y, radius, start, end, antiClockwise) {
|
|
309
309
|
this.strokeArc(x, y, radius, start, end, antiClockwise || false, true);
|
|
@@ -313,11 +313,11 @@ class CanvasRenderer extends Renderer {
|
|
|
313
313
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
314
314
|
* @name strokeEllipse
|
|
315
315
|
* @memberof CanvasRenderer
|
|
316
|
-
* @param {number} x ellipse center point x-axis
|
|
317
|
-
* @param {number} y ellipse center point y-axis
|
|
318
|
-
* @param {number} w horizontal radius of the ellipse
|
|
319
|
-
* @param {number} h vertical radius of the ellipse
|
|
320
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
316
|
+
* @param {number} x - ellipse center point x-axis
|
|
317
|
+
* @param {number} y - ellipse center point y-axis
|
|
318
|
+
* @param {number} w - horizontal radius of the ellipse
|
|
319
|
+
* @param {number} h - vertical radius of the ellipse
|
|
320
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
321
321
|
*/
|
|
322
322
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
323
323
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -354,10 +354,10 @@ class CanvasRenderer extends Renderer {
|
|
|
354
354
|
* Fill an ellipse at the specified coordinates with given radius
|
|
355
355
|
* @name fillEllipse
|
|
356
356
|
* @memberof CanvasRenderer
|
|
357
|
-
* @param {number} x ellipse center point x-axis
|
|
358
|
-
* @param {number} y ellipse center point y-axis
|
|
359
|
-
* @param {number} w horizontal radius of the ellipse
|
|
360
|
-
* @param {number} h vertical radius of the ellipse
|
|
357
|
+
* @param {number} x - ellipse center point x-axis
|
|
358
|
+
* @param {number} y - ellipse center point y-axis
|
|
359
|
+
* @param {number} w - horizontal radius of the ellipse
|
|
360
|
+
* @param {number} h - vertical radius of the ellipse
|
|
361
361
|
*/
|
|
362
362
|
fillEllipse(x, y, w, h) {
|
|
363
363
|
this.strokeEllipse(x, y, w, h, true);
|
|
@@ -367,10 +367,10 @@ class CanvasRenderer extends Renderer {
|
|
|
367
367
|
* Stroke a line of the given two points
|
|
368
368
|
* @name strokeLine
|
|
369
369
|
* @memberof CanvasRenderer
|
|
370
|
-
* @param {number} startX the start x coordinate
|
|
371
|
-
* @param {number} startY the start y coordinate
|
|
372
|
-
* @param {number} endX the end x coordinate
|
|
373
|
-
* @param {number} endY the end y coordinate
|
|
370
|
+
* @param {number} startX - the start x coordinate
|
|
371
|
+
* @param {number} startY - the start y coordinate
|
|
372
|
+
* @param {number} endX - the end x coordinate
|
|
373
|
+
* @param {number} endY - the end y coordinate
|
|
374
374
|
*/
|
|
375
375
|
strokeLine(startX, startY, endX, endY) {
|
|
376
376
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -390,10 +390,10 @@ class CanvasRenderer extends Renderer {
|
|
|
390
390
|
* Fill a line of the given two points
|
|
391
391
|
* @name fillLine
|
|
392
392
|
* @memberof CanvasRenderer
|
|
393
|
-
* @param {number} startX the start x coordinate
|
|
394
|
-
* @param {number} startY the start y coordinate
|
|
395
|
-
* @param {number} endX the end x coordinate
|
|
396
|
-
* @param {number} endY the end y coordinate
|
|
393
|
+
* @param {number} startX - the start x coordinate
|
|
394
|
+
* @param {number} startY - the start y coordinate
|
|
395
|
+
* @param {number} endX - the end x coordinate
|
|
396
|
+
* @param {number} endY - the end y coordinate
|
|
397
397
|
*/
|
|
398
398
|
fillLine(startX, startY, endX, endY) {
|
|
399
399
|
this.strokeLine(startX, startY, endX, endY);
|
|
@@ -403,8 +403,8 @@ class CanvasRenderer extends Renderer {
|
|
|
403
403
|
* Stroke the given me.Polygon on the screen
|
|
404
404
|
* @name strokePolygon
|
|
405
405
|
* @memberof CanvasRenderer
|
|
406
|
-
* @param {Polygon} poly the shape to draw
|
|
407
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
406
|
+
* @param {Polygon} poly - the shape to draw
|
|
407
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
408
408
|
*/
|
|
409
409
|
strokePolygon(poly, fill = false) {
|
|
410
410
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -431,7 +431,7 @@ class CanvasRenderer extends Renderer {
|
|
|
431
431
|
* Fill the given me.Polygon on the screen
|
|
432
432
|
* @name fillPolygon
|
|
433
433
|
* @memberof CanvasRenderer
|
|
434
|
-
* @param {Polygon} poly the shape to draw
|
|
434
|
+
* @param {Polygon} poly - the shape to draw
|
|
435
435
|
*/
|
|
436
436
|
fillPolygon(poly) {
|
|
437
437
|
this.strokePolygon(poly, true);
|
|
@@ -445,7 +445,7 @@ class CanvasRenderer extends Renderer {
|
|
|
445
445
|
* @param {number} y
|
|
446
446
|
* @param {number} width
|
|
447
447
|
* @param {number} height
|
|
448
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
448
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
449
449
|
*/
|
|
450
450
|
strokeRect(x, y, width, height, fill = false) {
|
|
451
451
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -479,7 +479,7 @@ class CanvasRenderer extends Renderer {
|
|
|
479
479
|
* @param {number} width
|
|
480
480
|
* @param {number} height
|
|
481
481
|
* @param {number} radius
|
|
482
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
482
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
483
483
|
*/
|
|
484
484
|
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
485
485
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -567,7 +567,7 @@ class CanvasRenderer extends Renderer {
|
|
|
567
567
|
* rotates the canvas context
|
|
568
568
|
* @name rotate
|
|
569
569
|
* @memberof CanvasRenderer
|
|
570
|
-
* @param {number} angle in radians
|
|
570
|
+
* @param {number} angle - in radians
|
|
571
571
|
*/
|
|
572
572
|
rotate(angle) {
|
|
573
573
|
this.getContext().rotate(angle);
|
|
@@ -589,7 +589,7 @@ class CanvasRenderer extends Renderer {
|
|
|
589
589
|
* By default, or upon reset, the value is set to #000000.
|
|
590
590
|
* @name setColor
|
|
591
591
|
* @memberof CanvasRenderer
|
|
592
|
-
* @param {Color|string} color css color value
|
|
592
|
+
* @param {Color|string} color - css color value
|
|
593
593
|
*/
|
|
594
594
|
setColor(color) {
|
|
595
595
|
var context = this.getContext();
|
|
@@ -605,7 +605,7 @@ class CanvasRenderer extends Renderer {
|
|
|
605
605
|
* Set the global alpha
|
|
606
606
|
* @name setGlobalAlpha
|
|
607
607
|
* @memberof CanvasRenderer
|
|
608
|
-
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
608
|
+
* @param {number} alpha - 0.0 to 1.0 values accepted.
|
|
609
609
|
*/
|
|
610
610
|
setGlobalAlpha(alpha) {
|
|
611
611
|
this.getContext().globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
@@ -625,7 +625,7 @@ class CanvasRenderer extends Renderer {
|
|
|
625
625
|
* Set the line width on the context
|
|
626
626
|
* @name setLineWidth
|
|
627
627
|
* @memberof CanvasRenderer
|
|
628
|
-
* @param {number} width Line width
|
|
628
|
+
* @param {number} width - Line width
|
|
629
629
|
*/
|
|
630
630
|
setLineWidth(width) {
|
|
631
631
|
this.getContext().lineWidth = width;
|
|
@@ -636,7 +636,7 @@ class CanvasRenderer extends Renderer {
|
|
|
636
636
|
* identity one, and then apply the given transformation matrix.
|
|
637
637
|
* @name setTransform
|
|
638
638
|
* @memberof CanvasRenderer
|
|
639
|
-
* @param {Matrix2d} mat2d Matrix to transform by
|
|
639
|
+
* @param {Matrix2d} mat2d - Matrix to transform by
|
|
640
640
|
*/
|
|
641
641
|
setTransform(mat2d) {
|
|
642
642
|
this.resetTransform();
|
|
@@ -647,7 +647,7 @@ class CanvasRenderer extends Renderer {
|
|
|
647
647
|
* Multiply given matrix into the renderer tranformation matrix
|
|
648
648
|
* @name transform
|
|
649
649
|
* @memberof CanvasRenderer
|
|
650
|
-
* @param {Matrix2d} mat2d Matrix to transform by
|
|
650
|
+
* @param {Matrix2d} mat2d - Matrix to transform by
|
|
651
651
|
*/
|
|
652
652
|
transform(mat2d) {
|
|
653
653
|
var m = mat2d.toArray(),
|
|
@@ -721,8 +721,8 @@ class CanvasRenderer extends Renderer {
|
|
|
721
721
|
* Mask are not preserved through renderer context save and restore.
|
|
722
722
|
* @name setMask
|
|
723
723
|
* @memberof CanvasRenderer
|
|
724
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
725
|
-
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
724
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - the shape defining the mask to be applied
|
|
725
|
+
* @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
|
|
726
726
|
*/
|
|
727
727
|
setMask(mask, invert = false) {
|
|
728
728
|
var context = this.getContext();
|
package/src/video/renderer.js
CHANGED
|
@@ -19,19 +19,19 @@ import Point from "../geometries/point.js";
|
|
|
19
19
|
*/
|
|
20
20
|
class Renderer {
|
|
21
21
|
/**
|
|
22
|
-
* @param {object} options The renderer parameters
|
|
23
|
-
* @param {number} options.width The width of the canvas without scaling
|
|
24
|
-
* @param {number} options.height The height of the canvas without scaling
|
|
25
|
-
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
26
|
-
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
27
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
28
|
-
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
|
|
29
|
-
* @param {boolean} [options.premultipliedAlpha=true] in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
30
|
-
* @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
|
|
31
|
-
* @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
|
|
32
|
-
* @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
|
|
33
|
-
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
34
|
-
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
22
|
+
* @param {object} options - The renderer parameters
|
|
23
|
+
* @param {number} options.width - The width of the canvas without scaling
|
|
24
|
+
* @param {number} options.height - The height of the canvas without scaling
|
|
25
|
+
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
26
|
+
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
27
|
+
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
28
|
+
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
29
|
+
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
30
|
+
* @param {boolean} [options.blendMode="normal"] - the default blend mode to use ("normal", "multiply")
|
|
31
|
+
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel rendering (performance hit when enabled)
|
|
32
|
+
* @param {boolean} [options.verbose=false] - Enable the verbose mode that provides additional details as to what the renderer is doing
|
|
33
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
34
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
35
35
|
*/
|
|
36
36
|
constructor(options) {
|
|
37
37
|
/**
|
|
@@ -155,7 +155,7 @@ class Renderer {
|
|
|
155
155
|
* Returns the 2D Context object of the given Canvas<br>
|
|
156
156
|
* Also configures anti-aliasing and blend modes based on constructor options.
|
|
157
157
|
* @param {HTMLCanvasElement} canvas
|
|
158
|
-
* @param {boolean} [transparent=true] use false to disable transparency
|
|
158
|
+
* @param {boolean} [transparent=true] - use false to disable transparency
|
|
159
159
|
* @returns {CanvasRenderingContext2D}
|
|
160
160
|
*/
|
|
161
161
|
getContext2d(canvas, transparent) {
|
|
@@ -234,8 +234,8 @@ class Renderer {
|
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* resizes the system canvas
|
|
237
|
-
* @param {number} width new width of the canvas
|
|
238
|
-
* @param {number} height new height of the canvas
|
|
237
|
+
* @param {number} width - new width of the canvas
|
|
238
|
+
* @param {number} height - new height of the canvas
|
|
239
239
|
*/
|
|
240
240
|
resize(width, height) {
|
|
241
241
|
var canvas = this.getCanvas();
|
|
@@ -288,8 +288,8 @@ class Renderer {
|
|
|
288
288
|
|
|
289
289
|
/**
|
|
290
290
|
* stroke the given shape
|
|
291
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
292
|
-
* @param {boolean} [fill=false] fill the shape with the current color if true
|
|
291
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to stroke
|
|
292
|
+
* @param {boolean} [fill=false] - fill the shape with the current color if true
|
|
293
293
|
*/
|
|
294
294
|
stroke(shape, fill) {
|
|
295
295
|
if (shape instanceof RoundRect) {
|
|
@@ -325,7 +325,7 @@ class Renderer {
|
|
|
325
325
|
* fill the given shape
|
|
326
326
|
* @name fill
|
|
327
327
|
* @memberof Renderer
|
|
328
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
|
|
328
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape - a shape object to fill
|
|
329
329
|
*/
|
|
330
330
|
fill(shape) {
|
|
331
331
|
this.stroke(shape, true);
|
|
@@ -333,9 +333,9 @@ class Renderer {
|
|
|
333
333
|
|
|
334
334
|
/**
|
|
335
335
|
* tint the given image or canvas using the given color
|
|
336
|
-
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
|
|
337
|
-
* @param {Color|string} color the color that will be used to tint the image
|
|
338
|
-
* @param {string} [mode="multiply"] the composition mode used to tint the image
|
|
336
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src - the source image to be tinted
|
|
337
|
+
* @param {Color|string} color - the color that will be used to tint the image
|
|
338
|
+
* @param {string} [mode="multiply"] - the composition mode used to tint the image
|
|
339
339
|
* @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
|
|
340
340
|
*/
|
|
341
341
|
tint(src, color, mode) {
|
|
@@ -361,8 +361,8 @@ class Renderer {
|
|
|
361
361
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
362
362
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
363
363
|
* Mask are not preserved through renderer context save and restore.
|
|
364
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
365
|
-
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
364
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - the shape defining the mask to be applied
|
|
365
|
+
* @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
|
|
366
366
|
*/
|
|
367
367
|
// eslint-disable-next-line no-unused-vars
|
|
368
368
|
setMask(mask) {}
|
|
@@ -375,8 +375,8 @@ class Renderer {
|
|
|
375
375
|
|
|
376
376
|
/**
|
|
377
377
|
* set a coloring tint for sprite based renderables
|
|
378
|
-
* @param {Color} tint the tint color
|
|
379
|
-
* @param {number} [alpha] an alpha value to be applied to the tint
|
|
378
|
+
* @param {Color} tint - the tint color
|
|
379
|
+
* @param {number} [alpha] - an alpha value to be applied to the tint
|
|
380
380
|
*/
|
|
381
381
|
setTint(tint, alpha = tint.alpha) {
|
|
382
382
|
// global tint color
|
|
@@ -38,9 +38,9 @@ export function createAtlas(width, height, name = "default", repeat = "no-repeat
|
|
|
38
38
|
*/
|
|
39
39
|
export class TextureAtlas {
|
|
40
40
|
/**
|
|
41
|
-
* @param {object|object[]} atlases atlas information. See {@link loader.getJSON}
|
|
42
|
-
* @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] Image source
|
|
43
|
-
* @param {boolean} [cache=false] Use true to skip caching this Texture
|
|
41
|
+
* @param {object|object[]} atlases - atlas information. See {@link loader.getJSON}
|
|
42
|
+
* @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] - Image source
|
|
43
|
+
* @param {boolean} [cache=false] - Use true to skip caching this Texture
|
|
44
44
|
* @example
|
|
45
45
|
* // create a texture atlas from a JSON Object
|
|
46
46
|
* game.texture = new me.TextureAtlas(
|
|
@@ -269,7 +269,7 @@ export class TextureAtlas {
|
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
271
|
* return the default or specified atlas dictionnary
|
|
272
|
-
* @param {string} [name] atlas name in case of multipack textures
|
|
272
|
+
* @param {string} [name] - atlas name in case of multipack textures
|
|
273
273
|
* @returns {object}
|
|
274
274
|
*/
|
|
275
275
|
getAtlas(name) {
|
|
@@ -290,7 +290,7 @@ export class TextureAtlas {
|
|
|
290
290
|
|
|
291
291
|
/**
|
|
292
292
|
* return the source texture for the given region (or default one if none specified)
|
|
293
|
-
* @param {object} [region] region name in case of multipack textures
|
|
293
|
+
* @param {object} [region] - region name in case of multipack textures
|
|
294
294
|
* @returns {HTMLImageElement|HTMLCanvasElement}
|
|
295
295
|
*/
|
|
296
296
|
getTexture(region) {
|
|
@@ -303,11 +303,11 @@ export class TextureAtlas {
|
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
* add a region to the atlas
|
|
306
|
-
* @param {string} name region mame
|
|
307
|
-
* @param {number} x x origin of the region
|
|
308
|
-
* @param {number} y y origin of the region
|
|
309
|
-
* @param {number} w width of the region
|
|
310
|
-
* @param {number} h height of the region
|
|
306
|
+
* @param {string} name - region mame
|
|
307
|
+
* @param {number} x - x origin of the region
|
|
308
|
+
* @param {number} y - y origin of the region
|
|
309
|
+
* @param {number} w - width of the region
|
|
310
|
+
* @param {number} h - height of the region
|
|
311
311
|
* @returns {object} the created region
|
|
312
312
|
*/
|
|
313
313
|
addRegion(name, x, y, w, h) {
|
|
@@ -336,8 +336,8 @@ export class TextureAtlas {
|
|
|
336
336
|
|
|
337
337
|
/**
|
|
338
338
|
* return a normalized region (or frame) information for the specified sprite name
|
|
339
|
-
* @param {string} name name of the sprite
|
|
340
|
-
* @param {string} [atlas] name of a specific atlas where to search for the region
|
|
339
|
+
* @param {string} name - name of the sprite
|
|
340
|
+
* @param {string} [atlas] - name of a specific atlas where to search for the region
|
|
341
341
|
* @returns {object}
|
|
342
342
|
*/
|
|
343
343
|
getRegion(name, atlas) {
|
|
@@ -358,7 +358,7 @@ export class TextureAtlas {
|
|
|
358
358
|
|
|
359
359
|
/**
|
|
360
360
|
* return the uvs mapping for the given region
|
|
361
|
-
* @param {object} name region (or frame) name
|
|
361
|
+
* @param {object} name - region (or frame) name
|
|
362
362
|
* @returns {Float32Array} region Uvs
|
|
363
363
|
*/
|
|
364
364
|
getUVs(name) {
|
|
@@ -379,10 +379,10 @@ export class TextureAtlas {
|
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
381
|
* add uvs mapping for the given region
|
|
382
|
-
* @param {object} atlas the atlas dictionnary where the region is define
|
|
383
|
-
* @param {object} name region (or frame) name
|
|
384
|
-
* @param {number} w the width of the region
|
|
385
|
-
* @param {number} h the height of the region
|
|
382
|
+
* @param {object} atlas - the atlas dictionnary where the region is define
|
|
383
|
+
* @param {object} name - region (or frame) name
|
|
384
|
+
* @param {number} w - the width of the region
|
|
385
|
+
* @param {number} h - the height of the region
|
|
386
386
|
* @returns {Float32Array} the created region UVs
|
|
387
387
|
*/
|
|
388
388
|
addUVs(atlas, name, w, h) {
|
|
@@ -409,9 +409,9 @@ export class TextureAtlas {
|
|
|
409
409
|
|
|
410
410
|
/**
|
|
411
411
|
* Create a sprite object using the first region found using the specified name
|
|
412
|
-
* @param {string} name name of the sprite
|
|
413
|
-
* @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
|
|
414
|
-
* @param {boolean} [nineSlice=false] if true returns a 9-slice sprite
|
|
412
|
+
* @param {string} name - name of the sprite
|
|
413
|
+
* @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
|
|
414
|
+
* @param {boolean} [nineSlice=false] - if true returns a 9-slice sprite
|
|
415
415
|
* @returns {Sprite|NineSliceSprite}
|
|
416
416
|
* @example
|
|
417
417
|
* // create a new texture object under the `game` namespace
|
|
@@ -449,9 +449,9 @@ export class TextureAtlas {
|
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
451
|
* Create an animation object using the first region found using all specified names
|
|
452
|
-
* @param {string[]|number[]} names list of names for each sprite
|
|
452
|
+
* @param {string[]|number[]} names - list of names for each sprite
|
|
453
453
|
* (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
|
|
454
|
-
* @param {object} [settings] Additional settings passed to the {@link Sprite} contructor
|
|
454
|
+
* @param {object} [settings] - Additional settings passed to the {@link Sprite} contructor
|
|
455
455
|
* @returns {Sprite}
|
|
456
456
|
* @example
|
|
457
457
|
* // create a new texture object under the `game` namespace
|
|
@@ -14,13 +14,13 @@ var defaultAttributes = {
|
|
|
14
14
|
*/
|
|
15
15
|
class CanvasTexture {
|
|
16
16
|
/**
|
|
17
|
-
* @param {number} width the desired width of the canvas
|
|
18
|
-
* @param {number} height the desired height of the canvas
|
|
19
|
-
* @param {object} attributes The attributes to create both the canvas and context
|
|
20
|
-
* @param {boolean} [attributes.context="2d"] the context type to be created ("2d", "webgl", "webgl2")
|
|
21
|
-
* @param {boolean} [attributes.offscreenCanvas=false] will create an offscreenCanvas if true instead of a standard canvas
|
|
22
|
-
* @param {boolean} [attributes.willReadFrequently=false] Indicates whether or not a lot of read-back operations are planned
|
|
23
|
-
* @param {boolean} [attributes.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
17
|
+
* @param {number} width - the desired width of the canvas
|
|
18
|
+
* @param {number} height - the desired height of the canvas
|
|
19
|
+
* @param {object} attributes - The attributes to create both the canvas and context
|
|
20
|
+
* @param {boolean} [attributes.context="2d"] - the context type to be created ("2d", "webgl", "webgl2")
|
|
21
|
+
* @param {boolean} [attributes.offscreenCanvas=false] - will create an offscreenCanvas if true instead of a standard canvas
|
|
22
|
+
* @param {boolean} [attributes.willReadFrequently=false] - Indicates whether or not a lot of read-back operations are planned
|
|
23
|
+
* @param {boolean} [attributes.antiAlias=false] - Whether to enable anti-aliasing, use false (default) for a pixelated effect.
|
|
24
24
|
*/
|
|
25
25
|
constructor(width, height, attributes = defaultAttributes) {
|
|
26
26
|
|
|
@@ -89,8 +89,8 @@ class CanvasTexture {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Resizes the canvas texture to the given width and height.
|
|
92
|
-
* @param {number} width the desired width
|
|
93
|
-
* @param {number} height the desired height
|
|
92
|
+
* @param {number} width - the desired width
|
|
93
|
+
* @param {number} height - the desired height
|
|
94
94
|
*/
|
|
95
95
|
resize(width, height) {
|
|
96
96
|
this.canvas.width = Math.round(width);
|
package/src/video/video.js
CHANGED
|
@@ -194,18 +194,18 @@ export let renderer = null;
|
|
|
194
194
|
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
195
195
|
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
196
196
|
* @function video.init
|
|
197
|
-
* @param {number} width The width of the canvas viewport
|
|
198
|
-
* @param {number} height The height of the canvas viewport
|
|
199
|
-
* @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
|
|
200
|
-
* @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
|
|
201
|
-
* @param {number} [options.renderer=video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
|
|
202
|
-
* @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
|
|
203
|
-
* @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
204
|
-
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
205
|
-
* @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.
|
|
206
|
-
* @param {boolean} [options.transparent=false] whether to allow transparent pixels in the front buffer (screen).
|
|
207
|
-
* @param {boolean} [options.antiAlias=false] whether to enable or not video scaling interpolation
|
|
208
|
-
* @param {boolean} [options.consoleHeader=true] whether to display melonJS version and basic device information in the console
|
|
197
|
+
* @param {number} width - The width of the canvas viewport
|
|
198
|
+
* @param {number} height - The height of the canvas viewport
|
|
199
|
+
* @param {object} [options] - The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
|
|
200
|
+
* @param {string|HTMLElement} [options.parent=document.body] - the DOM parent element to hold the canvas in the HTML file
|
|
201
|
+
* @param {number} [options.renderer=video.AUTO] - renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
|
|
202
|
+
* @param {number|string} [options.scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
|
|
203
|
+
* @param {string} [options.scaleMethod="fit"] - screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
204
|
+
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
205
|
+
* @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.
|
|
206
|
+
* @param {boolean} [options.transparent=false] - whether to allow transparent pixels in the front buffer (screen).
|
|
207
|
+
* @param {boolean} [options.antiAlias=false] - whether to enable or not video scaling interpolation
|
|
208
|
+
* @param {boolean} [options.consoleHeader=true] - whether to display melonJS version and basic device information in the console
|
|
209
209
|
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
210
210
|
* @example
|
|
211
211
|
* // init the video with a 640x480 canvas
|
|
@@ -381,9 +381,9 @@ export function init(width, height, options) {
|
|
|
381
381
|
/**
|
|
382
382
|
* Create and return a new Canvas element
|
|
383
383
|
* @function video.createCanvas
|
|
384
|
-
* @param {number} width width
|
|
385
|
-
* @param {number} height height
|
|
386
|
-
* @param {boolean} [returnOffscreenCanvas=false] will return an OffscreenCanvas if supported
|
|
384
|
+
* @param {number} width - width
|
|
385
|
+
* @param {number} height - height
|
|
386
|
+
* @param {boolean} [returnOffscreenCanvas=false] - will return an OffscreenCanvas if supported
|
|
387
387
|
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
388
388
|
*/
|
|
389
389
|
export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
@@ -425,8 +425,8 @@ export function getParent() {
|
|
|
425
425
|
* Only use this if you are not using the automatic scaling feature.
|
|
426
426
|
* @function video.scale
|
|
427
427
|
* @see video.init
|
|
428
|
-
* @param {number} x x scaling multiplier
|
|
429
|
-
* @param {number} y y scaling multiplier
|
|
428
|
+
* @param {number} x - x scaling multiplier
|
|
429
|
+
* @param {number} y - y scaling multiplier
|
|
430
430
|
*/
|
|
431
431
|
export function scale(x, y) {
|
|
432
432
|
var canvas = renderer.getCanvas();
|