melonjs 14.0.2 → 14.1.1
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 +238 -0
- package/dist/melonjs.mjs/audio/audio.js +536 -0
- package/dist/melonjs.mjs/camera/camera2d.js +731 -0
- package/dist/melonjs.mjs/entity/entity.js +247 -0
- package/dist/melonjs.mjs/game.js +29 -0
- package/dist/melonjs.mjs/geometries/ellipse.js +274 -0
- package/dist/melonjs.mjs/geometries/line.js +115 -0
- package/dist/melonjs.mjs/geometries/path2d.js +318 -0
- package/dist/melonjs.mjs/geometries/point.js +88 -0
- package/dist/melonjs.mjs/geometries/poly.js +498 -0
- package/dist/melonjs.mjs/geometries/rectangle.js +374 -0
- package/dist/melonjs.mjs/geometries/roundrect.js +167 -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 +446 -0
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +193 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +636 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +309 -0
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +81 -0
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +504 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +218 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +155 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +124 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +107 -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 +616 -0
- package/dist/melonjs.mjs/math/math.js +218 -0
- package/dist/melonjs.mjs/math/matrix2.js +501 -0
- package/dist/melonjs.mjs/math/matrix3.js +679 -0
- package/dist/melonjs.mjs/math/observable_vector2.js +469 -0
- package/dist/melonjs.mjs/math/observable_vector3.js +559 -0
- package/dist/melonjs.mjs/math/vector2.js +526 -0
- package/dist/melonjs.mjs/math/vector3.js +567 -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 +265 -0
- package/dist/melonjs.mjs/particles/particle.js +186 -0
- package/dist/melonjs.mjs/particles/settings.js +319 -0
- package/dist/melonjs.mjs/physics/body.js +702 -0
- package/dist/melonjs.mjs/physics/bounds.js +459 -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 +394 -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 +219 -0
- package/dist/melonjs.mjs/plugin/plugin.js +141 -0
- package/dist/melonjs.mjs/renderable/collectable.js +60 -0
- package/dist/melonjs.mjs/renderable/colorlayer.js +78 -0
- package/dist/melonjs.mjs/renderable/container.js +1016 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
- package/dist/melonjs.mjs/renderable/imagelayer.js +305 -0
- package/dist/melonjs.mjs/renderable/light2d.js +155 -0
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +246 -0
- package/dist/melonjs.mjs/renderable/renderable.js +781 -0
- package/dist/melonjs.mjs/renderable/sprite.js +653 -0
- package/dist/melonjs.mjs/renderable/trigger.js +156 -0
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +212 -0
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +225 -0
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +127 -0
- package/dist/melonjs.mjs/state/stage.js +236 -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 +363 -0
- package/dist/melonjs.mjs/text/bitmaptextdata.js +198 -0
- package/dist/melonjs.mjs/text/glyph.js +65 -0
- package/dist/melonjs.mjs/text/text.js +452 -0
- package/dist/melonjs.mjs/text/textmetrics.js +175 -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 +479 -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 +806 -0
- package/dist/melonjs.mjs/video/renderer.js +410 -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 +142 -0
- package/dist/melonjs.mjs/video/webgl/glshader.js +167 -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 +494 -0
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1035 -0
- package/dist/melonjs.module.d.ts +1298 -1359
- package/dist/melonjs.module.js +2072 -3520
- package/package.json +21 -16
- package/src/application/application.js +4 -5
- package/src/audio/audio.js +32 -32
- package/src/camera/camera2d.js +32 -33
- package/src/entity/entity.js +18 -19
- package/src/geometries/ellipse.js +17 -18
- package/src/geometries/line.js +6 -7
- package/src/geometries/path2d.js +33 -34
- package/src/geometries/point.js +1 -2
- package/src/geometries/poly.js +16 -18
- package/src/geometries/rectangle.js +19 -20
- package/src/geometries/roundrect.js +9 -10
- 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 +23 -24
- package/src/level/tiled/TMXTile.js +6 -7
- package/src/level/tiled/TMXTileMap.js +8 -10
- package/src/level/tiled/TMXTileset.js +3 -4
- package/src/level/tiled/TMXTilesetGroup.js +1 -2
- package/src/level/tiled/TMXUtils.js +5 -5
- 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 +20 -21
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -2
- package/src/loader/loader.js +20 -20
- package/src/math/color.js +21 -22
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +17 -18
- package/src/math/matrix3.js +26 -27
- package/src/math/observable_vector2.js +15 -16
- package/src/math/observable_vector3.js +17 -18
- package/src/math/vector2.js +10 -11
- package/src/math/vector3.js +11 -12
- package/src/particles/emitter.js +7 -8
- package/src/particles/particle.js +3 -4
- package/src/physics/body.js +29 -30
- package/src/physics/bounds.js +10 -10
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +6 -6
- package/src/physics/quadtree.js +18 -23
- package/src/physics/sat.js +31 -31
- package/src/physics/world.js +6 -7
- package/src/plugin/plugin.js +5 -5
- package/src/renderable/collectable.js +4 -6
- package/src/renderable/colorlayer.js +6 -8
- package/src/renderable/container.js +25 -27
- package/src/renderable/dragndrop.js +14 -14
- package/src/renderable/imagelayer.js +14 -15
- package/src/renderable/light2d.js +4 -5
- package/src/renderable/nineslicesprite.js +17 -18
- package/src/renderable/renderable.js +26 -28
- package/src/renderable/sprite.js +29 -30
- package/src/renderable/trigger.js +16 -17
- package/src/renderable/ui/uibaseelement.js +8 -9
- package/src/renderable/ui/uispriteelement.js +8 -8
- package/src/renderable/ui/uitextbutton.js +15 -15
- package/src/state/stage.js +8 -9
- 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 +19 -20
- package/src/text/bitmaptextdata.js +3 -4
- package/src/text/glyph.js +1 -2
- package/src/text/text.js +24 -25
- package/src/text/textmetrics.js +9 -10
- package/src/tweens/tween.js +20 -21
- 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 +72 -73
- package/src/video/renderer.js +27 -28
- 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/buffer/vertex.js +1 -2
- package/src/video/webgl/glshader.js +12 -12
- package/src/video/webgl/webgl_compositor.js +42 -43
- package/src/video/webgl/webgl_renderer.js +76 -77
package/src/state/state.js
CHANGED
|
@@ -68,7 +68,7 @@ function _pauseRunLoop() {
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* this is only called when using requestAnimFrame stuff
|
|
71
|
-
* @param {number} time current timestamp in milliseconds
|
|
71
|
+
* @param {number} time - current timestamp in milliseconds
|
|
72
72
|
* @ignore
|
|
73
73
|
*/
|
|
74
74
|
function _renderFrame(time) {
|
|
@@ -296,7 +296,7 @@ var state = {
|
|
|
296
296
|
* @name stop
|
|
297
297
|
* @memberof state
|
|
298
298
|
* @public
|
|
299
|
-
* @param {boolean} [pauseTrack=false] pause current track on screen stop.
|
|
299
|
+
* @param {boolean} [pauseTrack=false] - pause current track on screen stop.
|
|
300
300
|
*/
|
|
301
301
|
stop(pauseTrack=false) {
|
|
302
302
|
// only stop when we are not loading stuff
|
|
@@ -322,7 +322,7 @@ var state = {
|
|
|
322
322
|
* @name pause
|
|
323
323
|
* @memberof state
|
|
324
324
|
* @public
|
|
325
|
-
* @param {boolean} [music=false] pause current music track on screen pause
|
|
325
|
+
* @param {boolean} [music=false] - pause current music track on screen pause
|
|
326
326
|
*/
|
|
327
327
|
pause(music=false) {
|
|
328
328
|
// only pause when we are not loading stuff
|
|
@@ -347,7 +347,7 @@ var state = {
|
|
|
347
347
|
* @name restart
|
|
348
348
|
* @memberof state
|
|
349
349
|
* @public
|
|
350
|
-
* @param {boolean} [music=false] resume current music track on screen resume
|
|
350
|
+
* @param {boolean} [music=false] - resume current music track on screen resume
|
|
351
351
|
*/
|
|
352
352
|
restart(music=false) {
|
|
353
353
|
if (!this.isRunning()) {
|
|
@@ -374,7 +374,7 @@ var state = {
|
|
|
374
374
|
* @name resume
|
|
375
375
|
* @memberof state
|
|
376
376
|
* @public
|
|
377
|
-
* @param {boolean} [music=false] resume current music track on screen resume
|
|
377
|
+
* @param {boolean} [music=false] - resume current music track on screen resume
|
|
378
378
|
*/
|
|
379
379
|
resume(music=false) {
|
|
380
380
|
if (this.isPaused()) {
|
|
@@ -420,9 +420,9 @@ var state = {
|
|
|
420
420
|
* @name set
|
|
421
421
|
* @memberof state
|
|
422
422
|
* @public
|
|
423
|
-
* @param {number} state State ID (see constants)
|
|
424
|
-
* @param {Stage} stage Instantiated Stage to associate with state ID
|
|
425
|
-
* @param {boolean} [start = false] if true the state will be changed immediately after adding it.
|
|
423
|
+
* @param {number} state - State ID (see constants)
|
|
424
|
+
* @param {Stage} stage - Instantiated Stage to associate with state ID
|
|
425
|
+
* @param {boolean} [start = false] - if true the state will be changed immediately after adding it.
|
|
426
426
|
* @example
|
|
427
427
|
* class MenuButton extends me.GUI_Object {
|
|
428
428
|
* onClick() {
|
|
@@ -479,7 +479,7 @@ var state = {
|
|
|
479
479
|
* @name set
|
|
480
480
|
* @memberof state
|
|
481
481
|
* @public
|
|
482
|
-
* @param {number} [state] State ID (see constants)
|
|
482
|
+
* @param {number} [state] - State ID (see constants)
|
|
483
483
|
* @returns {Stage}
|
|
484
484
|
*/
|
|
485
485
|
get(state = _state) {
|
|
@@ -508,9 +508,9 @@ var state = {
|
|
|
508
508
|
* @name transition
|
|
509
509
|
* @memberof state
|
|
510
510
|
* @public
|
|
511
|
-
* @param {string} effect (only "fade" is supported for now)
|
|
512
|
-
* @param {Color|string} color a CSS color value
|
|
513
|
-
* @param {number} [duration=1000] expressed in milliseconds
|
|
511
|
+
* @param {string} effect - (only "fade" is supported for now)
|
|
512
|
+
* @param {Color|string} color - a CSS color value
|
|
513
|
+
* @param {number} [duration=1000] - expressed in milliseconds
|
|
514
514
|
*/
|
|
515
515
|
transition(effect, color, duration) {
|
|
516
516
|
if (effect === "fade") {
|
|
@@ -524,7 +524,7 @@ var state = {
|
|
|
524
524
|
* @name setTransition
|
|
525
525
|
* @memberof state
|
|
526
526
|
* @public
|
|
527
|
-
* @param {number} state State ID (see constants)
|
|
527
|
+
* @param {number} state - State ID (see constants)
|
|
528
528
|
* @param {boolean} enable
|
|
529
529
|
*/
|
|
530
530
|
setTransition(state, enable) {
|
|
@@ -536,9 +536,9 @@ var state = {
|
|
|
536
536
|
* @name change
|
|
537
537
|
* @memberof state
|
|
538
538
|
* @public
|
|
539
|
-
* @param {number} state State ID (see constants)
|
|
540
|
-
* @param {boolean} forceChange if true the state will be changed immediately
|
|
541
|
-
* @param {object} [...arguments] extra arguments to be passed to the reset functions
|
|
539
|
+
* @param {number} state - State ID (see constants)
|
|
540
|
+
* @param {boolean} forceChange - if true the state will be changed immediately
|
|
541
|
+
* @param {object} [...arguments] - extra arguments to be passed to the reset functions
|
|
542
542
|
* @example
|
|
543
543
|
* // The onResetEvent method on the play screen will receive two args:
|
|
544
544
|
* // "level_1" and the number 3
|
|
@@ -589,7 +589,7 @@ var state = {
|
|
|
589
589
|
* @name isCurrent
|
|
590
590
|
* @memberof state
|
|
591
591
|
* @public
|
|
592
|
-
* @param {number} state State ID (see constants)
|
|
592
|
+
* @param {number} state - State ID (see constants)
|
|
593
593
|
* @returns {boolean} true if the specified state is the current one
|
|
594
594
|
*/
|
|
595
595
|
isCurrent(state) {
|
package/src/system/device.js
CHANGED
|
@@ -389,7 +389,7 @@ export let stopOnBlur = false;
|
|
|
389
389
|
* @function onReady
|
|
390
390
|
* @memberof device
|
|
391
391
|
* @public
|
|
392
|
-
* @param {Function} fn the function to be executed
|
|
392
|
+
* @param {Function} fn - the function to be executed
|
|
393
393
|
* @example
|
|
394
394
|
* // small game skeleton
|
|
395
395
|
* var game = {
|
|
@@ -438,7 +438,7 @@ export function onReady(fn) {
|
|
|
438
438
|
* @function enableSwipe
|
|
439
439
|
* @memberof device
|
|
440
440
|
* @public
|
|
441
|
-
* @param {boolean} [enable=true] enable or disable swipe.
|
|
441
|
+
* @param {boolean} [enable=true] - enable or disable swipe.
|
|
442
442
|
*/
|
|
443
443
|
export function enableSwipe(enable) {
|
|
444
444
|
let moveEvent = pointerEvent ? "pointermove" : (touchEvent ? "touchmove" : "mousemove");
|
|
@@ -473,7 +473,7 @@ export function isFullscreen() {
|
|
|
473
473
|
* @function requestFullscreen
|
|
474
474
|
* @memberof device
|
|
475
475
|
* @public
|
|
476
|
-
* @param {object} [element=default canvas object] the element to be set in full-screen mode.
|
|
476
|
+
* @param {object} [element=default canvas object] - the element to be set in full-screen mode.
|
|
477
477
|
* @example
|
|
478
478
|
* // add a keyboard shortcut to toggle Fullscreen mode on/off
|
|
479
479
|
* me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
|
|
@@ -549,7 +549,7 @@ export function getScreenOrientation() {
|
|
|
549
549
|
* @memberof device
|
|
550
550
|
* @public
|
|
551
551
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
|
|
552
|
-
* @param {string|string[]} orientation The orientation into which to lock the screen.
|
|
552
|
+
* @param {string|string[]} orientation - The orientation into which to lock the screen.
|
|
553
553
|
* @returns {boolean} true if the orientation was unsuccessfully locked
|
|
554
554
|
*/
|
|
555
555
|
export function lockOrientation(orientation) {
|
|
@@ -629,7 +629,7 @@ export function getStorage(type = "local") {
|
|
|
629
629
|
* @function getParentElement
|
|
630
630
|
* @memberof device
|
|
631
631
|
* @public
|
|
632
|
-
* @param {string|HTMLElement} element the parent element name or a HTMLElement object
|
|
632
|
+
* @param {string|HTMLElement} element - the parent element name or a HTMLElement object
|
|
633
633
|
* @returns {HTMLElement} the parent Element
|
|
634
634
|
*/
|
|
635
635
|
export function getParentElement(element) {
|
|
@@ -647,7 +647,7 @@ export function getParentElement(element) {
|
|
|
647
647
|
* @function getElement
|
|
648
648
|
* @memberof device
|
|
649
649
|
* @public
|
|
650
|
-
* @param {string|HTMLElement} element the parent element name or a HTMLElement object
|
|
650
|
+
* @param {string|HTMLElement} element - the parent element name or a HTMLElement object
|
|
651
651
|
* @returns {HTMLElement} the corresponding DOM Element or null if not existing
|
|
652
652
|
*/
|
|
653
653
|
export function getElement(element) {
|
|
@@ -677,7 +677,7 @@ export function getElement(element) {
|
|
|
677
677
|
* @memberof device
|
|
678
678
|
* @public
|
|
679
679
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
|
|
680
|
-
* @param {string|HTMLElement} element an HTMLElement object
|
|
680
|
+
* @param {string|HTMLElement} element - an HTMLElement object
|
|
681
681
|
* @returns {DOMRect} the size and position of the element relatively to the viewport
|
|
682
682
|
*/
|
|
683
683
|
export function getElementBounds(element) {
|
|
@@ -697,7 +697,7 @@ export function getElementBounds(element) {
|
|
|
697
697
|
* @memberof device
|
|
698
698
|
* @public
|
|
699
699
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
|
|
700
|
-
* @param {string|HTMLElement} element an HTMLElement object
|
|
700
|
+
* @param {string|HTMLElement} element - an HTMLElement object
|
|
701
701
|
* @returns {DOMRect} the size and position of the given element parent relative to the viewport
|
|
702
702
|
*/
|
|
703
703
|
export function getParentBounds(element) {
|
|
@@ -709,8 +709,8 @@ export function getParentBounds(element) {
|
|
|
709
709
|
* @function isWebGLSupported
|
|
710
710
|
* @memberof device
|
|
711
711
|
* @public
|
|
712
|
-
* @param {object} [options] context creation options
|
|
713
|
-
* @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.
|
|
712
|
+
* @param {object} [options] - context creation options
|
|
713
|
+
* @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.
|
|
714
714
|
* @returns {boolean} true if WebGL is supported
|
|
715
715
|
*/
|
|
716
716
|
export function isWebGLSupported(options) {
|
|
@@ -882,7 +882,7 @@ export function unwatchDeviceOrientation() {
|
|
|
882
882
|
* @function vibrate
|
|
883
883
|
* @memberof device
|
|
884
884
|
* @public
|
|
885
|
-
* @param {number|number[]} pattern pattern of vibration and pause intervals
|
|
885
|
+
* @param {number|number[]} pattern - pattern of vibration and pause intervals
|
|
886
886
|
* @example
|
|
887
887
|
* // vibrate for 1000 ms
|
|
888
888
|
* me.device.vibrate(1000);
|
package/src/system/event.js
CHANGED
|
@@ -473,8 +473,8 @@ export const ONCONTEXT_RESTORED = "renderer.contextrestored";
|
|
|
473
473
|
/**
|
|
474
474
|
* calls each of the listeners registered for a given event.
|
|
475
475
|
* @function event.emit
|
|
476
|
-
* @param {string|symbol} eventName The event name.
|
|
477
|
-
* @param {object} [...arguments] arguments to be passed to all listeners
|
|
476
|
+
* @param {string|symbol} eventName - The event name.
|
|
477
|
+
* @param {object} [...arguments] - arguments to be passed to all listeners
|
|
478
478
|
* @returns {boolean} true if the event had listeners, false otherwise.
|
|
479
479
|
* @example
|
|
480
480
|
* me.event.emit("event-name", a, b, c);
|
|
@@ -486,9 +486,9 @@ export function emit(eventName, ...args) {
|
|
|
486
486
|
/**
|
|
487
487
|
* Add a listener for a given event.
|
|
488
488
|
* @function event.on
|
|
489
|
-
* @param {string|symbol} eventName The event name.
|
|
490
|
-
* @param {Function} listener The listener function.
|
|
491
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
489
|
+
* @param {string|symbol} eventName - The event name.
|
|
490
|
+
* @param {Function} listener - The listener function.
|
|
491
|
+
* @param {*} [context=this] - The context to invoke the listener with.
|
|
492
492
|
* @returns {EventEmitter} `this`.
|
|
493
493
|
* @public
|
|
494
494
|
* @example
|
|
@@ -501,9 +501,9 @@ export function on(eventName, listener, context) {
|
|
|
501
501
|
/**
|
|
502
502
|
* Add a one-time listener for a given event.
|
|
503
503
|
* @function event.once
|
|
504
|
-
* @param {string|symbol} eventName The event name.
|
|
505
|
-
* @param {Function} listener The listener function.
|
|
506
|
-
* @param {*} [context=this] The context to invoke the listener with.
|
|
504
|
+
* @param {string|symbol} eventName - The event name.
|
|
505
|
+
* @param {Function} listener - The listener function.
|
|
506
|
+
* @param {*} [context=this] - The context to invoke the listener with.
|
|
507
507
|
* @returns {EventEmitter} `this`.
|
|
508
508
|
* @public
|
|
509
509
|
* @example
|
|
@@ -516,8 +516,8 @@ export function once(eventName, listener, context) {
|
|
|
516
516
|
/**
|
|
517
517
|
* remove the given listener for a given event.
|
|
518
518
|
* @function event.off
|
|
519
|
-
* @param {string|symbol} eventName The event name.
|
|
520
|
-
* @param {Function} listener The listener function.
|
|
519
|
+
* @param {string|symbol} eventName - The event name.
|
|
520
|
+
* @param {Function} listener - The listener function.
|
|
521
521
|
* @returns {EventEmitter} `this`.
|
|
522
522
|
* @public
|
|
523
523
|
* @example
|
package/src/system/pooling.js
CHANGED
|
@@ -23,9 +23,9 @@ class ObjectPool {
|
|
|
23
23
|
* register an object to the pool. <br>
|
|
24
24
|
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
25
25
|
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
26
|
-
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
27
|
-
* @param {object} classObj corresponding Class to be instantiated
|
|
28
|
-
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
26
|
+
* @param {string} className - as defined in the Name field of the Object Properties (in Tiled)
|
|
27
|
+
* @param {object} classObj - corresponding Class to be instantiated
|
|
28
|
+
* @param {boolean} [recycling=false] - enables object recycling for the specified class
|
|
29
29
|
* @example
|
|
30
30
|
* // implement CherryEntity
|
|
31
31
|
* class CherryEntity extends Spritesheet {
|
|
@@ -50,8 +50,8 @@ class ObjectPool {
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Pull a new instance of the requested object (if added into the object pool)
|
|
53
|
-
* @param {string} name as used in {@link pool.register}
|
|
54
|
-
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
53
|
+
* @param {string} name - as used in {@link pool.register}
|
|
54
|
+
* @param {object} [...arguments] - arguments to be passed when instantiating/reinitializing the object
|
|
55
55
|
* @returns {object} the instance of the requested object
|
|
56
56
|
* @example
|
|
57
57
|
* me.pool.register("bullet", BulletEntity, true);
|
|
@@ -122,8 +122,8 @@ class ObjectPool {
|
|
|
122
122
|
* and object must have been instantiated using {@link pool#pull},
|
|
123
123
|
* otherwise this function won't work
|
|
124
124
|
* @throws will throw an error if the object cannot be recycled
|
|
125
|
-
* @param {object} obj instance to be recycled
|
|
126
|
-
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
125
|
+
* @param {object} obj - instance to be recycled
|
|
126
|
+
* @param {boolean} [throwOnError=true] - throw an exception if the object cannot be recycled
|
|
127
127
|
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
128
128
|
*/
|
|
129
129
|
push(obj, throwOnError = true) {
|
|
@@ -144,7 +144,7 @@ class ObjectPool {
|
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Check if an object with the provided name is registered
|
|
147
|
-
* @param {string} name of the registered object class
|
|
147
|
+
* @param {string} name - of the registered object class
|
|
148
148
|
* @returns {boolean} true if the classname is registered
|
|
149
149
|
*/
|
|
150
150
|
exists(name) {
|
|
@@ -155,7 +155,7 @@ class ObjectPool {
|
|
|
155
155
|
* Check if an object is poolable
|
|
156
156
|
* (was properly registered with the recycling feature enable)
|
|
157
157
|
* @see register
|
|
158
|
-
* @param {object} obj object to be checked
|
|
158
|
+
* @param {object} obj - object to be checked
|
|
159
159
|
* @returns {boolean} true if the object is poolable
|
|
160
160
|
* @example
|
|
161
161
|
* if (!me.pool.poolable(myCherryEntity)) {
|
package/src/system/save.js
CHANGED
|
@@ -74,7 +74,7 @@ var save = {
|
|
|
74
74
|
* Add new keys to localStorage and set them to the given default values if they do not exist
|
|
75
75
|
* @name add
|
|
76
76
|
* @memberof save
|
|
77
|
-
* @param {object} props key and corresponding values
|
|
77
|
+
* @param {object} props - key and corresponding values
|
|
78
78
|
* @example
|
|
79
79
|
* // Initialize "score" and "lives" with default values
|
|
80
80
|
* me.save.add({ score : 0, lives : 3 });
|
|
@@ -127,7 +127,7 @@ var save = {
|
|
|
127
127
|
* Remove a key from localStorage
|
|
128
128
|
* @name remove
|
|
129
129
|
* @memberof save
|
|
130
|
-
* @param {string} key key to be removed
|
|
130
|
+
* @param {string} key - key to be removed
|
|
131
131
|
* @example
|
|
132
132
|
* // Remove the "score" key from localStorage
|
|
133
133
|
* me.save.remove("score");
|
package/src/system/timer.js
CHANGED
|
@@ -105,10 +105,10 @@ class Timer {
|
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Calls a function once after a specified delay. See me.timer.setInterval to repeativly call a function.
|
|
108
|
-
* @param {Function} fn the function you want to execute after delay milliseconds.
|
|
109
|
-
* @param {number} delay the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
110
|
-
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
111
|
-
* @param {...*} args optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
108
|
+
* @param {Function} fn - the function you want to execute after delay milliseconds.
|
|
109
|
+
* @param {number} delay - the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
110
|
+
* @param {boolean} [pauseable=true] - respects the pause state of the engine.
|
|
111
|
+
* @param {...*} args - optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
112
112
|
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearTimeout().
|
|
113
113
|
* @example
|
|
114
114
|
* // set a timer to call "myFunction" after 1000ms
|
|
@@ -131,10 +131,10 @@ class Timer {
|
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Calls a function continously at the specified interval. See setTimeout to call function a single time.
|
|
134
|
-
* @param {Function} fn the function to execute
|
|
135
|
-
* @param {number} delay the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
136
|
-
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
137
|
-
* @param {...*} args optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
134
|
+
* @param {Function} fn - the function to execute
|
|
135
|
+
* @param {number} delay - the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
136
|
+
* @param {boolean} [pauseable=true] - respects the pause state of the engine.
|
|
137
|
+
* @param {...*} args - optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
138
138
|
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearInterval().
|
|
139
139
|
* @example
|
|
140
140
|
* // set a timer to call "myFunction" every 1000ms
|
|
@@ -157,7 +157,7 @@ class Timer {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* Clears the delay set by me.timer.setTimeout().
|
|
160
|
-
* @param {number} timeoutID ID of the timeout to be cleared
|
|
160
|
+
* @param {number} timeoutID - ID of the timeout to be cleared
|
|
161
161
|
*/
|
|
162
162
|
clearTimeout(timeoutID) {
|
|
163
163
|
utils.function.defer(this.clearTimer.bind(this), this, timeoutID);
|
|
@@ -165,7 +165,7 @@ class Timer {
|
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Clears the Interval set by me.timer.setInterval().
|
|
168
|
-
* @param {number} intervalID ID of the interval to be cleared
|
|
168
|
+
* @param {number} intervalID - ID of the interval to be cleared
|
|
169
169
|
*/
|
|
170
170
|
clearInterval(intervalID) {
|
|
171
171
|
utils.function.defer(this.clearTimer.bind(this), this, intervalID);
|
package/src/text/bitmaptext.js
CHANGED
|
@@ -9,22 +9,22 @@ import TextMetrics from "./textmetrics.js";
|
|
|
9
9
|
* a bitmap font object
|
|
10
10
|
* @augments Renderable
|
|
11
11
|
*/
|
|
12
|
-
class BitmapText extends Renderable {
|
|
12
|
+
export default class BitmapText extends Renderable {
|
|
13
13
|
/**
|
|
14
|
-
* @param {number} x position of the text object
|
|
15
|
-
* @param {number} y position of the text object
|
|
16
|
-
* @param {object} settings the text configuration
|
|
17
|
-
* @param {string|Image} settings.font a font name to identify the corresponing source image
|
|
18
|
-
* @param {string} [settings.fontData=settings.font] the bitmap font data corresponding name, or the bitmap font data itself
|
|
19
|
-
* @param {number} [settings.size] size a scaling ratio
|
|
20
|
-
* @param {Color|string} [settings.fillStyle] a CSS color value used to tint the bitmapText (@see BitmapText.tint)
|
|
21
|
-
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
22
|
-
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
23
|
-
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
24
|
-
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
25
|
-
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
26
|
-
* @param {number} [settings.wordWrapWidth] the maximum length in CSS pixel for a single segment of text
|
|
27
|
-
* @param {(string|string[])} [settings.text] a string, or an array of strings
|
|
14
|
+
* @param {number} x - position of the text object
|
|
15
|
+
* @param {number} y - position of the text object
|
|
16
|
+
* @param {object} settings - the text configuration
|
|
17
|
+
* @param {string|Image} settings.font - a font name to identify the corresponing source image
|
|
18
|
+
* @param {string} [settings.fontData=settings.font] - the bitmap font data corresponding name, or the bitmap font data itself
|
|
19
|
+
* @param {number} [settings.size] - size a scaling ratio
|
|
20
|
+
* @param {Color|string} [settings.fillStyle] - a CSS color value used to tint the bitmapText (@see BitmapText.tint)
|
|
21
|
+
* @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
|
|
22
|
+
* @param {string} [settings.textAlign="left"] - horizontal text alignment
|
|
23
|
+
* @param {string} [settings.textBaseline="top"] - the text baseline
|
|
24
|
+
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
25
|
+
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at
|
|
26
|
+
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
|
|
27
|
+
* @param {(string|string[])} [settings.text] - a string, or an array of strings
|
|
28
28
|
* @example
|
|
29
29
|
* // Use me.loader.preload or me.loader.load to load assets
|
|
30
30
|
* me.loader.preload([
|
|
@@ -142,7 +142,7 @@ class BitmapText extends Renderable {
|
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* change the font settings
|
|
145
|
-
* @param {string} textAlign ("left", "center", "right")
|
|
145
|
+
* @param {string} textAlign - ("left", "center", "right")
|
|
146
146
|
* @param {number} [scale]
|
|
147
147
|
* @returns {BitmapText} this object for chaining
|
|
148
148
|
*/
|
|
@@ -159,7 +159,7 @@ class BitmapText extends Renderable {
|
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* change the text to be displayed
|
|
162
|
-
* @param {number|string|string[]} value a string, or an array of strings
|
|
162
|
+
* @param {number|string|string[]} value - a string, or an array of strings
|
|
163
163
|
* @returns {BitmapText} this object for chaining
|
|
164
164
|
*/
|
|
165
165
|
setText(value = "") {
|
|
@@ -201,7 +201,7 @@ class BitmapText extends Renderable {
|
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
203
|
* change the font display size
|
|
204
|
-
* @param {number} scale ratio
|
|
204
|
+
* @param {number} scale - ratio
|
|
205
205
|
* @returns {BitmapText} this object for chaining
|
|
206
206
|
*/
|
|
207
207
|
resize(scale) {
|
|
@@ -226,7 +226,7 @@ class BitmapText extends Renderable {
|
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* draw the bitmap font
|
|
229
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
229
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
|
|
230
230
|
* @param {string} [text]
|
|
231
231
|
* @param {number} [x]
|
|
232
232
|
* @param {number} [y]
|
|
@@ -358,4 +358,3 @@ class BitmapText extends Renderable {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
}
|
|
361
|
-
export default BitmapText;
|
|
@@ -21,7 +21,7 @@ function getValueFromPair(string, pattern) {
|
|
|
21
21
|
* @ignore
|
|
22
22
|
* @name _getFirstGlyph
|
|
23
23
|
* @memberof BitmapTextData
|
|
24
|
-
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
24
|
+
* @param {object} glyphs - the map of glyphs, each key is a char code
|
|
25
25
|
* @returns {Glyph}
|
|
26
26
|
*/
|
|
27
27
|
function getFirstGlyph(glyphs) {
|
|
@@ -39,7 +39,7 @@ function getFirstGlyph(glyphs) {
|
|
|
39
39
|
* @ignore
|
|
40
40
|
* @name createSpaceGlyph
|
|
41
41
|
* @memberof BitmapTextData
|
|
42
|
-
* @param {object} glyphs the map of glyphs, each key is a char code
|
|
42
|
+
* @param {object} glyphs - the map of glyphs, each key is a char code
|
|
43
43
|
*/
|
|
44
44
|
function createSpaceGlyph(glyphs) {
|
|
45
45
|
var spaceCharCode = " ".charCodeAt(0);
|
|
@@ -56,7 +56,7 @@ function createSpaceGlyph(glyphs) {
|
|
|
56
56
|
* Class for storing relevant data from the font file.
|
|
57
57
|
* @ignore
|
|
58
58
|
*/
|
|
59
|
-
class BitmapTextData {
|
|
59
|
+
export default class BitmapTextData {
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* @param {string} data - The bitmap font data pulled from the resource loader using me.loader.getBinary()
|
|
@@ -187,4 +187,3 @@ class BitmapTextData {
|
|
|
187
187
|
this.capHeight -= padY;
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
export default BitmapTextData;
|
package/src/text/glyph.js
CHANGED
|
@@ -7,7 +7,7 @@ const PAGE_SIZE = 1 << LOG2_PAGE_SIZE;
|
|
|
7
7
|
* a glyph representing a single character in a font
|
|
8
8
|
* @ignore
|
|
9
9
|
*/
|
|
10
|
-
class Glyph {
|
|
10
|
+
export default class Glyph {
|
|
11
11
|
/**
|
|
12
12
|
* @ignore
|
|
13
13
|
*/
|
|
@@ -55,4 +55,3 @@ class Glyph {
|
|
|
55
55
|
page[ch & PAGE_SIZE - 1] = value;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
export default Glyph;
|
package/src/text/text.js
CHANGED
|
@@ -36,23 +36,23 @@ var getContext2d = function (renderer, text) {
|
|
|
36
36
|
* a generic system font object.
|
|
37
37
|
* @augments Renderable
|
|
38
38
|
*/
|
|
39
|
-
class Text extends Renderable {
|
|
39
|
+
export default class Text extends Renderable {
|
|
40
40
|
/**
|
|
41
|
-
* @param {number} x position of the text object
|
|
42
|
-
* @param {number} y position of the text object
|
|
43
|
-
* @param {object} settings the text configuration
|
|
44
|
-
* @param {string} settings.font a CSS family font name
|
|
45
|
-
* @param {number|string} settings.size size, or size + suffix (px, em, pt)
|
|
46
|
-
* @param {Color|string} [settings.fillStyle="#000000"] a CSS color value
|
|
47
|
-
* @param {Color|string} [settings.strokeStyle="#000000"] a CSS color value
|
|
48
|
-
* @param {number} [settings.lineWidth=1] line width, in pixels, when drawing stroke
|
|
49
|
-
* @param {string} [settings.textAlign="left"] horizontal text alignment
|
|
50
|
-
* @param {string} [settings.textBaseline="top"] the text baseline
|
|
51
|
-
* @param {number} [settings.lineHeight=1.0] line spacing height
|
|
52
|
-
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] anchor point to draw the text at
|
|
53
|
-
* @param {boolean} [settings.offScreenCanvas=false] whether to draw the font to an individual "cache" texture first
|
|
54
|
-
* @param {number} [settings.wordWrapWidth] the maximum length in CSS pixel for a single segment of text
|
|
55
|
-
* @param {(string|string[])} [settings.text=""] a string, or an array of strings
|
|
41
|
+
* @param {number} x - position of the text object
|
|
42
|
+
* @param {number} y - position of the text object
|
|
43
|
+
* @param {object} settings - the text configuration
|
|
44
|
+
* @param {string} settings.font - a CSS family font name
|
|
45
|
+
* @param {number|string} settings.size - size, or size + suffix (px, em, pt)
|
|
46
|
+
* @param {Color|string} [settings.fillStyle="#000000"] - a CSS color value
|
|
47
|
+
* @param {Color|string} [settings.strokeStyle="#000000"] - a CSS color value
|
|
48
|
+
* @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
|
|
49
|
+
* @param {string} [settings.textAlign="left"] - horizontal text alignment
|
|
50
|
+
* @param {string} [settings.textBaseline="top"] - the text baseline
|
|
51
|
+
* @param {number} [settings.lineHeight=1.0] - line spacing height
|
|
52
|
+
* @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at
|
|
53
|
+
* @param {boolean} [settings.offScreenCanvas=false] - whether to draw the font to an individual "cache" texture first
|
|
54
|
+
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
|
|
55
|
+
* @param {(string|string[])} [settings.text=""] - a string, or an array of strings
|
|
56
56
|
* @example
|
|
57
57
|
* var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
58
58
|
*/
|
|
@@ -226,8 +226,8 @@ class Text extends Renderable {
|
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* set the font family and size
|
|
229
|
-
* @param {string} font a CSS font name
|
|
230
|
-
* @param {number|string} [size=10] size in px, or size + suffix (px, em, pt)
|
|
229
|
+
* @param {string} font - a CSS font name
|
|
230
|
+
* @param {number|string} [size=10] - size in px, or size + suffix (px, em, pt)
|
|
231
231
|
* @returns {Text} this object for chaining
|
|
232
232
|
* @example
|
|
233
233
|
* font.setFont("Arial", 20);
|
|
@@ -267,7 +267,7 @@ class Text extends Renderable {
|
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* change the text to be displayed
|
|
270
|
-
* @param {number|string|string[]} value a string, or an array of strings
|
|
270
|
+
* @param {number|string|string[]} value - a string, or an array of strings
|
|
271
271
|
* @returns {Text} this object for chaining
|
|
272
272
|
*/
|
|
273
273
|
setText(value = "") {
|
|
@@ -323,8 +323,8 @@ class Text extends Renderable {
|
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* measure the given text size in pixels
|
|
326
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer reference to the active renderer
|
|
327
|
-
* @param {string} [text] the text to be measured
|
|
326
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - reference to the active renderer
|
|
327
|
+
* @param {string} [text] - the text to be measured
|
|
328
328
|
* @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
|
|
329
329
|
*/
|
|
330
330
|
measureText(renderer, text = this._text) {
|
|
@@ -334,11 +334,11 @@ class Text extends Renderable {
|
|
|
334
334
|
|
|
335
335
|
/**
|
|
336
336
|
* draw a text at the specified coord
|
|
337
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
337
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
|
|
338
338
|
* @param {string} [text]
|
|
339
339
|
* @param {number} [x]
|
|
340
340
|
* @param {number} [y]
|
|
341
|
-
* @param {boolean} [stroke=false] draw stroke the the text if true
|
|
341
|
+
* @param {boolean} [stroke=false] - draw stroke the the text if true
|
|
342
342
|
*/
|
|
343
343
|
draw(renderer, text, x = this.pos.x, y = this.pos.y, stroke = false) {
|
|
344
344
|
// "hacky patch" for backward compatibilty
|
|
@@ -394,7 +394,7 @@ class Text extends Renderable {
|
|
|
394
394
|
* draw a stroke text at the specified coord, as defined <br>
|
|
395
395
|
* by the `lineWidth` and `fillStroke` properties. <br>
|
|
396
396
|
* Note : using drawStroke is not recommended for performance reasons
|
|
397
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer Reference to the destination renderer instance
|
|
397
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
|
|
398
398
|
* @param {string} text
|
|
399
399
|
* @param {number} x
|
|
400
400
|
* @param {number} y
|
|
@@ -441,4 +441,3 @@ class Text extends Renderable {
|
|
|
441
441
|
super.destroy();
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
|
-
export default Text;
|
package/src/text/textmetrics.js
CHANGED
|
@@ -7,10 +7,10 @@ import setContextStyle from "./textstyle.js";
|
|
|
7
7
|
* a Text Metrics object that contains helper for text manipulation
|
|
8
8
|
* @augments Bounds
|
|
9
9
|
*/
|
|
10
|
-
class TextMetrics extends Bounds {
|
|
10
|
+
export default class TextMetrics extends Bounds {
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @param {Text|BitmapText} ancestor the parent object that contains this TextMetrics object
|
|
13
|
+
* @param {Text|BitmapText} ancestor - the parent object that contains this TextMetrics object
|
|
14
14
|
*/
|
|
15
15
|
constructor(ancestor) {
|
|
16
16
|
|
|
@@ -42,8 +42,8 @@ class TextMetrics extends Bounds {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Returns the width of the given segment of inline text in CSS pixels.
|
|
45
|
-
* @param {string} text the text to be measured
|
|
46
|
-
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
45
|
+
* @param {string} text - the text to be measured
|
|
46
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
47
47
|
* @returns {number} the width of the given segment of inline text in CSS pixels.
|
|
48
48
|
*/
|
|
49
49
|
lineWidth(text, context) {
|
|
@@ -68,8 +68,8 @@ class TextMetrics extends Bounds {
|
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* measure the given text size in CSS pixels
|
|
71
|
-
* @param {string} text the text to be measured
|
|
72
|
-
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
71
|
+
* @param {string} text - the text to be measured
|
|
72
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
73
73
|
* @returns {TextMetrics} this
|
|
74
74
|
*/
|
|
75
75
|
measureText(text, context) {
|
|
@@ -117,9 +117,9 @@ class TextMetrics extends Bounds {
|
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* wrap the given text based on the given width
|
|
120
|
-
* @param {string|string[]} text the text to be wrapped
|
|
121
|
-
* @param {number} width maximum width of one segment of text in css pixel
|
|
122
|
-
* @param {CanvasRenderingContext2D} [context] reference to an active 2d context for canvas rendering
|
|
120
|
+
* @param {string|string[]} text - the text to be wrapped
|
|
121
|
+
* @param {number} width - maximum width of one segment of text in css pixel
|
|
122
|
+
* @param {CanvasRenderingContext2D} [context] - reference to an active 2d context for canvas rendering
|
|
123
123
|
* @returns {string[]} an array of string representing wrapped text
|
|
124
124
|
*/
|
|
125
125
|
wordWrap(text, width, context) {
|
|
@@ -164,4 +164,3 @@ class TextMetrics extends Bounds {
|
|
|
164
164
|
return output;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
export default TextMetrics;
|