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
Remarks
max_domain
The maximum domain (x-coordinate) that points can have.
var max_domain : float = 1.0
Property Value
Remarks
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
Remarks
min_domain
The minimum domain (x-coordinate) that points can have.
var min_domain : float = 0.0
Property Value
Remarks
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
Remarks
point_count
The number of points describing the curve.
var point_count : int = 0
Property Value
Remarks
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
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
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
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
set_point_offset(int, float)
Sets the offset from 0.5
.
int set_point_offset(int index, float offset)
Parameters
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
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
set_point_value(int, float)
Assigns the vertical position y
to the point at index
.
void set_point_value(int index, float y)
Parameters
Events
domain_changed
Emitted when max_domain or min_domain is changed.
signal domain_changed
range_changed
signal range_changed