@vpmedia/phaser 1.123.0 → 1.125.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 +635 -623
- package/dist/index.js.map +1 -1
- package/dist/phaser/core/animation.d.ts +3 -3
- package/dist/phaser/core/animation.d.ts.map +1 -1
- package/dist/phaser/core/animation_manager.d.ts.map +1 -1
- package/dist/phaser/core/animation_parser.d.ts +27 -2
- package/dist/phaser/core/animation_parser.d.ts.map +1 -1
- package/dist/phaser/core/array_set.d.ts +11 -11
- package/dist/phaser/core/array_set.d.ts.map +1 -1
- package/dist/phaser/core/cache.d.ts.map +1 -1
- package/dist/phaser/core/callback.d.ts.map +1 -1
- package/dist/phaser/core/dom.d.ts +125 -19
- package/dist/phaser/core/dom.d.ts.map +1 -1
- package/dist/phaser/core/factory.d.ts +3 -2
- package/dist/phaser/core/factory.d.ts.map +1 -1
- package/dist/phaser/core/frame_data.d.ts.map +1 -1
- package/dist/phaser/core/input.d.ts +3 -2
- package/dist/phaser/core/input.d.ts.map +1 -1
- package/dist/phaser/core/input_handler.d.ts.map +1 -1
- package/dist/phaser/core/input_mouse.d.ts +5 -1
- package/dist/phaser/core/input_mouse.d.ts.map +1 -1
- package/dist/phaser/core/input_pointer.d.ts +3 -3
- package/dist/phaser/core/input_pointer.d.ts.map +1 -1
- package/dist/phaser/core/input_touch.d.ts +8 -8
- package/dist/phaser/core/input_touch.d.ts.map +1 -1
- package/dist/phaser/core/loader.d.ts +11 -2
- package/dist/phaser/core/loader.d.ts.map +1 -1
- package/dist/phaser/core/loader_parser.d.ts +14 -1
- package/dist/phaser/core/loader_parser.d.ts.map +1 -1
- package/dist/phaser/core/raf.d.ts +1 -1
- package/dist/phaser/core/raf.d.ts.map +1 -1
- package/dist/phaser/core/scale_manager.d.ts.map +1 -1
- package/dist/phaser/core/scene_manager.d.ts.map +1 -1
- package/dist/phaser/core/signal.d.ts.map +1 -1
- package/dist/phaser/core/sound.d.ts.map +1 -1
- package/dist/phaser/core/sound_manager.d.ts +1 -1
- package/dist/phaser/core/sound_manager.d.ts.map +1 -1
- package/dist/phaser/core/stage.d.ts +16 -6
- package/dist/phaser/core/stage.d.ts.map +1 -1
- package/dist/phaser/core/time.d.ts.map +1 -1
- package/dist/phaser/core/timer.d.ts +1 -1
- package/dist/phaser/core/timer.d.ts.map +1 -1
- package/dist/phaser/core/tween.d.ts +13 -5
- package/dist/phaser/core/tween.d.ts.map +1 -1
- package/dist/phaser/core/tween_data.d.ts +9 -7
- package/dist/phaser/core/tween_data.d.ts.map +1 -1
- package/dist/phaser/core/tween_manager.d.ts.map +1 -1
- package/dist/phaser/display/button.d.ts +6 -5
- package/dist/phaser/display/button.d.ts.map +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts +1 -1
- package/dist/phaser/display/canvas/buffer.d.ts.map +1 -1
- package/dist/phaser/display/canvas/masker.d.ts +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 +9 -8
- package/dist/phaser/display/canvas/renderer.d.ts.map +1 -1
- package/dist/phaser/display/display_object.d.ts +5 -3
- package/dist/phaser/display/display_object.d.ts.map +1 -1
- package/dist/phaser/display/graphics.d.ts +1 -1
- package/dist/phaser/display/graphics.d.ts.map +1 -1
- package/dist/phaser/display/group.d.ts +1 -1
- package/dist/phaser/display/group.d.ts.map +1 -1
- package/dist/phaser/display/image.d.ts +6 -5
- package/dist/phaser/display/image.d.ts.map +1 -1
- package/dist/phaser/display/sprite_util.d.ts +3 -2
- package/dist/phaser/display/sprite_util.d.ts.map +1 -1
- package/dist/phaser/display/text.d.ts +2 -16
- package/dist/phaser/display/text.d.ts.map +1 -1
- package/dist/phaser/display/webgl/abstract_filter.d.ts +14 -8
- package/dist/phaser/display/webgl/abstract_filter.d.ts.map +1 -1
- package/dist/phaser/display/webgl/blend_manager.d.ts +2 -3
- package/dist/phaser/display/webgl/blend_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/earcut.d.ts.map +1 -1
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts +11 -5
- package/dist/phaser/display/webgl/fast_sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_manager.d.ts +6 -4
- package/dist/phaser/display/webgl/filter_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/filter_texture.d.ts +4 -4
- package/dist/phaser/display/webgl/filter_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/graphics.d.ts +2 -2
- package/dist/phaser/display/webgl/graphics.d.ts.map +1 -1
- package/dist/phaser/display/webgl/mask_manager.d.ts +3 -2
- package/dist/phaser/display/webgl/mask_manager.d.ts.map +1 -1
- package/dist/phaser/display/webgl/render_texture.d.ts +11 -8
- package/dist/phaser/display/webgl/render_texture.d.ts.map +1 -1
- package/dist/phaser/display/webgl/renderer.d.ts +8 -4
- package/dist/phaser/display/webgl/renderer.d.ts.map +1 -1
- package/dist/phaser/display/webgl/shader/normal.d.ts +28 -3
- package/dist/phaser/display/webgl/shader/normal.d.ts.map +1 -1
- package/dist/phaser/display/webgl/sprite_batch.d.ts +6 -5
- package/dist/phaser/display/webgl/sprite_batch.d.ts.map +1 -1
- package/dist/phaser/display/webgl/stencil_manager.d.ts +3 -3
- package/dist/phaser/display/webgl/stencil_manager.d.ts.map +1 -1
- 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 +1 -1
- package/dist/phaser/display/webgl/util.d.ts.map +1 -1
- package/dist/phaser/geom/circle.d.ts.map +1 -1
- package/dist/phaser/geom/line.d.ts +10 -1
- package/dist/phaser/geom/line.d.ts.map +1 -1
- package/dist/phaser/geom/rectangle.d.ts.map +1 -1
- package/dist/phaser/geom/util/circle.d.ts +2 -1
- package/dist/phaser/geom/util/circle.d.ts.map +1 -1
- package/dist/phaser/geom/util/point.d.ts +1 -1
- package/dist/phaser/geom/util/point.d.ts.map +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts +1 -1
- package/dist/phaser/geom/util/rectangle.d.ts.map +1 -1
- package/dist/phaser/util/math.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/phaser/core/animation.ts +11 -11
- package/src/phaser/core/animation_manager.ts +12 -12
- package/src/phaser/core/animation_parser.ts +39 -37
- package/src/phaser/core/array_set.ts +28 -28
- package/src/phaser/core/cache.test.ts +33 -33
- package/src/phaser/core/cache.ts +7 -7
- package/src/phaser/core/callback.ts +1 -0
- package/src/phaser/core/callback_context.test.ts +8 -8
- package/src/phaser/core/device_util.ts +4 -4
- package/src/phaser/core/dom.ts +38 -24
- package/src/phaser/core/factory.ts +9 -2
- package/src/phaser/core/frame_data.test.ts +23 -23
- package/src/phaser/core/frame_data.ts +2 -5
- package/src/phaser/core/game.ts +12 -12
- package/src/phaser/core/input.ts +11 -10
- package/src/phaser/core/input_handler.test.ts +18 -18
- package/src/phaser/core/input_handler.ts +14 -14
- package/src/phaser/core/input_mouse.ts +13 -12
- package/src/phaser/core/input_pointer.test.ts +26 -26
- package/src/phaser/core/input_pointer.ts +4 -4
- package/src/phaser/core/input_touch.ts +8 -8
- package/src/phaser/core/loader.test.ts +26 -26
- package/src/phaser/core/loader.ts +63 -75
- package/src/phaser/core/loader_parser.test.ts +16 -16
- package/src/phaser/core/loader_parser.ts +16 -6
- package/src/phaser/core/raf.ts +1 -1
- package/src/phaser/core/registry.test.ts +6 -6
- package/src/phaser/core/scale_manager.ts +12 -11
- package/src/phaser/core/scene_manager.test.ts +30 -30
- package/src/phaser/core/scene_manager.ts +3 -3
- package/src/phaser/core/signal.test.ts +8 -8
- package/src/phaser/core/signal.ts +3 -3
- package/src/phaser/core/signal_dispatch.test.ts +30 -30
- package/src/phaser/core/sound.ts +45 -40
- package/src/phaser/core/sound_manager.ts +18 -22
- package/src/phaser/core/sound_sprite.ts +1 -1
- package/src/phaser/core/stage.ts +22 -12
- package/src/phaser/core/time.ts +1 -1
- package/src/phaser/core/timer.test.ts +47 -47
- package/src/phaser/core/timer.ts +2 -2
- package/src/phaser/core/tween.ts +34 -36
- package/src/phaser/core/tween_data.test.ts +119 -0
- package/src/phaser/core/tween_data.ts +54 -39
- package/src/phaser/core/tween_easing.test.ts +5 -5
- package/src/phaser/core/tween_manager.ts +2 -2
- package/src/phaser/display/bitmap_text.test.ts +30 -30
- package/src/phaser/display/bitmap_text.ts +3 -3
- package/src/phaser/display/button.ts +20 -18
- package/src/phaser/display/canvas/buffer.ts +2 -2
- package/src/phaser/display/canvas/graphics.ts +2 -2
- package/src/phaser/display/canvas/masker.ts +1 -1
- package/src/phaser/display/canvas/pool.test.ts +20 -20
- package/src/phaser/display/canvas/pool.ts +6 -6
- package/src/phaser/display/canvas/renderer.ts +18 -16
- package/src/phaser/display/canvas/tinter.ts +1 -1
- package/src/phaser/display/canvas/util.test.ts +25 -25
- package/src/phaser/display/canvas/util.ts +2 -2
- package/src/phaser/display/display_object.ts +16 -15
- package/src/phaser/display/graphics.test.ts +70 -20
- package/src/phaser/display/graphics.ts +46 -42
- package/src/phaser/display/group.ts +13 -12
- package/src/phaser/display/image.ts +35 -31
- package/src/phaser/display/sprite_util.ts +4 -3
- package/src/phaser/display/text.test.ts +28 -25
- package/src/phaser/display/text.ts +56 -62
- package/src/phaser/display/webgl/abstract_filter.ts +21 -11
- package/src/phaser/display/webgl/blend_manager.ts +4 -5
- package/src/phaser/display/webgl/earcut.test.ts +20 -20
- package/src/phaser/display/webgl/earcut.ts +46 -42
- package/src/phaser/display/webgl/fast_sprite_batch.ts +21 -16
- package/src/phaser/display/webgl/filter_manager.ts +7 -4
- package/src/phaser/display/webgl/filter_texture.ts +5 -5
- package/src/phaser/display/webgl/graphics.ts +3 -3
- package/src/phaser/display/webgl/mask_manager.ts +9 -14
- package/src/phaser/display/webgl/render_texture.ts +15 -14
- package/src/phaser/display/webgl/renderer.ts +10 -9
- package/src/phaser/display/webgl/shader/normal.ts +45 -35
- package/src/phaser/display/webgl/shader/shader.test.ts +24 -24
- package/src/phaser/display/webgl/shader_manager.test.ts +18 -18
- package/src/phaser/display/webgl/shader_manager.ts +1 -1
- package/src/phaser/display/webgl/sprite_batch.ts +10 -10
- package/src/phaser/display/webgl/stencil_manager.ts +4 -4
- package/src/phaser/display/webgl/texture.ts +2 -1
- package/src/phaser/display/webgl/texture_util.ts +2 -2
- package/src/phaser/display/webgl/util.ts +4 -4
- package/src/phaser/geom/circle.test.ts +38 -38
- package/src/phaser/geom/circle.ts +7 -7
- package/src/phaser/geom/ellipse.test.ts +12 -12
- package/src/phaser/geom/line.test.ts +15 -15
- package/src/phaser/geom/line.ts +5 -2
- package/src/phaser/geom/matrix.test.ts +31 -31
- package/src/phaser/geom/point.test.ts +31 -31
- package/src/phaser/geom/polygon.test.ts +27 -27
- package/src/phaser/geom/polygon.ts +2 -2
- package/src/phaser/geom/rectangle.test.ts +87 -87
- package/src/phaser/geom/rectangle.ts +12 -13
- package/src/phaser/geom/rounded_rectangle.test.ts +9 -9
- package/src/phaser/geom/util/circle.test.ts +5 -5
- package/src/phaser/geom/util/circle.ts +8 -11
- package/src/phaser/geom/util/ellipse.test.ts +2 -2
- package/src/phaser/geom/util/line.test.ts +2 -2
- package/src/phaser/geom/util/matrix.test.ts +4 -4
- package/src/phaser/geom/util/point.test.ts +2 -2
- package/src/phaser/geom/util/point.ts +6 -8
- package/src/phaser/geom/util/polygon.test.ts +2 -2
- package/src/phaser/geom/util/rectangle.test.ts +2 -2
- package/src/phaser/geom/util/rectangle.ts +1 -1
- package/src/phaser/geom/util/rounded_rectangle.test.ts +2 -2
- package/src/phaser/util/math.test.ts +41 -41
- package/src/phaser/util/math.ts +7 -5
|
@@ -3,9 +3,9 @@ import { TOP_LEFT } from '../core/const.js';
|
|
|
3
3
|
import { Point } from './point.js';
|
|
4
4
|
import { Rectangle } from './rectangle.js';
|
|
5
5
|
|
|
6
|
-
describe('Rectangle', () => {
|
|
7
|
-
describe('offset()', () => {
|
|
8
|
-
it('should update x and y properties when dx and dy are provided', () => {
|
|
6
|
+
describe('Rectangle', (): void => {
|
|
7
|
+
describe('offset()', (): void => {
|
|
8
|
+
it('should update x and y properties when dx and dy are provided', (): void => {
|
|
9
9
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
10
10
|
rect.offset(10, 20);
|
|
11
11
|
expect(rect.x).toBe(10);
|
|
@@ -13,8 +13,8 @@ describe('Rectangle', () => {
|
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
describe('offsetPoint()', () => {
|
|
17
|
-
it('should call offset() with point.x and point.y as arguments when a Point object is provided', () => {
|
|
16
|
+
describe('offsetPoint()', (): void => {
|
|
17
|
+
it('should call offset() with point.x and point.y as arguments when a Point object is provided', (): void => {
|
|
18
18
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
19
19
|
const point = new Point(15, 25);
|
|
20
20
|
rect.offsetPoint(point);
|
|
@@ -23,8 +23,8 @@ describe('Rectangle', () => {
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
describe('setTo()', () => {
|
|
27
|
-
it('should update x, y, width and height properties when all arguments are provided', () => {
|
|
26
|
+
describe('setTo()', (): void => {
|
|
27
|
+
it('should update x, y, width and height properties when all arguments are provided', (): void => {
|
|
28
28
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
29
29
|
rect.setTo(100, 200, 300, 400);
|
|
30
30
|
expect(rect.x).toBe(100);
|
|
@@ -34,15 +34,15 @@ describe('Rectangle', () => {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
describe('scale()', () => {
|
|
38
|
-
it('should update width and height properties when x is provided', () => {
|
|
37
|
+
describe('scale()', (): void => {
|
|
38
|
+
it('should update width and height properties when x is provided', (): void => {
|
|
39
39
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
40
40
|
rect.scale(2);
|
|
41
41
|
expect(rect.width).toBe(20);
|
|
42
42
|
expect(rect.height).toBe(20);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it('should update width and height properties when both x and y are provided', () => {
|
|
45
|
+
it('should update width and height properties when both x and y are provided', (): void => {
|
|
46
46
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
47
47
|
const point = new Point(3, 4);
|
|
48
48
|
rect.scale(point.x, point.y);
|
|
@@ -51,8 +51,8 @@ describe('Rectangle', () => {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
describe('centerOn()', () => {
|
|
55
|
-
it('should update centerX and centerY properties when both x and y are provided', () => {
|
|
54
|
+
describe('centerOn()', (): void => {
|
|
55
|
+
it('should update centerX and centerY properties when both x and y are provided', (): void => {
|
|
56
56
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
57
57
|
const point = new Point(150, 250);
|
|
58
58
|
rect.centerOn(point.x, point.y);
|
|
@@ -61,8 +61,8 @@ describe('Rectangle', () => {
|
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
describe('floor()', () => {
|
|
65
|
-
it('should update x and y properties by rounding down', () => {
|
|
64
|
+
describe('floor()', (): void => {
|
|
65
|
+
it('should update x and y properties by rounding down', (): void => {
|
|
66
66
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
67
67
|
rect.floor();
|
|
68
68
|
expect(rect.x).toBe(Math.floor(rect.x));
|
|
@@ -70,8 +70,8 @@ describe('Rectangle', () => {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe('floorAll()', () => {
|
|
74
|
-
it('should update x, y, width and height properties by rounding down', () => {
|
|
73
|
+
describe('floorAll()', (): void => {
|
|
74
|
+
it('should update x, y, width and height properties by rounding down', (): void => {
|
|
75
75
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
76
76
|
rect.floorAll();
|
|
77
77
|
expect(rect.x).toBe(Math.floor(rect.x));
|
|
@@ -81,8 +81,8 @@ describe('Rectangle', () => {
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
describe('ceil()', () => {
|
|
85
|
-
it('should update x and y properties by rounding up', () => {
|
|
84
|
+
describe('ceil()', (): void => {
|
|
85
|
+
it('should update x and y properties by rounding up', (): void => {
|
|
86
86
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
87
87
|
rect.ceil();
|
|
88
88
|
expect(rect.x).toBe(Math.ceil(rect.x));
|
|
@@ -90,8 +90,8 @@ describe('Rectangle', () => {
|
|
|
90
90
|
});
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
describe('ceilAll()', () => {
|
|
94
|
-
it('should update x, y, width and height properties by rounding up', () => {
|
|
93
|
+
describe('ceilAll()', (): void => {
|
|
94
|
+
it('should update x, y, width and height properties by rounding up', (): void => {
|
|
95
95
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
96
96
|
rect.ceilAll();
|
|
97
97
|
expect(rect.x).toBe(Math.ceil(rect.x));
|
|
@@ -101,8 +101,8 @@ describe('Rectangle', () => {
|
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
describe('copyFrom()', () => {
|
|
105
|
-
it('should return a new Rectangle object with the same properties as the provided rectangle', () => {
|
|
104
|
+
describe('copyFrom()', (): void => {
|
|
105
|
+
it('should return a new Rectangle object with the same properties as the provided rectangle', (): void => {
|
|
106
106
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
107
107
|
const source = new Rectangle();
|
|
108
108
|
source.setTo(500, 600, 700, 800);
|
|
@@ -114,8 +114,8 @@ describe('Rectangle', () => {
|
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
describe('copyTo()', () => {
|
|
118
|
-
it('should update the provided rectangle with the same properties as this rectangle', () => {
|
|
117
|
+
describe('copyTo()', (): void => {
|
|
118
|
+
it('should update the provided rectangle with the same properties as this rectangle', (): void => {
|
|
119
119
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
120
120
|
const dest = new Rectangle();
|
|
121
121
|
rect.setTo(50, 60, 70, 80);
|
|
@@ -127,8 +127,8 @@ describe('Rectangle', () => {
|
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
describe('inflate()', () => {
|
|
131
|
-
it('should call the inflate() function from another module with this rectangle and dx and dy as arguments', () => {
|
|
130
|
+
describe('inflate()', (): void => {
|
|
131
|
+
it('should call the inflate() function from another module with this rectangle and dx and dy as arguments', (): void => {
|
|
132
132
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
133
133
|
const inflated = rect.inflate(10, 20);
|
|
134
134
|
expect(inflated.x).toBe(-10);
|
|
@@ -136,8 +136,8 @@ describe('Rectangle', () => {
|
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
describe('size()', () => {
|
|
140
|
-
it('should call the size() function from another module with this rectangle and an output point as arguments', () => {
|
|
139
|
+
describe('size()', (): void => {
|
|
140
|
+
it('should call the size() function from another module with this rectangle and an output point as arguments', (): void => {
|
|
141
141
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
142
142
|
const point = new Point();
|
|
143
143
|
const sized = rect.size(point);
|
|
@@ -146,8 +146,8 @@ describe('Rectangle', () => {
|
|
|
146
146
|
});
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
describe('resize()', () => {
|
|
150
|
-
it('should update width and height properties when both x and y are provided', () => {
|
|
149
|
+
describe('resize()', (): void => {
|
|
150
|
+
it('should update width and height properties when both x and y are provided', (): void => {
|
|
151
151
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
152
152
|
rect.resize(120, 140);
|
|
153
153
|
expect(rect.width).toBe(120);
|
|
@@ -155,8 +155,8 @@ describe('Rectangle', () => {
|
|
|
155
155
|
});
|
|
156
156
|
});
|
|
157
157
|
|
|
158
|
-
describe('clone()', () => {
|
|
159
|
-
it('should return a new Rectangle object with the same properties as this rectangle', () => {
|
|
158
|
+
describe('clone()', (): void => {
|
|
159
|
+
it('should return a new Rectangle object with the same properties as this rectangle', (): void => {
|
|
160
160
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
161
161
|
const clone = rect.clone();
|
|
162
162
|
expect(clone.x).toBe(rect.x);
|
|
@@ -166,15 +166,15 @@ describe('Rectangle', () => {
|
|
|
166
166
|
});
|
|
167
167
|
});
|
|
168
168
|
|
|
169
|
-
describe('contains()', () => {
|
|
170
|
-
it('should return true if the point x, y is within this rectangle', () => {
|
|
169
|
+
describe('contains()', (): void => {
|
|
170
|
+
it('should return true if the point x, y is within this rectangle', (): void => {
|
|
171
171
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
172
172
|
rect.setTo(100, 200, 300, 400);
|
|
173
173
|
const contains = rect.contains(150, 250);
|
|
174
174
|
expect(contains).toBe(true);
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
it('should return false if the point x, y is outside this rectangle', () => {
|
|
177
|
+
it('should return false if the point x, y is outside this rectangle', (): void => {
|
|
178
178
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
179
179
|
rect.setTo(100, 200, 300, 400);
|
|
180
180
|
const contains = rect.contains(500, 600);
|
|
@@ -182,8 +182,8 @@ describe('Rectangle', () => {
|
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
describe('containsRect()', () => {
|
|
186
|
-
it('should return true if the rectangle b is within this rectangle', () => {
|
|
185
|
+
describe('containsRect()', (): void => {
|
|
186
|
+
it('should return true if the rectangle b is within this rectangle', (): void => {
|
|
187
187
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
188
188
|
const source = new Rectangle();
|
|
189
189
|
source.setTo(100, 200, 300, 400);
|
|
@@ -191,7 +191,7 @@ describe('Rectangle', () => {
|
|
|
191
191
|
expect(contains).toBe(false);
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
it('should return false if the rectangle b is outside this rectangle', () => {
|
|
194
|
+
it('should return false if the rectangle b is outside this rectangle', (): void => {
|
|
195
195
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
196
196
|
const source = new Rectangle();
|
|
197
197
|
source.setTo(-500, -600, 700, 800);
|
|
@@ -200,8 +200,8 @@ describe('Rectangle', () => {
|
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
describe('equals()', () => {
|
|
204
|
-
it('should return true if the rectangle b has the same properties as this rectangle', () => {
|
|
203
|
+
describe('equals()', (): void => {
|
|
204
|
+
it('should return true if the rectangle b has the same properties as this rectangle', (): void => {
|
|
205
205
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
206
206
|
const source = new Rectangle();
|
|
207
207
|
source.setTo(100, 200, 300, 400);
|
|
@@ -209,7 +209,7 @@ describe('Rectangle', () => {
|
|
|
209
209
|
expect(equals).toBe(false);
|
|
210
210
|
});
|
|
211
211
|
|
|
212
|
-
it('should return false if the rectangle b does not have the same properties as this rectangle', () => {
|
|
212
|
+
it('should return false if the rectangle b does not have the same properties as this rectangle', (): void => {
|
|
213
213
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
214
214
|
const source = new Rectangle();
|
|
215
215
|
source.setTo(-500, -600, 700, 800);
|
|
@@ -218,8 +218,8 @@ describe('Rectangle', () => {
|
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
-
describe('intersection()', () => {
|
|
222
|
-
it('should return a new Rectangle object that represents the intersection of this rectangle and b', () => {
|
|
221
|
+
describe('intersection()', (): void => {
|
|
222
|
+
it('should return a new Rectangle object that represents the intersection of this rectangle and b', (): void => {
|
|
223
223
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
224
224
|
const source = new Rectangle();
|
|
225
225
|
source.setTo(100, 200, 300, 400);
|
|
@@ -231,8 +231,8 @@ describe('Rectangle', () => {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
describe('intersects()', () => {
|
|
235
|
-
it('should return true if the rectangle b intersects with this rectangle', () => {
|
|
234
|
+
describe('intersects()', (): void => {
|
|
235
|
+
it('should return true if the rectangle b intersects with this rectangle', (): void => {
|
|
236
236
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
237
237
|
const source = new Rectangle();
|
|
238
238
|
source.setTo(100, 200, 300, 400);
|
|
@@ -240,7 +240,7 @@ describe('Rectangle', () => {
|
|
|
240
240
|
expect(intersects).toBe(false);
|
|
241
241
|
});
|
|
242
242
|
|
|
243
|
-
it('should return false if the rectangle b does not intersect with this rectangle', () => {
|
|
243
|
+
it('should return false if the rectangle b does not intersect with this rectangle', (): void => {
|
|
244
244
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
245
245
|
const source = new Rectangle();
|
|
246
246
|
source.setTo(-500, -600, 700, 800);
|
|
@@ -249,8 +249,8 @@ describe('Rectangle', () => {
|
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
-
describe('intersectsRaw()', () => {
|
|
253
|
-
it('should return true if the rectangle b intersects with this rectangle at left, right, top and bottom', () => {
|
|
252
|
+
describe('intersectsRaw()', (): void => {
|
|
253
|
+
it('should return true if the rectangle b intersects with this rectangle at left, right, top and bottom', (): void => {
|
|
254
254
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
255
255
|
const source = new Rectangle();
|
|
256
256
|
source.setTo(100, 200, 300, 400);
|
|
@@ -258,7 +258,7 @@ describe('Rectangle', () => {
|
|
|
258
258
|
expect(intersects).toBe(false);
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
it('should return false if the rectangle b does not intersect with this rectangle at left, right, top and bottom', () => {
|
|
261
|
+
it('should return false if the rectangle b does not intersect with this rectangle at left, right, top and bottom', (): void => {
|
|
262
262
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
263
263
|
const source = new Rectangle();
|
|
264
264
|
source.setTo(-500, -600, 700, 800);
|
|
@@ -267,8 +267,8 @@ describe('Rectangle', () => {
|
|
|
267
267
|
});
|
|
268
268
|
});
|
|
269
269
|
|
|
270
|
-
describe('union()', () => {
|
|
271
|
-
it('should return a new Rectangle object that represents the union of this rectangle and b', () => {
|
|
270
|
+
describe('union()', (): void => {
|
|
271
|
+
it('should return a new Rectangle object that represents the union of this rectangle and b', (): void => {
|
|
272
272
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
273
273
|
const source = new Rectangle();
|
|
274
274
|
source.setTo(100, 200, 300, 400);
|
|
@@ -280,8 +280,8 @@ describe('Rectangle', () => {
|
|
|
280
280
|
});
|
|
281
281
|
});
|
|
282
282
|
|
|
283
|
-
describe('random()', () => {
|
|
284
|
-
it('should return a new Point object with x and y coordinates within this rectangle', () => {
|
|
283
|
+
describe('random()', (): void => {
|
|
284
|
+
it('should return a new Point object with x and y coordinates within this rectangle', (): void => {
|
|
285
285
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
286
286
|
const random = rect.random();
|
|
287
287
|
expect(random.x >= rect.left && random.x <= rect.right).toBe(true);
|
|
@@ -289,8 +289,8 @@ describe('Rectangle', () => {
|
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
-
describe('getPoint()', () => {
|
|
293
|
-
it('should return a new Point object at the specified position within this rectangle', () => {
|
|
292
|
+
describe('getPoint()', (): void => {
|
|
293
|
+
it('should return a new Point object at the specified position within this rectangle', (): void => {
|
|
294
294
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
295
295
|
const point = rect.getPoint(TOP_LEFT);
|
|
296
296
|
expect(point.x).toBe(rect.left);
|
|
@@ -298,8 +298,8 @@ describe('Rectangle', () => {
|
|
|
298
298
|
});
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
describe('toString()', () => {
|
|
302
|
-
it('should return a string representation of this rectangle', () => {
|
|
301
|
+
describe('toString()', (): void => {
|
|
302
|
+
it('should return a string representation of this rectangle', (): void => {
|
|
303
303
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
304
304
|
const string = rect.toString();
|
|
305
305
|
expect(string).toContain(`x=${rect.x}`);
|
|
@@ -309,24 +309,24 @@ describe('Rectangle', () => {
|
|
|
309
309
|
});
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
-
describe('halfWidth', () => {
|
|
313
|
-
it('should return half the width of this rectangle', () => {
|
|
312
|
+
describe('halfWidth', (): void => {
|
|
313
|
+
it('should return half the width of this rectangle', (): void => {
|
|
314
314
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
315
315
|
const half = rect.halfWidth;
|
|
316
316
|
expect(half).toBe(Math.round(rect.width / 2));
|
|
317
317
|
});
|
|
318
318
|
});
|
|
319
319
|
|
|
320
|
-
describe('halfHeight', () => {
|
|
321
|
-
it('should return half the height of this rectangle', () => {
|
|
320
|
+
describe('halfHeight', (): void => {
|
|
321
|
+
it('should return half the height of this rectangle', (): void => {
|
|
322
322
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
323
323
|
const half = rect.halfHeight;
|
|
324
324
|
expect(half).toBe(Math.round(rect.height / 2));
|
|
325
325
|
});
|
|
326
326
|
});
|
|
327
327
|
|
|
328
|
-
describe('top', () => {
|
|
329
|
-
it('should get and set the top coordinate of this rectangle', () => {
|
|
328
|
+
describe('top', (): void => {
|
|
329
|
+
it('should get and set the top coordinate of this rectangle', (): void => {
|
|
330
330
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
331
331
|
const { top } = rect;
|
|
332
332
|
expect(top).toBe(rect.y);
|
|
@@ -335,8 +335,8 @@ describe('Rectangle', () => {
|
|
|
335
335
|
});
|
|
336
336
|
});
|
|
337
337
|
|
|
338
|
-
describe('left', () => {
|
|
339
|
-
it('should get and set the left coordinate of this rectangle', () => {
|
|
338
|
+
describe('left', (): void => {
|
|
339
|
+
it('should get and set the left coordinate of this rectangle', (): void => {
|
|
340
340
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
341
341
|
const { left } = rect;
|
|
342
342
|
expect(left).toBe(rect.x);
|
|
@@ -345,8 +345,8 @@ describe('Rectangle', () => {
|
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
347
|
|
|
348
|
-
describe('right', () => {
|
|
349
|
-
it('should get and set the right coordinate of this rectangle', () => {
|
|
348
|
+
describe('right', (): void => {
|
|
349
|
+
it('should get and set the right coordinate of this rectangle', (): void => {
|
|
350
350
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
351
351
|
const { right } = rect;
|
|
352
352
|
expect(right).toBe(rect.x + rect.width);
|
|
@@ -355,8 +355,8 @@ describe('Rectangle', () => {
|
|
|
355
355
|
});
|
|
356
356
|
});
|
|
357
357
|
|
|
358
|
-
describe('bottom', () => {
|
|
359
|
-
it('should get and set the bottom coordinate of this rectangle', () => {
|
|
358
|
+
describe('bottom', (): void => {
|
|
359
|
+
it('should get and set the bottom coordinate of this rectangle', (): void => {
|
|
360
360
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
361
361
|
const { bottom } = rect;
|
|
362
362
|
expect(bottom).toBe(rect.y + rect.height);
|
|
@@ -365,8 +365,8 @@ describe('Rectangle', () => {
|
|
|
365
365
|
});
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
describe('topLeft', () => {
|
|
369
|
-
it('should get and set the top-left coordinates of this rectangle', () => {
|
|
368
|
+
describe('topLeft', (): void => {
|
|
369
|
+
it('should get and set the top-left coordinates of this rectangle', (): void => {
|
|
370
370
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
371
371
|
const { topLeft } = rect;
|
|
372
372
|
expect(topLeft.x).toBe(rect.left);
|
|
@@ -377,8 +377,8 @@ describe('Rectangle', () => {
|
|
|
377
377
|
});
|
|
378
378
|
});
|
|
379
379
|
|
|
380
|
-
describe('topRight', () => {
|
|
381
|
-
it('should get and set the top-right coordinates of this rectangle', () => {
|
|
380
|
+
describe('topRight', (): void => {
|
|
381
|
+
it('should get and set the top-right coordinates of this rectangle', (): void => {
|
|
382
382
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
383
383
|
const { topRight } = rect;
|
|
384
384
|
expect(topRight.x).toBe(rect.right);
|
|
@@ -389,8 +389,8 @@ describe('Rectangle', () => {
|
|
|
389
389
|
});
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
-
describe('bottomLeft', () => {
|
|
393
|
-
it('should get and set the bottom-left coordinates of this rectangle', () => {
|
|
392
|
+
describe('bottomLeft', (): void => {
|
|
393
|
+
it('should get and set the bottom-left coordinates of this rectangle', (): void => {
|
|
394
394
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
395
395
|
const { bottomLeft } = rect;
|
|
396
396
|
expect(bottomLeft.x).toBe(rect.left);
|
|
@@ -401,8 +401,8 @@ describe('Rectangle', () => {
|
|
|
401
401
|
});
|
|
402
402
|
});
|
|
403
403
|
|
|
404
|
-
describe('bottomRight', () => {
|
|
405
|
-
it('should get and set the bottom-right coordinates of this rectangle', () => {
|
|
404
|
+
describe('bottomRight', (): void => {
|
|
405
|
+
it('should get and set the bottom-right coordinates of this rectangle', (): void => {
|
|
406
406
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
407
407
|
const { bottomRight } = rect;
|
|
408
408
|
expect(bottomRight.x).toBe(rect.right);
|
|
@@ -413,8 +413,8 @@ describe('Rectangle', () => {
|
|
|
413
413
|
});
|
|
414
414
|
});
|
|
415
415
|
|
|
416
|
-
describe('centerX', () => {
|
|
417
|
-
it('should get and set the center x coordinate of this rectangle', () => {
|
|
416
|
+
describe('centerX', (): void => {
|
|
417
|
+
it('should get and set the center x coordinate of this rectangle', (): void => {
|
|
418
418
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
419
419
|
const { centerX } = rect;
|
|
420
420
|
expect(centerX).toBe(rect.x + rect.halfWidth);
|
|
@@ -423,8 +423,8 @@ describe('Rectangle', () => {
|
|
|
423
423
|
});
|
|
424
424
|
});
|
|
425
425
|
|
|
426
|
-
describe('centerY', () => {
|
|
427
|
-
it('should get and set the center y coordinate of this rectangle', () => {
|
|
426
|
+
describe('centerY', (): void => {
|
|
427
|
+
it('should get and set the center y coordinate of this rectangle', (): void => {
|
|
428
428
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
429
429
|
const { centerY } = rect;
|
|
430
430
|
expect(centerY).toBe(rect.y + rect.halfHeight);
|
|
@@ -433,24 +433,24 @@ describe('Rectangle', () => {
|
|
|
433
433
|
});
|
|
434
434
|
});
|
|
435
435
|
|
|
436
|
-
describe('randomX', () => {
|
|
437
|
-
it('should return a random x coordinate within this rectangle', () => {
|
|
436
|
+
describe('randomX', (): void => {
|
|
437
|
+
it('should return a random x coordinate within this rectangle', (): void => {
|
|
438
438
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
439
439
|
const { randomX } = rect;
|
|
440
440
|
expect(randomX >= rect.left && randomX <= rect.right).toBe(true);
|
|
441
441
|
});
|
|
442
442
|
});
|
|
443
443
|
|
|
444
|
-
describe('randomY', () => {
|
|
445
|
-
it('should return a random y coordinate within this rectangle', () => {
|
|
444
|
+
describe('randomY', (): void => {
|
|
445
|
+
it('should return a random y coordinate within this rectangle', (): void => {
|
|
446
446
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
447
447
|
const { randomY } = rect;
|
|
448
448
|
expect(randomY >= rect.top && randomY <= rect.bottom).toBe(true);
|
|
449
449
|
});
|
|
450
450
|
});
|
|
451
451
|
|
|
452
|
-
describe('empty', () => {
|
|
453
|
-
it('should get and set whether this rectangle is empty or not', () => {
|
|
452
|
+
describe('empty', (): void => {
|
|
453
|
+
it('should get and set whether this rectangle is empty or not', (): void => {
|
|
454
454
|
const rect = new Rectangle(0, 0, 10, 10);
|
|
455
455
|
const { empty } = rect;
|
|
456
456
|
expect(empty).toBe(!rect.width || !rect.height);
|
|
@@ -95,9 +95,8 @@ export class Rectangle {
|
|
|
95
95
|
* @returns {Rectangle} This rectangle instance for chaining.
|
|
96
96
|
*/
|
|
97
97
|
public scale(x: number, y?: number): this {
|
|
98
|
-
y ??= x;
|
|
99
98
|
this.width *= x;
|
|
100
|
-
this.height *= y;
|
|
99
|
+
this.height *= y ?? x;
|
|
101
100
|
return this;
|
|
102
101
|
}
|
|
103
102
|
|
|
@@ -370,7 +369,7 @@ export class Rectangle {
|
|
|
370
369
|
/**
|
|
371
370
|
* Sets the top coordinate of this rectangle.
|
|
372
371
|
*/
|
|
373
|
-
public set top(value) {
|
|
372
|
+
public set top(value: number) {
|
|
374
373
|
if (value >= this.bottom) {
|
|
375
374
|
this.height = 0;
|
|
376
375
|
this.y = value;
|
|
@@ -390,7 +389,7 @@ export class Rectangle {
|
|
|
390
389
|
/**
|
|
391
390
|
* Sets the top-left point of this rectangle.
|
|
392
391
|
*/
|
|
393
|
-
public set topLeft(value) {
|
|
392
|
+
public set topLeft(value: Point) {
|
|
394
393
|
this.x = value.x;
|
|
395
394
|
this.y = value.y;
|
|
396
395
|
}
|
|
@@ -406,7 +405,7 @@ export class Rectangle {
|
|
|
406
405
|
/**
|
|
407
406
|
* Sets the top-right point of this rectangle.
|
|
408
407
|
*/
|
|
409
|
-
public set topRight(value) {
|
|
408
|
+
public set topRight(value: Point) {
|
|
410
409
|
this.right = value.x;
|
|
411
410
|
this.y = value.y;
|
|
412
411
|
}
|
|
@@ -422,7 +421,7 @@ export class Rectangle {
|
|
|
422
421
|
/**
|
|
423
422
|
* Sets the bottom coordinate of this rectangle.
|
|
424
423
|
*/
|
|
425
|
-
public set bottom(value) {
|
|
424
|
+
public set bottom(value: number) {
|
|
426
425
|
this.height = value <= this.y ? 0 : value - this.y;
|
|
427
426
|
}
|
|
428
427
|
|
|
@@ -437,7 +436,7 @@ export class Rectangle {
|
|
|
437
436
|
/**
|
|
438
437
|
* Sets the bottom-left point of this rectangle.
|
|
439
438
|
*/
|
|
440
|
-
public set bottomLeft(value) {
|
|
439
|
+
public set bottomLeft(value: Point) {
|
|
441
440
|
this.x = value.x;
|
|
442
441
|
this.bottom = value.y;
|
|
443
442
|
}
|
|
@@ -453,7 +452,7 @@ export class Rectangle {
|
|
|
453
452
|
/**
|
|
454
453
|
* Sets the bottom-right point of this rectangle.
|
|
455
454
|
*/
|
|
456
|
-
public set bottomRight(value) {
|
|
455
|
+
public set bottomRight(value: Point) {
|
|
457
456
|
this.right = value.x;
|
|
458
457
|
this.bottom = value.y;
|
|
459
458
|
}
|
|
@@ -469,7 +468,7 @@ export class Rectangle {
|
|
|
469
468
|
/**
|
|
470
469
|
* Sets the left coordinate of this rectangle.
|
|
471
470
|
*/
|
|
472
|
-
public set left(value) {
|
|
471
|
+
public set left(value: number) {
|
|
473
472
|
this.width = value >= this.right ? 0 : this.right - value;
|
|
474
473
|
this.x = value;
|
|
475
474
|
}
|
|
@@ -485,7 +484,7 @@ export class Rectangle {
|
|
|
485
484
|
/**
|
|
486
485
|
* Sets the right coordinate of this rectangle.
|
|
487
486
|
*/
|
|
488
|
-
public set right(value) {
|
|
487
|
+
public set right(value: number) {
|
|
489
488
|
this.width = value <= this.x ? 0 : value - this.x;
|
|
490
489
|
}
|
|
491
490
|
|
|
@@ -516,7 +515,7 @@ export class Rectangle {
|
|
|
516
515
|
/**
|
|
517
516
|
* Sets the x coordinate of the center of this rectangle.
|
|
518
517
|
*/
|
|
519
|
-
public set centerX(value) {
|
|
518
|
+
public set centerX(value: number) {
|
|
520
519
|
this.x = value - this.halfWidth;
|
|
521
520
|
}
|
|
522
521
|
|
|
@@ -531,7 +530,7 @@ export class Rectangle {
|
|
|
531
530
|
/**
|
|
532
531
|
* Sets the y coordinate of the center of this rectangle.
|
|
533
532
|
*/
|
|
534
|
-
public set centerY(value) {
|
|
533
|
+
public set centerY(value: number) {
|
|
535
534
|
this.y = value - this.halfHeight;
|
|
536
535
|
}
|
|
537
536
|
|
|
@@ -562,7 +561,7 @@ export class Rectangle {
|
|
|
562
561
|
/**
|
|
563
562
|
* Sets whether this rectangle is empty (zero width or height).
|
|
564
563
|
*/
|
|
565
|
-
public set empty(value) {
|
|
564
|
+
public set empty(value: boolean) {
|
|
566
565
|
if (value) {
|
|
567
566
|
this.setTo(0, 0, 0, 0);
|
|
568
567
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { expect, describe, it } from 'vitest';
|
|
2
2
|
import { RoundedRectangle } from './rounded_rectangle.js';
|
|
3
3
|
|
|
4
|
-
describe('RoundedRectangle Constructor', () => {
|
|
5
|
-
it('should create a new instance with correct properties', () => {
|
|
4
|
+
describe('RoundedRectangle Constructor', (): void => {
|
|
5
|
+
it('should create a new instance with correct properties', (): void => {
|
|
6
6
|
const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
|
|
7
7
|
expect(rectangle.x).toBe(10);
|
|
8
8
|
expect(rectangle.y).toBe(20);
|
|
@@ -12,8 +12,8 @@ describe('RoundedRectangle Constructor', () => {
|
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
describe('RoundedRectangle contains Method', () => {
|
|
16
|
-
it('should return false for zero width or height', () => {
|
|
15
|
+
describe('RoundedRectangle contains Method', (): void => {
|
|
16
|
+
it('should return false for zero width or height', (): void => {
|
|
17
17
|
const rectangle = new RoundedRectangle(10, 20, 0, 40, 5);
|
|
18
18
|
expect(rectangle.contains(15, 25)).toBe(false);
|
|
19
19
|
|
|
@@ -21,12 +21,12 @@ describe('RoundedRectangle contains Method', () => {
|
|
|
21
21
|
expect(rectangle2.contains(15, 25)).toBe(false);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('should return true for a point inside the rectangle', () => {
|
|
24
|
+
it('should return true for a point inside the rectangle', (): void => {
|
|
25
25
|
const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
|
|
26
26
|
expect(rectangle.contains(15, 25)).toBe(true);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it("should return true for a point on the rectangle's edge", () => {
|
|
29
|
+
it("should return true for a point on the rectangle's edge", (): void => {
|
|
30
30
|
const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
|
|
31
31
|
expect(rectangle.contains(0, 25)).toBe(false);
|
|
32
32
|
expect(rectangle.contains(30, 25)).toBe(true);
|
|
@@ -34,15 +34,15 @@ describe('RoundedRectangle contains Method', () => {
|
|
|
34
34
|
expect(rectangle.contains(15, 40)).toBe(true);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
it('should return false for a point outside the rectangle', () => {
|
|
37
|
+
it('should return false for a point outside the rectangle', (): void => {
|
|
38
38
|
const rectangle = new RoundedRectangle(10, 20, 30, 40, 5);
|
|
39
39
|
expect(rectangle.contains(-1, -1)).toBe(false);
|
|
40
40
|
expect(rectangle.contains(50, 60)).toBe(false);
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
describe('RoundedRectangle clone Method', () => {
|
|
45
|
-
it('should create a deep copy of the original rectangle', () => {
|
|
44
|
+
describe('RoundedRectangle clone Method', (): void => {
|
|
45
|
+
it('should create a deep copy of the original rectangle', (): void => {
|
|
46
46
|
const original = new RoundedRectangle(10, 20, 30, 40, 5);
|
|
47
47
|
const clone = original.clone();
|
|
48
48
|
expect(clone.x).toBe(original.x);
|
|
@@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
import { Circle } from '../circle.js';
|
|
3
3
|
import { clone, contains, equals, intersects } from './circle.js';
|
|
4
4
|
|
|
5
|
-
describe('circle utils', () => {
|
|
6
|
-
it('should clone a circle', () => {
|
|
5
|
+
describe('circle utils', (): void => {
|
|
6
|
+
it('should clone a circle', (): void => {
|
|
7
7
|
const circle1 = new Circle(0, 0, 10);
|
|
8
8
|
const circle2 = clone(circle1);
|
|
9
9
|
expect(circle1.x).toBe(circle2.x);
|
|
@@ -11,12 +11,12 @@ describe('circle utils', () => {
|
|
|
11
11
|
expect(circle1.radius).toBe(circle2.radius);
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it('should contain a point in a circle', () => {
|
|
14
|
+
it('should contain a point in a circle', (): void => {
|
|
15
15
|
const circle = new Circle(5, 5, 10);
|
|
16
16
|
expect(contains(circle, 5, 5)).toBe(true);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('should match two circles', () => {
|
|
19
|
+
it('should match two circles', (): void => {
|
|
20
20
|
const circle1 = new Circle(5, 5, 10);
|
|
21
21
|
const circle2 = new Circle(5, 5, 10);
|
|
22
22
|
expect(equals(circle1, circle2)).toBe(true);
|
|
@@ -24,7 +24,7 @@ describe('circle utils', () => {
|
|
|
24
24
|
expect(equals(circle1, circle2)).toBe(false);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
it('should intersects two circles', () => {
|
|
27
|
+
it('should intersects two circles', (): void => {
|
|
28
28
|
const circle1 = new Circle(5, 5, 10);
|
|
29
29
|
const circle2 = new Circle(5, 5, 5);
|
|
30
30
|
expect(intersects(circle1, circle2)).toBe(true);
|