@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,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/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
|
-
import Point from '../point';
|
|
7
|
+
import { Point } from '../point';
|
|
7
8
|
|
|
8
9
|
/**
|
|
10
|
+
* TBD.
|
|
9
11
|
*
|
|
10
|
-
* @param {
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {
|
|
13
|
-
* @returns {
|
|
12
|
+
* @param {Point} a - TBD.
|
|
13
|
+
* @param {Point} b - TBD.
|
|
14
|
+
* @param {Point} output - TBD.
|
|
15
|
+
* @returns {Point} TBD.
|
|
14
16
|
*/
|
|
15
17
|
export function add(a, b, output = null) {
|
|
16
18
|
const result = output || new Point();
|
|
@@ -20,11 +22,12 @@ export function add(a, b, output = null) {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
25
|
+
* TBD.
|
|
23
26
|
*
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @returns {
|
|
27
|
+
* @param {Point} a - TBD.
|
|
28
|
+
* @param {Point} b - TBD.
|
|
29
|
+
* @param {Point} output - TBD.
|
|
30
|
+
* @returns {Point} TBD.
|
|
28
31
|
*/
|
|
29
32
|
export function subtract(a, b, output = null) {
|
|
30
33
|
const result = output || new Point();
|
|
@@ -34,11 +37,12 @@ export function subtract(a, b, output = null) {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/**
|
|
40
|
+
* TBD.
|
|
37
41
|
*
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
41
|
-
* @returns {
|
|
42
|
+
* @param {Point} a - TBD.
|
|
43
|
+
* @param {Point} b - TBD.
|
|
44
|
+
* @param {Point} output - TBD.
|
|
45
|
+
* @returns {Point} TBD.
|
|
42
46
|
*/
|
|
43
47
|
export function multiply(a, b, output = null) {
|
|
44
48
|
const result = output || new Point();
|
|
@@ -48,11 +52,12 @@ export function multiply(a, b, output = null) {
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
/**
|
|
55
|
+
* TBD.
|
|
51
56
|
*
|
|
52
|
-
* @param {
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
57
|
+
* @param {Point} a - TBD.
|
|
58
|
+
* @param {Point} b - TBD.
|
|
59
|
+
* @param {Point} output - TBD.
|
|
60
|
+
* @returns {Point} TBD.
|
|
56
61
|
*/
|
|
57
62
|
export function divide(a, b, output = null) {
|
|
58
63
|
const result = output || new Point();
|
|
@@ -62,30 +67,33 @@ export function divide(a, b, output = null) {
|
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
/**
|
|
70
|
+
* TBD.
|
|
65
71
|
*
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {boolean} TBD
|
|
72
|
+
* @param {Point} a - TBD.
|
|
73
|
+
* @param {Point} b - TBD.
|
|
74
|
+
* @returns {boolean} TBD.
|
|
69
75
|
*/
|
|
70
76
|
export function equals(a, b) {
|
|
71
|
-
return
|
|
77
|
+
return a.x === b.x && a.y === b.y;
|
|
72
78
|
}
|
|
73
79
|
|
|
74
80
|
/**
|
|
81
|
+
* TBD.
|
|
75
82
|
*
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {
|
|
78
|
-
* @returns {number} TBD
|
|
83
|
+
* @param {Point} a - TBD.
|
|
84
|
+
* @param {Point} b - TBD.
|
|
85
|
+
* @returns {number} TBD.
|
|
79
86
|
*/
|
|
80
87
|
export function angle(a, b) {
|
|
81
88
|
return Math.atan2(a.y - b.y, a.x - b.x);
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
/**
|
|
92
|
+
* TBD.
|
|
85
93
|
*
|
|
86
|
-
* @param {
|
|
87
|
-
* @param {
|
|
88
|
-
* @returns {
|
|
94
|
+
* @param {Point} a - TBD.
|
|
95
|
+
* @param {Point} output - TBD.
|
|
96
|
+
* @returns {Point} TBD.
|
|
89
97
|
*/
|
|
90
98
|
export function negative(a, output = null) {
|
|
91
99
|
const result = output || new Point();
|
|
@@ -93,12 +101,13 @@ export function negative(a, output = null) {
|
|
|
93
101
|
}
|
|
94
102
|
|
|
95
103
|
/**
|
|
104
|
+
* TBD.
|
|
96
105
|
*
|
|
97
|
-
* @param {
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {number} s TBD
|
|
100
|
-
* @param {
|
|
101
|
-
* @returns {
|
|
106
|
+
* @param {Point} a - TBD.
|
|
107
|
+
* @param {Point} b - TBD.
|
|
108
|
+
* @param {number} s - TBD.
|
|
109
|
+
* @param {Point} output - TBD.
|
|
110
|
+
* @returns {Point} TBD.
|
|
102
111
|
*/
|
|
103
112
|
export function multiplyAdd(a, b, s, output = null) {
|
|
104
113
|
const result = output || new Point();
|
|
@@ -106,12 +115,13 @@ export function multiplyAdd(a, b, s, output = null) {
|
|
|
106
115
|
}
|
|
107
116
|
|
|
108
117
|
/**
|
|
118
|
+
* TBD.
|
|
109
119
|
*
|
|
110
|
-
* @param {
|
|
111
|
-
* @param {
|
|
112
|
-
* @param {number} f TBD
|
|
113
|
-
* @param {
|
|
114
|
-
* @returns {
|
|
120
|
+
* @param {Point} a - TBD.
|
|
121
|
+
* @param {Point} b - TBD.
|
|
122
|
+
* @param {number} f - TBD.
|
|
123
|
+
* @param {Point} output - TBD.
|
|
124
|
+
* @returns {Point} TBD.
|
|
115
125
|
*/
|
|
116
126
|
export function interpolate(a, b, f, output = null) {
|
|
117
127
|
const result = output || new Point();
|
|
@@ -119,10 +129,11 @@ export function interpolate(a, b, f, output = null) {
|
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
/**
|
|
132
|
+
* TBD.
|
|
122
133
|
*
|
|
123
|
-
* @param {
|
|
124
|
-
* @param {
|
|
125
|
-
* @returns {
|
|
134
|
+
* @param {Point} a - TBD.
|
|
135
|
+
* @param {Point} output - TBD.
|
|
136
|
+
* @returns {Point} TBD.
|
|
126
137
|
*/
|
|
127
138
|
export function perp(a, output = null) {
|
|
128
139
|
const result = output || new Point();
|
|
@@ -130,10 +141,11 @@ export function perp(a, output = null) {
|
|
|
130
141
|
}
|
|
131
142
|
|
|
132
143
|
/**
|
|
144
|
+
* TBD.
|
|
133
145
|
*
|
|
134
|
-
* @param {
|
|
135
|
-
* @param {
|
|
136
|
-
* @returns {
|
|
146
|
+
* @param {Point} a - TBD.
|
|
147
|
+
* @param {Point} output - TBD.
|
|
148
|
+
* @returns {Point} TBD.
|
|
137
149
|
*/
|
|
138
150
|
export function rperp(a, output = null) {
|
|
139
151
|
const result = output || new Point();
|
|
@@ -141,11 +153,12 @@ export function rperp(a, output = null) {
|
|
|
141
153
|
}
|
|
142
154
|
|
|
143
155
|
/**
|
|
156
|
+
* TBD.
|
|
144
157
|
*
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {boolean} round TBD
|
|
148
|
-
* @returns {number} TBD
|
|
158
|
+
* @param {Point} a - TBD.
|
|
159
|
+
* @param {Point} b - TBD.
|
|
160
|
+
* @param {boolean} round - TBD.
|
|
161
|
+
* @returns {number} TBD.
|
|
149
162
|
*/
|
|
150
163
|
export function distance(a, b, round = false) {
|
|
151
164
|
const dx = a.x - b.x;
|
|
@@ -155,11 +168,12 @@ export function distance(a, b, round = false) {
|
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
/**
|
|
171
|
+
* TBD.
|
|
158
172
|
*
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
161
|
-
* @param {
|
|
162
|
-
* @returns {
|
|
173
|
+
* @param {Point} a - TBD.
|
|
174
|
+
* @param {Point} b - TBD.
|
|
175
|
+
* @param {Point} output - TBD.
|
|
176
|
+
* @returns {Point} TBD.
|
|
163
177
|
*/
|
|
164
178
|
export function project(a, b, output = null) {
|
|
165
179
|
const result = output || new Point();
|
|
@@ -171,11 +185,12 @@ export function project(a, b, output = null) {
|
|
|
171
185
|
}
|
|
172
186
|
|
|
173
187
|
/**
|
|
188
|
+
* TBD.
|
|
174
189
|
*
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
178
|
-
* @returns {
|
|
190
|
+
* @param {Point} a - TBD.
|
|
191
|
+
* @param {Point} b - TBD.
|
|
192
|
+
* @param {Point} output - TBD.
|
|
193
|
+
* @returns {Point} TBD.
|
|
179
194
|
*/
|
|
180
195
|
export function projectUnit(a, b, output = null) {
|
|
181
196
|
const result = output || new Point();
|
|
@@ -187,10 +202,11 @@ export function projectUnit(a, b, output = null) {
|
|
|
187
202
|
}
|
|
188
203
|
|
|
189
204
|
/**
|
|
205
|
+
* TBD.
|
|
190
206
|
*
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
193
|
-
* @returns {
|
|
207
|
+
* @param {Point} a - TBD.
|
|
208
|
+
* @param {Point} output - TBD.
|
|
209
|
+
* @returns {Point} TBD.
|
|
194
210
|
*/
|
|
195
211
|
export function normalRightHand(a, output = null) {
|
|
196
212
|
const result = output || new Point();
|
|
@@ -198,10 +214,11 @@ export function normalRightHand(a, output = null) {
|
|
|
198
214
|
}
|
|
199
215
|
|
|
200
216
|
/**
|
|
217
|
+
* TBD.
|
|
201
218
|
*
|
|
202
|
-
* @param {
|
|
203
|
-
* @param {
|
|
204
|
-
* @returns {
|
|
219
|
+
* @param {Point} a - TBD.
|
|
220
|
+
* @param {Point} output - TBD.
|
|
221
|
+
* @returns {Point} TBD.
|
|
205
222
|
*/
|
|
206
223
|
export function normalize(a, output = null) {
|
|
207
224
|
const result = output || new Point();
|
|
@@ -213,14 +230,15 @@ export function normalize(a, output = null) {
|
|
|
213
230
|
}
|
|
214
231
|
|
|
215
232
|
/**
|
|
233
|
+
* TBD.
|
|
216
234
|
*
|
|
217
|
-
* @param {
|
|
218
|
-
* @param {number} x TBD
|
|
219
|
-
* @param {number} y TBD
|
|
220
|
-
* @param {number} ang TBD
|
|
221
|
-
* @param {boolean} asDegrees TBD
|
|
222
|
-
* @param {number} dist TBD
|
|
223
|
-
* @returns {object} TBD
|
|
235
|
+
* @param {Point} a - TBD.
|
|
236
|
+
* @param {number} x - TBD.
|
|
237
|
+
* @param {number} y - TBD.
|
|
238
|
+
* @param {number} ang - TBD.
|
|
239
|
+
* @param {boolean} asDegrees - TBD.
|
|
240
|
+
* @param {number} dist - TBD.
|
|
241
|
+
* @returns {object} TBD.
|
|
224
242
|
*/
|
|
225
243
|
export function rotate(a, x, y, ang, asDegrees, dist) {
|
|
226
244
|
if (asDegrees) {
|
|
@@ -243,10 +261,12 @@ export function rotate(a, x, y, ang, asDegrees, dist) {
|
|
|
243
261
|
}
|
|
244
262
|
|
|
245
263
|
/**
|
|
264
|
+
* TBD.
|
|
246
265
|
*
|
|
247
|
-
* @param {
|
|
248
|
-
* @param {
|
|
249
|
-
* @returns {
|
|
266
|
+
* @param {Point[]} points - TBD.
|
|
267
|
+
* @param {Point} output - TBD.
|
|
268
|
+
* @returns {Point} TBD.
|
|
269
|
+
* @throws Error TBD.
|
|
250
270
|
*/
|
|
251
271
|
export function centroid(points, output = null) {
|
|
252
272
|
const result = output || new Point();
|
|
@@ -266,11 +286,12 @@ export function centroid(points, output = null) {
|
|
|
266
286
|
}
|
|
267
287
|
|
|
268
288
|
/**
|
|
289
|
+
* TBD.
|
|
269
290
|
*
|
|
270
|
-
* @param {object} obj TBD
|
|
271
|
-
* @param {string} xProp TBD
|
|
272
|
-
* @param {string} yProp TBD
|
|
273
|
-
* @returns {
|
|
291
|
+
* @param {object} obj - TBD.
|
|
292
|
+
* @param {string} xProp - TBD.
|
|
293
|
+
* @param {string} yProp - TBD.
|
|
294
|
+
* @returns {Point} TBD.
|
|
274
295
|
*/
|
|
275
296
|
export function parse(obj, xProp = 'x', yProp = 'y') {
|
|
276
297
|
const point = new Point();
|
|
@@ -284,10 +305,11 @@ export function parse(obj, xProp = 'x', yProp = 'y') {
|
|
|
284
305
|
}
|
|
285
306
|
|
|
286
307
|
/**
|
|
308
|
+
* TBD.
|
|
287
309
|
*
|
|
288
|
-
* @param {
|
|
289
|
-
* @param {
|
|
290
|
-
* @returns {
|
|
310
|
+
* @param {Point} input - TBD.
|
|
311
|
+
* @param {Point} output - TBD.
|
|
312
|
+
* @returns {Point} TBD.
|
|
291
313
|
*/
|
|
292
314
|
export function clone(input, output = null) {
|
|
293
315
|
const result = output || new Point();
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/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 Polygon from
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TBD
|
|
10
|
-
*
|
|
11
|
-
* @deprecated
|
|
12
|
-
* @returns {boolean} TBD
|
|
13
|
-
*/
|
|
14
|
-
export default function () {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
7
|
+
import { Polygon } from '../polygon';
|
|
17
8
|
|
|
18
9
|
/**
|
|
10
|
+
* TBD.
|
|
19
11
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @returns {
|
|
12
|
+
* @param {Polygon} input - TBD.
|
|
13
|
+
* @param {Polygon} output - TBD.
|
|
14
|
+
* @returns {Polygon} TBD.
|
|
23
15
|
*/
|
|
24
16
|
export function clone(input, output = null) {
|
|
25
17
|
const result = output || new Polygon();
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/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 Rectangle from
|
|
7
|
-
import Point from '../point';
|
|
7
|
+
import { Rectangle } from '../rectangle';
|
|
8
|
+
import { Point } from '../point';
|
|
8
9
|
|
|
9
10
|
/**
|
|
11
|
+
* TBD.
|
|
10
12
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {number} dx TBD
|
|
13
|
-
* @param {number} dy TBD
|
|
14
|
-
* @returns {
|
|
13
|
+
* @param {Rectangle} a - TBD.
|
|
14
|
+
* @param {number} dx - TBD.
|
|
15
|
+
* @param {number} dy - TBD.
|
|
16
|
+
* @returns {Rectangle} TBD.
|
|
15
17
|
*/
|
|
16
18
|
export function inflate(a, dx, dy) {
|
|
17
19
|
a.x -= dx;
|
|
@@ -22,20 +24,22 @@ export function inflate(a, dx, dy) {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/**
|
|
27
|
+
* TBD.
|
|
25
28
|
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {object} point TBD
|
|
28
|
-
* @returns {
|
|
29
|
+
* @param {Rectangle} a - TBD.
|
|
30
|
+
* @param {object} point - TBD.
|
|
31
|
+
* @returns {Rectangle} TBD.
|
|
29
32
|
*/
|
|
30
33
|
export function inflatePoint(a, point) {
|
|
31
34
|
return inflate(a, point.x, point.y);
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
/**
|
|
38
|
+
* TBD.
|
|
35
39
|
*
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
38
|
-
* @returns {
|
|
40
|
+
* @param {Rectangle} a - TBD.
|
|
41
|
+
* @param {Point} output - TBD.
|
|
42
|
+
* @returns {Point} TBD.
|
|
39
43
|
*/
|
|
40
44
|
export function size(a, output = null) {
|
|
41
45
|
const result = output || new Point();
|
|
@@ -44,10 +48,11 @@ export function size(a, output = null) {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/**
|
|
51
|
+
* TBD.
|
|
47
52
|
*
|
|
48
|
-
* @param {
|
|
49
|
-
* @param {
|
|
50
|
-
* @returns {
|
|
53
|
+
* @param {Rectangle} input - TBD.
|
|
54
|
+
* @param {Rectangle} output - TBD.
|
|
55
|
+
* @returns {Rectangle} TBD.
|
|
51
56
|
*/
|
|
52
57
|
export function clone(input, output = null) {
|
|
53
58
|
const result = output || new Rectangle();
|
|
@@ -56,81 +61,88 @@ export function clone(input, output = null) {
|
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
64
|
+
* TBD.
|
|
59
65
|
*
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {number} x TBD
|
|
62
|
-
* @param {number} y TBD
|
|
63
|
-
* @returns {boolean} TBD
|
|
66
|
+
* @param {Rectangle} a - TBD.
|
|
67
|
+
* @param {number} x - TBD.
|
|
68
|
+
* @param {number} y - TBD.
|
|
69
|
+
* @returns {boolean} TBD.
|
|
64
70
|
*/
|
|
65
71
|
export function contains(a, x, y) {
|
|
66
72
|
if (a.width <= 0 || a.height <= 0) {
|
|
67
73
|
return false;
|
|
68
74
|
}
|
|
69
|
-
return
|
|
75
|
+
return x >= a.x && x < a.right && y >= a.y && y < a.bottom;
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
/**
|
|
79
|
+
* TBD.
|
|
73
80
|
*
|
|
74
|
-
* @param {number} rx TBD
|
|
75
|
-
* @param {number} ry TBD
|
|
76
|
-
* @param {number} rw TBD
|
|
77
|
-
* @param {number} rh TBD
|
|
78
|
-
* @param {number} x TBD
|
|
79
|
-
* @param {number} y TBD
|
|
80
|
-
* @returns {boolean} TBD
|
|
81
|
+
* @param {number} rx - TBD.
|
|
82
|
+
* @param {number} ry - TBD.
|
|
83
|
+
* @param {number} rw - TBD.
|
|
84
|
+
* @param {number} rh - TBD.
|
|
85
|
+
* @param {number} x - TBD.
|
|
86
|
+
* @param {number} y - TBD.
|
|
87
|
+
* @returns {boolean} TBD.
|
|
81
88
|
*/
|
|
82
89
|
export function containsRaw(rx, ry, rw, rh, x, y) {
|
|
83
|
-
return
|
|
90
|
+
return x >= rx && x < rx + rw && y >= ry && y < ry + rh;
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
/**
|
|
94
|
+
* TBD.
|
|
87
95
|
*
|
|
88
|
-
* @param {
|
|
89
|
-
* @param {
|
|
90
|
-
* @returns {boolean} TBD
|
|
96
|
+
* @param {Rectangle} a - TBD.
|
|
97
|
+
* @param {Point} point - TBD.
|
|
98
|
+
* @returns {boolean} TBD.
|
|
91
99
|
*/
|
|
92
100
|
export function containsPoint(a, point) {
|
|
93
101
|
return contains(a, point.x, point.y);
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
/**
|
|
105
|
+
* TBD.
|
|
97
106
|
*
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {
|
|
100
|
-
* @returns {boolean} TBD
|
|
107
|
+
* @param {Rectangle} a - TBD.
|
|
108
|
+
* @param {Rectangle} b - TBD.
|
|
109
|
+
* @returns {boolean} TBD.
|
|
101
110
|
*/
|
|
102
111
|
export function containsRect(a, b) {
|
|
103
112
|
if (a.volume > b.volume) {
|
|
104
113
|
return false;
|
|
105
114
|
}
|
|
106
|
-
return
|
|
115
|
+
return a.x >= b.x && a.y >= b.y && a.right < b.right && a.bottom < b.bottom;
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
/**
|
|
119
|
+
* TBD.
|
|
110
120
|
*
|
|
111
|
-
* @param {
|
|
112
|
-
* @param {
|
|
113
|
-
* @returns {boolean} TBD
|
|
121
|
+
* @param {Rectangle} a - TBD.
|
|
122
|
+
* @param {Rectangle} b - TBD.
|
|
123
|
+
* @returns {boolean} TBD.
|
|
114
124
|
*/
|
|
115
125
|
export function equals(a, b) {
|
|
116
|
-
return
|
|
126
|
+
return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
/**
|
|
130
|
+
* TBD.
|
|
120
131
|
*
|
|
121
|
-
* @param {
|
|
122
|
-
* @param {
|
|
123
|
-
* @returns {boolean} TBD
|
|
132
|
+
* @param {Rectangle} a - TBD.
|
|
133
|
+
* @param {Rectangle} b - TBD.
|
|
134
|
+
* @returns {boolean} TBD.
|
|
124
135
|
*/
|
|
125
136
|
export function sameDimensions(a, b) {
|
|
126
|
-
return
|
|
137
|
+
return a.width === b.width && a.height === b.height;
|
|
127
138
|
}
|
|
128
139
|
|
|
129
140
|
/**
|
|
141
|
+
* TBD.
|
|
130
142
|
*
|
|
131
|
-
* @param {
|
|
132
|
-
* @param {
|
|
133
|
-
* @returns {boolean} TBD
|
|
143
|
+
* @param {Rectangle} a - TBD.
|
|
144
|
+
* @param {Rectangle} b - TBD.
|
|
145
|
+
* @returns {boolean} TBD.
|
|
134
146
|
*/
|
|
135
147
|
export function intersects(a, b) {
|
|
136
148
|
if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) {
|
|
@@ -140,11 +152,12 @@ export function intersects(a, b) {
|
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
/**
|
|
155
|
+
* TBD.
|
|
143
156
|
*
|
|
144
|
-
* @param {
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
147
|
-
* @returns {
|
|
157
|
+
* @param {Rectangle} a - TBD.
|
|
158
|
+
* @param {Rectangle} b - TBD.
|
|
159
|
+
* @param {Rectangle} output - TBD.
|
|
160
|
+
* @returns {Rectangle} TBD.
|
|
148
161
|
*/
|
|
149
162
|
export function intersection(a, b, output = null) {
|
|
150
163
|
const result = output || new Rectangle();
|
|
@@ -158,36 +171,49 @@ export function intersection(a, b, output = null) {
|
|
|
158
171
|
}
|
|
159
172
|
|
|
160
173
|
/**
|
|
174
|
+
* TBD.
|
|
161
175
|
*
|
|
162
|
-
* @param {
|
|
163
|
-
* @param {number} left TBD
|
|
164
|
-
* @param {number} right TBD
|
|
165
|
-
* @param {number} top TBD
|
|
166
|
-
* @param {number} bottom TBD
|
|
167
|
-
* @param {number} tolerance TBD
|
|
168
|
-
* @returns {boolean} TBD
|
|
176
|
+
* @param {Rectangle} a - TBD.
|
|
177
|
+
* @param {number} left - TBD.
|
|
178
|
+
* @param {number} right - TBD.
|
|
179
|
+
* @param {number} top - TBD.
|
|
180
|
+
* @param {number} bottom - TBD.
|
|
181
|
+
* @param {number} tolerance - TBD.
|
|
182
|
+
* @returns {boolean} TBD.
|
|
169
183
|
*/
|
|
170
184
|
export function intersectsRaw(a, left, right, top, bottom, tolerance = 0) {
|
|
171
|
-
return !(
|
|
185
|
+
return !(
|
|
186
|
+
left > a.right + tolerance ||
|
|
187
|
+
right < a.left - tolerance ||
|
|
188
|
+
top > a.bottom + tolerance ||
|
|
189
|
+
bottom < a.top - tolerance
|
|
190
|
+
);
|
|
172
191
|
}
|
|
173
192
|
|
|
174
193
|
/**
|
|
194
|
+
* TBD.
|
|
175
195
|
*
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
178
|
-
* @param {
|
|
179
|
-
* @returns {
|
|
196
|
+
* @param {Rectangle} a - TBD.
|
|
197
|
+
* @param {Rectangle} b - TBD.
|
|
198
|
+
* @param {Rectangle} output - TBD.
|
|
199
|
+
* @returns {Rectangle} TBD.
|
|
180
200
|
*/
|
|
181
201
|
export function union(a, b, output = null) {
|
|
182
202
|
const result = output || new Rectangle();
|
|
183
|
-
return result.setTo(
|
|
203
|
+
return result.setTo(
|
|
204
|
+
Math.min(a.x, b.x),
|
|
205
|
+
Math.min(a.y, b.y),
|
|
206
|
+
Math.max(a.right, b.right) - Math.min(a.left, b.left),
|
|
207
|
+
Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top)
|
|
208
|
+
);
|
|
184
209
|
}
|
|
185
210
|
|
|
186
211
|
/**
|
|
212
|
+
* TBD.
|
|
187
213
|
*
|
|
188
|
-
* @param {
|
|
189
|
-
* @param {
|
|
190
|
-
* @returns {
|
|
214
|
+
* @param {Point[]} points - TBD.
|
|
215
|
+
* @param {Rectangle} output - TBD.
|
|
216
|
+
* @returns {Rectangle} TBD.
|
|
191
217
|
*/
|
|
192
218
|
export function aabb(points, output = null) {
|
|
193
219
|
const result = output || new Rectangle();
|
|
@@ -214,9 +240,9 @@ export function aabb(points, output = null) {
|
|
|
214
240
|
}
|
|
215
241
|
|
|
216
242
|
/**
|
|
217
|
-
* TBD
|
|
243
|
+
* TBD.
|
|
218
244
|
*
|
|
219
|
-
* @returns {
|
|
245
|
+
* @returns {Rectangle} TBD.
|
|
220
246
|
*/
|
|
221
247
|
export function getEmptyRectangle() {
|
|
222
248
|
if (!window.PhaserRegistry) {
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @module geom/util/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
|
-
import RoundedRectangle from
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TBD
|
|
10
|
-
*
|
|
11
|
-
* @deprecated
|
|
12
|
-
* @returns {boolean} TBD
|
|
13
|
-
*/
|
|
14
|
-
export default function () {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
7
|
+
import { RoundedRectangle } from '../rounded_rectangle';
|
|
17
8
|
|
|
18
9
|
/**
|
|
10
|
+
* TBD.
|
|
19
11
|
*
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
22
|
-
* @returns {
|
|
12
|
+
* @param {RoundedRectangle} input - TBD.
|
|
13
|
+
* @param {RoundedRectangle} output - TBD.
|
|
14
|
+
* @returns {RoundedRectangle} TBD.
|
|
23
15
|
*/
|
|
24
16
|
export function clone(input, output = null) {
|
|
25
17
|
const result = output || new RoundedRectangle();
|