melonjs 15.3.0 → 15.4.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/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +1 -1
- package/dist/melonjs.mjs/application/application.js +53 -5
- package/dist/melonjs.mjs/application/header.js +2 -2
- package/dist/melonjs.mjs/application/resize.js +4 -8
- package/dist/melonjs.mjs/application/settings.js +5 -5
- package/dist/melonjs.mjs/audio/audio.js +4 -6
- package/dist/melonjs.mjs/camera/camera2d.js +12 -14
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +3 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
- package/dist/melonjs.mjs/geometries/line.js +18 -25
- package/dist/melonjs.mjs/geometries/path2d.js +16 -13
- package/dist/melonjs.mjs/geometries/point.js +8 -16
- package/dist/melonjs.mjs/geometries/poly.js +40 -97
- package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
- package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
- package/dist/melonjs.mjs/index.js +6 -6
- package/dist/melonjs.mjs/input/gamepad.js +1 -1
- package/dist/melonjs.mjs/input/input.js +1 -1
- package/dist/melonjs.mjs/input/keyboard.js +3 -3
- package/dist/melonjs.mjs/input/pointer.js +4 -4
- package/dist/melonjs.mjs/input/pointerevent.js +6 -7
- package/dist/melonjs.mjs/lang/console.js +1 -1
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +26 -29
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +4 -5
- package/dist/melonjs.mjs/loader/settings.js +1 -1
- package/dist/melonjs.mjs/math/color.js +2 -2
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +5 -59
- package/dist/melonjs.mjs/math/matrix3.js +82 -141
- package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
- package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
- package/dist/melonjs.mjs/math/vector2.js +7 -91
- package/dist/melonjs.mjs/math/vector3.js +6 -90
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +2 -2
- package/dist/melonjs.mjs/particles/particle.js +2 -2
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +22 -20
- package/dist/melonjs.mjs/physics/bounds.js +27 -33
- package/dist/melonjs.mjs/physics/collision.js +5 -5
- package/dist/melonjs.mjs/physics/detector.js +10 -10
- package/dist/melonjs.mjs/physics/quadtree.js +5 -5
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +3 -4
- package/dist/melonjs.mjs/physics/world.js +6 -9
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
- package/dist/melonjs.mjs/renderable/container.js +25 -25
- package/dist/melonjs.mjs/renderable/draggable.js +1 -1
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
- package/dist/melonjs.mjs/renderable/light2d.js +3 -3
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
- package/dist/melonjs.mjs/renderable/renderable.js +26 -26
- package/dist/melonjs.mjs/renderable/sprite.js +3 -3
- package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
- package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
- package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
- package/dist/melonjs.mjs/renderable/text/text.js +422 -0
- package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
- package/dist/melonjs.mjs/renderable/trigger.js +10 -10
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
- package/dist/melonjs.mjs/state/stage.js +2 -2
- package/dist/melonjs.mjs/state/state.js +1 -38
- package/dist/melonjs.mjs/system/device.js +49 -10
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +24 -2
- package/dist/melonjs.mjs/system/platform.js +18 -18
- package/dist/melonjs.mjs/system/pooling.js +10 -10
- package/dist/melonjs.mjs/system/save.js +1 -1
- package/dist/melonjs.mjs/system/timer.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
- package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
- package/dist/melonjs.mjs/text/glyph.js +1 -1
- package/dist/melonjs.mjs/text/text.js +1 -1
- package/dist/melonjs.mjs/text/textmetrics.js +1 -1
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +1 -1
- package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
- package/dist/melonjs.mjs/tweens/tween.js +2 -2
- package/dist/melonjs.mjs/utils/agent.js +1 -1
- package/dist/melonjs.mjs/utils/array.js +1 -1
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +2 -3
- package/dist/melonjs.mjs/utils/string.js +1 -1
- package/dist/melonjs.mjs/utils/utils.js +1 -1
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -7
- package/dist/melonjs.mjs/video/renderer.js +16 -16
- package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +4 -4
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
- package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +50 -52
- package/dist/melonjs.module.js +1137 -1576
- package/dist/types/application/application.d.ts +28 -4
- package/dist/types/application/header.d.ts +2 -2
- package/dist/types/application/settings.d.ts +23 -23
- package/dist/types/audio/audio.d.ts +3 -5
- package/dist/types/camera/camera2d.d.ts +13 -16
- package/dist/types/entity/entity.d.ts +0 -1
- package/dist/types/geometries/ellipse.d.ts +18 -50
- package/dist/types/geometries/path2d.d.ts +1 -1
- package/dist/types/geometries/point.d.ts +5 -13
- package/dist/types/geometries/poly.d.ts +26 -75
- package/dist/types/geometries/rectangle.d.ts +12 -58
- package/dist/types/geometries/roundrect.d.ts +2 -11
- package/dist/types/index.d.ts +3 -3
- package/dist/types/input/gamepad.d.ts +31 -31
- package/dist/types/input/keyboard.d.ts +105 -105
- package/dist/types/input/pointer.d.ts +21 -21
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
- package/dist/types/math/matrix2.d.ts +9 -63
- package/dist/types/math/matrix3.d.ts +9 -68
- package/dist/types/math/observable_vector2.d.ts +2 -2
- package/dist/types/math/observable_vector3.d.ts +2 -2
- package/dist/types/math/vector2.d.ts +8 -92
- package/dist/types/math/vector3.d.ts +8 -92
- package/dist/types/particles/settings.d.ts +29 -29
- package/dist/types/physics/body.d.ts +10 -8
- package/dist/types/physics/bounds.d.ts +24 -30
- package/dist/types/physics/collision.d.ts +12 -12
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/physics/world.d.ts +4 -7
- package/dist/types/renderable/container.d.ts +19 -19
- package/dist/types/renderable/imagelayer.d.ts +6 -6
- package/dist/types/renderable/light2d.d.ts +7 -7
- package/dist/types/renderable/renderable.d.ts +9 -16
- package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
- package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/renderable/text/glyph.d.ts +28 -0
- package/dist/types/renderable/text/text.d.ts +159 -0
- package/dist/types/renderable/text/textmetrics.d.ts +47 -0
- package/dist/types/renderable/text/textstyle.d.ts +5 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
- package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
- package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
- package/dist/types/state/state.d.ts +11 -11
- package/dist/types/system/device.d.ts +15 -9
- package/dist/types/system/event.d.ts +20 -0
- package/dist/types/system/platform.d.ts +17 -17
- package/dist/types/utils/function.d.ts +1 -2
- package/dist/types/video/renderer.d.ts +13 -13
- package/dist/types/video/texture/canvas_texture.d.ts +14 -14
- package/dist/types/video/video.d.ts +2 -2
- package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
- package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
- package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
- package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
- package/dist/types/video/webgl/utils/precision.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +47 -50
- package/package.json +15 -15
- package/src/application/application.js +51 -3
- package/src/application/header.js +1 -1
- package/src/application/resize.js +3 -7
- package/src/application/settings.js +4 -4
- package/src/audio/audio.js +3 -5
- package/src/camera/camera2d.js +11 -13
- package/src/entity/entity.js +2 -3
- package/src/geometries/ellipse.js +25 -58
- package/src/geometries/line.js +17 -24
- package/src/geometries/path2d.js +15 -12
- package/src/geometries/point.js +7 -15
- package/src/geometries/poly.js +39 -96
- package/src/geometries/rectangle.js +36 -90
- package/src/geometries/roundrect.js +25 -34
- package/src/index.js +4 -4
- package/src/input/keyboard.js +2 -2
- package/src/input/pointer.js +3 -3
- package/src/input/pointerevent.js +5 -6
- package/src/lang/deprecated.js +1 -1
- package/src/level/tiled/TMXLayer.js +15 -32
- package/src/level/tiled/TMXObject.js +2 -3
- package/src/level/tiled/TMXTile.js +3 -3
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/level/tiled/TMXTileset.js +3 -6
- package/src/level/tiled/TMXTilesetGroup.js +1 -1
- package/src/level/tiled/TMXUtils.js +25 -28
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/src/loader/parser.js +3 -4
- package/src/math/color.js +1 -1
- package/src/math/matrix2.js +4 -58
- package/src/math/matrix3.js +81 -140
- package/src/math/observable_vector2.js +6 -6
- package/src/math/observable_vector3.js +4 -4
- package/src/math/vector2.js +6 -90
- package/src/math/vector3.js +5 -89
- package/src/particles/emitter.js +1 -1
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +21 -19
- package/src/physics/bounds.js +26 -32
- package/src/physics/collision.js +4 -4
- package/src/physics/detector.js +9 -9
- package/src/physics/quadtree.js +4 -4
- package/src/physics/sat.js +2 -3
- package/src/physics/world.js +5 -8
- package/src/polyfill/roundrect.js +163 -163
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/colorlayer.js +3 -3
- package/src/renderable/container.js +24 -24
- package/src/renderable/imagelayer.js +3 -3
- package/src/renderable/light2d.js +2 -2
- package/src/renderable/nineslicesprite.js +1 -1
- package/src/renderable/renderable.js +25 -25
- package/src/renderable/sprite.js +2 -2
- package/src/{text → renderable/text}/bitmaptext.js +8 -8
- package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
- package/src/{text → renderable/text}/glyph.js +1 -1
- package/src/{text → renderable/text}/text.js +16 -17
- package/src/{text → renderable/text}/textmetrics.js +2 -2
- package/src/renderable/trigger.js +9 -9
- package/src/renderable/ui/uibaseelement.js +6 -6
- package/src/renderable/ui/uispriteelement.js +6 -6
- package/src/renderable/ui/uitextbutton.js +2 -2
- package/src/state/stage.js +1 -1
- package/src/state/state.js +0 -49
- package/src/system/device.js +48 -9
- package/src/system/event.js +22 -0
- package/src/system/platform.js +18 -18
- package/src/system/pooling.js +9 -9
- package/src/tweens/tween.js +1 -1
- package/src/utils/function.js +1 -2
- package/src/video/canvas/canvas_renderer.js +2 -6
- package/src/video/renderer.js +15 -15
- package/src/video/texture/atlas.js +12 -12
- package/src/video/texture/canvas_texture.js +14 -14
- package/src/video/video.js +3 -3
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +12 -13
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +1 -2
- package/src/video/webgl/glshader.js +1 -1
- package/src/video/webgl/utils/precision.js +3 -3
- package/src/video/webgl/webgl_renderer.js +49 -51
- /package/src/{text → renderable/text}/textstyle.js +0 -0
|
@@ -60,9 +60,30 @@ export default class Application {
|
|
|
60
60
|
isInitialized: boolean;
|
|
61
61
|
/**
|
|
62
62
|
* the given settings used when creating this application
|
|
63
|
-
* @type {
|
|
63
|
+
* @type {object}
|
|
64
64
|
*/
|
|
65
|
-
settings:
|
|
65
|
+
settings: object;
|
|
66
|
+
/**
|
|
67
|
+
* Specify whether to pause this app when losing focus
|
|
68
|
+
* @type {boolean}
|
|
69
|
+
* @default true
|
|
70
|
+
* @example
|
|
71
|
+
* // keep the default game instance running even when loosing focus
|
|
72
|
+
* me.game.pauseOnBlur = false;
|
|
73
|
+
*/
|
|
74
|
+
pauseOnBlur: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Specify whether to unpause this app when gaining back focus
|
|
77
|
+
* @type {boolean}
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
resumeOnFocus: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Specify whether to stop this app when losing focus
|
|
83
|
+
* @type {boolean}
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
stopOnBlur: boolean;
|
|
66
87
|
isDirty: boolean;
|
|
67
88
|
isAlwaysDirty: boolean;
|
|
68
89
|
frameCounter: number;
|
|
@@ -76,8 +97,11 @@ export default class Application {
|
|
|
76
97
|
updateAverageDelta: number;
|
|
77
98
|
/**
|
|
78
99
|
* init the game instance (create a physic world, update starting time, etc..)
|
|
100
|
+
* @param {number} width - The width of the canvas viewport
|
|
101
|
+
* @param {number} height - The height of the canvas viewport
|
|
102
|
+
* @param {Application.Settings} [options] - The optional parameters for the application and default renderer
|
|
79
103
|
*/
|
|
80
|
-
init(width:
|
|
104
|
+
init(width: number, height: number, options?: any): void;
|
|
81
105
|
/**
|
|
82
106
|
* reset the game Object manager
|
|
83
107
|
* destroy all current objects
|
|
@@ -107,7 +131,7 @@ export default class Application {
|
|
|
107
131
|
updateFrameRate(): void;
|
|
108
132
|
/**
|
|
109
133
|
* Returns the parent HTML Element holding the main canvas of this application
|
|
110
|
-
* @returns {HTMLElement}
|
|
134
|
+
* @returns {HTMLElement} the parent HTML element
|
|
111
135
|
*/
|
|
112
136
|
getParentElement(): HTMLElement;
|
|
113
137
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* display information
|
|
3
|
-
* @param {Application}
|
|
3
|
+
* @param {Application} app - the game application instance calling this function
|
|
4
4
|
*/
|
|
5
|
-
export function consoleHeader(app:
|
|
5
|
+
export function consoleHeader(app: Application): void;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export namespace defaultSettings {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
let parent: undefined;
|
|
3
|
+
let renderer: number;
|
|
4
|
+
let autoScale: boolean;
|
|
5
|
+
let scale: number;
|
|
6
|
+
let scaleMethod: string;
|
|
7
|
+
let scaleTarget: undefined;
|
|
8
|
+
let transparent: boolean;
|
|
9
|
+
let premultipliedAlpha: boolean;
|
|
10
|
+
let blendMode: string;
|
|
11
|
+
let antiAlias: boolean;
|
|
12
|
+
let failIfMajorPerformanceCaveat: boolean;
|
|
13
|
+
let subPixel: boolean;
|
|
14
|
+
let preferWebGL1: boolean;
|
|
15
|
+
let powerPreference: string;
|
|
16
|
+
let verbose: boolean;
|
|
17
|
+
let consoleHeader: boolean;
|
|
18
|
+
let legacy: boolean;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Application & Renderer Settings definition.
|
|
@@ -34,7 +34,7 @@ export type Settings = {
|
|
|
34
34
|
*/
|
|
35
35
|
scale?: string | number | undefined;
|
|
36
36
|
/**
|
|
37
|
-
* - screen scaling modes
|
|
37
|
+
* - screen scaling modes : <br>
|
|
38
38
|
* - <i><b>`fit`</b></i> : Letterboxed; content is scaled to design aspect ratio <br>
|
|
39
39
|
* <center><img src="images/scale-fit.png"/></center><br>
|
|
40
40
|
* - <i><b>`fill-min`</b></i> : Canvas is resized to fit minimum design resolution; content is scaled to design aspect ratio <br>
|
|
@@ -50,7 +50,7 @@ export type Settings = {
|
|
|
50
50
|
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio <br>
|
|
51
51
|
* <center><img src="images/scale-stretch.png"/></center>
|
|
52
52
|
*/
|
|
53
|
-
scaleMethod?:
|
|
53
|
+
scaleMethod?: "flex" | "fill-min" | "fill-max" | "flex-width" | "flex-height" | "stretch" | "fit" | undefined;
|
|
54
54
|
/**
|
|
55
55
|
* - the HTML Element to be used as the reference target when using automatic scaling (by default melonJS will use the parent container of the div element containing the canvas)
|
|
56
56
|
*/
|
|
@@ -60,13 +60,13 @@ export type Settings = {
|
|
|
60
60
|
*/
|
|
61
61
|
preferWebGL1?: boolean | undefined;
|
|
62
62
|
/**
|
|
63
|
-
* - ~Experimental~ the default method to sort object on the z axis in WebGL
|
|
63
|
+
* - ~Experimental~ the default method to sort object on the z axis in WebGL
|
|
64
64
|
*/
|
|
65
|
-
depthTest?:
|
|
65
|
+
depthTest?: "sorting" | "z-buffer" | undefined;
|
|
66
66
|
/**
|
|
67
|
-
* - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context
|
|
67
|
+
* - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context. 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.
|
|
68
68
|
*/
|
|
69
|
-
powerPreference?:
|
|
69
|
+
powerPreference?: "default" | "high-performance" | "low-power" | undefined;
|
|
70
70
|
/**
|
|
71
71
|
* - whether to allow transparent pixels in the front buffer (screen).
|
|
72
72
|
*/
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Initialize and configure the audio support.<br>
|
|
3
|
-
* melonJS supports a wide array of audio codecs that have varying browser support :
|
|
4
|
-
* <i> ("mp3", "mpeg", opus", "ogg", "oga", "wav", "aac", "caf", "m4a", "m4b", "mp4", "weba", "webm", "dolby", "flac")</i>.<br>
|
|
5
3
|
* For a maximum browser coverage the recommendation is to use at least two of them,
|
|
6
4
|
* typically default to webm and then fallback to mp3 for the best balance of small filesize and high quality,
|
|
7
5
|
* webm has nearly full browser coverage with a great combination of compression and quality, and mp3 will fallback gracefully for other browsers.
|
|
8
6
|
* It is important to remember that melonJS selects the first compatible sound based on the list of extensions and given order passed here.
|
|
9
7
|
* So if you want webm to be used before mp3, you need to put the audio format in that order.
|
|
10
8
|
* @function audio.init
|
|
11
|
-
* @param {string} [format="mp3"] - audio format to prioritize
|
|
9
|
+
* @param {string} [format="mp3"] - audio format to prioritize ("mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac")
|
|
12
10
|
* @returns {boolean} Indicates whether audio initialization was successful
|
|
13
11
|
* @example
|
|
14
12
|
* // initialize the "sound engine", giving "webm" as default desired audio format, and "mp3" as a fallback
|
|
@@ -21,10 +19,10 @@ export function init(format?: string | undefined): boolean;
|
|
|
21
19
|
/**
|
|
22
20
|
* check if the given audio format is supported
|
|
23
21
|
* @function audio.hasFormat
|
|
24
|
-
* @param {
|
|
22
|
+
* @param {"mp3"|"mpeg"|"opus"|"ogg"|"oga"|"wav"|"aac"|"caf"|"m4a"|"m4b"|"mp4"|"weba"|"webm"|"dolby"|"flac"} codec - the audio format to check for support
|
|
25
23
|
* @returns {boolean} return true if the given audio format is supported
|
|
26
24
|
*/
|
|
27
|
-
export function hasFormat(codec:
|
|
25
|
+
export function hasFormat(codec: "mp3" | "mpeg" | "opus" | "ogg" | "oga" | "wav" | "aac" | "caf" | "m4a" | "m4b" | "mp4" | "weba" | "webm" | "dolby" | "flac"): boolean;
|
|
28
26
|
/**
|
|
29
27
|
* check if audio (HTML5 or WebAudio) is supported
|
|
30
28
|
* @function audio.hasAudio
|
|
@@ -81,7 +81,7 @@ export default class Camera2d extends Renderable {
|
|
|
81
81
|
*/
|
|
82
82
|
invCurrentTransform: Matrix2d;
|
|
83
83
|
offset: Vector2d;
|
|
84
|
-
target: Vector2d |
|
|
84
|
+
target: Vector2d | null;
|
|
85
85
|
follow_axis: number;
|
|
86
86
|
_shake: {
|
|
87
87
|
intensity: number;
|
|
@@ -100,15 +100,15 @@ export default class Camera2d extends Renderable {
|
|
|
100
100
|
/** @ignore */
|
|
101
101
|
_updateProjectionMatrix(): void;
|
|
102
102
|
/** @ignore */
|
|
103
|
-
_followH(target: any):
|
|
103
|
+
_followH(target: any): any;
|
|
104
104
|
/** @ignore */
|
|
105
|
-
_followV(target: any):
|
|
105
|
+
_followV(target: any): any;
|
|
106
106
|
/**
|
|
107
107
|
* reset the camera position to specified coordinates
|
|
108
108
|
* @name reset
|
|
109
109
|
* @memberof Camera2d
|
|
110
|
-
* @param {number} [x=0]
|
|
111
|
-
* @param {number} [y=0]
|
|
110
|
+
* @param {number} [x=0] - initial position of the camera on the x axis
|
|
111
|
+
* @param {number} [y=0] - initial position of the camera on the y axis
|
|
112
112
|
*/
|
|
113
113
|
reset(x?: number | undefined, y?: number | undefined): void;
|
|
114
114
|
/**
|
|
@@ -167,8 +167,8 @@ export default class Camera2d extends Renderable {
|
|
|
167
167
|
* @name move
|
|
168
168
|
* @memberof Camera2d
|
|
169
169
|
* @see Camera2d.focusOn
|
|
170
|
-
* @param {number} x
|
|
171
|
-
* @param {number} y
|
|
170
|
+
* @param {number} x - horizontal offset
|
|
171
|
+
* @param {number} y - vertical offset
|
|
172
172
|
* @example
|
|
173
173
|
* // Move the camera up by four pixels
|
|
174
174
|
* me.game.viewport.move(0, -4);
|
|
@@ -245,17 +245,16 @@ export default class Camera2d extends Renderable {
|
|
|
245
245
|
* @memberof Camera2d
|
|
246
246
|
* @param {Renderable|Entity|Sprite|NineSliceSprite} obj - to be checked against
|
|
247
247
|
* @param {boolean} [floating = obj.floating] - if visibility check should be done against screen coordinates
|
|
248
|
-
* @returns {boolean}
|
|
248
|
+
* @returns {boolean} true if within the viewport
|
|
249
249
|
*/
|
|
250
250
|
isVisible(obj: Renderable | Entity | Sprite | NineSliceSprite, floating?: boolean | undefined): boolean;
|
|
251
251
|
/**
|
|
252
252
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
253
253
|
* @name localToWorld
|
|
254
254
|
* @memberof Camera2d
|
|
255
|
-
* @param {number} x
|
|
256
|
-
* @param {number} y
|
|
257
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
258
|
-
* converted value
|
|
255
|
+
* @param {number} x - the x coordinate of the local point to be converted
|
|
256
|
+
* @param {number} y - the y coordinate of the local point to be converted
|
|
257
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
259
258
|
* @returns {Vector2d}
|
|
260
259
|
*/
|
|
261
260
|
localToWorld(x: number, y: number, v?: number | undefined): Vector2d;
|
|
@@ -265,9 +264,8 @@ export default class Camera2d extends Renderable {
|
|
|
265
264
|
* @memberof Camera2d
|
|
266
265
|
* @param {number} x
|
|
267
266
|
* @param {number} y
|
|
268
|
-
* @param {number} [v] - an optional vector object where to set the
|
|
269
|
-
* converted
|
|
270
|
-
* @returns {Vector2d}
|
|
267
|
+
* @param {number} [v] - an optional vector object where to set the converted value
|
|
268
|
+
* @returns {Vector2d} a vector with the converted local coordinates
|
|
271
269
|
*/
|
|
272
270
|
worldToLocal(x: number, y: number, v?: number | undefined): Vector2d;
|
|
273
271
|
/**
|
|
@@ -285,5 +283,4 @@ import Renderable from "./../renderable/renderable.js";
|
|
|
285
283
|
import Matrix3d from "./../math/matrix3.js";
|
|
286
284
|
import Matrix2d from "./../math/matrix2.js";
|
|
287
285
|
import Vector2d from "./../math/vector2.js";
|
|
288
|
-
import ObservableVector3d from "./../math/observable_vector3.js";
|
|
289
286
|
import Rect from "./../geometries/rectangle.js";
|
|
@@ -14,8 +14,6 @@ export default class Ellipse {
|
|
|
14
14
|
* the center coordinates of the ellipse
|
|
15
15
|
* @public
|
|
16
16
|
* @type {Vector2d}
|
|
17
|
-
* @name pos
|
|
18
|
-
* @memberof Ellipse
|
|
19
17
|
*/
|
|
20
18
|
public pos: Vector2d;
|
|
21
19
|
/**
|
|
@@ -27,32 +25,24 @@ export default class Ellipse {
|
|
|
27
25
|
* Maximum radius of the ellipse
|
|
28
26
|
* @public
|
|
29
27
|
* @type {number}
|
|
30
|
-
* @name radius
|
|
31
|
-
* @memberof Ellipse
|
|
32
28
|
*/
|
|
33
29
|
public radius: number;
|
|
34
30
|
/**
|
|
35
31
|
* Pre-scaled radius vector for ellipse
|
|
36
32
|
* @public
|
|
37
33
|
* @type {Vector2d}
|
|
38
|
-
* @name radiusV
|
|
39
|
-
* @memberof Ellipse
|
|
40
34
|
*/
|
|
41
35
|
public radiusV: Vector2d;
|
|
42
36
|
/**
|
|
43
37
|
* Radius squared, for pythagorean theorom
|
|
44
38
|
* @public
|
|
45
39
|
* @type {Vector2d}
|
|
46
|
-
* @name radiusSq
|
|
47
|
-
* @memberof Ellipse
|
|
48
40
|
*/
|
|
49
41
|
public radiusSq: Vector2d;
|
|
50
42
|
/**
|
|
51
43
|
* x/y scaling ratio for ellipse
|
|
52
44
|
* @public
|
|
53
45
|
* @type {Vector2d}
|
|
54
|
-
* @name ratio
|
|
55
|
-
* @memberof Ellipse
|
|
56
46
|
*/
|
|
57
47
|
public ratio: Vector2d;
|
|
58
48
|
shapeType: string;
|
|
@@ -60,8 +50,6 @@ export default class Ellipse {
|
|
|
60
50
|
onResetEvent(x: any, y: any, w: any, h: any): void;
|
|
61
51
|
/**
|
|
62
52
|
* set new value to the Ellipse shape
|
|
63
|
-
* @name setShape
|
|
64
|
-
* @memberof Ellipse
|
|
65
53
|
* @param {number} x - the center x coordinate of the ellipse
|
|
66
54
|
* @param {number} y - the center y coordinate of the ellipse
|
|
67
55
|
* @param {number} w - width (diameter) of the ellipse
|
|
@@ -71,8 +59,6 @@ export default class Ellipse {
|
|
|
71
59
|
setShape(x: number, y: number, w: number, h: number): Ellipse;
|
|
72
60
|
/**
|
|
73
61
|
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
74
|
-
* @name rotate
|
|
75
|
-
* @memberof Ellipse
|
|
76
62
|
* @param {number} angle - The angle to rotate (in radians)
|
|
77
63
|
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
78
64
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
@@ -80,74 +66,56 @@ export default class Ellipse {
|
|
|
80
66
|
rotate(angle: number, v?: Vector2d | ObservableVector2d): Ellipse;
|
|
81
67
|
/**
|
|
82
68
|
* Scale this Ellipse by the specified scalar.
|
|
83
|
-
* @
|
|
84
|
-
* @
|
|
85
|
-
* @param {number} x
|
|
86
|
-
* @param {number} [y=x]
|
|
69
|
+
* @param {number} x - the scale factor along the x-axis
|
|
70
|
+
* @param {number} [y=x] - the scale factor along the y-axis
|
|
87
71
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
88
72
|
*/
|
|
89
73
|
scale(x: number, y?: number | undefined): Ellipse;
|
|
90
74
|
/**
|
|
91
75
|
* Scale this Ellipse by the specified vector.
|
|
92
|
-
* @name scale
|
|
93
|
-
* @memberof Ellipse
|
|
94
76
|
* @param {Vector2d} v
|
|
95
77
|
* @returns {Ellipse} Reference to this object for method chaining
|
|
96
78
|
*/
|
|
97
79
|
scaleV(v: Vector2d): Ellipse;
|
|
98
80
|
/**
|
|
99
81
|
* apply the given transformation matrix to this ellipse
|
|
100
|
-
* @name transform
|
|
101
|
-
* @memberof Ellipse
|
|
102
82
|
* @param {Matrix2d} matrix - the transformation matrix
|
|
103
83
|
* @returns {Polygon} Reference to this object for method chaining
|
|
104
84
|
*/
|
|
105
85
|
transform(matrix: Matrix2d): Polygon;
|
|
106
86
|
/**
|
|
107
87
|
* translate the circle/ellipse by the specified offset
|
|
108
|
-
* @
|
|
109
|
-
* @
|
|
110
|
-
* @method
|
|
111
|
-
* @param {number} x - x offset
|
|
112
|
-
* @param {number} y - y offset
|
|
113
|
-
* @returns {Ellipse} this ellipse
|
|
114
|
-
*/
|
|
115
|
-
/**
|
|
116
|
-
* translate the circle/ellipse by the specified vector
|
|
117
|
-
* @name translate
|
|
118
|
-
* @memberof Ellipse
|
|
119
|
-
* @param {Vector2d} v - vector offset
|
|
88
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to translate by
|
|
89
|
+
* @param {number} [y] - y offset
|
|
120
90
|
* @returns {Ellipse} this ellipse
|
|
91
|
+
* @example
|
|
92
|
+
* ellipse.translate(10, 10);
|
|
93
|
+
* // or
|
|
94
|
+
* ellipse.translate(myVector2d);
|
|
121
95
|
*/
|
|
122
96
|
translate(...args: any[]): Ellipse;
|
|
123
97
|
/**
|
|
124
98
|
* check if this circle/ellipse contains the specified point
|
|
125
|
-
* @
|
|
126
|
-
* @
|
|
127
|
-
* @memberof Ellipse
|
|
128
|
-
* @param {Vector2d} point
|
|
129
|
-
* @returns {boolean} true if contains
|
|
130
|
-
*/
|
|
131
|
-
/**
|
|
132
|
-
* check if this circle/ellipse contains the specified point
|
|
133
|
-
* @name contains
|
|
134
|
-
* @memberof Ellipse
|
|
135
|
-
* @param {number} x - x coordinate
|
|
136
|
-
* @param {number} y - y coordinate
|
|
99
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to check
|
|
100
|
+
* @param {number} [y] - y coordinate
|
|
137
101
|
* @returns {boolean} true if contains
|
|
102
|
+
* @example
|
|
103
|
+
* if (circle.contains(10, 10)) {
|
|
104
|
+
* // do something
|
|
105
|
+
* }
|
|
106
|
+
* // or
|
|
107
|
+
* if (circle.contains(myVector2d)) {
|
|
108
|
+
* // do something
|
|
109
|
+
* }
|
|
138
110
|
*/
|
|
139
111
|
contains(...args: any[]): boolean;
|
|
140
112
|
/**
|
|
141
113
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
142
|
-
* @name getBounds
|
|
143
|
-
* @memberof Ellipse
|
|
144
114
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
145
115
|
*/
|
|
146
116
|
getBounds(): Bounds;
|
|
147
117
|
/**
|
|
148
118
|
* clone this Ellipse
|
|
149
|
-
* @name clone
|
|
150
|
-
* @memberof Ellipse
|
|
151
119
|
* @returns {Ellipse} new Ellipse
|
|
152
120
|
*/
|
|
153
121
|
clone(): Ellipse;
|
|
@@ -27,7 +27,7 @@ export default class Path2D {
|
|
|
27
27
|
closePath(): void;
|
|
28
28
|
/**
|
|
29
29
|
* triangulate the shape defined by this path into an array of triangles
|
|
30
|
-
* @returns {Point[]}
|
|
30
|
+
* @returns {Point[]} an array of vertices representing the triangulated path or shape
|
|
31
31
|
*/
|
|
32
32
|
triangulatePath(): Point[];
|
|
33
33
|
/**
|
|
@@ -6,13 +6,13 @@ export default class Point {
|
|
|
6
6
|
constructor(x?: number, y?: number);
|
|
7
7
|
/**
|
|
8
8
|
* the position of the point on the horizontal axis
|
|
9
|
-
* @type {
|
|
9
|
+
* @type {number}
|
|
10
10
|
* @default 0
|
|
11
11
|
*/
|
|
12
12
|
x: number;
|
|
13
13
|
/**
|
|
14
14
|
* the position of the point on the vertical axis
|
|
15
|
-
* @type {
|
|
15
|
+
* @type {number}
|
|
16
16
|
* @default 0
|
|
17
17
|
*/
|
|
18
18
|
y: number;
|
|
@@ -26,17 +26,9 @@ export default class Point {
|
|
|
26
26
|
*/
|
|
27
27
|
set(x?: number, y?: number): Point;
|
|
28
28
|
/**
|
|
29
|
-
* return true if
|
|
30
|
-
* @
|
|
31
|
-
* @
|
|
32
|
-
* @method
|
|
33
|
-
* @param {Point} point
|
|
34
|
-
* @returns {boolean}
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* return true if this point is equal to the given values
|
|
38
|
-
* @param {number} x
|
|
39
|
-
* @param {number} y
|
|
29
|
+
* return true if this point is equal to the given point
|
|
30
|
+
* @param {number|Point|Vector2d} x
|
|
31
|
+
* @param {number} [y]
|
|
40
32
|
* @returns {boolean}
|
|
41
33
|
*/
|
|
42
34
|
equals(...args: any[]): boolean;
|
|
@@ -17,21 +17,15 @@ export default class Polygon {
|
|
|
17
17
|
constructor(x: number, y: number, points: Vector2d[]);
|
|
18
18
|
/**
|
|
19
19
|
* origin point of the Polygon
|
|
20
|
-
* @public
|
|
21
20
|
* @type {Vector2d}
|
|
22
|
-
* @name pos
|
|
23
|
-
* @memberof Polygon
|
|
24
21
|
*/
|
|
25
|
-
|
|
22
|
+
pos: Vector2d;
|
|
26
23
|
/**
|
|
27
24
|
* Array of points defining the Polygon <br>
|
|
28
25
|
* Note: If you manually change `points`, you **must** call `recalc`afterwards so that the changes get applied correctly.
|
|
29
|
-
* @public
|
|
30
26
|
* @type {Vector2d[]}
|
|
31
|
-
* @name points
|
|
32
|
-
* @memberof Polygon
|
|
33
27
|
*/
|
|
34
|
-
|
|
28
|
+
points: Vector2d[];
|
|
35
29
|
/**
|
|
36
30
|
* The edges here are the direction of the `n`th edge of the polygon, relative to
|
|
37
31
|
* the `n`th point. If you want to draw a given edge from the edge value, you must
|
|
@@ -56,8 +50,6 @@ export default class Polygon {
|
|
|
56
50
|
onResetEvent(x: any, y: any, points: any): void;
|
|
57
51
|
/**
|
|
58
52
|
* set new value to the Polygon
|
|
59
|
-
* @name setShape
|
|
60
|
-
* @memberof Polygon
|
|
61
53
|
* @param {number} x - position of the Polygon
|
|
62
54
|
* @param {number} y - position of the Polygon
|
|
63
55
|
* @param {Vector2d[]|number[]} points - array of vector or vertice defining the Polygon
|
|
@@ -66,38 +58,28 @@ export default class Polygon {
|
|
|
66
58
|
setShape(x: number, y: number, points: Vector2d[] | number[]): Polygon;
|
|
67
59
|
/**
|
|
68
60
|
* set the vertices defining this Polygon
|
|
69
|
-
* @name setVertices
|
|
70
|
-
* @memberof Polygon
|
|
71
61
|
* @param {Vector2d[]} vertices - array of vector or vertice defining the Polygon
|
|
72
62
|
* @returns {Polygon} this instance for objecf chaining
|
|
73
63
|
*/
|
|
74
64
|
setVertices(vertices: Vector2d[]): Polygon;
|
|
75
65
|
/**
|
|
76
66
|
* apply the given transformation matrix to this Polygon
|
|
77
|
-
* @name transform
|
|
78
|
-
* @memberof Polygon
|
|
79
67
|
* @param {Matrix2d} m - the transformation matrix
|
|
80
68
|
* @returns {Polygon} Reference to this object for method chaining
|
|
81
69
|
*/
|
|
82
70
|
transform(m: Matrix2d): Polygon;
|
|
83
71
|
/**
|
|
84
72
|
* apply an isometric projection to this shape
|
|
85
|
-
* @name toIso
|
|
86
|
-
* @memberof Polygon
|
|
87
73
|
* @returns {Polygon} Reference to this object for method chaining
|
|
88
74
|
*/
|
|
89
75
|
toIso(): Polygon;
|
|
90
76
|
/**
|
|
91
|
-
* apply a 2d projection to this
|
|
92
|
-
* @name to2d
|
|
93
|
-
* @memberof Polygon
|
|
77
|
+
* apply a 2d projection to this shapen
|
|
94
78
|
* @returns {Polygon} Reference to this object for method chaining
|
|
95
79
|
*/
|
|
96
80
|
to2d(): Polygon;
|
|
97
81
|
/**
|
|
98
82
|
* Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
|
|
99
|
-
* @name rotate
|
|
100
|
-
* @memberof Polygon
|
|
101
83
|
* @param {number} angle - The angle to rotate (in radians)
|
|
102
84
|
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
103
85
|
* @returns {Polygon} Reference to this object for method chaining
|
|
@@ -105,8 +87,6 @@ export default class Polygon {
|
|
|
105
87
|
rotate(angle: number, v?: Vector2d | ObservableVector2d): Polygon;
|
|
106
88
|
/**
|
|
107
89
|
* Scale this Polygon by the given scalar.
|
|
108
|
-
* @name scale
|
|
109
|
-
* @memberof Polygon
|
|
110
90
|
* @param {number} x
|
|
111
91
|
* @param {number} [y=x]
|
|
112
92
|
* @returns {Polygon} Reference to this object for method chaining
|
|
@@ -114,8 +94,6 @@ export default class Polygon {
|
|
|
114
94
|
scale(x: number, y?: number | undefined): Polygon;
|
|
115
95
|
/**
|
|
116
96
|
* Scale this Polygon by the given vector
|
|
117
|
-
* @name scaleV
|
|
118
|
-
* @memberof Polygon
|
|
119
97
|
* @param {Vector2d} v
|
|
120
98
|
* @returns {Polygon} Reference to this object for method chaining
|
|
121
99
|
*/
|
|
@@ -123,97 +101,70 @@ export default class Polygon {
|
|
|
123
101
|
/**
|
|
124
102
|
* Computes the calculated collision polygon.
|
|
125
103
|
* This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
|
|
126
|
-
* @name recalc
|
|
127
|
-
* @memberof Polygon
|
|
128
104
|
* @returns {Polygon} Reference to this object for method chaining
|
|
129
105
|
*/
|
|
130
106
|
recalc(): Polygon;
|
|
131
107
|
/**
|
|
132
108
|
* returns a list of indices for all triangles defined in this polygon
|
|
133
|
-
* @name getIndices
|
|
134
|
-
* @memberof Polygon
|
|
135
109
|
* @returns {Array} an array of vertex indices for all triangles forming this polygon.
|
|
136
110
|
*/
|
|
137
111
|
getIndices(): any[];
|
|
138
112
|
/**
|
|
139
113
|
* Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
|
|
140
|
-
* @name isConvex
|
|
141
|
-
* @memberof Polygon
|
|
142
114
|
* @returns {boolean} true if the vertices are convex, false if not, null if not computable
|
|
143
115
|
*/
|
|
144
116
|
isConvex(): boolean;
|
|
145
117
|
/**
|
|
146
118
|
* translate the Polygon by the specified offset
|
|
147
|
-
* @
|
|
148
|
-
* @
|
|
149
|
-
* @method
|
|
150
|
-
* @param {number} x - x offset
|
|
151
|
-
* @param {number} y - y offset
|
|
152
|
-
* @returns {Polygon} this Polygon
|
|
153
|
-
*/
|
|
154
|
-
/**
|
|
155
|
-
* translate the Polygon by the specified vector
|
|
156
|
-
* @name translate
|
|
157
|
-
* @memberof Polygon
|
|
158
|
-
* @param {Vector2d} v - vector offset
|
|
119
|
+
* @param {number|Vector2d} x - x offset or a vector point to translate by
|
|
120
|
+
* @param {number} [y] - y offset
|
|
159
121
|
* @returns {Polygon} Reference to this object for method chaining
|
|
122
|
+
* @example
|
|
123
|
+
* polygon.translate(10, 10);
|
|
124
|
+
* // or
|
|
125
|
+
* polygon.translate(myVector2d);
|
|
160
126
|
*/
|
|
161
127
|
translate(...args: any[]): Polygon;
|
|
162
128
|
/**
|
|
163
129
|
* Shifts the Polygon to the given position vector.
|
|
164
|
-
* @
|
|
165
|
-
* @
|
|
166
|
-
* @
|
|
167
|
-
*
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
* Shifts the Polygon to the given x, y position.
|
|
171
|
-
* @name shift
|
|
172
|
-
* @memberof Polygon
|
|
173
|
-
* @param {number} x
|
|
174
|
-
* @param {number} y
|
|
130
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to shift to
|
|
131
|
+
* @param {number} [y]
|
|
132
|
+
* @example
|
|
133
|
+
* polygon.shift(10, 10);
|
|
134
|
+
* // or
|
|
135
|
+
* polygon.shift(myVector2d);
|
|
175
136
|
*/
|
|
176
137
|
shift(...args: any[]): void;
|
|
177
|
-
/**
|
|
178
|
-
* Returns true if the polygon contains the given point.
|
|
179
|
-
* (Note: it is highly recommended to first do a hit test on the corresponding <br>
|
|
180
|
-
* bounding rect, as the function can be highly consuming with complex shapes)
|
|
181
|
-
* @name contains
|
|
182
|
-
* @memberof Polygon
|
|
183
|
-
* @method
|
|
184
|
-
* @param {Vector2d} point
|
|
185
|
-
* @returns {boolean} true if contains
|
|
186
|
-
*/
|
|
187
138
|
/**
|
|
188
139
|
* Returns true if the polygon contains the given point. <br>
|
|
189
140
|
* (Note: it is highly recommended to first do a hit test on the corresponding <br>
|
|
190
141
|
* bounding rect, as the function can be highly consuming with complex shapes)
|
|
191
|
-
* @
|
|
192
|
-
* @
|
|
193
|
-
* @
|
|
194
|
-
* @
|
|
195
|
-
*
|
|
142
|
+
* @param {number|Vector2d} x - x coordinate or a vector point to check
|
|
143
|
+
* @param {number} [y] - y coordinate
|
|
144
|
+
* @returns {boolean} True if the polygon contain the point, otherwise false
|
|
145
|
+
* @example
|
|
146
|
+
* if (polygon.contains(10, 10)) {
|
|
147
|
+
* // do something
|
|
148
|
+
* }
|
|
149
|
+
* // or
|
|
150
|
+
* if (polygon.contains(myVector2d)) {
|
|
151
|
+
* // do something
|
|
152
|
+
* }
|
|
196
153
|
*/
|
|
197
154
|
contains(...args: any[]): boolean;
|
|
198
155
|
/**
|
|
199
156
|
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
200
|
-
* @name getBounds
|
|
201
|
-
* @memberof Polygon
|
|
202
157
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
203
158
|
*/
|
|
204
159
|
getBounds(): Bounds;
|
|
205
160
|
_bounds: object | undefined;
|
|
206
161
|
/**
|
|
207
162
|
* update the bounding box for this shape.
|
|
208
|
-
* @name updateBounds
|
|
209
|
-
* @memberof Polygon
|
|
210
163
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
211
164
|
*/
|
|
212
165
|
updateBounds(): Bounds;
|
|
213
166
|
/**
|
|
214
167
|
* clone this Polygon
|
|
215
|
-
* @name clone
|
|
216
|
-
* @memberof Polygon
|
|
217
168
|
* @returns {Polygon} new Polygon
|
|
218
169
|
*/
|
|
219
170
|
clone(): Polygon;
|