@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
@@ -5,25 +5,28 @@ import { GEOM_LINE } from '../core/const.js';
5
5
 
6
6
  export class Line {
7
7
  /**
8
- * TBD.
9
- * @param {number} x1 - TBD.
10
- * @param {number} y1 - TBD.
11
- * @param {number} x2 - TBD.
12
- * @param {number} y2 - TBD.
8
+ * Creates a new Line instance.
9
+ * @param {number} x1 - The x coordinate of the start point (default: 0).
10
+ * @param {number} y1 - The y coordinate of the start point (default: 0).
11
+ * @param {number} x2 - The x coordinate of the end point (default: 0).
12
+ * @param {number} y2 - The y coordinate of the end point (default: 0).
13
13
  */
14
14
  constructor(x1 = 0, y1 = 0, x2 = 0, y2 = 0) {
15
+ /** @type {Point} */
15
16
  this.start = new Point(x1, y1);
17
+ /** @type {Point} */
16
18
  this.end = new Point(x2, y2);
19
+ /** @type {number} */
17
20
  this.type = GEOM_LINE;
18
21
  }
19
22
 
20
23
  /**
21
- * TBD.
22
- * @param {number} x1 - TBD.
23
- * @param {number} y1 - TBD.
24
- * @param {number} x2 - TBD.
25
- * @param {number} y2 - TBD.
26
- * @returns {Line} TBD.
24
+ * Sets the coordinates of this line to new values.
25
+ * @param {number} x1 - The new x coordinate of the start point.
26
+ * @param {number} y1 - The new y coordinate of the start point.
27
+ * @param {number} x2 - The new x coordinate of the end point.
28
+ * @param {number} y2 - The new y coordinate of the end point.
29
+ * @returns {Line} This line instance for chaining.
27
30
  */
28
31
  setTo(x1, y1, x2, y2) {
29
32
  this.start.setTo(x1, y1);
@@ -32,11 +35,11 @@ export class Line {
32
35
  }
33
36
 
34
37
  /**
35
- * TBD.
36
- * @param {object} startSprite - TBD.
37
- * @param {object} endSprite - TBD.
38
- * @param {boolean} useCenter - TBD.
39
- * @returns {Line} TBD.
38
+ * Sets the coordinates of this line to match the positions of two sprites.
39
+ * @param {object} startSprite - The starting sprite to get the position from.
40
+ * @param {object} endSprite - The ending sprite to get the position from.
41
+ * @param {boolean} useCenter - Whether to use the center of the sprites (default: false).
42
+ * @returns {Line} This line instance for chaining.
40
43
  */
41
44
  fromSprite(startSprite, endSprite, useCenter = false) {
42
45
  if (useCenter) {
@@ -46,12 +49,12 @@ export class Line {
46
49
  }
47
50
 
48
51
  /**
49
- * TBD.
50
- * @param {number} x - TBD.
51
- * @param {number} y - TBD.
52
- * @param {number} angle - TBD.
53
- * @param {number} length - TBD.
54
- * @returns {Line} TBD.
52
+ * Sets the coordinates of this line to a point at a specific angle and distance.
53
+ * @param {number} x - The x coordinate of the starting point.
54
+ * @param {number} y - The y coordinate of the starting point.
55
+ * @param {number} angle - The angle in radians to set the line at.
56
+ * @param {number} length - The length of the line.
57
+ * @returns {Line} This line instance for chaining.
55
58
  */
56
59
  fromAngle(x, y, angle, length) {
57
60
  this.start.setTo(x, y);
@@ -60,10 +63,10 @@ export class Line {
60
63
  }
61
64
 
62
65
  /**
63
- * TBD.
64
- * @param {number} angle - TBD.
65
- * @param {boolean} asDegrees - TBD.
66
- * @returns {Line} TBD.
66
+ * Rotates this line around its center point by the specified angle.
67
+ * @param {number} angle - The angle in radians (or degrees if asDegrees is true) to rotate by.
68
+ * @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
69
+ * @returns {Line} This line instance for chaining.
67
70
  */
68
71
  rotate(angle, asDegrees = false) {
69
72
  const cx = (this.start.x + this.end.x) / 2;
@@ -74,12 +77,12 @@ export class Line {
74
77
  }
75
78
 
76
79
  /**
77
- * TBD.
78
- * @param {number} x - TBD.
79
- * @param {number} y - TBD.
80
- * @param {number} angle - TBD.
81
- * @param {boolean} asDegrees - TBD.
82
- * @returns {Line} TBD.
80
+ * Rotates this line around a specific point by the specified angle.
81
+ * @param {number} x - The x coordinate of the center point to rotate around.
82
+ * @param {number} y - The y coordinate of the center point to rotate around.
83
+ * @param {number} angle - The angle in radians (or degrees if asDegrees is true) to rotate by.
84
+ * @param {boolean} asDegrees - Whether the angle is provided in degrees (default: false).
85
+ * @returns {Line} This line instance for chaining.
83
86
  */
84
87
  rotateAround(x, y, angle, asDegrees = false) {
85
88
  this.start.rotate(x, y, angle, asDegrees);
@@ -88,29 +91,29 @@ export class Line {
88
91
  }
89
92
 
90
93
  /**
91
- * TBD.
92
- * @param {Line} line - TBD.
93
- * @param {boolean} asSegment - TBD.
94
- * @param {Point} result - TBD.
95
- * @returns {Point} TBD.
94
+ * Checks if this line intersects with another line.
95
+ * @param {Line} line - The other line to check for intersection with.
96
+ * @param {boolean} asSegment - Whether to treat the lines as segments (default: false).
97
+ * @param {Point} result - The point to store the intersection in (optional).
98
+ * @returns {Point} The intersection point, or null if no intersection occurs.
96
99
  */
97
100
  intersects(line, asSegment, result) {
98
101
  return intersectsPoints(this.start, this.end, line.start, line.end, asSegment, result);
99
102
  }
100
103
 
101
104
  /**
102
- * TBD.
103
- * @param {Line} line - TBD.
104
- * @returns {number} TBD.
105
+ * Calculates the reflection of this line off another line.
106
+ * @param {Line} line - The line to reflect off.
107
+ * @returns {number} The angle of reflection in radians.
105
108
  */
106
109
  reflect(line) {
107
110
  return reflect(this, line);
108
111
  }
109
112
 
110
113
  /**
111
- * TBD.
112
- * @param {Point} output - TBD.
113
- * @returns {Point} TBD.
114
+ * Returns the midpoint of this line.
115
+ * @param {Point} output - The point to store the result in (optional).
116
+ * @returns {Point} The midpoint of this line.
114
117
  */
115
118
  midPoint(output = null) {
116
119
  const result = output || new Point();
@@ -120,9 +123,9 @@ export class Line {
120
123
  }
121
124
 
122
125
  /**
123
- * TBD.
124
- * @param {number} x - TBD.
125
- * @param {number} y - TBD.
126
+ * Centers this line on the specified point.
127
+ * @param {number} x - The x coordinate to center the line on.
128
+ * @param {number} y - The y coordinate to center the line on.
126
129
  */
127
130
  centerOn(x, y) {
128
131
  const cx = (this.start.x + this.end.x) / 2;
@@ -134,20 +137,20 @@ export class Line {
134
137
  }
135
138
 
136
139
  /**
137
- * TBD.
138
- * @param {number} x - TBD.
139
- * @param {number} y - TBD.
140
- * @returns {boolean} TBD.
140
+ * Checks if the specified point lies on this line (not necessarily on the segment).
141
+ * @param {number} x - The x coordinate of the point to check.
142
+ * @param {number} y - The y coordinate of the point to check.
143
+ * @returns {boolean} True if the point lies on this line, false otherwise.
141
144
  */
142
145
  pointOnLine(x, y) {
143
146
  return (x - this.start.x) * (this.end.y - this.start.y) === (this.end.x - this.start.x) * (y - this.start.y);
144
147
  }
145
148
 
146
149
  /**
147
- * TBD.
148
- * @param {number} x - TBD.
149
- * @param {number} y - TBD.
150
- * @returns {boolean} TBD.
150
+ * Checks if the specified point lies on this line segment.
151
+ * @param {number} x - The x coordinate of the point to check.
152
+ * @param {number} y - The y coordinate of the point to check.
153
+ * @returns {boolean} True if the point lies on this line segment, false otherwise.
151
154
  */
152
155
  pointOnSegment(x, y) {
153
156
  const xMin = Math.min(this.start.x, this.end.x);
@@ -158,9 +161,9 @@ export class Line {
158
161
  }
159
162
 
160
163
  /**
161
- * TBD.
162
- * @param {Point} output - TBD.
163
- * @returns {Point} TBD.
164
+ * Returns a random point on this line.
165
+ * @param {Point} output - The point to store the result in (optional).
166
+ * @returns {Point} A random point on this line.
164
167
  */
165
168
  random(output = null) {
166
169
  const result = output || new Point();
@@ -171,10 +174,10 @@ export class Line {
171
174
  }
172
175
 
173
176
  /**
174
- * TBD.
175
- * @param {number} stepRate - TBD.
176
- * @param {number[][]} results - TBD.
177
- * @returns {number[][]} TBD.
177
+ * Gets coordinates of points along this line at regular intervals.
178
+ * @param {number} stepRate - The interval between points (default: 1).
179
+ * @param {number[][]} results - The array to store the results in (optional).
180
+ * @returns {number[][]} An array of coordinate pairs representing points along this line.
178
181
  */
179
182
  coordinatesOnLine(stepRate = 1, results = []) {
180
183
  let x1 = Math.round(this.start.x);
@@ -207,16 +210,16 @@ export class Line {
207
210
  }
208
211
 
209
212
  /**
210
- * TBD.
211
- * @returns {Line} TBD.
213
+ * Creates a clone of this line.
214
+ * @returns {Line} A new line with the same values as this one.
212
215
  */
213
216
  clone() {
214
217
  return clone(this);
215
218
  }
216
219
 
217
220
  /**
218
- * TBD.
219
- * @returns {number} TBD.
221
+ * Gets the length of this line.
222
+ * @returns {number} The length of this line.
220
223
  */
221
224
  get length() {
222
225
  return Math.sqrt(
@@ -226,112 +229,112 @@ export class Line {
226
229
  }
227
230
 
228
231
  /**
229
- * TBD.
230
- * @returns {number} TBD.
232
+ * Gets the angle of this line in radians.
233
+ * @returns {number} The angle of this line in radians.
231
234
  */
232
235
  get angle() {
233
236
  return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x);
234
237
  }
235
238
 
236
239
  /**
237
- * TBD.
238
- * @returns {number} TBD.
240
+ * Gets the slope of this line.
241
+ * @returns {number} The slope of this line.
239
242
  */
240
243
  get slope() {
241
244
  return (this.end.y - this.start.y) / (this.end.x - this.start.x);
242
245
  }
243
246
 
244
247
  /**
245
- * TBD.
246
- * @returns {number} TBD.
248
+ * Gets the perpendicular slope of this line.
249
+ * @returns {number} The perpendicular slope of this line.
247
250
  */
248
251
  get perpSlope() {
249
252
  return -((this.end.x - this.start.x) / (this.end.y - this.start.y));
250
253
  }
251
254
 
252
255
  /**
253
- * TBD.
254
- * @returns {number} TBD.
256
+ * Gets the x coordinate of the leftmost point on this line.
257
+ * @returns {number} The x coordinate of the leftmost point on this line.
255
258
  */
256
259
  get x() {
257
260
  return Math.min(this.start.x, this.end.x);
258
261
  }
259
262
 
260
263
  /**
261
- * TBD.
262
- * @returns {number} TBD.
264
+ * Gets the y coordinate of the topmost point on this line.
265
+ * @returns {number} The y coordinate of the topmost point on this line.
263
266
  */
264
267
  get y() {
265
268
  return Math.min(this.start.y, this.end.y);
266
269
  }
267
270
 
268
271
  /**
269
- * TBD.
270
- * @returns {number} TBD.
272
+ * Gets the x coordinate of the leftmost point on this line.
273
+ * @returns {number} The x coordinate of the leftmost point on this line.
271
274
  */
272
275
  get left() {
273
276
  return Math.min(this.start.x, this.end.x);
274
277
  }
275
278
 
276
279
  /**
277
- * TBD.
278
- * @returns {number} TBD.
280
+ * Gets the x coordinate of the rightmost point on this line.
281
+ * @returns {number} The x coordinate of the rightmost point on this line.
279
282
  */
280
283
  get right() {
281
284
  return Math.max(this.start.x, this.end.x);
282
285
  }
283
286
 
284
287
  /**
285
- * TBD.
286
- * @returns {number} TBD.
288
+ * Gets the y coordinate of the topmost point on this line.
289
+ * @returns {number} The y coordinate of the topmost point on this line.
287
290
  */
288
291
  get top() {
289
292
  return Math.min(this.start.y, this.end.y);
290
293
  }
291
294
 
292
295
  /**
293
- * TBD.
294
- * @returns {number} TBD.
296
+ * Gets the y coordinate of the bottommost point on this line.
297
+ * @returns {number} The y coordinate of the bottommost point on this line.
295
298
  */
296
299
  get bottom() {
297
300
  return Math.max(this.start.y, this.end.y);
298
301
  }
299
302
 
300
303
  /**
301
- * TBD.
302
- * @returns {number} TBD.
304
+ * Gets the width of this line (absolute difference between x coordinates).
305
+ * @returns {number} The width of this line.
303
306
  */
304
307
  get width() {
305
308
  return Math.abs(this.start.x - this.end.x);
306
309
  }
307
310
 
308
311
  /**
309
- * TBD.
310
- * @returns {number} TBD.
312
+ * Gets the height of this line (absolute difference between y coordinates).
313
+ * @returns {number} The height of this line.
311
314
  */
312
315
  get height() {
313
316
  return Math.abs(this.start.y - this.end.y);
314
317
  }
315
318
 
316
319
  /**
317
- * TBD.
318
- * @returns {number} TBD.
320
+ * Gets the normal vector x component of this line (perpendicular to the line).
321
+ * @returns {number} The normal vector x component of this line.
319
322
  */
320
323
  get normalX() {
321
324
  return Math.cos(this.angle - 1.5707963267948966);
322
325
  }
323
326
 
324
327
  /**
325
- * TBD.
326
- * @returns {number} TBD.
328
+ * Gets the normal vector y component of this line (perpendicular to the line).
329
+ * @returns {number} The normal vector y component of this line.
327
330
  */
328
331
  get normalY() {
329
332
  return Math.sin(this.angle - 1.5707963267948966);
330
333
  }
331
334
 
332
335
  /**
333
- * TBD.
334
- * @returns {number} TBD.
336
+ * Gets the angle of the normal vector of this line in radians.
337
+ * @returns {number} The angle of the normal vector of this line in radians.
335
338
  */
336
339
  get normalAngle() {
337
340
  return wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
@@ -4,42 +4,49 @@ import { GEOM_MATRIX } from '../core/const.js';
4
4
 
5
5
  export class Matrix {
6
6
  /**
7
- * TBD.
8
- * @param {number} a - TBD.
9
- * @param {number} b - TBD.
10
- * @param {number} c - TBD.
11
- * @param {number} d - TBD.
12
- * @param {number} tx - TBD.
13
- * @param {number} ty - TBD.
7
+ * Creates a new Matrix instance.
8
+ * @param {number} a - The a component of the matrix (default: 1).
9
+ * @param {number} b - The b component of the matrix (default: 0).
10
+ * @param {number} c - The c component of the matrix (default: 0).
11
+ * @param {number} d - The d component of the matrix (default: 1).
12
+ * @param {number} tx - The tx component of the matrix (default: 0).
13
+ * @param {number} ty - The ty component of the matrix (default: 0).
14
14
  */
15
15
  constructor(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {
16
+ /** @type {number} */
16
17
  this.a = a;
18
+ /** @type {number} */
17
19
  this.b = b;
20
+ /** @type {number} */
18
21
  this.c = c;
22
+ /** @type {number} */
19
23
  this.d = d;
24
+ /** @type {number} */
20
25
  this.tx = tx;
26
+ /** @type {number} */
21
27
  this.ty = ty;
28
+ /** @type {number} */
22
29
  this.type = GEOM_MATRIX;
23
30
  }
24
31
 
25
32
  /**
26
- * TBD.
27
- * @param {number[]} array - TBD.
28
- * @returns {Matrix} TBD.
33
+ * Sets the matrix components from an array.
34
+ * @param {number[]} array - The array to read the matrix components from (should have 6 elements).
35
+ * @returns {Matrix} This matrix instance for chaining.
29
36
  */
30
37
  fromArray(array) {
31
38
  return this.setTo(array[0], array[1], array[3], array[4], array[2], array[5]);
32
39
  }
33
40
 
34
41
  /**
35
- * TBD.
36
- * @param {number} a - TBD.
37
- * @param {number} b - TBD.
38
- * @param {number} c - TBD.
39
- * @param {number} d - TBD.
40
- * @param {number} tx - TBD.
41
- * @param {number} ty - TBD.
42
- * @returns {Matrix} TBD.
42
+ * Sets the matrix components to new values.
43
+ * @param {number} a - The new a component of the matrix.
44
+ * @param {number} b - The new b component of the matrix.
45
+ * @param {number} c - The new c component of the matrix.
46
+ * @param {number} d - The new d component of the matrix.
47
+ * @param {number} tx - The new tx component of the matrix.
48
+ * @param {number} ty - The new ty component of the matrix.
49
+ * @returns {Matrix} This matrix instance for chaining.
43
50
  */
44
51
  setTo(a, b, c, d, tx, ty) {
45
52
  this.a = a;
@@ -52,17 +59,17 @@ export class Matrix {
52
59
  }
53
60
 
54
61
  /**
55
- * TBD.
56
- * @returns {Matrix} TBD.
62
+ * Creates a clone of this matrix.
63
+ * @returns {Matrix} A new matrix with the same values as this one.
57
64
  */
58
65
  clone() {
59
66
  return clone(this);
60
67
  }
61
68
 
62
69
  /**
63
- * TBD.
64
- * @param {Matrix} matrix - TBD.
65
- * @returns {Matrix} TBD.
70
+ * Copies the values of this matrix to another matrix.
71
+ * @param {Matrix} matrix - The matrix to copy values to.
72
+ * @returns {Matrix} The destination matrix.
66
73
  */
67
74
  copyTo(matrix) {
68
75
  matrix.copyFrom(this);
@@ -70,9 +77,9 @@ export class Matrix {
70
77
  }
71
78
 
72
79
  /**
73
- * TBD.
74
- * @param {Matrix} matrix - TBD.
75
- * @returns {Matrix} TBD.
80
+ * Copies the values from another matrix to this matrix.
81
+ * @param {Matrix} matrix - The matrix to copy values from.
82
+ * @returns {Matrix} This matrix instance for chaining.
76
83
  */
77
84
  copyFrom(matrix) {
78
85
  this.a = matrix.a;
@@ -85,10 +92,10 @@ export class Matrix {
85
92
  }
86
93
 
87
94
  /**
88
- * TBD.
89
- * @param {boolean} transpose - TBD.
90
- * @param {Float32Array} output - TBD.
91
- * @returns {Float32Array} TBD.
95
+ * Converts this matrix to a Float32Array.
96
+ * @param {boolean} transpose - Whether to transpose the matrix (default: false).
97
+ * @param {Float32Array} output - The array to store the result in (optional).
98
+ * @returns {Float32Array} A Float32Array containing the matrix elements.
92
99
  */
93
100
  toArray(transpose = false, output = null) {
94
101
  const result = output || new Float32Array(9);
@@ -117,10 +124,10 @@ export class Matrix {
117
124
  }
118
125
 
119
126
  /**
120
- * TBD.
121
- * @param {Point} pos - TBD.
122
- * @param {Point} output - TBD.
123
- * @returns {Point} TBD.
127
+ * Applies this matrix to a point.
128
+ * @param {Point} pos - The point to apply the matrix to.
129
+ * @param {Point} output - The point to store the result in (optional).
130
+ * @returns {Point} The transformed point.
124
131
  */
125
132
  apply(pos, output = null) {
126
133
  const result = output || new Point();
@@ -130,10 +137,10 @@ export class Matrix {
130
137
  }
131
138
 
132
139
  /**
133
- * TBD.
134
- * @param {Point} pos - TBD.
135
- * @param {Point} output - TBD.
136
- * @returns {Point} TBD.
140
+ * Applies the inverse of this matrix to a point.
141
+ * @param {Point} pos - The point to apply the inverse matrix to.
142
+ * @param {Point} output - The point to store the result in (optional).
143
+ * @returns {Point} The transformed point.
137
144
  */
138
145
  applyInverse(pos, output = null) {
139
146
  const result = output || new Point();
@@ -146,10 +153,10 @@ export class Matrix {
146
153
  }
147
154
 
148
155
  /**
149
- * TBD.
150
- * @param {number} x - TBD.
151
- * @param {number} y - TBD.
152
- * @returns {Matrix} TBD.
156
+ * Translates this matrix by the specified amounts.
157
+ * @param {number} x - The amount to translate in the x direction.
158
+ * @param {number} y - The amount to translate in the y direction.
159
+ * @returns {Matrix} This matrix instance for chaining.
153
160
  */
154
161
  translate(x, y) {
155
162
  this.tx += x;
@@ -158,10 +165,10 @@ export class Matrix {
158
165
  }
159
166
 
160
167
  /**
161
- * TBD.
162
- * @param {number} x - TBD.
163
- * @param {number} y - TBD.
164
- * @returns {Matrix} TBD.
168
+ * Scales this matrix by the specified amounts.
169
+ * @param {number} x - The amount to scale in the x direction.
170
+ * @param {number} y - The amount to scale in the y direction.
171
+ * @returns {Matrix} This matrix instance for chaining.
165
172
  */
166
173
  scale(x, y) {
167
174
  this.a *= x;
@@ -174,9 +181,9 @@ export class Matrix {
174
181
  }
175
182
 
176
183
  /**
177
- * TBD.
178
- * @param {number} angle - TBD.
179
- * @returns {Matrix} TBD.
184
+ * Rotates this matrix by the specified angle.
185
+ * @param {number} angle - The angle in radians to rotate by.
186
+ * @returns {Matrix} This matrix instance for chaining.
180
187
  */
181
188
  rotate(angle) {
182
189
  const cos = Math.cos(angle);
@@ -194,9 +201,9 @@ export class Matrix {
194
201
  }
195
202
 
196
203
  /**
197
- * TBD.
198
- * @param {Matrix} matrix - TBD.
199
- * @returns {Matrix} TBD.
204
+ * Appends another matrix to this matrix (multiplying matrices).
205
+ * @param {Matrix} matrix - The matrix to append.
206
+ * @returns {Matrix} This matrix instance for chaining.
200
207
  */
201
208
  append(matrix) {
202
209
  const a1 = this.a;
@@ -213,8 +220,8 @@ export class Matrix {
213
220
  }
214
221
 
215
222
  /**
216
- * TBD.
217
- * @returns {Matrix} TBD.
223
+ * Sets this matrix to an identity matrix (no transformation).
224
+ * @returns {Matrix} This matrix instance for chaining.
218
225
  */
219
226
  identity() {
220
227
  return this.setTo(1, 0, 0, 1, 0, 0);