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

Inherits: Resource < RefCounted < Object

A mathematical curve.

Description

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.

Properties

int

bake_resolution

100

float

max_value

1.0

float

min_value

0.0

int

point_count

0

Methods

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

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

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)


Signals

range_changed()

Emitted when max_value or min_value is changed.


Enumerations

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.


Property Descriptions

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