Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

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 ( Vector2 position, float left_tangent=0, float right_tangent=0, TangentMode left_mode=0, TangentMode right_mode=0 )

void

bake ( )

void

clean_dupes ( )

void

clear_points ( )

TangentMode

get_point_left_mode ( int index ) const

float

get_point_left_tangent ( int index ) const

Vector2

get_point_position ( int index ) const

TangentMode

get_point_right_mode ( int index ) const

float

get_point_right_tangent ( int index ) const

void

remove_point ( int index )

float

sample ( float offset ) const

float

sample_baked ( float offset ) const

void

set_point_left_mode ( int index, TangentMode mode )

void

set_point_left_tangent ( int index, float tangent )

int

set_point_offset ( int index, float offset )

void

set_point_right_mode ( int index, TangentMode mode )

void

set_point_right_tangent ( int index, float tangent )

void

set_point_value ( int index, float y )


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