@vpmedia/phaser 1.104.0 → 1.106.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.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +164 -592
- 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 +38 -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 +13 -13
- package/src/index.ts +8 -0
- package/src/phaser/core/animation.ts +46 -61
- package/src/phaser/core/animation_manager.ts +27 -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 +24 -25
- 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 +72 -68
- package/src/phaser/core/input_handler.ts +93 -84
- 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 +108 -70
- package/src/phaser/core/loader_parser.ts +24 -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 +16 -10
- package/src/phaser/core/signal_binding.ts +9 -2
- package/src/phaser/core/sound.ts +71 -112
- package/src/phaser/core/sound_manager.ts +31 -30
- package/src/phaser/core/sound_sprite.ts +11 -12
- package/src/phaser/core/stage.ts +8 -8
- package/src/phaser/core/time.ts +34 -35
- package/src/phaser/core/timer.ts +40 -34
- package/src/phaser/core/timer_event.ts +23 -23
- package/src/phaser/core/tween.ts +62 -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 +11 -12
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -31
- package/src/phaser/display/button.ts +34 -49
- 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 +17 -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 +19 -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 +38 -52
- package/src/phaser/display/sprite_batch.ts +1 -2
- package/src/phaser/display/sprite_util.ts +17 -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 +44 -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 +17 -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 +18 -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 +20 -8
- package/src/phaser/display/webgl/texture.ts +40 -24
- package/src/phaser/display/webgl/texture_util.ts +2 -3
- package/src/phaser/display/webgl/util.ts +10 -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 +27 -20
- package/src/phaser/geom/util/polygon.ts +1 -1
- package/src/phaser/geom/util/rectangle.ts +22 -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.
|
|
@@ -54,17 +39,17 @@ export class Button extends Image {
|
|
|
54
39
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
55
40
|
*/
|
|
56
41
|
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
|
|
42
|
+
game: import('../core/game.js').Game,
|
|
43
|
+
x: number = 0,
|
|
44
|
+
y: number = 0,
|
|
45
|
+
key: string = null,
|
|
46
|
+
callback: Function = null,
|
|
47
|
+
callbackContext: any = null,
|
|
48
|
+
overFrame: string = null,
|
|
49
|
+
outFrame: string = null,
|
|
50
|
+
downFrame: string = null,
|
|
51
|
+
upFrame: string = null,
|
|
52
|
+
disabledFrame: string = null
|
|
68
53
|
) {
|
|
69
54
|
super(game, x, y, key, outFrame);
|
|
70
55
|
this.type = BUTTON;
|
|
@@ -126,7 +111,7 @@ export class Button extends Image {
|
|
|
126
111
|
* @param {boolean} isEnabled - Whether the button should be enabled (true) or disabled (false).
|
|
127
112
|
* @param {boolean} isImmediate - Whether to change the state immediately or with a delay (default: false).
|
|
128
113
|
*/
|
|
129
|
-
setEnabled(isEnabled, isImmediate = false) {
|
|
114
|
+
setEnabled(isEnabled: boolean, isImmediate: boolean = false) {
|
|
130
115
|
this.input.enabled = isEnabled;
|
|
131
116
|
if (isImmediate) {
|
|
132
117
|
this.changeStateFrame(isEnabled ? STATE_UP : STATE_DISABLED);
|
|
@@ -157,7 +142,7 @@ export class Button extends Image {
|
|
|
157
142
|
* @param {string} frame - The frame identifier to set for this state.
|
|
158
143
|
* @param {boolean} switchImmediately - Whether to switch to the new frame immediately (default: false).
|
|
159
144
|
*/
|
|
160
|
-
setStateFrame(state, frame, switchImmediately = false) {
|
|
145
|
+
setStateFrame(state: string, frame: string, switchImmediately: boolean = false) {
|
|
161
146
|
const frameKey = `_on${state}Frame`;
|
|
162
147
|
if (frame) {
|
|
163
148
|
this[frameKey] = frame;
|
|
@@ -174,7 +159,7 @@ export class Button extends Image {
|
|
|
174
159
|
* @param {string} newState - The new state to change to (Over, Out, Down, Up, Disabled).
|
|
175
160
|
* @returns {boolean} True if the frame was changed, false otherwise.
|
|
176
161
|
*/
|
|
177
|
-
changeStateFrame(newState) {
|
|
162
|
+
changeStateFrame(newState: string) {
|
|
178
163
|
if (this.freezeFrames) {
|
|
179
164
|
return false;
|
|
180
165
|
}
|
|
@@ -199,7 +184,7 @@ export class Button extends Image {
|
|
|
199
184
|
* @param {string} upFrame - The frame identifier to use when the button is released.
|
|
200
185
|
* @param {string} disabledFrame - The frame identifier to use when the button is disabled.
|
|
201
186
|
*/
|
|
202
|
-
setFrames(overFrame, outFrame, downFrame, upFrame, disabledFrame = null) {
|
|
187
|
+
setFrames(overFrame: string, outFrame: string, downFrame: string, upFrame: string, disabledFrame: string = null) {
|
|
203
188
|
this.setStateFrame(STATE_OVER, overFrame, this.input.pointerOver());
|
|
204
189
|
this.setStateFrame(STATE_OUT, outFrame, !this.input.pointerOver());
|
|
205
190
|
this.setStateFrame(STATE_DOWN, downFrame, this.input.pointerDown());
|
|
@@ -214,7 +199,7 @@ export class Button extends Image {
|
|
|
214
199
|
* @param {object} sprite - The sprite that triggered the event.
|
|
215
200
|
* @param {object} pointer - The pointer that triggered the event.
|
|
216
201
|
*/
|
|
217
|
-
onInputOverHandler(sprite, pointer) {
|
|
202
|
+
onInputOverHandler(sprite: any, pointer: any) {
|
|
218
203
|
if (pointer.justReleased() && (this.justReleasedPreventsOver & pointer.pointerMode) === pointer.pointerMode) {
|
|
219
204
|
// If the Pointer was only just released then we don't fire an over event
|
|
220
205
|
return;
|
|
@@ -233,7 +218,7 @@ export class Button extends Image {
|
|
|
233
218
|
* @param {object} sprite - The sprite that triggered the event.
|
|
234
219
|
* @param {object} pointer - The pointer that triggered the event.
|
|
235
220
|
*/
|
|
236
|
-
onInputOutHandler(sprite, pointer) {
|
|
221
|
+
onInputOutHandler(sprite: any, pointer: any) {
|
|
237
222
|
this.changeStateFrame(STATE_OUT);
|
|
238
223
|
if (this.onInputOut) {
|
|
239
224
|
this.onInputOut.dispatch(this, pointer);
|
|
@@ -245,7 +230,7 @@ export class Button extends Image {
|
|
|
245
230
|
* @param {object} sprite - The sprite that triggered the event.
|
|
246
231
|
* @param {object} pointer - The pointer that triggered the event.
|
|
247
232
|
*/
|
|
248
|
-
onInputDownHandler(sprite, pointer) {
|
|
233
|
+
onInputDownHandler(sprite: any, pointer: any) {
|
|
249
234
|
this.changeStateFrame(STATE_DOWN);
|
|
250
235
|
if (this.onInputDown) {
|
|
251
236
|
this.onInputDown.dispatch(this, pointer);
|
|
@@ -258,7 +243,7 @@ export class Button extends Image {
|
|
|
258
243
|
* @param {object} pointer - The pointer that triggered the event.
|
|
259
244
|
* @param {boolean} isOver - Whether the pointer is currently over the button (default: true).
|
|
260
245
|
*/
|
|
261
|
-
onInputUpHandler(sprite, pointer, isOver) {
|
|
246
|
+
onInputUpHandler(sprite: any, pointer: any, isOver: boolean) {
|
|
262
247
|
if (this.onInputUp) {
|
|
263
248
|
this.onInputUp.dispatch(this, pointer, isOver);
|
|
264
249
|
}
|
|
@@ -292,7 +277,7 @@ export class Button extends Image {
|
|
|
292
277
|
* Sets whether input is currently enabled for this button.
|
|
293
278
|
* @param {boolean} value - Whether to enable (true) or disable (false) input.
|
|
294
279
|
*/
|
|
295
|
-
set inputEnabled(value) {
|
|
280
|
+
set inputEnabled(value: boolean) {
|
|
296
281
|
if (value) {
|
|
297
282
|
if (this.input === null) {
|
|
298
283
|
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,15 @@ 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 = (
|
|
120
|
+
export const setTransform = (
|
|
121
|
+
context: CanvasRenderingContext2D,
|
|
122
|
+
translateX: number,
|
|
123
|
+
translateY: number,
|
|
124
|
+
scaleX: number,
|
|
125
|
+
scaleY: number,
|
|
126
|
+
skewX: number,
|
|
127
|
+
skewY: number
|
|
128
|
+
) => {
|
|
121
129
|
context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
|
|
122
130
|
return context;
|
|
123
131
|
};
|
|
@@ -127,7 +135,7 @@ export const setTransform = (context, translateX, translateY, scaleX, scaleY, sk
|
|
|
127
135
|
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
128
136
|
* @returns {string | null} The smoothing property name or null if not found.
|
|
129
137
|
*/
|
|
130
|
-
export const getSmoothingPrefix = (context) => {
|
|
138
|
+
export const getSmoothingPrefix = (context: CanvasRenderingContext2D) => {
|
|
131
139
|
const VENDORS = ['i', 'webkitI', 'msI', 'mozI', 'oI'];
|
|
132
140
|
for (let i = 0; i < VENDORS.length; i += 1) {
|
|
133
141
|
const s = `${VENDORS[i]}mageSmoothingEnabled`;
|
|
@@ -144,7 +152,7 @@ export const getSmoothingPrefix = (context) => {
|
|
|
144
152
|
* @param {number} value - The smoothing enabled value to set.
|
|
145
153
|
* @returns {object} The modified rendering context.
|
|
146
154
|
*/
|
|
147
|
-
export const setSmoothingEnabled = (context, value) => {
|
|
155
|
+
export const setSmoothingEnabled = (context: any, value: number) => {
|
|
148
156
|
const s = getSmoothingPrefix(context);
|
|
149
157
|
if (s) {
|
|
150
158
|
context[s] = value;
|