@ringozz/godot 4.7.2-583 → 4.7.2-592

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 (49) hide show
  1. package/README.md +19 -1
  2. package/gen/classes/ArrayOccluder3D.ts +1 -1
  3. package/gen/classes/CPUParticles2D.ts +3 -3
  4. package/gen/classes/CPUParticles3D.ts +3 -3
  5. package/gen/classes/CSGPolygon3D.ts +1 -1
  6. package/gen/classes/CollisionPolygon2D.ts +1 -1
  7. package/gen/classes/CollisionPolygon3D.ts +1 -1
  8. package/gen/classes/ColorPalette.ts +1 -1
  9. package/gen/classes/ConcavePolygonShape2D.ts +1 -1
  10. package/gen/classes/ConcavePolygonShape3D.ts +1 -1
  11. package/gen/classes/ConvexPolygonShape2D.ts +1 -1
  12. package/gen/classes/ConvexPolygonShape3D.ts +1 -1
  13. package/gen/classes/FontVariation.ts +1 -1
  14. package/gen/classes/Gradient.ts +1 -1
  15. package/gen/classes/Line2D.ts +1 -1
  16. package/gen/classes/MultiMesh.ts +4 -4
  17. package/gen/classes/NavigationMesh.ts +1 -1
  18. package/gen/classes/NavigationObstacle2D.ts +1 -1
  19. package/gen/classes/NavigationObstacle3D.ts +1 -1
  20. package/gen/classes/NavigationPathQueryResult2D.ts +1 -1
  21. package/gen/classes/NavigationPathQueryResult3D.ts +1 -1
  22. package/gen/classes/NavigationPolygon.ts +1 -1
  23. package/gen/classes/OccluderPolygon2D.ts +1 -1
  24. package/gen/classes/Polygon2D.ts +3 -3
  25. package/gen/classes/PolygonOccluder3D.ts +1 -1
  26. package/gen/classes/Window.ts +1 -1
  27. package/gen/index.ts +0 -3
  28. package/gen/utility-functions.ts +114 -114
  29. package/gen/value-types/AABB.ts +267 -277
  30. package/gen/value-types/Basis.ts +313 -264
  31. package/gen/value-types/Color.ts +398 -268
  32. package/gen/value-types/Plane.ts +121 -125
  33. package/gen/value-types/Projection.ts +178 -126
  34. package/gen/value-types/Quaternion.ts +180 -179
  35. package/gen/value-types/Rect2.ts +169 -171
  36. package/gen/value-types/Rect2i.ts +148 -150
  37. package/gen/value-types/Transform2D.ts +192 -194
  38. package/gen/value-types/Transform3D.ts +133 -126
  39. package/gen/value-types/Vector2.ts +370 -354
  40. package/gen/value-types/Vector2i.ts +192 -191
  41. package/gen/value-types/Vector3.ts +354 -354
  42. package/gen/value-types/Vector3i.ts +187 -192
  43. package/gen/value-types/Vector4.ts +263 -274
  44. package/gen/value-types/Vector4i.ts +187 -198
  45. package/gen/value-types/index.ts +16 -16
  46. package/package.json +20 -4
  47. package/src/debug.ts +30 -27
  48. package/src/index.ts +0 -2
  49. package/src/runtime.ts +16 -7
@@ -1,9 +1,9 @@
1
1
  // Auto-generated from extension_api.json - DO NOT EDIT
2
2
  // Generated by dev/codegen.ts
3
3
 
4
- import { GodotVar, _C, _R, _get, _set } from '../../src/runtime.ts';
4
+ import { _V } from '../../src/runtime.ts';
5
5
  import type { GodotArray, GodotDictionary, PackedVector2Array, Variant } from '../heap-types/index.ts';
6
- import type { Transform2D, Vector2i } from '../value-types/index.ts';
6
+ import type { Transform2D, Vector2i } from './index.ts';
7
7
 
8
8
  /**
9
9
  * A 2-element structure that can be used to represent 2D coordinates or any other pair of numeric values.
@@ -11,355 +11,371 @@ import type { Transform2D, Vector2i } from '../value-types/index.ts';
11
11
  * See {@link Vector2i} for its integer counterpart.
12
12
  * **Note:** In a boolean context, a Vector2 will evaluate to `false` if it's equal to `Vector2(0, 0)`. Otherwise, a Vector2 will always evaluate to `true`.
13
13
  */
