@vpmedia/phaser 1.94.0 → 1.96.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.
Files changed (205) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/package.json +11 -11
  3. package/src/phaser/core/animation.js +79 -56
  4. package/src/phaser/core/animation_manager.js +55 -55
  5. package/src/phaser/core/animation_parser.js +2 -2
  6. package/src/phaser/core/cache.js +154 -154
  7. package/src/phaser/core/device.js +2 -1
  8. package/src/phaser/core/device_util.js +27 -27
  9. package/src/phaser/core/dom.js +43 -43
  10. package/src/phaser/core/event_manager.js +63 -63
  11. package/src/phaser/core/factory.js +47 -47
  12. package/src/phaser/core/frame.js +30 -30
  13. package/src/phaser/core/frame_data.js +30 -28
  14. package/src/phaser/core/frame_util.js +8 -8
  15. package/src/phaser/core/game.js +35 -19
  16. package/src/phaser/core/input_pointer.js +18 -0
  17. package/src/phaser/core/loader.js +171 -171
  18. package/src/phaser/core/loader_parser.js +22 -22
  19. package/src/phaser/core/raf.js +1 -1
  20. package/src/phaser/core/scale_manager.js +3 -2
  21. package/src/phaser/core/scene.js +16 -10
  22. package/src/phaser/core/scene_manager.js +51 -43
  23. package/src/phaser/core/signal.js +56 -52
  24. package/src/phaser/core/sound.js +54 -54
  25. package/src/phaser/core/sound_manager.js +49 -49
  26. package/src/phaser/core/stage.js +16 -16
  27. package/src/phaser/core/time.js +54 -30
  28. package/src/phaser/core/timer.js +82 -64
  29. package/src/phaser/core/timer_event.js +9 -9
  30. package/src/phaser/core/tween.js +106 -90
  31. package/src/phaser/core/tween_data.js +30 -30
  32. package/src/phaser/core/tween_manager.js +32 -24
  33. package/src/phaser/core/world.js +4 -3
  34. package/src/phaser/display/bitmap_text.js +72 -54
  35. package/src/phaser/display/button.js +48 -47
  36. package/src/phaser/display/canvas/buffer.js +8 -8
  37. package/src/phaser/display/canvas/graphics.js +8 -8
  38. package/src/phaser/display/canvas/masker.js +5 -5
  39. package/src/phaser/display/canvas/pool.js +18 -18
  40. package/src/phaser/display/canvas/renderer.js +17 -16
  41. package/src/phaser/display/canvas/tinter.js +22 -22
  42. package/src/phaser/display/canvas/util.js +42 -42
  43. package/src/phaser/display/display_object.js +119 -108
  44. package/src/phaser/display/graphics.js +129 -112
  45. package/src/phaser/display/graphics_data.js +10 -10
  46. package/src/phaser/display/graphics_data_util.js +3 -3
  47. package/src/phaser/display/group.js +63 -50
  48. package/src/phaser/display/image.js +68 -50
  49. package/src/phaser/display/sprite_batch.js +2 -2
  50. package/src/phaser/display/sprite_util.js +19 -19
  51. package/src/phaser/display/text.js +217 -187
  52. package/src/phaser/display/webgl/abstract_filter.js +4 -4
  53. package/src/phaser/display/webgl/base_texture.js +9 -9
  54. package/src/phaser/display/webgl/blend_manager.js +7 -7
  55. package/src/phaser/display/webgl/earcut.js +95 -95
  56. package/src/phaser/display/webgl/earcut_node.js +4 -4
  57. package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
  58. package/src/phaser/display/webgl/filter_manager.js +9 -9
  59. package/src/phaser/display/webgl/filter_texture.js +10 -10
  60. package/src/phaser/display/webgl/graphics.js +37 -37
  61. package/src/phaser/display/webgl/graphics_data.js +4 -4
  62. package/src/phaser/display/webgl/mask_manager.js +6 -6
  63. package/src/phaser/display/webgl/render_texture.js +16 -16
  64. package/src/phaser/display/webgl/renderer.js +21 -20
  65. package/src/phaser/display/webgl/shader/complex.js +4 -4
  66. package/src/phaser/display/webgl/shader/fast.js +4 -4
  67. package/src/phaser/display/webgl/shader/normal.js +8 -8
  68. package/src/phaser/display/webgl/shader/primitive.js +4 -4
  69. package/src/phaser/display/webgl/shader/strip.js +4 -4
  70. package/src/phaser/display/webgl/shader_manager.js +9 -9
  71. package/src/phaser/display/webgl/sprite_batch.js +18 -18
  72. package/src/phaser/display/webgl/stencil_manager.js +16 -16
  73. package/src/phaser/display/webgl/texture.js +13 -13
  74. package/src/phaser/display/webgl/texture_util.js +8 -8
  75. package/src/phaser/display/webgl/util.js +25 -25
  76. package/src/phaser/geom/circle.js +74 -69
  77. package/src/phaser/geom/ellipse.js +33 -28
  78. package/src/phaser/geom/line.js +96 -93
  79. package/src/phaser/geom/matrix.js +61 -54
  80. package/src/phaser/geom/point.js +99 -96
  81. package/src/phaser/geom/polygon.js +27 -22
  82. package/src/phaser/geom/rectangle.js +137 -132
  83. package/src/phaser/geom/rounded_rectangle.js +12 -12
  84. package/src/phaser/geom/util/circle.js +33 -33
  85. package/src/phaser/geom/util/ellipse.js +5 -5
  86. package/src/phaser/geom/util/line.js +26 -26
  87. package/src/phaser/geom/util/matrix.js +8 -8
  88. package/src/phaser/geom/util/point.js +97 -97
  89. package/src/phaser/geom/util/polygon.js +4 -4
  90. package/src/phaser/geom/util/rectangle.js +74 -74
  91. package/src/phaser/geom/util/rounded_rectangle.js +4 -4
  92. package/src/phaser/util/math.js +81 -81
  93. package/types/phaser/core/animation.d.ts +79 -56
  94. package/types/phaser/core/animation.d.ts.map +1 -1
  95. package/types/phaser/core/animation_manager.d.ts +55 -55
  96. package/types/phaser/core/animation_parser.d.ts +3 -2
  97. package/types/phaser/core/animation_parser.d.ts.map +1 -1
  98. package/types/phaser/core/cache.d.ts +154 -154
  99. package/types/phaser/core/device.d.ts.map +1 -1
  100. package/types/phaser/core/dom.d.ts +51 -44
  101. package/types/phaser/core/dom.d.ts.map +1 -1
  102. package/types/phaser/core/event_manager.d.ts +63 -63
  103. package/types/phaser/core/factory.d.ts +47 -47
  104. package/types/phaser/core/frame.d.ts +30 -30
  105. package/types/phaser/core/frame_data.d.ts +28 -27
  106. package/types/phaser/core/frame_data.d.ts.map +1 -1
  107. package/types/phaser/core/game.d.ts +54 -21
  108. package/types/phaser/core/game.d.ts.map +1 -1
  109. package/types/phaser/core/input_pointer.d.ts +18 -0
  110. package/types/phaser/core/input_pointer.d.ts.map +1 -1
  111. package/types/phaser/core/loader.d.ts +175 -172
  112. package/types/phaser/core/loader.d.ts.map +1 -1
  113. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  114. package/types/phaser/core/raf.d.ts +1 -1
  115. package/types/phaser/core/scale_manager.d.ts +6 -5
  116. package/types/phaser/core/scale_manager.d.ts.map +1 -1
  117. package/types/phaser/core/scene.d.ts +15 -9
  118. package/types/phaser/core/scene.d.ts.map +1 -1
  119. package/types/phaser/core/scene_manager.d.ts +51 -43
  120. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  121. package/types/phaser/core/signal.d.ts +54 -51
  122. package/types/phaser/core/signal.d.ts.map +1 -1
  123. package/types/phaser/core/sound.d.ts +54 -54
  124. package/types/phaser/core/sound_manager.d.ts +49 -49
  125. package/types/phaser/core/stage.d.ts +10 -10
  126. package/types/phaser/core/time.d.ts +54 -30
  127. package/types/phaser/core/time.d.ts.map +1 -1
  128. package/types/phaser/core/timer.d.ts +82 -64
  129. package/types/phaser/core/timer.d.ts.map +1 -1
  130. package/types/phaser/core/timer_event.d.ts +9 -9
  131. package/types/phaser/core/tween.d.ts +106 -90
  132. package/types/phaser/core/tween.d.ts.map +1 -1
  133. package/types/phaser/core/tween_data.d.ts +30 -30
  134. package/types/phaser/core/tween_manager.d.ts +35 -67
  135. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  136. package/types/phaser/core/world.d.ts +4 -3
  137. package/types/phaser/core/world.d.ts.map +1 -1
  138. package/types/phaser/display/bitmap_text.d.ts +76 -53
  139. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  140. package/types/phaser/display/button.d.ts +47 -46
  141. package/types/phaser/display/button.d.ts.map +1 -1
  142. package/types/phaser/display/canvas/buffer.d.ts +8 -8
  143. package/types/phaser/display/canvas/graphics.d.ts +3 -3
  144. package/types/phaser/display/canvas/graphics.d.ts.map +1 -1
  145. package/types/phaser/display/canvas/pool.d.ts +6 -3
  146. package/types/phaser/display/canvas/pool.d.ts.map +1 -1
  147. package/types/phaser/display/canvas/renderer.d.ts +18 -17
  148. package/types/phaser/display/canvas/renderer.d.ts.map +1 -1
  149. package/types/phaser/display/canvas/util.d.ts +6 -6
  150. package/types/phaser/display/canvas/util.d.ts.map +1 -1
  151. package/types/phaser/display/display_object.d.ts +119 -108
  152. package/types/phaser/display/display_object.d.ts.map +1 -1
  153. package/types/phaser/display/graphics.d.ts +118 -102
  154. package/types/phaser/display/graphics.d.ts.map +1 -1
  155. package/types/phaser/display/graphics_data.d.ts +10 -10
  156. package/types/phaser/display/group.d.ts +59 -47
  157. package/types/phaser/display/group.d.ts.map +1 -1
  158. package/types/phaser/display/image.d.ts +58 -45
  159. package/types/phaser/display/image.d.ts.map +1 -1
  160. package/types/phaser/display/text.d.ts +237 -188
  161. package/types/phaser/display/text.d.ts.map +1 -1
  162. package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
  163. package/types/phaser/display/webgl/base_texture.d.ts +10 -10
  164. package/types/phaser/display/webgl/base_texture.d.ts.map +1 -1
  165. package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
  166. package/types/phaser/display/webgl/earcut.d.ts +95 -95
  167. package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
  168. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
  169. package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
  170. package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
  171. package/types/phaser/display/webgl/graphics.d.ts +2 -2
  172. package/types/phaser/display/webgl/graphics.d.ts.map +1 -1
  173. package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
  174. package/types/phaser/display/webgl/render_texture.d.ts +16 -16
  175. package/types/phaser/display/webgl/renderer.d.ts +21 -20
  176. package/types/phaser/display/webgl/renderer.d.ts.map +1 -1
  177. package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
  178. package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
  179. package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
  180. package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
  181. package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
  182. package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
  183. package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
  184. package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
  185. package/types/phaser/display/webgl/texture.d.ts +12 -12
  186. package/types/phaser/display/webgl/texture_util.d.ts +4 -2
  187. package/types/phaser/display/webgl/texture_util.d.ts.map +1 -1
  188. package/types/phaser/geom/circle.d.ts +74 -69
  189. package/types/phaser/geom/circle.d.ts.map +1 -1
  190. package/types/phaser/geom/ellipse.d.ts +33 -28
  191. package/types/phaser/geom/ellipse.d.ts.map +1 -1
  192. package/types/phaser/geom/line.d.ts +96 -93
  193. package/types/phaser/geom/line.d.ts.map +1 -1
  194. package/types/phaser/geom/matrix.d.ts +61 -54
  195. package/types/phaser/geom/matrix.d.ts.map +1 -1
  196. package/types/phaser/geom/point.d.ts +99 -96
  197. package/types/phaser/geom/point.d.ts.map +1 -1
  198. package/types/phaser/geom/polygon.d.ts +29 -23
  199. package/types/phaser/geom/polygon.d.ts.map +1 -1
  200. package/types/phaser/geom/rectangle.d.ts +137 -132
  201. package/types/phaser/geom/rectangle.d.ts.map +1 -1
  202. package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
  203. package/types/phaser/geom/util/point.d.ts +1 -1
  204. package/types/phaser/geom/util/point.d.ts.map +1 -1
  205. package/pnpm-workspace.yaml +0 -4
