@vpmedia/phaser 1.14.0 → 1.16.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 +3 -3
- package/package.json +6 -5
- package/src/index.js +15 -18
- package/src/phaser/core/animation.js +102 -6
- package/src/phaser/core/animation_manager.js +88 -10
- package/src/phaser/core/animation_parser.js +5 -20
- package/src/phaser/core/array_set.js +51 -5
- package/src/phaser/core/cache.js +291 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +5 -6
- package/src/phaser/core/device_util.js +3 -25
- package/src/phaser/core/dom.js +127 -29
- package/src/phaser/core/event_manager.js +128 -6
- package/src/phaser/core/factory.js +69 -34
- package/src/phaser/core/frame.js +43 -6
- package/src/phaser/core/frame_data.js +55 -5
- package/src/phaser/core/frame_util.js +7 -14
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +116 -17
- package/src/phaser/core/input_handler.js +242 -42
- package/src/phaser/core/input_mouse.js +68 -7
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +79 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +274 -101
- package/src/phaser/core/loader_parser.js +2 -14
- package/src/phaser/core/raf.js +16 -5
- package/src/phaser/core/scale_manager.js +204 -39
- package/src/phaser/core/scene.js +24 -5
- package/src/phaser/core/scene_manager.js +81 -11
- package/src/phaser/core/signal.js +88 -11
- package/src/phaser/core/signal_binding.js +35 -15
- package/src/phaser/core/sound.js +99 -10
- package/src/phaser/core/sound_manager.js +89 -13
- package/src/phaser/core/sound_sprite.js +20 -5
- package/src/phaser/core/stage.js +43 -7
- package/src/phaser/core/time.js +67 -5
- package/src/phaser/core/timer.js +107 -30
- package/src/phaser/core/timer_event.js +11 -6
- package/src/phaser/core/tween.js +124 -30
- package/src/phaser/core/tween_data.js +42 -18
- package/src/phaser/core/tween_easing.js +1 -39
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +92 -11
- package/src/phaser/display/button.js +64 -13
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -16
- package/src/phaser/display/canvas/masker.js +0 -8
- package/src/phaser/display/canvas/pool.js +0 -14
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -48
- package/src/phaser/display/canvas/util.js +0 -15
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +162 -27
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -9
- package/src/phaser/display/group.js +75 -10
- package/src/phaser/display/image.js +86 -10
- package/src/phaser/display/sprite_batch.js +3 -9
- package/src/phaser/display/sprite_util.js +3 -28
- package/src/phaser/display/text.js +332 -32
- package/src/phaser/display/webgl/abstract_filter.js +8 -7
- package/src/phaser/display/webgl/base_texture.js +20 -12
- package/src/phaser/display/webgl/blend_manager.js +14 -7
- package/src/phaser/display/webgl/earcut.js +4 -50
- package/src/phaser/display/webgl/earcut_node.js +6 -7
- package/src/phaser/display/webgl/fast_sprite_batch.js +34 -11
- package/src/phaser/display/webgl/filter_manager.js +25 -7
- package/src/phaser/display/webgl/filter_texture.js +21 -22
- package/src/phaser/display/webgl/graphics.js +5 -40
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -8
- package/src/phaser/display/webgl/render_texture.js +33 -21
- package/src/phaser/display/webgl/renderer.js +38 -11
- package/src/phaser/display/webgl/shader/complex.js +10 -6
- package/src/phaser/display/webgl/shader/fast.js +10 -6
- package/src/phaser/display/webgl/shader/normal.js +23 -32
- package/src/phaser/display/webgl/shader/primitive.js +10 -6
- package/src/phaser/display/webgl/shader/strip.js +10 -6
- package/src/phaser/display/webgl/shader_manager.js +18 -6
- package/src/phaser/display/webgl/sprite_batch.js +41 -8
- package/src/phaser/display/webgl/stencil_manager.js +28 -6
- package/src/phaser/display/webgl/texture.js +28 -15
- package/src/phaser/display/webgl/texture_util.js +0 -8
- package/src/phaser/display/webgl/util.js +0 -11
- package/src/phaser/geom/circle.js +123 -19
- package/src/phaser/geom/ellipse.js +39 -19
- package/src/phaser/geom/line.js +148 -17
- package/src/phaser/geom/matrix.js +73 -7
- package/src/phaser/geom/point.js +152 -7
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -7
- package/src/phaser/geom/rounded_rectangle.js +10 -7
- package/src/phaser/geom/util/circle.js +3 -16
- package/src/phaser/geom/util/ellipse.js +0 -8
- package/src/phaser/geom/util/line.js +5 -19
- package/src/phaser/geom/util/matrix.js +1 -10
- package/src/phaser/geom/util/point.js +0 -26
- package/src/phaser/geom/util/polygon.js +1 -8
- package/src/phaser/geom/util/rectangle.js +1 -23
- package/src/phaser/geom/util/rounded_rectangle.js +1 -8
- package/src/phaser/util/math.js +3 -43
- package/{types → typedefs}/global.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +106 -5
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +88 -1
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +5 -6
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +53 -7
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +348 -58
- package/types/phaser/core/cache.d.ts.map +1 -1
- package/types/phaser/core/const.d.ts +143 -40
- package/types/phaser/core/const.d.ts.map +1 -1
- package/types/phaser/core/device.d.ts +2 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -10
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +122 -3
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +142 -15
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +74 -7
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +68 -26
- package/types/phaser/core/frame.d.ts.map +1 -1
- package/types/phaser/core/frame_data.d.ts +61 -9
- package/types/phaser/core/frame_data.d.ts.map +1 -1
- package/types/phaser/core/frame_util.d.ts +10 -10
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +54 -20
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +132 -21
- package/types/phaser/core/input.d.ts.map +1 -1
- package/types/phaser/core/input_handler.d.ts +258 -25
- package/types/phaser/core/input_handler.d.ts.map +1 -1
- package/types/phaser/core/input_mouse.d.ts +59 -12
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +49 -15
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +80 -4
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +52 -15
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +268 -23
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts +0 -4
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +17 -7
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +210 -15
- package/types/phaser/core/scale_manager.d.ts.map +1 -1
- package/types/phaser/core/scene.d.ts +21 -5
- package/types/phaser/core/scene.d.ts.map +1 -1
- package/types/phaser/core/scene_manager.d.ts +90 -10
- package/types/phaser/core/scene_manager.d.ts.map +1 -1
- package/types/phaser/core/signal.d.ts +95 -11
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +35 -6
- package/types/phaser/core/signal_binding.d.ts.map +1 -1
- package/types/phaser/core/sound.d.ts +111 -14
- package/types/phaser/core/sound.d.ts.map +1 -1
- package/types/phaser/core/sound_manager.d.ts +94 -8
- package/types/phaser/core/sound_manager.d.ts.map +1 -1
- package/types/phaser/core/sound_sprite.d.ts +22 -8
- package/types/phaser/core/sound_sprite.d.ts.map +1 -1
- package/types/phaser/core/stage.d.ts +32 -3
- package/types/phaser/core/stage.d.ts.map +1 -1
- package/types/phaser/core/time.d.ts +73 -6
- package/types/phaser/core/time.d.ts.map +1 -1
- package/types/phaser/core/timer.d.ts +103 -2
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +11 -5
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +123 -3
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +42 -3
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -36
- package/types/phaser/core/tween_easing.d.ts.map +1 -1
- package/types/phaser/core/tween_manager.d.ts +49 -2
- package/types/phaser/core/tween_manager.d.ts.map +1 -1
- package/types/phaser/core/world.d.ts +9 -1
- package/types/phaser/core/world.d.ts.map +1 -1
- package/types/phaser/display/bitmap_text.d.ts +89 -12
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +68 -11
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +21 -5
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts +0 -3
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts +0 -2
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -13
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +30 -3
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts +0 -5
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts +0 -9
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +196 -9
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +142 -16
- package/types/phaser/display/graphics.d.ts.map +1 -1
- package/types/phaser/display/graphics_data.d.ts +15 -1
- package/types/phaser/display/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/graphics_data_util.d.ts +3 -3
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +68 -6
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +77 -15
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -4
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts +0 -5
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +373 -53
- package/types/phaser/display/text.d.ts.map +1 -1
- package/types/phaser/display/webgl/abstract_filter.d.ts +8 -6
- package/types/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/types/phaser/display/webgl/base_texture.d.ts +20 -1
- package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/blend_manager.d.ts +11 -6
- package/types/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut.d.ts +0 -27
- package/types/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/types/phaser/display/webgl/earcut_node.d.ts +9 -9
- package/types/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts +33 -6
- package/types/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_manager.d.ts +23 -7
- package/types/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/filter_texture.d.ts +21 -3
- package/types/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics.d.ts +0 -12
- package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +12 -8
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts +0 -2
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +31 -4
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +42 -5
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +12 -2
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +12 -2
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +21 -1
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +12 -2
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +12 -2
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +20 -5
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +38 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/webgl/stencil_manager.d.ts +25 -0
- package/types/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture.d.ts +22 -1
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts +0 -2
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -10
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +130 -10
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +42 -6
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -14
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +84 -12
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -19
- package/types/phaser/geom/point.d.ts.map +1 -1
- package/types/phaser/geom/polygon.d.ts +45 -5
- package/types/phaser/geom/polygon.d.ts.map +1 -1
- package/types/phaser/geom/rectangle.d.ts +253 -21
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -2
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -10
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -7
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -10
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts +0 -3
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts +0 -20
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts +0 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts +0 -16
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts +0 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -27
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module geom/rectangle
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
1
|
import { Point } from './point';
|
|
8
2
|
import {
|
|
9
3
|
inflate,
|
|
@@ -33,7 +27,6 @@ import {
|
|
|
33
27
|
export class Rectangle {
|
|
34
28
|
/**
|
|
35
29
|
* TBD.
|
|
36
|
-
*
|
|
37
30
|
* @param {number} x - TBD.
|
|
38
31
|
* @param {number} y - TBD.
|
|
39
32
|
* @param {number} width - TBD.
|
|
@@ -47,16 +40,35 @@ export class Rectangle {
|
|
|
47
40
|
this.type = GEOM_RECTANGLE;
|
|
48
41
|
}
|
|
49
42
|
|
|
43
|
+
/**
|
|
44
|
+
* TBD.
|
|
45
|
+
* @param {number} dx - TBD.
|
|
46
|
+
* @param {number} dy - TBD.
|
|
47
|
+
* @returns {Rectangle} TBD.
|
|
48
|
+
*/
|
|
50
49
|
offset(dx, dy) {
|
|
51
50
|
this.x += dx;
|
|
52
51
|
this.y += dy;
|
|
53
52
|
return this;
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
/**
|
|
56
|
+
* TBD.
|
|
57
|
+
* @param {Point} point - TBD.
|
|
58
|
+
* @returns {Rectangle} TBD.
|
|
59
|
+
*/
|
|
56
60
|
offsetPoint(point) {
|
|
57
61
|
return this.offset(point.x, point.y);
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
/**
|
|
65
|
+
* TBD.
|
|
66
|
+
* @param {number} x - TBD.
|
|
67
|
+
* @param {number} y - TBD.
|
|
68
|
+
* @param {number} width - TBD.
|
|
69
|
+
* @param {number} height - TBD.
|
|
70
|
+
* @returns {Rectangle} TBD.
|
|
71
|
+
*/
|
|
60
72
|
setTo(x, y, width, height) {
|
|
61
73
|
this.x = x;
|
|
62
74
|
this.y = y;
|
|
@@ -65,6 +77,12 @@ export class Rectangle {
|
|
|
65
77
|
return this;
|
|
66
78
|
}
|
|
67
79
|
|
|
80
|
+
/**
|
|
81
|
+
* TBD.
|
|
82
|
+
* @param {number} x - TBD.
|
|
83
|
+
* @param {number} y - TBD.
|
|
84
|
+
* @returns {Rectangle} TBD.
|
|
85
|
+
*/
|
|
68
86
|
scale(x, y) {
|
|
69
87
|
if (y === undefined) {
|
|
70
88
|
y = x;
|
|
@@ -74,17 +92,29 @@ export class Rectangle {
|
|
|
74
92
|
return this;
|
|
75
93
|
}
|
|
76
94
|
|
|
95
|
+
/**
|
|
96
|
+
* TBD.
|
|
97
|
+
* @param {number} x - TBD.
|
|
98
|
+
* @param {number} y - TBD.
|
|
99
|
+
* @returns {Rectangle} TBD.
|
|
100
|
+
*/
|
|
77
101
|
centerOn(x, y) {
|
|
78
102
|
this.centerX = x;
|
|
79
103
|
this.centerY = y;
|
|
80
104
|
return this;
|
|
81
105
|
}
|
|
82
106
|
|
|
107
|
+
/**
|
|
108
|
+
* TBD.
|
|
109
|
+
*/
|
|
83
110
|
floor() {
|
|
84
111
|
this.x = Math.floor(this.x);
|
|
85
112
|
this.y = Math.floor(this.y);
|
|
86
113
|
}
|
|
87
114
|
|
|
115
|
+
/**
|
|
116
|
+
* TBD.
|
|
117
|
+
*/
|
|
88
118
|
floorAll() {
|
|
89
119
|
this.x = Math.floor(this.x);
|
|
90
120
|
this.y = Math.floor(this.y);
|
|
@@ -92,11 +122,17 @@ export class Rectangle {
|
|
|
92
122
|
this.height = Math.floor(this.height);
|
|
93
123
|
}
|
|
94
124
|
|
|
125
|
+
/**
|
|
126
|
+
* TBD.
|
|
127
|
+
*/
|
|
95
128
|
ceil() {
|
|
96
129
|
this.x = Math.ceil(this.x);
|
|
97
130
|
this.y = Math.ceil(this.y);
|
|
98
131
|
}
|
|
99
132
|
|
|
133
|
+
/**
|
|
134
|
+
* TBD.
|
|
135
|
+
*/
|
|
100
136
|
ceilAll() {
|
|
101
137
|
this.x = Math.ceil(this.x);
|
|
102
138
|
this.y = Math.ceil(this.y);
|
|
@@ -104,10 +140,20 @@ export class Rectangle {
|
|
|
104
140
|
this.height = Math.ceil(this.height);
|
|
105
141
|
}
|
|
106
142
|
|
|
143
|
+
/**
|
|
144
|
+
* TBD.
|
|
145
|
+
* @param {Rectangle} source - TBD.
|
|
146
|
+
* @returns {Rectangle} TBD.
|
|
147
|
+
*/
|
|
107
148
|
copyFrom(source) {
|
|
108
149
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
109
150
|
}
|
|
110
151
|
|
|
152
|
+
/**
|
|
153
|
+
* TBD.
|
|
154
|
+
* @param {Rectangle} dest - TBD.
|
|
155
|
+
* @returns {Rectangle} TBD.
|
|
156
|
+
*/
|
|
111
157
|
copyTo(dest) {
|
|
112
158
|
dest.x = this.x;
|
|
113
159
|
dest.y = this.y;
|
|
@@ -116,52 +162,121 @@ export class Rectangle {
|
|
|
116
162
|
return dest;
|
|
117
163
|
}
|
|
118
164
|
|
|
165
|
+
/**
|
|
166
|
+
* TBD.
|
|
167
|
+
* @param {number} dx - TBD.
|
|
168
|
+
* @param {number} dy - TBD.
|
|
169
|
+
* @returns {Rectangle} TBD.
|
|
170
|
+
*/
|
|
119
171
|
inflate(dx, dy) {
|
|
120
172
|
return inflate(this, dx, dy);
|
|
121
173
|
}
|
|
122
174
|
|
|
175
|
+
/**
|
|
176
|
+
* TBD.
|
|
177
|
+
* @param {Point} output - TBD.
|
|
178
|
+
* @returns {Point} TBD.
|
|
179
|
+
*/
|
|
123
180
|
size(output) {
|
|
124
181
|
return size(this, output);
|
|
125
182
|
}
|
|
126
183
|
|
|
184
|
+
/**
|
|
185
|
+
* TBD.
|
|
186
|
+
* @param {number} width - TBD.
|
|
187
|
+
* @param {number} height - TBD.
|
|
188
|
+
* @returns {Rectangle} TBD.
|
|
189
|
+
*/
|
|
127
190
|
resize(width, height) {
|
|
128
191
|
this.width = width;
|
|
129
192
|
this.height = height;
|
|
130
193
|
return this;
|
|
131
194
|
}
|
|
132
195
|
|
|
196
|
+
/**
|
|
197
|
+
* TBD.
|
|
198
|
+
* @param {Rectangle} output - TBD.
|
|
199
|
+
* @returns {Rectangle} TBD.
|
|
200
|
+
*/
|
|
133
201
|
clone(output) {
|
|
134
202
|
return clone(this, output);
|
|
135
203
|
}
|
|
136
204
|
|
|
205
|
+
/**
|
|
206
|
+
* TBD.
|
|
207
|
+
* @param {number} x - TBD.
|
|
208
|
+
* @param {number} y - TBD.
|
|
209
|
+
* @returns {boolean} TBD.
|
|
210
|
+
*/
|
|
137
211
|
contains(x, y) {
|
|
138
212
|
return contains(this, x, y);
|
|
139
213
|
}
|
|
140
214
|
|
|
215
|
+
/**
|
|
216
|
+
* TBD.
|
|
217
|
+
* @param {Rectangle} b - TBD.
|
|
218
|
+
* @returns {boolean} TBD.
|
|
219
|
+
*/
|
|
141
220
|
containsRect(b) {
|
|
142
221
|
return containsRect(b, this);
|
|
143
222
|
}
|
|
144
223
|
|
|
224
|
+
/**
|
|
225
|
+
* TBD.
|
|
226
|
+
* @param {Rectangle} b - TBD.
|
|
227
|
+
* @returns {boolean} TBD.
|
|
228
|
+
*/
|
|
145
229
|
equals(b) {
|
|
146
230
|
return equals(this, b);
|
|
147
231
|
}
|
|
148
232
|
|
|
233
|
+
/**
|
|
234
|
+
* TBD.
|
|
235
|
+
* @param {Rectangle} b - TBD.
|
|
236
|
+
* @param {Rectangle} out - TBD.
|
|
237
|
+
* @returns {Rectangle} TBD.
|
|
238
|
+
*/
|
|
149
239
|
intersection(b, out) {
|
|
150
240
|
return intersection(this, b, out);
|
|
151
241
|
}
|
|
152
242
|
|
|
243
|
+
/**
|
|
244
|
+
* TBD.
|
|
245
|
+
* @param {Rectangle} b - TBD.
|
|
246
|
+
* @returns {boolean} TBD.
|
|
247
|
+
*/
|
|
153
248
|
intersects(b) {
|
|
154
249
|
return intersects(this, b);
|
|
155
250
|
}
|
|
156
251
|
|
|
252
|
+
/**
|
|
253
|
+
* TBD.
|
|
254
|
+
* @param {number} left - TBD.
|
|
255
|
+
* @param {number} right - TBD.
|
|
256
|
+
* @param {number} top - TBD.
|
|
257
|
+
* @param {number} bottom - TBD.
|
|
258
|
+
* @param {number} tolerance - TBD.
|
|
259
|
+
* @returns {boolean} TBD.
|
|
260
|
+
*/
|
|
157
261
|
intersectsRaw(left, right, top, bottom, tolerance) {
|
|
158
262
|
return intersectsRaw(this, left, right, top, bottom, tolerance);
|
|
159
263
|
}
|
|
160
264
|
|
|
265
|
+
/**
|
|
266
|
+
* TBD.
|
|
267
|
+
* @param {Rectangle} b - TBD.
|
|
268
|
+
* @param {Rectangle} out - TBD.
|
|
269
|
+
* @returns {Rectangle} TBD.
|
|
270
|
+
*/
|
|
161
271
|
union(b, out) {
|
|
162
272
|
return union(this, b, out);
|
|
163
273
|
}
|
|
164
274
|
|
|
275
|
+
/**
|
|
276
|
+
* TBD.
|
|
277
|
+
* @param {Point} output - TBD.
|
|
278
|
+
* @returns {Point} TBD.
|
|
279
|
+
*/
|
|
165
280
|
random(output = null) {
|
|
166
281
|
const result = output || new Point();
|
|
167
282
|
result.x = this.randomX;
|
|
@@ -169,6 +284,12 @@ export class Rectangle {
|
|
|
169
284
|
return result;
|
|
170
285
|
}
|
|
171
286
|
|
|
287
|
+
/**
|
|
288
|
+
* TBD.
|
|
289
|
+
* @param {number} position - TBD.
|
|
290
|
+
* @param {Point} output - TBD.
|
|
291
|
+
* @returns {Point} TBD.
|
|
292
|
+
*/
|
|
172
293
|
getPoint(position, output = null) {
|
|
173
294
|
const result = output || new Point();
|
|
174
295
|
switch (position) {
|
|
@@ -195,6 +316,10 @@ export class Rectangle {
|
|
|
195
316
|
}
|
|
196
317
|
}
|
|
197
318
|
|
|
319
|
+
/**
|
|
320
|
+
* TBD.
|
|
321
|
+
* @returns {string} TBD.
|
|
322
|
+
*/
|
|
198
323
|
toString() {
|
|
199
324
|
return (
|
|
200
325
|
'[{Rectangle (x=' +
|
|
@@ -211,18 +336,33 @@ export class Rectangle {
|
|
|
211
336
|
);
|
|
212
337
|
}
|
|
213
338
|
|
|
339
|
+
/**
|
|
340
|
+
* TBD.
|
|
341
|
+
* @returns {number} TBD.
|
|
342
|
+
*/
|
|
214
343
|
get halfWidth() {
|
|
215
344
|
return Math.round(this.width / 2);
|
|
216
345
|
}
|
|
217
346
|
|
|
347
|
+
/**
|
|
348
|
+
* TBD.
|
|
349
|
+
* @returns {number} TBD.
|
|
350
|
+
*/
|
|
218
351
|
get halfHeight() {
|
|
219
352
|
return Math.round(this.height / 2);
|
|
220
353
|
}
|
|
221
354
|
|
|
355
|
+
/**
|
|
356
|
+
* TBD.
|
|
357
|
+
* @returns {number} TBD.
|
|
358
|
+
*/
|
|
222
359
|
get top() {
|
|
223
360
|
return this.y;
|
|
224
361
|
}
|
|
225
362
|
|
|
363
|
+
/**
|
|
364
|
+
* TBD.
|
|
365
|
+
*/
|
|
226
366
|
set top(value) {
|
|
227
367
|
if (value >= this.bottom) {
|
|
228
368
|
this.height = 0;
|
|
@@ -232,28 +372,49 @@ export class Rectangle {
|
|
|
232
372
|
}
|
|
233
373
|
}
|
|
234
374
|
|
|
375
|
+
/**
|
|
376
|
+
* TBD.
|
|
377
|
+
* @returns {Point} TBD.
|
|
378
|
+
*/
|
|
235
379
|
get topLeft() {
|
|
236
380
|
return new Point(this.x, this.y);
|
|
237
381
|
}
|
|
238
382
|
|
|
383
|
+
/**
|
|
384
|
+
* TBD.
|
|
385
|
+
*/
|
|
239
386
|
set topLeft(value) {
|
|
240
387
|
this.x = value.x;
|
|
241
388
|
this.y = value.y;
|
|
242
389
|
}
|
|
243
390
|
|
|
391
|
+
/**
|
|
392
|
+
* TBD.
|
|
393
|
+
* @returns {Point} TBD.
|
|
394
|
+
*/
|
|
244
395
|
get topRight() {
|
|
245
396
|
return new Point(this.x + this.width, this.y);
|
|
246
397
|
}
|
|
247
398
|
|
|
399
|
+
/**
|
|
400
|
+
* TBD.
|
|
401
|
+
*/
|
|
248
402
|
set topRight(value) {
|
|
249
403
|
this.right = value.x;
|
|
250
404
|
this.y = value.y;
|
|
251
405
|
}
|
|
252
406
|
|
|
407
|
+
/**
|
|
408
|
+
* TBD.
|
|
409
|
+
* @returns {number} TBD.
|
|
410
|
+
*/
|
|
253
411
|
get bottom() {
|
|
254
412
|
return this.y + this.height;
|
|
255
413
|
}
|
|
256
414
|
|
|
415
|
+
/**
|
|
416
|
+
* TBD.
|
|
417
|
+
*/
|
|
257
418
|
set bottom(value) {
|
|
258
419
|
if (value <= this.y) {
|
|
259
420
|
this.height = 0;
|
|
@@ -262,28 +423,49 @@ export class Rectangle {
|
|
|
262
423
|
}
|
|
263
424
|
}
|
|
264
425
|
|
|
426
|
+
/**
|
|
427
|
+
* TBD.
|
|
428
|
+
* @returns {Point} TBD.
|
|
429
|
+
*/
|
|
265
430
|
get bottomLeft() {
|
|
266
431
|
return new Point(this.x, this.bottom);
|
|
267
432
|
}
|
|
268
433
|
|
|
434
|
+
/**
|
|
435
|
+
* TBD.
|
|
436
|
+
*/
|
|
269
437
|
set bottomLeft(value) {
|
|
270
438
|
this.x = value.x;
|
|
271
439
|
this.bottom = value.y;
|
|
272
440
|
}
|
|
273
441
|
|
|
442
|
+
/**
|
|
443
|
+
* TBD.
|
|
444
|
+
* @returns {Point} TBD.
|
|
445
|
+
*/
|
|
274
446
|
get bottomRight() {
|
|
275
447
|
return new Point(this.right, this.bottom);
|
|
276
448
|
}
|
|
277
449
|
|
|
450
|
+
/**
|
|
451
|
+
* TBD.
|
|
452
|
+
*/
|
|
278
453
|
set bottomRight(value) {
|
|
279
454
|
this.right = value.x;
|
|
280
455
|
this.bottom = value.y;
|
|
281
456
|
}
|
|
282
457
|
|
|
458
|
+
/**
|
|
459
|
+
* TBD.
|
|
460
|
+
* @returns {number} TBD.
|
|
461
|
+
*/
|
|
283
462
|
get left() {
|
|
284
463
|
return this.x;
|
|
285
464
|
}
|
|
286
465
|
|
|
466
|
+
/**
|
|
467
|
+
* TBD.
|
|
468
|
+
*/
|
|
287
469
|
set left(value) {
|
|
288
470
|
if (value >= this.right) {
|
|
289
471
|
this.width = 0;
|
|
@@ -293,10 +475,17 @@ export class Rectangle {
|
|
|
293
475
|
this.x = value;
|
|
294
476
|
}
|
|
295
477
|
|
|
478
|
+
/**
|
|
479
|
+
* TBD.
|
|
480
|
+
* @returns {number} TBD.
|
|
481
|
+
*/
|
|
296
482
|
get right() {
|
|
297
483
|
return this.x + this.width;
|
|
298
484
|
}
|
|
299
485
|
|
|
486
|
+
/**
|
|
487
|
+
* TBD.
|
|
488
|
+
*/
|
|
300
489
|
set right(value) {
|
|
301
490
|
if (value <= this.x) {
|
|
302
491
|
this.width = 0;
|
|
@@ -305,42 +494,79 @@ export class Rectangle {
|
|
|
305
494
|
}
|
|
306
495
|
}
|
|
307
496
|
|
|
497
|
+
/**
|
|
498
|
+
* TBD.
|
|
499
|
+
* @returns {number} TBD.
|
|
500
|
+
*/
|
|
308
501
|
get volume() {
|
|
309
502
|
return this.width * this.height;
|
|
310
503
|
}
|
|
311
504
|
|
|
505
|
+
/**
|
|
506
|
+
* TBD.
|
|
507
|
+
* @returns {number} TBD.
|
|
508
|
+
*/
|
|
312
509
|
get perimeter() {
|
|
313
510
|
return this.width * 2 + this.height * 2;
|
|
314
511
|
}
|
|
315
512
|
|
|
513
|
+
/**
|
|
514
|
+
* TBD.
|
|
515
|
+
* @returns {number} TBD.
|
|
516
|
+
*/
|
|
316
517
|
get centerX() {
|
|
317
518
|
return this.x + this.halfWidth;
|
|
318
519
|
}
|
|
319
520
|
|
|
521
|
+
/**
|
|
522
|
+
* TBD.
|
|
523
|
+
*/
|
|
320
524
|
set centerX(value) {
|
|
321
525
|
this.x = value - this.halfWidth;
|
|
322
526
|
}
|
|
323
527
|
|
|
528
|
+
/**
|
|
529
|
+
* TBD.
|
|
530
|
+
* @returns {number} TBD.
|
|
531
|
+
*/
|
|
324
532
|
get centerY() {
|
|
325
533
|
return this.y + this.halfHeight;
|
|
326
534
|
}
|
|
327
535
|
|
|
536
|
+
/**
|
|
537
|
+
* TBD.
|
|
538
|
+
*/
|
|
328
539
|
set centerY(value) {
|
|
329
540
|
this.y = value - this.halfHeight;
|
|
330
541
|
}
|
|
331
542
|
|
|
543
|
+
/**
|
|
544
|
+
* TBD.
|
|
545
|
+
* @returns {number} TBD.
|
|
546
|
+
*/
|
|
332
547
|
get randomX() {
|
|
333
548
|
return this.x + Math.random() * this.width;
|
|
334
549
|
}
|
|
335
550
|
|
|
551
|
+
/**
|
|
552
|
+
* TBD.
|
|
553
|
+
* @returns {number} TBD.
|
|
554
|
+
*/
|
|
336
555
|
get randomY() {
|
|
337
556
|
return this.y + Math.random() * this.height;
|
|
338
557
|
}
|
|
339
558
|
|
|
559
|
+
/**
|
|
560
|
+
* TBD.
|
|
561
|
+
* @returns {boolean} TBD.
|
|
562
|
+
*/
|
|
340
563
|
get empty() {
|
|
341
564
|
return !this.width || !this.height;
|
|
342
565
|
}
|
|
343
566
|
|
|
567
|
+
/**
|
|
568
|
+
* TBD.
|
|
569
|
+
*/
|
|
344
570
|
set empty(value) {
|
|
345
571
|
if (value === true) {
|
|
346
572
|
this.setTo(0, 0, 0, 0);
|
|
@@ -1,16 +1,9 @@
|
|
|
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)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
1
|
import { clone } from './util/rounded_rectangle';
|
|
8
2
|
import { GEOM_ROUNDED_RECTANGLE } from '../core/const';
|
|
9
3
|
|
|
10
4
|
export class RoundedRectangle {
|
|
11
5
|
/**
|
|
12
6
|
* TBD.
|
|
13
|
-
*
|
|
14
7
|
* @param {number} x - TBD.
|
|
15
8
|
* @param {number} y - TBD.
|
|
16
9
|
* @param {number} width - TBD.
|
|
@@ -26,6 +19,12 @@ export class RoundedRectangle {
|
|
|
26
19
|
this.type = GEOM_ROUNDED_RECTANGLE;
|
|
27
20
|
}
|
|
28
21
|
|
|
22
|
+
/**
|
|
23
|
+
* TBD.
|
|
24
|
+
* @param {number} x - TBD.
|
|
25
|
+
* @param {number} y - TBD.
|
|
26
|
+
* @returns {boolean} TBD.
|
|
27
|
+
*/
|
|
29
28
|
contains(x, y) {
|
|
30
29
|
if (this.width <= 0 || this.height <= 0) {
|
|
31
30
|
return false;
|
|
@@ -38,6 +37,10 @@ export class RoundedRectangle {
|
|
|
38
37
|
return false;
|
|
39
38
|
}
|
|
40
39
|
|
|
40
|
+
/**
|
|
41
|
+
* TBD.
|
|
42
|
+
* @returns {RoundedRectangle} TBD.
|
|
43
|
+
*/
|
|
41
44
|
clone() {
|
|
42
45
|
return clone(this);
|
|
43
46
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* @module geom/util/circle
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
|
-
import { Circle } from '../circle';
|
|
1
|
+
import { Circle } from '../circle';
|
|
8
2
|
import { Point } from '../point';
|
|
9
3
|
import { degToRad, distance } from '../../util/math';
|
|
10
4
|
|
|
11
5
|
/**
|
|
12
6
|
* TBD.
|
|
13
|
-
*
|
|
14
7
|
* @param {Circle} input - TBD.
|
|
15
8
|
* @param {Circle} output - TBD.
|
|
16
9
|
* @returns {Circle} TBD.
|
|
@@ -25,7 +18,6 @@ export function clone(input, output = null) {
|
|
|
25
18
|
|
|
26
19
|
/**
|
|
27
20
|
* TBD.
|
|
28
|
-
*
|
|
29
21
|
* @param {Circle} a - TBD.
|
|
30
22
|
* @param {number} x - TBD.
|
|
31
23
|
* @param {number} y - TBD.
|
|
@@ -42,7 +34,6 @@ export function contains(a, x, y) {
|
|
|
42
34
|
|
|
43
35
|
/**
|
|
44
36
|
* TBD.
|
|
45
|
-
*
|
|
46
37
|
* @param {Circle} a - TBD.
|
|
47
38
|
* @param {Circle} b - TBD.
|
|
48
39
|
* @returns {boolean} TBD.
|
|
@@ -53,7 +44,6 @@ export function equals(a, b) {
|
|
|
53
44
|
|
|
54
45
|
/**
|
|
55
46
|
* TBD.
|
|
56
|
-
*
|
|
57
47
|
* @param {Circle} a - TBD.
|
|
58
48
|
* @param {Circle} b - TBD.
|
|
59
49
|
* @returns {boolean} TBD.
|
|
@@ -64,12 +54,11 @@ export function intersects(a, b) {
|
|
|
64
54
|
|
|
65
55
|
/**
|
|
66
56
|
* TBD.
|
|
67
|
-
*
|
|
68
57
|
* @param {Circle} a - TBD.
|
|
69
58
|
* @param {number} angle - TBD.
|
|
70
59
|
* @param {boolean} asDegrees - TBD.
|
|
71
|
-
* @param {
|
|
72
|
-
* @returns {
|
|
60
|
+
* @param {Point} output - TBD.
|
|
61
|
+
* @returns {Point} TBD.
|
|
73
62
|
*/
|
|
74
63
|
export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
75
64
|
const result = output || new Point();
|
|
@@ -83,7 +72,6 @@ export function circumferencePoint(a, angle, asDegrees = false, output = null) {
|
|
|
83
72
|
|
|
84
73
|
/**
|
|
85
74
|
* TBD.
|
|
86
|
-
*
|
|
87
75
|
* @param {Circle} a - TBD.
|
|
88
76
|
* @param {number} angle - TBD.
|
|
89
77
|
* @param {boolean} asDegrees - TBD.
|
|
@@ -102,7 +90,6 @@ export function intersectsPoint(a, angle, asDegrees = false, output = null) {
|
|
|
102
90
|
|
|
103
91
|
/**
|
|
104
92
|
* TBD.
|
|
105
|
-
*
|
|
106
93
|
* @param {Circle} c - TBD.
|
|
107
94
|
* @param {object} r - TBD.
|
|
108
95
|
* @returns {boolean} TBD.
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module geom/util/ellipse
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* TBD.
|
|
10
|
-
*
|
|
11
3
|
* @param {object} a - TBD.
|
|
12
4
|
* @param {number} x - TBD.
|
|
13
5
|
* @param {number} y - TBD.
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module geom/util/line
|
|
3
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
4
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
5
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
6
|
-
*/
|
|
7
1
|
import { Point } from '../point';
|
|
8
|
-
import { Line } from
|
|
2
|
+
import { Line } from '../line';
|
|
9
3
|
import { intersects as intersectsRect } from './rectangle';
|
|
10
4
|
|
|
11
5
|
/**
|
|
12
6
|
* TBD.
|
|
13
|
-
*
|
|
14
7
|
* @param {Line} input - TBD.
|
|
15
8
|
* @param {Line} output - TBD.
|
|
16
9
|
* @returns {Line} TBD.
|
|
@@ -26,14 +19,13 @@ export function clone(input, output = null) {
|
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* TBD.
|
|
29
|
-
*
|
|
30
22
|
* @param {object} a - TBD.
|
|
31
23
|
* @param {object} b - TBD.
|
|
32
24
|
* @param {object} e - TBD.
|
|
33
25
|
* @param {object} f - TBD.
|
|
34
26
|
* @param {boolean} asSegment - TBD.
|
|
35
27
|
* @param {Point} output - TBD.
|
|
36
|
-
* @returns {
|
|
28
|
+
* @returns {Point} TBD.
|
|
37
29
|
*/
|
|
38
30
|
export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
39
31
|
const result = output || new Point();
|
|
@@ -63,12 +55,11 @@ export function intersectsPoints(a, b, e, f, asSegment = true, output = null) {
|
|
|
63
55
|
|
|
64
56
|
/**
|
|
65
57
|
* TBD.
|
|
66
|
-
*
|
|
67
58
|
* @param {object} a - TBD.
|
|
68
59
|
* @param {object} b - TBD.
|
|
69
60
|
* @param {boolean} asSegment - TBD.
|
|
70
|
-
* @param {
|
|
71
|
-
* @returns {
|
|
61
|
+
* @param {Point} result - TBD.
|
|
62
|
+
* @returns {Point} TBD.
|
|
72
63
|
*/
|
|
73
64
|
export function intersects(a, b, asSegment, result) {
|
|
74
65
|
return intersectsPoints(a.start, a.end, b.start, b.end, asSegment, result);
|
|
@@ -76,7 +67,6 @@ export function intersects(a, b, asSegment, result) {
|
|
|
76
67
|
|
|
77
68
|
/**
|
|
78
69
|
* TBD.
|
|
79
|
-
*
|
|
80
70
|
* @param {object} line - TBD.
|
|
81
71
|
* @param {object} rect - TBD.
|
|
82
72
|
* @returns {boolean} TBD.
|
|
@@ -97,10 +87,7 @@ export function intersectsRectangle(line, rect) {
|
|
|
97
87
|
let t = 0;
|
|
98
88
|
// If the start or end of the line is inside the rect then we assume
|
|
99
89
|
// collision, as rects are solid for our use-case.
|
|
100
|
-
if (
|
|
101
|
-
(x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) ||
|
|
102
|
-
(x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)
|
|
103
|
-
) {
|
|
90
|
+
if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) {
|
|
104
91
|
return true;
|
|
105
92
|
}
|
|
106
93
|
if (x1 < bx1 && x2 >= bx1) {
|
|
@@ -134,7 +121,6 @@ export function intersectsRectangle(line, rect) {
|
|
|
134
121
|
|
|
135
122
|
/**
|
|
136
123
|
* TBD.
|
|
137
|
-
*
|
|
138
124
|
* @param {object} a - TBD.
|
|
139
125
|
* @param {object} b - TBD.
|
|
140
126
|
* @returns {number} TBD.
|