曲线2d¶
Inherits: Resource < Reference < Object
类别: 核心
简要说明¶
描述二维空间中的B_zier曲线。
属性¶
5.0 |
方法¶
无效 |
add_point ( Vector2 position, Vector2 in=Vector2( 0, 0 ), Vector2 out=Vector2( 0, 0 ), int at_position=-1 ) |
无效 |
clear_points ( ) |
get_baked_length ( ) const |
|
get_baked_points ( ) const |
|
get_closest_offset ( Vector2 to_point ) const |
|
get_closest_point ( Vector2 to_point ) const |
|
get_point_count ( ) const |
|
get_point_in ( int idx ) const |
|
get_point_out ( int idx ) const |
|
get_point_position ( int idx ) const |
|
interpolate ( int idx, float t ) const |
|
interpolate_baked ( float offset, bool cubic=false ) const |
|
interpolatef ( float fofs ) const |
|
无效 |
remove_point ( int idx ) |
无效 |
set_point_in ( int idx, Vector2 position ) |
无效 |
set_point_out ( int idx, Vector2 position ) |
无效 |
set_point_position ( int idx, Vector2 position ) |
tessellate ( int max_stages=5, float tolerance_degrees=4 ) const |
属性描述¶
float bake_interval
违约 |
5.0 |
设定器 |
设置烘焙间隔(值) |
吸气剂 |
获取“烘焙间隔”() |
两个相邻缓存点之间的距离(像素)。更改它将强制在下次 get_baked_points 或 get_baked_length 调用函数。距离越小,缓存中的点越多,占用的内存越多,因此请小心使用。
方法说明¶
void add_point ( Vector2 position, Vector2 in=Vector2( 0, 0 ), Vector2 out=Vector2( 0, 0 ), int at_position=-1 )
在曲线上添加点 position
,带控制点 in
和 out
.
如果 at_position
如果给定,则在点编号之前插入点 at_position
,将该点(以及之后的每个点)移动到插入点之后。如果 at_position
未给定,或是非法值 (at_position <0
或 at_position >= [method get_point_count]
)点将附加在点列表的末尾。
void clear_points ( )
从曲线中删除所有点。
float get_baked_length ( ) const
基于缓存点返回曲线的总长度。给定足够的密度(见 bake_interval )应该足够近似。
PoolVector2Array get_baked_points ( ) const
将点的缓存作为 PoolVector2Array .
返回最接近的偏移量 to_point
. 此偏移量用于 interpolate_baked .
to_point
必须在曲线的局部空间中。
返回最接近的点(在曲线的局部空间中)到 to_point
.
to_point
必须在曲线的局部空间中。
int get_point_count ( ) const
返回描述曲线的点数。
返回指向顶点的控制点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0)
.
返回从顶点引出的控制点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0)
.
返回顶点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误,并返回 (0, 0)
.
返回顶点之间的位置 idx
和顶点 idx + 1
在哪里 t
控制点是否为第一个顶点 (t = 0.0
)最后一个顶点 (t = 1.0
或者介于两者之间。的值 t
超出范围 (0.0 >= t <=1
)给出奇怪但可预测的结果。
如果 idx
超出界限,将截断到第一个或最后一个顶点,并且 t
被忽略。如果曲线没有点,函数将向控制台发送一个错误,并返回 (0, 0)
.
返回曲线中位置处的点 offset
在哪里 offset
以沿曲线的像素距离测量。
为此,它会找到两个缓存点, offset
介于两者之间,然后插入值。这个插值是三次的,如果 cubic
设置为 true
,或线性(如果设置为) false
.
三次插值倾向于更好地跟踪曲线,但线性插值更快(而且通常足够精确)。
返回顶点位置 fofs
. 它调用 interpolate 使用的整数部分 fofs
作为 idx
,其分数部分为 t
.
void remove_point ( int idx )
删除点 idx
从曲线上看。在以下情况下向控制台发送错误: idx
超出界限。
设置指向顶点的控制点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误。
设置从顶点引出的控制点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误。
设置顶点的位置 idx
. 如果索引超出界限,函数将向控制台发送错误。
PoolVector2Array tessellate ( int max_stages=5, float tolerance_degrees=4 ) const
返回曲线上具有曲率控制的点密度的点列表。也就是说,曲线部分比直线部分有更多的点。
这种近似使每个点之间的直线段,然后细分这些段,直到得到的形状足够相似。
max_stages
控制曲线段在被认为足够近似之前可能面对的细分数目。每个细分将分段分割为两半,因此默认的5个阶段可能意味着每个曲线分段最多32个细分。小心增加!
tolerance_degrees
控制细分段之前,段的中点可能偏离实际曲线的角度。