@vpmedia/phaser 1.11.0 → 1.12.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/phaser/core/animation.js +9 -6
- package/src/phaser/core/animation_manager.js +14 -4
- package/src/phaser/core/animation_parser.js +24 -3
- package/src/phaser/core/array_set.js +1 -3
- package/src/phaser/core/cache.js +6 -6
- package/src/phaser/core/device.js +0 -2
- package/src/phaser/core/device_util.js +21 -6
- package/src/phaser/core/dom.js +34 -25
- package/src/phaser/core/event_manager.js +45 -17
- package/src/phaser/core/factory.js +26 -4
- package/src/phaser/core/frame.js +0 -2
- package/src/phaser/core/frame_data.js +0 -2
- package/src/phaser/core/game.js +8 -6
- package/src/phaser/core/input.js +17 -9
- package/src/phaser/core/input_handler.js +100 -26
- package/src/phaser/core/input_mouse.js +10 -14
- package/src/phaser/core/input_mspointer.js +10 -9
- package/src/phaser/core/input_pointer.js +58 -17
- package/src/phaser/core/input_touch.js +6 -8
- package/src/phaser/core/loader.js +168 -51
- package/src/phaser/core/loader_parser.js +4 -1
- package/src/phaser/core/raf.js +0 -2
- package/src/phaser/core/scale_manager.js +69 -25
- package/src/phaser/core/scene.js +0 -2
- package/src/phaser/core/scene_manager.js +6 -3
- package/src/phaser/core/signal.js +15 -8
- package/src/phaser/core/signal_binding.js +10 -5
- package/src/phaser/core/sound.js +20 -11
- package/src/phaser/core/sound_manager.js +56 -20
- package/src/phaser/core/sound_sprite.js +32 -32
- package/src/phaser/core/stage.js +0 -3
- package/src/phaser/core/time.js +0 -2
- package/src/phaser/core/timer.js +24 -7
- package/src/phaser/core/timer_event.js +0 -2
- package/src/phaser/core/tween.js +32 -8
- package/src/phaser/core/tween_data.js +15 -7
- package/src/phaser/core/tween_easing.js +24 -20
- package/src/phaser/core/tween_manager.js +31 -13
- package/src/phaser/core/world.js +0 -2
- package/src/phaser/display/bitmap_text.js +8 -9
- package/src/phaser/display/button.js +16 -4
- package/src/phaser/display/canvas/buffer.js +0 -2
- package/src/phaser/display/canvas/graphics.js +21 -9
- package/src/phaser/display/canvas/masker.js +1 -1
- package/src/phaser/display/canvas/renderer.js +39 -19
- package/src/phaser/display/canvas/tinter.js +43 -6
- package/src/phaser/display/canvas/util.js +1 -1
- package/src/phaser/display/display_object.js +33 -19
- package/src/phaser/display/graphics.js +52 -27
- package/src/phaser/display/graphics_data.js +0 -2
- package/src/phaser/display/graphics_data_util.js +9 -1
- package/src/phaser/display/group.js +1 -4
- package/src/phaser/display/image.js +2 -4
- package/src/phaser/display/sprite_batch.js +0 -2
- package/src/phaser/display/sprite_util.js +46 -11
- package/src/phaser/display/text.js +77 -26
- package/src/phaser/display/webgl/abstract_filter.js +0 -2
- package/src/phaser/display/webgl/base_texture.js +5 -3
- package/src/phaser/display/webgl/blend_manager.js +0 -2
- package/src/phaser/display/webgl/earcut.js +63 -22
- package/src/phaser/display/webgl/earcut_node.js +0 -2
- package/src/phaser/display/webgl/fast_sprite_batch.js +47 -46
- package/src/phaser/display/webgl/filter_manager.js +0 -2
- package/src/phaser/display/webgl/filter_texture.js +16 -5
- package/src/phaser/display/webgl/graphics.js +38 -16
- package/src/phaser/display/webgl/graphics_data.js +0 -2
- package/src/phaser/display/webgl/mask_manager.js +10 -2
- package/src/phaser/display/webgl/render_texture.js +14 -5
- package/src/phaser/display/webgl/renderer.js +39 -7
- package/src/phaser/display/webgl/shader/complex.js +0 -2
- package/src/phaser/display/webgl/shader/fast.js +8 -3
- package/src/phaser/display/webgl/shader/normal.js +42 -14
- package/src/phaser/display/webgl/shader/primitive.js +0 -2
- package/src/phaser/display/webgl/shader/strip.js +0 -2
- package/src/phaser/display/webgl/shader_manager.js +0 -2
- package/src/phaser/display/webgl/sprite_batch.js +13 -14
- package/src/phaser/display/webgl/stencil_manager.js +18 -20
- package/src/phaser/display/webgl/texture.js +10 -7
- package/src/phaser/display/webgl/util.js +1 -2
- package/src/phaser/geom/circle.js +15 -7
- package/src/phaser/geom/ellipse.js +13 -6
- package/src/phaser/geom/line.js +19 -10
- package/src/phaser/geom/matrix.js +0 -2
- package/src/phaser/geom/point.js +9 -11
- package/src/phaser/geom/polygon.js +9 -5
- package/src/phaser/geom/rectangle.js +44 -10
- package/src/phaser/geom/rounded_rectangle.js +0 -2
- package/src/phaser/geom/util/circle.js +3 -3
- package/src/phaser/geom/util/ellipse.js +3 -3
- package/src/phaser/geom/util/line.js +16 -13
- package/src/phaser/geom/util/point.js +1 -1
- package/src/phaser/geom/util/rectangle.js +17 -7
- package/src/phaser/util/math.js +37 -23
- package/tsconfig.json +110 -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 +20 -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 +48 -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 +15 -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 +35 -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 +48 -0
- package/types/phaser/display/bitmap_text.d.ts.map +1 -0
- package/types/phaser/display/button.d.ts +33 -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 +18 -0
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -0
- package/types/phaser/display/canvas/masker.d.ts +12 -0
- package/types/phaser/display/canvas/masker.d.ts.map +1 -0
- package/types/phaser/display/canvas/pool.d.ts +45 -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 +36 -0
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -0
- package/types/phaser/display/canvas/util.d.ts +70 -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 +53 -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 +7 -0
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -0
- package/types/phaser/display/group.d.ts +41 -0
- package/types/phaser/display/group.d.ts.map +1 -0
- package/types/phaser/display/image.d.ts +43 -0
- package/types/phaser/display/image.d.ts.map +1 -0
- package/types/phaser/display/sprite_batch.d.ts +6 -0
- package/types/phaser/display/sprite_batch.d.ts.map +1 -0
- package/types/phaser/display/sprite_util.d.ts +35 -0
- package/types/phaser/display/sprite_util.d.ts.map +1 -0
- package/types/phaser/display/text.d.ts +116 -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 +13 -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 +15 -0
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -0
- package/types/phaser/display/webgl/util.d.ts +41 -0
- package/types/phaser/display/webgl/util.d.ts.map +1 -0
- package/types/phaser/geom/circle.d.ts +39 -0
- package/types/phaser/geom/circle.d.ts.map +1 -0
- package/types/phaser/geom/ellipse.d.ts +18 -0
- package/types/phaser/geom/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/line.d.ts +37 -0
- package/types/phaser/geom/line.d.ts.map +1 -0
- package/types/phaser/geom/matrix.d.ts +25 -0
- package/types/phaser/geom/matrix.d.ts.map +1 -0
- package/types/phaser/geom/point.d.ts +37 -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 +63 -0
- package/types/phaser/geom/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/rounded_rectangle.d.ts +12 -0
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/circle.d.ts +55 -0
- package/types/phaser/geom/util/circle.d.ts.map +1 -0
- package/types/phaser/geom/util/ellipse.d.ts +21 -0
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -0
- package/types/phaser/geom/util/line.d.ts +42 -0
- package/types/phaser/geom/util/line.d.ts.map +1 -0
- package/types/phaser/geom/util/matrix.d.ts +20 -0
- package/types/phaser/geom/util/matrix.d.ts.map +1 -0
- package/types/phaser/geom/util/point.d.ts +157 -0
- package/types/phaser/geom/util/point.d.ts.map +1 -0
- package/types/phaser/geom/util/polygon.d.ts +15 -0
- package/types/phaser/geom/util/polygon.d.ts.map +1 -0
- package/types/phaser/geom/util/rectangle.d.ts +124 -0
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts +15 -0
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -0
- package/types/phaser/util/math.d.ts +162 -0
- package/types/phaser/util/math.d.ts.map +1 -0
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import { hex2rgb } from '../../util/math';
|
|
8
8
|
|
|
9
9
|
export default class {
|
|
10
|
-
|
|
11
10
|
constructor() {
|
|
12
11
|
this.stencilStack = [];
|
|
13
12
|
this.reverse = true;
|
|
@@ -35,39 +34,39 @@ export default class {
|
|
|
35
34
|
this.stencilStack.push(webGLData);
|
|
36
35
|
const level = this.count;
|
|
37
36
|
gl.colorMask(false, false, false, false);
|
|
38
|
-
gl.stencilFunc(gl.ALWAYS, 0,
|
|
37
|
+
gl.stencilFunc(gl.ALWAYS, 0, 0xff);
|
|
39
38
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);
|
|
40
39
|
// draw the triangle strip!
|
|
41
40
|
if (webGLData.mode === 1) {
|
|
42
41
|
gl.drawElements(gl.TRIANGLE_FAN, webGLData.indices.length - 4, gl.UNSIGNED_SHORT, 0);
|
|
43
42
|
if (this.reverse) {
|
|
44
|
-
gl.stencilFunc(gl.EQUAL,
|
|
43
|
+
gl.stencilFunc(gl.EQUAL, 0xff - level, 0xff);
|
|
45
44
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
|
|
46
45
|
} else {
|
|
47
|
-
gl.stencilFunc(gl.EQUAL, level,
|
|
46
|
+
gl.stencilFunc(gl.EQUAL, level, 0xff);
|
|
48
47
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
|
|
49
48
|
}
|
|
50
49
|
// draw a quad to increment..
|
|
51
50
|
gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, (webGLData.indices.length - 4) * 2);
|
|
52
51
|
if (this.reverse) {
|
|
53
|
-
gl.stencilFunc(gl.EQUAL,
|
|
52
|
+
gl.stencilFunc(gl.EQUAL, 0xff - (level + 1), 0xff);
|
|
54
53
|
} else {
|
|
55
|
-
gl.stencilFunc(gl.EQUAL, level + 1,
|
|
54
|
+
gl.stencilFunc(gl.EQUAL, level + 1, 0xff);
|
|
56
55
|
}
|
|
57
56
|
this.reverse = !this.reverse;
|
|
58
57
|
} else {
|
|
59
58
|
if (!this.reverse) {
|
|
60
|
-
gl.stencilFunc(gl.EQUAL,
|
|
59
|
+
gl.stencilFunc(gl.EQUAL, 0xff - level, 0xff);
|
|
61
60
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
|
|
62
61
|
} else {
|
|
63
|
-
gl.stencilFunc(gl.EQUAL, level,
|
|
62
|
+
gl.stencilFunc(gl.EQUAL, level, 0xff);
|
|
64
63
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
|
|
65
64
|
}
|
|
66
65
|
gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0);
|
|
67
66
|
if (!this.reverse) {
|
|
68
|
-
gl.stencilFunc(gl.EQUAL,
|
|
67
|
+
gl.stencilFunc(gl.EQUAL, 0xff - (level + 1), 0xff);
|
|
69
68
|
} else {
|
|
70
|
-
gl.stencilFunc(gl.EQUAL, level + 1,
|
|
69
|
+
gl.stencilFunc(gl.EQUAL, level + 1, 0xff);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
gl.colorMask(true, true, true, true);
|
|
@@ -130,41 +129,40 @@ export default class {
|
|
|
130
129
|
if (webGLData.mode === 1) {
|
|
131
130
|
this.reverse = !this.reverse;
|
|
132
131
|
if (this.reverse) {
|
|
133
|
-
gl.stencilFunc(gl.EQUAL,
|
|
132
|
+
gl.stencilFunc(gl.EQUAL, 0xff - (level + 1), 0xff);
|
|
134
133
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
|
|
135
134
|
} else {
|
|
136
|
-
gl.stencilFunc(gl.EQUAL, level + 1,
|
|
135
|
+
gl.stencilFunc(gl.EQUAL, level + 1, 0xff);
|
|
137
136
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
|
|
138
137
|
}
|
|
139
138
|
// draw a quad to increment..
|
|
140
139
|
gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, (webGLData.indices.length - 4) * 2);
|
|
141
|
-
gl.stencilFunc(gl.ALWAYS, 0,
|
|
140
|
+
gl.stencilFunc(gl.ALWAYS, 0, 0xff);
|
|
142
141
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INVERT);
|
|
143
142
|
// draw the triangle strip!
|
|
144
143
|
gl.drawElements(gl.TRIANGLE_FAN, webGLData.indices.length - 4, gl.UNSIGNED_SHORT, 0);
|
|
145
144
|
if (!this.reverse) {
|
|
146
|
-
gl.stencilFunc(gl.EQUAL,
|
|
145
|
+
gl.stencilFunc(gl.EQUAL, 0xff - level, 0xff);
|
|
147
146
|
} else {
|
|
148
|
-
gl.stencilFunc(gl.EQUAL, level,
|
|
147
|
+
gl.stencilFunc(gl.EQUAL, level, 0xff);
|
|
149
148
|
}
|
|
150
149
|
} else {
|
|
151
150
|
if (!this.reverse) {
|
|
152
|
-
gl.stencilFunc(gl.EQUAL,
|
|
151
|
+
gl.stencilFunc(gl.EQUAL, 0xff - (level + 1), 0xff);
|
|
153
152
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
|
|
154
153
|
} else {
|
|
155
|
-
gl.stencilFunc(gl.EQUAL, level + 1,
|
|
154
|
+
gl.stencilFunc(gl.EQUAL, level + 1, 0xff);
|
|
156
155
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.DECR);
|
|
157
156
|
}
|
|
158
157
|
gl.drawElements(gl.TRIANGLE_STRIP, webGLData.indices.length, gl.UNSIGNED_SHORT, 0);
|
|
159
158
|
if (!this.reverse) {
|
|
160
|
-
gl.stencilFunc(gl.EQUAL,
|
|
159
|
+
gl.stencilFunc(gl.EQUAL, 0xff - level, 0xff);
|
|
161
160
|
} else {
|
|
162
|
-
gl.stencilFunc(gl.EQUAL, level,
|
|
161
|
+
gl.stencilFunc(gl.EQUAL, level, 0xff);
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
gl.colorMask(true, true, true, true);
|
|
166
165
|
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
|
-
|
|
170
168
|
}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import Rectangle from '../../geom/rectangle';
|
|
8
8
|
|
|
9
9
|
export class TextureUvs {
|
|
10
|
-
|
|
11
10
|
constructor() {
|
|
12
11
|
this.x0 = 0;
|
|
13
12
|
this.y0 = 0;
|
|
@@ -18,11 +17,9 @@ export class TextureUvs {
|
|
|
18
17
|
this.x3 = 0;
|
|
19
18
|
this.y3 = 0;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export default class {
|
|
25
|
-
|
|
26
23
|
constructor(baseTexture, frame, crop, trim) {
|
|
27
24
|
this.noFrame = false;
|
|
28
25
|
if (!frame) {
|
|
@@ -74,18 +71,25 @@ export default class {
|
|
|
74
71
|
this.crop.y = frame.y;
|
|
75
72
|
this.crop.width = frame.width;
|
|
76
73
|
this.crop.height = frame.height;
|
|
77
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
!this.trim &&
|
|
76
|
+
(frame.x + frame.width > this.baseTexture.width ||
|
|
77
|
+
frame.y + frame.height > this.baseTexture.height)
|
|
78
|
+
) {
|
|
78
79
|
// If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect.
|
|
79
80
|
// Instead `Texture.valid` will be set to `false` (#1556)
|
|
80
81
|
// TODO: make this configurable
|
|
81
82
|
const isTextureSilentFail = true;
|
|
82
83
|
if (!isTextureSilentFail) {
|
|
83
|
-
throw new Error(
|
|
84
|
+
throw new Error(
|
|
85
|
+
'Texture Error: frame does not fit inside the base Texture dimensions ' + this
|
|
86
|
+
);
|
|
84
87
|
}
|
|
85
88
|
this.valid = false;
|
|
86
89
|
return;
|
|
87
90
|
}
|
|
88
|
-
this.valid =
|
|
91
|
+
this.valid =
|
|
92
|
+
frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
|
|
89
93
|
if (this.trim) {
|
|
90
94
|
this.width = this.trim.width;
|
|
91
95
|
this.height = this.trim.height;
|
|
@@ -113,5 +117,4 @@ export default class {
|
|
|
113
117
|
this._uvs.x3 = frame.x / tw;
|
|
114
118
|
this._uvs.y3 = (frame.y + frame.height) / th;
|
|
115
119
|
}
|
|
116
|
-
|
|
117
120
|
}
|
|
@@ -10,7 +10,6 @@ import { clone, contains, circumferencePoint } from './util/circle';
|
|
|
10
10
|
import { GEOM_CIRCLE } from '../core/const';
|
|
11
11
|
|
|
12
12
|
export default class {
|
|
13
|
-
|
|
14
13
|
constructor(x = 0, y = 0, diameter = 0) {
|
|
15
14
|
this.x = x;
|
|
16
15
|
this.y = y;
|
|
@@ -30,11 +29,11 @@ export default class {
|
|
|
30
29
|
const result = output || new Point();
|
|
31
30
|
const t = 2 * Math.PI * Math.random();
|
|
32
31
|
const u = Math.random() + Math.random();
|
|
33
|
-
const r =
|
|
32
|
+
const r = u > 1 ? 2 - u : u;
|
|
34
33
|
const x = r * Math.cos(t);
|
|
35
34
|
const y = r * Math.sin(t);
|
|
36
|
-
result.x = this.x +
|
|
37
|
-
result.y = this.y +
|
|
35
|
+
result.x = this.x + x * this.radius;
|
|
36
|
+
result.y = this.y + y * this.radius;
|
|
38
37
|
return result;
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -89,7 +88,17 @@ export default class {
|
|
|
89
88
|
}
|
|
90
89
|
|
|
91
90
|
toString() {
|
|
92
|
-
return
|
|
91
|
+
return (
|
|
92
|
+
'[{Circle (x=' +
|
|
93
|
+
this.x +
|
|
94
|
+
' y=' +
|
|
95
|
+
this.y +
|
|
96
|
+
' diameter=' +
|
|
97
|
+
this.diameter +
|
|
98
|
+
' radius=' +
|
|
99
|
+
this.radius +
|
|
100
|
+
')}]'
|
|
101
|
+
);
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
get diameter() {
|
|
@@ -174,7 +183,7 @@ export default class {
|
|
|
174
183
|
}
|
|
175
184
|
|
|
176
185
|
get empty() {
|
|
177
|
-
return
|
|
186
|
+
return this._diameter === 0;
|
|
178
187
|
}
|
|
179
188
|
|
|
180
189
|
set empty(value) {
|
|
@@ -182,5 +191,4 @@ export default class {
|
|
|
182
191
|
this.setTo(0, 0, 0);
|
|
183
192
|
}
|
|
184
193
|
}
|
|
185
|
-
|
|
186
194
|
}
|
|
@@ -9,7 +9,6 @@ import { contains } from './util/ellipse';
|
|
|
9
9
|
import { GEOM_ELLIPSE } from '../core/const';
|
|
10
10
|
|
|
11
11
|
export default class {
|
|
12
|
-
|
|
13
12
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
14
13
|
this.x = x;
|
|
15
14
|
this.y = y;
|
|
@@ -52,14 +51,22 @@ export default class {
|
|
|
52
51
|
const r = Math.random();
|
|
53
52
|
result.x = Math.sqrt(r) * Math.cos(p);
|
|
54
53
|
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
|
|
54
|
+
result.x = this.x + (result.x * this.width) / 2.0;
|
|
55
|
+
result.y = this.y + (result.y * this.height) / 2.0;
|
|
57
56
|
return result;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
toString() {
|
|
61
|
-
return
|
|
60
|
+
return (
|
|
61
|
+
'[{Ellipse (x=' +
|
|
62
|
+
this.x +
|
|
63
|
+
' y=' +
|
|
64
|
+
this.y +
|
|
65
|
+
' width=' +
|
|
66
|
+
this.width +
|
|
67
|
+
' height=' +
|
|
68
|
+
this.height +
|
|
69
|
+
')}]'
|
|
70
|
+
);
|
|
62
71
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
72
|
}
|
package/src/phaser/geom/line.js
CHANGED
|
@@ -9,7 +9,6 @@ import { wrap } from '../util/math';
|
|
|
9
9
|
import { GEOM_LINE } from '../core/const';
|
|
10
10
|
|
|
11
11
|
export default class {
|
|
12
|
-
|
|
13
12
|
constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
|
|
14
13
|
this.start = new Point(x1, y1);
|
|
15
14
|
this.end = new Point(x2, y2);
|
|
@@ -24,14 +23,19 @@ export default class {
|
|
|
24
23
|
|
|
25
24
|
fromSprite(startSprite, endSprite, useCenter = false) {
|
|
26
25
|
if (useCenter) {
|
|
27
|
-
return this.setTo(
|
|
26
|
+
return this.setTo(
|
|
27
|
+
startSprite.center.x,
|
|
28
|
+
startSprite.center.y,
|
|
29
|
+
endSprite.center.x,
|
|
30
|
+
endSprite.center.y
|
|
31
|
+
);
|
|
28
32
|
}
|
|
29
33
|
return this.setTo(startSprite.x, startSprite.y, endSprite.x, endSprite.y);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
fromAngle(x, y, angle, length) {
|
|
33
37
|
this.start.setTo(x, y);
|
|
34
|
-
this.end.setTo(x +
|
|
38
|
+
this.end.setTo(x + Math.cos(angle) * length, y + Math.sin(angle) * length);
|
|
35
39
|
return this;
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -74,7 +78,10 @@ export default class {
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
pointOnLine(x, y) {
|
|
77
|
-
return (
|
|
81
|
+
return (
|
|
82
|
+
(x - this.start.x) * (this.end.y - this.start.y) ===
|
|
83
|
+
(this.end.x - this.start.x) * (y - this.start.y)
|
|
84
|
+
);
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
pointOnSegment(x, y) {
|
|
@@ -82,7 +89,7 @@ export default class {
|
|
|
82
89
|
const xMax = Math.max(this.start.x, this.end.x);
|
|
83
90
|
const yMin = Math.min(this.start.y, this.end.y);
|
|
84
91
|
const yMax = Math.max(this.start.y, this.end.y);
|
|
85
|
-
return
|
|
92
|
+
return this.pointOnLine(x, y) && x >= xMin && x <= xMax && y >= yMin && y <= yMax;
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
random(output = null) {
|
|
@@ -100,12 +107,12 @@ export default class {
|
|
|
100
107
|
const y2 = Math.round(this.end.y);
|
|
101
108
|
const dx = Math.abs(x2 - x1);
|
|
102
109
|
const dy = Math.abs(y2 - y1);
|
|
103
|
-
const sx =
|
|
104
|
-
const sy =
|
|
110
|
+
const sx = x1 < x2 ? 1 : -1;
|
|
111
|
+
const sy = y1 < y2 ? 1 : -1;
|
|
105
112
|
let err = dx - dy;
|
|
106
113
|
results.push([x1, y1]);
|
|
107
114
|
let i = 1;
|
|
108
|
-
while (!(
|
|
115
|
+
while (!(x1 === x2 && y1 === y2)) {
|
|
109
116
|
const e2 = err << 1;
|
|
110
117
|
if (e2 > -dy) {
|
|
111
118
|
err -= dy;
|
|
@@ -128,7 +135,10 @@ export default class {
|
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
get length() {
|
|
131
|
-
return Math.sqrt(
|
|
138
|
+
return Math.sqrt(
|
|
139
|
+
(this.end.x - this.start.x) * (this.end.x - this.start.x) +
|
|
140
|
+
(this.end.y - this.start.y) * (this.end.y - this.start.y)
|
|
141
|
+
);
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
get angle() {
|
|
@@ -186,5 +196,4 @@ export default class {
|
|
|
186
196
|
get normalAngle() {
|
|
187
197
|
return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
|
|
188
198
|
}
|
|
189
|
-
|
|
190
199
|
}
|
|
@@ -8,7 +8,6 @@ import { clone } from './util/matrix';
|
|
|
8
8
|
import { GEOM_MATRIX } from '../core/const';
|
|
9
9
|
|
|
10
10
|
export default class {
|
|
11
|
-
|
|
12
11
|
constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
|
|
13
12
|
this.a = a;
|
|
14
13
|
this.b = b;
|
|
@@ -143,5 +142,4 @@ export default class {
|
|
|
143
142
|
identity() {
|
|
144
143
|
return this.setTo(1, 0, 0, 1, 0, 0);
|
|
145
144
|
}
|
|
146
|
-
|
|
147
145
|
}
|
package/src/phaser/geom/point.js
CHANGED
|
@@ -7,7 +7,6 @@ import { distance, rotate, clone } from './util/point';
|
|
|
7
7
|
import { GEOM_POINT } from '../core/const';
|
|
8
8
|
|
|
9
9
|
export default class {
|
|
10
|
-
|
|
11
10
|
constructor(x = 0, y = 0) {
|
|
12
11
|
this.x = x;
|
|
13
12
|
this.y = y;
|
|
@@ -24,14 +23,14 @@ export default class {
|
|
|
24
23
|
|
|
25
24
|
setTo(x, y) {
|
|
26
25
|
this.x = x || 0;
|
|
27
|
-
this.y = y || (
|
|
26
|
+
this.y = y || (y !== 0 ? this.x : 0);
|
|
28
27
|
return this;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
set(x, y) {
|
|
32
31
|
// deprecated, use setTo(x, y)
|
|
33
32
|
this.x = x || 0;
|
|
34
|
-
this.y = y || (
|
|
33
|
+
this.y = y || (y !== 0 ? this.x : 0);
|
|
35
34
|
return this;
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -90,12 +89,12 @@ export default class {
|
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
equals(a) {
|
|
93
|
-
return
|
|
92
|
+
return a.x === this.x && a.y === this.y;
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
angle(a, asDegrees = false) {
|
|
97
96
|
if (asDegrees) {
|
|
98
|
-
return (180 / Math.PI) *
|
|
97
|
+
return (180 / Math.PI) * Math.atan2(a.y - this.y, a.x - this.x);
|
|
99
98
|
}
|
|
100
99
|
return Math.atan2(a.y - this.y, a.x - this.x);
|
|
101
100
|
}
|
|
@@ -105,11 +104,11 @@ export default class {
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
getMagnitude() {
|
|
108
|
-
return Math.sqrt(
|
|
107
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
109
108
|
}
|
|
110
109
|
|
|
111
110
|
getMagnitudeSq() {
|
|
112
|
-
return
|
|
111
|
+
return this.x * this.x + this.y * this.y;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
setMagnitude(magnitude) {
|
|
@@ -126,15 +125,15 @@ export default class {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
isZero() {
|
|
129
|
-
return
|
|
128
|
+
return this.x === 0 && this.y === 0;
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
dot(a) {
|
|
133
|
-
return
|
|
132
|
+
return this.x * a.x + this.y * a.y;
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
cross(a) {
|
|
137
|
-
return
|
|
136
|
+
return this.x * a.y - this.y * a.x;
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
perp() {
|
|
@@ -160,5 +159,4 @@ export default class {
|
|
|
160
159
|
toString() {
|
|
161
160
|
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
|
|
162
161
|
}
|
|
163
|
-
|
|
164
162
|
}
|
|
@@ -8,7 +8,6 @@ import { clone } from './util/polygon';
|
|
|
8
8
|
import { GEOM_POLYGON } from '../core/const';
|
|
9
9
|
|
|
10
10
|
export default class {
|
|
11
|
-
|
|
12
11
|
constructor(points = null) {
|
|
13
12
|
this.area = 0;
|
|
14
13
|
this._points = [];
|
|
@@ -53,7 +52,10 @@ export default class {
|
|
|
53
52
|
const iy = this._points[i + 1];
|
|
54
53
|
const jx = this._points[j];
|
|
55
54
|
const jy = this._points[j + 1];
|
|
56
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
((iy <= y && y < jy) || (jy <= y && y < iy)) &&
|
|
57
|
+
x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
|
|
58
|
+
) {
|
|
57
59
|
inside = !inside;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
@@ -63,7 +65,10 @@ export default class {
|
|
|
63
65
|
const iy = this._points[i].y;
|
|
64
66
|
const jx = this._points[j].x;
|
|
65
67
|
const jy = this._points[j].y;
|
|
66
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
((iy <= y && y < jy) || (jy <= y && y < iy)) &&
|
|
70
|
+
x < ((jx - ix) * (y - iy)) / (jy - iy) + ix
|
|
71
|
+
) {
|
|
67
72
|
inside = !inside;
|
|
68
73
|
}
|
|
69
74
|
}
|
|
@@ -117,7 +122,7 @@ export default class {
|
|
|
117
122
|
} else {
|
|
118
123
|
p2 = this._points[i + 1];
|
|
119
124
|
}
|
|
120
|
-
avgHeight = (
|
|
125
|
+
avgHeight = (p1.y - y0 + (p2.y - y0)) / 2;
|
|
121
126
|
width = p1.x - p2.x;
|
|
122
127
|
this.area += avgHeight * width;
|
|
123
128
|
}
|
|
@@ -136,5 +141,4 @@ export default class {
|
|
|
136
141
|
this._points = [];
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
|
-
|
|
140
144
|
}
|
|
@@ -4,11 +4,32 @@
|
|
|
4
4
|
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
5
5
|
*/
|
|
6
6
|
import Point from './point';
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
inflate,
|
|
9
|
+
size,
|
|
10
|
+
clone,
|
|
11
|
+
contains,
|
|
12
|
+
containsRect,
|
|
13
|
+
equals,
|
|
14
|
+
intersects,
|
|
15
|
+
intersection,
|
|
16
|
+
intersectsRaw,
|
|
17
|
+
union,
|
|
18
|
+
} from './util/rectangle';
|
|
19
|
+
import {
|
|
20
|
+
GEOM_RECTANGLE,
|
|
21
|
+
TOP_LEFT,
|
|
22
|
+
TOP_CENTER,
|
|
23
|
+
TOP_RIGHT,
|
|
24
|
+
LEFT_CENTER,
|
|
25
|
+
CENTER,
|
|
26
|
+
RIGHT_CENTER,
|
|
27
|
+
BOTTOM_LEFT,
|
|
28
|
+
BOTTOM_CENTER,
|
|
29
|
+
BOTTOM_RIGHT,
|
|
30
|
+
} from '../core/const';
|
|
9
31
|
|
|
10
32
|
export default class {
|
|
11
|
-
|
|
12
33
|
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
13
34
|
this.x = x;
|
|
14
35
|
this.y = y;
|
|
@@ -36,7 +57,9 @@ export default class {
|
|
|
36
57
|
}
|
|
37
58
|
|
|
38
59
|
scale(x, y) {
|
|
39
|
-
if (y === undefined) {
|
|
60
|
+
if (y === undefined) {
|
|
61
|
+
y = x;
|
|
62
|
+
}
|
|
40
63
|
this.width *= x;
|
|
41
64
|
this.height *= y;
|
|
42
65
|
return this;
|
|
@@ -164,7 +187,19 @@ export default class {
|
|
|
164
187
|
}
|
|
165
188
|
|
|
166
189
|
toString() {
|
|
167
|
-
return
|
|
190
|
+
return (
|
|
191
|
+
'[{Rectangle (x=' +
|
|
192
|
+
this.x +
|
|
193
|
+
' y=' +
|
|
194
|
+
this.y +
|
|
195
|
+
' width=' +
|
|
196
|
+
this.width +
|
|
197
|
+
' height=' +
|
|
198
|
+
this.height +
|
|
199
|
+
' empty=' +
|
|
200
|
+
this.empty +
|
|
201
|
+
')}]'
|
|
202
|
+
);
|
|
168
203
|
}
|
|
169
204
|
|
|
170
205
|
get halfWidth() {
|
|
@@ -184,7 +219,7 @@ export default class {
|
|
|
184
219
|
this.height = 0;
|
|
185
220
|
this.y = value;
|
|
186
221
|
} else {
|
|
187
|
-
this.height =
|
|
222
|
+
this.height = this.bottom - value;
|
|
188
223
|
}
|
|
189
224
|
}
|
|
190
225
|
|
|
@@ -266,7 +301,7 @@ export default class {
|
|
|
266
301
|
}
|
|
267
302
|
|
|
268
303
|
get perimeter() {
|
|
269
|
-
return
|
|
304
|
+
return this.width * 2 + this.height * 2;
|
|
270
305
|
}
|
|
271
306
|
|
|
272
307
|
get centerX() {
|
|
@@ -286,11 +321,11 @@ export default class {
|
|
|
286
321
|
}
|
|
287
322
|
|
|
288
323
|
get randomX() {
|
|
289
|
-
return this.x +
|
|
324
|
+
return this.x + Math.random() * this.width;
|
|
290
325
|
}
|
|
291
326
|
|
|
292
327
|
get randomY() {
|
|
293
|
-
return this.y +
|
|
328
|
+
return this.y + Math.random() * this.height;
|
|
294
329
|
}
|
|
295
330
|
|
|
296
331
|
get empty() {
|
|
@@ -302,5 +337,4 @@ export default class {
|
|
|
302
337
|
this.setTo(0, 0, 0, 0);
|
|
303
338
|
}
|
|
304
339
|
}
|
|
305
|
-
|
|
306
340
|
}
|
|
@@ -7,7 +7,6 @@ import { clone } from './util/rounded_rectangle';
|
|
|
7
7
|
import { GEOM_ROUNDED_RECTANGLE } from '../core/const';
|
|
8
8
|
|
|
9
9
|
export default class {
|
|
10
|
-
|
|
11
10
|
constructor(x = 0, y = 0, width = 0, height = 0, radius = 20) {
|
|
12
11
|
this.x = x;
|
|
13
12
|
this.y = y;
|
|
@@ -32,5 +31,4 @@ export default class {
|
|
|
32
31
|
clone() {
|
|
33
32
|
return clone(this);
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
}
|
|
@@ -32,7 +32,7 @@ export function contains(a, x, y) {
|
|
|
32
32
|
if (a.radius > 0 && x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
|
|
33
33
|
const dx = (a.x - x) * (a.x - x);
|
|
34
34
|
const dy = (a.y - y) * (a.y - y);
|
|
35
|
-
return
|
|
35
|
+
return dx + dy <= a.radius * a.radius;
|
|
36
36
|
}
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
@@ -44,7 +44,7 @@ export function contains(a, x, y) {
|
|
|
44
44
|
* @returns {boolean} TBD
|
|
45
45
|
*/
|
|
46
46
|
export function equals(a, b) {
|
|
47
|
-
return
|
|
47
|
+
return a.x === b.x && a.y === b.y && a.diameter === b.diameter;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
@@ -54,7 +54,7 @@ export function equals(a, b) {
|
|
|
54
54
|
* @returns {boolean} TBD
|
|
55
55
|
*/
|
|
56
56
|
export function intersects(a, b) {
|
|
57
|
-
return distance(a.x, a.y, b.x, b.y) <=
|
|
57
|
+
return distance(a.x, a.y, b.x, b.y) <= a.radius + b.radius;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -26,9 +26,9 @@ export function contains(a, x, y) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
// Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
|
|
29
|
-
let normx = (
|
|
30
|
-
let normy = (
|
|
29
|
+
let normx = (x - a.x) / a.width - 0.5;
|
|
30
|
+
let normy = (y - a.y) / a.height - 0.5;
|
|
31
31
|
normx *= normx;
|
|
32
32
|
normy *= normy;
|
|
33
|
-
return
|
|
33
|
+
return normx + normy < 0.25;
|
|
34
34
|
}
|