@vpmedia/phaser 1.95.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 (167) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/package.json +9 -9
  3. package/src/phaser/core/animation.js +61 -56
  4. package/src/phaser/core/animation_manager.js +55 -55
  5. package/src/phaser/core/cache.js +154 -154
  6. package/src/phaser/core/device.js +2 -1
  7. package/src/phaser/core/device_util.js +27 -27
  8. package/src/phaser/core/dom.js +43 -43
  9. package/src/phaser/core/event_manager.js +63 -63
  10. package/src/phaser/core/factory.js +47 -47
  11. package/src/phaser/core/frame.js +30 -30
  12. package/src/phaser/core/frame_data.js +30 -28
  13. package/src/phaser/core/frame_util.js +8 -8
  14. package/src/phaser/core/game.js +34 -18
  15. package/src/phaser/core/loader.js +170 -170
  16. package/src/phaser/core/loader_parser.js +22 -22
  17. package/src/phaser/core/raf.js +1 -1
  18. package/src/phaser/core/scene.js +16 -10
  19. package/src/phaser/core/scene_manager.js +51 -43
  20. package/src/phaser/core/signal.js +56 -52
  21. package/src/phaser/core/sound.js +54 -54
  22. package/src/phaser/core/sound_manager.js +49 -49
  23. package/src/phaser/core/stage.js +16 -16
  24. package/src/phaser/core/time.js +30 -30
  25. package/src/phaser/core/timer.js +64 -64
  26. package/src/phaser/core/timer_event.js +9 -9
  27. package/src/phaser/core/tween.js +90 -90
  28. package/src/phaser/core/tween_data.js +30 -30
  29. package/src/phaser/core/tween_manager.js +29 -24
  30. package/src/phaser/core/world.js +4 -3
  31. package/src/phaser/display/bitmap_text.js +61 -54
  32. package/src/phaser/display/button.js +48 -47
  33. package/src/phaser/display/canvas/buffer.js +8 -8
  34. package/src/phaser/display/canvas/graphics.js +8 -8
  35. package/src/phaser/display/canvas/masker.js +5 -5
  36. package/src/phaser/display/canvas/pool.js +18 -18
  37. package/src/phaser/display/canvas/renderer.js +16 -16
  38. package/src/phaser/display/canvas/tinter.js +22 -22
  39. package/src/phaser/display/canvas/util.js +42 -42
  40. package/src/phaser/display/display_object.js +119 -108
  41. package/src/phaser/display/graphics.js +112 -112
  42. package/src/phaser/display/graphics_data.js +10 -10
  43. package/src/phaser/display/graphics_data_util.js +3 -3
  44. package/src/phaser/display/group.js +50 -50
  45. package/src/phaser/display/image.js +54 -50
  46. package/src/phaser/display/sprite_batch.js +2 -2
  47. package/src/phaser/display/sprite_util.js +19 -19
  48. package/src/phaser/display/text.js +212 -187
  49. package/src/phaser/display/webgl/abstract_filter.js +4 -4
  50. package/src/phaser/display/webgl/base_texture.js +9 -9
  51. package/src/phaser/display/webgl/blend_manager.js +7 -7
  52. package/src/phaser/display/webgl/earcut.js +95 -95
  53. package/src/phaser/display/webgl/earcut_node.js +4 -4
  54. package/src/phaser/display/webgl/fast_sprite_batch.js +15 -15
  55. package/src/phaser/display/webgl/filter_manager.js +9 -9
  56. package/src/phaser/display/webgl/filter_texture.js +10 -10
  57. package/src/phaser/display/webgl/graphics.js +37 -37
  58. package/src/phaser/display/webgl/graphics_data.js +4 -4
  59. package/src/phaser/display/webgl/mask_manager.js +6 -6
  60. package/src/phaser/display/webgl/render_texture.js +16 -16
  61. package/src/phaser/display/webgl/renderer.js +20 -20
  62. package/src/phaser/display/webgl/shader/complex.js +4 -4
  63. package/src/phaser/display/webgl/shader/fast.js +4 -4
  64. package/src/phaser/display/webgl/shader/normal.js +8 -8
  65. package/src/phaser/display/webgl/shader/primitive.js +4 -4
  66. package/src/phaser/display/webgl/shader/strip.js +4 -4
  67. package/src/phaser/display/webgl/shader_manager.js +9 -9
  68. package/src/phaser/display/webgl/sprite_batch.js +18 -18
  69. package/src/phaser/display/webgl/stencil_manager.js +16 -16
  70. package/src/phaser/display/webgl/texture.js +13 -13
  71. package/src/phaser/display/webgl/texture_util.js +8 -8
  72. package/src/phaser/display/webgl/util.js +25 -25
  73. package/src/phaser/geom/circle.js +69 -69
  74. package/src/phaser/geom/ellipse.js +28 -28
  75. package/src/phaser/geom/line.js +93 -93
  76. package/src/phaser/geom/matrix.js +54 -54
  77. package/src/phaser/geom/point.js +96 -96
  78. package/src/phaser/geom/polygon.js +22 -22
  79. package/src/phaser/geom/rectangle.js +132 -132
  80. package/src/phaser/geom/rounded_rectangle.js +12 -12
  81. package/src/phaser/geom/util/circle.js +33 -33
  82. package/src/phaser/geom/util/ellipse.js +5 -5
  83. package/src/phaser/geom/util/line.js +26 -26
  84. package/src/phaser/geom/util/matrix.js +8 -8
  85. package/src/phaser/geom/util/point.js +97 -97
  86. package/src/phaser/geom/util/polygon.js +4 -4
  87. package/src/phaser/geom/util/rectangle.js +74 -74
  88. package/src/phaser/geom/util/rounded_rectangle.js +4 -4
  89. package/src/phaser/util/math.js +81 -81
  90. package/types/phaser/core/animation.d.ts +61 -56
  91. package/types/phaser/core/animation.d.ts.map +1 -1
  92. package/types/phaser/core/animation_manager.d.ts +55 -55
  93. package/types/phaser/core/cache.d.ts +154 -154
  94. package/types/phaser/core/device.d.ts.map +1 -1
  95. package/types/phaser/core/dom.d.ts +43 -43
  96. package/types/phaser/core/event_manager.d.ts +63 -63
  97. package/types/phaser/core/factory.d.ts +47 -47
  98. package/types/phaser/core/frame.d.ts +30 -30
  99. package/types/phaser/core/frame_data.d.ts +28 -27
  100. package/types/phaser/core/frame_data.d.ts.map +1 -1
  101. package/types/phaser/core/game.d.ts +52 -19
  102. package/types/phaser/core/game.d.ts.map +1 -1
  103. package/types/phaser/core/loader.d.ts +170 -170
  104. package/types/phaser/core/loader_parser.d.ts.map +1 -1
  105. package/types/phaser/core/raf.d.ts +1 -1
  106. package/types/phaser/core/scene.d.ts +15 -9
  107. package/types/phaser/core/scene.d.ts.map +1 -1
  108. package/types/phaser/core/scene_manager.d.ts +51 -43
  109. package/types/phaser/core/scene_manager.d.ts.map +1 -1
  110. package/types/phaser/core/signal.d.ts +54 -51
  111. package/types/phaser/core/signal.d.ts.map +1 -1
  112. package/types/phaser/core/sound.d.ts +54 -54
  113. package/types/phaser/core/sound_manager.d.ts +49 -49
  114. package/types/phaser/core/stage.d.ts +10 -10
  115. package/types/phaser/core/time.d.ts +30 -30
  116. package/types/phaser/core/timer.d.ts +64 -64
  117. package/types/phaser/core/timer_event.d.ts +9 -9
  118. package/types/phaser/core/tween.d.ts +90 -90
  119. package/types/phaser/core/tween_data.d.ts +30 -30
  120. package/types/phaser/core/tween_manager.d.ts +29 -24
  121. package/types/phaser/core/tween_manager.d.ts.map +1 -1
  122. package/types/phaser/core/world.d.ts +4 -3
  123. package/types/phaser/core/world.d.ts.map +1 -1
  124. package/types/phaser/display/bitmap_text.d.ts +59 -52
  125. package/types/phaser/display/bitmap_text.d.ts.map +1 -1
  126. package/types/phaser/display/button.d.ts +47 -46
  127. package/types/phaser/display/button.d.ts.map +1 -1
  128. package/types/phaser/display/canvas/buffer.d.ts +8 -8
  129. package/types/phaser/display/canvas/renderer.d.ts +16 -16
  130. package/types/phaser/display/display_object.d.ts +119 -108
  131. package/types/phaser/display/display_object.d.ts.map +1 -1
  132. package/types/phaser/display/graphics.d.ts +101 -101
  133. package/types/phaser/display/graphics_data.d.ts +10 -10
  134. package/types/phaser/display/group.d.ts +47 -47
  135. package/types/phaser/display/image.d.ts +42 -40
  136. package/types/phaser/display/image.d.ts.map +1 -1
  137. package/types/phaser/display/text.d.ts +207 -184
  138. package/types/phaser/display/text.d.ts.map +1 -1
  139. package/types/phaser/display/webgl/abstract_filter.d.ts +4 -4
  140. package/types/phaser/display/webgl/base_texture.d.ts +9 -9
  141. package/types/phaser/display/webgl/blend_manager.d.ts +6 -6
  142. package/types/phaser/display/webgl/earcut.d.ts +95 -95
  143. package/types/phaser/display/webgl/earcut_node.d.ts +4 -4
  144. package/types/phaser/display/webgl/fast_sprite_batch.d.ts +15 -15
  145. package/types/phaser/display/webgl/filter_manager.d.ts +8 -8
  146. package/types/phaser/display/webgl/filter_texture.d.ts +10 -10
  147. package/types/phaser/display/webgl/graphics_data.d.ts +4 -4
  148. package/types/phaser/display/webgl/render_texture.d.ts +16 -16
  149. package/types/phaser/display/webgl/renderer.d.ts +20 -20
  150. package/types/phaser/display/webgl/shader/complex.d.ts +4 -4
  151. package/types/phaser/display/webgl/shader/fast.d.ts +4 -4
  152. package/types/phaser/display/webgl/shader/normal.d.ts +8 -8
  153. package/types/phaser/display/webgl/shader/primitive.d.ts +4 -4
  154. package/types/phaser/display/webgl/shader/strip.d.ts +4 -4
  155. package/types/phaser/display/webgl/shader_manager.d.ts +8 -8
  156. package/types/phaser/display/webgl/sprite_batch.d.ts +17 -17
  157. package/types/phaser/display/webgl/stencil_manager.d.ts +15 -15
  158. package/types/phaser/display/webgl/texture.d.ts +12 -12
  159. package/types/phaser/geom/circle.d.ts +69 -69
  160. package/types/phaser/geom/ellipse.d.ts +28 -28
  161. package/types/phaser/geom/line.d.ts +93 -93
  162. package/types/phaser/geom/matrix.d.ts +54 -54
  163. package/types/phaser/geom/point.d.ts +96 -96
  164. package/types/phaser/geom/polygon.d.ts +22 -22
  165. package/types/phaser/geom/rectangle.d.ts +132 -132
  166. package/types/phaser/geom/rounded_rectangle.d.ts +12 -12
  167. package/pnpm-workspace.yaml +0 -4
