@vpmedia/phaser 1.15.0 → 1.17.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 +114 -6
- package/src/phaser/core/animation_manager.js +102 -10
- package/src/phaser/core/animation_parser.js +6 -19
- package/src/phaser/core/array_set.js +59 -5
- package/src/phaser/core/cache.js +307 -6
- package/src/phaser/core/const.js +107 -4
- package/src/phaser/core/device.js +3 -6
- package/src/phaser/core/device_util.js +3 -16
- 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 -12
- package/src/phaser/core/game.js +35 -7
- package/src/phaser/core/input.js +133 -17
- package/src/phaser/core/input_handler.js +243 -43
- package/src/phaser/core/input_mouse.js +70 -5
- package/src/phaser/core/input_mspointer.js +40 -9
- package/src/phaser/core/input_pointer.js +88 -17
- package/src/phaser/core/input_touch.js +42 -5
- package/src/phaser/core/loader.js +303 -101
- package/src/phaser/core/loader_parser.js +2 -10
- 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 -8
- package/src/phaser/core/tween_manager.js +47 -5
- package/src/phaser/core/world.js +9 -6
- package/src/phaser/display/bitmap_text.js +91 -10
- package/src/phaser/display/button.js +63 -12
- package/src/phaser/display/canvas/buffer.js +16 -6
- package/src/phaser/display/canvas/graphics.js +1 -13
- package/src/phaser/display/canvas/masker.js +0 -6
- package/src/phaser/display/canvas/pool.js +0 -7
- package/src/phaser/display/canvas/renderer.js +28 -8
- package/src/phaser/display/canvas/tinter.js +4 -43
- package/src/phaser/display/canvas/util.js +0 -6
- package/src/phaser/display/display_object.js +192 -20
- package/src/phaser/display/graphics.js +161 -26
- package/src/phaser/display/graphics_data.js +14 -6
- package/src/phaser/display/graphics_data_util.js +2 -8
- package/src/phaser/display/group.js +82 -9
- package/src/phaser/display/image.js +87 -9
- package/src/phaser/display/sprite_batch.js +3 -8
- package/src/phaser/display/sprite_util.js +3 -23
- package/src/phaser/display/text.js +331 -31
- 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 -23
- 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 -28
- package/src/phaser/display/webgl/graphics_data.js +10 -7
- package/src/phaser/display/webgl/mask_manager.js +0 -6
- 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 -6
- package/src/phaser/display/webgl/util.js +0 -7
- package/src/phaser/geom/circle.js +123 -18
- package/src/phaser/geom/ellipse.js +39 -18
- package/src/phaser/geom/line.js +148 -16
- package/src/phaser/geom/matrix.js +73 -6
- package/src/phaser/geom/point.js +152 -6
- package/src/phaser/geom/polygon.js +42 -14
- package/src/phaser/geom/rectangle.js +233 -6
- package/src/phaser/geom/rounded_rectangle.js +10 -6
- package/src/phaser/geom/util/circle.js +3 -9
- package/src/phaser/geom/util/ellipse.js +0 -7
- package/src/phaser/geom/util/line.js +5 -14
- package/src/phaser/geom/util/matrix.js +1 -7
- package/src/phaser/geom/util/point.js +0 -6
- package/src/phaser/geom/util/polygon.js +1 -7
- package/src/phaser/geom/util/rectangle.js +1 -7
- package/src/phaser/geom/util/rounded_rectangle.js +1 -7
- package/src/phaser/util/math.js +3 -21
- package/types/index.d.ts +2 -1
- package/types/index.d.ts.map +1 -1
- package/types/phaser/core/animation.d.ts +126 -13
- package/types/phaser/core/animation.d.ts.map +1 -1
- package/types/phaser/core/animation_manager.d.ts +121 -19
- package/types/phaser/core/animation_manager.d.ts.map +1 -1
- package/types/phaser/core/animation_parser.d.ts +6 -5
- package/types/phaser/core/animation_parser.d.ts.map +1 -1
- package/types/phaser/core/array_set.d.ts +67 -13
- package/types/phaser/core/array_set.d.ts.map +1 -1
- package/types/phaser/core/cache.d.ts +365 -69
- 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 +0 -5
- package/types/phaser/core/device.d.ts.map +1 -1
- package/types/phaser/core/device_util.d.ts +1 -1
- package/types/phaser/core/device_util.d.ts.map +1 -1
- package/types/phaser/core/dom.d.ts +119 -0
- package/types/phaser/core/dom.d.ts.map +1 -1
- package/types/phaser/core/event_manager.d.ts +127 -0
- package/types/phaser/core/event_manager.d.ts.map +1 -1
- package/types/phaser/core/factory.d.ts +75 -8
- package/types/phaser/core/factory.d.ts.map +1 -1
- package/types/phaser/core/frame.d.ts +64 -21
- 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 -8
- package/types/phaser/core/frame_util.d.ts.map +1 -1
- package/types/phaser/core/game.d.ts +40 -6
- package/types/phaser/core/game.d.ts.map +1 -1
- package/types/phaser/core/input.d.ts +143 -15
- 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 +62 -14
- package/types/phaser/core/input_mouse.d.ts.map +1 -1
- package/types/phaser/core/input_mspointer.d.ts +51 -17
- package/types/phaser/core/input_mspointer.d.ts.map +1 -1
- package/types/phaser/core/input_pointer.d.ts +99 -14
- package/types/phaser/core/input_pointer.d.ts.map +1 -1
- package/types/phaser/core/input_touch.d.ts +53 -16
- package/types/phaser/core/input_touch.d.ts.map +1 -1
- package/types/phaser/core/loader.d.ts +299 -28
- package/types/phaser/core/loader.d.ts.map +1 -1
- package/types/phaser/core/loader_parser.d.ts.map +1 -1
- package/types/phaser/core/raf.d.ts +19 -9
- package/types/phaser/core/raf.d.ts.map +1 -1
- package/types/phaser/core/scale_manager.d.ts +208 -13
- 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 +93 -9
- package/types/phaser/core/signal.d.ts.map +1 -1
- package/types/phaser/core/signal_binding.d.ts +34 -5
- 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 +97 -11
- 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 +108 -7
- package/types/phaser/core/timer.d.ts.map +1 -1
- package/types/phaser/core/timer_event.d.ts +13 -7
- package/types/phaser/core/timer_event.d.ts.map +1 -1
- package/types/phaser/core/tween.d.ts +124 -4
- package/types/phaser/core/tween.d.ts.map +1 -1
- package/types/phaser/core/tween_data.d.ts +41 -2
- package/types/phaser/core/tween_data.d.ts.map +1 -1
- package/types/phaser/core/tween_easing.d.ts +0 -5
- 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 +84 -7
- package/types/phaser/display/bitmap_text.d.ts.map +1 -1
- package/types/phaser/display/button.d.ts +65 -8
- package/types/phaser/display/button.d.ts.map +1 -1
- package/types/phaser/display/canvas/buffer.d.ts +20 -4
- package/types/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/types/phaser/display/canvas/masker.d.ts.map +1 -1
- package/types/phaser/display/canvas/pool.d.ts +0 -6
- package/types/phaser/display/canvas/pool.d.ts.map +1 -1
- package/types/phaser/display/canvas/renderer.d.ts +29 -2
- package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/types/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/types/phaser/display/canvas/util.d.ts.map +1 -1
- package/types/phaser/display/display_object.d.ts +195 -8
- package/types/phaser/display/display_object.d.ts.map +1 -1
- package/types/phaser/display/graphics.d.ts +132 -6
- 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 -2
- package/types/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/types/phaser/display/group.d.ts +80 -10
- package/types/phaser/display/group.d.ts.map +1 -1
- package/types/phaser/display/image.d.ts +72 -6
- package/types/phaser/display/image.d.ts.map +1 -1
- package/types/phaser/display/sprite_batch.d.ts +4 -3
- package/types/phaser/display/sprite_batch.d.ts.map +1 -1
- package/types/phaser/display/sprite_util.d.ts.map +1 -1
- package/types/phaser/display/text.d.ts +366 -46
- 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.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 +22 -6
- 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.map +1 -1
- package/types/phaser/display/webgl/graphics_data.d.ts +10 -6
- package/types/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/types/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/render_texture.d.ts +30 -3
- package/types/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/renderer.d.ts +41 -4
- package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/complex.d.ts +10 -0
- package/types/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/fast.d.ts +10 -0
- package/types/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/normal.d.ts +20 -0
- package/types/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/primitive.d.ts +10 -0
- package/types/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader/strip.d.ts +10 -0
- package/types/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/types/phaser/display/webgl/shader_manager.d.ts +15 -0
- package/types/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/types/phaser/display/webgl/sprite_batch.d.ts +37 -0
- 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 +21 -0
- package/types/phaser/display/webgl/texture.d.ts.map +1 -1
- package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/types/phaser/display/webgl/util.d.ts +0 -6
- package/types/phaser/display/webgl/util.d.ts.map +1 -1
- package/types/phaser/geom/circle.d.ts +131 -9
- package/types/phaser/geom/circle.d.ts.map +1 -1
- package/types/phaser/geom/ellipse.d.ts +43 -5
- package/types/phaser/geom/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/line.d.ts +159 -13
- package/types/phaser/geom/line.d.ts.map +1 -1
- package/types/phaser/geom/matrix.d.ts +85 -11
- package/types/phaser/geom/matrix.d.ts.map +1 -1
- package/types/phaser/geom/point.d.ts +170 -18
- 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 -20
- package/types/phaser/geom/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/rounded_rectangle.d.ts +11 -1
- package/types/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/circle.d.ts +3 -3
- package/types/phaser/geom/util/circle.d.ts.map +1 -1
- package/types/phaser/geom/util/ellipse.d.ts +0 -6
- package/types/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/types/phaser/geom/util/line.d.ts +5 -5
- package/types/phaser/geom/util/line.d.ts.map +1 -1
- package/types/phaser/geom/util/matrix.d.ts.map +1 -1
- package/types/phaser/geom/util/point.d.ts.map +1 -1
- package/types/phaser/geom/util/polygon.d.ts.map +1 -1
- package/types/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/types/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/types/phaser/util/math.d.ts +0 -5
- package/types/phaser/util/math.d.ts.map +1 -1
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
* @module display/webgl/texture
|
|
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
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
7
|
-
*/
|
|
8
|
-
import { Rectangle } from '../../geom/rectangle';
|
|
1
|
+
import { Rectangle } from '../../geom/rectangle';
|
|
9
2
|
|
|
10
3
|
export class TextureUvs {
|
|
4
|
+
/**
|
|
5
|
+
* TBD.
|
|
6
|
+
*/
|
|
11
7
|
constructor() {
|
|
12
8
|
this.x0 = 0;
|
|
13
9
|
this.y0 = 0;
|
|
@@ -21,6 +17,13 @@ export class TextureUvs {
|
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
export class Texture {
|
|
20
|
+
/**
|
|
21
|
+
* TBD.
|
|
22
|
+
* @param baseTexture - TBD.
|
|
23
|
+
* @param frame - TBD.
|
|
24
|
+
* @param crop - TBD.
|
|
25
|
+
* @param trim - TBD.
|
|
26
|
+
*/
|
|
24
27
|
constructor(baseTexture, frame, crop, trim) {
|
|
25
28
|
this.noFrame = false;
|
|
26
29
|
if (!frame) {
|
|
@@ -49,6 +52,9 @@ export class Texture {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
/**
|
|
56
|
+
* TBD.
|
|
57
|
+
*/
|
|
52
58
|
onBaseTextureLoaded() {
|
|
53
59
|
if (this.noFrame) {
|
|
54
60
|
this.frame = new Rectangle(0, 0, this.baseTexture.width, this.baseTexture.height);
|
|
@@ -56,6 +62,10 @@ export class Texture {
|
|
|
56
62
|
this.setFrame(this.frame);
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/**
|
|
66
|
+
* TBD.
|
|
67
|
+
* @param destroyBase - TBD.
|
|
68
|
+
*/
|
|
59
69
|
destroy(destroyBase = false) {
|
|
60
70
|
if (destroyBase) {
|
|
61
71
|
this.baseTexture.destroy();
|
|
@@ -63,6 +73,10 @@ export class Texture {
|
|
|
63
73
|
this.valid = false;
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
/**
|
|
77
|
+
* TBD.
|
|
78
|
+
* @param frame - TBD.
|
|
79
|
+
*/
|
|
66
80
|
setFrame(frame) {
|
|
67
81
|
this.noFrame = false;
|
|
68
82
|
this.frame = frame;
|
|
@@ -74,23 +88,19 @@ export class Texture {
|
|
|
74
88
|
this.crop.height = frame.height;
|
|
75
89
|
if (
|
|
76
90
|
!this.trim &&
|
|
77
|
-
(frame.x + frame.width > this.baseTexture.width ||
|
|
78
|
-
frame.y + frame.height > this.baseTexture.height)
|
|
91
|
+
(frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height)
|
|
79
92
|
) {
|
|
80
93
|
// If `true` then `PIXI.Texture.setFrame` will no longer throw an error if the texture dimensions are incorrect.
|
|
81
94
|
// Instead `Texture.valid` will be set to `false` (#1556)
|
|
82
95
|
// TODO: make this configurable
|
|
83
96
|
const isTextureSilentFail = true;
|
|
84
97
|
if (!isTextureSilentFail) {
|
|
85
|
-
throw new Error(
|
|
86
|
-
'Texture Error: frame does not fit inside the base Texture dimensions ' + this
|
|
87
|
-
);
|
|
98
|
+
throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this);
|
|
88
99
|
}
|
|
89
100
|
this.valid = false;
|
|
90
101
|
return;
|
|
91
102
|
}
|
|
92
|
-
this.valid =
|
|
93
|
-
frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
|
|
103
|
+
this.valid = frame && frame.width && frame.height && this.baseTexture.source && this.baseTexture.hasLoaded;
|
|
94
104
|
if (this.trim) {
|
|
95
105
|
this.width = this.trim.width;
|
|
96
106
|
this.height = this.trim.height;
|
|
@@ -102,6 +112,9 @@ export class Texture {
|
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
|
|
115
|
+
/**
|
|
116
|
+
* TBD.
|
|
117
|
+
*/
|
|
105
118
|
_updateUvs() {
|
|
106
119
|
if (!this._uvs) {
|
|
107
120
|
this._uvs = new TextureUvs();
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
1
|
import { BaseTexture } from './base_texture';
|
|
8
2
|
import { Texture } from './texture';
|
|
9
3
|
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2018-present Richard Davey, Photon Storm Ltd., Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)
|
|
3
|
-
* @author Andras Csizmadia <andras@vpmedia.hu>
|
|
4
|
-
* @author Richard Davey <rich@photonstorm.com>
|
|
5
|
-
* @author Mat Groves http://matgroves.com/ @Doormat23
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
/**
|
|
9
2
|
* TBD.
|
|
10
3
|
*/
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module geom/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
1
|
import { Point } from './point';
|
|
8
|
-
import { Rectangle } from
|
|
2
|
+
import { Rectangle } from './rectangle';
|
|
9
3
|
import { distance } from '../util/math';
|
|
10
4
|
import { clone, contains, circumferencePoint } from './util/circle';
|
|
11
5
|
import { GEOM_CIRCLE } from '../core/const';
|
|
@@ -28,10 +22,19 @@ export class Circle {
|
|
|
28
22
|
this.type = GEOM_CIRCLE;
|
|
29
23
|
}
|
|
30
24
|
|
|
25
|
+
/**
|
|
26
|
+
* TBD.
|
|
27
|
+
* @returns {number} TBD.
|
|
28
|
+
*/
|
|
31
29
|
circumference() {
|
|
32
30
|
return 2 * (Math.PI * this._radius);
|
|
33
31
|
}
|
|
34
32
|
|
|
33
|
+
/**
|
|
34
|
+
* TBD.
|
|
35
|
+
* @param {Point} output - TBD.
|
|
36
|
+
* @returns {Point} TBD.
|
|
37
|
+
*/
|
|
35
38
|
random(output = null) {
|
|
36
39
|
const result = output || new Point();
|
|
37
40
|
const t = 2 * Math.PI * Math.random();
|
|
@@ -44,10 +47,21 @@ export class Circle {
|
|
|
44
47
|
return result;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
/**
|
|
51
|
+
* TBD.
|
|
52
|
+
* @returns {Rectangle} TBD.
|
|
53
|
+
*/
|
|
47
54
|
getBounds() {
|
|
48
55
|
return new Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter);
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
/**
|
|
59
|
+
* TBD.
|
|
60
|
+
* @param {number} x - TBD.
|
|
61
|
+
* @param {number} y - TBD.
|
|
62
|
+
* @param {number} diameter - TBD.
|
|
63
|
+
* @returns {Circle} TBD.
|
|
64
|
+
*/
|
|
51
65
|
setTo(x, y, diameter) {
|
|
52
66
|
this.x = x;
|
|
53
67
|
this.y = y;
|
|
@@ -56,10 +70,20 @@ export class Circle {
|
|
|
56
70
|
return this;
|
|
57
71
|
}
|
|
58
72
|
|
|
73
|
+
/**
|
|
74
|
+
* TBD.
|
|
75
|
+
* @param {Circle} source - TBD.
|
|
76
|
+
* @returns {Circle} TBD.
|
|
77
|
+
*/
|
|
59
78
|
copyFrom(source) {
|
|
60
79
|
return this.setTo(source.x, source.y, source.diameter);
|
|
61
80
|
}
|
|
62
81
|
|
|
82
|
+
/**
|
|
83
|
+
* TBD.
|
|
84
|
+
* @param {Circle} dest - TBD.
|
|
85
|
+
* @returns {Circle} TBD.
|
|
86
|
+
*/
|
|
63
87
|
copyTo(dest) {
|
|
64
88
|
dest.x = this.x;
|
|
65
89
|
dest.y = this.y;
|
|
@@ -67,51 +91,86 @@ export class Circle {
|
|
|
67
91
|
return dest;
|
|
68
92
|
}
|
|
69
93
|
|
|
94
|
+
/**
|
|
95
|
+
* TBD.
|
|
96
|
+
* @param {Circle} dest - TBD.
|
|
97
|
+
* @param {boolean} round - TBD.
|
|
98
|
+
* @returns {number} TBD.
|
|
99
|
+
*/
|
|
70
100
|
distance(dest, round = false) {
|
|
71
101
|
const d = distance(this.x, this.y, dest.x, dest.y);
|
|
72
102
|
return round ? Math.round(d) : d;
|
|
73
103
|
}
|
|
74
104
|
|
|
105
|
+
/**
|
|
106
|
+
* TBD.
|
|
107
|
+
* @returns {Circle} TBD.
|
|
108
|
+
*/
|
|
75
109
|
clone() {
|
|
76
110
|
return clone(this);
|
|
77
111
|
}
|
|
78
112
|
|
|
113
|
+
/**
|
|
114
|
+
* TBD.
|
|
115
|
+
* @param {number} x - TBD.
|
|
116
|
+
* @param {number} y - TBD.
|
|
117
|
+
* @returns {boolean} TBD.
|
|
118
|
+
*/
|
|
79
119
|
contains(x, y) {
|
|
80
120
|
return contains(this, x, y);
|
|
81
121
|
}
|
|
82
122
|
|
|
123
|
+
/**
|
|
124
|
+
* TBD.
|
|
125
|
+
* @param {number} angle - TBD.
|
|
126
|
+
* @param {boolean} asDegrees - TBD.
|
|
127
|
+
* @param {Point} out - TBD.
|
|
128
|
+
* @returns {Point} TBD.
|
|
129
|
+
*/
|
|
83
130
|
circumferencePoint(angle, asDegrees, out) {
|
|
84
131
|
return circumferencePoint(this, angle, asDegrees, out);
|
|
85
132
|
}
|
|
86
133
|
|
|
134
|
+
/**
|
|
135
|
+
* TBD.
|
|
136
|
+
* @param {number} dx - TBD.
|
|
137
|
+
* @param {number} dy - TBD.
|
|
138
|
+
* @returns {Circle} TBD.
|
|
139
|
+
*/
|
|
87
140
|
offset(dx, dy) {
|
|
88
141
|
this.x += dx;
|
|
89
142
|
this.y += dy;
|
|
90
143
|
return this;
|
|
91
144
|
}
|
|
92
145
|
|
|
146
|
+
/**
|
|
147
|
+
* TBD.
|
|
148
|
+
* @param {Point} point - TBD.
|
|
149
|
+
* @returns {Circle} TBD.
|
|
150
|
+
*/
|
|
93
151
|
offsetPoint(point) {
|
|
94
152
|
return this.offset(point.x, point.y);
|
|
95
153
|
}
|
|
96
154
|
|
|
155
|
+
/**
|
|
156
|
+
* TBD.
|
|
157
|
+
* @returns {string} TBD.
|
|
158
|
+
*/
|
|
97
159
|
toString() {
|
|
98
|
-
return (
|
|
99
|
-
'[{Circle (x=' +
|
|
100
|
-
this.x +
|
|
101
|
-
' y=' +
|
|
102
|
-
this.y +
|
|
103
|
-
' diameter=' +
|
|
104
|
-
this.diameter +
|
|
105
|
-
' radius=' +
|
|
106
|
-
this.radius +
|
|
107
|
-
')}]'
|
|
108
|
-
);
|
|
160
|
+
return '[{Circle (x=' + this.x + ' y=' + this.y + ' diameter=' + this.diameter + ' radius=' + this.radius + ')}]';
|
|
109
161
|
}
|
|
110
162
|
|
|
163
|
+
/**
|
|
164
|
+
* TBD.
|
|
165
|
+
* @returns {number} TBD.
|
|
166
|
+
*/
|
|
111
167
|
get diameter() {
|
|
112
168
|
return this._diameter;
|
|
113
169
|
}
|
|
114
170
|
|
|
171
|
+
/**
|
|
172
|
+
* TBD.
|
|
173
|
+
*/
|
|
115
174
|
set diameter(value) {
|
|
116
175
|
if (value > 0) {
|
|
117
176
|
this._diameter = value;
|
|
@@ -119,10 +178,17 @@ export class Circle {
|
|
|
119
178
|
}
|
|
120
179
|
}
|
|
121
180
|
|
|
181
|
+
/**
|
|
182
|
+
* TBD.
|
|
183
|
+
* @returns {number} TBD.
|
|
184
|
+
*/
|
|
122
185
|
get radius() {
|
|
123
186
|
return this._radius;
|
|
124
187
|
}
|
|
125
188
|
|
|
189
|
+
/**
|
|
190
|
+
* TBD.
|
|
191
|
+
*/
|
|
126
192
|
set radius(value) {
|
|
127
193
|
if (value > 0) {
|
|
128
194
|
this._radius = value;
|
|
@@ -130,10 +196,17 @@ export class Circle {
|
|
|
130
196
|
}
|
|
131
197
|
}
|
|
132
198
|
|
|
199
|
+
/**
|
|
200
|
+
* TBD.
|
|
201
|
+
* @returns {number} TBD.
|
|
202
|
+
*/
|
|
133
203
|
get left() {
|
|
134
204
|
return this.x - this._radius;
|
|
135
205
|
}
|
|
136
206
|
|
|
207
|
+
/**
|
|
208
|
+
* TBD.
|
|
209
|
+
*/
|
|
137
210
|
set left(value) {
|
|
138
211
|
if (value > this.x) {
|
|
139
212
|
this._radius = 0;
|
|
@@ -143,10 +216,17 @@ export class Circle {
|
|
|
143
216
|
}
|
|
144
217
|
}
|
|
145
218
|
|
|
219
|
+
/**
|
|
220
|
+
* TBD.
|
|
221
|
+
* @returns {number} TBD.
|
|
222
|
+
*/
|
|
146
223
|
get right() {
|
|
147
224
|
return this.x + this._radius;
|
|
148
225
|
}
|
|
149
226
|
|
|
227
|
+
/**
|
|
228
|
+
* TBD.
|
|
229
|
+
*/
|
|
150
230
|
set right(value) {
|
|
151
231
|
if (value < this.x) {
|
|
152
232
|
this._radius = 0;
|
|
@@ -156,10 +236,17 @@ export class Circle {
|
|
|
156
236
|
}
|
|
157
237
|
}
|
|
158
238
|
|
|
239
|
+
/**
|
|
240
|
+
* TBD.
|
|
241
|
+
* @returns {number} TBD.
|
|
242
|
+
*/
|
|
159
243
|
get top() {
|
|
160
244
|
return this.y - this._radius;
|
|
161
245
|
}
|
|
162
246
|
|
|
247
|
+
/**
|
|
248
|
+
* TBD.
|
|
249
|
+
*/
|
|
163
250
|
set top(value) {
|
|
164
251
|
if (value > this.y) {
|
|
165
252
|
this._radius = 0;
|
|
@@ -169,10 +256,17 @@ export class Circle {
|
|
|
169
256
|
}
|
|
170
257
|
}
|
|
171
258
|
|
|
259
|
+
/**
|
|
260
|
+
* TBD.
|
|
261
|
+
* @returns {number} TBD.
|
|
262
|
+
*/
|
|
172
263
|
get bottom() {
|
|
173
264
|
return this.y + this._radius;
|
|
174
265
|
}
|
|
175
266
|
|
|
267
|
+
/**
|
|
268
|
+
* TBD.
|
|
269
|
+
*/
|
|
176
270
|
set bottom(value) {
|
|
177
271
|
if (value < this.y) {
|
|
178
272
|
this._radius = 0;
|
|
@@ -182,6 +276,10 @@ export class Circle {
|
|
|
182
276
|
}
|
|
183
277
|
}
|
|
184
278
|
|
|
279
|
+
/**
|
|
280
|
+
* TBD.
|
|
281
|
+
* @returns {number} TBD.
|
|
282
|
+
*/
|
|
185
283
|
get area() {
|
|
186
284
|
if (this._radius > 0) {
|
|
187
285
|
return Math.PI * this._radius * this._radius;
|
|
@@ -189,10 +287,17 @@ export class Circle {
|
|
|
189
287
|
return 0;
|
|
190
288
|
}
|
|
191
289
|
|
|
290
|
+
/**
|
|
291
|
+
* TBD.
|
|
292
|
+
* @returns {boolean} TBD.
|
|
293
|
+
*/
|
|
192
294
|
get empty() {
|
|
193
295
|
return this._diameter === 0;
|
|
194
296
|
}
|
|
195
297
|
|
|
298
|
+
/**
|
|
299
|
+
* TBD.
|
|
300
|
+
*/
|
|
196
301
|
set empty(value) {
|
|
197
302
|
if (value === true) {
|
|
198
303
|
this.setTo(0, 0, 0);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module geom/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
1
|
import { Point } from './point';
|
|
8
|
-
import { Rectangle } from
|
|
2
|
+
import { Rectangle } from './rectangle';
|
|
9
3
|
import { contains } from './util/ellipse';
|
|
10
4
|
import { GEOM_ELLIPSE } from '../core/const';
|
|
11
5
|
|
|
@@ -25,6 +19,14 @@ export class Ellipse {
|
|
|
25
19
|
this.type = GEOM_ELLIPSE;
|
|
26
20
|
}
|
|
27
21
|
|
|
22
|
+
/**
|
|
23
|
+
* TBD.
|
|
24
|
+
* @param {number} x - TBD.
|
|
25
|
+
* @param {number} y - TBD.
|
|
26
|
+
* @param {number} width - TBD.
|
|
27
|
+
* @param {number} height - TBD.
|
|
28
|
+
* @returns {Ellipse} TBD.
|
|
29
|
+
*/
|
|
28
30
|
setTo(x, y, width, height) {
|
|
29
31
|
this.x = x;
|
|
30
32
|
this.y = y;
|
|
@@ -33,14 +35,28 @@ export class Ellipse {
|
|
|
33
35
|
return this;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
/**
|
|
39
|
+
* TBD.
|
|
40
|
+
* @returns {Rectangle} TBD.
|
|
41
|
+
*/
|
|
36
42
|
getBounds() {
|
|
37
43
|
return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height);
|
|
38
44
|
}
|
|
39
45
|
|
|
46
|
+
/**
|
|
47
|
+
* TBD.
|
|
48
|
+
* @param {Ellipse} source - TBD.
|
|
49
|
+
* @returns {Ellipse} TBD.
|
|
50
|
+
*/
|
|
40
51
|
copyFrom(source) {
|
|
41
52
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
42
53
|
}
|
|
43
54
|
|
|
55
|
+
/**
|
|
56
|
+
* TBD.
|
|
57
|
+
* @param {Ellipse} dest - TBD.
|
|
58
|
+
* @returns {Ellipse} TBD.
|
|
59
|
+
*/
|
|
44
60
|
copyTo(dest) {
|
|
45
61
|
dest.x = this.x;
|
|
46
62
|
dest.y = this.y;
|
|
@@ -49,10 +65,21 @@ export class Ellipse {
|
|
|
49
65
|
return dest;
|
|
50
66
|
}
|
|
51
67
|
|
|
68
|
+
/**
|
|
69
|
+
* TBD.
|
|
70
|
+
* @param {number} x - TBD.
|
|
71
|
+
* @param {number} y - TBD.
|
|
72
|
+
* @returns {boolean} TBD.
|
|
73
|
+
*/
|
|
52
74
|
contains(x, y) {
|
|
53
75
|
return contains(this, x, y);
|
|
54
76
|
}
|
|
55
77
|
|
|
78
|
+
/**
|
|
79
|
+
* TBD.
|
|
80
|
+
* @param {Point} output - TBD.
|
|
81
|
+
* @returns {Point} TBD.
|
|
82
|
+
*/
|
|
56
83
|
random(output = null) {
|
|
57
84
|
const result = output || new Point();
|
|
58
85
|
const p = Math.random() * Math.PI * 2;
|
|
@@ -64,17 +91,11 @@ export class Ellipse {
|
|
|
64
91
|
return result;
|
|
65
92
|
}
|
|
66
93
|
|
|
94
|
+
/**
|
|
95
|
+
* TBD.
|
|
96
|
+
* @returns {string} TBD.
|
|
97
|
+
*/
|
|
67
98
|
toString() {
|
|
68
|
-
return (
|
|
69
|
-
'[{Ellipse (x=' +
|
|
70
|
-
this.x +
|
|
71
|
-
' y=' +
|
|
72
|
-
this.y +
|
|
73
|
-
' width=' +
|
|
74
|
-
this.width +
|
|
75
|
-
' height=' +
|
|
76
|
-
this.height +
|
|
77
|
-
')}]'
|
|
78
|
-
);
|
|
99
|
+
return '[{Ellipse (x=' + this.x + ' y=' + this.y + ' width=' + this.width + ' height=' + this.height + ')}]';
|
|
79
100
|
}
|
|
80
101
|
}
|