melonjs 14.2.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.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/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +153 -9
- package/dist/melonjs.mjs/application/header.js +34 -0
- package/dist/melonjs.mjs/application/resize.js +1 -1
- package/dist/melonjs.mjs/application/settings.js +28 -0
- package/dist/melonjs.mjs/audio/audio.js +1 -1
- package/dist/melonjs.mjs/camera/camera2d.js +2 -2
- package/dist/melonjs.mjs/entity/entity.js +1 -1
- package/dist/melonjs.mjs/game.js +1 -1
- package/dist/melonjs.mjs/geometries/ellipse.js +1 -1
- package/dist/melonjs.mjs/geometries/line.js +1 -1
- package/dist/melonjs.mjs/geometries/path2d.js +1 -1
- package/dist/melonjs.mjs/geometries/point.js +1 -1
- package/dist/melonjs.mjs/geometries/poly.js +1 -1
- package/dist/melonjs.mjs/geometries/rectangle.js +1 -1
- package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
- package/dist/melonjs.mjs/index.js +41 -30
- 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 +1 -1
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +2 -2
- package/dist/melonjs.mjs/lang/deprecated.js +1 -1
- package/dist/melonjs.mjs/level/level.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +2 -2
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +1 -1
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/math/color.js +1 -1
- package/dist/melonjs.mjs/math/math.js +1 -1
- package/dist/melonjs.mjs/math/matrix2.js +1 -1
- package/dist/melonjs.mjs/math/matrix3.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector2.js +1 -1
- package/dist/melonjs.mjs/math/observable_vector3.js +1 -1
- package/dist/melonjs.mjs/math/vector2.js +1 -1
- package/dist/melonjs.mjs/math/vector3.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.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 +1 -1
- package/dist/melonjs.mjs/particles/particle.js +1 -1
- package/dist/melonjs.mjs/particles/settings.js +1 -1
- package/dist/melonjs.mjs/physics/body.js +1 -1
- package/dist/melonjs.mjs/physics/bounds.js +1 -1
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +174 -146
- package/dist/melonjs.mjs/physics/quadtree.js +1 -1
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +1 -1
- package/dist/melonjs.mjs/physics/world.js +10 -30
- package/dist/melonjs.mjs/plugin/plugin.js +3 -3
- package/dist/melonjs.mjs/renderable/collectable.js +1 -1
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +3 -87
- package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
- package/dist/melonjs.mjs/renderable/imagelayer.js +2 -2
- package/dist/melonjs.mjs/renderable/light2d.js +1 -1
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
- package/dist/melonjs.mjs/renderable/renderable.js +1 -1
- package/dist/melonjs.mjs/renderable/sprite.js +1 -1
- package/dist/melonjs.mjs/renderable/trigger.js +2 -2
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
- package/dist/melonjs.mjs/state/stage.js +2 -2
- package/dist/melonjs.mjs/state/state.js +2 -2
- package/dist/melonjs.mjs/system/device.js +2 -22
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +1 -1
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +4 -1
- package/dist/melonjs.mjs/video/renderer.js +8 -1
- package/dist/melonjs.mjs/video/texture/atlas.js +1 -1
- package/dist/melonjs.mjs/video/texture/cache.js +1 -1
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +3 -2
- package/dist/melonjs.mjs/video/utils/autodetect.js +27 -0
- package/dist/melonjs.mjs/video/utils/resize.js +1 -1
- package/dist/melonjs.mjs/video/video.js +15 -147
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
- package/dist/melonjs.mjs/video/webgl/glshader.js +2 -3
- 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 +20 -2
- 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_compositor.js +1 -1
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +4 -1
- package/dist/melonjs.module.js +20922 -20921
- package/dist/types/application/application.d.ts +144 -0
- package/dist/types/application/header.d.ts +5 -0
- package/dist/types/application/resize.d.ts +5 -0
- package/dist/types/application/settings.d.ts +18 -0
- package/dist/types/audio/audio.d.ts +267 -0
- package/dist/types/camera/camera2d.d.ts +289 -0
- package/dist/types/entity/entity.d.ts +98 -0
- package/{src/game.js → dist/types/game.d.ts} +3 -14
- package/dist/types/geometries/ellipse.d.ts +154 -0
- package/dist/types/geometries/line.d.ts +11 -0
- package/dist/types/geometries/path2d.d.ts +121 -0
- package/dist/types/geometries/point.d.ts +53 -0
- package/dist/types/geometries/poly.d.ts +222 -0
- package/dist/types/geometries/rectangle.d.ts +176 -0
- package/dist/types/geometries/roundrect.d.ts +52 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/input/gamepad.d.ts +95 -0
- package/dist/types/input/input.d.ts +15 -0
- package/dist/types/input/keyboard.d.ts +205 -0
- package/dist/types/input/pointer.d.ts +270 -0
- package/dist/types/input/pointerevent.d.ts +181 -0
- package/dist/types/lang/deprecated.d.ts +53 -0
- package/dist/types/level/level.d.ts +134 -0
- package/dist/types/level/tiled/TMXGroup.d.ts +82 -0
- package/dist/types/level/tiled/TMXLayer.d.ts +180 -0
- package/dist/types/level/tiled/TMXObject.d.ts +195 -0
- package/dist/types/level/tiled/TMXTile.d.ts +78 -0
- package/dist/types/level/tiled/TMXTileMap.d.ts +180 -0
- package/dist/types/level/tiled/TMXTileset.d.ts +94 -0
- package/dist/types/level/tiled/TMXTilesetGroup.d.ts +32 -0
- package/dist/types/level/tiled/TMXUtils.d.ts +47 -0
- package/dist/types/level/tiled/renderer/TMXHexagonalRenderer.d.ts +87 -0
- package/dist/types/level/tiled/renderer/TMXIsometricRenderer.d.ts +55 -0
- package/dist/types/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +43 -0
- package/dist/types/level/tiled/renderer/TMXRenderer.d.ts +75 -0
- package/dist/types/level/tiled/renderer/TMXStaggeredRenderer.d.ts +8 -0
- package/dist/types/loader/loader.d.ts +181 -0
- package/dist/types/loader/loadingscreen.d.ts +18 -0
- package/dist/types/math/color.d.ts +170 -0
- package/dist/types/math/math.d.ts +165 -0
- package/dist/types/math/matrix2.d.ts +209 -0
- package/dist/types/math/matrix3.d.ts +236 -0
- package/dist/types/math/observable_vector2.d.ts +278 -0
- package/dist/types/math/observable_vector3.d.ts +277 -0
- package/dist/types/math/vector2.d.ts +327 -0
- package/dist/types/math/vector3.d.ts +332 -0
- package/dist/types/particles/emitter.d.ts +188 -0
- package/dist/types/particles/particle.d.ts +32 -0
- package/dist/types/particles/settings.d.ts +32 -0
- package/dist/types/physics/body.d.ts +330 -0
- package/dist/types/physics/bounds.d.ts +250 -0
- package/dist/types/physics/collision.d.ts +44 -0
- package/dist/types/physics/detector.d.ts +64 -0
- package/dist/types/physics/quadtree.d.ts +79 -0
- package/dist/types/physics/response.d.ts +37 -0
- package/dist/types/physics/sat.d.ts +48 -0
- package/dist/types/physics/world.d.ts +83 -0
- package/dist/types/plugin/plugin.d.ts +10 -0
- package/dist/types/polyfill/console.d.ts +0 -0
- package/dist/types/polyfill/index.d.ts +1 -0
- package/dist/types/polyfill/performance.d.ts +0 -0
- package/dist/types/polyfill/requestAnimationFrame.d.ts +1 -0
- package/dist/types/polyfill/roundrect.d.ts +0 -0
- package/dist/types/renderable/collectable.d.ts +19 -0
- package/dist/types/renderable/colorlayer.d.ts +28 -0
- package/dist/types/renderable/container.d.ts +302 -0
- package/dist/types/renderable/dragndrop.d.ts +118 -0
- package/dist/types/renderable/imagelayer.d.ts +106 -0
- package/dist/types/renderable/light2d.d.ts +58 -0
- package/dist/types/renderable/nineslicesprite.d.ts +59 -0
- package/dist/types/renderable/renderable.d.ts +402 -0
- package/dist/types/renderable/sprite.d.ts +268 -0
- package/dist/types/renderable/trigger.d.ts +61 -0
- package/dist/types/renderable/ui/uibaseelement.d.ts +95 -0
- package/dist/types/renderable/ui/uispriteelement.d.ts +127 -0
- package/dist/types/renderable/ui/uitextbutton.d.ts +54 -0
- package/dist/types/state/stage.d.ts +116 -0
- package/dist/types/state/state.d.ts +170 -0
- package/dist/types/system/device.d.ts +579 -0
- package/dist/types/system/dom.d.ts +1 -0
- package/dist/types/system/event.d.ts +473 -0
- package/dist/types/system/platform.d.ts +31 -0
- package/dist/types/system/pooling.d.ts +101 -0
- package/dist/types/system/save.d.ts +25 -0
- package/dist/types/system/timer.d.ts +126 -0
- package/dist/types/text/bitmaptext.d.ts +151 -0
- package/dist/types/text/bitmaptextdata.d.ts +35 -0
- package/dist/types/text/glyph.d.ts +28 -0
- package/dist/types/text/text.d.ts +173 -0
- package/dist/types/text/textmetrics.d.ts +47 -0
- package/dist/types/text/textstyle.d.ts +5 -0
- package/dist/types/tweens/easing.d.ts +46 -0
- package/dist/types/tweens/interpolation.d.ts +18 -0
- package/dist/types/tweens/tween.d.ts +195 -0
- package/dist/types/utils/agent.d.ts +21 -0
- package/dist/types/utils/array.d.ts +39 -0
- package/dist/types/utils/file.d.ts +18 -0
- package/dist/types/utils/function.d.ts +32 -0
- package/dist/types/utils/string.d.ts +50 -0
- package/dist/types/utils/utils.d.ts +17 -0
- package/dist/types/video/canvas/canvas_renderer.d.ts +380 -0
- package/dist/types/video/renderer.d.ts +222 -0
- package/dist/types/video/texture/atlas.d.ts +201 -0
- package/dist/types/video/texture/cache.d.ts +45 -0
- package/dist/types/video/texture/canvas_texture.d.ts +78 -0
- package/dist/types/video/utils/autodetect.d.ts +7 -0
- package/dist/types/video/utils/resize.d.ts +4 -0
- package/dist/types/video/video.d.ts +92 -0
- package/dist/types/video/webgl/buffer/vertex.d.ts +56 -0
- package/dist/types/video/webgl/glshader.d.ts +93 -0
- package/dist/types/video/webgl/utils/attributes.d.ts +4 -0
- package/dist/types/video/webgl/utils/precision.d.ts +13 -0
- package/dist/types/video/webgl/utils/program.d.ts +5 -0
- package/dist/types/video/webgl/utils/string.d.ts +5 -0
- package/dist/types/video/webgl/utils/uniforms.d.ts +4 -0
- package/dist/types/video/webgl/webgl_compositor.d.ts +174 -0
- package/dist/types/video/webgl/webgl_renderer.d.ts +429 -0
- package/package.json +4 -4
- package/src/application/application.js +151 -7
- package/src/application/header.js +25 -0
- package/src/{video/utils → application}/resize.js +9 -6
- package/src/application/settings.js +19 -0
- package/src/camera/camera2d.js +1 -1
- package/src/index.js +34 -23
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +1 -1
- package/src/level/level.js +1 -1
- package/src/level/tiled/TMXLayer.js +1 -1
- package/src/level/tiled/TMXTileMap.js +2 -2
- package/src/loader/loadingscreen.js +1 -1
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +172 -145
- package/src/physics/world.js +10 -30
- package/src/renderable/container.js +7 -91
- package/src/renderable/imagelayer.js +1 -1
- package/src/renderable/trigger.js +1 -1
- package/src/renderable/ui/uibaseelement.js +1 -1
- package/src/state/stage.js +1 -1
- package/src/state/state.js +1 -1
- package/src/system/device.js +0 -20
- package/src/tweens/tween.js +1 -1
- package/src/video/canvas/canvas_renderer.js +3 -0
- package/src/video/renderer.js +7 -0
- package/src/video/texture/canvas_texture.js +2 -1
- package/src/video/utils/autodetect.js +18 -0
- package/src/video/video.js +13 -145
- package/src/video/webgl/glshader.js +3 -4
- package/src/video/webgl/utils/precision.js +18 -0
- package/src/video/webgl/webgl_renderer.js +3 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a 2D orthographic camera
|
|
4
|
+
* @augments Renderable
|
|
5
|
+
*/
|
|
6
|
+
export default class Camera2d extends Renderable {
|
|
7
|
+
/**
|
|
8
|
+
* Axis definition
|
|
9
|
+
* @enum {number}
|
|
10
|
+
* @property {number} NONE no axis
|
|
11
|
+
* @property {number} HORIZONTAL horizontal axis only
|
|
12
|
+
* @property {number} VERTICAL vertical axis only
|
|
13
|
+
* @property {number} BOTH both axis
|
|
14
|
+
* @readonly
|
|
15
|
+
* @name AXIS
|
|
16
|
+
* @memberof Camera2d
|
|
17
|
+
*/
|
|
18
|
+
readonly AXIS: {
|
|
19
|
+
NONE: number;
|
|
20
|
+
HORIZONTAL: number;
|
|
21
|
+
VERTICAL: number;
|
|
22
|
+
BOTH: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Camera bounds
|
|
26
|
+
* @public
|
|
27
|
+
* @type {Bounds}
|
|
28
|
+
* @name bounds
|
|
29
|
+
* @memberof Camera2d
|
|
30
|
+
*/
|
|
31
|
+
public bounds: Bounds;
|
|
32
|
+
/**
|
|
33
|
+
* enable or disable damping
|
|
34
|
+
* @private
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
private smoothFollow;
|
|
38
|
+
/**
|
|
39
|
+
* Camera damping for smooth transition [0 .. 1].
|
|
40
|
+
* 1 being the maximum value and will snap the camera to the target position
|
|
41
|
+
* @public
|
|
42
|
+
* @type {number}
|
|
43
|
+
* @name damping
|
|
44
|
+
* @default 1.0
|
|
45
|
+
* @memberof Camera2d
|
|
46
|
+
*/
|
|
47
|
+
public damping: number;
|
|
48
|
+
/**
|
|
49
|
+
* the closest point relative to the camera
|
|
50
|
+
* @public
|
|
51
|
+
* @type {number}
|
|
52
|
+
* @name near
|
|
53
|
+
* @default -1000
|
|
54
|
+
* @memberof Camera2d
|
|
55
|
+
*/
|
|
56
|
+
public near: number;
|
|
57
|
+
/**
|
|
58
|
+
* the furthest point relative to the camera.
|
|
59
|
+
* @public
|
|
60
|
+
* @type {number}
|
|
61
|
+
* @name far
|
|
62
|
+
* @default 1000
|
|
63
|
+
* @memberof Camera2d
|
|
64
|
+
*/
|
|
65
|
+
public far: number;
|
|
66
|
+
/**
|
|
67
|
+
* the default camera projection matrix
|
|
68
|
+
* (2d cameras use an orthographic projection by default).
|
|
69
|
+
* @public
|
|
70
|
+
* @type {Matrix3d}
|
|
71
|
+
* @name projectionMatrix
|
|
72
|
+
* @memberof Camera2d
|
|
73
|
+
*/
|
|
74
|
+
public projectionMatrix: Matrix3d;
|
|
75
|
+
/**
|
|
76
|
+
* the invert camera transform used to unproject points
|
|
77
|
+
* @ignore
|
|
78
|
+
* @type {Matrix2d}
|
|
79
|
+
* @name invCurrentTransform
|
|
80
|
+
* @memberof Camera2d
|
|
81
|
+
*/
|
|
82
|
+
invCurrentTransform: Matrix2d;
|
|
83
|
+
offset: Vector2d;
|
|
84
|
+
target: Vector2d | ObservableVector3d | null;
|
|
85
|
+
follow_axis: number;
|
|
86
|
+
_shake: {
|
|
87
|
+
intensity: number;
|
|
88
|
+
duration: number;
|
|
89
|
+
axis: number;
|
|
90
|
+
onComplete: null;
|
|
91
|
+
};
|
|
92
|
+
_fadeOut: {
|
|
93
|
+
color: null;
|
|
94
|
+
tween: null;
|
|
95
|
+
};
|
|
96
|
+
_fadeIn: {
|
|
97
|
+
color: null;
|
|
98
|
+
tween: null;
|
|
99
|
+
};
|
|
100
|
+
/** @ignore */
|
|
101
|
+
_updateProjectionMatrix(): void;
|
|
102
|
+
/** @ignore */
|
|
103
|
+
_followH(target: any): number;
|
|
104
|
+
/** @ignore */
|
|
105
|
+
_followV(target: any): number;
|
|
106
|
+
/**
|
|
107
|
+
* reset the camera position to specified coordinates
|
|
108
|
+
* @name reset
|
|
109
|
+
* @memberof Camera2d
|
|
110
|
+
* @param {number} [x=0]
|
|
111
|
+
* @param {number} [y=0]
|
|
112
|
+
*/
|
|
113
|
+
reset(x?: number | undefined, y?: number | undefined): void;
|
|
114
|
+
/**
|
|
115
|
+
* change the deadzone settings.
|
|
116
|
+
* the "deadzone" defines an area within the current camera in which
|
|
117
|
+
* the followed renderable can move without scrolling the camera.
|
|
118
|
+
* @name setDeadzone
|
|
119
|
+
* @see Camera2d.follow
|
|
120
|
+
* @memberof Camera2d
|
|
121
|
+
* @param {number} w - deadzone width
|
|
122
|
+
* @param {number} h - deadzone height
|
|
123
|
+
*/
|
|
124
|
+
setDeadzone(w: number, h: number): void;
|
|
125
|
+
deadzone: Rect | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* resize the camera
|
|
128
|
+
* @name resize
|
|
129
|
+
* @memberof Camera2d
|
|
130
|
+
* @param {number} w - new width of the camera
|
|
131
|
+
* @param {number} h - new height of the camera
|
|
132
|
+
* @returns {Camera2d} this camera
|
|
133
|
+
*/
|
|
134
|
+
resize(w: number, h: number): Camera2d;
|
|
135
|
+
/**
|
|
136
|
+
* set the camera boundaries (set to the world limit by default).
|
|
137
|
+
* the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
|
|
138
|
+
* @name setBounds
|
|
139
|
+
* @memberof Camera2d
|
|
140
|
+
* @param {number} x - world left limit
|
|
141
|
+
* @param {number} y - world top limit
|
|
142
|
+
* @param {number} w - world width limit
|
|
143
|
+
* @param {number} h - world height limit
|
|
144
|
+
*/
|
|
145
|
+
setBounds(x: number, y: number, w: number, h: number): void;
|
|
146
|
+
/**
|
|
147
|
+
* set the camera to follow the specified renderable. <br>
|
|
148
|
+
* (this will put the camera center around the given target)
|
|
149
|
+
* @name follow
|
|
150
|
+
* @memberof Camera2d
|
|
151
|
+
* @param {Renderable|Vector2d} target - renderable or position vector to follow
|
|
152
|
+
* @param {number} [axis=me.game.viewport.AXIS.BOTH] - Which axis to follow (see {@link Camera2d.AXIS})
|
|
153
|
+
* @param {number} [damping=1] - default damping value
|
|
154
|
+
* @example
|
|
155
|
+
* // set the camera to follow this renderable on both axis, and enable damping
|
|
156
|
+
* me.game.viewport.follow(this, me.game.viewport.AXIS.BOTH, 0.1);
|
|
157
|
+
*/
|
|
158
|
+
follow(target: Renderable | Vector2d, axis?: number | undefined, damping?: number | undefined): void;
|
|
159
|
+
/**
|
|
160
|
+
* unfollow the current target
|
|
161
|
+
* @name unfollow
|
|
162
|
+
* @memberof Camera2d
|
|
163
|
+
*/
|
|
164
|
+
unfollow(): void;
|
|
165
|
+
/**
|
|
166
|
+
* move the camera upper-left position by the specified offset.
|
|
167
|
+
* @name move
|
|
168
|
+
* @memberof Camera2d
|
|
169
|
+
* @see Camera2d.focusOn
|
|
170
|
+
* @param {number} x
|
|
171
|
+
* @param {number} y
|
|
172
|
+
* @example
|
|
173
|
+
* // Move the camera up by four pixels
|
|
174
|
+
* me.game.viewport.move(0, -4);
|
|
175
|
+
*/
|
|
176
|
+
move(x: number, y: number): void;
|
|
177
|
+
/**
|
|
178
|
+
* move the camera upper-left position to the specified coordinates
|
|
179
|
+
* @name moveTo
|
|
180
|
+
* @memberof Camera2d
|
|
181
|
+
* @see Camera2d.focusOn
|
|
182
|
+
* @param {number} x
|
|
183
|
+
* @param {number} y
|
|
184
|
+
*/
|
|
185
|
+
moveTo(x: number, y: number): void;
|
|
186
|
+
/** @ignore */
|
|
187
|
+
updateTarget(): void;
|
|
188
|
+
/** @ignore */
|
|
189
|
+
update(dt: any): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* shake the camera
|
|
192
|
+
* @name shake
|
|
193
|
+
* @memberof Camera2d
|
|
194
|
+
* @param {number} intensity - maximum offset that the screen can be moved
|
|
195
|
+
* while shaking
|
|
196
|
+
* @param {number} duration - expressed in milliseconds
|
|
197
|
+
* @param {number} [axis=me.game.viewport.AXIS.BOTH] - specify on which axis to apply the shake effect (see {@link Camera2d.AXIS})
|
|
198
|
+
* @param {Function} [onComplete] - callback once shaking effect is over
|
|
199
|
+
* @param {boolean} [force] - if true this will override the current effect
|
|
200
|
+
* @example
|
|
201
|
+
* // shake it baby !
|
|
202
|
+
* me.game.viewport.shake(10, 500, me.game.viewport.AXIS.BOTH);
|
|
203
|
+
*/
|
|
204
|
+
shake(intensity: number, duration: number, axis?: number | undefined, onComplete?: Function | undefined, force?: boolean | undefined): void;
|
|
205
|
+
/**
|
|
206
|
+
* fadeOut(flash) effect<p>
|
|
207
|
+
* screen is filled with the specified color and slowly goes back to normal
|
|
208
|
+
* @name fadeOut
|
|
209
|
+
* @memberof Camera2d
|
|
210
|
+
* @param {Color|string} color - a CSS color value
|
|
211
|
+
* @param {number} [duration=1000] - expressed in milliseconds
|
|
212
|
+
* @param {Function} [onComplete] - callback once effect is over
|
|
213
|
+
* @example
|
|
214
|
+
* // fade the camera to white upon dying, reload the level, and then fade out back
|
|
215
|
+
* me.game.viewport.fadeIn("#fff", 150, function() {
|
|
216
|
+
* me.audio.play("die", false);
|
|
217
|
+
* me.level.reload();
|
|
218
|
+
* me.game.viewport.fadeOut("#fff", 150);
|
|
219
|
+
* });
|
|
220
|
+
*/
|
|
221
|
+
fadeOut(color: Color | string, duration?: number | undefined, onComplete?: Function | undefined): void;
|
|
222
|
+
/**
|
|
223
|
+
* fadeIn effect <p>
|
|
224
|
+
* fade to the specified color
|
|
225
|
+
* @name fadeIn
|
|
226
|
+
* @memberof Camera2d
|
|
227
|
+
* @param {Color|string} color - a CSS color value
|
|
228
|
+
* @param {number} [duration=1000] - expressed in milliseconds
|
|
229
|
+
* @param {Function} [onComplete] - callback once effect is over
|
|
230
|
+
* @example
|
|
231
|
+
* // flash the camera to white for 75ms
|
|
232
|
+
* me.game.viewport.fadeIn("#FFFFFF", 75);
|
|
233
|
+
*/
|
|
234
|
+
fadeIn(color: Color | string, duration?: number | undefined, onComplete?: Function | undefined): void;
|
|
235
|
+
/**
|
|
236
|
+
* set the camera position around the specified object
|
|
237
|
+
* @name focusOn
|
|
238
|
+
* @memberof Camera2d
|
|
239
|
+
* @param {Renderable} target - the renderable to focus the camera on
|
|
240
|
+
*/
|
|
241
|
+
focusOn(target: Renderable): void;
|
|
242
|
+
/**
|
|
243
|
+
* check if the specified renderable is in the camera
|
|
244
|
+
* @name isVisible
|
|
245
|
+
* @memberof Camera2d
|
|
246
|
+
* @param {Renderable} obj - to be checked against
|
|
247
|
+
* @param {boolean} [floating = obj.floating] - if visibility check should be done against screen coordinates
|
|
248
|
+
* @returns {boolean}
|
|
249
|
+
*/
|
|
250
|
+
isVisible(obj: Renderable, floating?: boolean | undefined): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* convert the given "local" (screen) coordinates into world coordinates
|
|
253
|
+
* @name localToWorld
|
|
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
|
|
259
|
+
* @returns {Vector2d}
|
|
260
|
+
*/
|
|
261
|
+
localToWorld(x: number, y: number, v?: number | undefined): Vector2d;
|
|
262
|
+
/**
|
|
263
|
+
* convert the given world coordinates into "local" (screen) coordinates
|
|
264
|
+
* @name worldToLocal
|
|
265
|
+
* @memberof Camera2d
|
|
266
|
+
* @param {number} x
|
|
267
|
+
* @param {number} y
|
|
268
|
+
* @param {number} [v] - an optional vector object where to set the
|
|
269
|
+
* converted value
|
|
270
|
+
* @returns {Vector2d}
|
|
271
|
+
*/
|
|
272
|
+
worldToLocal(x: number, y: number, v?: number | undefined): Vector2d;
|
|
273
|
+
/**
|
|
274
|
+
* render the camera effects
|
|
275
|
+
* @ignore
|
|
276
|
+
*/
|
|
277
|
+
drawFX(renderer: any): void;
|
|
278
|
+
/**
|
|
279
|
+
* draw all object visibile in this viewport
|
|
280
|
+
* @ignore
|
|
281
|
+
*/
|
|
282
|
+
draw(renderer: any, container: any): void;
|
|
283
|
+
}
|
|
284
|
+
import Renderable from "./../renderable/renderable.js";
|
|
285
|
+
import Matrix3d from "./../math/matrix3.js";
|
|
286
|
+
import Matrix2d from "./../math/matrix2.js";
|
|
287
|
+
import Vector2d from "./../math/vector2.js";
|
|
288
|
+
import ObservableVector3d from "./../math/observable_vector3.js";
|
|
289
|
+
import Rect from "./../geometries/rectangle.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a Generic Object Entity
|
|
4
|
+
* @augments Renderable
|
|
5
|
+
* @see Renderable
|
|
6
|
+
*/
|
|
7
|
+
export default class Entity extends Renderable {
|
|
8
|
+
/**
|
|
9
|
+
* @param {number} x - the x coordinates of the entity object
|
|
10
|
+
* @param {number} y - the y coordinates of the entity object
|
|
11
|
+
* @param {object} settings - Entity properties, to be defined through Tiled or when calling the entity constructor
|
|
12
|
+
* <img src="images/object_properties.png"/>
|
|
13
|
+
* @param {number} settings.width - the physical width the entity takes up in game
|
|
14
|
+
* @param {number} settings.height - the physical height the entity takes up in game
|
|
15
|
+
* @param {string} [settings.name] - object entity name
|
|
16
|
+
* @param {string} [settings.id] - object unique IDs
|
|
17
|
+
* @param {Image|string} [settings.image] - resource name of a spritesheet to use for the entity renderable component
|
|
18
|
+
* @param {Vector2d} [settings.anchorPoint=0.0] - Entity anchor point
|
|
19
|
+
* @param {number} [settings.framewidth=settings.width] - width of a single frame in the given spritesheet
|
|
20
|
+
* @param {number} [settings.frameheight=settings.width] - height of a single frame in the given spritesheet
|
|
21
|
+
* @param {string} [settings.type] - object type
|
|
22
|
+
* @param {number} [settings.collisionMask] - Mask collision detection for this object
|
|
23
|
+
* @param {Rect[]|Polygon[]|Line[]|Ellipse[]} [settings.shapes] - the initial list of collision shapes (usually populated through Tiled)
|
|
24
|
+
*/
|
|
25
|
+
constructor(x: number, y: number, settings: {
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
id?: string | undefined;
|
|
30
|
+
image?: string | (new (width?: number | undefined, height?: number | undefined) => HTMLImageElement) | undefined;
|
|
31
|
+
anchorPoint?: any;
|
|
32
|
+
framewidth?: number | undefined;
|
|
33
|
+
frameheight?: number | undefined;
|
|
34
|
+
type?: string | undefined;
|
|
35
|
+
collisionMask?: number | undefined;
|
|
36
|
+
shapes?: Line[] | Polygon[] | Ellipse[] | Rect[] | undefined;
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* The array of renderable children of this entity.
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
42
|
+
children: any[];
|
|
43
|
+
public set renderable(arg: Renderable);
|
|
44
|
+
/**
|
|
45
|
+
* The entity renderable component (can be any objects deriving from me.Renderable, like me.Sprite for example)
|
|
46
|
+
* @public
|
|
47
|
+
* @type {Renderable}
|
|
48
|
+
* @name renderable
|
|
49
|
+
* @memberof Entity
|
|
50
|
+
*/
|
|
51
|
+
public get renderable(): Renderable;
|
|
52
|
+
/**
|
|
53
|
+
* object type (as defined in Tiled)
|
|
54
|
+
* @public
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @name type
|
|
57
|
+
* @memberof Entity
|
|
58
|
+
*/
|
|
59
|
+
public type: string;
|
|
60
|
+
/**
|
|
61
|
+
* object unique ID (as defined in Tiled)
|
|
62
|
+
* @public
|
|
63
|
+
* @type {number}
|
|
64
|
+
* @name id
|
|
65
|
+
* @memberof Entity
|
|
66
|
+
*/
|
|
67
|
+
public id: number;
|
|
68
|
+
/**
|
|
69
|
+
* dead/living state of the entity<br>
|
|
70
|
+
* default value : true
|
|
71
|
+
* @public
|
|
72
|
+
* @type {boolean}
|
|
73
|
+
* @name alive
|
|
74
|
+
* @memberof Entity
|
|
75
|
+
*/
|
|
76
|
+
public alive: boolean;
|
|
77
|
+
body: Body;
|
|
78
|
+
/** @ignore */
|
|
79
|
+
update(dt: any): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* update the bounds position when the body is modified
|
|
82
|
+
* @ignore
|
|
83
|
+
* @name onBodyUpdate
|
|
84
|
+
* @memberof Entity
|
|
85
|
+
* @param {Body} body - the body whose bounds to update
|
|
86
|
+
*/
|
|
87
|
+
onBodyUpdate(body: Body): void;
|
|
88
|
+
preDraw(renderer: any): void;
|
|
89
|
+
/**
|
|
90
|
+
* onDeactivateEvent Notification function<br>
|
|
91
|
+
* Called by engine before deleting the object
|
|
92
|
+
* @name onDeactivateEvent
|
|
93
|
+
* @memberof Entity
|
|
94
|
+
*/
|
|
95
|
+
onDeactivateEvent(): void;
|
|
96
|
+
}
|
|
97
|
+
import Renderable from "./../renderable/renderable.js";
|
|
98
|
+
import Body from "./../physics/body.js";
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import Application from "./application/application.js";
|
|
3
|
-
|
|
1
|
+
export default game;
|
|
4
2
|
/**
|
|
5
3
|
* game is a default instance of a melonJS Application and represents your current game,
|
|
6
4
|
* it contains all the objects, tilemap layers, current viewport, collision map, etc...<br>
|
|
7
5
|
* @namespace game
|
|
8
6
|
* @see Application
|
|
9
7
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let game = new Application();
|
|
13
|
-
|
|
14
|
-
// initialize the game manager on system boot
|
|
15
|
-
event.on(event.BOOT, () => {
|
|
16
|
-
// initialize the default game instance
|
|
17
|
-
game.init();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default game;
|
|
8
|
+
declare let game: Application;
|
|
9
|
+
import Application from "./application/application.js";
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* an ellipse Object
|
|
4
|
+
*/
|
|
5
|
+
export default class Ellipse {
|
|
6
|
+
/**
|
|
7
|
+
* @param {number} x - the center x coordinate of the ellipse
|
|
8
|
+
* @param {number} y - the center y coordinate of the ellipse
|
|
9
|
+
* @param {number} w - width (diameter) of the ellipse
|
|
10
|
+
* @param {number} h - height (diameter) of the ellipse
|
|
11
|
+
*/
|
|
12
|
+
constructor(x: number, y: number, w: number, h: number);
|
|
13
|
+
/**
|
|
14
|
+
* the center coordinates of the ellipse
|
|
15
|
+
* @public
|
|
16
|
+
* @type {Vector2d}
|
|
17
|
+
* @name pos
|
|
18
|
+
* @memberof Ellipse
|
|
19
|
+
*/
|
|
20
|
+
public pos: Vector2d;
|
|
21
|
+
/**
|
|
22
|
+
* The bounding rectangle for this shape
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
private _bounds;
|
|
26
|
+
/**
|
|
27
|
+
* Maximum radius of the ellipse
|
|
28
|
+
* @public
|
|
29
|
+
* @type {number}
|
|
30
|
+
* @name radius
|
|
31
|
+
* @memberof Ellipse
|
|
32
|
+
*/
|
|
33
|
+
public radius: number;
|
|
34
|
+
/**
|
|
35
|
+
* Pre-scaled radius vector for ellipse
|
|
36
|
+
* @public
|
|
37
|
+
* @type {Vector2d}
|
|
38
|
+
* @name radiusV
|
|
39
|
+
* @memberof Ellipse
|
|
40
|
+
*/
|
|
41
|
+
public radiusV: Vector2d;
|
|
42
|
+
/**
|
|
43
|
+
* Radius squared, for pythagorean theorom
|
|
44
|
+
* @public
|
|
45
|
+
* @type {Vector2d}
|
|
46
|
+
* @name radiusSq
|
|
47
|
+
* @memberof Ellipse
|
|
48
|
+
*/
|
|
49
|
+
public radiusSq: Vector2d;
|
|
50
|
+
/**
|
|
51
|
+
* x/y scaling ratio for ellipse
|
|
52
|
+
* @public
|
|
53
|
+
* @type {Vector2d}
|
|
54
|
+
* @name ratio
|
|
55
|
+
* @memberof Ellipse
|
|
56
|
+
*/
|
|
57
|
+
public ratio: Vector2d;
|
|
58
|
+
shapeType: string;
|
|
59
|
+
/** @ignore */
|
|
60
|
+
onResetEvent(x: any, y: any, w: any, h: any): void;
|
|
61
|
+
/**
|
|
62
|
+
* set new value to the Ellipse shape
|
|
63
|
+
* @name setShape
|
|
64
|
+
* @memberof Ellipse
|
|
65
|
+
* @param {number} x - the center x coordinate of the ellipse
|
|
66
|
+
* @param {number} y - the center y coordinate of the ellipse
|
|
67
|
+
* @param {number} w - width (diameter) of the ellipse
|
|
68
|
+
* @param {number} h - height (diameter) of the ellipse
|
|
69
|
+
* @returns {Ellipse} this instance for objecf chaining
|
|
70
|
+
*/
|
|
71
|
+
setShape(x: number, y: number, w: number, h: number): Ellipse;
|
|
72
|
+
/**
|
|
73
|
+
* Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
|
|
74
|
+
* @name rotate
|
|
75
|
+
* @memberof Ellipse
|
|
76
|
+
* @param {number} angle - The angle to rotate (in radians)
|
|
77
|
+
* @param {Vector2d|ObservableVector2d} [v] - an optional point to rotate around
|
|
78
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
79
|
+
*/
|
|
80
|
+
rotate(angle: number, v?: Vector2d | ObservableVector2d): Ellipse;
|
|
81
|
+
/**
|
|
82
|
+
* Scale this Ellipse by the specified scalar.
|
|
83
|
+
* @name scale
|
|
84
|
+
* @memberof Ellipse
|
|
85
|
+
* @param {number} x
|
|
86
|
+
* @param {number} [y=x]
|
|
87
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
88
|
+
*/
|
|
89
|
+
scale(x: number, y?: number | undefined): Ellipse;
|
|
90
|
+
/**
|
|
91
|
+
* Scale this Ellipse by the specified vector.
|
|
92
|
+
* @name scale
|
|
93
|
+
* @memberof Ellipse
|
|
94
|
+
* @param {Vector2d} v
|
|
95
|
+
* @returns {Ellipse} Reference to this object for method chaining
|
|
96
|
+
*/
|
|
97
|
+
scaleV(v: Vector2d): Ellipse;
|
|
98
|
+
/**
|
|
99
|
+
* apply the given transformation matrix to this ellipse
|
|
100
|
+
* @name transform
|
|
101
|
+
* @memberof Ellipse
|
|
102
|
+
* @param {Matrix2d} matrix - the transformation matrix
|
|
103
|
+
* @returns {Polygon} Reference to this object for method chaining
|
|
104
|
+
*/
|
|
105
|
+
transform(matrix: Matrix2d): Polygon;
|
|
106
|
+
/**
|
|
107
|
+
* translate the circle/ellipse by the specified offset
|
|
108
|
+
* @name translate
|
|
109
|
+
* @memberof Ellipse
|
|
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
|
|
120
|
+
* @returns {Ellipse} this ellipse
|
|
121
|
+
*/
|
|
122
|
+
translate(...args: any[]): Ellipse;
|
|
123
|
+
/**
|
|
124
|
+
* check if this circle/ellipse contains the specified point
|
|
125
|
+
* @name contains
|
|
126
|
+
* @method
|
|
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
|
|
137
|
+
* @returns {boolean} true if contains
|
|
138
|
+
*/
|
|
139
|
+
contains(...args: any[]): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
|
|
142
|
+
* @name getBounds
|
|
143
|
+
* @memberof Ellipse
|
|
144
|
+
* @returns {Bounds} this shape bounding box Rectangle object
|
|
145
|
+
*/
|
|
146
|
+
getBounds(): Bounds;
|
|
147
|
+
/**
|
|
148
|
+
* clone this Ellipse
|
|
149
|
+
* @name clone
|
|
150
|
+
* @memberof Ellipse
|
|
151
|
+
* @returns {Ellipse} new Ellipse
|
|
152
|
+
*/
|
|
153
|
+
clone(): Ellipse;
|
|
154
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a line segment Object
|
|
4
|
+
* @augments Polygon
|
|
5
|
+
* @param {number} x - origin point of the Line
|
|
6
|
+
* @param {number} y - origin point of the Line
|
|
7
|
+
* @param {Vector2d[]} points - array of vectors defining the Line
|
|
8
|
+
*/
|
|
9
|
+
export default class Line extends Polygon {
|
|
10
|
+
}
|
|
11
|
+
import Polygon from "./poly.js";
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @classdesc
|
|
3
|
+
* a simplified path2d implementation, supporting only one path
|
|
4
|
+
*/
|
|
5
|
+
export default class Path2D {
|
|
6
|
+
/**
|
|
7
|
+
* the points defining the current path
|
|
8
|
+
* @public
|
|
9
|
+
* @type {Vector2d[]}
|
|
10
|
+
* @name points
|
|
11
|
+
* @memberof Path2D#
|
|
12
|
+
*/
|
|
13
|
+
public points: Vector2d[];
|
|
14
|
+
/**
|
|
15
|
+
* space between interpolated points for quadratic and bezier curve approx. in pixels.
|
|
16
|
+
* @public
|
|
17
|
+
* @type {number}
|
|
18
|
+
* @name arcResolution
|
|
19
|
+
* @default 5
|
|
20
|
+
* @memberof Path2D#
|
|
21
|
+
*/
|
|
22
|
+
public arcResolution: number;
|
|
23
|
+
vertices: any[];
|
|
24
|
+
/**
|
|
25
|
+
* begin a new path
|
|
26
|
+
* @name beginPath
|
|
27
|
+
* @memberof Path2D
|
|
28
|
+
*/
|
|
29
|
+
beginPath(): void;
|
|
30
|
+
/**
|
|
31
|
+
* causes the point of the pen to move back to the start of the current path.
|
|
32
|
+
* It tries to draw a straight line from the current point to the start.
|
|
33
|
+
* If the shape has already been closed or has only one point, this function does nothing.
|
|
34
|
+
* @name closePath
|
|
35
|
+
* @memberof Path2D
|
|
36
|
+
*/
|
|
37
|
+
closePath(): void;
|
|
38
|
+
/**
|
|
39
|
+
* triangulate the shape defined by this path into an array of triangles
|
|
40
|
+
* @name triangulatePath
|
|
41
|
+
* @memberof Path2D
|
|
42
|
+
* @returns {Vector2d[]}
|
|
43
|
+
*/
|
|
44
|
+
triangulatePath(): Vector2d[];
|
|
45
|
+
/**
|
|
46
|
+
* moves the starting point of the current path to the (x, y) coordinates.
|
|
47
|
+
* @name moveTo
|
|
48
|
+
* @memberof Path2D
|
|
49
|
+
* @param {number} x - the x-axis (horizontal) coordinate of the point.
|
|
50
|
+
* @param {number} y - the y-axis (vertical) coordinate of the point.
|
|
51
|
+
*/
|
|
52
|
+
moveTo(x: number, y: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* connects the last point in the current patch to the (x, y) coordinates with a straight line.
|
|
55
|
+
* @name lineTo
|
|
56
|
+
* @memberof Path2D
|
|
57
|
+
* @param {number} x - the x-axis coordinate of the line's end point.
|
|
58
|
+
* @param {number} y - the y-axis coordinate of the line's end point.
|
|
59
|
+
*/
|
|
60
|
+
lineTo(x: number, y: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* adds an arc to the current path which is centered at (x, y) position with the given radius,
|
|
63
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
|
|
64
|
+
* @name arc
|
|
65
|
+
* @memberof Path2D
|
|
66
|
+
* @param {number} x - the horizontal coordinate of the arc's center.
|
|
67
|
+
* @param {number} y - the vertical coordinate of the arc's center.
|
|
68
|
+
* @param {number} radius - the arc's radius. Must be positive.
|
|
69
|
+
* @param {number} startAngle - the angle at which the arc starts in radians, measured from the positive x-axis.
|
|
70
|
+
* @param {number} endAngle - the angle at which the arc ends in radians, measured from the positive x-axis.
|
|
71
|
+
* @param {boolean} [anticlockwise=false] - an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
|
|
72
|
+
*/
|
|
73
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
|
|
74
|
+
/**
|
|
75
|
+
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
76
|
+
* @name arcTo
|
|
77
|
+
* @memberof Path2D
|
|
78
|
+
* @param {number} x1 - the x-axis coordinate of the first control point.
|
|
79
|
+
* @param {number} y1 - the y-axis coordinate of the first control point.
|
|
80
|
+
* @param {number} x2 - the x-axis coordinate of the second control point.
|
|
81
|
+
* @param {number} y2 - the y-axis coordinate of the second control point.
|
|
82
|
+
* @param {number} radius - the arc's radius. Must be positive.
|
|
83
|
+
*/
|
|
84
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
85
|
+
/**
|
|
86
|
+
* adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
|
|
87
|
+
* starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
|
|
88
|
+
* @name ellipse
|
|
89
|
+
* @memberof Path2D
|
|
90
|
+
* @param {number} x - the x-axis (horizontal) coordinate of the ellipse's center.
|
|
91
|
+
* @param {number} y - the y-axis (vertical) coordinate of the ellipse's center.
|
|
92
|
+
* @param {number} radiusX - the ellipse's major-axis radius. Must be non-negative.
|
|
93
|
+
* @param {number} radiusY - the ellipse's minor-axis radius. Must be non-negative.
|
|
94
|
+
* @param {number} rotation - the rotation of the ellipse, expressed in radians.
|
|
95
|
+
* @param {number} startAngle - the angle at which the ellipse starts, measured clockwise from the positive x-axis and expressed in radians.
|
|
96
|
+
* @param {number} endAngle - the angle at which the ellipse ends, measured clockwise from the positive x-axis and expressed in radians.
|
|
97
|
+
* @param {boolean} [anticlockwise=false] - an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
|
|
98
|
+
*/
|
|
99
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
|
|
100
|
+
/**
|
|
101
|
+
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|
|
102
|
+
* @name rect
|
|
103
|
+
* @memberof Path2D
|
|
104
|
+
* @param {number} x - the x-axis coordinate of the rectangle's starting point.
|
|
105
|
+
* @param {number} y - the y-axis coordinate of the rectangle's starting point.
|
|
106
|
+
* @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
|
|
107
|
+
* @param {number} height - the rectangle's height. Positive values are down, and negative are up.
|
|
108
|
+
*/
|
|
109
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* adds an rounded rectangle to the current path.
|
|
112
|
+
* @name roundRect
|
|
113
|
+
* @memberof Path2D
|
|
114
|
+
* @param {number} x - the x-axis coordinate of the rectangle's starting point.
|
|
115
|
+
* @param {number} y - the y-axis coordinate of the rectangle's starting point.
|
|
116
|
+
* @param {number} width - the rectangle's width. Positive values are to the right, and negative to the left.
|
|
117
|
+
* @param {number} height - the rectangle's height. Positive values are down, and negative are up.
|
|
118
|
+
* @param {number} radius - the arc's radius to draw the borders. Must be positive.
|
|
119
|
+
*/
|
|
120
|
+
roundRect(x: number, y: number, width: number, height: number, radius: number): void;
|
|
121
|
+
}
|