@@ -3,38 +3,41 @@ import { clone, distance, rotate } from './util/point.js';
3
3
 
4
4
  export class Point {
5
5
  /**
6
- * TBD.
7
- * @param {number} x - TBD.
8
- * @param {number} y - TBD.
6
+ * Creates a new Point instance.
7
+ * @param {number} x - The x coordinate of the point (default: 0).
8
+ * @param {number} y - The y coordinate of the point (default: 0).
9
9
  */
10
10
  constructor(x = 0, y = 0) {
11
+ /** @type {number} */
11
12
  this.x = x;
13
+ /** @type {number} */
12
14
  this.y = y;
15
+ /** @type {number} */
13
16
  this.type = GEOM_POINT;
14
17
  }
15
18
 
16
19
  /**
17
- * TBD.
18
- * @param {Point} source - TBD.
19
- * @returns {Point} TBD.
20
+ * Copies the coordinates from another point to this point.
21
+ * @param {Point} source - The point to copy coordinates from.
22
+ * @returns {Point} This point instance for chaining.
20
23
  */
21
24
  copyFrom(source) {
22
25
  return this.setTo(source.x, source.y);
23
26
  }
24
27
 
25
28
  /**
26
- * TBD.
27
- * @returns {Point} TBD.
29
+ * Returns a new point with the x and y coordinates swapped.
30
+ * @returns {Point} A new point instance with swapped coordinates.
28
31
  */
29
32
  invert() {
30
33
  return this.setTo(this.y, this.x);
31
34
  }
32
35
 
33
36
  /**
34
- * TBD.
35
- * @param {number} x - TBD.
36
- * @param {number} y - TBD.
37
- * @returns {Point} TBD.
37
+ * Sets the coordinates of this point to new values.
38
+ * @param {number} x - The new x coordinate for the point.
39
+ * @param {number} y - The new y coordinate for the point.
40
+ * @returns {Point} This point instance for chaining.
38
41
  */
39
42
  setTo(x, y) {
40
43
  this.x = x || 0;
@@ -43,11 +46,11 @@ export class Point {
43
46
  }
44
47
 
45
48
  /**
46
- * TBD.
47
- * @param {number} x - TBD.
48
- * @param {number} y - TBD.
49
- * @returns {Point} TBD.
50
- * @deprecated
49
+ * Sets the coordinates of this point to new values.
50
+ * @param {number} x - The new x coordinate for the point.
51
+ * @param {number} y - The new y coordinate for the point.
52
+ * @returns {Point} This point instance for chaining.
53
+ * @deprecated Use setTo instead.
51
54
  */
52
55
  set(x, y) {
53
56
  this.x = x || 0;
@@ -56,10 +59,10 @@ export class Point {
56
59
  }
57
60
 
58
61
  /**
59
- * TBD.
60
- * @param {number} x - TBD.
61
- * @param {number} y - TBD.
62
- * @returns {Point} TBD.
62
+ * Adds the given x and y values to the point's coordinates.
63
+ * @param {number} x - The amount to add to the x coordinate.
64
+ * @param {number} y - The amount to add to the y coordinate.
65
+ * @returns {Point} This point instance for chaining.
63
66
  */
64
67
  add(x, y) {
65
68
  this.x += x;
@@ -68,10 +71,10 @@ export class Point {
68
71
  }
69
72
 
70
73
  /**
71
- * TBD.
72
- * @param {number} x - TBD.
73
- * @param {number} y - TBD.
74
- * @returns {Point} TBD.
74
+ * Subtracts the given x and y values from the point's coordinates.
75
+ * @param {number} x - The amount to subtract from the x coordinate.
76
+ * @param {number} y - The amount to subtract from the y coordinate.
77
+ * @returns {Point} This point instance for chaining.
75
78
  */
76
79
  subtract(x, y) {
77
80
  this.x -= x;
@@ -80,10 +83,10 @@ export class Point {
80
83
  }
81
84
 
82
85
  /**
83
- * TBD.
84
- * @param {number} x - TBD.
85
- * @param {number} y - TBD.
86
- * @returns {Point} TBD.
86
+ * Multiplies the point's coordinates by the given x and y values.
87
+ * @param {number} x - The amount to multiply the x coordinate by.
88
+ * @param {number} y - The amount to multiply the y coordinate by.
89
+ * @returns {Point} This point instance for chaining.
87
90
  */
88
91
  multiply(x, y) {
89
92
  this.x *= x;
@@ -92,10 +95,10 @@ export class Point {
92
95
  }
93
96
 
94
97
  /**
95
- * TBD.
96
- * @param {number} x - TBD.
97
- * @param {number} y - TBD.
98
- * @returns {Point} TBD.
98
+ * Divides the point's coordinates by the given x and y values.
99
+ * @param {number} x - The amount to divide the x coordinate by.
100
+ * @param {number} y - The amount to divide the y coordinate by.
101
+ * @returns {Point} This point instance for chaining.
99
102
  */
100
103
  divide(x, y) {
101
104
  this.x /= x;
@@ -104,10 +107,10 @@ export class Point {
104
107
  }
105
108
 
106
109
  /**
107
- * TBD.
108
- * @param {number} min - TBD.
109
- * @param {number} max - TBD.
110
- * @returns {Point} TBD.
110
+ * Constrains the x coordinate of this point to the given range.
111
+ * @param {number} min - The minimum value for the x coordinate.
112
+ * @param {number} max - The maximum value for the x coordinate.
113
+ * @returns {Point} This point instance for chaining.
111
114
  */
112
115
  clampX(min, max) {
113
116
  this.x = Math.max(min, Math.min(max, this.x));
@@ -115,10 +118,10 @@ export class Point {
115
118
  }
116
119
 
117
120
  /**
118
- * TBD.
119
- * @param {number} min - TBD.
120
- * @param {number} max - TBD.
121
- * @returns {Point} TBD.
121
+ * Constrains the y coordinate of this point to the given range.
122
+ * @param {number} min - The minimum value for the y coordinate.
123
+ * @param {number} max - The maximum value for the y coordinate.
124
+ * @returns {Point} This point instance for chaining.
122
125
  */
123
126
  clampY(min, max) {
124
127
  this.y = Math.max(min, Math.min(max, this.y));
@@ -126,10 +129,10 @@ export class Point {
126
129
  }
127
130
 
128
131
  /**
129
- * TBD.
130
- * @param {number} min - TBD.
131
- * @param {number} max - TBD.
132
- * @returns {Point} TBD.
132
+ * Constrains both coordinates of this point to the given range.
133
+ * @param {number} min - The minimum value for both coordinates.
134
+ * @param {number} max - The maximum value for both coordinates.
135
+ * @returns {Point} This point instance for chaining.
133
136
  */
134
137
  clamp(min, max) {
135
138
  this.x = Math.max(min, Math.min(max, this.x));
@@ -138,17 +141,17 @@ export class Point {
138
141
  }
139
142
 
140
143
  /**
141
- * TBD.
142
- * @returns {Point} TBD.
144
+ * Creates a clone of this point.
145
+ * @returns {Point} A new point with the same coordinates as this one.
143
146
  */
144
147
  clone() {
145
148
  return clone(this);
146
149
  }
147
150
 
148
151
  /**
149
- * TBD.
150
- * @param {Point} dest - TBD.
151
- * @returns {Point} TBD.
152
+ * Copies the coordinates of this point to another point.
153
+ * @param {Point} dest - The point to copy coordinates to.
154
+ * @returns {Point} The destination point.
152
155
  */
153
156
  copyTo(dest) {
154
157
  dest.x = this.x;
@@ -157,28 +160,28 @@ export class Point {
157
160
  }
158
161
 
159
162
  /**
160
- * TBD.
161
- * @param {Point} b - TBD.
162
- * @returns {number} TBD.
163
+ * Calculates the distance between this point and another point.
164
+ * @param {Point} b - The other point to calculate the distance to.
165
+ * @returns {number} The distance between the two points.
163
166
  */
164
167
  distance(b) {
165
168
  return distance(this, b);
166
169
  }
167
170
 
168
171
  /**
169
- * TBD.
170
- * @param {Point} a - TBD.
171
- * @returns {boolean} TBD.
172
+ * Checks if this point is equal to another point.
173
+ * @param {Point} a - The other point to compare with.
174
+ * @returns {boolean} True if the points have the same coordinates, false otherwise.
172
175
  */
173
176
  equals(a) {
174
177
  return a.x === this.x && a.y === this.y;
175
178
  }
176
179
 
177
180
  /**
178
- * TBD.
179
- * @param {Point} a - TBD.
180
- * @param {boolean} asDegrees - TBD.
181
- * @returns {number} TBD.
181
+ * Calculates the angle between this point and another point.
182
+ * @param {Point} a - The other point to calculate the angle to.
183
+ * @param {boolean} asDegrees - Whether to return the result in degrees (default: false).
184
+ * @returns {number} The angle between the two points in radians or degrees.
182
185
  */
183
186
  angle(a, asDegrees = false) {
184
187
  if (asDegrees) {
@@ -188,46 +191,46 @@ export class Point {
188
191
  }
189
192
 
190
193
  /**
191
- * TBD.
192
- * @param {number} x - TBD.
193
- * @param {number} y - TBD.
194
- * @param {number} angle - TBD.
195
- * @param {boolean} asDegrees - TBD.
196
- * @param {number | null | undefined} dist - TBD.
197
- * @returns {Point} TBD.
194
+ * Rotates this point around another point by a given angle.
195
+ * @param {number} x - The x coordinate of the center point to rotate around.
196
+ * @param {number} y - The y coordinate of the center point to rotate around.
197
+ * @param {number} angle - The angle in radians to rotate by.
198
+ * @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
199
+ * @param {number | null | undefined} dist - The distance to rotate from (default: null).
200
+ * @returns {Point} This point instance for chaining.
198
201
  */
199
202
  rotate(x, y, angle, asDegrees, dist = null) {
200
203
  return rotate(this, x, y, angle, asDegrees, dist);
201
204
  }
202
205
 
203
206
  /**
204
- * TBD.
205
- * @returns {number} TBD.
207
+ * Calculates the magnitude (length) of this point from the origin.
208
+ * @returns {number} The magnitude of the point.
206
209
  */
207
210
  getMagnitude() {
208
211
  return Math.sqrt(this.x * this.x + this.y * this.y);
209
212
  }
210
213
 
211
214
  /**
212
- * TBD.
213
- * @returns {number} TBD.
215
+ * Calculates the square of the magnitude (length) of this point from the origin.
216
+ * @returns {number} The square of the magnitude of the point.
214
217
  */
215
218
  getMagnitudeSq() {
216
219
  return this.x * this.x + this.y * this.y;
217
220
  }
218
221
 
219
222
  /**
220
- * TBD.
221
- * @param {number} magnitude - TBD.
222
- * @returns {Point} TBD.
223
+ * Sets the magnitude (length) of this point while preserving its direction.
224
+ * @param {number} magnitude - The new magnitude for the point.
225
+ * @returns {Point} This point instance for chaining.
223
226
  */
224
227
  setMagnitude(magnitude) {
225
228
  return this.normalize().multiply(magnitude, magnitude);
226
229
  }
227
230
 
228
231
  /**
229
- * TBD.
230
- * @returns {Point} TBD.
232
+ * Normalizes this point to have a magnitude of 1 while preserving its direction.
233
+ * @returns {Point} This point instance for chaining.
231
234
  */
232
235
  normalize() {
233
236
  if (!this.isZero()) {
@@ -239,74 +242,74 @@ export class Point {
239
242
  }
240
243
 
241
244
  /**
242
- * TBD.
243
- * @returns {boolean} TBD.
245
+ * Checks if this point has zero magnitude (is at the origin).
246
+ * @returns {boolean} True if both x and y coordinates are zero, false otherwise.
244
247
  */
245
248
  isZero() {
246
249
  return this.x === 0 && this.y === 0;
247
250
  }
248
251
 
249
252
  /**
250
- * TBD.
251
- * @param {Point} a - TBD.
252
- * @returns {number} TBD.
253
+ * Calculates the dot product of this point and another point.
254
+ * @param {Point} a - The other point to calculate the dot product with.
255
+ * @returns {number} The dot product of the two points.
253
256
  */
254
257
  dot(a) {
255
258
  return this.x * a.x + this.y * a.y;
256
259
  }
257
260
 
258
261
  /**
259
- * TBD.
260
- * @param {Point} a - TBD.
261
- * @returns {number} TBD.
262
+ * Calculates the cross product of this point and another point.
263
+ * @param {Point} a - The other point to calculate the cross product with.
264
+ * @returns {number} The cross product of the two points.
262
265
  */
263
266
  cross(a) {
264
267
  return this.x * a.y - this.y * a.x;
265
268
  }
266
269
 
267
270
  /**
268
- * TBD.
269
- * @returns {Point} TBD.
271
+ * Returns a perpendicular point (rotated 90 degrees counter-clockwise).
272
+ * @returns {Point} A new point that is perpendicular to this one.
270
273
  */
271
274
  perp() {
272
275
  return this.setTo(-this.y, this.x);
273
276
  }
274
277
 
275
278
  /**
276
- * TBD.
277
- * @returns {Point} TBD.
279
+ * Returns a perpendicular point (rotated 90 degrees clockwise).
280
+ * @returns {Point} A new point that is perpendicular to this one (rotated clockwise).
278
281
  */
279
282
  rperp() {
280
283
  return this.setTo(this.y, -this.x);
281
284
  }
282
285
 
283
286
  /**
284
- * TBD.
285
- * @returns {Point} TBD.
287
+ * Returns a point with the same direction as this one but with y coordinate negated.
288
+ * @returns {Point} A new point with the same x coordinate but negated y coordinate.
286
289
  */
287
290
  normalRightHand() {
288
291
  return this.setTo(this.y * -1, this.x);
289
292
  }
290
293
 
291
294
  /**
292
- * TBD.
293
- * @returns {Point} TBD.
295
+ * Returns a new point with the x and y coordinates rounded down to the nearest integer.
296
+ * @returns {Point} A new point with floored coordinates.
294
297
  */
295
298
  floor() {
296
299
  return this.setTo(Math.floor(this.x), Math.floor(this.y));
297
300
  }
298
301
 
299
302
  /**
300
- * TBD.
301
- * @returns {Point} TBD.
303
+ * Returns a new point with the x and y coordinates rounded up to the nearest integer.
304
+ * @returns {Point} A new point with ceiled coordinates.
302
305
  */
303
306
  ceil() {
304
307
  return this.setTo(Math.ceil(this.x), Math.ceil(this.y));
305
308
  }
306
309
 
307
310
  /**
308
- * TBD.
309
- * @returns {string} TBD.
311
+ * Returns a string representation of this point.
312
+ * @returns {string} A string representation of the point in the format "[Point (x=value y=value)]".
310
313
  */
311
314
  toString() {
312
315
  return `[{Point (x=${this.x} y=${this.y})}]`;
@@ -4,14 +4,19 @@ import { GEOM_POLYGON } from '../core/const.js';
4
4
 
5
5
  export class Polygon {
6
6
  /**
7
- * TBD.
8
- * @param {object[]} points - TBD.
7
+ * Creates a new Polygon instance.
8
+ * @param {object[]} points - The array of points to define the polygon (optional).
9
9
  */
10
10
  constructor(points = null) {
11
+ /** @type {number} */
11
12
  this.area = 0;
13
+ /** @type {Point[]} */
12
14
  this._points = [];
15
+ /** @type {boolean} */
13
16
  this.closed = true;
17
+ /** @type {boolean} */
14
18
  this.flattened = false;
19
+ /** @type {number} */
15
20
  this.type = GEOM_POLYGON;
16
21
  if (points) {
17
22
  this.setTo(points);
@@ -19,9 +24,9 @@ export class Polygon {
19
24
  }
20
25
 
21
26
  /**
22
- * TBD.
23
- * @param {number[]} output - TBD.
24
- * @returns {number[]} TBD.
27
+ * Converts the polygon's points to a number array.
28
+ * @param {number[]} output - The array to store the result in (optional).
29
+ * @returns {number[]} An array of numbers representing the polygon's points.
25
30
  */
26
31
  toNumberArray(output = []) {
27
32
  for (let i = 0; i < this._points.length; i += 1) {
@@ -38,8 +43,8 @@ export class Polygon {
38
43
  }
39
44
 
40
45
  /**
41
- * TBD.
42
- * @returns {Polygon} TBD.
46
+ * Flattens the polygon's point array to a simple numeric array.
47
+ * @returns {Polygon} This polygon instance for chaining.
43
48
  */
44
49
  flatten() {
45
50
  this._points = this.toNumberArray();
@@ -48,18 +53,18 @@ export class Polygon {
48
53
  }
49
54
 
50
55
  /**
51
- * TBD.
52
- * @returns {Polygon} TBD.
56
+ * Creates a clone of this polygon.
57
+ * @returns {Polygon} A new polygon with the same values as this one.
53
58
  */
54
59
  clone() {
55
60
  return clone(this);
56
61
  }
57
62
 
58
63
  /**
59
- * TBD.
60
- * @param {number} x - TBD.
61
- * @param {number} y - TBD.
62
- * @returns {boolean} TBD.
64
+ * Checks if the specified point is contained within this polygon.
65
+ * @param {number} x - The x coordinate of the point to check.
66
+ * @param {number} y - The y coordinate of the point to check.
67
+ * @returns {boolean} True if the point is contained within this polygon, false otherwise.
63
68
  */
64
69
  contains(x, y) {
65
70
  // Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva
@@ -89,9 +94,9 @@ export class Polygon {
89
94
  }
90
95
 
91
96
  /**
92
- * TBD.
93
- * @param {object[]} points - TBD.
94
- * @returns {Polygon} TBD.
97
+ * Sets the polygon's points to new values.
98
+ * @param {object[]} points - The array of points to define the polygon.
99
+ * @returns {Polygon} This polygon instance for chaining.
95
100
  */
96
101
  setTo(points) {
97
102
  this.area = 0;
@@ -128,9 +133,9 @@ export class Polygon {
128
133
  }
129
134
 
130
135
  /**
131
- * TBD.
132
- * @param {number} y0 - TBD.
133
- * @returns {number} TBD.
136
+ * Calculates the area of this polygon.
137
+ * @param {number} y0 - The y coordinate of the lowest boundary (internal use).
138
+ * @returns {number} The area of this polygon.
134
139
  */
135
140
  calculateArea(y0) {
136
141
  let p1;
@@ -152,15 +157,15 @@ export class Polygon {
152
157
  }
153
158
 
154
159
  /**
155
- * TBD.
156
- * @returns {object[]} TBD.
160
+ * Gets the points of this polygon.
161
+ * @returns {object[]} The array of points that define this polygon.
157
162
  */
158
163
  get points() {
159
164
  return this._points;
160
165
  }
161
166
 
162
167
  /**
163
- * TBD.
168
+ * Sets the points of this polygon.
164
169
  */
165
170
  set points(value) {
166
171
  if (value !== null) {