@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 { BUTTON, POINTER_CONTACT } from '../core/const.js';
|
|
3
2
|
import { InputHandler } from '../core/input_handler.js';
|
|
4
3
|
import { Signal } from '../core/signal.js';
|
|
@@ -11,34 +10,20 @@ const STATE_UP = 'Up';
|
|
|
11
10
|
const STATE_DISABLED = 'Disabled';
|
|
12
11
|
|
|
13
12
|
export class Button extends Image {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/** @type {Signal} */
|
|
29
|
-
onInputDown;
|
|
30
|
-
/** @type {Signal} */
|
|
31
|
-
onInputUp;
|
|
32
|
-
/** @type {boolean} */
|
|
33
|
-
onOverMouseOnly;
|
|
34
|
-
/** @type {number} */
|
|
35
|
-
justReleasedPreventsOver;
|
|
36
|
-
/** @type {boolean} */
|
|
37
|
-
freezeFrames;
|
|
38
|
-
/** @type {boolean} */
|
|
39
|
-
forceOut;
|
|
40
|
-
/** @type {InputHandler} */
|
|
41
|
-
input;
|
|
13
|
+
_onOverFrame!: string | null;
|
|
14
|
+
_onOutFrame!: string | null;
|
|
15
|
+
_onDownFrame!: string | null;
|
|
16
|
+
_onUpFrame!: string | null;
|
|
17
|
+
_onDisabledFrame!: string | null;
|
|
18
|
+
onInputOver!: Signal;
|
|
19
|
+
onInputOut!: Signal;
|
|
20
|
+
onInputDown!: Signal;
|
|
21
|
+
onInputUp!: Signal;
|
|
22
|
+
onOverMouseOnly!: boolean;
|
|
23
|
+
justReleasedPreventsOver!: number;
|
|
24
|
+
freezeFrames!: boolean;
|
|
25
|
+
forceOut!: any;
|
|
26
|
+
input!: InputHandler;
|
|
42
27
|
/**
|
|
43
28
|
* Creates a new Button instance.
|
|
44
29
|
* @param {import('../core/game.js').Game} game - The game instance this button belongs to.
|
|
@@ -53,19 +38,7 @@ export class Button extends Image {
|
|
|
53
38
|
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
54
39
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
55
40
|
*/
|
|
56
|
-
constructor(
|
|
57
|
-
game,
|
|
58
|
-
x = 0,
|
|
59
|
-
y = 0,
|
|
60
|
-
key = null,
|
|
61
|
-
callback = null,
|
|
62
|
-
callbackContext = null,
|
|
63
|
-
overFrame = null,
|
|
64
|
-
outFrame = null,
|
|
65
|
-
downFrame = null,
|
|
66
|
-
upFrame = null,
|
|
67
|
-
disabledFrame = null
|
|
68
|
-
) {
|
|
41
|
+
constructor(game: import('../core/game.js').Game, x: number = 0, y: number = 0, key: string = null, callback: Function = null, callbackContext: any = null, overFrame: string = null, outFrame: string = null, downFrame: string = null, upFrame: string = null, disabledFrame: string = null) {
|
|
69
42
|
super(game, x, y, key, outFrame);
|
|
70
43
|
this.type = BUTTON;
|
|
71
44
|
this._onOverFrame = null;
|
|
@@ -126,7 +99,7 @@ export class Button extends Image {
|
|
|
126
99
|
* @param {boolean} isEnabled - Whether the button should be enabled (true) or disabled (false).
|
|
127
100
|
* @param {boolean} isImmediate - Whether to change the state immediately or with a delay (default: false).
|
|
128
101
|
*/
|
|
129
|
-
setEnabled(isEnabled, isImmediate = false) {
|
|
102
|
+
setEnabled(isEnabled: boolean, isImmediate: boolean = false) {
|
|
130
103
|
this.input.enabled = isEnabled;
|
|
131
104
|
if (isImmediate) {
|
|
132
105
|
this.changeStateFrame(isEnabled ? STATE_UP : STATE_DISABLED);
|
|
@@ -157,7 +130,7 @@ export class Button extends Image {
|
|
|
157
130
|
* @param {string} frame - The frame identifier to set for this state.
|
|
158
131
|
* @param {boolean} switchImmediately - Whether to switch to the new frame immediately (default: false).
|
|
159
132
|
*/
|
|
160
|
-
setStateFrame(state, frame, switchImmediately = false) {
|
|
133
|
+
setStateFrame(state: string, frame: string, switchImmediately: boolean = false) {
|
|
161
134
|
const frameKey = `_on${state}Frame`;
|
|
162
135
|
if (frame) {
|
|
163
136
|
this[frameKey] = frame;
|
|
@@ -174,7 +147,7 @@ export class Button extends Image {
|
|
|
174
147
|
* @param {string} newState - The new state to change to (Over, Out, Down, Up, Disabled).
|
|
175
148
|
* @returns {boolean} True if the frame was changed, false otherwise.
|
|
176
149
|
*/
|
|
177
|
-
changeStateFrame(newState) {
|
|
150
|
+
changeStateFrame(newState: string) {
|
|
178
151
|
if (this.freezeFrames) {
|
|
179
152
|
return false;
|
|
180
153
|
}
|
|
@@ -199,7 +172,7 @@ export class Button extends Image {
|
|
|
199
172
|
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
200
173
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
201
174
|
*/
|
|
202
|
-
setFrames(overFrame, outFrame, downFrame, upFrame, disabledFrame = null) {
|
|
175
|
+
setFrames(overFrame: string, outFrame: string, downFrame: string, upFrame: string, disabledFrame: string = null) {
|
|
203
176
|
this.setStateFrame(STATE_OVER, overFrame, this.input.pointerOver());
|
|
204
177
|
this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
|
|
205
178
|
this.setStateFrame(STATE_DOWN, downFrame, this.input.pointerDown());
|
|
@@ -214,7 +187,7 @@ export class Button extends Image {
|
|
|
214
187
|
* @param {object} sprite - The sprite that triggered the event.
|
|
215
188
|
* @param {object} pointer - The pointer that triggered the event.
|
|
216
189
|
*/
|
|
217
|
-
onInputOverHandler(sprite, pointer) {
|
|
190
|
+
onInputOverHandler(sprite: any, pointer: any) {
|
|
218
191
|
if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
|
|
219
192
|
// If the Pointer was only just released then we don't fire an over event
|
|
220
193
|
return;
|
|
@@ -233,7 +206,7 @@ export class Button extends Image {
|
|
|
233
206
|
* @param {object} sprite - The sprite that triggered the event.
|
|
234
207
|
* @param {object} pointer - The pointer that triggered the event.
|
|
235
208
|
*/
|
|
236
|
-
onInputOutHandler(sprite, pointer) {
|
|
209
|
+
onInputOutHandler(sprite: any, pointer: any) {
|
|
237
210
|
this.changeStateFrame(STATE_OUT);
|
|
238
211
|
if (this.onInputOut) {
|
|
239
212
|
this.onInputOut.dispatch(this, pointer);
|
|
@@ -245,7 +218,7 @@ export class Button extends Image {
|
|
|
245
218
|
* @param {object} sprite - The sprite that triggered the event.
|
|
246
219
|
* @param {object} pointer - The pointer that triggered the event.
|
|
247
220
|
*/
|
|
248
|
-
onInputDownHandler(sprite, pointer) {
|
|
221
|
+
onInputDownHandler(sprite: any, pointer: any) {
|
|
249
222
|
this.changeStateFrame(STATE_DOWN);
|
|
250
223
|
if (this.onInputDown) {
|
|
251
224
|
this.onInputDown.dispatch(this, pointer);
|
|
@@ -258,7 +231,7 @@ export class Button extends Image {
|
|
|
258
231
|
* @param {object} pointer - The pointer that triggered the event.
|
|
259
232
|
* @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
|
|
260
233
|
*/
|
|
261
|
-
onInputUpHandler(sprite, pointer, isOver) {
|
|
234
|
+
onInputUpHandler(sprite: any, pointer: any, isOver: boolean) {
|
|
262
235
|
if (this.onInputUp) {
|
|
263
236
|
this.onInputUp.dispatch(this, pointer, isOver);
|
|
264
237
|
}
|
|
@@ -292,7 +265,7 @@ export class Button extends Image {
|
|
|
292
265
|
* Sets whether input is currently enabled for this button.
|
|
293
266
|
* @param {boolean} value - Whether to enable (true) or disable (false) input.
|
|
294
267
|
*/
|
|
295
|
-
set inputEnabled(value) {
|
|
268
|
+
set inputEnabled(value: boolean) {
|
|
296
269
|
if (value) {
|
|
297
270
|
if (this.input === null) {
|
|
298
271
|
this.input = new InputHandler(this);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { create, removeByCanvas } from './pool.js';
|
|
3
2
|
|
|
4
3
|
export class CanvasBuffer {
|
|
5
|
-
width;
|
|
6
|
-
height;
|
|
7
|
-
canvas;
|
|
8
|
-
context;
|
|
4
|
+
width!: any;
|
|
5
|
+
height!: any;
|
|
6
|
+
canvas!: any;
|
|
7
|
+
context!: any;
|
|
9
8
|
/**
|
|
10
9
|
* Creates a new CanvasBuffer instance.
|
|
11
10
|
* @param {number} width - The width of the canvas buffer.
|
|
12
11
|
* @param {number} height - The height of the canvas buffer.
|
|
13
12
|
*/
|
|
14
|
-
constructor(width, height) {
|
|
13
|
+
constructor(width: number, height: number) {
|
|
15
14
|
this.width = width;
|
|
16
15
|
this.height = height;
|
|
17
16
|
this.canvas = create(this, this.width, this.height);
|
|
@@ -33,7 +32,7 @@ context;
|
|
|
33
32
|
* @param {number} width - The new width of the canvas buffer.
|
|
34
33
|
* @param {number} height - The new height of the canvas buffer.
|
|
35
34
|
*/
|
|
36
|
-
resize(width, height) {
|
|
35
|
+
resize(width: number, height: number) {
|
|
37
36
|
this.width = width;
|
|
38
37
|
this.height = height;
|
|
39
38
|
this.canvas.width = width;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { GEOM_CIRCLE, GEOM_ELLIPSE, GEOM_POLYGON, GEOM_RECTANGLE, GEOM_ROUNDED_RECTANGLE } from '../../core/const.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Renders a graphics object to canvas.
|
|
6
5
|
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
7
6
|
*/
|
|
8
|
-
export const updateGraphicsTint = (graphics) => {
|
|
7
|
+
export const updateGraphicsTint = (graphics: import('../graphics.js').Graphics) => {
|
|
9
8
|
if (graphics.tint === 0xffffff) {
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
@@ -32,7 +31,7 @@ export const updateGraphicsTint = (graphics) => {
|
|
|
32
31
|
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
33
32
|
* @param {object} context - The canvas rendering context.
|
|
34
33
|
*/
|
|
35
|
-
export const renderGraphics = (graphics, context) => {
|
|
34
|
+
export const renderGraphics = (graphics: import('../graphics.js').Graphics, context: any) => {
|
|
36
35
|
const worldAlpha = graphics.worldAlpha;
|
|
37
36
|
if (graphics.dirty) {
|
|
38
37
|
updateGraphicsTint(graphics);
|
|
@@ -161,7 +160,7 @@ export const renderGraphics = (graphics, context) => {
|
|
|
161
160
|
* @param {import('../graphics.js').Graphics} graphics - The graphics object to render.
|
|
162
161
|
* @param {object} context - The canvas rendering context.
|
|
163
162
|
*/
|
|
164
|
-
export const renderGraphicsMask = (graphics, context) => {
|
|
163
|
+
export const renderGraphicsMask = (graphics: import('../graphics.js').Graphics, context: any) => {
|
|
165
164
|
const len = graphics.graphicsData.length;
|
|
166
165
|
if (len === 0) {
|
|
167
166
|
return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { renderGraphicsMask } from './graphics.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -6,7 +5,7 @@ import { renderGraphicsMask } from './graphics.js';
|
|
|
6
5
|
* @param {object} maskData - The mask data to apply.
|
|
7
6
|
* @param {object} renderSession - The rendering session object.
|
|
8
7
|
*/
|
|
9
|
-
export const pushMask = (maskData, renderSession) => {
|
|
8
|
+
export const pushMask = (maskData: any, renderSession: any) => {
|
|
10
9
|
const context = renderSession.context;
|
|
11
10
|
context.save();
|
|
12
11
|
const cacheAlpha = maskData.alpha;
|
|
@@ -29,6 +28,6 @@ export const pushMask = (maskData, renderSession) => {
|
|
|
29
28
|
* Pops a mask from the rendering stack.
|
|
30
29
|
* @param {object} renderSession - The rendering session object.
|
|
31
30
|
*/
|
|
32
|
-
export const popMask = (renderSession) => {
|
|
31
|
+
export const popMask = (renderSession: any) => {
|
|
33
32
|
renderSession.context.restore();
|
|
34
33
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* Gets the canvas pool array.
|
|
4
3
|
* @returns {{canvas: HTMLCanvasElement, parent: object}[]} The canvas pool array.
|
|
@@ -31,7 +30,7 @@ export const getFirst = () => {
|
|
|
31
30
|
* Adds a canvas to the pool with the specified parent.
|
|
32
31
|
* @param {object} parent - The parent object for the canvas.
|
|
33
32
|
*/
|
|
34
|
-
export const remove = (parent) => {
|
|
33
|
+
export const remove = (parent: any) => {
|
|
35
34
|
const pool = getPool();
|
|
36
35
|
for (let i = 0; i < pool.length; i += 1) {
|
|
37
36
|
if (pool[i].parent === parent) {
|
|
@@ -46,7 +45,7 @@ export const remove = (parent) => {
|
|
|
46
45
|
* Removes a canvas from the pool.
|
|
47
46
|
* @param {HTMLCanvasElement} canvas - The canvas to remove from the pool.
|
|
48
47
|
*/
|
|
49
|
-
export const removeByCanvas = (canvas) => {
|
|
48
|
+
export const removeByCanvas = (canvas: HTMLCanvasElement) => {
|
|
50
49
|
const pool = getPool();
|
|
51
50
|
for (let i = 0; i < pool.length; i += 1) {
|
|
52
51
|
if (pool[i].canvas === canvas) {
|
|
@@ -95,7 +94,7 @@ export const getFree = () => {
|
|
|
95
94
|
* @param {boolean} skipPool - True to skip using the pool and create a new canvas.
|
|
96
95
|
* @returns {HTMLCanvasElement} The canvas from the pool or a newly created one.
|
|
97
96
|
*/
|
|
98
|
-
export const create = (parent, width, height, skipPool = false) => {
|
|
97
|
+
export const create = (parent: any, width?: any, height?: any, skipPool: boolean = false) => {
|
|
99
98
|
if (parent === undefined) {
|
|
100
99
|
console.warn('Created CanvasPool element with undefined parent.');
|
|
101
100
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import {
|
|
3
2
|
BLEND_ADD,
|
|
4
3
|
BLEND_COLOR,
|
|
@@ -27,24 +26,24 @@ import { detectCapabilities } from './tinter.js';
|
|
|
27
26
|
import { getSmoothingPrefix } from './util.js';
|
|
28
27
|
|
|
29
28
|
export class CanvasRenderer {
|
|
30
|
-
type;
|
|
31
|
-
resolution;
|
|
32
|
-
clearBeforeRender;
|
|
33
|
-
transparent;
|
|
34
|
-
autoResize;
|
|
35
|
-
contextLost;
|
|
36
|
-
width;
|
|
37
|
-
height;
|
|
38
|
-
view;
|
|
39
|
-
context;
|
|
40
|
-
refresh;
|
|
41
|
-
count;
|
|
42
|
-
renderSession;
|
|
29
|
+
type!: any;
|
|
30
|
+
resolution!: any;
|
|
31
|
+
clearBeforeRender!: any;
|
|
32
|
+
transparent!: any;
|
|
33
|
+
autoResize!: any;
|
|
34
|
+
contextLost!: any;
|
|
35
|
+
width!: any;
|
|
36
|
+
height!: any;
|
|
37
|
+
view!: any;
|
|
38
|
+
context!: any;
|
|
39
|
+
refresh!: any;
|
|
40
|
+
count!: any;
|
|
41
|
+
renderSession!: any;
|
|
43
42
|
/**
|
|
44
43
|
* Creates a new CanvasRenderer instance.
|
|
45
44
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
46
45
|
*/
|
|
47
|
-
constructor(game) {
|
|
46
|
+
constructor(game: import('../../core/game.js').Game) {
|
|
48
47
|
detectCapabilities(game);
|
|
49
48
|
/** @type {number} */
|
|
50
49
|
this.type = RENDER_CANVAS;
|
|
@@ -79,7 +78,7 @@ renderSession;
|
|
|
79
78
|
* Renders the stage to canvas.
|
|
80
79
|
* @param {import('../../core/stage.js').Stage} root - The root stage to render.
|
|
81
80
|
*/
|
|
82
|
-
render(root) {
|
|
81
|
+
render(root: import('../../core/stage.js').Stage) {
|
|
83
82
|
if (!this.context) {
|
|
84
83
|
return;
|
|
85
84
|
}
|
|
@@ -104,7 +103,7 @@ renderSession;
|
|
|
104
103
|
* Destroys this renderer and cleans up resources.
|
|
105
104
|
* @param {boolean} removeView - Whether to remove the view from the DOM.
|
|
106
105
|
*/
|
|
107
|
-
destroy(removeView = true) {
|
|
106
|
+
destroy(removeView: boolean = true) {
|
|
108
107
|
if (removeView && this.view.parent) {
|
|
109
108
|
this.view.parent.removeChild(this.view);
|
|
110
109
|
}
|
|
@@ -118,7 +117,7 @@ renderSession;
|
|
|
118
117
|
* @param {number} width - The new width of the canvas.
|
|
119
118
|
* @param {number} height - The new height of the canvas.
|
|
120
119
|
*/
|
|
121
|
-
resize(width, height) {
|
|
120
|
+
resize(width: number, height: number) {
|
|
122
121
|
this.width = width * this.resolution;
|
|
123
122
|
this.height = height * this.resolution;
|
|
124
123
|
this.view.width = this.width;
|
|
@@ -138,7 +137,7 @@ renderSession;
|
|
|
138
137
|
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
139
138
|
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
140
139
|
*/
|
|
141
|
-
renderDisplayObject(displayObject, context, matrix) {
|
|
140
|
+
renderDisplayObject(displayObject: any, context?: any, matrix?: any) {
|
|
142
141
|
this.renderSession.context = context || this.context;
|
|
143
142
|
this.renderSession.resolution = this.resolution;
|
|
144
143
|
displayObject.renderCanvas(this.renderSession, matrix);
|
|
@@ -177,7 +176,7 @@ renderSession;
|
|
|
177
176
|
* Initializes the WebGL context for rendering.
|
|
178
177
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
179
178
|
*/
|
|
180
|
-
initContext(game) {
|
|
179
|
+
initContext(game: import('../../core/game.js').Game) {
|
|
181
180
|
// stub
|
|
182
181
|
}
|
|
183
182
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT, ENGINE_ERROR_GETTING_DOCUMENT } from '../../core/error_code.js';
|
|
3
2
|
import { hex2rgb } from '../../util/math.js';
|
|
4
3
|
import { create, removeByCanvas } from './pool.js';
|
|
@@ -9,7 +8,7 @@ import { create, removeByCanvas } from './pool.js';
|
|
|
9
8
|
* @param {object} color - The color to tint with.
|
|
10
9
|
* @returns {object} The tinted sprite.
|
|
11
10
|
*/
|
|
12
|
-
export const getTintedTexture = (sprite, color) => {
|
|
11
|
+
export const getTintedTexture = (sprite: any, color: any) => {
|
|
13
12
|
const canvas = sprite.tintedTexture || create('CanvasTinter', 1, 1);
|
|
14
13
|
window.PhaserRegistry.CANVAS_TINT_METHOD(sprite.texture, color, canvas);
|
|
15
14
|
return canvas;
|
|
@@ -22,7 +21,7 @@ export const getTintedTexture = (sprite, color) => {
|
|
|
22
21
|
* @param {HTMLCanvasElement} canvas - The canvas to render to.
|
|
23
22
|
* @throws {Error} If the operation fails.
|
|
24
23
|
*/
|
|
25
|
-
export const tintWithMultiply = (texture, color, canvas) => {
|
|
24
|
+
export const tintWithMultiply = (texture: any, color: any, canvas: HTMLCanvasElement) => {
|
|
26
25
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
27
26
|
if (!context) {
|
|
28
27
|
throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
|
|
@@ -48,7 +47,7 @@ export const tintWithMultiply = (texture, color, canvas) => {
|
|
|
48
47
|
* @param {HTMLCanvasElement} canvas - The canvas to render to.
|
|
49
48
|
* @throws {Error} If the operation fails.
|
|
50
49
|
*/
|
|
51
|
-
export const tintWithPerPixel = (texture, color, canvas) => {
|
|
50
|
+
export const tintWithPerPixel = (texture: any, color: any, canvas: HTMLCanvasElement) => {
|
|
52
51
|
const context = canvas.getContext('2d', { willReadFrequently: false });
|
|
53
52
|
if (!context) {
|
|
54
53
|
throw new Error(ENGINE_ERROR_CREATING_CANVAS_2D_CONTEXT);
|
|
@@ -167,7 +166,7 @@ export const canUseNewCanvasBlendModes = () => {
|
|
|
167
166
|
* Creates a new Tinter instance.
|
|
168
167
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
169
168
|
*/
|
|
170
|
-
export const detectCapabilities = (game) => {
|
|
169
|
+
export const detectCapabilities = (game: import('../../core/game.js').Game) => {
|
|
171
170
|
if (!window.PhaserRegistry) {
|
|
172
171
|
window.PhaserRegistry = {};
|
|
173
172
|
}
|
|
@@ -9,7 +9,7 @@ import { create as createCanvas } from './pool.js';
|
|
|
9
9
|
* @param {boolean} skipPool - Whether to skip using the canvas pool.
|
|
10
10
|
* @returns {HTMLCanvasElement} The created HTML canvas element.
|
|
11
11
|
*/
|
|
12
|
-
export const create = (parent, width, height, id, skipPool) => {
|
|
12
|
+
export const create = (parent: any, width: number, height: number, id: string, skipPool: boolean) => {
|
|
13
13
|
width = width || 256;
|
|
14
14
|
height = height || 256;
|
|
15
15
|
const canvas = skipPool ? document.createElement('canvas') : createCanvas(parent, width, height);
|
|
@@ -28,7 +28,7 @@ export const create = (parent, width, height, id, skipPool) => {
|
|
|
28
28
|
* @param {string} color - The background color to set.
|
|
29
29
|
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
30
30
|
*/
|
|
31
|
-
export const setBackgroundColor = (canvas, color) => {
|
|
31
|
+
export const setBackgroundColor = (canvas: HTMLCanvasElement, color: string) => {
|
|
32
32
|
color = color || 'rgb(0,0,0)';
|
|
33
33
|
canvas.style.backgroundColor = color;
|
|
34
34
|
return canvas;
|
|
@@ -40,7 +40,7 @@ export const setBackgroundColor = (canvas, color) => {
|
|
|
40
40
|
* @param {string} value - The touch action value to set.
|
|
41
41
|
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
42
42
|
*/
|
|
43
|
-
export const setTouchAction = (canvas, value = 'none') => {
|
|
43
|
+
export const setTouchAction = (canvas: HTMLCanvasElement, value: string = 'none') => {
|
|
44
44
|
value = value || 'none';
|
|
45
45
|
// @ts-ignore
|
|
46
46
|
canvas.style.msTouchAction = value;
|
|
@@ -55,7 +55,7 @@ export const setTouchAction = (canvas, value = 'none') => {
|
|
|
55
55
|
* @param {string} value - The user select value to set.
|
|
56
56
|
* @returns {HTMLCanvasElement} The modified canvas element.
|
|
57
57
|
*/
|
|
58
|
-
export const setUserSelect = (canvas, value = 'none') => {
|
|
58
|
+
export const setUserSelect = (canvas: HTMLCanvasElement, value: string = 'none') => {
|
|
59
59
|
value = value || 'none';
|
|
60
60
|
canvas.style['-webkit-touch-callout'] = value;
|
|
61
61
|
canvas.style['-webkit-user-select'] = value;
|
|
@@ -74,7 +74,7 @@ export const setUserSelect = (canvas, value = 'none') => {
|
|
|
74
74
|
* @param {boolean} overflowHidden - Whether to set overflow hidden on the parent.
|
|
75
75
|
* @returns {HTMLCanvasElement} The added canvas element.
|
|
76
76
|
*/
|
|
77
|
-
export const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
77
|
+
export const addToDOM = (canvas: HTMLCanvasElement, parent: any, overflowHidden: boolean = true) => {
|
|
78
78
|
let target;
|
|
79
79
|
if (parent) {
|
|
80
80
|
if (typeof parent === 'string') {
|
|
@@ -100,7 +100,7 @@ export const addToDOM = (canvas, parent, overflowHidden = true) => {
|
|
|
100
100
|
* Removes a canvas element from the DOM.
|
|
101
101
|
* @param {HTMLCanvasElement} canvas - The canvas element to remove.
|
|
102
102
|
*/
|
|
103
|
-
export const removeFromDOM = (canvas) => {
|
|
103
|
+
export const removeFromDOM = (canvas: HTMLCanvasElement) => {
|
|
104
104
|
if (canvas && canvas.parentNode) {
|
|
105
105
|
canvas.parentNode.removeChild(canvas);
|
|
106
106
|
}
|
|
@@ -117,7 +117,7 @@ export const removeFromDOM = (canvas) => {
|
|
|
117
117
|
* @param {number} skewY - The Y skew value.
|
|
118
118
|
* @returns {CanvasRenderingContext2D} The modified rendering context.
|
|
119
119
|
*/
|
|
120
|
-
export const setTransform = (context, translateX, translateY, scaleX, scaleY, skewX, skewY) => {
|
|
120
|
+
export const setTransform = (context: CanvasRenderingContext2D, translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number) => {
|
|
121
121
|
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
|
122
122
|
return context;
|
|
123
123
|
};
|
|
@@ -127,7 +127,7 @@ export const setTransform = (context, translateX, translateY, scaleX, scaleY, sk
|
|
|
127
127
|
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
128
128
|
* @returns {string | null} The smoothing property name or null if not found.
|
|
129
129
|
*/
|
|
130
|
-
export const getSmoothingPrefix = (context) => {
|
|
130
|
+
export const getSmoothingPrefix = (context: CanvasRenderingContext2D) => {
|
|
131
131
|
const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
|
|
132
132
|
for (let i = 0; i < VENDORS.length; i += 1) {
|
|
133
133
|
const s = `${VENDORS[i]}mageSmoothingEnabled`;
|
|
@@ -144,7 +144,7 @@ export const getSmoothingPrefix = (context) => {
|
|
|
144
144
|
* @param {number} value - The smoothing enabled value to set.
|
|
145
145
|
* @returns {object} The modified rendering context.
|
|
146
146
|
*/
|
|
147
|
-
export const setSmoothingEnabled = (context, value) => {
|
|
147
|
+
export const setSmoothingEnabled = (context: any, value: number) => {
|
|
148
148
|
const s = getSmoothingPrefix(context);
|
|
149
149
|
if (s) {
|
|
150
150
|
context[s] = value;
|