@@ -2,11 +2,11 @@ import { Point } from '../point.js';
2
2
  import { Rectangle } from '../rectangle.js';
3
3
 
4
4
  /**
5
- * TBD.
6
- * @param {Rectangle} a - TBD.
7
- * @param {number} dx - TBD.
8
- * @param {number} dy - TBD.
9
- * @returns {Rectangle} TBD.
5
+ * Inflates the rectangle by the specified amounts on each axis.
6
+ * @param {Rectangle} a - The rectangle to inflate.
7
+ * @param {number} dx - The amount to inflate the rectangle horizontally.
8
+ * @param {number} dy - The amount to inflate the rectangle vertically.
9
+ * @returns {Rectangle} The inflated rectangle.
10
10
  */
11
11
  export const inflate = (a, dx, dy) => {
12
12
  a.x -= dx;
@@ -17,20 +17,20 @@ export const inflate = (a, dx, dy) => {
17
17
  };
18
18
 
19
19
  /**
20
- * TBD.
21
- * @param {Rectangle} a - TBD.
22
- * @param {object} point - TBD.
23
- * @returns {Rectangle} TBD.
20
+ * Inflates the rectangle by the specified point values on each axis.
21
+ * @param {Rectangle} a - The rectangle to inflate.
22
+ * @param {object} point - The point containing x and y values to inflate the rectangle by.
23
+ * @returns {Rectangle} The inflated rectangle.
24
24
  */
25
25
  export const inflatePoint = (a, point) => {
26
26
  return inflate(a, point.x, point.y);
27
27
  };
28
28
 
29
29
  /**
30
- * TBD.
31
- * @param {Rectangle} a - TBD.
32
- * @param {Point} output - TBD.
33
- * @returns {Point} TBD.
30
+ * Gets the size of the rectangle as a point.
31
+ * @param {Rectangle} a - The rectangle to get the size of.
32
+ * @param {Point} output - Optional point to store the result in.
33
+ * @returns {Point} The size of the rectangle as a point (width, height).
34
34
  */
35
35
  export const size = (a, output = null) => {
36
36
  const result = output || new Point();
@@ -39,10 +39,10 @@ export const size = (a, output = null) => {
39
39
  };
40
40
 
41
41
  /**
42
- * TBD.
43
- * @param {Rectangle} input - TBD.
44
- * @param {Rectangle} output - TBD.
45
- * @returns {Rectangle} TBD.
42
+ * Clones a rectangle.
43
+ * @param {Rectangle} input - The rectangle to clone.
44
+ * @param {Rectangle} output - Optional rectangle to store the result in.
45
+ * @returns {Rectangle} The cloned rectangle.
46
46
  */
47
47
  export const clone = (input, output = null) => {
48
48
  const result = output || new Rectangle();
@@ -51,11 +51,11 @@ export const clone = (input, output = null) => {
51
51
  };
52
52
 
53
53
  /**
54
- * TBD.
55
- * @param {Rectangle} a - TBD.
56
- * @param {number} x - TBD.
57
- * @param {number} y - TBD.
58
- * @returns {boolean} TBD.
54
+ * Checks if a point is contained within the rectangle.
55
+ * @param {Rectangle} a - The rectangle to check.
56
+ * @param {number} x - The x coordinate of the point.
57
+ * @param {number} y - The y coordinate of the point.
58
+ * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
59
59
  */
60
60
  export const contains = (a, x, y) => {
61
61
  if (a.width <= 0 || a.height <= 0) {
@@ -65,34 +65,34 @@ export const contains = (a, x, y) => {
65
65
  };
66
66
 
67
67
  /**
68
- * TBD.
69
- * @param {number} rx - TBD.
70
- * @param {number} ry - TBD.
71
- * @param {number} rw - TBD.
72
- * @param {number} rh - TBD.
73
- * @param {number} x - TBD.
74
- * @param {number} y - TBD.
75
- * @returns {boolean} TBD.
68
+ * Checks if a point is contained within the rectangle (raw version).
69
+ * @param {number} rx - The x coordinate of the rectangle.
70
+ * @param {number} ry - The y coordinate of the rectangle.
71
+ * @param {number} rw - The width of the rectangle.
72
+ * @param {number} rh - The height of the rectangle.
73
+ * @param {number} x - The x coordinate of the point.
74
+ * @param {number} y - The y coordinate of the point.
75
+ * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
76
76
  */
77
77
  export const containsRaw = (rx, ry, rw, rh, x, y) => {
78
78
  return x >= rx && x < rx + rw && y >= ry && y < ry + rh;
79
79
  };
80
80
 
81
81
  /**
82
- * TBD.
83
- * @param {Rectangle} a - TBD.
84
- * @param {Point} point - TBD.
85
- * @returns {boolean} TBD.
82
+ * Checks if a point is contained within the rectangle.
83
+ * @param {Rectangle} a - The rectangle to check.
84
+ * @param {Point} point - The point to check.
85
+ * @returns {boolean} True if the point is contained within the rectangle, false otherwise.
86
86
  */
87
87
  export const containsPoint = (a, point) => {
88
88
  return contains(a, point.x, point.y);
89
89
  };
90
90
 
91
91
  /**
92
- * TBD.
93
- * @param {Rectangle} a - TBD.
94
- * @param {Rectangle} b - TBD.
95
- * @returns {boolean} TBD.
92
+ * Checks if rectangle a contains rectangle b.
93
+ * @param {Rectangle} a - The first rectangle to check.
94
+ * @param {Rectangle} b - The second rectangle to check.
95
+ * @returns {boolean} True if rectangle a contains rectangle b, false otherwise.
96
96
  */
97
97
  export const containsRect = (a, b) => {
98
98
  if (a.volume > b.volume) {
@@ -102,30 +102,30 @@ export const containsRect = (a, b) => {
102
102
  };
103
103
 
104
104
  /**
105
- * TBD.
106
- * @param {Rectangle} a - TBD.
107
- * @param {Rectangle} b - TBD.
108
- * @returns {boolean} TBD.
105
+ * Checks if two rectangles are equal.
106
+ * @param {Rectangle} a - The first rectangle to compare.
107
+ * @param {Rectangle} b - The second rectangle to compare.
108
+ * @returns {boolean} True if the rectangles are equal, false otherwise.
109
109
  */
110
110
  export const equals = (a, b) => {
111
111
  return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
112
112
  };
113
113
 
114
114
  /**
115
- * TBD.
116
- * @param {Rectangle} a - TBD.
117
- * @param {Rectangle} b - TBD.
118
- * @returns {boolean} TBD.
115
+ * Checks if two rectangles have the same dimensions.
116
+ * @param {Rectangle} a - The first rectangle to compare.
117
+ * @param {Rectangle} b - The second rectangle to compare.
118
+ * @returns {boolean} True if the rectangles have the same dimensions, false otherwise.
119
119
  */
120
120
  export const sameDimensions = (a, b) => {
121
121
  return a.width === b.width && a.height === b.height;
122
122
  };
123
123
 
124
124
  /**
125
- * TBD.
126
- * @param {Rectangle} a - TBD.
127
- * @param {Rectangle} b - TBD.
128
- * @returns {boolean} TBD.
125
+ * Checks if two rectangles intersect.
126
+ * @param {Rectangle} a - The first rectangle to check.
127
+ * @param {Rectangle} b - The second rectangle to check.
128
+ * @returns {boolean} True if the rectangles intersect, false otherwise.
129
129
  */
130
130
  export const intersects = (a, b) => {
131
131
  if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) {
@@ -135,11 +135,11 @@ export const intersects = (a, b) => {
135
135
  };
136
136
 
137
137
  /**
138
- * TBD.
139
- * @param {Rectangle} a - TBD.
140
- * @param {Rectangle} b - TBD.
141
- * @param {Rectangle} output - TBD.
142
- * @returns {Rectangle} TBD.
138
+ * Gets the intersection of two rectangles.
139
+ * @param {Rectangle} a - The first rectangle.
140
+ * @param {Rectangle} b - The second rectangle.
141
+ * @param {Rectangle} output - Optional rectangle to store the result in.
142
+ * @returns {Rectangle} The intersection of the rectangles, or an empty rectangle if they don't intersect.
143
143
  */
144
144
  export const intersection = (a, b, output = null) => {
145
145
  const result = output || new Rectangle();
@@ -153,14 +153,14 @@ export const intersection = (a, b, output = null) => {
153
153
  };
154
154
 
155
155
  /**
156
- * TBD.
157
- * @param {Rectangle} a - TBD.
158
- * @param {number} left - TBD.
159
- * @param {number} right - TBD.
160
- * @param {number} top - TBD.
161
- * @param {number} bottom - TBD.
162
- * @param {number} tolerance - TBD.
163
- * @returns {boolean} TBD.
156
+ * Checks if a rectangle intersects with a set of raw coordinates.
157
+ * @param {Rectangle} a - The rectangle to check.
158
+ * @param {number} left - The left coordinate of the area to check.
159
+ * @param {number} right - The right coordinate of the area to check.
160
+ * @param {number} top - The top coordinate of the area to check.
161
+ * @param {number} bottom - The bottom coordinate of the area to check.
162
+ * @param {number} tolerance - Optional tolerance value for intersection.
163
+ * @returns {boolean} True if the rectangle intersects with the area, false otherwise.
164
164
  */
165
165
  export const intersectsRaw = (a, left, right, top, bottom, tolerance = 0) => {
166
166
  return !(
@@ -172,11 +172,11 @@ export const intersectsRaw = (a, left, right, top, bottom, tolerance = 0) => {
172
172
  };
173
173
 
174
174
  /**
175
- * TBD.
176
- * @param {Rectangle} a - TBD.
177
- * @param {Rectangle} b - TBD.
178
- * @param {Rectangle} output - TBD.
179
- * @returns {Rectangle} TBD.
175
+ * Gets the union of two rectangles.
176
+ * @param {Rectangle} a - The first rectangle.
177
+ * @param {Rectangle} b - The second rectangle.
178
+ * @param {Rectangle} output - Optional rectangle to store the result in.
179
+ * @returns {Rectangle} The union of the rectangles.
180
180
  */
181
181
  export const union = (a, b, output = null) => {
182
182
  const result = output || new Rectangle();
@@ -189,10 +189,10 @@ export const union = (a, b, output = null) => {
189
189
  };
190
190
 
191
191
  /**
192
- * TBD.
193
- * @param {Point[]} points - TBD.
194
- * @param {Rectangle} output - TBD.
195
- * @returns {Rectangle} TBD.
192
+ * Gets the axis-aligned bounding box (AABB) of a set of points.
193
+ * @param {Point[]} points - The array of points to calculate the AABB for.
194
+ * @param {Rectangle} output - Optional rectangle to store the result in.
195
+ * @returns {Rectangle} The AABB of the points.
196
196
  */
197
197
  export const aabb = (points, output = null) => {
198
198
  const result = output || new Rectangle();
@@ -219,8 +219,8 @@ export const aabb = (points, output = null) => {
219
219
  };
220
220
 
221
221
  /**
222
- * TBD.
223
- * @returns {Rectangle} TBD.
222
+ * Gets an empty rectangle instance.
223
+ * @returns {Rectangle} An empty rectangle.
224
224
  */
225
225
  export const getEmptyRectangle = () => {
226
226
  if (!window.PhaserRegistry) {
@@ -1,10 +1,10 @@
1
1
  import { RoundedRectangle } from '../rounded_rectangle.js';
2
2
 
3
3
  /**
4
- * TBD.
5
- * @param {RoundedRectangle} input - TBD.
6
- * @param {RoundedRectangle} output - TBD.
7
- * @returns {RoundedRectangle} TBD.
4
+ * Clones a rounded rectangle.
5
+ * @param {RoundedRectangle} input - The rounded rectangle to clone.
6
+ * @param {RoundedRectangle} output - Optional rounded rectangle to store the result in.
7
+ * @returns {RoundedRectangle} The cloned rounded rectangle.
8
8
  */
9
9
  export const clone = (input, output = null) => {
10
10
  const result = output || new RoundedRectangle();
@@ -3,27 +3,27 @@ export const RAD_TO_DEG = 180 / Math.PI;
3
3
  export const PI_2 = Math.PI * 2;
4
4
 
5
5
  /**
6
- * TBD.
7
- * @param {number} hex - TBD.
8
- * @returns {number[]} TBD.
6
+ * Converts a hexadecimal color value to RGB components.
7
+ * @param {number} hex - The hexadecimal color value.
8
+ * @returns {number[]} An array containing the RGB components [r, g, b].
9
9
  */
10
10
  export const hex2rgb = (hex) => {
11
11
  return [((hex >> 16) & 0xff) / 255, ((hex >> 8) & 0xff) / 255, (hex & 0xff) / 255];
12
12
  };
13
13
 
14
14
  /**
15
- * TBD.
16
- * @param {number} rgb - TBD.
17
- * @returns {number} TBD.
15
+ * Converts RGB components to a hexadecimal color value.
16
+ * @param {number} rgb - The RGB components array [r, g, b].
17
+ * @returns {number} The hexadecimal color value.
18
18
  */
19
19
  export const rgb2hex = (rgb) => {
20
20
  return ((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + rgb[2] * 255;
21
21
  };
22
22
 
23
23
  /**
24
- * TBD.
25
- * @param {number} value - TBD.
26
- * @returns {number} TBD.
24
+ * Gets the next power of two greater than or equal to a value.
25
+ * @param {number} value - The input value.
26
+ * @returns {number} The next power of two.
27
27
  */
28
28
  export const getNextPowerOfTwo = (value) => {
29
29
  // see: https://en.wikipedia.org/wiki/Power_of_two#Fast_algorithm_to_check_if_a_positive_number_is_a_power_of_two
@@ -38,49 +38,49 @@ export const getNextPowerOfTwo = (value) => {
38
38
  };
39
39
 
40
40
  /**
41
- * TBD.
42
- * @param {number} width - TBD.
43
- * @param {number} height - TBD.
44
- * @returns {boolean} TBD.
41
+ * Checks if both width and height are powers of two.
42
+ * @param {number} width - The width to check.
43
+ * @param {number} height - The height to check.
44
+ * @returns {boolean} True if both width and height are powers of two, false otherwise.
45
45
  */
46
46
  export const isPowerOfTwo = (width, height) => {
47
47
  return width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0;
48
48
  };
49
49
 
50
50
  /**
51
- * TBD.
52
- * @param {number} degrees - TBD.
53
- * @returns {number} TBD.
51
+ * Converts degrees to radians.
52
+ * @param {number} degrees - The angle in degrees.
53
+ * @returns {number} The angle in radians.
54
54
  */
55
55
  export const degToRad = (degrees) => {
56
56
  return degrees * DEG_TO_RAD;
57
57
  };
58
58
 
59
59
  /**
60
- * TBD.
61
- * @param {number} radians - TBD.
62
- * @returns {number} TBD.
60
+ * Converts radians to degrees.
61
+ * @param {number} radians - The angle in radians.
62
+ * @returns {number} The angle in degrees.
63
63
  */
64
64
  export const radToDeg = (radians) => {
65
65
  return radians * RAD_TO_DEG;
66
66
  };
67
67
 
68
68
  /**
69
- * TBD.
70
- * @param {number} min - TBD.
71
- * @param {number} max - TBD.
72
- * @returns {number} TBD.
69
+ * Gets a random integer between min and max (inclusive).
70
+ * @param {number} min - The minimum value.
71
+ * @param {number} max - The maximum value.
72
+ * @returns {number} A random integer between min and max.
73
73
  */
74
74
  export const between = (min, max) => {
75
75
  return Math.floor(Math.random() * (max - min + 1) + min);
76
76
  };
77
77
 
78
78
  /**
79
- * TBD.
80
- * @param {number} input - TBD.
81
- * @param {number} gap - TBD.
82
- * @param {number} start - TBD.
83
- * @returns {number} TBD.
79
+ * Snaps a value to the nearest multiple of gap, starting from start.
80
+ * @param {number} input - The value to snap.
81
+ * @param {number} gap - The gap size to snap to.
82
+ * @param {number} start - The starting offset for snapping.
83
+ * @returns {number} The snapped value.
84
84
  */
85
85
  export const snapToCeil = (input, gap = 0, start = 0) => {
86
86
  if (gap === 0) {
@@ -92,11 +92,11 @@ export const snapToCeil = (input, gap = 0, start = 0) => {
92
92
  };
93
93
 
94
94
  /**
95
- * TBD.
96
- * @param {number} value - TBD.
97
- * @param {number} min - TBD.
98
- * @param {number} max - TBD.
99
- * @returns {number} TBD.
95
+ * Wraps a value within a range.
96
+ * @param {number} value - The value to wrap.
97
+ * @param {number} min - The minimum value of the range.
98
+ * @param {number} max - The maximum value of the range.
99
+ * @returns {number} The wrapped value.
100
100
  */
101
101
  export const wrap = (value, min, max) => {
102
102
  const range = max - min;
@@ -111,31 +111,31 @@ export const wrap = (value, min, max) => {
111
111
  };
112
112
 
113
113
  /**
114
- * TBD.
115
- * @param {number} p0 - TBD.
116
- * @param {number} p1 - TBD.
117
- * @param {number} t - TBD.
118
- * @returns {number} TBD.
114
+ * Performs linear interpolation between two values.
115
+ * @param {number} p0 - The first point.
116
+ * @param {number} p1 - The second point.
117
+ * @param {number} t - The interpolation factor (0 to 1).
118
+ * @returns {number} The interpolated value.
119
119
  */
120
120
  export const linear = (p0, p1, t) => {
121
121
  return (p1 - p0) * t + p0;
122
122
  };
123
123
 
124
124
  /**
125
- * TBD.
126
- * @param {number} a - TBD.
127
- * @param {number} b - TBD.
128
- * @returns {number} TBD.
125
+ * Calculates the absolute difference between two numbers.
126
+ * @param {number} a - The first number.
127
+ * @param {number} b - The second number.
128
+ * @returns {number} The absolute difference between a and b.
129
129
  */
130
130
  export const difference = (a, b) => {
131
131
  return Math.abs(a - b);
132
132
  };
133
133
 
134
134
  /**
135
- * TBD.
136
- * @param {number[]} v - TBD.
137
- * @param {number} k - TBD.
138
- * @returns {number} TBD.
135
+ * Performs linear interpolation on an array of values.
136
+ * @param {number[]} v - The array of values.
137
+ * @param {number} k - The interpolation factor (0 to 1).
138
+ * @returns {number} The interpolated value.
139
139
  */
140
140
  export const linearInterpolation = (v, k) => {
141
141
  const m = v.length - 1;
@@ -151,12 +151,12 @@ export const linearInterpolation = (v, k) => {
151
151
  };
152
152
 
153
153
  /**
154
- * TBD.
155
- * @param {number} x1 - TBD.
156
- * @param {number} y1 - TBD.
157
- * @param {number} x2 - TBD.
158
- * @param {number} y2 - TBD.
159
- * @returns {number} TBD.
154
+ * Calculates the distance between two points.
155
+ * @param {number} x1 - The x-coordinate of the first point.
156
+ * @param {number} y1 - The y-coordinate of the first point.
157
+ * @param {number} x2 - The x-coordinate of the second point.
158
+ * @param {number} y2 - The y-coordinate of the second point.
159
+ * @returns {number} The distance between the two points.
160
160
  */
161
161
  export const distance = (x1, y1, x2, y2) => {
162
162
  const dx = x1 - x2;
@@ -165,43 +165,43 @@ export const distance = (x1, y1, x2, y2) => {
165
165
  };
166
166
 
167
167
  /**
168
- * TBD.
169
- * @param {number} a - TBD.
170
- * @param {number} b - TBD.
171
- * @param {number} tolerance - TBD.
172
- * @returns {boolean} TBD.
168
+ * Checks if two numbers are within a tolerance of each other.
169
+ * @param {number} a - The first number.
170
+ * @param {number} b - The second number.
171
+ * @param {number} tolerance - The tolerance value.
172
+ * @returns {boolean} True if the numbers are within tolerance, false otherwise.
173
173
  */
174
174
  export const within = (a, b, tolerance) => {
175
175
  return Math.abs(a - b) <= tolerance;
176
176
  };
177
177
 
178
178
  /**
179
- * TBD.
180
- * @param {number} a - TBD.
181
- * @param {number} r - TBD.
182
- * @param {number} g - TBD.
183
- * @param {number} b - TBD.
184
- * @returns {number} TBD.
179
+ * Creates a 32-bit color value from alpha, red, green, and blue components.
180
+ * @param {number} a - The alpha component (0-255).
181
+ * @param {number} r - The red component (0-255).
182
+ * @param {number} g - The green component (0-255).
183
+ * @param {number} b - The blue component (0-255).
184
+ * @returns {number} The 32-bit color value.
185
185
  */
186
186
  export const getColor32 = (a, r, g, b) => {
187
187
  return (a << 24) | (r << 16) | (g << 8) | b;
188
188
  };
189
189
 
190
190
  /**
191
- * TBD.
192
- * @param {number} r - TBD.
193
- * @param {number} g - TBD.
194
- * @param {number} b - TBD.
195
- * @returns {number} TBD.
191
+ * Creates a 24-bit color value from red, green, and blue components.
192
+ * @param {number} r - The red component (0-255).
193
+ * @param {number} g - The green component (0-255).
194
+ * @param {number} b - The blue component (0-255).
195
+ * @returns {number} The 24-bit color value.
196
196
  */
197
197
  export const getColor = (r, g, b) => {
198
198
  return (r << 16) | (g << 8) | b;
199
199
  };
200
200
 
201
201
  /**
202
- * TBD.
203
- * @param {string} value - TBD.
204
- * @param {{r?: number, g?: number, b?: number}} out - TBD.
202
+ * Converts a hex color string to RGB components.
203
+ * @param {string} value - The hex color string (e.g. "#FF0000").
204
+ * @param {{r?: number, g?: number, b?: number}} out - The object to store the result in.
205
205
  */
206
206
  export const hexToColor = (value, out) => {
207
207
  // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
@@ -215,9 +215,9 @@ export const hexToColor = (value, out) => {
215
215
  };
216
216
 
217
217
  /**
218
- * TBD.
219
- * @param {string} value - TBD.
220
- * @param {{r?: number, g?: number, b?: number, a?: number}} out - TBD.
218
+ * Converts a web color string (e.g. "rgb(255, 0, 0)") to RGB components with alpha.
219
+ * @param {string} value - The web color string (e.g. "rgba(255, 0, 0, 0.5)").
220
+ * @param {{r?: number, g?: number, b?: number, a?: number}} out - The object to store the result in.
221
221
  */
222
222
  export const webToColor = (value, out) => {
223
223
  const result = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(value);
@@ -230,9 +230,9 @@ export const webToColor = (value, out) => {
230
230
  };
231
231
 
232
232
  /**
233
- * TBD.
234
- * @param {number} color - TBD.
235
- * @returns {{ alpha: number, red: number, green: number, blue: number, a: number, r: number, g: number, b: number}} TBD.
233
+ * Extracts RGB components from a 32-bit color value.
234
+ * @param {number} color - The 32-bit color value.
235
+ * @returns {{ alpha: number, red: number, green: number, blue: number, a: number, r: number, g: number, b: number}} An object containing the color components.
236
236
  */
237
237
  export const getRGB = (color) => {
238
238
  if (color > 16777215) {
@@ -261,10 +261,10 @@ export const getRGB = (color) => {
261
261
  };
262
262
 
263
263
  /**
264
- * TBD.
265
- * @param {string|number} value - TBD.
266
- * @param {{a?: number, r?: number, g?: number, b?: number, rgba?: string, color?: number, color32?: number}} out - TBD.
267
- * @returns {{a?: number, r?: number, g?: number, b?: number, rgba?: string, color?: number, color32?: number}} TBD.
264
+ * Converts a color value (string or number) to an object with various color formats.
265
+ * @param {string|number} value - The color value (e.g. "#FF0000" or 0xFF0000).
266
+ * @param {{a?: number, r?: number, g?: number, b?: number, rgba?: string, color?: number, color32?: number}} out - The object to store the result in.
267
+ * @returns {{a?: number, r?: number, g?: number, b?: number, rgba?: string, color?: number, color32?: number}} The updated out object.
268
268
  */
269
269
  export const valueToColor = (value, out) => {
270
270
  if (typeof value === 'string') {