@vpmedia/phaser 1.104.0 → 1.105.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/dist/index.js +151 -574
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -57
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +11 -10
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +2 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +3 -3
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts +60 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts.map +1 -1
- package/dist/phaser/core/device_util.d.ts +10 -10
- package/dist/phaser/core/device_util.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +6 -5
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/event_manager.d.ts +49 -174
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +7 -7
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame.d.ts +27 -48
- package/dist/phaser/core/frame.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts +11 -60
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/frame_util.d.ts +4 -14
- package/dist/phaser/core/frame_util.d.ts.map +1 -1
- package/dist/phaser/core/game.d.ts +49 -58
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +15 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +23 -20
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +26 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_mspointer.d.ts +2 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +9 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +2 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +28 -28
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +4 -4
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +2 -2
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts +22 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +1 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +10 -9
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts +9 -8
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/signal_binding.d.ts +2 -2
- package/dist/phaser/core/signal_binding.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts +56 -101
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +11 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +4 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +3 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +5 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +10 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -21
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +37 -59
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +6 -5
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_easing.d.ts +31 -31
- package/dist/phaser/core/tween_easing.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts +4 -4
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/core/world.d.ts +1 -1
- package/dist/phaser/core/world.d.ts.map +1 -1
- package/dist/phaser/display/bitmap_text.d.ts +22 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +23 -35
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +2 -2
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/graphics.d.ts +3 -3
- package/dist/phaser/display/canvas/graphics.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts.map +1 -1
- package/dist/phaser/display/canvas/pool.d.ts +2 -2
- package/dist/phaser/display/canvas/pool.d.ts.map +1 -1
- package/dist/phaser/display/canvas/renderer.d.ts +5 -5
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/tinter.d.ts +3 -3
- package/dist/phaser/display/canvas/tinter.d.ts.map +1 -1
- package/dist/phaser/display/canvas/util.d.ts +9 -9
- package/dist/phaser/display/canvas/util.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +45 -42
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +24 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +1 -1
- package/dist/phaser/display/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts +1 -1
- package/dist/phaser/display/graphics_data_util.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +24 -37
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +34 -49
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_batch.d.ts +1 -1
- package/dist/phaser/display/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +5 -5
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +86 -66
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +2 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +2 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +3 -2
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts +10 -10
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts +1 -1
- package/dist/phaser/display/webgl/earcut_node.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +2 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +2 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +3 -2
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +11 -10
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts +2 -1
- package/dist/phaser/display/webgl/graphics_data.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +2 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +8 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +1 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +2 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +4 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +3 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +5 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +15 -2
- package/dist/phaser/display/webgl/texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture_util.d.ts +2 -2
- package/dist/phaser/display/webgl/texture_util.d.ts.map +1 -1
- package/dist/phaser/display/webgl/util.d.ts +6 -6
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts +11 -10
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/ellipse.d.ts +6 -5
- package/dist/phaser/geom/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +14 -14
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/matrix.d.ts +13 -12
- package/dist/phaser/geom/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/point.d.ts +19 -19
- package/dist/phaser/geom/point.d.ts.map +1 -1
- package/dist/phaser/geom/polygon.d.ts +6 -6
- package/dist/phaser/geom/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts +20 -20
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/rounded_rectangle.d.ts +2 -2
- package/dist/phaser/geom/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +9 -7
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts +1 -1
- package/dist/phaser/geom/util/ellipse.d.ts.map +1 -1
- package/dist/phaser/geom/util/line.d.ts +5 -3
- package/dist/phaser/geom/util/line.d.ts.map +1 -1
- package/dist/phaser/geom/util/matrix.d.ts +2 -1
- package/dist/phaser/geom/util/matrix.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +19 -19
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/polygon.d.ts +2 -1
- package/dist/phaser/geom/util/polygon.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +17 -15
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts +2 -1
- package/dist/phaser/geom/util/rounded_rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts +51 -142
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +38 -61
- package/src/phaser/core/animation_manager.ts +21 -21
- package/src/phaser/core/animation_parser.ts +11 -3
- package/src/phaser/core/array_set.ts +8 -8
- package/src/phaser/core/cache.ts +75 -68
- package/src/phaser/core/device.ts +23 -24
- package/src/phaser/core/device_util.ts +10 -10
- package/src/phaser/core/dom.ts +5 -5
- package/src/phaser/core/event_manager.ts +52 -193
- package/src/phaser/core/factory.ts +25 -18
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -76
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +36 -63
- package/src/phaser/core/input.ts +68 -68
- package/src/phaser/core/input_handler.ts +81 -86
- package/src/phaser/core/input_mouse.ts +42 -36
- package/src/phaser/core/input_mspointer.ts +24 -25
- package/src/phaser/core/input_pointer.ts +55 -56
- package/src/phaser/core/input_touch.ts +26 -26
- package/src/phaser/core/loader.ts +97 -70
- package/src/phaser/core/loader_parser.ts +6 -7
- package/src/phaser/core/raf.ts +2 -2
- package/src/phaser/core/scale_manager.ts +85 -82
- package/src/phaser/core/scene.ts +3 -4
- package/src/phaser/core/scene_manager.ts +26 -26
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +65 -112
- package/src/phaser/core/sound_manager.ts +31 -30
- package/src/phaser/core/sound_sprite.ts +10 -11
- package/src/phaser/core/stage.ts +8 -8
- package/src/phaser/core/time.ts +33 -34
- package/src/phaser/core/timer.ts +40 -34
- package/src/phaser/core/timer_event.ts +23 -23
- package/src/phaser/core/tween.ts +42 -68
- package/src/phaser/core/tween_data.ts +31 -31
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -11
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -31
- package/src/phaser/display/button.ts +24 -51
- package/src/phaser/display/canvas/buffer.ts +6 -7
- package/src/phaser/display/canvas/graphics.ts +3 -4
- package/src/phaser/display/canvas/masker.ts +2 -3
- package/src/phaser/display/canvas/pool.ts +3 -4
- package/src/phaser/display/canvas/renderer.ts +19 -20
- package/src/phaser/display/canvas/tinter.ts +4 -5
- package/src/phaser/display/canvas/util.ts +9 -9
- package/src/phaser/display/display_object.ts +49 -50
- package/src/phaser/display/graphics.ts +56 -43
- package/src/phaser/display/graphics_data.ts +11 -12
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -42
- package/src/phaser/display/image.ts +32 -52
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +5 -6
- package/src/phaser/display/text.ts +82 -56
- package/src/phaser/display/webgl/abstract_filter.ts +8 -8
- package/src/phaser/display/webgl/base_texture.ts +14 -15
- package/src/phaser/display/webgl/blend_manager.ts +5 -5
- package/src/phaser/display/webgl/earcut.ts +27 -27
- package/src/phaser/display/webgl/earcut_node.ts +1 -1
- package/src/phaser/display/webgl/fast_sprite_batch.ts +19 -19
- package/src/phaser/display/webgl/filter_manager.ts +5 -5
- package/src/phaser/display/webgl/filter_texture.ts +7 -7
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -11
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -12
- package/src/phaser/display/webgl/renderer.ts +24 -24
- package/src/phaser/display/webgl/shader/complex.ts +7 -7
- package/src/phaser/display/webgl/shader/fast.ts +8 -8
- package/src/phaser/display/webgl/shader/normal.ts +12 -12
- package/src/phaser/display/webgl/shader/primitive.ts +7 -7
- package/src/phaser/display/webgl/shader/strip.ts +7 -7
- package/src/phaser/display/webgl/shader_manager.ts +13 -13
- package/src/phaser/display/webgl/sprite_batch.ts +20 -20
- package/src/phaser/display/webgl/stencil_manager.ts +8 -8
- package/src/phaser/display/webgl/texture.ts +35 -24
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +6 -6
- package/src/phaser/geom/circle.ts +10 -10
- package/src/phaser/geom/ellipse.ts +6 -6
- package/src/phaser/geom/line.ts +14 -14
- package/src/phaser/geom/matrix.ts +12 -12
- package/src/phaser/geom/point.ts +19 -19
- package/src/phaser/geom/polygon.ts +5 -5
- package/src/phaser/geom/rectangle.ts +21 -21
- package/src/phaser/geom/rounded_rectangle.ts +2 -2
- package/src/phaser/geom/util/circle.ts +7 -7
- package/src/phaser/geom/util/ellipse.ts +1 -1
- package/src/phaser/geom/util/line.ts +5 -5
- package/src/phaser/geom/util/matrix.ts +1 -1
- package/src/phaser/geom/util/point.ts +20 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +15 -15
- package/src/phaser/geom/util/rounded_rectangle.ts +1 -1
- package/src/phaser/util/math.ts +65 -151
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Matrix } from '../geom/matrix.js';
|
|
3
2
|
import { Point } from '../geom/point.js';
|
|
4
3
|
import { Rectangle } from '../geom/rectangle.js';
|
|
@@ -13,14 +12,10 @@ export class DisplayObject {
|
|
|
13
12
|
renderable = false;
|
|
14
13
|
/** @type {boolean} */
|
|
15
14
|
visible = true;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/** @type {Point} */
|
|
21
|
-
pivot;
|
|
22
|
-
/** @type {Point} */
|
|
23
|
-
anchor;
|
|
15
|
+
position!: Point;
|
|
16
|
+
scale!: Point;
|
|
17
|
+
pivot!: Point;
|
|
18
|
+
anchor!: Point;
|
|
24
19
|
/** @type {number} */
|
|
25
20
|
rotation = 0;
|
|
26
21
|
/** @type {number} */
|
|
@@ -31,18 +26,15 @@ export class DisplayObject {
|
|
|
31
26
|
parent = null;
|
|
32
27
|
/** @type {number} */
|
|
33
28
|
worldAlpha = 1;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** @type {Point} */
|
|
37
|
-
worldScale;
|
|
29
|
+
worldTransform!: Matrix;
|
|
30
|
+
worldScale!: Point;
|
|
38
31
|
/** @type {Rectangle} */
|
|
39
32
|
filterArea = null;
|
|
40
33
|
/** @type {number} */
|
|
41
34
|
_sr = 0;
|
|
42
35
|
/** @type {number} */
|
|
43
36
|
_cr = 1;
|
|
44
|
-
|
|
45
|
-
cachedBounds;
|
|
37
|
+
cachedBounds!: Rectangle;
|
|
46
38
|
/** @type {Rectangle} */
|
|
47
39
|
currentBounds = null;
|
|
48
40
|
/** @type {import('./graphics.js').Graphics} */
|
|
@@ -51,23 +43,30 @@ export class DisplayObject {
|
|
|
51
43
|
_filters = null;
|
|
52
44
|
/** @type {object} */
|
|
53
45
|
_filterBlock = null;
|
|
54
|
-
|
|
55
|
-
children;
|
|
46
|
+
children!: any[];
|
|
56
47
|
/** @type {boolean} */
|
|
57
48
|
ignoreChildInput = false;
|
|
58
49
|
/** @type {string | null} */
|
|
59
50
|
name = null;
|
|
60
51
|
/** @type {object | null} */
|
|
61
52
|
data = null;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
game!: import('../core/game.js').Game;
|
|
54
|
+
type!: number;
|
|
55
|
+
_cachedSprite!: any;
|
|
56
|
+
rotationCache!: any;
|
|
57
|
+
worldRotation!: any;
|
|
58
|
+
transformCallback!: any;
|
|
59
|
+
transformCallbackContext!: any;
|
|
60
|
+
_width!: any;
|
|
61
|
+
_height!: any;
|
|
62
|
+
z!: any;
|
|
63
|
+
events!: any;
|
|
64
|
+
renderOrderID!: any;
|
|
66
65
|
/**
|
|
67
66
|
* Creates a new DisplayObject instance.
|
|
68
67
|
* @param {import('../core/game.js').Game} game - The game instance this display object belongs to.
|
|
69
68
|
*/
|
|
70
|
-
constructor(game) {
|
|
69
|
+
constructor(game: import('../core/game.js').Game) {
|
|
71
70
|
/** @type {boolean} */
|
|
72
71
|
this.exists = true;
|
|
73
72
|
/** @type {boolean} */
|
|
@@ -164,7 +163,7 @@ export class DisplayObject {
|
|
|
164
163
|
* @param {DisplayObject} child - The child display object to add.
|
|
165
164
|
* @returns {DisplayObject} The added child display object.
|
|
166
165
|
*/
|
|
167
|
-
addChild(child) {
|
|
166
|
+
addChild(child: DisplayObject) {
|
|
168
167
|
return this.addChildAt(child, this.children.length);
|
|
169
168
|
}
|
|
170
169
|
|
|
@@ -175,7 +174,7 @@ export class DisplayObject {
|
|
|
175
174
|
* @returns {DisplayObject} The added child display object.
|
|
176
175
|
* @throws {Error} If the index is out of bounds.
|
|
177
176
|
*/
|
|
178
|
-
addChildAt(child, index) {
|
|
177
|
+
addChildAt(child: DisplayObject, index: number) {
|
|
179
178
|
if (index >= 0 && index <= this.children.length) {
|
|
180
179
|
if (child.parent) {
|
|
181
180
|
child.parent.removeChild(child);
|
|
@@ -193,7 +192,7 @@ export class DisplayObject {
|
|
|
193
192
|
* @param {DisplayObject} child2 - The second child display object.
|
|
194
193
|
* @throws {Error} If either child is not a child of this container.
|
|
195
194
|
*/
|
|
196
|
-
swapChildren(child, child2) {
|
|
195
|
+
swapChildren(child: DisplayObject, child2: DisplayObject) {
|
|
197
196
|
if (child === child2) {
|
|
198
197
|
return;
|
|
199
198
|
}
|
|
@@ -212,7 +211,7 @@ export class DisplayObject {
|
|
|
212
211
|
* @returns {number} The index of the child in the children list.
|
|
213
212
|
* @throws {Error} If the child is not a child of this container.
|
|
214
213
|
*/
|
|
215
|
-
getChildIndex(child) {
|
|
214
|
+
getChildIndex(child: DisplayObject) {
|
|
216
215
|
const index = this.children.indexOf(child);
|
|
217
216
|
if (index === -1) {
|
|
218
217
|
throw new Error('The supplied DisplayObject must be a child of the caller');
|
|
@@ -226,7 +225,7 @@ export class DisplayObject {
|
|
|
226
225
|
* @param {number} index - The new index for the child.
|
|
227
226
|
* @throws {Error} If the index is out of bounds.
|
|
228
227
|
*/
|
|
229
|
-
setChildIndex(child, index) {
|
|
228
|
+
setChildIndex(child: DisplayObject, index: number) {
|
|
230
229
|
if (index < 0 || index >= this.children.length) {
|
|
231
230
|
throw new Error('The supplied index is out of bounds');
|
|
232
231
|
}
|
|
@@ -241,7 +240,7 @@ export class DisplayObject {
|
|
|
241
240
|
* @returns {DisplayObject} The child display object at the specified index.
|
|
242
241
|
* @throws {Error} If the index is out of bounds.
|
|
243
242
|
*/
|
|
244
|
-
getChildAt(index) {
|
|
243
|
+
getChildAt(index: number) {
|
|
245
244
|
if (index < 0 || index >= this.children.length) {
|
|
246
245
|
throw new Error(
|
|
247
246
|
`getChildAt: Supplied index ${
|
|
@@ -257,7 +256,7 @@ export class DisplayObject {
|
|
|
257
256
|
* @param {DisplayObject} child - The child display object to remove.
|
|
258
257
|
* @returns {DisplayObject} The removed child display object.
|
|
259
258
|
*/
|
|
260
|
-
removeChild(child) {
|
|
259
|
+
removeChild(child: DisplayObject) {
|
|
261
260
|
const index = this.children.indexOf(child);
|
|
262
261
|
if (index === -1) {
|
|
263
262
|
return null;
|
|
@@ -270,7 +269,7 @@ export class DisplayObject {
|
|
|
270
269
|
* @param {number} index - The index of the child to remove.
|
|
271
270
|
* @returns {DisplayObject} The removed child display object.
|
|
272
271
|
*/
|
|
273
|
-
removeChildAt(index) {
|
|
272
|
+
removeChildAt(index: number) {
|
|
274
273
|
const child = this.getChildAt(index);
|
|
275
274
|
if (child) {
|
|
276
275
|
child.parent = undefined;
|
|
@@ -286,7 +285,7 @@ export class DisplayObject {
|
|
|
286
285
|
* @returns {DisplayObject[]} The array of removed child display objects.
|
|
287
286
|
* @throws {Error} If the range is invalid.
|
|
288
287
|
*/
|
|
289
|
-
removeChildren(beginIndex, endIndex) {
|
|
288
|
+
removeChildren(beginIndex: number, endIndex: number) {
|
|
290
289
|
if (beginIndex === undefined) {
|
|
291
290
|
beginIndex = 0;
|
|
292
291
|
}
|
|
@@ -313,7 +312,7 @@ export class DisplayObject {
|
|
|
313
312
|
* @param {DisplayObject | null | undefined} parent - The parent display object to use for the world transform calculation.
|
|
314
313
|
* @returns {DisplayObject} This DisplayObject instance for chaining.
|
|
315
314
|
*/
|
|
316
|
-
updateTransform(parent = null) {
|
|
315
|
+
updateTransform(parent: DisplayObject | null | undefined = null) {
|
|
317
316
|
if (!parent && !this.parent) {
|
|
318
317
|
return this;
|
|
319
318
|
}
|
|
@@ -401,7 +400,7 @@ export class DisplayObject {
|
|
|
401
400
|
* @param {DisplayObject} targetCoordinateSpace - The coordinate space to calculate bounds in.
|
|
402
401
|
* @returns {Rectangle} The bounds rectangle of this display object.
|
|
403
402
|
*/
|
|
404
|
-
getBounds(targetCoordinateSpace) {
|
|
403
|
+
getBounds(targetCoordinateSpace?: any) {
|
|
405
404
|
const isTargetCoordinateSpaceDisplayObject = targetCoordinateSpace && targetCoordinateSpace.contains !== undefined;
|
|
406
405
|
let isTargetCoordinateSpaceThisOrParent = true;
|
|
407
406
|
if (!isTargetCoordinateSpaceDisplayObject) {
|
|
@@ -511,7 +510,7 @@ export class DisplayObject {
|
|
|
511
510
|
* @param {DisplayObject} child - The child display object to check.
|
|
512
511
|
* @returns {boolean} True if the child is contained within this container, false otherwise.
|
|
513
512
|
*/
|
|
514
|
-
contains(child) {
|
|
513
|
+
contains(child: DisplayObject) {
|
|
515
514
|
if (!child) {
|
|
516
515
|
return false;
|
|
517
516
|
}
|
|
@@ -525,7 +524,7 @@ export class DisplayObject {
|
|
|
525
524
|
* Renders this display object using WebGL.
|
|
526
525
|
* @param {object} renderSession - The WebGL rendering session.
|
|
527
526
|
*/
|
|
528
|
-
renderWebGL(renderSession) {
|
|
527
|
+
renderWebGL(renderSession: any) {
|
|
529
528
|
if (!this.visible || this.alpha <= 0) {
|
|
530
529
|
return;
|
|
531
530
|
}
|
|
@@ -563,7 +562,7 @@ export class DisplayObject {
|
|
|
563
562
|
* Renders this display object using Canvas.
|
|
564
563
|
* @param {object} renderSession - The Canvas rendering session.
|
|
565
564
|
*/
|
|
566
|
-
renderCanvas(renderSession) {
|
|
565
|
+
renderCanvas(renderSession: any) {
|
|
567
566
|
if (!this.visible || this.alpha <= 0) {
|
|
568
567
|
return;
|
|
569
568
|
}
|
|
@@ -613,7 +612,7 @@ export class DisplayObject {
|
|
|
613
612
|
* @param {Point} position - The local position to convert.
|
|
614
613
|
* @returns {Point} The converted global position.
|
|
615
614
|
*/
|
|
616
|
-
toGlobal(position) {
|
|
615
|
+
toGlobal(position: Point) {
|
|
617
616
|
this.updateTransform();
|
|
618
617
|
return this.worldTransform.apply(position);
|
|
619
618
|
}
|
|
@@ -624,7 +623,7 @@ export class DisplayObject {
|
|
|
624
623
|
* @param {DisplayObject} from - The display object to convert from (defaults to this).
|
|
625
624
|
* @returns {Point} The converted local position.
|
|
626
625
|
*/
|
|
627
|
-
toLocal(position, from) {
|
|
626
|
+
toLocal(position: Point, from: DisplayObject) {
|
|
628
627
|
if (from) {
|
|
629
628
|
position = from.toGlobal(position);
|
|
630
629
|
}
|
|
@@ -636,7 +635,7 @@ export class DisplayObject {
|
|
|
636
635
|
* Renders a cached sprite for this display object.
|
|
637
636
|
* @param {object} renderSession - The rendering session.
|
|
638
637
|
*/
|
|
639
|
-
renderCachedSprite(renderSession) {
|
|
638
|
+
renderCachedSprite(renderSession: any) {
|
|
640
639
|
if (!this._cachedSprite) {
|
|
641
640
|
return;
|
|
642
641
|
}
|
|
@@ -680,7 +679,7 @@ export class DisplayObject {
|
|
|
680
679
|
* Sets the width of this display object.
|
|
681
680
|
* @param {number} value - The new width in pixels.
|
|
682
681
|
*/
|
|
683
|
-
set width(value) {
|
|
682
|
+
set width(value: number) {
|
|
684
683
|
const { width } = this.getLocalBounds();
|
|
685
684
|
if (width !== 0) {
|
|
686
685
|
this.scale.x = value / width;
|
|
@@ -702,7 +701,7 @@ export class DisplayObject {
|
|
|
702
701
|
* Sets the height of this display object.
|
|
703
702
|
* @param {number} value - The new height in pixels.
|
|
704
703
|
*/
|
|
705
|
-
set height(value) {
|
|
704
|
+
set height(value: number) {
|
|
706
705
|
const { height } = this.getLocalBounds();
|
|
707
706
|
if (height !== 0) {
|
|
708
707
|
this.scale.y = value / height;
|
|
@@ -724,7 +723,7 @@ export class DisplayObject {
|
|
|
724
723
|
* Sets the x position of this display object.
|
|
725
724
|
* @param {number} value - The new x position in pixels.
|
|
726
725
|
*/
|
|
727
|
-
set x(value) {
|
|
726
|
+
set x(value: number) {
|
|
728
727
|
this.position.x = value;
|
|
729
728
|
}
|
|
730
729
|
|
|
@@ -740,7 +739,7 @@ export class DisplayObject {
|
|
|
740
739
|
* Sets the y position of this display object.
|
|
741
740
|
* @param {number} value - The new y position in pixels.
|
|
742
741
|
*/
|
|
743
|
-
set y(value) {
|
|
742
|
+
set y(value: number) {
|
|
744
743
|
this.position.y = value;
|
|
745
744
|
}
|
|
746
745
|
|
|
@@ -779,7 +778,7 @@ export class DisplayObject {
|
|
|
779
778
|
* Sets the mask for this display object.
|
|
780
779
|
* @param {import('./graphics.js').Graphics} value - The mask object to set, or null to remove the mask.
|
|
781
780
|
*/
|
|
782
|
-
set mask(value) {
|
|
781
|
+
set mask(value: import('./graphics.js').Graphics) {
|
|
783
782
|
if (this._mask) {
|
|
784
783
|
this._mask.isMask = false;
|
|
785
784
|
}
|
|
@@ -819,7 +818,7 @@ export class DisplayObject {
|
|
|
819
818
|
* Sets the center x position of this display object.
|
|
820
819
|
* @param {number} value - The new center x position in pixels.
|
|
821
820
|
*/
|
|
822
|
-
set centerX(value) {
|
|
821
|
+
set centerX(value: number) {
|
|
823
822
|
this.x = value + this.offsetX - this.width * 0.5;
|
|
824
823
|
}
|
|
825
824
|
|
|
@@ -835,7 +834,7 @@ export class DisplayObject {
|
|
|
835
834
|
* Sets the center y position of this display object.
|
|
836
835
|
* @param {number} value - The new center y position in pixels.
|
|
837
836
|
*/
|
|
838
|
-
set centerY(value) {
|
|
837
|
+
set centerY(value: number) {
|
|
839
838
|
this.y = value + this.offsetY - this.height * 0.5;
|
|
840
839
|
}
|
|
841
840
|
|
|
@@ -851,7 +850,7 @@ export class DisplayObject {
|
|
|
851
850
|
* Sets the left x position of this display object.
|
|
852
851
|
* @param {number} value - The new left x position in pixels.
|
|
853
852
|
*/
|
|
854
|
-
set left(value) {
|
|
853
|
+
set left(value: number) {
|
|
855
854
|
this.x = value + this.offsetX;
|
|
856
855
|
}
|
|
857
856
|
|
|
@@ -867,7 +866,7 @@ export class DisplayObject {
|
|
|
867
866
|
* Sets the right x position of this display object.
|
|
868
867
|
* @param {number} value - The new right x position in pixels.
|
|
869
868
|
*/
|
|
870
|
-
set right(value) {
|
|
869
|
+
set right(value: number) {
|
|
871
870
|
this.x = value - this.width + this.offsetX;
|
|
872
871
|
}
|
|
873
872
|
|
|
@@ -883,7 +882,7 @@ export class DisplayObject {
|
|
|
883
882
|
* Sets the top y position of this display object.
|
|
884
883
|
* @param {number} value - The new top y position in pixels.
|
|
885
884
|
*/
|
|
886
|
-
set top(value) {
|
|
885
|
+
set top(value: number) {
|
|
887
886
|
this.y = value + this.offsetY;
|
|
888
887
|
}
|
|
889
888
|
|
|
@@ -899,7 +898,7 @@ export class DisplayObject {
|
|
|
899
898
|
* Sets the bottom y position of this display object.
|
|
900
899
|
* @param {number} value - The new bottom y position in pixels.
|
|
901
900
|
*/
|
|
902
|
-
set bottom(value) {
|
|
901
|
+
set bottom(value: number) {
|
|
903
902
|
this.y = value - this.height + this.offsetY;
|
|
904
903
|
}
|
|
905
904
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import {
|
|
3
2
|
BLEND_NORMAL,
|
|
4
3
|
GEOM_CIRCLE,
|
|
@@ -26,31 +25,37 @@ import { renderGraphics as renderWebGLGraphics } from './webgl/graphics.js';
|
|
|
26
25
|
import { textureFromCanvas } from './webgl/texture_util.js';
|
|
27
26
|
|
|
28
27
|
export class Graphics extends DisplayObject {
|
|
29
|
-
type;
|
|
30
|
-
renderable;
|
|
31
|
-
fillAlpha;
|
|
32
|
-
lineWidth;
|
|
33
|
-
lineColor;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
declare type: any;
|
|
29
|
+
declare renderable: any;
|
|
30
|
+
fillAlpha!: any;
|
|
31
|
+
lineWidth!: any;
|
|
32
|
+
lineColor!: any;
|
|
33
|
+
lineAlpha!: any;
|
|
34
|
+
graphicsData!: any;
|
|
35
|
+
declare tint: any;
|
|
36
|
+
blendMode!: any;
|
|
37
|
+
currentPath!: any;
|
|
38
|
+
_webGL!: any;
|
|
39
|
+
isMask!: any;
|
|
40
|
+
boundsPadding!: any;
|
|
41
|
+
_localBounds!: any;
|
|
42
|
+
dirty!: any;
|
|
43
|
+
clearDirty!: any;
|
|
44
|
+
_boundsDirty!: any;
|
|
45
|
+
_cacheAsBitmap!: any;
|
|
46
|
+
webGLDirty!: any;
|
|
47
|
+
cachedSpriteDirty!: any;
|
|
48
|
+
declare _cachedSprite: any;
|
|
49
|
+
filling!: any;
|
|
50
|
+
fillColor!: any;
|
|
51
|
+
_prevTint!: any;
|
|
47
52
|
/**
|
|
48
53
|
* Creates a new Graphics object.
|
|
49
54
|
* @param {import('../core/game.js').Game} game - The game instance.
|
|
50
55
|
* @param {number} x - The x coordinate of the graphics object.
|
|
51
56
|
* @param {number} y - The y coordinate of the graphics object.
|
|
52
57
|
*/
|
|
53
|
-
constructor(game, x = 0, y = 0) {
|
|
58
|
+
constructor(game: import('../core/game.js').Game, x: number = 0, y: number = 0) {
|
|
54
59
|
super(game);
|
|
55
60
|
/** @type {number} */
|
|
56
61
|
this.type = GRAPHICS;
|
|
@@ -106,7 +111,7 @@ cachedSpriteDirty;
|
|
|
106
111
|
* @param {number} alpha - The alpha (transparency) of the line to draw.
|
|
107
112
|
* @returns {Graphics} This Graphics object for chaining.
|
|
108
113
|
*/
|
|
109
|
-
lineStyle(lineWidth = 0, color = 0, alpha = 1) {
|
|
114
|
+
lineStyle(lineWidth: number = 0, color: number = 0, alpha: number = 1) {
|
|
110
115
|
this.lineWidth = lineWidth || 0;
|
|
111
116
|
this.lineColor = color || 0;
|
|
112
117
|
this.lineAlpha = alpha === undefined ? 1 : alpha;
|
|
@@ -130,7 +135,7 @@ cachedSpriteDirty;
|
|
|
130
135
|
* @param {number} y - The y coordinate to move to.
|
|
131
136
|
* @returns {Graphics} This Graphics object for chaining.
|
|
132
137
|
*/
|
|
133
|
-
moveTo(x, y) {
|
|
138
|
+
moveTo(x: number, y: number) {
|
|
134
139
|
this.drawShape(new Polygon([x, y]));
|
|
135
140
|
return this;
|
|
136
141
|
}
|
|
@@ -141,7 +146,7 @@ cachedSpriteDirty;
|
|
|
141
146
|
* @param {number} y - The y coordinate to draw to.
|
|
142
147
|
* @returns {Graphics} This Graphics object for chaining.
|
|
143
148
|
*/
|
|
144
|
-
lineTo(x, y) {
|
|
149
|
+
lineTo(x: number, y: number) {
|
|
145
150
|
if (!this.currentPath) {
|
|
146
151
|
this.moveTo(0, 0);
|
|
147
152
|
}
|
|
@@ -159,7 +164,7 @@ cachedSpriteDirty;
|
|
|
159
164
|
* @param {number} toY - The y coordinate to draw to.
|
|
160
165
|
* @returns {Graphics} This Graphics object for chaining.
|
|
161
166
|
*/
|
|
162
|
-
quadraticCurveTo(cpX, cpY, toX, toY) {
|
|
167
|
+
quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number) {
|
|
163
168
|
if (this.currentPath) {
|
|
164
169
|
if (this.currentPath.shape.points.length === 0) {
|
|
165
170
|
this.currentPath.shape.points = [0, 0];
|
|
@@ -198,7 +203,7 @@ cachedSpriteDirty;
|
|
|
198
203
|
* @param {number} toY - The y coordinate to draw to.
|
|
199
204
|
* @returns {Graphics} This Graphics object for chaining.
|
|
200
205
|
*/
|
|
201
|
-
bezierCurveTo(cpX, cpY, cpX2, cpY2, toX, toY) {
|
|
206
|
+
bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number) {
|
|
202
207
|
if (this.currentPath) {
|
|
203
208
|
if (this.currentPath.shape.points.length === 0) {
|
|
204
209
|
this.currentPath.shape.points = [0, 0];
|
|
@@ -242,7 +247,7 @@ cachedSpriteDirty;
|
|
|
242
247
|
* @param {number} radius - The radius of the arc.
|
|
243
248
|
* @returns {Graphics} This Graphics object for chaining.
|
|
244
249
|
*/
|
|
245
|
-
arcTo(x1, y1, x2, y2, radius) {
|
|
250
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number) {
|
|
246
251
|
if (this.currentPath) {
|
|
247
252
|
if (this.currentPath.shape.points.length === 0) {
|
|
248
253
|
this.currentPath.shape.points.push(x1, y1);
|
|
@@ -296,7 +301,15 @@ cachedSpriteDirty;
|
|
|
296
301
|
* @param {number} segments - The number of segments to use for drawing the arc.
|
|
297
302
|
* @returns {Graphics} This Graphics object for chaining.
|
|
298
303
|
*/
|
|
299
|
-
arc(
|
|
304
|
+
arc(
|
|
305
|
+
cx: number,
|
|
306
|
+
cy: number,
|
|
307
|
+
radius: number,
|
|
308
|
+
startAngle: number,
|
|
309
|
+
endAngle: number,
|
|
310
|
+
anticlockwise: boolean = false,
|
|
311
|
+
segments: number = 40
|
|
312
|
+
) {
|
|
300
313
|
// If we do this we can never draw a full circle
|
|
301
314
|
if (startAngle === endAngle) {
|
|
302
315
|
return this;
|
|
@@ -345,7 +358,7 @@ cachedSpriteDirty;
|
|
|
345
358
|
* @param {number} alpha - The fill alpha (transparency) to use.
|
|
346
359
|
* @returns {Graphics} This Graphics object for chaining.
|
|
347
360
|
*/
|
|
348
|
-
beginFill(color = 0, alpha = 1) {
|
|
361
|
+
beginFill(color: number = 0, alpha: number = 1) {
|
|
349
362
|
this.filling = true;
|
|
350
363
|
this.fillColor = color || 0;
|
|
351
364
|
this.fillAlpha = alpha === undefined ? 1 : alpha;
|
|
@@ -378,7 +391,7 @@ cachedSpriteDirty;
|
|
|
378
391
|
* @param {number} height - The height of the rectangle.
|
|
379
392
|
* @returns {Graphics} This Graphics object for chaining.
|
|
380
393
|
*/
|
|
381
|
-
drawRect(x, y, width, height) {
|
|
394
|
+
drawRect(x: number, y: number, width: number, height: number) {
|
|
382
395
|
this.drawShape(new Rectangle(x, y, width, height));
|
|
383
396
|
return this;
|
|
384
397
|
}
|
|
@@ -392,7 +405,7 @@ cachedSpriteDirty;
|
|
|
392
405
|
* @param {number} radius - The radius of the rounded corners.
|
|
393
406
|
* @returns {Graphics} This Graphics object for chaining.
|
|
394
407
|
*/
|
|
395
|
-
drawRoundedRect(x, y, width, height, radius) {
|
|
408
|
+
drawRoundedRect(x: number, y: number, width: number, height: number, radius: number) {
|
|
396
409
|
this.drawShape(new RoundedRectangle(x, y, width, height, radius));
|
|
397
410
|
return this;
|
|
398
411
|
}
|
|
@@ -404,7 +417,7 @@ cachedSpriteDirty;
|
|
|
404
417
|
* @param {number} diameter - The diameter of the circle.
|
|
405
418
|
* @returns {Graphics} This Graphics object for chaining.
|
|
406
419
|
*/
|
|
407
|
-
drawCircle(x, y, diameter) {
|
|
420
|
+
drawCircle(x: number, y: number, diameter: number) {
|
|
408
421
|
this.drawShape(new Circle(x, y, diameter));
|
|
409
422
|
return this;
|
|
410
423
|
}
|
|
@@ -417,7 +430,7 @@ cachedSpriteDirty;
|
|
|
417
430
|
* @param {number} height - The height of the ellipse.
|
|
418
431
|
* @returns {Graphics} This Graphics object for chaining.
|
|
419
432
|
*/
|
|
420
|
-
drawEllipse(x, y, width, height) {
|
|
433
|
+
drawEllipse(x: number, y: number, width: number, height: number) {
|
|
421
434
|
this.drawShape(new Ellipse(x, y, width, height));
|
|
422
435
|
return this;
|
|
423
436
|
}
|
|
@@ -427,7 +440,7 @@ cachedSpriteDirty;
|
|
|
427
440
|
* @param {Polygon} path - The polygon to draw.
|
|
428
441
|
* @returns {Graphics} This Graphics object for chaining.
|
|
429
442
|
*/
|
|
430
|
-
drawPolygon(path) {
|
|
443
|
+
drawPolygon(path: Polygon) {
|
|
431
444
|
let points;
|
|
432
445
|
if (path instanceof Polygon) {
|
|
433
446
|
points = path.points;
|
|
@@ -474,7 +487,7 @@ cachedSpriteDirty;
|
|
|
474
487
|
* Renders the graphics object using WebGL.
|
|
475
488
|
* @param {object} renderSession - The render session to use.
|
|
476
489
|
*/
|
|
477
|
-
renderWebGL(renderSession) {
|
|
490
|
+
renderWebGL(renderSession: any) {
|
|
478
491
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
479
492
|
if (this.visible === false || this.alpha === 0 || this.isMask === true) {
|
|
480
493
|
return;
|
|
@@ -488,7 +501,7 @@ cachedSpriteDirty;
|
|
|
488
501
|
this.dirty = false;
|
|
489
502
|
}
|
|
490
503
|
this._cachedSprite.worldAlpha = this.worldAlpha;
|
|
491
|
-
renderSpriteWebGL.call(this._cachedSprite, renderSession);
|
|
504
|
+
(renderSpriteWebGL as any).call(this._cachedSprite, renderSession);
|
|
492
505
|
} else {
|
|
493
506
|
renderSession.spriteBatch.stop();
|
|
494
507
|
renderSession.blendModeManager.setBlendMode(this.blendMode);
|
|
@@ -534,7 +547,7 @@ cachedSpriteDirty;
|
|
|
534
547
|
* Renders the graphics object using Canvas.
|
|
535
548
|
* @param {object} renderSession - The render session to use.
|
|
536
549
|
*/
|
|
537
|
-
renderCanvas(renderSession) {
|
|
550
|
+
renderCanvas(renderSession: any) {
|
|
538
551
|
// if the sprite is not visible or the alpha is 0 then no need to render this element
|
|
539
552
|
if (this.visible === false || this.alpha === 0 || this.isMask === true) {
|
|
540
553
|
return;
|
|
@@ -591,7 +604,7 @@ cachedSpriteDirty;
|
|
|
591
604
|
* @param {import('../geom/matrix.js').Matrix} matrix - The transformation matrix to use.
|
|
592
605
|
* @returns {Rectangle} The bounds rectangle of the graphics object.
|
|
593
606
|
*/
|
|
594
|
-
getBounds(matrix = null) {
|
|
607
|
+
getBounds(matrix: import('../geom/matrix.js').Matrix = null) {
|
|
595
608
|
if (!this.renderable) {
|
|
596
609
|
return getEmptyRectangle();
|
|
597
610
|
}
|
|
@@ -671,7 +684,7 @@ cachedSpriteDirty;
|
|
|
671
684
|
* @param {Point} tempPoint - A temporary point object to use.
|
|
672
685
|
* @returns {boolean} True if the graphics object contains the point, otherwise false.
|
|
673
686
|
*/
|
|
674
|
-
containsPoint(point, tempPoint) {
|
|
687
|
+
containsPoint(point: Point, tempPoint: Point) {
|
|
675
688
|
this.worldTransform.applyInverse(point, tempPoint);
|
|
676
689
|
const graphicsData = this.graphicsData;
|
|
677
690
|
for (let i = 0; i < graphicsData.length; i += 0) {
|
|
@@ -827,7 +840,7 @@ cachedSpriteDirty;
|
|
|
827
840
|
* @param {object} shape - The shape to draw.
|
|
828
841
|
* @returns {GraphicsData} The graphics data for the drawn shape.
|
|
829
842
|
*/
|
|
830
|
-
drawShape(shape) {
|
|
843
|
+
drawShape(shape: any) {
|
|
831
844
|
if (this.currentPath) {
|
|
832
845
|
// check current path!
|
|
833
846
|
if (this.currentPath.shape.points.length <= 2) {
|
|
@@ -877,14 +890,14 @@ cachedSpriteDirty;
|
|
|
877
890
|
* @param {Point[]} points - The points of the triangle.
|
|
878
891
|
* @param {boolean} cull - Whether to perform backface culling.
|
|
879
892
|
*/
|
|
880
|
-
drawTriangle(points, cull = false) {
|
|
893
|
+
drawTriangle(points: Point[], cull: boolean = false) {
|
|
881
894
|
const triangle = new Polygon(points);
|
|
882
895
|
if (cull) {
|
|
883
896
|
const cameraToFace = new Point(0 - points[0].x, 0 - points[0].y);
|
|
884
897
|
const ab = new Point(points[1].x - points[0].x, points[1].y - points[0].y);
|
|
885
898
|
const cb = new Point(points[1].x - points[2].x, points[1].y - points[2].y);
|
|
886
899
|
const faceNormal = cb.cross(ab);
|
|
887
|
-
if (cameraToFace.dot(faceNormal) > 0) {
|
|
900
|
+
if (cameraToFace.dot(faceNormal as any) > 0) {
|
|
888
901
|
this.drawPolygon(triangle);
|
|
889
902
|
}
|
|
890
903
|
} else {
|
|
@@ -898,7 +911,7 @@ cachedSpriteDirty;
|
|
|
898
911
|
* @param {number[]} indices - The indices of the vertices to use.
|
|
899
912
|
* @param {boolean} cull - Whether to perform backface culling.
|
|
900
913
|
*/
|
|
901
|
-
drawTriangles(vertices, indices, cull = false) {
|
|
914
|
+
drawTriangles(vertices: any, indices: number[], cull: boolean = false) {
|
|
902
915
|
const point1 = new Point();
|
|
903
916
|
const point2 = new Point();
|
|
904
917
|
const point3 = new Point();
|
|
@@ -934,7 +947,7 @@ cachedSpriteDirty;
|
|
|
934
947
|
for (i = 0; i < indices.length; i += 1) {
|
|
935
948
|
point1.x = vertices[indices[i] * 2];
|
|
936
949
|
point1.y = vertices[indices[i] * 2 + 1];
|
|
937
|
-
points.push(point1.copyTo({}));
|
|
950
|
+
points.push(point1.copyTo({} as any));
|
|
938
951
|
if (points.length === 3) {
|
|
939
952
|
this.drawTriangle(points, cull);
|
|
940
953
|
points = [];
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { clone } from './graphics_data_util.js';
|
|
3
2
|
|
|
4
3
|
export class GraphicsData {
|
|
5
|
-
lineWidth;
|
|
6
|
-
lineColor;
|
|
7
|
-
lineAlpha;
|
|
8
|
-
_lineTint;
|
|
9
|
-
fillColor;
|
|
10
|
-
fillAlpha;
|
|
11
|
-
_fillTint;
|
|
12
|
-
fill;
|
|
13
|
-
shape;
|
|
14
|
-
type;
|
|
4
|
+
lineWidth!: any;
|
|
5
|
+
lineColor!: any;
|
|
6
|
+
lineAlpha!: any;
|
|
7
|
+
_lineTint!: any;
|
|
8
|
+
fillColor!: any;
|
|
9
|
+
fillAlpha!: any;
|
|
10
|
+
_fillTint!: any;
|
|
11
|
+
fill!: any;
|
|
12
|
+
shape!: any;
|
|
13
|
+
type!: any;
|
|
15
14
|
/**
|
|
16
15
|
* Creates a new GraphicsData object.
|
|
17
16
|
* @param {number} lineWidth - The line width.
|
|
@@ -22,7 +21,7 @@ type;
|
|
|
22
21
|
* @param {boolean} fill - Whether to fill the shape.
|
|
23
22
|
* @param {object} shape - The shape to draw.
|
|
24
23
|
*/
|
|
25
|
-
constructor(lineWidth, lineColor, lineAlpha, fillColor, fillAlpha, fill, shape) {
|
|
24
|
+
constructor(lineWidth: number, lineColor: number, lineAlpha: number, fillColor: number, fillAlpha: number, fill: boolean, shape: any) {
|
|
26
25
|
this.lineWidth = lineWidth;
|
|
27
26
|
this.lineColor = lineColor;
|
|
28
27
|
this.lineAlpha = lineAlpha;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { GraphicsData } from './graphics_data.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -6,7 +5,7 @@ import { GraphicsData } from './graphics_data.js';
|
|
|
6
5
|
* @param {GraphicsData} source - The source GraphicsData to clone.
|
|
7
6
|
* @returns {GraphicsData} A new cloned GraphicsData object.
|
|
8
7
|
*/
|
|
9
|
-
export const clone = (source) => {
|
|
8
|
+
export const clone = (source: GraphicsData) => {
|
|
10
9
|
return new GraphicsData(
|
|
11
10
|
source.lineWidth,
|
|
12
11
|
source.lineColor,
|