@vpmedia/phaser 1.103.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 +997 -403
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +35 -11
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts +20 -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 +68 -60
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/device.d.ts +23 -0
- 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 -158
- package/dist/phaser/core/event_manager.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +8 -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 -58
- 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 +50 -3
- package/dist/phaser/core/game.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +66 -13
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts +64 -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 +18 -2
- package/dist/phaser/core/input_mspointer.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +53 -9
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +19 -1
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +56 -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 +77 -17
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene.d.ts +3 -1
- package/dist/phaser/core/scene.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts +25 -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 +58 -10
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +28 -9
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/sound_sprite.d.ts +10 -4
- package/dist/phaser/core/sound_sprite.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +7 -3
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts +32 -5
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +30 -10
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/timer_event.d.ts +11 -12
- package/dist/phaser/core/timer_event.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +38 -14
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +30 -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 +8 -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 +35 -20
- package/dist/phaser/display/bitmap_text.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +24 -8
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +6 -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 +18 -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 +82 -23
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +42 -16
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/graphics_data.d.ts +11 -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 -9
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +36 -13
- 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 +8 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/base_texture.d.ts +14 -2
- package/dist/phaser/display/webgl/base_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +5 -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 +17 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +5 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +7 -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 +11 -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 +12 -1
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +25 -6
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/complex.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts +8 -1
- package/dist/phaser/display/webgl/shader/fast.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +11 -0
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/primitive.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts +7 -1
- package/dist/phaser/display/webgl/shader/strip.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader_manager.d.ts +14 -2
- package/dist/phaser/display/webgl/shader_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +19 -2
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +8 -4
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/texture.d.ts +35 -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 +2 -2
- package/src/phaser/core/animation.ts +41 -18
- package/src/phaser/core/animation_manager.ts +21 -12
- 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 -60
- package/src/phaser/core/device.ts +23 -1
- 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 -177
- package/src/phaser/core/factory.ts +25 -17
- package/src/phaser/core/frame.ts +37 -51
- package/src/phaser/core/frame_data.ts +29 -74
- package/src/phaser/core/frame_util.ts +3 -16
- package/src/phaser/core/game.ts +40 -11
- package/src/phaser/core/input.ts +68 -17
- package/src/phaser/core/input_handler.ts +81 -45
- package/src/phaser/core/input_mouse.ts +42 -13
- package/src/phaser/core/input_mspointer.ts +24 -9
- package/src/phaser/core/input_pointer.ts +55 -12
- package/src/phaser/core/input_touch.ts +26 -9
- package/src/phaser/core/loader.ts +97 -42
- 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 -27
- package/src/phaser/core/scene.ts +3 -2
- package/src/phaser/core/scene_manager.ts +26 -11
- package/src/phaser/core/signal.ts +10 -10
- package/src/phaser/core/signal_binding.ts +2 -2
- package/src/phaser/core/sound.ts +72 -26
- package/src/phaser/core/sound_manager.ts +31 -13
- package/src/phaser/core/sound_sprite.ts +10 -5
- package/src/phaser/core/stage.ts +8 -4
- package/src/phaser/core/time.ts +33 -7
- package/src/phaser/core/timer.ts +40 -14
- package/src/phaser/core/timer_event.ts +23 -14
- package/src/phaser/core/tween.ts +43 -23
- package/src/phaser/core/tween_data.ts +31 -7
- package/src/phaser/core/tween_easing.ts +31 -31
- package/src/phaser/core/tween_manager.ts +10 -7
- package/src/phaser/core/world.ts +1 -2
- package/src/phaser/display/bitmap_text.ts +41 -18
- package/src/phaser/display/button.ts +24 -23
- package/src/phaser/display/canvas/buffer.ts +6 -3
- 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 -7
- 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 +120 -61
- package/src/phaser/display/graphics.ts +56 -25
- package/src/phaser/display/graphics_data.ts +11 -2
- package/src/phaser/display/graphics_data_util.ts +1 -2
- package/src/phaser/display/group.ts +32 -14
- package/src/phaser/display/image.ts +37 -19
- 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 -2
- package/src/phaser/display/webgl/base_texture.ts +14 -3
- package/src/phaser/display/webgl/blend_manager.ts +5 -3
- 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 -4
- package/src/phaser/display/webgl/filter_manager.ts +5 -2
- package/src/phaser/display/webgl/filter_texture.ts +7 -3
- package/src/phaser/display/webgl/graphics.ts +10 -11
- package/src/phaser/display/webgl/graphics_data.ts +11 -2
- package/src/phaser/display/webgl/mask_manager.ts +2 -3
- package/src/phaser/display/webgl/render_texture.ts +12 -2
- package/src/phaser/display/webgl/renderer.ts +24 -7
- package/src/phaser/display/webgl/shader/complex.ts +7 -2
- package/src/phaser/display/webgl/shader/fast.ts +8 -2
- package/src/phaser/display/webgl/shader/normal.ts +12 -2
- package/src/phaser/display/webgl/shader/primitive.ts +7 -2
- package/src/phaser/display/webgl/shader/strip.ts +7 -2
- package/src/phaser/display/webgl/shader_manager.ts +13 -3
- package/src/phaser/display/webgl/sprite_batch.ts +20 -4
- package/src/phaser/display/webgl/stencil_manager.ts +8 -5
- package/src/phaser/display/webgl/texture.ts +35 -4
- 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,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,11 +26,24 @@ import { detectCapabilities } from './tinter.js';
|
|
|
27
26
|
import { getSmoothingPrefix } from './util.js';
|
|
28
27
|
|
|
29
28
|
export class CanvasRenderer {
|
|
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;
|
|
30
42
|
/**
|
|
31
43
|
* Creates a new CanvasRenderer instance.
|
|
32
44
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
33
45
|
*/
|
|
34
|
-
constructor(game) {
|
|
46
|
+
constructor(game: import('../../core/game.js').Game) {
|
|
35
47
|
detectCapabilities(game);
|
|
36
48
|
/** @type {number} */
|
|
37
49
|
this.type = RENDER_CANVAS;
|
|
@@ -66,7 +78,7 @@ export class CanvasRenderer {
|
|
|
66
78
|
* Renders the stage to canvas.
|
|
67
79
|
* @param {import('../../core/stage.js').Stage} root - The root stage to render.
|
|
68
80
|
*/
|
|
69
|
-
render(root) {
|
|
81
|
+
render(root: import('../../core/stage.js').Stage) {
|
|
70
82
|
if (!this.context) {
|
|
71
83
|
return;
|
|
72
84
|
}
|
|
@@ -91,7 +103,7 @@ export class CanvasRenderer {
|
|
|
91
103
|
* Destroys this renderer and cleans up resources.
|
|
92
104
|
* @param {boolean} removeView - Whether to remove the view from the DOM.
|
|
93
105
|
*/
|
|
94
|
-
destroy(removeView = true) {
|
|
106
|
+
destroy(removeView: boolean = true) {
|
|
95
107
|
if (removeView && this.view.parent) {
|
|
96
108
|
this.view.parent.removeChild(this.view);
|
|
97
109
|
}
|
|
@@ -105,7 +117,7 @@ export class CanvasRenderer {
|
|
|
105
117
|
* @param {number} width - The new width of the canvas.
|
|
106
118
|
* @param {number} height - The new height of the canvas.
|
|
107
119
|
*/
|
|
108
|
-
resize(width, height) {
|
|
120
|
+
resize(width: number, height: number) {
|
|
109
121
|
this.width = width * this.resolution;
|
|
110
122
|
this.height = height * this.resolution;
|
|
111
123
|
this.view.width = this.width;
|
|
@@ -125,7 +137,7 @@ export class CanvasRenderer {
|
|
|
125
137
|
* @param {CanvasRenderingContext2D} context - The canvas rendering context.
|
|
126
138
|
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
127
139
|
*/
|
|
128
|
-
renderDisplayObject(displayObject, context, matrix) {
|
|
140
|
+
renderDisplayObject(displayObject: any, context?: any, matrix?: any) {
|
|
129
141
|
this.renderSession.context = context || this.context;
|
|
130
142
|
this.renderSession.resolution = this.resolution;
|
|
131
143
|
displayObject.renderCanvas(this.renderSession, matrix);
|
|
@@ -164,7 +176,7 @@ export class CanvasRenderer {
|
|
|
164
176
|
* Initializes the WebGL context for rendering.
|
|
165
177
|
* @param {import('../../core/game.js').Game} game - The game instance.
|
|
166
178
|
*/
|
|
167
|
-
initContext(game) {
|
|
179
|
+
initContext(game: import('../../core/game.js').Game) {
|
|
168
180
|
// stub
|
|
169
181
|
}
|
|
170
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;
|