Curve
繼承: Resource < RefCounted < Object
數學曲線。
說明
This resource describes a mathematical curve by defining a set of points and tangents at each point. By default, it ranges between 0 and 1 on the X and Y axes, but these ranges can be changed.
Please note that many resources and nodes assume they are given unit curves. A unit curve is a curve whose domain (the X axis) is between 0 and 1. Some examples of unit curve usage are CPUParticles2D.angle_curve and Line2D.width_curve.
屬性
|
||
|
||
|
||
|
||
|
||
|
方法
add_point(position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: TangentMode = 0, right_mode: TangentMode = 0) |
|
void |
bake() |
void |
|
void |
|
get_domain_range() const |
|
get_point_left_mode(index: int) const |
|
get_point_left_tangent(index: int) const |
|
get_point_position(index: int) const |
|
get_point_right_mode(index: int) const |
|
get_point_right_tangent(index: int) const |
|
get_value_range() const |
|
void |
remove_point(index: int) |
sample_baked(offset: float) const |
|
void |
set_point_left_mode(index: int, mode: TangentMode) |
void |
set_point_left_tangent(index: int, tangent: float) |
set_point_offset(index: int, offset: float) |
|
void |
set_point_right_mode(index: int, mode: TangentMode) |
void |
set_point_right_tangent(index: int, tangent: float) |
void |
set_point_value(index: int, y: float) |
訊號
domain_changed() 🔗
Emitted when max_domain or min_domain is changed.
range_changed() 🔗
列舉
enum TangentMode: 🔗
TangentMode TANGENT_FREE = 0
點這邊的切線是使用者自訂的。
TangentMode TANGENT_LINEAR = 1
曲線計算點的這一側的切線,作為向相鄰點的一半的斜率。
TangentMode TANGENT_MODE_COUNT = 2
可用切線模式的總數。
屬性說明
烘焙(即快取)曲線資料中包含的點的數量。
The maximum domain (x-coordinate) that points can have.
The maximum value (y-coordinate) that points can have. Tangents can cause higher values between points.
The minimum domain (x-coordinate) that points can have.
The minimum value (y-coordinate) that points can have. Tangents can cause lower values between points.
描述該曲線的點的數量。
方法說明
int add_point(position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: TangentMode = 0, right_mode: TangentMode = 0) 🔗
在曲線上新增一個點。對於每一側,如果 *_mode 為 TANGENT_LINEAR,則 *_tangent 角度(以度為單位)將使用曲線到鄰近點的一半的斜率。如果 *_mode 設定為 TANGENT_FREE,則允許自訂分配給 *_tangent 的角度。
void bake() 🔗
重新計算曲線的烘焙點快取。
void clean_dupes() 🔗
移除重複點,即與曲線上相鄰點的距離小於 0.00001 個單位(引擎中的 epsilon 值)的點。
void clear_points() 🔗
從曲線中移除所有點。
float get_domain_range() const 🔗
Returns the difference between min_domain and max_domain.
TangentMode get_point_left_mode(index: int) const 🔗
返回索引為 index 的點的左側切線模式 TangentMode。
float get_point_left_tangent(index: int) const 🔗
返回索引為 index 的點的左側切線夾角(單位為度)。
Vector2 get_point_position(index: int) const 🔗
返回索引為 index 的點的曲線座標。
TangentMode get_point_right_mode(index: int) const 🔗
返回索引為 index 的點的右側切線模式 TangentMode。
float get_point_right_tangent(index: int) const 🔗
返回索引為 index 的點的右側切線夾角(單位為度)。
float get_value_range() const 🔗
Returns the difference between min_value and max_value.
void remove_point(index: int) 🔗
移除曲線中索引為 index 的點。
float sample(offset: float) const 🔗
返回沿曲線的 X 位置 offset 處將存在的點的 Y 值。
float sample_baked(offset: float) const 🔗
使用烘焙的快取返回沿曲線的 X 位置 offset 處將存在的點的 Y 值。烘焙尚未烘焙的曲線的點。
void set_point_left_mode(index: int, mode: TangentMode) 🔗
將索引為 index 的點的左側 TangentMode 設定為 mode。
void set_point_left_tangent(index: int, tangent: float) 🔗
將索引為 index 的點的左側切線角度設定為 tangent。
int set_point_offset(index: int, offset: float) 🔗
設定相對於 0.5 的偏移量。
void set_point_right_mode(index: int, mode: TangentMode) 🔗
將索引為 index 的點的右側 TangentMode 設定為 mode。
void set_point_right_tangent(index: int, tangent: float) 🔗
將索引為 index 的點的右側切線角度設定為 tangent。
void set_point_value(index: int, y: float) 🔗
將索引為 index 的點的垂直位置設定為 y。