Curve

继承: Resource < RefCounted < Object

A mathematical curve.

描述

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 Y axis and positions points relative to the 0.5 Y position.

See also Gradient which is designed for color interpolation. See also Curve2D and Curve3D.

属性

方法

intadd_point ( position: Vector2, left_tangent: float = 0, right_tangent: float = 0, left_mode: TangentMode = 0, right_mode: TangentMode = 0 )
voidbake ( )
voidclean_dupes ( )
voidclear_points ( )
TangentModeget_point_left_mode ( index: int ) const1
floatget_point_left_tangent ( index: int ) const1
Vector2get_point_position ( index: int ) const1
TangentModeget_point_right_mode ( index: int ) const1
floatget_point_right_tangent ( index: int ) const1
voidremove_point ( index: int )
floatsample ( offset: float ) const1
floatsample_baked ( offset: float ) const1
voidset_point_left_mode ( index: int, mode: TangentMode )
voidset_point_left_tangent ( index: int, tangent: float )
intset_point_offset ( index: int, offset: float )
voidset_point_right_mode ( index: int, mode: TangentMode )
voidset_point_right_tangent ( index: int, tangent: float )
voidset_point_value ( index: int, y: float )

信号

range_changed ( )

Emitted when max_value or min_value is changed.


枚举

enum TangentMode:

TangentMode TANGENT_FREE = 0

The tangent on this side of the point is user-defined.

TangentMode TANGENT_LINEAR = 1

The curve calculates the tangent on this side of the point as the slope halfway towards the adjacent point.

TangentMode TANGENT_MODE_COUNT = 2

The total number of available tangent modes.


属性说明

int bake_resolution = 100

  • void set_bake_resolution ( value: int )
  • int get_bake_resolution ( )

The number of points to include in the baked (i.e. cached) curve data.


float max_value = 1.0

  • void set_max_value ( value: float )
  • float get_max_value ( )

The maximum value the curve can reach.


float min_value = 0.0

  • void set_min_value ( value: float )
  • float get_min_value ( )

The minimum value the curve can reach.


int point_count = 0

  • void set_point_count ( value: int )
  • int get_point_count ( )

The number of points describing the curve.


方法说明

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

Adds a point to the curve. For each side, if the *_mode is TANGENT_LINEAR, the *_tangent angle (in degrees) uses the slope of the curve halfway to the adjacent point. Allows custom assignments to the *_tangent angle if *_mode is set to TANGENT_FREE.


void bake ( )

Recomputes the baked cache of points for the curve.


void clean_dupes ( )

Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.


void clear_points ( )

Removes all points from the curve.


TangentMode get_point_left_mode ( index: int ) const1

Returns the left TangentMode for the point at index.


float get_point_left_tangent ( index: int ) const1

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


Vector2 get_point_position ( index: int ) const1

Returns the curve coordinates for the point at index.


TangentMode get_point_right_mode ( index: int ) const1

Returns the right TangentMode for the point at index.


float get_point_right_tangent ( index: int ) const1

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


void remove_point ( index: int )

Removes the point at index from the curve.


float sample ( offset: float ) const1

Returns the Y value for the point that would exist at the X position offset along the curve.


float sample_baked ( offset: float ) const1

Returns the Y value for the point that would exist at the X position offset along the curve using the baked cache. Bakes the curve's points if not already baked.


void set_point_left_mode ( index: int, mode: TangentMode )

Sets the left TangentMode for the point at index to mode.


void set_point_left_tangent ( index: int, tangent: float )

Sets the left tangent angle for the point at index to tangent.


int set_point_offset ( index: int, offset: float )

Sets the offset from 0.5.


void set_point_right_mode ( index: int, mode: TangentMode )

Sets the right TangentMode for the point at index to mode.


void set_point_right_tangent ( index: int, tangent: float )

Sets the right tangent angle for the point at index to tangent.


void set_point_value ( index: int, y: float )

Assigns the vertical position y to the point at index.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。