/
Curve2D.hx
274 lines (212 loc) · 14 KB
/
Curve2D.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
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
This class describes a Bézier curve in 2D space. It is mainly used to give a shape to a `godot.Path2D`, but can be manually sampled for other purposes.
It keeps a cache of precalculated points along the curve, to speed up further calculations.
**/
@:libType
@:csNative
@:native("Godot.Curve2D")
@:autoBuild(godot.Godot.buildUserClass())
extern class Curve2D extends godot.Resource {
@:native("_Data")
public var _Data:godot.collections.Dictionary;
/**
The distance in pixels between two adjacent cached points. Changing it forces the cache to be recomputed the next time the `godot.Curve2D.getBakedPoints` or `godot.Curve2D.getBakedLength` function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care.
**/
@:native("BakeInterval")
public var bakeInterval:Single;
@:native("new")
public function new():Void;
/**
Returns the number of points describing the curve.
**/
@:native("GetPointCount")
public function getPointCount():Int;
#if doc_gen
/**
Adds a point to a curve at `position` relative to the `godot.Curve2D`'s position, with control points `in` and `out`.
If `at_position` is given, the point is inserted before the point number `at_position`, moving that point (and every point after) after the inserted point. If `at_position` is not given, or is an illegal value (`at_position <0` or `at_position >= [method get_point_count]`), the point will be appended at the end of the point list.
@param in If the parameter is null, then the default value is new Vector2(0, 0)
@param out If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("AddPoint")
public function addPoint(position:godot.Vector2, ?in_:Null<godot.Vector2>, ?out:Null<godot.Vector2>, ?atPosition:Int):Void;
#else
/**
Adds a point to a curve at `position` relative to the `godot.Curve2D`'s position, with control points `in` and `out`.
If `at_position` is given, the point is inserted before the point number `at_position`, moving that point (and every point after) after the inserted point. If `at_position` is not given, or is an illegal value (`at_position <0` or `at_position >= [method get_point_count]`), the point will be appended at the end of the point list.
@param in If the parameter is null, then the default value is new Vector2(0, 0)
@param out If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("AddPoint")
public overload function addPoint(position:godot.Vector2):Void;
/**
Adds a point to a curve at `position` relative to the `godot.Curve2D`'s position, with control points `in` and `out`.
If `at_position` is given, the point is inserted before the point number `at_position`, moving that point (and every point after) after the inserted point. If `at_position` is not given, or is an illegal value (`at_position <0` or `at_position >= [method get_point_count]`), the point will be appended at the end of the point list.
@param in If the parameter is null, then the default value is new Vector2(0, 0)
@param out If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("AddPoint")
public overload function addPoint(position:godot.Vector2, in_:Nullable1<godot.Vector2>):Void;
/**
Adds a point to a curve at `position` relative to the `godot.Curve2D`'s position, with control points `in` and `out`.
If `at_position` is given, the point is inserted before the point number `at_position`, moving that point (and every point after) after the inserted point. If `at_position` is not given, or is an illegal value (`at_position <0` or `at_position >= [method get_point_count]`), the point will be appended at the end of the point list.
@param in If the parameter is null, then the default value is new Vector2(0, 0)
@param out If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("AddPoint")
public overload function addPoint(position:godot.Vector2, in_:Nullable1<godot.Vector2>, out:Nullable1<godot.Vector2>):Void;
/**
Adds a point to a curve at `position` relative to the `godot.Curve2D`'s position, with control points `in` and `out`.
If `at_position` is given, the point is inserted before the point number `at_position`, moving that point (and every point after) after the inserted point. If `at_position` is not given, or is an illegal value (`at_position <0` or `at_position >= [method get_point_count]`), the point will be appended at the end of the point list.
@param in If the parameter is null, then the default value is new Vector2(0, 0)
@param out If the parameter is null, then the default value is new Vector2(0, 0)
**/
@:native("AddPoint")
public overload function addPoint(position:godot.Vector2, in_:Nullable1<godot.Vector2>, out:Nullable1<godot.Vector2>, atPosition:Int):Void;
#end
/**
Sets the position for the vertex `idx`. If the index is out of bounds, the function sends an error to the console.
**/
@:native("SetPointPosition")
public function setPointPosition(idx:Int, position:godot.Vector2):Void;
/**
Returns the position of the vertex `idx`. If the index is out of bounds, the function sends an error to the console, and returns `(0, 0)`.
**/
@:native("GetPointPosition")
public function getPointPosition(idx:Int):godot.Vector2;
/**
Sets the position of the control point leading to the vertex `idx`. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
**/
@:native("SetPointIn")
public function setPointIn(idx:Int, position:godot.Vector2):Void;
/**
Returns the position of the control point leading to the vertex `idx`. The returned position is relative to the vertex `idx`. If the index is out of bounds, the function sends an error to the console, and returns `(0, 0)`.
**/
@:native("GetPointIn")
public function getPointIn(idx:Int):godot.Vector2;
/**
Sets the position of the control point leading out of the vertex `idx`. If the index is out of bounds, the function sends an error to the console. The position is relative to the vertex.
**/
@:native("SetPointOut")
public function setPointOut(idx:Int, position:godot.Vector2):Void;
/**
Returns the position of the control point leading out of the vertex `idx`. The returned position is relative to the vertex `idx`. If the index is out of bounds, the function sends an error to the console, and returns `(0, 0)`.
**/
@:native("GetPointOut")
public function getPointOut(idx:Int):godot.Vector2;
/**
Deletes the point `idx` from the curve. Sends an error to the console if `idx` is out of bounds.
**/
@:native("RemovePoint")
public function removePoint(idx:Int):Void;
/**
Removes all points from the curve.
**/
@:native("ClearPoints")
public function clearPoints():Void;
/**
Returns the position between the vertex `idx` and the vertex `idx + 1`, where `t` controls if the point is the first vertex (`t = 0.0`), the last vertex (`t = 1.0`), or in between. Values of `t` outside the range (`0.0 >= t <=1`) give strange, but predictable results.
If `idx` is out of bounds it is truncated to the first or last vertex, and `t` is ignored. If the curve has no points, the function sends an error to the console, and returns `(0, 0)`.
**/
@:native("Interpolate")
public function interpolate(idx:Int, t:Single):godot.Vector2;
/**
Returns the position at the vertex `fofs`. It calls `godot.Curve2D.interpolate` using the integer part of `fofs` as `idx`, and its fractional part as `t`.
**/
@:native("Interpolatef")
public function interpolatef(fofs:Single):godot.Vector2;
@:native("SetBakeInterval")
public function setBakeInterval(distance:Single):Void;
@:native("GetBakeInterval")
public function getBakeInterval():Single;
/**
Returns the total length of the curve, based on the cached points. Given enough density (see `godot.Curve2D.bakeInterval`), it should be approximate enough.
**/
@:native("GetBakedLength")
public function getBakedLength():Single;
#if doc_gen
/**
Returns a point within the curve at position `offset`, where `offset` is measured as a pixel distance along the curve.
To do that, it finds the two cached points where the `offset` lies between, then interpolates the values. This interpolation is cubic if `cubic` is set to `true`, or linear if set to `false`.
Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
**/
@:native("InterpolateBaked")
public function interpolateBaked(offset:Single, ?cubic:Bool):godot.Vector2;
#else
/**
Returns a point within the curve at position `offset`, where `offset` is measured as a pixel distance along the curve.
To do that, it finds the two cached points where the `offset` lies between, then interpolates the values. This interpolation is cubic if `cubic` is set to `true`, or linear if set to `false`.
Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
**/
@:native("InterpolateBaked")
public overload function interpolateBaked(offset:Single):godot.Vector2;
/**
Returns a point within the curve at position `offset`, where `offset` is measured as a pixel distance along the curve.
To do that, it finds the two cached points where the `offset` lies between, then interpolates the values. This interpolation is cubic if `cubic` is set to `true`, or linear if set to `false`.
Cubic interpolation tends to follow the curves better, but linear is faster (and often, precise enough).
**/
@:native("InterpolateBaked")
public overload function interpolateBaked(offset:Single, cubic:Bool):godot.Vector2;
#end
/**
Returns the cache of points as a `godot.Vector2`.
**/
public extern inline function getBakedPoints():std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.GetBakedPoints()", this));
}
/**
Returns the closest baked point (in curve's local space) to `to_point`.
`to_point` must be in this curve's local space.
**/
@:native("GetClosestPoint")
public function getClosestPoint(toPoint:godot.Vector2):godot.Vector2;
/**
Returns the closest offset to `to_point`. This offset is meant to be used in `godot.Curve2D.interpolateBaked`.
`to_point` must be in this curve's local space.
**/
@:native("GetClosestOffset")
public function getClosestOffset(toPoint:godot.Vector2):Single;
#if doc_gen
/**
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
`max_stages` controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
`tolerance_degrees` controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
**/
public extern inline function tessellate(?maxStages:Int, ?toleranceDegrees:Single):std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.Tessellate({1}, {2})", this, maxStages, toleranceDegrees));
}
#else
/**
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
`max_stages` controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
`tolerance_degrees` controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
**/
public overload extern inline function tessellate():std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.Tessellate()", this));
}
/**
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
`max_stages` controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
`tolerance_degrees` controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
**/
public overload extern inline function tessellate(maxStages:Int):std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.Tessellate({1})", this, maxStages));
}
/**
Returns a list of points along the curve, with a curvature controlled point density. That is, the curvier parts will have more points than the straighter parts.
This approximation makes straight segments between each point, then subdivides those segments until the resulting shape is similar enough.
`max_stages` controls how many subdivisions a curve segment may face before it is considered approximate enough. Each subdivision splits the segment in half, so the default 5 stages may mean up to 32 subdivisions per curve segment. Increase with care!
`tolerance_degrees` controls how many degrees the midpoint of a segment may deviate from the real curve, before the segment has to be subdivided.
**/
public overload extern inline function tessellate(maxStages:Int, toleranceDegrees:Single):std.Array<godot.Vector2> {
return cs.Lib.array(cs.Syntax.code("{0}.Tessellate({1}, {2})", this, maxStages, toleranceDegrees));
}
#end
}