@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,20 +1,20 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { compileProgram } from '../util.js';
|
|
4
3
|
|
|
5
4
|
// the next one is used for rendering triangle strips
|
|
6
5
|
|
|
7
6
|
export class ComplexPrimitiveShader {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new ComplexShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
16
16
|
*/
|
|
17
|
-
constructor(gl) {
|
|
17
|
+
constructor(gl: WebGLRenderingContext) {
|
|
18
18
|
this.gl = gl;
|
|
19
19
|
this._UID = uuidv4();
|
|
20
20
|
/** @type {WebGLProgram} */
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { compileProgram } from '../util.js';
|
|
4
3
|
|
|
5
4
|
// this shader is used for the fast sprite rendering
|
|
6
5
|
|
|
7
6
|
export class FastShader {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
textureCount!: any;
|
|
12
|
+
fragmentSrc!: any;
|
|
13
|
+
vertexSrc!: any;
|
|
14
14
|
/**
|
|
15
15
|
* Creates a new FastShader instance.
|
|
16
16
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
17
17
|
*/
|
|
18
|
-
constructor(gl) {
|
|
18
|
+
constructor(gl: WebGLRenderingContext) {
|
|
19
19
|
this.gl = gl;
|
|
20
20
|
this._UID = uuidv4();
|
|
21
21
|
/** @type {WebGLProgram} */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { compileProgram } from '../util.js';
|
|
4
3
|
|
|
@@ -25,16 +24,17 @@ const defaultVertexSrc = [
|
|
|
25
24
|
// this shader is used for the default sprite rendering
|
|
26
25
|
|
|
27
26
|
export class NormalShader {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
gl!: any;
|
|
29
|
+
_UID!: any;
|
|
30
|
+
program!: any;
|
|
31
|
+
fragmentSrc!: any;
|
|
32
|
+
vertexSrc!: any;
|
|
33
|
+
textureCount!: any;
|
|
34
|
+
firstRun!: any;
|
|
35
|
+
dirty!: any;
|
|
36
|
+
uniforms!: any;
|
|
37
|
+
attributes!: any;
|
|
38
38
|
/**
|
|
39
39
|
* Creates a new NormalShader instance.
|
|
40
40
|
* @param {WebGLRenderingContext & { id: number }} gl - The WebGL rendering context.
|
|
@@ -147,7 +147,7 @@ attributes;
|
|
|
147
147
|
* Sets a uniform value for this shader.
|
|
148
148
|
* @param {object} uniform - The uniform to set.
|
|
149
149
|
*/
|
|
150
|
-
initSampler2D(uniform) {
|
|
150
|
+
initSampler2D(uniform: any) {
|
|
151
151
|
if (!uniform.value || !uniform.value.baseTexture || !uniform.value.baseTexture.hasLoaded) {
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { compileProgram } from '../util.js';
|
|
4
3
|
|
|
5
4
|
// the next one is used for rendering primitives
|
|
6
5
|
|
|
7
6
|
export class PrimitiveShader {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new PrimitiveShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
16
16
|
*/
|
|
17
|
-
constructor(gl) {
|
|
17
|
+
constructor(gl: WebGLRenderingContext) {
|
|
18
18
|
this.gl = gl;
|
|
19
19
|
this._UID = uuidv4();
|
|
20
20
|
/** @type {WebGLProgram} */
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
2
|
import { compileProgram } from '../util.js';
|
|
4
3
|
|
|
5
4
|
// the next one is used for rendering triangle strips
|
|
6
5
|
|
|
7
6
|
export class StripShader {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
gl!: any;
|
|
9
|
+
_UID!: any;
|
|
10
|
+
program!: any;
|
|
11
|
+
fragmentSrc!: any;
|
|
12
|
+
vertexSrc!: any;
|
|
13
13
|
/**
|
|
14
14
|
* Creates a new StripShader instance.
|
|
15
15
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
16
16
|
*/
|
|
17
|
-
constructor(gl) {
|
|
17
|
+
constructor(gl: WebGLRenderingContext) {
|
|
18
18
|
this.gl = gl;
|
|
19
19
|
this._UID = uuidv4();
|
|
20
20
|
/** @type {WebGLProgram} */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { ComplexPrimitiveShader } from './shader/complex.js';
|
|
3
2
|
import { FastShader } from './shader/fast.js';
|
|
4
3
|
import { NormalShader } from './shader/normal.js';
|
|
@@ -6,16 +5,17 @@ import { PrimitiveShader } from './shader/primitive.js';
|
|
|
6
5
|
import { StripShader } from './shader/strip.js';
|
|
7
6
|
|
|
8
7
|
export class WebGLShaderManager {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
gl!: any;
|
|
10
|
+
primitiveShader!: any;
|
|
11
|
+
complexPrimitiveShader!: any;
|
|
12
|
+
defaultShader!: any;
|
|
13
|
+
fastShader!: any;
|
|
14
|
+
stripShader!: any;
|
|
15
|
+
maxAttibs!: any;
|
|
16
|
+
attribState!: any;
|
|
17
|
+
tempAttribState!: any;
|
|
18
|
+
stack!: any;
|
|
19
19
|
/**
|
|
20
20
|
* Initializes the shader manager with a WebGL context.
|
|
21
21
|
*/
|
|
@@ -53,7 +53,7 @@ stack;
|
|
|
53
53
|
* Sets up the shader manager for WebGL rendering.
|
|
54
54
|
* @param {number[]} attribs - The attribute locations to set up.
|
|
55
55
|
*/
|
|
56
|
-
setAttribs(attribs) {
|
|
56
|
+
setAttribs(attribs: number[]) {
|
|
57
57
|
// reset temp state
|
|
58
58
|
let i;
|
|
59
59
|
for (i = 0; i < this.tempAttribState.length; i += 1) {
|
|
@@ -82,7 +82,7 @@ stack;
|
|
|
82
82
|
* @param {NormalShader} shader - The shader to set up.
|
|
83
83
|
* @returns {boolean} Whether the shader setup was successful.
|
|
84
84
|
*/
|
|
85
|
-
setShader(shader) {
|
|
85
|
+
setShader(shader: NormalShader) {
|
|
86
86
|
if (this._currentId === shader._UID) {
|
|
87
87
|
return false;
|
|
88
88
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { AbstractFilter } from './abstract_filter.js';
|
|
3
2
|
import { NormalShader } from './shader/normal.js';
|
|
4
3
|
|
|
5
4
|
export class WebGLSpriteBatch {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
vertSize!: any;
|
|
7
|
+
size!: any;
|
|
8
|
+
vertices!: any;
|
|
9
|
+
positions!: any;
|
|
10
|
+
colors!: any;
|
|
11
|
+
indices!: any;
|
|
12
|
+
lastIndexCount!: any;
|
|
13
|
+
drawing!: any;
|
|
14
|
+
currentBatchSize!: any;
|
|
15
|
+
currentBaseTexture!: any;
|
|
16
|
+
dirty!: any;
|
|
17
|
+
textures!: any;
|
|
18
|
+
blendModes!: any;
|
|
19
|
+
shaders!: any;
|
|
20
|
+
sprites!: any;
|
|
21
|
+
defaultShader!: any;
|
|
22
22
|
/**
|
|
23
23
|
* Creates a new SpriteBatch instance.
|
|
24
24
|
*/
|
|
@@ -88,7 +88,7 @@ defaultShader;
|
|
|
88
88
|
* Renders the sprite batch using WebGL.
|
|
89
89
|
* @param {object} renderSession - The render session to use.
|
|
90
90
|
*/
|
|
91
|
-
begin(renderSession) {
|
|
91
|
+
begin(renderSession: any) {
|
|
92
92
|
this.renderSession = renderSession;
|
|
93
93
|
this.shader = this.renderSession.shaderManager.defaultShader;
|
|
94
94
|
this.start();
|
|
@@ -106,7 +106,7 @@ defaultShader;
|
|
|
106
106
|
* @param {import('../../display/image.js').Image} sprite - The sprite to render.
|
|
107
107
|
* @param {import('../../geom/matrix.js').Matrix} matrix - The transformation matrix.
|
|
108
108
|
*/
|
|
109
|
-
render(sprite, matrix) {
|
|
109
|
+
render(sprite: import('../../display/image.js').Image, matrix: import('../../geom/matrix.js').Matrix) {
|
|
110
110
|
const texture = sprite.texture;
|
|
111
111
|
// They provided an alternative rendering matrix, so use it
|
|
112
112
|
let wt = sprite.worldTransform;
|
|
@@ -315,7 +315,7 @@ defaultShader;
|
|
|
315
315
|
* @param {number} size - The size of the batch.
|
|
316
316
|
* @param {number} startIndex - The start index in the batch.
|
|
317
317
|
*/
|
|
318
|
-
renderBatch(texture, size, startIndex) {
|
|
318
|
+
renderBatch(texture: import('./base_texture.js').BaseTexture, size: number, startIndex: number) {
|
|
319
319
|
if (size === 0) {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { hex2rgb } from '../../util/math.js';
|
|
3
2
|
|
|
4
3
|
export class WebGLStencilManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
stencilStack!: any;
|
|
6
|
+
reverse!: any;
|
|
7
|
+
count!: any;
|
|
8
8
|
/**
|
|
9
9
|
* Initializes the stencil manager.
|
|
10
10
|
*/
|
|
@@ -18,7 +18,7 @@ count;
|
|
|
18
18
|
* Binds the stencil buffer for rendering.
|
|
19
19
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
20
20
|
*/
|
|
21
|
-
setContext(gl) {
|
|
21
|
+
setContext(gl: WebGLRenderingContext) {
|
|
22
22
|
this.gl = gl;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -36,7 +36,7 @@ count;
|
|
|
36
36
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
37
37
|
* @param {object} renderSession - The rendering session.
|
|
38
38
|
*/
|
|
39
|
-
pushStencil(graphics, webGLData, renderSession) {
|
|
39
|
+
pushStencil(graphics: import('../graphics.js').Graphics, webGLData: import('./graphics_data.js').GraphicsData, renderSession: any) {
|
|
40
40
|
const gl = renderSession.gl;
|
|
41
41
|
this.bindGraphics(graphics, webGLData, renderSession);
|
|
42
42
|
if (this.stencilStack.length === 0) {
|
|
@@ -94,7 +94,7 @@ count;
|
|
|
94
94
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
95
95
|
* @param {object} renderSession - The rendering session.
|
|
96
96
|
*/
|
|
97
|
-
bindGraphics(graphics, webGLData, renderSession) {
|
|
97
|
+
bindGraphics(graphics: import('../graphics.js').Graphics, webGLData: import('./graphics_data.js').GraphicsData, renderSession: any) {
|
|
98
98
|
// if(this._currentGraphics === graphics)return;
|
|
99
99
|
// this._currentGraphics = graphics;
|
|
100
100
|
const gl = renderSession.gl;
|
|
@@ -141,7 +141,7 @@ count;
|
|
|
141
141
|
* @param {import('./graphics_data.js').GraphicsData} webGLData - The WebGL graphics data.
|
|
142
142
|
* @param {object} renderSession - The rendering session.
|
|
143
143
|
*/
|
|
144
|
-
popStencil(graphics, webGLData, renderSession) {
|
|
144
|
+
popStencil(graphics: import('../graphics.js').Graphics, webGLData: import('./graphics_data.js').GraphicsData, renderSession: any) {
|
|
145
145
|
const gl = renderSession.gl;
|
|
146
146
|
this.stencilStack.pop();
|
|
147
147
|
this.count -= 1;
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { Rectangle } from '../../geom/rectangle.js';
|
|
3
2
|
|
|
4
3
|
export class TextureUvs {
|
|
5
|
-
noFrame;
|
|
6
|
-
baseTexture;
|
|
7
|
-
frame;
|
|
8
|
-
trim;
|
|
9
|
-
valid;
|
|
10
|
-
isTiling;
|
|
11
|
-
requiresUpdate;
|
|
12
|
-
requiresReTint;
|
|
13
|
-
_uvs;
|
|
14
|
-
width;
|
|
15
|
-
height;
|
|
16
|
-
crop;
|
|
17
|
-
x0;
|
|
18
|
-
y0;
|
|
19
|
-
x1;
|
|
20
|
-
y1;
|
|
21
|
-
x2;
|
|
22
|
-
y2;
|
|
23
|
-
x3;
|
|
24
|
-
y3;
|
|
4
|
+
noFrame!: any;
|
|
5
|
+
baseTexture!: any;
|
|
6
|
+
frame!: any;
|
|
7
|
+
trim!: any;
|
|
8
|
+
valid!: any;
|
|
9
|
+
isTiling!: any;
|
|
10
|
+
requiresUpdate!: any;
|
|
11
|
+
requiresReTint!: any;
|
|
12
|
+
_uvs!: any;
|
|
13
|
+
width!: any;
|
|
14
|
+
height!: any;
|
|
15
|
+
crop!: any;
|
|
16
|
+
x0!: any;
|
|
17
|
+
y0!: any;
|
|
18
|
+
x1!: any;
|
|
19
|
+
y1!: any;
|
|
20
|
+
x2!: any;
|
|
21
|
+
y2!: any;
|
|
22
|
+
x3!: any;
|
|
23
|
+
y3!: any;
|
|
25
24
|
/**
|
|
26
25
|
* Creates a new Texture instance.
|
|
27
26
|
*/
|
|
@@ -38,6 +37,18 @@ y3;
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
export class Texture {
|
|
40
|
+
noFrame!: any;
|
|
41
|
+
baseTexture!: any;
|
|
42
|
+
frame!: any;
|
|
43
|
+
trim!: any;
|
|
44
|
+
valid!: any;
|
|
45
|
+
isTiling!: any;
|
|
46
|
+
requiresUpdate!: any;
|
|
47
|
+
requiresReTint!: any;
|
|
48
|
+
_uvs!: any;
|
|
49
|
+
width!: any;
|
|
50
|
+
height!: any;
|
|
51
|
+
crop!: any;
|
|
41
52
|
/**
|
|
42
53
|
* Creates a new Texture instance.
|
|
43
54
|
* @param {import('./base_texture.js').BaseTexture} baseTexture - The base texture to use.
|
|
@@ -45,7 +56,7 @@ export class Texture {
|
|
|
45
56
|
* @param {Rectangle | null | undefined} crop - The crop rectangle.
|
|
46
57
|
* @param {Rectangle | null | undefined} trim - The trim rectangle.
|
|
47
58
|
*/
|
|
48
|
-
constructor(baseTexture, frame = null, crop = null, trim = null) {
|
|
59
|
+
constructor(baseTexture: import('./base_texture.js').BaseTexture, frame: Rectangle | null | undefined = null, crop: Rectangle | null | undefined = null, trim: Rectangle | null | undefined = null) {
|
|
49
60
|
this.noFrame = false;
|
|
50
61
|
if (!frame) {
|
|
51
62
|
this.noFrame = true;
|
|
@@ -97,7 +108,7 @@ export class Texture {
|
|
|
97
108
|
* Destroys this texture and cleans up resources.
|
|
98
109
|
* @param {boolean} destroyBase - Whether to destroy the base texture as well.
|
|
99
110
|
*/
|
|
100
|
-
destroy(destroyBase = false) {
|
|
111
|
+
destroy(destroyBase: boolean = false) {
|
|
101
112
|
if (destroyBase) {
|
|
102
113
|
this.baseTexture.destroy();
|
|
103
114
|
}
|
|
@@ -109,7 +120,7 @@ export class Texture {
|
|
|
109
120
|
* @param {Rectangle} frame - The new frame rectangle.
|
|
110
121
|
* @throws {Error} If the operation fails.
|
|
111
122
|
*/
|
|
112
|
-
setFrame(frame) {
|
|
123
|
+
setFrame(frame: Rectangle) {
|
|
113
124
|
this.noFrame = false;
|
|
114
125
|
this.frame = frame;
|
|
115
126
|
this.width = frame.width;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
import { BaseTexture } from './base_texture.js';
|
|
3
2
|
import { Texture } from './texture.js';
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ import { Texture } from './texture.js';
|
|
|
8
7
|
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
9
8
|
* @returns {BaseTexture} The newly created BaseTexture instance.
|
|
10
9
|
*/
|
|
11
|
-
export const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
10
|
+
export const baseTextureFromCanvas = (canvas: HTMLCanvasElement, scaleMode: number) => {
|
|
12
11
|
if (canvas.width === 0) {
|
|
13
12
|
canvas.width = 1;
|
|
14
13
|
}
|
|
@@ -24,6 +23,6 @@ export const baseTextureFromCanvas = (canvas, scaleMode) => {
|
|
|
24
23
|
* @param {number} [scaleMode] - The scale mode to use for the texture.
|
|
25
24
|
* @returns {Texture} The newly created Texture instance.
|
|
26
25
|
*/
|
|
27
|
-
export const textureFromCanvas = (canvas, scaleMode) => {
|
|
26
|
+
export const textureFromCanvas = (canvas: HTMLCanvasElement, scaleMode?: any) => {
|
|
28
27
|
return new Texture(baseTextureFromCanvas(canvas, scaleMode));
|
|
29
28
|
};
|
|
@@ -18,7 +18,7 @@ export const CONTEXT_LOST_WEBGL = 0x9242;
|
|
|
18
18
|
* @param {WebGLRenderingContext} gl - The WebGL rendering context.
|
|
19
19
|
* @returns {number} The error code from the WebGL context.
|
|
20
20
|
*/
|
|
21
|
-
export const getWebGLContextErrorCode = (gl) => {
|
|
21
|
+
export const getWebGLContextErrorCode = (gl: WebGLRenderingContext) => {
|
|
22
22
|
return gl?.getError() ?? 0;
|
|
23
23
|
};
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ export const getWebGLContextErrorCode = (gl) => {
|
|
|
27
27
|
* @param {number} errorCode - The error code to look up.
|
|
28
28
|
* @returns {string} The name of the WebGL error.
|
|
29
29
|
*/
|
|
30
|
-
export const getWebGLContextErrorName = (errorCode) => {
|
|
30
|
+
export const getWebGLContextErrorName = (errorCode: number) => {
|
|
31
31
|
switch (errorCode) {
|
|
32
32
|
case NO_ERROR:
|
|
33
33
|
return 'NO_ERROR';
|
|
@@ -60,7 +60,7 @@ export const initDefaultShaders = () => {};
|
|
|
60
60
|
* @param {object} shaderType - The type of shader to compile.
|
|
61
61
|
* @returns {WebGLShader} The compiled WebGL shader or null if compilation failed.
|
|
62
62
|
*/
|
|
63
|
-
export const compileShader = (gl, shaderSrc, shaderType) => {
|
|
63
|
+
export const compileShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string, shaderType: any) => {
|
|
64
64
|
const src = Array.isArray(shaderSrc) ? shaderSrc.join('\n') : shaderSrc;
|
|
65
65
|
const shader = gl.createShader(shaderType);
|
|
66
66
|
gl.shaderSource(shader, src);
|
|
@@ -81,7 +81,7 @@ export const compileShader = (gl, shaderSrc, shaderType) => {
|
|
|
81
81
|
* @param {string[]|string} shaderSrc - The vertex shader source code.
|
|
82
82
|
* @returns {WebGLShader} The compiled WebGL vertex shader or null if compilation failed.
|
|
83
83
|
*/
|
|
84
|
-
export const compileVertexShader = (gl, shaderSrc) => {
|
|
84
|
+
export const compileVertexShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
85
85
|
return compileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
|
86
86
|
};
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ export const compileVertexShader = (gl, shaderSrc) => {
|
|
|
91
91
|
* @param {string[]|string} shaderSrc - The fragment shader source code.
|
|
92
92
|
* @returns {WebGLShader} The compiled WebGL fragment shader or null if compilation failed.
|
|
93
93
|
*/
|
|
94
|
-
export const compileFragmentShader = (gl, shaderSrc) => {
|
|
94
|
+
export const compileFragmentShader = (gl: WebGLRenderingContext, shaderSrc: string[]|string) => {
|
|
95
95
|
return compileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
|
96
96
|
};
|
|
97
97
|
|
|
@@ -102,7 +102,7 @@ export const compileFragmentShader = (gl, shaderSrc) => {
|
|
|
102
102
|
* @param {string[]|string} fragmentSrc - The fragment shader source code.
|
|
103
103
|
* @returns {WebGLProgram} The compiled WebGL shader program or null if compilation failed.
|
|
104
104
|
*/
|
|
105
|
-
export const compileProgram = (gl, vertexSrc, fragmentSrc) => {
|
|
105
|
+
export const compileProgram = (gl: WebGLRenderingContext, vertexSrc: string[]|string, fragmentSrc: string[]|string) => {
|
|
106
106
|
const fragmentShader = compileFragmentShader(gl, fragmentSrc);
|
|
107
107
|
const vertexShader = compileVertexShader(gl, vertexSrc);
|
|
108
108
|
|
|
@@ -17,7 +17,7 @@ export class Circle {
|
|
|
17
17
|
* @param {number} y - The y coordinate of the center point (default: 0).
|
|
18
18
|
* @param {number} diameter - The diameter of the circle (default: 0).
|
|
19
19
|
*/
|
|
20
|
-
constructor(x = 0, y = 0, diameter = 0) {
|
|
20
|
+
constructor(x: number = 0, y: number = 0, diameter: number = 0) {
|
|
21
21
|
/** @type {number} */
|
|
22
22
|
this.x = x;
|
|
23
23
|
/** @type {number} */
|
|
@@ -46,7 +46,7 @@ export class Circle {
|
|
|
46
46
|
* @param {Point} output - The point to store the result in (optional).
|
|
47
47
|
* @returns {Point} A random point within this circle.
|
|
48
48
|
*/
|
|
49
|
-
random(output = null) {
|
|
49
|
+
random(output: Point = null) {
|
|
50
50
|
const result = output || new Point();
|
|
51
51
|
const t = 2 * Math.PI * Math.random();
|
|
52
52
|
const u = Math.random() + Math.random();
|
|
@@ -73,7 +73,7 @@ export class Circle {
|
|
|
73
73
|
* @param {number} diameter - The new diameter of the circle.
|
|
74
74
|
* @returns {Circle} This circle instance for chaining.
|
|
75
75
|
*/
|
|
76
|
-
setTo(x, y, diameter) {
|
|
76
|
+
setTo(x: number, y: number, diameter: number) {
|
|
77
77
|
this.x = x;
|
|
78
78
|
this.y = y;
|
|
79
79
|
this._diameter = diameter;
|
|
@@ -86,7 +86,7 @@ export class Circle {
|
|
|
86
86
|
* @param {Circle} source - The circle to copy values from.
|
|
87
87
|
* @returns {Circle} This circle instance for chaining.
|
|
88
88
|
*/
|
|
89
|
-
copyFrom(source) {
|
|
89
|
+
copyFrom(source: Circle) {
|
|
90
90
|
return this.setTo(source.x, source.y, source.diameter);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -95,7 +95,7 @@ export class Circle {
|
|
|
95
95
|
* @param {Circle} dest - The circle to copy values to.
|
|
96
96
|
* @returns {Circle} The destination circle.
|
|
97
97
|
*/
|
|
98
|
-
copyTo(dest) {
|
|
98
|
+
copyTo(dest: Circle) {
|
|
99
99
|
dest.x = this.x;
|
|
100
100
|
dest.y = this.y;
|
|
101
101
|
dest.diameter = this._diameter;
|
|
@@ -108,7 +108,7 @@ export class Circle {
|
|
|
108
108
|
* @param {boolean} round - Whether to round the result (default: false).
|
|
109
109
|
* @returns {number} The distance between the circles.
|
|
110
110
|
*/
|
|
111
|
-
distance(dest, round = false) {
|
|
111
|
+
distance(dest: Circle, round: boolean = false) {
|
|
112
112
|
const d = distance(this.x, this.y, dest.x, dest.y);
|
|
113
113
|
return round ? Math.round(d) : d;
|
|
114
114
|
}
|
|
@@ -127,7 +127,7 @@ export class Circle {
|
|
|
127
127
|
* @param {number} y - The y coordinate of the point to check.
|
|
128
128
|
* @returns {boolean} True if the point is contained within this circle, false otherwise.
|
|
129
129
|
*/
|
|
130
|
-
contains(x, y) {
|
|
130
|
+
contains(x: number, y: number) {
|
|
131
131
|
return contains(this, x, y);
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -138,7 +138,7 @@ export class Circle {
|
|
|
138
138
|
* @param {Point} out - The point to store the result in (optional).
|
|
139
139
|
* @returns {Point} A point at the specified angle on the circumference of this circle.
|
|
140
140
|
*/
|
|
141
|
-
circumferencePoint(angle, asDegrees
|
|
141
|
+
circumferencePoint(angle: number, asDegrees?: boolean, out?: Point) {
|
|
142
142
|
return circumferencePoint(this, angle, asDegrees, out);
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -148,7 +148,7 @@ export class Circle {
|
|
|
148
148
|
* @param {number} dy - The amount to offset the y coordinate by.
|
|
149
149
|
* @returns {Circle} This circle instance for chaining.
|
|
150
150
|
*/
|
|
151
|
-
offset(dx, dy) {
|
|
151
|
+
offset(dx: number, dy: number) {
|
|
152
152
|
this.x += dx;
|
|
153
153
|
this.y += dy;
|
|
154
154
|
return this;
|
|
@@ -159,7 +159,7 @@ export class Circle {
|
|
|
159
159
|
* @param {Point} point - The point to offset the circle by.
|
|
160
160
|
* @returns {Circle} This circle instance for chaining.
|
|
161
161
|
*/
|
|
162
|
-
offsetPoint(point) {
|
|
162
|
+
offsetPoint(point: Point) {
|
|
163
163
|
return this.offset(point.x, point.y);
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -17,7 +17,7 @@ export class Ellipse {
|
|
|
17
17
|
* @param {number} width - The width of the ellipse (default: 0).
|
|
18
18
|
* @param {number} height - The height of the ellipse (default: 0).
|
|
19
19
|
*/
|
|
20
|
-
constructor(x = 0, y = 0, width = 0, height = 0) {
|
|
20
|
+
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
|
|
21
21
|
/** @type {number} */
|
|
22
22
|
this.x = x;
|
|
23
23
|
/** @type {number} */
|
|
@@ -38,7 +38,7 @@ export class Ellipse {
|
|
|
38
38
|
* @param {number} height - The new height of the ellipse.
|
|
39
39
|
* @returns {Ellipse} This ellipse instance for chaining.
|
|
40
40
|
*/
|
|
41
|
-
setTo(x, y, width, height) {
|
|
41
|
+
setTo(x: number, y: number, width: number, height: number) {
|
|
42
42
|
this.x = x;
|
|
43
43
|
this.y = y;
|
|
44
44
|
this.width = width;
|
|
@@ -59,7 +59,7 @@ export class Ellipse {
|
|
|
59
59
|
* @param {Ellipse} source - The ellipse to copy values from.
|
|
60
60
|
* @returns {Ellipse} This ellipse instance for chaining.
|
|
61
61
|
*/
|
|
62
|
-
copyFrom(source) {
|
|
62
|
+
copyFrom(source: Ellipse) {
|
|
63
63
|
return this.setTo(source.x, source.y, source.width, source.height);
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -68,7 +68,7 @@ export class Ellipse {
|
|
|
68
68
|
* @param {Ellipse} dest - The ellipse to copy values to.
|
|
69
69
|
* @returns {Ellipse} The destination ellipse.
|
|
70
70
|
*/
|
|
71
|
-
copyTo(dest) {
|
|
71
|
+
copyTo(dest: Ellipse) {
|
|
72
72
|
dest.x = this.x;
|
|
73
73
|
dest.y = this.y;
|
|
74
74
|
dest.width = this.width;
|
|
@@ -82,7 +82,7 @@ export class Ellipse {
|
|
|
82
82
|
* @param {number} y - The y coordinate of the point to check.
|
|
83
83
|
* @returns {boolean} True if the point is contained within this ellipse, false otherwise.
|
|
84
84
|
*/
|
|
85
|
-
contains(x, y) {
|
|
85
|
+
contains(x: number, y: number) {
|
|
86
86
|
return contains(this, x, y);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -91,7 +91,7 @@ export class Ellipse {
|
|
|
91
91
|
* @param {Point} output - The point to store the result in (optional).
|
|
92
92
|
* @returns {Point} A random point within this ellipse.
|
|
93
93
|
*/
|
|
94
|
-
random(output = null) {
|
|
94
|
+
random(output: Point = null) {
|
|
95
95
|
const result = output || new Point();
|
|
96
96
|
const p = Math.random() * Math.PI * 2;
|
|
97
97
|
const r = Math.random();
|