@vpmedia/phaser 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +8 -5
- package/src/index.js +19 -19
- package/src/phaser/core/animation.js +12 -9
- package/src/phaser/core/animation_manager.js +16 -6
- package/src/phaser/core/animation_parser.js +40 -17
- package/src/phaser/core/array_set.js +3 -5
- package/src/phaser/core/cache.js +12 -12
- package/src/phaser/core/const.js +1 -1
- package/src/phaser/core/device.js +2 -4
- package/src/phaser/core/device_util.js +50 -17
- package/src/phaser/core/dom.js +36 -27
- package/src/phaser/core/event_manager.js +47 -19
- package/src/phaser/core/factory.js +34 -12
- package/src/phaser/core/frame.js +3 -5
- package/src/phaser/core/frame_data.js +2 -4
- package/src/phaser/core/frame_util.js +11 -9
- package/src/phaser/core/game.js +22 -19
- package/src/phaser/core/input.js +24 -16
- package/src/phaser/core/input_handler.js +102 -28
- package/src/phaser/core/input_mouse.js +12 -16
- package/src/phaser/core/input_mspointer.js +11 -10
- package/src/phaser/core/input_pointer.js +61 -20
- package/src/phaser/core/input_touch.js +7 -9
- package/src/phaser/core/loader.js +171 -54
- package/src/phaser/core/loader_parser.js +29 -22
- package/src/phaser/core/raf.js +2 -4
- package/src/phaser/core/scale_manager.js +75 -31
- package/src/phaser/core/scene.js +2 -4
- package/src/phaser/core/scene_manager.js +9 -6
- package/src/phaser/core/signal.js +19 -11
- package/src/phaser/core/signal_binding.js +12 -7
- package/src/phaser/core/sound.js +23 -14
- package/src/phaser/core/sound_manager.js +62 -26
- package/src/phaser/core/sound_sprite.js +34 -34
- package/src/phaser/core/stage.js +4 -7
- package/src/phaser/core/time.js +3 -5
- package/src/phaser/core/timer.js +27 -10
- package/src/phaser/core/timer_event.js +1 -3
- package/src/phaser/core/tween.js +36 -12
- package/src/phaser/core/tween_data.js +17 -9
- package/src/phaser/core/tween_easing.js +87 -83
- package/src/phaser/core/tween_manager.js +34 -16
- package/src/phaser/core/world.js +3 -5
- package/src/phaser/display/bitmap_text.js +25 -14
- package/src/phaser/display/button.js +35 -8
- package/src/phaser/display/canvas/buffer.js +1 -3
- package/src/phaser/display/canvas/graphics.js +30 -15
- package/src/phaser/display/canvas/masker.js +7 -5
- package/src/phaser/display/canvas/pool.js +18 -11
- package/src/phaser/display/canvas/renderer.js +40 -20
- package/src/phaser/display/canvas/tinter.js +61 -19
- package/src/phaser/display/canvas/util.js +44 -35
- package/src/phaser/display/display_object.js +42 -24
- package/src/phaser/display/graphics.js +72 -39
- package/src/phaser/display/graphics_data.js +3 -4
- package/src/phaser/display/graphics_data_util.js +15 -5
- package/src/phaser/display/group.js +15 -9
- package/src/phaser/display/image.js +17 -9
- package/src/phaser/display/sprite_batch.js +8 -4
- package/src/phaser/display/sprite_util.js +67 -26
- package/src/phaser/display/text.js +92 -31
- package/src/phaser/display/webgl/abstract_filter.js +1 -3
- package/src/phaser/display/webgl/base_texture.js +8 -5
- package/src/phaser/display/webgl/blend_manager.js +1 -3
- package/src/phaser/display/webgl/earcut.js +170 -129
- package/src/phaser/display/webgl/earcut_node.js +1 -3
- package/src/phaser/display/webgl/fast_sprite_batch.js +48 -47
- package/src/phaser/display/webgl/filter_manager.js +1 -3
- package/src/phaser/display/webgl/filter_texture.js +17 -6
- package/src/phaser/display/webgl/graphics.js +72 -50
- package/src/phaser/display/webgl/graphics_data.js +2 -4
- package/src/phaser/display/webgl/mask_manager.js +17 -7
- package/src/phaser/display/webgl/render_texture.js +19 -10
- package/src/phaser/display/webgl/renderer.js +41 -9
- package/src/phaser/display/webgl/shader/complex.js +1 -3
- package/src/phaser/display/webgl/shader/fast.js +9 -4
- package/src/phaser/display/webgl/shader/normal.js +43 -15
- package/src/phaser/display/webgl/shader/primitive.js +1 -3
- package/src/phaser/display/webgl/shader/strip.js +1 -3
- package/src/phaser/display/webgl/shader_manager.js +1 -3
- package/src/phaser/display/webgl/sprite_batch.js +14 -15
- package/src/phaser/display/webgl/stencil_manager.js +19 -21
- package/src/phaser/display/webgl/texture.js +14 -10
- package/src/phaser/display/webgl/texture_util.js +11 -9
- package/src/phaser/display/webgl/util.js +21 -18
- package/src/phaser/geom/circle.js +27 -11
- package/src/phaser/geom/ellipse.js +26 -10
- package/src/phaser/geom/line.js +31 -13
- package/src/phaser/geom/matrix.js +14 -5
- package/src/phaser/geom/point.js +18 -13
- package/src/phaser/geom/polygon.js +13 -8
- package/src/phaser/geom/rectangle.js +57 -14
- package/src/phaser/geom/rounded_rectangle.js +12 -4
- package/src/phaser/geom/util/circle.js +40 -32
- package/src/phaser/geom/util/ellipse.js +10 -18
- package/src/phaser/geom/util/line.js +46 -37
- package/src/phaser/geom/util/matrix.js +11 -9
- package/src/phaser/geom/util/point.js +101 -79
- package/src/phaser/geom/util/polygon.js +7 -15
- package/src/phaser/geom/util/rectangle.js +95 -69
- package/src/phaser/geom/util/rounded_rectangle.js +7 -15
- package/src/phaser/util/math.js +123 -89
- package/types/global.d.ts +7 -0
- package/types/index.d.ts +22 -0
- package/types/index.d.ts.map +1 -0
- package/types/phaser/core/animation.d.ts +55 -0
- package/types/phaser/core/animation.d.ts.map +1 -0
- package/types/phaser/core/animation_manager.d.ts +35 -0
- package/types/phaser/core/animation_manager.d.ts.map +1 -0
- package/types/phaser/core/animation_parser.d.ts +22 -0
- package/types/phaser/core/animation_parser.d.ts.map +1 -0
- package/types/phaser/core/array_set.d.ts +23 -0
- package/types/phaser/core/array_set.d.ts.map +1 -0
- package/types/phaser/core/cache.d.ts +106 -0
- package/types/phaser/core/cache.d.ts.map +1 -0
- package/types/phaser/core/const.d.ts +81 -0
- package/types/phaser/core/const.d.ts.map +1 -0
- package/types/phaser/core/device.d.ts +36 -0
- package/types/phaser/core/device.d.ts.map +1 -0
- package/types/phaser/core/device_util.d.ts +58 -0
- package/types/phaser/core/device_util.d.ts.map +1 -0
- package/types/phaser/core/dom.d.ts +63 -0
- package/types/phaser/core/dom.d.ts.map +1 -0
- package/types/phaser/core/event_manager.d.ts +53 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -0
- package/types/phaser/core/factory.d.ts +12 -0
- package/types/phaser/core/factory.d.ts.map +1 -0
- package/types/phaser/core/frame.d.ts +30 -0
- package/types/phaser/core/frame.d.ts.map +1 -0
- package/types/phaser/core/frame_data.d.ts +14 -0
- package/types/phaser/core/frame_data.d.ts.map +1 -0
- package/types/phaser/core/frame_util.d.ts +17 -0
- package/types/phaser/core/frame_util.d.ts.map +1 -0
- package/types/phaser/core/game.d.ts +57 -0
- package/types/phaser/core/game.d.ts.map +1 -0
- package/types/phaser/core/input.d.ts +92 -0
- package/types/phaser/core/input.d.ts.map +1 -0
- package/types/phaser/core/input_handler.d.ts +111 -0
- package/types/phaser/core/input_handler.d.ts.map +1 -0
- package/types/phaser/core/input_mouse.d.ts +39 -0
- package/types/phaser/core/input_mouse.d.ts.map +1 -0
- package/types/phaser/core/input_mspointer.d.ts +34 -0
- package/types/phaser/core/input_mspointer.d.ts.map +1 -0
- package/types/phaser/core/input_pointer.d.ts +68 -0
- package/types/phaser/core/input_pointer.d.ts.map +1 -0
- package/types/phaser/core/input_touch.d.ts +37 -0
- package/types/phaser/core/input_touch.d.ts.map +1 -0
- package/types/phaser/core/loader.d.ts +94 -0
- package/types/phaser/core/loader.d.ts.map +1 -0
- package/types/phaser/core/loader_parser.d.ts +39 -0
- package/types/phaser/core/loader_parser.d.ts.map +1 -0
- package/types/phaser/core/raf.d.ts +15 -0
- package/types/phaser/core/raf.d.ts.map +1 -0
- package/types/phaser/core/scale_manager.d.ts +137 -0
- package/types/phaser/core/scale_manager.d.ts.map +1 -0
- package/types/phaser/core/scene.d.ts +17 -0
- package/types/phaser/core/scene.d.ts.map +1 -0
- package/types/phaser/core/scene_manager.d.ts +39 -0
- package/types/phaser/core/scene_manager.d.ts.map +1 -0
- package/types/phaser/core/signal.d.ts +25 -0
- package/types/phaser/core/signal.d.ts.map +1 -0
- package/types/phaser/core/signal_binding.d.ts +26 -0
- package/types/phaser/core/signal_binding.d.ts.map +1 -0
- package/types/phaser/core/sound.d.ts +72 -0
- package/types/phaser/core/sound.d.ts.map +1 -0
- package/types/phaser/core/sound_manager.d.ts +50 -0
- package/types/phaser/core/sound_manager.d.ts.map +1 -0
- package/types/phaser/core/sound_sprite.d.ts +18 -0
- package/types/phaser/core/sound_sprite.d.ts.map +1 -0
- package/types/phaser/core/stage.d.ts +23 -0
- package/types/phaser/core/stage.d.ts.map +1 -0
- package/types/phaser/core/time.d.ts +49 -0
- package/types/phaser/core/time.d.ts.map +1 -0
- package/types/phaser/core/timer.d.ts +49 -0
- package/types/phaser/core/timer.d.ts.map +1 -0
- package/types/phaser/core/timer_event.d.ts +18 -0
- package/types/phaser/core/timer_event.d.ts.map +1 -0
- package/types/phaser/core/tween.d.ts +52 -0
- package/types/phaser/core/tween.d.ts.map +1 -0
- package/types/phaser/core/tween_data.d.ts +37 -0
- package/types/phaser/core/tween_data.d.ts.map +1 -0
- package/types/phaser/core/tween_easing.d.ts +192 -0
- package/types/phaser/core/tween_easing.d.ts.map +1 -0
- package/types/phaser/core/tween_manager.d.ts +94 -0
- package/types/phaser/core/tween_manager.d.ts.map +1 -0
- package/types/phaser/core/world.d.ts +6 -0
- package/types/phaser/core/world.d.ts.map +1 -0
- package/types/phaser/display/bitmap_text.d.ts +59 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +47 -0
- package/types/phaser/display/button.d.ts.map +1 -0
- package/types/phaser/display/canvas/buffer.d.ts +11 -0
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -0
- package/types/phaser/display/canvas/graphics.d.ts +21 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +14 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +52 -0
- package/types/phaser/display/canvas/pool.d.ts.map +1 -0
- package/types/phaser/display/canvas/renderer.d.ts +28 -0
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -0
- package/types/phaser/display/canvas/tinter.d.ts +41 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +79 -0
- package/types/phaser/display/canvas/util.d.ts.map +1 -0
- package/types/phaser/display/display_object.d.ts +83 -0
- package/types/phaser/display/display_object.d.ts.map +1 -0
- package/types/phaser/display/graphics.d.ts +60 -0
- package/types/phaser/display/graphics.d.ts.map +1 -0
- package/types/phaser/display/graphics_data.d.ts +15 -0
- package/types/phaser/display/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/graphics_data_util.d.ts +8 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +49 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +52 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +11 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +40 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +125 -0
- package/types/phaser/display/text.d.ts.map +1 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts +17 -0
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -0
- package/types/phaser/display/webgl/base_texture.d.ts +20 -0
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/blend_manager.d.ts +14 -0
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut.d.ts +215 -0
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -0
- package/types/phaser/display/webgl/earcut_node.d.ts +19 -0
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +34 -0
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_manager.d.ts +21 -0
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/filter_texture.d.ts +13 -0
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics.d.ts +80 -0
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -0
- package/types/phaser/display/webgl/graphics_data.d.ts +23 -0
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -0
- package/types/phaser/display/webgl/mask_manager.d.ts +15 -0
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/render_texture.d.ts +25 -0
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/renderer.d.ts +44 -0
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/complex.d.ts +22 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/fast.d.ts +25 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/normal.d.ts +25 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts +21 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader/strip.d.ts +22 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -0
- package/types/phaser/display/webgl/shader_manager.d.ts +24 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts +36 -0
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts +12 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture.d.ts +30 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -0
- package/types/phaser/display/webgl/texture_util.d.ts +17 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +45 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +46 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +26 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +45 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +35 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +43 -0
- package/types/phaser/geom/point.d.ts.map +1 -0
- package/types/phaser/geom/polygon.d.ts +17 -0
- package/types/phaser/geom/polygon.d.ts.map +1 -0
- package/types/phaser/geom/rectangle.d.ts +71 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +21 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +64 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +16 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +49 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +22 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +179 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +10 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +141 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +10 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +182 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
3
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
4
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
5
|
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
5
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* TBD.
|
|
10
10
|
*/
|
|
11
|
-
export function initDefaultShaders() {
|
|
12
|
-
}
|
|
11
|
+
export function initDefaultShaders() {}
|
|
13
12
|
|
|
14
13
|
/**
|
|
14
|
+
* TBD.
|
|
15
15
|
*
|
|
16
|
-
* @param {object} gl TBD
|
|
17
|
-
* @param {string[]|string} shaderSrc TBD
|
|
18
|
-
* @param {object} shaderType TBD
|
|
19
|
-
* @returns {object} TBD
|
|
16
|
+
* @param {object} gl - TBD.
|
|
17
|
+
* @param {string[]|string} shaderSrc - TBD.
|
|
18
|
+
* @param {object} shaderType - TBD.
|
|
19
|
+
* @returns {object} TBD.
|
|
20
20
|
*/
|
|
21
21
|
export function compileShader(gl, shaderSrc, shaderType) {
|
|
22
22
|
let src = shaderSrc;
|
|
@@ -36,31 +36,34 @@ export function compileShader(gl, shaderSrc, shaderType) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
+
* TBD.
|
|
39
40
|
*
|
|
40
|
-
* @param {object} gl TBD
|
|
41
|
-
* @param {string[]|string} shaderSrc TBD
|
|
42
|
-
* @returns {object} TBD
|
|
41
|
+
* @param {object} gl - TBD.
|
|
42
|
+
* @param {string[]|string} shaderSrc - TBD.
|
|
43
|
+
* @returns {object} TBD.
|
|
43
44
|
*/
|
|
44
45
|
export function compileVertexShader(gl, shaderSrc) {
|
|
45
46
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
50
|
+
* TBD.
|
|
49
51
|
*
|
|
50
|
-
* @param {object} gl TBD
|
|
51
|
-
* @param {string[]|string} shaderSrc TBD
|
|
52
|
-
* @returns {object} TBD
|
|
52
|
+
* @param {object} gl - TBD.
|
|
53
|
+
* @param {string[]|string} shaderSrc - TBD.
|
|
54
|
+
* @returns {object} TBD.
|
|
53
55
|
*/
|
|
54
56
|
export function compileFragmentShader(gl, shaderSrc) {
|
|
55
57
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/**
|
|
61
|
+
* TBD.
|
|
59
62
|
*
|
|
60
|
-
* @param {object} gl TBD
|
|
61
|
-
* @param {string[]|string} vertexSrc TBD
|
|
62
|
-
* @param {string[]|string} fragmentSrc TBD
|
|
63
|
-
* @returns {object} TBD
|
|
63
|
+
* @param {object} gl - TBD.
|
|
64
|
+
* @param {string[]|string} vertexSrc - TBD.
|
|
65
|
+
* @param {string[]|string} fragmentSrc - TBD.
|
|
66
|
+
* @returns {object} TBD.
|
|
64
67
|
*/
|
|
65
68
|
export function compileProgram(gl, vertexSrc, fragmentSrc) {
|
|
66
69
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/circle
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
-
import Rectangle from
|
|
7
|
+
import { Point } from './point';
|
|
8
|
+
import { Rectangle } from './rectangle';
|
|
8
9
|
import { distance } from '../util/math';
|
|
9
10
|
import { clone, contains, circumferencePoint } from './util/circle';
|
|
10
11
|
import { GEOM_CIRCLE } from '../core/const';
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
-
|
|
13
|
+
export class Circle {
|
|
14
|
+
/**
|
|
15
|
+
* TBD.
|
|
16
|
+
*
|
|
17
|
+
* @param {number} x - TBD.
|
|
18
|
+
* @param {number} y - TBD.
|
|
19
|
+
* @param {number} diameter - TBD.
|
|
20
|
+
*/
|
|
14
21
|
constructor(x = 0, y = 0, diameter = 0) {
|
|
15
22
|
this.x = x;
|
|
16
23
|
this.y = y;
|
|
@@ -30,11 +37,11 @@ export default class {
|
|
|
30
37
|
const result = output || new Point();
|
|
31
38
|
const t = 2 * Math.PI * Math.random();
|
|
32
39
|
const u = Math.random() + Math.random();
|
|
33
|
-
const r =
|
|
40
|
+
const r = u > 1 ? 2 - u : u;
|
|
34
41
|
const x = r * Math.cos(t);
|
|
35
42
|
const y = r * Math.sin(t);
|
|
36
|
-
result.x = this.x +
|
|
37
|
-
result.y = this.y +
|
|
43
|
+
result.x = this.x + x * this.radius;
|
|
44
|
+
result.y = this.y + y * this.radius;
|
|
38
45
|
return result;
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -89,7 +96,17 @@ export default class {
|
|
|
89
96
|
}
|
|
90
97
|
|
|
91
98
|
toString() {
|
|
92
|
-
return
|
|
99
|
+
return (
|
|
100
|
+
'[{Circle (x=' +
|
|
101
|
+
this.x +
|
|
102
|
+
' y=' +
|
|
103
|
+
this.y +
|
|
104
|
+
' diameter=' +
|
|
105
|
+
this.diameter +
|
|
106
|
+
' radius=' +
|
|
107
|
+
this.radius +
|
|
108
|
+
')}]'
|
|
109
|
+
);
|
|
93
110
|
}
|
|
94
111
|
|
|
95
112
|
get diameter() {
|
|
@@ -174,7 +191,7 @@ export default class {
|
|
|
174
191
|
}
|
|
175
192
|
|
|
176
193
|
get empty() {
|
|
177
|
-
return
|
|
194
|
+
return this._diameter === 0;
|
|
178
195
|
}
|
|
179
196
|
|
|
180
197
|
set empty(value) {
|
|
@@ -182,5 +199,4 @@ export default class {
|
|
|
182
199
|
this.setTo(0, 0, 0);
|
|
183
200
|
}
|
|
184
201
|
}
|
|
185
|
-
|
|
186
202
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/ellipse
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
-
import Rectangle from
|
|
7
|
+
import { Point } from './point';
|
|
8
|
+
import { Rectangle } from './rectangle';
|
|
8
9
|
import { contains } from './util/ellipse';
|
|
9
10
|
import { GEOM_ELLIPSE } from '../core/const';
|
|
10
11
|
|
|
11
|
-
export
|
|
12
|
-
|
|
12
|
+
export class Ellipse {
|
|
13
|
+
/**
|
|
14
|
+
* TBD.
|
|
15
|
+
*
|
|
16
|
+
* @param {number} x - TBD.
|
|
17
|
+
* @param {number} y - TBD.
|
|
18
|
+
* @param {number} width - TBD.
|
|
19
|
+
* @param {number} height - TBD.
|
|
20
|
+
*/
|
|
13
21
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
14
22
|
this.x = x;
|
|
15
23
|
this.y = y;
|
|
@@ -52,14 +60,22 @@ export default class {
|
|
|
52
60
|
const r = Math.random();
|
|
53
61
|
result.x = Math.sqrt(r) * Math.cos(p);
|
|
54
62
|
result.y = Math.sqrt(r) * Math.sin(p);
|
|
55
|
-
result.x = this.x + (result.x * this.width / 2.0
|
|
56
|
-
result.y = this.y + (result.y * this.height / 2.0
|
|
63
|
+
result.x = this.x + (result.x * this.width) / 2.0;
|
|
64
|
+
result.y = this.y + (result.y * this.height) / 2.0;
|
|
57
65
|
return result;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
toString() {
|
|
61
|
-
return
|
|
69
|
+
return (
|
|
70
|
+
'[{Ellipse (x=' +
|
|
71
|
+
this.x +
|
|
72
|
+
' y=' +
|
|
73
|
+
this.y +
|
|
74
|
+
' width=' +
|
|
75
|
+
this.width +
|
|
76
|
+
' height=' +
|
|
77
|
+
this.height +
|
|
78
|
+
')}]'
|
|
79
|
+
);
|
|
62
80
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
81
|
}
|
package/src/phaser/geom/line.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/line
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
+
import { Point } from './point';
|
|
7
8
|
import { clone, intersectsPoints, reflect } from './util/line';
|
|
8
9
|
import { wrap } from '../util/math';
|
|
9
10
|
import { GEOM_LINE } from '../core/const';
|
|
10
11
|
|
|
11
|
-
export
|
|
12
|
-
|
|
12
|
+
export class Line {
|
|
13
|
+
/**
|
|
14
|
+
* TBD.
|
|
15
|
+
*
|
|
16
|
+
* @param {number} x1 - TBD.
|
|
17
|
+
* @param {number} y1 - TBD.
|
|
18
|
+
* @param {number} x2 - TBD.
|
|
19
|
+
* @param {number} y2 - TBD.
|
|
20
|
+
*/
|
|
13
21
|
constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
|
|
14
22
|
this.start = new Point(x1, y1);
|
|
15
23
|
this.end = new Point(x2, y2);
|
|
@@ -24,14 +32,19 @@ export default class {
|
|
|
24
32
|
|
|
25
33
|
fromSprite(startSprite, endSprite, useCenter = false) {
|
|
26
34
|
if (useCenter) {
|
|
27
|
-
return this.setTo(
|
|
35
|
+
return this.setTo(
|
|
36
|
+
startSprite.center.x,
|
|
37
|
+
startSprite.center.y,
|
|
38
|
+
endSprite.center.x,
|
|
39
|
+
endSprite.center.y
|
|
40
|
+
);
|
|
28
41
|
}
|
|
29
42
|
return this.setTo(startSprite.x, startSprite.y, endSprite.x, endSprite.y);
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
fromAngle(x, y, angle, length) {
|
|
33
46
|
this.start.setTo(x, y);
|
|
34
|
-
this.end.setTo(x +
|
|
47
|
+
this.end.setTo(x + Math.cos(angle) * length, y + Math.sin(angle) * length);
|
|
35
48
|
return this;
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -74,7 +87,10 @@ export default class {
|
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
pointOnLine(x, y) {
|
|
77
|
-
return (
|
|
90
|
+
return (
|
|
91
|
+
(x - this.start.x) * (this.end.y - this.start.y) ===
|
|
92
|
+
(this.end.x - this.start.x) * (y - this.start.y)
|
|
93
|
+
);
|
|
78
94
|
}
|
|
79
95
|
|
|
80
96
|
pointOnSegment(x, y) {
|
|
@@ -82,7 +98,7 @@ export default class {
|
|
|
82
98
|
const xMax = Math.max(this.start.x, this.end.x);
|
|
83
99
|
const yMin = Math.min(this.start.y, this.end.y);
|
|
84
100
|
const yMax = Math.max(this.start.y, this.end.y);
|
|
85
|
-
return
|
|
101
|
+
return this.pointOnLine(x, y) && x >= xMin && x <= xMax && y >= yMin && y <= yMax;
|
|
86
102
|
}
|
|
87
103
|
|
|
88
104
|
random(output = null) {
|
|
@@ -100,12 +116,12 @@ export default class {
|
|
|
100
116
|
const y2 = Math.round(this.end.y);
|
|
101
117
|
const dx = Math.abs(x2 - x1);
|
|
102
118
|
const dy = Math.abs(y2 - y1);
|
|
103
|
-
const sx =
|
|
104
|
-
const sy =
|
|
119
|
+
const sx = x1 < x2 ? 1 : -1;
|
|
120
|
+
const sy = y1 < y2 ? 1 : -1;
|
|
105
121
|
let err = dx - dy;
|
|
106
122
|
results.push([x1, y1]);
|
|
107
123
|
let i = 1;
|
|
108
|
-
while (!(
|
|
124
|
+
while (!(x1 === x2 && y1 === y2)) {
|
|
109
125
|
const e2 = err << 1;
|
|
110
126
|
if (e2 > -dy) {
|
|
111
127
|
err -= dy;
|
|
@@ -128,7 +144,10 @@ export default class {
|
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
get length() {
|
|
131
|
-
return Math.sqrt(
|
|
147
|
+
return Math.sqrt(
|
|
148
|
+
(this.end.x - this.start.x) * (this.end.x - this.start.x) +
|
|
149
|
+
(this.end.y - this.start.y) * (this.end.y - this.start.y)
|
|
150
|
+
);
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
get angle() {
|
|
@@ -186,5 +205,4 @@ export default class {
|
|
|
186
205
|
get normalAngle() {
|
|
187
206
|
return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
|
|
188
207
|
}
|
|
189
|
-
|
|
190
208
|
}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/matrix
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
+
import { Point } from './point';
|
|
7
8
|
import { clone } from './util/matrix';
|
|
8
9
|
import { GEOM_MATRIX } from '../core/const';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
11
|
+
export class Matrix {
|
|
12
|
+
/**
|
|
13
|
+
* TBD.
|
|
14
|
+
*
|
|
15
|
+
* @param {number} a - TBD.
|
|
16
|
+
* @param {number} b - TBD.
|
|
17
|
+
* @param {number} c - TBD.
|
|
18
|
+
* @param {number} d - TBD.
|
|
19
|
+
* @param {number} tx - TBD.
|
|
20
|
+
* @param {number} ty - TBD.
|
|
21
|
+
*/
|
|
12
22
|
constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
|
|
13
23
|
this.a = a;
|
|
14
24
|
this.b = b;
|
|
@@ -143,5 +153,4 @@ export default class {
|
|
|
143
153
|
identity() {
|
|
144
154
|
return this.setTo(1, 0, 0, 1, 0, 0);
|
|
145
155
|
}
|
|
146
|
-
|
|
147
156
|
}
|
package/src/phaser/geom/point.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/point
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
7
|
import { distance, rotate, clone } from './util/point';
|
|
7
8
|
import { GEOM_POINT } from '../core/const';
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
10
|
+
export class Point {
|
|
11
|
+
/**
|
|
12
|
+
* TBD.
|
|
13
|
+
*
|
|
14
|
+
* @param {number} x - TBD.
|
|
15
|
+
* @param {number} y - TBD.
|
|
16
|
+
*/
|
|
11
17
|
constructor(x = 0, y = 0) {
|
|
12
18
|
this.x = x;
|
|
13
19
|
this.y = y;
|
|
@@ -24,14 +30,14 @@ export default class {
|
|
|
24
30
|
|
|
25
31
|
setTo(x, y) {
|
|
26
32
|
this.x = x || 0;
|
|
27
|
-
this.y = y || (
|
|
33
|
+
this.y = y || (y !== 0 ? this.x : 0);
|
|
28
34
|
return this;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
set(x, y) {
|
|
32
38
|
// deprecated, use setTo(x, y)
|
|
33
39
|
this.x = x || 0;
|
|
34
|
-
this.y = y || (
|
|
40
|
+
this.y = y || (y !== 0 ? this.x : 0);
|
|
35
41
|
return this;
|
|
36
42
|
}
|
|
37
43
|
|
|
@@ -90,12 +96,12 @@ export default class {
|
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
equals(a) {
|
|
93
|
-
return
|
|
99
|
+
return a.x === this.x && a.y === this.y;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
angle(a, asDegrees = false) {
|
|
97
103
|
if (asDegrees) {
|
|
98
|
-
return (180 / Math.PI) *
|
|
104
|
+
return (180 / Math.PI) * Math.atan2(a.y - this.y, a.x - this.x);
|
|
99
105
|
}
|
|
100
106
|
return Math.atan2(a.y - this.y, a.x - this.x);
|
|
101
107
|
}
|
|
@@ -105,11 +111,11 @@ export default class {
|
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
getMagnitude() {
|
|
108
|
-
return Math.sqrt(
|
|
114
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
getMagnitudeSq() {
|
|
112
|
-
return
|
|
118
|
+
return this.x * this.x + this.y * this.y;
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
setMagnitude(magnitude) {
|
|
@@ -126,15 +132,15 @@ export default class {
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
isZero() {
|
|
129
|
-
return
|
|
135
|
+
return this.x === 0 && this.y === 0;
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
dot(a) {
|
|
133
|
-
return
|
|
139
|
+
return this.x * a.x + this.y * a.y;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
cross(a) {
|
|
137
|
-
return
|
|
143
|
+
return this.x * a.y - this.y * a.x;
|
|
138
144
|
}
|
|
139
145
|
|
|
140
146
|
perp() {
|
|
@@ -160,5 +166,4 @@ export default class {
|
|
|
160
166
|
toString() {
|
|
161
167
|
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
|
|
162
168
|
}
|
|
163
|
-
|
|
164
169
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/polygon
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
+
import { Point } from './point';
|
|
7
8
|
import { clone } from './util/polygon';
|
|
8
9
|
import { GEOM_POLYGON } from '../core/const';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
|
|
11
|
+
export class Polygon {
|
|
12
12
|
constructor(points = null) {
|
|
13
13
|
this.area = 0;
|
|
14
14
|
this._points = [];
|
|
@@ -53,7 +53,10 @@ export default class {
|
|
|
53
53
|
const iy = this._points[i + 1];
|
|
54
54
|
const jx = this._points[j];
|
|
55
55
|
const jy = this._points[j + 1];
|
|
56
|
-
if (
|
|
56
|
+
if (
|
|
57
|
+
((iy <= y && y < jy) || (jy <= y && y < iy)) &&
|
|
58
|
+
x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
|
|
59
|
+
) {
|
|
57
60
|
inside = !inside;
|
|
58
61
|
}
|
|
59
62
|
}
|
|
@@ -63,7 +66,10 @@ export default class {
|
|
|
63
66
|
const iy = this._points[i].y;
|
|
64
67
|
const jx = this._points[j].x;
|
|
65
68
|
const jy = this._points[j].y;
|
|
66
|
-
if (
|
|
69
|
+
if (
|
|
70
|
+
((iy <= y && y < jy) || (jy <= y && y < iy)) &&
|
|
71
|
+
x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
|
|
72
|
+
) {
|
|
67
73
|
inside = !inside;
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -117,7 +123,7 @@ export default class {
|
|
|
117
123
|
} else {
|
|
118
124
|
p2 = this._points[i + 1];
|
|
119
125
|
}
|
|
120
|
-
avgHeight = (
|
|
126
|
+
avgHeight = (p1.y - y0 + (p2.y - y0)) / 2;
|
|
121
127
|
width = p1.x - p2.x;
|
|
122
128
|
this.area += avgHeight * width;
|
|
123
129
|
}
|
|
@@ -136,5 +142,4 @@ export default class {
|
|
|
136
142
|
this._points = [];
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
|
|
140
145
|
}
|
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/rectangle
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
|
-
import Point from './point';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
import { Point } from './point';
|
|
8
|
+
import {
|
|
9
|
+
inflate,
|
|
10
|
+
size,
|
|
11
|
+
clone,
|
|
12
|
+
contains,
|
|
13
|
+
containsRect,
|
|
14
|
+
equals,
|
|
15
|
+
intersects,
|
|
16
|
+
intersection,
|
|
17
|
+
intersectsRaw,
|
|
18
|
+
union,
|
|
19
|
+
} from './util/rectangle';
|
|
20
|
+
import {
|
|
21
|
+
GEOM_RECTANGLE,
|
|
22
|
+
TOP_LEFT,
|
|
23
|
+
TOP_CENTER,
|
|
24
|
+
TOP_RIGHT,
|
|
25
|
+
LEFT_CENTER,
|
|
26
|
+
CENTER,
|
|
27
|
+
RIGHT_CENTER,
|
|
28
|
+
BOTTOM_LEFT,
|
|
29
|
+
BOTTOM_CENTER,
|
|
30
|
+
BOTTOM_RIGHT,
|
|
31
|
+
} from '../core/const';
|
|
32
|
+
|
|
33
|
+
export class Rectangle {
|
|
34
|
+
/**
|
|
35
|
+
* TBD.
|
|
36
|
+
*
|
|
37
|
+
* @param {number} x - TBD.
|
|
38
|
+
* @param {number} y - TBD.
|
|
39
|
+
* @param {number} width - TBD.
|
|
40
|
+
* @param {number} height - TBD.
|
|
41
|
+
*/
|
|
12
42
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
13
43
|
this.x = x;
|
|
14
44
|
this.y = y;
|
|
@@ -36,7 +66,9 @@ export default class {
|
|
|
36
66
|
}
|
|
37
67
|
|
|
38
68
|
scale(x, y) {
|
|
39
|
-
if (y === undefined) {
|
|
69
|
+
if (y === undefined) {
|
|
70
|
+
y = x;
|
|
71
|
+
}
|
|
40
72
|
this.width *= x;
|
|
41
73
|
this.height *= y;
|
|
42
74
|
return this;
|
|
@@ -164,7 +196,19 @@ export default class {
|
|
|
164
196
|
}
|
|
165
197
|
|
|
166
198
|
toString() {
|
|
167
|
-
return
|
|
199
|
+
return (
|
|
200
|
+
'[{Rectangle (x=' +
|
|
201
|
+
this.x +
|
|
202
|
+
' y=' +
|
|
203
|
+
this.y +
|
|
204
|
+
' width=' +
|
|
205
|
+
this.width +
|
|
206
|
+
' height=' +
|
|
207
|
+
this.height +
|
|
208
|
+
' empty=' +
|
|
209
|
+
this.empty +
|
|
210
|
+
')}]'
|
|
211
|
+
);
|
|
168
212
|
}
|
|
169
213
|
|
|
170
214
|
get halfWidth() {
|
|
@@ -184,7 +228,7 @@ export default class {
|
|
|
184
228
|
this.height = 0;
|
|
185
229
|
this.y = value;
|
|
186
230
|
} else {
|
|
187
|
-
this.height =
|
|
231
|
+
this.height = this.bottom - value;
|
|
188
232
|
}
|
|
189
233
|
}
|
|
190
234
|
|
|
@@ -266,7 +310,7 @@ export default class {
|
|
|
266
310
|
}
|
|
267
311
|
|
|
268
312
|
get perimeter() {
|
|
269
|
-
return
|
|
313
|
+
return this.width * 2 + this.height * 2;
|
|
270
314
|
}
|
|
271
315
|
|
|
272
316
|
get centerX() {
|
|
@@ -286,11 +330,11 @@ export default class {
|
|
|
286
330
|
}
|
|
287
331
|
|
|
288
332
|
get randomX() {
|
|
289
|
-
return this.x +
|
|
333
|
+
return this.x + Math.random() * this.width;
|
|
290
334
|
}
|
|
291
335
|
|
|
292
336
|
get randomY() {
|
|
293
|
-
return this.y +
|
|
337
|
+
return this.y + Math.random() * this.height;
|
|
294
338
|
}
|
|
295
339
|
|
|
296
340
|
get empty() {
|
|
@@ -302,5 +346,4 @@ export default class {
|
|
|
302
346
|
this.setTo(0, 0, 0, 0);
|
|
303
347
|
}
|
|
304
348
|
}
|
|
305
|
-
|
|
306
349
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/rounded_rectangle
|
|
3
|
+
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
2
4
|
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
3
5
|
* @author Richard Davey <rich@photonstorm.com>
|
|
4
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
6
|
*/
|
|
6
7
|
import { clone } from './util/rounded_rectangle';
|
|
7
8
|
import { GEOM_ROUNDED_RECTANGLE } from '../core/const';
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
10
|
+
export class RoundedRectangle {
|
|
11
|
+
/**
|
|
12
|
+
* TBD.
|
|
13
|
+
*
|
|
14
|
+
* @param {number} x - TBD.
|
|
15
|
+
* @param {number} y - TBD.
|
|
16
|
+
* @param {number} width - TBD.
|
|
17
|
+
* @param {number} height - TBD.
|
|
18
|
+
* @param {number} radius - TBD.
|
|
19
|
+
*/
|
|
11
20
|
constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
|
|
12
21
|
this.x = x;
|
|
13
22
|
this.y = y;
|
|
@@ -32,5 +41,4 @@ export default class {
|
|
|
32
41
|
clone() {
|
|
33
42
|
return clone(this);
|
|
34
43
|
}
|
|
35
|
-
|
|
36
44
|
}
|