Table of Contents

Class Curve

A mathematical curve.

Inheritance
Curve

Remarks

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 angle_curve and width_curve.

Properties

bake_resolution

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

var bake_resolution : int = 100

Property Value

int

Remarks

  • void set_bake_resolution(int value)
  • int get_bake_resolution

max_domain

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

var max_domain : float = 1.0

Property Value

float

Remarks

  • void set_max_domain(float value)
  • float get_max_domain

max_value

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

var max_value : float = 1.0

Property Value

float

Remarks

  • void set_max_value(float value)
  • float get_max_value

min_domain

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

var min_domain : float = 0.0

Property Value

float

Remarks

  • void set_min_domain(float value)
  • float get_min_domain

min_value

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

var min_value : float = 0.0

Property Value

float

Remarks

  • void set_min_value(float value)
  • float get_min_value

point_count

The number of points describing the curve.

var point_count : int = 0

Property Value

int

Remarks

  • void set_point_count(int value)
  • int get_point_count

Methods

add_point(Vector2, float, float, int, int)

Adds a point to the curve. For each side, if the *_mode is Curve.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 Curve.TANGENT_FREE.

int add_point(Vector2 position, float left_tangent, float right_tangent, int left_mode, int right_mode)

Parameters

position Vector2
left_tangent float
right_tangent float
left_mode int
right_mode int

bake

Recomputes the baked cache of points for the curve.

void bake

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 clean_dupes

clear_points

Removes all points from the curve.

void clear_points

get_domain_range

Qualifiers: const

Returns the difference between min_domain and max_domain.

float get_domain_range

get_point_left_mode(int)

Qualifiers: const

Returns the left TangentMode for the point at index.

int get_point_left_mode(int index)

Parameters

index int

get_point_left_tangent(int)

Qualifiers: const

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

float get_point_left_tangent(int index)

Parameters

index int

get_point_position(int)

Qualifiers: const

Returns the curve coordinates for the point at index.

Vector2 get_point_position(int index)

Parameters

index int

get_point_right_mode(int)

Qualifiers: const

Returns the right TangentMode for the point at index.

int get_point_right_mode(int index)

Parameters

index int

get_point_right_tangent(int)

Qualifiers: const

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

float get_point_right_tangent(int index)

Parameters

index int

get_value_range

Qualifiers: const

Returns the difference between min_value and max_value.

float get_value_range

remove_point(int)

Removes the point at index from the curve.

void remove_point(int index)

Parameters

index int

sample(float)

Qualifiers: const

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

float sample(float offset)

Parameters

offset float

sample_baked(float)

Qualifiers: const

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.

float sample_baked(float offset)

Parameters

offset float

set_point_left_mode(int, int)

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

void set_point_left_mode(int index, int mode)

Parameters

index int
mode int

set_point_left_tangent(int, float)

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

void set_point_left_tangent(int index, float tangent)

Parameters

index int
tangent float

set_point_offset(int, float)

Sets the offset from 0.5.

int set_point_offset(int index, float offset)

Parameters

index int
offset float

set_point_right_mode(int, int)

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

void set_point_right_mode(int index, int mode)

Parameters

index int
mode int

set_point_right_tangent(int, float)

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

void set_point_right_tangent(int index, float tangent)

Parameters

index int
tangent float

set_point_value(int, float)

Assigns the vertical position y to the point at index.

void set_point_value(int index, float y)

Parameters

index int
y float

Events

domain_changed

Emitted when max_domain or min_domain is changed.

signal domain_changed

range_changed

Emitted when max_value or min_value is changed.

signal range_changed