14
- export class Vector2 extends GodotVar {
15
- /**
16
- * The vector's X component. Also accessible by using the index position `[0]`.
17
- */
18
- get x(): number { return _get(this, 14941) as number; }
19
- set x(v: number) { _set(this, 14941, v); }
20
-
21
- /**
22
- * The vector's Y component. Also accessible by using the index position `[1]`.
23
- */
24
- get y(): number { return _get(this, 14952) as number; }
25
- set y(v: number) { _set(this, 14952, v); }
26
-
27
- constructor();
28
- constructor(from: Vector2);
29
- constructor(from: Vector2i);
30
- constructor(x: number, y: number);
31
- constructor(...args: any[]) { super(5, ...args); }
32
-
33
- /**
34
- * Returns this vector's angle with respect to the positive X axis, or `(1, 0)` vector, in radians.
35
- * For example, `Vector2.RIGHT.angle()` will return zero, `Vector2.DOWN.angle()` will return `PI / 2` (a quarter turn, or 90 degrees), and `Vector2(1, -1).angle()` will return `-PI / 4` (a negative eighth turn, or -45 degrees).
36
- * This is equivalent to calling {@link atan2} with {@link y} and {@link x}.
37
- * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle.png)
38
- */
39
- angle(): number { return _C(this, 1448) as number; }
40
-
41
- /**
42
- * Returns the signed angle to the given vector, in radians. The result ranges from `-PI` to `PI` (inclusive).
43
- * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to.png)
44
- */
45
- angleTo(to: Vector2): number { return _C(this, 1453, to) as number; }
46
-
47
- /**
48
- * Returns the signed angle between the X axis and the line from this vector to point `to`, in radians. The result ranges from `-PI` to `PI` (inclusive).
49
- * `a.angle_to_point(b)` is equivalent to `(b - a).angle()`. See also {@link angle}.
50
- * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to_point.png)
51
- */
52
- angleToPoint(to: Vector2): number { return _C(this, 1454, to) as number; }
53
-
54
- /**
55
- * Returns the normalized vector pointing from this vector to `to`.
56
- * `a.direction_to(b)` is equivalent to `(b - a).normalized()`. See also {@link normalized}.
57
- */
58
- directionTo(to: Vector2): Vector2 { return _C(this, 2792, to) as Vector2; }
59
-
60
- /**
61
- * Returns the [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
62
- */
63
- distanceTo(to: Vector2): number { return _C(this, 2850, to) as number; }
64
-
65
- /**
66
- * Returns the squared [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
67
- * This method runs faster than {@link distanceTo}, so prefer it if you need to compare vectors or need the squared distance for some formula.
68
- */
69
- distanceSquaredTo(to: Vector2): number { return _C(this, 2849, to) as number; }
70
-
71
- /**
72
- * Returns the length (magnitude) of this vector.
73
- */
74
- length(): number { return _C(this, 8546) as number; }
75
-
76
- /**
77
- * Returns the squared length (squared magnitude) of this vector.
78
- * This method runs faster than {@link length}, so prefer it if you need to compare vectors or need the squared distance for some formula.
79
- */
80
- lengthSquared(): number { return _C(this, 8547) as number; }
81
-
82
- /**
83
- * Returns the vector with a maximum length by limiting its length to `length`. If the vector is non-finite, the result is undefined.
84
- */
85
- limitLength(length?: number /* = 1.0 */): Vector2 { return _C(this, 8615, length) as Vector2; }
86
-
87
- /**
88
- * Returns the result of scaling the vector to unit length. Equivalent to `v / v.length()`. Returns `(0, 0)` if `v.length() == 0`. See also {@link isNormalized}.
89
- * **Note:** This function may return incorrect values if the input vector length is near zero.
90
- */
91
- normalized(): Vector2 { return _C(this, 9103) as Vector2; }
92
-
93
- /**
94
- * Returns `true` if the vector is normalized, i.e. its length is approximately equal to 1.
95
- */
96
- isNormalized(): boolean { return _C(this, 8138) as boolean; }
97
-
98
- /**
99
- * Returns `true` if this vector and `to` are approximately equal, by running {@link isEqualApprox} on each component.
100
- */
101
- isEqualApprox(to: Vector2): boolean { return _C(this, 7938, to) as boolean; }
102
-
103
- /**
104
- * Returns `true` if this vector's values are approximately zero, by running {@link isZeroApprox} on each component.
105
- * This method is faster than using {@link isEqualApprox} with one value as a zero vector.
106
- */
107
- isZeroApprox(): boolean { return _C(this, 8459) as boolean; }
108
-
109
- /**
110
- * Returns `true` if this vector is finite, by calling {@link isFinite} on each component.
111
- */
112
- isFinite(): boolean { return _C(this, 7951) as boolean; }
113
-
114
- /**
115
- * Returns a vector composed of the {@link fposmod} of this vector's components and `mod`.
116
- */
117
- posmod(mod: number): Vector2 { return _C(this, 9518, mod) as Vector2; }
118
-
119
- /**
120
- * Returns a vector composed of the {@link fposmod} of this vector's components and `modv`'s components.
121
- */
122
- posmodv(modv: Vector2): Vector2 { return _C(this, 9519, modv) as Vector2; }
123
-
124
- /**
125
- * Returns a new vector resulting from projecting this vector onto the given vector `b`. The resulting new vector is parallel to `b`. See also {@link slide}.
126
- * **Note:** If the vector `b` is a zero vector, the components of the resulting new vector will be `NAN`.
127
- */
128
- project(b: Vector2): Vector2 { return _C(this, 9589, b) as Vector2; }
129
-
130
- /**
131
- * Returns the result of the linear interpolation between this vector and `to` by amount `weight`. `weight` is on the range of `0.0` to `1.0`, representing the amount of interpolation.
132
- */
133
- lerp(to: Vector2, weight: number): Vector2 { return _C(this, 8548, to, weight) as Vector2; }
134
-
135
- /**
136
- * Returns the result of spherical linear interpolation between this vector and `to`, by amount `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
137
- * This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like {@link lerp}.
138
- */
139
- slerp(to: Vector2, weight: number): Vector2 { return _C(this, 13656, to, weight) as Vector2; }
140
-
141
- /**
142
- * Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
143
- */
144
- cubicInterpolate(b: Vector2, preA: Vector2, postB: Vector2, weight: number): Vector2 { return _C(this, 2590, b, preA, postB, weight) as Vector2; }
145
-
146
- /**
147
- * Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
148
- * It can perform smoother interpolation than {@link cubicInterpolate} by the time values.
149
- */
150
- cubicInterpolateInTime(b: Vector2, preA: Vector2, postB: Vector2, weight: number, bT: number, preAT: number, postBT: number): Vector2 { return _C(this, 2593, b, preA, postB, weight, bT, preAT, postBT) as Vector2; }
151
-
152
- /**
153
- * Returns the point at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
154
- */
155
- bezierInterpolate(control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _C(this, 1757, control1, control2, end, t) as Vector2; }
156
-
157
- /**
158
- * Returns the derivative at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
159
- */
160
- bezierDerivative(control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _C(this, 1756, control1, control2, end, t) as Vector2; }
161
-
162
- /**
163
- * Returns the axis of the vector's highest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_X}.
164
- */
165
- maxAxisIndex(): number { return _C(this, 8806) as number; }
166
-
167
- /**
168
- * Returns the axis of the vector's lowest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_Y}.
169
- */
170
- minAxisIndex(): number { return _C(this, 8911) as number; }
171
-
172
- /**
173
- * Returns a new vector moved toward `to` by the fixed `delta` amount. Will not go past the final value.
174
- */
175
- moveToward(to: Vector2, delta: number): Vector2 { return _C(this, 9004, to, delta) as Vector2; }
176
-
177
- /**
178
- * Returns the result of rotating this vector by `angle` (in radians). See also {@link degToRad}.
179
- */
180
- rotated(angle: number): Vector2 { return _C(this, 10144, angle) as Vector2; }
181
-
182
- /**
183
- * Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length.
184
- */
185
- orthogonal(): Vector2 { return _C(this, 9228) as Vector2; }
186
-
187
- /**
188
- * Returns a new vector with all components rounded down (towards negative infinity).
189
- */
190
- floor(): Vector2 { return _C(this, 3335) as Vector2; }
191
-
192
- /**
193
- * Returns a new vector with all components rounded up (towards positive infinity).
194
- */
195
- ceil(): Vector2 { return _C(this, 2156) as Vector2; }
196
-
197
- /**
198
- * Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
199
- */
200
- round(): Vector2 { return _C(this, 10166) as Vector2; }
201
-
202
- /**
203
- * Returns this vector's aspect ratio, which is {@link x} divided by {@link y}.
204
- */
205
- aspect(): number { return _C(this, 1602) as number; }
206
-
207
- /**
208
- * Returns the dot product of this vector and `with`. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
209
- * The dot product will be `0` for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
210
- * When using unit (normalized) vectors, the result will always be between `-1.0` (180 degree angle) when the vectors are facing opposite directions, and `1.0` (0 degree angle) when the vectors are aligned.
211
- * **Note:** `a.dot(b)` is equivalent to `b.dot(a)`.
212
- */
213
- dot(_with: Vector2): number { return _C(this, 2871, _with) as number; }
214
-
215
- /**
216
- * Returns a new vector resulting from sliding this vector along a line with normal `n`. The resulting new vector is perpendicular to `n`, and is equivalent to this vector minus its projection on `n`. See also {@link project}.
217
- * **Note:** The vector `n` must be normalized. See also {@link normalized}.
218
- */
219
- slide(n: Vector2): Vector2 { return _C(this, 13659, n) as Vector2; }
220
-
221
- /**
222
- * Returns the vector "bounced off" from a line defined by the given normal `n` perpendicular to the line.
223
- * **Note:** {@link bounce} performs the operation that most engines and frameworks call {@link code skip-lint}reflect()[/code].
224
- */
225
- bounce(n: Vector2): Vector2 { return _C(this, 1902, n) as Vector2; }
226
-
227
- /**
228
- * Returns the result of reflecting the vector from a line defined by the given direction vector `line`.
229
- * **Note:** {@link reflect} differs from what other engines and frameworks call {@link code skip-lint}reflect()[/code]. In other engines, {@link code skip-lint}reflect()[/code] takes a normal direction which is a direction perpendicular to the line. In Godot, you specify the direction of the line directly. See also {@link bounce} which does what most engines call {@link code skip-lint}reflect()[/code].
230
- */
231
- reflect(line: Vector2): Vector2 { return _C(this, 9776, line) as Vector2; }
232
-
233
- /**
234
- * Returns the 2D analog of the cross product for this vector and `with`.
235
- * This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area. If the two vectors are parallel this returns zero, making it useful for testing if two vectors are parallel.
236
- * **Note:** Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog.
237
- */
238
- cross(_with: Vector2): number { return _C(this, 2586, _with) as number; }
239
-
240
- /**
241
- * Returns a new vector with all components in absolute values (i.e. positive).
242
- */
243
- abs(): Vector2 { return _C(this, 1053) as Vector2; }
244
-
245
- /**
246
- * Returns a new vector with each component set to `1.0` if it's positive, `-1.0` if it's negative, and `0.0` if it's zero. The result is identical to calling {@link sign} on each component.
247
- */
248
- sign(): Vector2 { return _C(this, 13597) as Vector2; }
249
-
250
- /**
251
- * Returns a new vector with all components clamped between the components of `min` and `max`, by running {@link clamp} on each component.
252
- */
253
- clamp(min: Vector2, max: Vector2): Vector2 { return _C(this, 2202, min, max) as Vector2; }
254
-
255
- /**
256
- * Returns a new vector with all components clamped between `min` and `max`, by running {@link clamp} on each component.
257
- */
258
- clampf(min: number, max: number): Vector2 { return _C(this, 2205, min, max) as Vector2; }
259
-
260
- /**
261
- * Returns a new vector with each component snapped to the nearest multiple of the corresponding component in `step`. This can also be used to round the components to an arbitrary number of decimals.
262
- */
263
- snapped(step: Vector2): Vector2 { return _C(this, 13674, step) as Vector2; }
264
-
265
- /**
266
- * Returns a new vector with each component snapped to the nearest multiple of `step`. This can also be used to round the components to an arbitrary number of decimals.
267
- */
268
- snappedf(step: number): Vector2 { return _C(this, 13675, step) as Vector2; }
269
-
270
- /**
271
- * Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with.x), minf(y, with.y))`.
272
- */
273
- min(_with: Vector2): Vector2 { return _C(this, 8910, _with) as Vector2; }
274
-
275
- /**
276
- * Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with), minf(y, with))`.
277
- */
278
- minf(_with: number): Vector2 { return _C(this, 8921, _with) as Vector2; }
279
-
280
- /**
281
- * Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with.x), maxf(y, with.y))`.
282
- */
283
- max(_with: Vector2): Vector2 { return _C(this, 8804, _with) as Vector2; }
284
-
285
- /**
286
- * Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with), maxf(y, with))`.
287
- */
288
- maxf(_with: number): Vector2 { return _C(this, 8839, _with) as Vector2; }
289
-
290
- equals(other: Variant | Vector2): boolean { return _C(this, -1, other) as boolean; }
291
-
292
- notEquals(other: Variant | Vector2): boolean { return _C(this, -2, other) as boolean; }
293
-
294
- /**
295
- * Returns the negative value of the {@link Vector2}. This is the same as writing `Vector2(-v.x, -v.y)`. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
296
- */
297
- neg(): Vector2 { return _C(this, -11, undefined) as Vector2; }
298
-
299
- /**
300
- * Returns the same value as if the `+` was not there. Unary `+` does nothing, but sometimes it can make your code more readable.
301
- */
302
- pos(): Vector2 { return _C(this, -12, undefined) as Vector2; }
303
-
304
- not(): boolean { return _C(this, -24, undefined) as boolean; }
305
-
306
- /**
307
- * Multiplies each component of the {@link Vector2} by the given {@link int}.
308
- */
309
- mul(other: number | Vector2 | Transform2D): Vector2 { return _C(this, -9, other) as Vector2; }
310
-
311
- /**
312
- * Divides each component of the {@link Vector2} by the given {@link int}.
313
- */
314
- div(other: number | Vector2): Vector2 { return _C(this, -10, other) as Vector2; }
315
-
316
- /**
317
- * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
318
- * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
319
- */
320
- lessThan(other: Vector2): boolean { return _C(this, -3, other) as boolean; }
321
-
322
- /**
323
- * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
324
- * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
325
- */
326
- lessThanOrEqual(other: Vector2): boolean { return _C(this, -4, other) as boolean; }
327
-
328
- /**
329
- * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
330
- * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
331
- */
332
- greaterThan(other: Vector2): boolean { return _C(this, -5, other) as boolean; }
333
-
334
- /**
335
- * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
336
- * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
337
- */
338
- greaterThanOrEqual(other: Vector2): boolean { return _C(this, -6, other) as boolean; }
339
-
340
- /**
341
- * Adds each component of the {@link Vector2} by the components of the given {@link Vector2}.
342
- *
343
- * ```text
344
- *
345
- * print(Vector2(10, 20) + Vector2(3, 4)) # Prints (13.0, 24.0)
346
- *
347
- * ```
348
- */
349
- add(other: Vector2): Vector2 { return _C(this, -7, other) as Vector2; }
350
-
351
- /**
352
- * Subtracts each component of the {@link Vector2} by the components of the given {@link Vector2}.
353
- *
354
- * ```text
355
- *
356
- * print(Vector2(10, 20) - Vector2(3, 4)) # Prints (7.0, 16.0)
357
- *
358
- * ```
359
- */
360
- sub(other: Vector2): Vector2 { return _C(this, -8, other) as Vector2; }
361
-
362
- contains(other: GodotDictionary | GodotArray | PackedVector2Array): boolean { return _C(this, -25, other) as boolean; }
363
-
364
- static readonly name = _R(5, Vector2);
365
- }
14
+ export type Vector2 = [x: number, y: number];
15
+
16
+ /**
17
+ * Returns this vector's angle with respect to the positive X axis, or `(1, 0)` vector, in radians.
18
+ * For example, `Vector2.RIGHT.angle()` will return zero, `Vector2.DOWN.angle()` will return `PI / 2` (a quarter turn, or 90 degrees), and `Vector2(1, -1).angle()` will return `-PI / 4` (a negative eighth turn, or -45 degrees).
19
+ * This is equivalent to calling {@link atan2} with {@link y} and {@link x}.
20
+ * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle.png)
21
+ */
22
+ export function angle(self: Vector2): number { return _V(5, 1448, self) as number; }
23
+
24
+ /**
25
+ * Returns the signed angle to the given vector, in radians. The result ranges from `-PI` to `PI` (inclusive).
26
+ * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to.png)
27
+ */
28
+ export function angleTo(self: Vector2, to: Vector2): number { return _V(5, 1453, self, to) as number; }
29
+
30
+ /**
31
+ * Returns the signed angle between the X axis and the line from this vector to point `to`, in radians. The result ranges from `-PI` to `PI` (inclusive).
32
+ * `a.angle_to_point(b)` is equivalent to `(b - a).angle()`. See also {@link angle}.
33
+ * [Illustration of the returned angle.](https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to_point.png)
34
+ */
35
+ export function angleToPoint(self: Vector2, to: Vector2): number { return _V(5, 1454, self, to) as number; }
36
+
37
+ /**
38
+ * Returns the normalized vector pointing from this vector to `to`.
39
+ * `a.direction_to(b)` is equivalent to `(b - a).normalized()`. See also {@link normalized}.
40
+ */
41
+ export function directionTo(self: Vector2, to: Vector2): Vector2 { return _V(5, 2792, self, to) as Vector2; }
42
+
43
+ /**
44
+ * Returns the [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
45
+ */
46
+ export function distanceTo(self: Vector2, to: Vector2): number { return _V(5, 2850, self, to) as number; }
47
+
48
+ /**
49
+ * Returns the squared [Euclidean distance](https://en.wikipedia.org/wiki/Euclidean_distance) between this vector and `to`.
50
+ * This method runs faster than {@link distanceTo}, so prefer it if you need to compare vectors or need the squared distance for some formula.
51
+ */
52
+ export function distanceSquaredTo(self: Vector2, to: Vector2): number { return _V(5, 2849, self, to) as number; }
53
+
54
+ /**
55
+ * Returns the length (magnitude) of this vector.
56
+ */
57
+ export function length(self: Vector2): number { return _V(5, 8546, self) as number; }
58
+
59
+ /**
60
+ * Returns the squared length (squared magnitude) of this vector.
61
+ * This method runs faster than {@link length}, so prefer it if you need to compare vectors or need the squared distance for some formula.
62
+ */
63
+ export function lengthSquared(self: Vector2): number { return _V(5, 8547, self) as number; }
64
+
65
+ /**
66
+ * Returns the vector with a maximum length by limiting its length to `length`. If the vector is non-finite, the result is undefined.
67
+ */
68
+ export function limitLength(self: Vector2, length?: number /* = 1.0 */): Vector2 { return _V(5, 8615, self, length) as Vector2; }
69
+
70
+ /**
71
+ * Returns the result of scaling the vector to unit length. Equivalent to `v / v.length()`. Returns `(0, 0)` if `v.length() == 0`. See also {@link isNormalized}.
72
+ * **Note:** This function may return incorrect values if the input vector length is near zero.
73
+ */
74
+ export function normalized(self: Vector2): Vector2 { return _V(5, 9103, self) as Vector2; }
75
+
76
+ /**
77
+ * Returns `true` if the vector is normalized, i.e. its length is approximately equal to 1.
78
+ */
79
+ export function isNormalized(self: Vector2): boolean { return _V(5, 8138, self) as boolean; }
80
+
81
+ /**
82
+ * Returns `true` if this vector and `to` are approximately equal, by running {@link isEqualApprox} on each component.
83
+ */
84
+ export function isEqualApprox(self: Vector2, to: Vector2): boolean { return _V(5, 7938, self, to) as boolean; }
85
+
86
+ /**
87
+ * Returns `true` if this vector's values are approximately zero, by running {@link isZeroApprox} on each component.
88
+ * This method is faster than using {@link isEqualApprox} with one value as a zero vector.
89
+ */
90
+ export function isZeroApprox(self: Vector2): boolean { return _V(5, 8459, self) as boolean; }
91
+
92
+ /**
93
+ * Returns `true` if this vector is finite, by calling {@link isFinite} on each component.
94
+ */
95
+ export function isFinite(self: Vector2): boolean { return _V(5, 7951, self) as boolean; }
96
+
97
+ /**
98
+ * Returns a vector composed of the {@link fposmod} of this vector's components and `mod`.
99
+ */
100
+ export function posmod(self: Vector2, mod: number): Vector2 { return _V(5, 9518, self, mod) as Vector2; }
101
+
102
+ /**
103
+ * Returns a vector composed of the {@link fposmod} of this vector's components and `modv`'s components.
104
+ */
105
+ export function posmodv(self: Vector2, modv: Vector2): Vector2 { return _V(5, 9519, self, modv) as Vector2; }
106
+
107
+ /**
108
+ * Returns a new vector resulting from projecting this vector onto the given vector `b`. The resulting new vector is parallel to `b`. See also {@link slide}.
109
+ * **Note:** If the vector `b` is a zero vector, the components of the resulting new vector will be `NAN`.
110
+ */
111
+ export function project(self: Vector2, b: Vector2): Vector2 { return _V(5, 9589, self, b) as Vector2; }
112
+
113
+ /**
114
+ * Returns the result of the linear interpolation between this vector and `to` by amount `weight`. `weight` is on the range of `0.0` to `1.0`, representing the amount of interpolation.
115
+ */
116
+ export function lerp(self: Vector2, to: Vector2, weight: number): Vector2 { return _V(5, 8548, self, to, weight) as Vector2; }
117
+
118
+ /**
119
+ * Returns the result of spherical linear interpolation between this vector and `to`, by amount `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
120
+ * This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like {@link lerp}.
121
+ */
122
+ export function slerp(self: Vector2, to: Vector2, weight: number): Vector2 { return _V(5, 13656, self, to, weight) as Vector2; }
123
+
124
+ /**
125
+ * Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
126
+ */
127
+ export function cubicInterpolate(self: Vector2, b: Vector2, preA: Vector2, postB: Vector2, weight: number): Vector2 { return _V(5, 2590, self, b, preA, postB, weight) as Vector2; }
128
+
129
+ /**
130
+ * Performs a cubic interpolation between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `weight`. `weight` is on the range of 0.0 to 1.0, representing the amount of interpolation.
131
+ * It can perform smoother interpolation than {@link cubicInterpolate} by the time values.
132
+ */
133
+ export function cubicInterpolateInTime(self: Vector2, b: Vector2, preA: Vector2, postB: Vector2, weight: number, bT: number, preAT: number, postBT: number): Vector2 { return _V(5, 2593, self, b, preA, postB, weight, bT, preAT, postBT) as Vector2; }
134
+
135
+ /**
136
+ * Returns the point at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
137
+ */
138
+ export function bezierInterpolate(self: Vector2, control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _V(5, 1757, self, control1, control2, end, t) as Vector2; }
139
+
140
+ /**
141
+ * Returns the derivative at the given `t` on the [Bézier curve](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) defined by this vector and the given `control1`, `control2`, and `end` points.
142
+ */
143
+ export function bezierDerivative(self: Vector2, control1: Vector2, control2: Vector2, end: Vector2, t: number): Vector2 { return _V(5, 1756, self, control1, control2, end, t) as Vector2; }
144
+
145
+ /**
146
+ * Returns the axis of the vector's highest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_X}.
147
+ */
148
+ export function maxAxisIndex(self: Vector2): number { return _V(5, 8806, self) as number; }
149
+
150
+ /**
151
+ * Returns the axis of the vector's lowest value. See `AXIS_*` constants. If all components are equal, this method returns {@link AXIS_Y}.
152
+ */
153
+ export function minAxisIndex(self: Vector2): number { return _V(5, 8911, self) as number; }
154
+
155
+ /**
156
+ * Returns a new vector moved toward `to` by the fixed `delta` amount. Will not go past the final value.
157
+ */
158
+ export function moveToward(self: Vector2, to: Vector2, delta: number): Vector2 { return _V(5, 9004, self, to, delta) as Vector2; }
159
+
160
+ /**
161
+ * Returns the result of rotating this vector by `angle` (in radians). See also {@link degToRad}.
162
+ */
163
+ export function rotated(self: Vector2, angle: number): Vector2 { return _V(5, 10144, self, angle) as Vector2; }
164
+
165
+ /**
166
+ * Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length.
167
+ */
168
+ export function orthogonal(self: Vector2): Vector2 { return _V(5, 9228, self) as Vector2; }
169
+
170
+ /**
171
+ * Returns a new vector with all components rounded down (towards negative infinity).
172
+ */
173
+ export function floor(self: Vector2): Vector2 { return _V(5, 3335, self) as Vector2; }
174
+
175
+ /**
176
+ * Returns a new vector with all components rounded up (towards positive infinity).
177
+ */
178
+ export function ceil(self: Vector2): Vector2 { return _V(5, 2156, self) as Vector2; }
179
+
180
+ /**
181
+ * Returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
182
+ */
183
+ export function round(self: Vector2): Vector2 { return _V(5, 10166, self) as Vector2; }
184
+
185
+ /**
186
+ * Returns this vector's aspect ratio, which is {@link x} divided by {@link y}.
187
+ */
188
+ export function aspect(self: Vector2): number { return _V(5, 1602, self) as number; }
189
+
190
+ /**
191
+ * Returns the dot product of this vector and `with`. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
192
+ * The dot product will be `0` for a right angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
193
+ * When using unit (normalized) vectors, the result will always be between `-1.0` (180 degree angle) when the vectors are facing opposite directions, and `1.0` (0 degree angle) when the vectors are aligned.
194
+ * **Note:** `a.dot(b)` is equivalent to `b.dot(a)`.
195
+ */
196
+ export function dot(self: Vector2, _with: Vector2): number { return _V(5, 2871, self, _with) as number; }
197
+
198
+ /**
199
+ * Returns a new vector resulting from sliding this vector along a line with normal `n`. The resulting new vector is perpendicular to `n`, and is equivalent to this vector minus its projection on `n`. See also {@link project}.
200
+ * **Note:** The vector `n` must be normalized. See also {@link normalized}.
201
+ */
202
+ export function slide(self: Vector2, n: Vector2): Vector2 { return _V(5, 13659, self, n) as Vector2; }
203
+
204
+ /**
205
+ * Returns the vector "bounced off" from a line defined by the given normal `n` perpendicular to the line.
206
+ * **Note:** {@link bounce} performs the operation that most engines and frameworks call {@link code skip-lint}reflect()[/code].
207
+ */
208
+ export function bounce(self: Vector2, n: Vector2): Vector2 { return _V(5, 1902, self, n) as Vector2; }
209
+
210
+ /**
211
+ * Returns the result of reflecting the vector from a line defined by the given direction vector `line`.
212
+ * **Note:** {@link reflect} differs from what other engines and frameworks call {@link code skip-lint}reflect()[/code]. In other engines, {@link code skip-lint}reflect()[/code] takes a normal direction which is a direction perpendicular to the line. In Godot, you specify the direction of the line directly. See also {@link bounce} which does what most engines call {@link code skip-lint}reflect()[/code].
213
+ */
214
+ export function reflect(self: Vector2, line: Vector2): Vector2 { return _V(5, 9776, self, line) as Vector2; }
215
+
216
+ /**
217
+ * Returns the 2D analog of the cross product for this vector and `with`.
218
+ * This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area. If the two vectors are parallel this returns zero, making it useful for testing if two vectors are parallel.
219
+ * **Note:** Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog.
220
+ */
221
+ export function cross(self: Vector2, _with: Vector2): number { return _V(5, 2586, self, _with) as number; }
222
+
223
+ /**
224
+ * Returns a new vector with all components in absolute values (i.e. positive).
225
+ */
226
+ export function abs(self: Vector2): Vector2 { return _V(5, 1053, self) as Vector2; }
227
+
228
+ /**
229
+ * Returns a new vector with each component set to `1.0` if it's positive, `-1.0` if it's negative, and `0.0` if it's zero. The result is identical to calling {@link sign} on each component.
230
+ */
231
+ export function sign(self: Vector2): Vector2 { return _V(5, 13597, self) as Vector2; }
232
+
233
+ /**
234
+ * Returns a new vector with all components clamped between the components of `min` and `max`, by running {@link clamp} on each component.
235
+ */
236
+ export function clamp(self: Vector2, min: Vector2, max: Vector2): Vector2 { return _V(5, 2202, self, min, max) as Vector2; }
237
+
238
+ /**
239
+ * Returns a new vector with all components clamped between `min` and `max`, by running {@link clamp} on each component.
240
+ */
241
+ export function clampf(self: Vector2, min: number, max: number): Vector2 { return _V(5, 2205, self, min, max) as Vector2; }
242
+
243
+ /**
244
+ * Returns a new vector with each component snapped to the nearest multiple of the corresponding component in `step`. This can also be used to round the components to an arbitrary number of decimals.
245
+ */
246
+ export function snapped(self: Vector2, step: Vector2): Vector2 { return _V(5, 13674, self, step) as Vector2; }
247
+
248
+ /**
249
+ * Returns a new vector with each component snapped to the nearest multiple of `step`. This can also be used to round the components to an arbitrary number of decimals.
250
+ */
251
+ export function snappedf(self: Vector2, step: number): Vector2 { return _V(5, 13675, self, step) as Vector2; }
252
+
253
+ /**
254
+ * Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with.x), minf(y, with.y))`.
255
+ */
256
+ export function min(self: Vector2, _with: Vector2): Vector2 { return _V(5, 8910, self, _with) as Vector2; }
257
+
258
+ /**
259
+ * Returns the component-wise minimum of this and `with`, equivalent to `Vector2(minf(x, with), minf(y, with))`.
260
+ */
261
+ export function minf(self: Vector2, _with: number): Vector2 { return _V(5, 8921, self, _with) as Vector2; }
262
+
263
+ /**
264
+ * Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with.x), maxf(y, with.y))`.
265
+ */
266
+ export function max(self: Vector2, _with: Vector2): Vector2 { return _V(5, 8804, self, _with) as Vector2; }
267
+
268
+ /**
269
+ * Returns the component-wise maximum of this and `with`, equivalent to `Vector2(maxf(x, with), maxf(y, with))`.
270
+ */
271
+ export function maxf(self: Vector2, _with: number): Vector2 { return _V(5, 8839, self, _with) as Vector2; }
272
+
273
+ /**
274
+ * Creates a {@link Vector2} rotated to the given `angle` in radians. This is equivalent to doing `Vector2(cos(angle), sin(angle))` or `Vector2.RIGHT.rotated(angle)`.
275
+ *
276
+ * ```text
277
+ *
278
+ * print(Vector2.from_angle(0)) # Prints (1.0, 0.0)
279
+ * print(Vector2(1, 0).angle()) # Prints 0.0, which is the angle used above.
280
+ * print(Vector2.from_angle(PI / 2)) # Prints (0.0, 1.0)
281
+ *
282
+ * ```
283
+ *
284
+ * **Note:** The length of the returned {@link Vector2} is *approximately* `1.0`, but is is not guaranteed to be exactly `1.0` due to floating-point precision issues. Call {@link normalized} on the returned {@link Vector2} if you require a unit vector.
285
+ */
286
+ export function fromAngle(angle: number): Vector2 { return _V(5, 3592, undefined, angle) as Vector2; }
287
+
288
+ export function equals(a: Vector2, b: Variant | Vector2): boolean { return _V(5, -1, a, b) as boolean; }
289
+
290
+ export function notEquals(a: Vector2, b: Variant | Vector2): boolean { return _V(5, -2, a, b) as boolean; }
291
+
292
+ /**
293
+ * Returns the negative value of the {@link Vector2}. This is the same as writing `Vector2(-v.x, -v.y)`. This operation flips the direction of the vector while keeping the same magnitude. With floats, the number zero can be either positive or negative.
294
+ */
295
+ export function neg(self: Vector2): Vector2 { return _V(5, -11, self, undefined) as Vector2; }
296
+
297
+ /**
298
+ * Returns the same value as if the `+` was not there. Unary `+` does nothing, but sometimes it can make your code more readable.
299
+ */
300
+ export function pos(self: Vector2): Vector2 { return _V(5, -12, self, undefined) as Vector2; }
301
+
302
+ export function not(self: Vector2): boolean { return _V(5, -24, self, undefined) as boolean; }
303
+
304
+ /**
305
+ * Multiplies each component of the {@link Vector2} by the given {@link int}.
306
+ */
307
+ export function mul(a: Vector2, b: number | Vector2 | Transform2D): Vector2 { return _V(5, -9, a, b) as Vector2; }
308
+
309
+ /**
310
+ * Divides each component of the {@link Vector2} by the given {@link int}.
311
+ */
312
+ export function div(a: Vector2, b: number | Vector2): Vector2 { return _V(5, -10, a, b) as Vector2; }
313
+
314
+ /**
315
+ * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
316
+ * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
317
+ */
318
+ export function lessThan(a: Vector2, b: Vector2): boolean { return _V(5, -3, a, b) as boolean; }
319
+
320
+ /**
321
+ * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is less than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
322
+ * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
323
+ */
324
+ export function lessThanOrEqual(a: Vector2, b: Vector2): boolean { return _V(5, -4, a, b) as boolean; }
325
+
326
+ /**
327
+ * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
328
+ * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
329
+ */
330
+ export function greaterThan(a: Vector2, b: Vector2): boolean { return _V(5, -5, a, b) as boolean; }
331
+
332
+ /**
333
+ * Compares two {@link Vector2} vectors by first checking if the X value of the left vector is greater than or equal to the X value of the `right` vector. If the X values are exactly equal, then it repeats this check with the Y values of the two vectors. This operator is useful for sorting vectors.
334
+ * **Note:** Vectors with `NAN` elements don't behave the same as other vectors. Therefore, the results from this operator may not be accurate if NaNs are included.
335
+ */
336
+ export function greaterThanOrEqual(a: Vector2, b: Vector2): boolean { return _V(5, -6, a, b) as boolean; }
337
+
338
+ /**
339
+ * Adds each component of the {@link Vector2} by the components of the given {@link Vector2}.
340
+ *
341
+ * ```text
342
+ *
343
+ * print(Vector2(10, 20) + Vector2(3, 4)) # Prints (13.0, 24.0)
344
+ *
345
+ * ```
346
+ */
347
+ export function add(a: Vector2, b: Vector2): Vector2 { return _V(5, -7, a, b) as Vector2; }
348
+
349
+ /**
350
+ * Subtracts each component of the {@link Vector2} by the components of the given {@link Vector2}.
351
+ *
352
+ * ```text
353
+ *
354
+ * print(Vector2(10, 20) - Vector2(3, 4)) # Prints (7.0, 16.0)
355
+ *
356
+ * ```
357
+ */
358
+ export function sub(a: Vector2, b: Vector2): Vector2 { return _V(5, -8, a, b) as Vector2; }
359
+
360
+ export function contains(a: Vector2, b: GodotDictionary | GodotArray | PackedVector2Array): boolean { return _V(5, -25, a, b) as boolean; }
361
+
362
+ /**
363
+ * Constructs a default-initialized {@link Vector2} with all components set to `0`.
364
+ */
365
+ export function create(): Vector2 { return _V(5, -4096, 0) as Vector2; }
366
+
367
+ /**
368
+ * Constructs a {@link Vector2} as a copy of the given {@link Vector2}.
369
+ */
370
+ export function fromVector2(from: Vector2): Vector2 { return _V(5, -4096, 1, from) as Vector2; }
371
+
372
+ /**
373
+ * Constructs a new {@link Vector2} from {@link Vector2i}.
374
+ */
375
+ export function fromVector2i(from: Vector2i): Vector2 { return _V(5, -4096, 2, from) as Vector2; }
376
+
377
+ /**
378
+ * Constructs a new {@link Vector2} from the given `x` and `y`.
379
+ */
380
+ export function fromXY(x: number, y: number): Vector2 { return _V(5, -4096, 3, x, y) as Vector2; }
381
+