Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

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.

屬性

int

bake_resolution

100

float

max_domain

1.0

float

max_value

1.0

float

min_domain

0.0

float

min_value

0.0

int

point_count

0

int

point_{index}/left_mode

0

float

point_{index}/left_tangent

0.0

Vector2

point_{index}/position

Vector2(0, 0)

int

point_{index}/right_mode

0

float

point_{index}/right_tangent

0.0

方法

int

add_point(position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: TangentMode = 0, right_mode: TangentMode = 0)

void

bake()

void

clean_dupes()

void

clear_points()

float

get_domain_range() const

TangentMode

get_point_left_mode(index: int) const

float

get_point_left_tangent(index: int) const

Vector2

get_point_position(index: int) const

TangentMode

get_point_right_mode(index: int) const

float

get_point_right_tangent(index: int) const

float

get_value_range() const

void

remove_point(index: int)

float

sample(offset: float) const

float

sample_baked(offset: float) const

void

set_point_left_mode(index: int, mode: TangentMode)

void

set_point_left_tangent(index: int, tangent: float)

int

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() 🔗

更改 max_valuemin_value 時發出。


列舉

enum TangentMode: 🔗

TangentMode TANGENT_FREE = 0

點這邊的切線是使用者自訂的。

TangentMode TANGENT_LINEAR = 1

曲線計算點的這一側的切線,作為向相鄰點的一半的斜率。

TangentMode TANGENT_MODE_COUNT = 2

可用切線模式的總數。


屬性說明

int bake_resolution = 100 🔗

  • void set_bake_resolution(value: int)

  • int get_bake_resolution()

烘焙(即快取)曲線資料中包含的點的數量。


float max_domain = 1.0 🔗

  • void set_max_domain(value: float)

  • float get_max_domain()

The maximum domain (x-coordinate) that points can have.


float max_value = 1.0 🔗

  • void set_max_value(value: float)

  • float get_max_value()

The maximum value (y-coordinate) that points can have. Tangents can cause higher values between points.


float min_domain = 0.0 🔗

  • void set_min_domain(value: float)

  • float get_min_domain()

The minimum domain (x-coordinate) that points can have.


float min_value = 0.0 🔗

  • void set_min_value(value: float)

  • float get_min_value()

The minimum value (y-coordinate) that points can have. Tangents can cause lower values between points.


int point_count = 0 🔗

  • void set_point_count(value: int)

  • int get_point_count()

描述該曲線的點的數量。


int point_{index}/left_mode = 0 🔗

The left TangentMode for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.


float point_{index}/left_tangent = 0.0 🔗

The left tangent angle (in degrees) for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.


Vector2 point_{index}/position = Vector2(0, 0) 🔗

The position of the point at index.

Note: index is a value in the 0 .. point_count - 1 range.


int point_{index}/right_mode = 0 🔗

The right TangentMode for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.


float point_{index}/right_tangent = 0.0 🔗

The right tangent angle (in degrees) for the point at index.

Note: index is a value in the 0 .. point_count - 1 range.


方法說明

int add_point(position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: TangentMode = 0, right_mode: TangentMode = 0) 🔗

在曲線上新增一個點。對於每一側,如果 *_modeTANGENT_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) 🔗

Assigns the horizontal position offset to the point at index.


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