/
Transform2D.hx
374 lines (312 loc) · 12.4 KB
/
Transform2D.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
2×3 matrix (2 rows, 3 columns) used for 2D linear transformations.
It can represent transformations such as translation, rotation, or scaling.
It consists of a three `godot.Vector2` values: x, y, and the origin.
For more information, read this documentation article:
https://docs.godotengine.org/en/3.4/tutorials/math/matrices_and_transforms.html
**/
#if doc_gen
@:struct
@:libType
@:csNative
@:native("Godot.Transform2D")
@:autoBuild(godot.Godot.buildUserClass())
extern class Transform2D extends cs.system.ValueType implements cs.system.IEquatable_1<godot.Transform2D> {
#else
@:forward
@:forwardStatics
extern abstract Transform2D(Transform2D_) from Transform2D_ to Transform2D_ {
#end
#if !doc_gen
/**
Constructs a transformation matrix from 3 vectors (matrix columns).
@param xAxis The X vector, or column index 0.
@param yAxis The Y vector, or column index 1.
@param originPos The origin vector, or column index 2.
**/
public overload inline function new(xAxis:godot.Vector2, yAxis:godot.Vector2, originPos:godot.Vector2) {
this = new Transform2D_(xAxis, yAxis, originPos);
}
#end
#if !doc_gen
/**
Constructs a transformation matrix from the given components.
Arguments are named such that xy is equal to calling x.y
@param xx The X component of the X column vector, accessed via `t.x.x` or `[0][0]`
@param xy The Y component of the X column vector, accessed via `t.x.y` or `[0][1]`
@param yx The X component of the Y column vector, accessed via `t.y.x` or `[1][0]`
@param yy The Y component of the Y column vector, accessed via `t.y.y` or `[1][1]`
@param ox The X component of the origin vector, accessed via `t.origin.x` or `[2][0]`
@param oy The Y component of the origin vector, accessed via `t.origin.y` or `[2][1]`
**/
public overload inline function new(xx:Single, xy:Single, yx:Single, yy:Single, ox:Single, oy:Single) {
this = new Transform2D_(xx, xy, yx, yy, ox, oy);
}
#end
#if !doc_gen
/**
Constructs a transformation matrix from a `rotation` value and
`origin` vector.
@param rotation The rotation of the new transform, in radians.
@param origin The origin vector, or column index 2.
**/
public overload inline function new(rotation:Single, origin:godot.Vector2) {
this = new Transform2D_(rotation, origin);
}
#end
/**
Operator overload for `godot.Transform2D` * `godot.Transform2D`.
**/
@:op(A * B) static inline overload function op_Multiply(left:godot.Transform2D, right:godot.Transform2D):godot.Transform2D {
return cs.Syntax.code("{0} * {1}", left, right);
}
/**
Operator overload for `godot.Transform2D` * `godot.Vector2`.
**/
@:op(A * B) static inline overload function op_Multiply(transform:godot.Transform2D, vector:godot.Vector2):godot.Vector2 {
return cs.Syntax.code("{0} * {1}", transform, vector);
}
/**
Operator overload for `godot.Vector2` * `godot.Transform2D`.
**/
@:op(A * B) static inline overload function op_Multiply(vector:godot.Vector2, transform:godot.Transform2D):godot.Vector2 {
return cs.Syntax.code("{0} * {1}", vector, transform);
}
/**
Operator overload for `godot.Transform2D` * `godot.Rect2`.
**/
@:op(A * B) static inline overload function op_Multiply(transform:godot.Transform2D, rect:godot.Rect2):godot.Rect2 {
return cs.Syntax.code("{0} * {1}", transform, rect);
}
/**
Operator overload for `godot.Rect2` * `godot.Transform2D`.
**/
@:op(A * B) static inline overload function op_Multiply(rect:godot.Rect2, transform:godot.Transform2D):godot.Rect2 {
return cs.Syntax.code("{0} * {1}", rect, transform);
}
/**
Operator overload for `godot.Transform2D` * `cs.NativeArray<godot.Vector2>`.
**/
@:op(A * B) static inline overload function op_Multiply(transform:godot.Transform2D, array:cs.NativeArray<godot.Vector2>):cs.NativeArray<godot.Vector2> {
return cs.Syntax.code("{0} * {1}", transform, array);
}
/**
Operator overload for `cs.NativeArray<godot.Vector2>` * `godot.Transform2D`.
**/
@:op(A * B) static inline overload function op_Multiply(array:cs.NativeArray<godot.Vector2>, transform:godot.Transform2D):cs.NativeArray<godot.Vector2> {
return cs.Syntax.code("{0} * {1}", array, transform);
}
/**
Operator overload for `godot.Transform2D` == `godot.Transform2D`.
**/
@:op(A == B) static inline function op_Equality(left:godot.Transform2D, right:godot.Transform2D):Bool {
return cs.Syntax.code("{0} == {1}", left, right);
}
/**
Operator overload for `godot.Transform2D` != `godot.Transform2D`.
**/
@:op(A != B) static inline function op_Inequality(left:godot.Transform2D, right:godot.Transform2D):Bool {
return cs.Syntax.code("{0} != {1}", left, right);
}
#if !doc_gen
}
@:struct
@:libType
@:csNative
@:native("Godot.Transform2D")
@:autoBuild(godot.Godot.buildUserClass())
extern class Transform2D_ extends cs.system.ValueType implements cs.system.IEquatable_1<godot.Transform2D> {
#end
/**
The transform that will flip something along the Y axis.
Value: Equivalent to `new Transform2D(Vector2.Right, Vector2.Up, Vector2.Zero)`.
**/
@:native("FlipY")
public static var FLIP_Y(default, never):godot.Transform2D;
/**
The transform that will flip something along the X axis.
Value: Equivalent to `new Transform2D(Vector2.Left, Vector2.Down, Vector2.Zero)`.
**/
@:native("FlipX")
public static var FLIP_X(default, never):godot.Transform2D;
/**
The identity transform, with no translation, rotation, or scaling applied.
This is used as a replacement for `Transform2D()` in GDScript.
Do not use `new Transform2D()` with no arguments in C#, because it sets all values to zero.
Value: Equivalent to `new Transform2D(Vector2.Right, Vector2.Down, Vector2.Zero)`.
**/
@:native("Identity")
public static var IDENTITY(default, never):godot.Transform2D;
/**
The scale of this transformation matrix.
Value: Equivalent to the lengths of each column vector, but Y is negative if the determinant is negative.
**/
@:native("Scale")
public var scale:godot.Vector2;
/**
The rotation of this transformation matrix.
Value: Getting is equivalent to calling `godot.Mathf.atan2` with the values of `godot.Transform2D.x`.
**/
@:native("Rotation")
public var rotation:Single;
/**
The origin vector (column 2, the third column). Equivalent to array index `[2]`.
The origin vector represents translation.
**/
@:native("origin")
public var origin:godot.Vector2;
/**
The basis matrix's Y vector (column 1). Equivalent to array index `[1]`.
**/
@:native("y")
public var y:godot.Vector2;
/**
The basis matrix's X vector (column 0). Equivalent to array index `[0]`.
Value:
**/
@:native("x")
public var x:godot.Vector2;
/**
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation, scaling, and translation.
@see `godot.Transform2D.inverse`
@returns The inverse transformation matrix.
**/
@:native("AffineInverse")
public function affineInverse():godot.Transform2D;
/**
Returns a vector transformed (multiplied) by the basis matrix.
This method does not account for translation (the `godot.Transform2D.origin` vector).
@see `godot.Transform2D.basisXformInv`
@param v A vector to transform.
@returns The transformed vector.
**/
@:native("BasisXform")
public function basisXform(v:godot.Vector2):godot.Vector2;
/**
Returns a vector transformed (multiplied) by the inverse basis matrix.
This method does not account for translation (the `godot.Transform2D.origin` vector).
Note: This results in a multiplication by the inverse of the
basis matrix only if it represents a rotation-reflection.
@see `godot.Transform2D.basisXform`
@param v A vector to inversely transform.
@returns The inversely transformed vector.
**/
@:native("BasisXformInv")
public function basisXformInv(v:godot.Vector2):godot.Vector2;
/**
Interpolates this transform to the other `transform` by `weight`.
@param transform The other transform.
@param weight A value on the range of 0.0 to 1.0, representing the amount of interpolation.
@returns The interpolated transform.
**/
@:native("InterpolateWith")
public function interpolateWith(transform:godot.Transform2D, weight:Single):godot.Transform2D;
/**
Returns the inverse of the transform, under the assumption that
the transformation is composed of rotation and translation
(no scaling, use `godot.Transform2D.affineInverse` for transforms with scaling).
@returns The inverse matrix.
**/
@:native("Inverse")
public function inverse():godot.Transform2D;
/**
Returns the transform with the basis orthogonal (90 degrees),
and normalized axis vectors (scale of 1 or -1).
@returns The orthonormalized transform.
**/
@:native("Orthonormalized")
public function orthonormalized():godot.Transform2D;
/**
Rotates the transform by `phi` (in radians), using matrix multiplication.
@param phi The angle to rotate, in radians.
@returns The rotated transformation matrix.
**/
@:native("Rotated")
public function rotated(phi:Single):godot.Transform2D;
/**
Scales the transform by the given scaling factor, using matrix multiplication.
@param scale The scale to introduce.
@returns The scaled transformation matrix.
**/
@:native("Scaled")
public function scaled(scale:godot.Vector2):godot.Transform2D;
/**
Translates the transform by the given `offset`,
relative to the transform's basis vectors.
Unlike `godot.Transform2D.rotated` and `godot.Transform2D.scaled`,
this does not use matrix multiplication.
@param offset The offset to translate by.
@returns The translated matrix.
**/
@:native("Translated")
public function translated(offset:godot.Vector2):godot.Transform2D;
/**
Returns a vector transformed (multiplied) by this transformation matrix.
@see `godot.Transform2D.xformInv`
@param v A vector to transform.
@returns The transformed vector.
**/
@:native("Xform")
public function xform(v:godot.Vector2):godot.Vector2;
/**
Returns a vector transformed (multiplied) by the inverse transformation matrix.
@see `godot.Transform2D.xform`
@param v A vector to inversely transform.
@returns The inversely transformed vector.
**/
@:native("XformInv")
public function xformInv(v:godot.Vector2):godot.Vector2;
/**
Constructs a transformation matrix from 3 vectors (matrix columns).
@param xAxis The X vector, or column index 0.
@param yAxis The Y vector, or column index 1.
@param originPos The origin vector, or column index 2.
**/
@:native("new")
public overload function new(xAxis:godot.Vector2, yAxis:godot.Vector2, originPos:godot.Vector2):Void;
/**
Constructs a transformation matrix from the given components.
Arguments are named such that xy is equal to calling x.y
@param xx The X component of the X column vector, accessed via `t.x.x` or `[0][0]`
@param xy The Y component of the X column vector, accessed via `t.x.y` or `[0][1]`
@param yx The X component of the Y column vector, accessed via `t.y.x` or `[1][0]`
@param yy The Y component of the Y column vector, accessed via `t.y.y` or `[1][1]`
@param ox The X component of the origin vector, accessed via `t.origin.x` or `[2][0]`
@param oy The Y component of the origin vector, accessed via `t.origin.y` or `[2][1]`
**/
@:native("new")
public overload function new(xx:Single, xy:Single, yx:Single, yy:Single, ox:Single, oy:Single):Void;
/**
Constructs a transformation matrix from a `rotation` value and
`origin` vector.
@param rotation The rotation of the new transform, in radians.
@param origin The origin vector, or column index 2.
**/
@:native("new")
public overload function new(rotation:Single, origin:godot.Vector2):Void;
/**
Returns `true` if this transform and `other` are approximately equal,
by running `godot.Vector2.isEqualApprox` on each component.
@param other The other transform to compare.
@returns Whether or not the matrices are approximately equal.
**/
@:native("IsEqualApprox")
public function isEqualApprox(other:godot.Transform2D):Bool;
/**
Converts this `godot.Transform2D` to a string.
@returns A string representation of this transform.
**/
@:native("ToString")
public overload function toString():std.String;
/**
Converts this `godot.Transform2D` to a string with the given `format`.
@returns A string representation of this transform.
**/
@:native("ToString")
public overload function toString(format:std.String):std.String;
}