Class Curve
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class Curve : Resource, IDisposable
- Inheritance
-
Curve
- Implements
- Inherited Members
Constructors
Curve()
public Curve()
Properties
BakeResolution
The number of points to include in the baked (i.e. cached) curve data.
public int BakeResolution { get; set; }
Property Value
MaxValue
The maximum value the curve can reach.
public float MaxValue { get; set; }
Property Value
MinValue
The minimum value the curve can reach.
public float MinValue { get; set; }
Property Value
PointCount
The number of points describing the curve.
public int PointCount { get; set; }
Property Value
_Data
public Array _Data { get; set; }
Property Value
Methods
AddPoint(Vector2, float, float, TangentMode, TangentMode)
Adds a point to the curve. For each side, if the *_mode
is 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 Free.
public int AddPoint(Vector2 position, float leftTangent = 0, float rightTangent = 0, Curve.TangentMode leftMode = TangentMode.Free, Curve.TangentMode rightMode = TangentMode.Free)
Parameters
position
Vector2leftTangent
floatrightTangent
floatleftMode
Curve.TangentModerightMode
Curve.TangentMode
Returns
Bake()
Recomputes the baked cache of points for the curve.
public void Bake()
CleanDupes()
Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.
public void CleanDupes()
ClearPoints()
Removes all points from the curve.
public void ClearPoints()
GetPointLeftMode(int)
Returns the left Curve.TangentMode for the point at index
.
public Curve.TangentMode GetPointLeftMode(int index)
Parameters
index
int
Returns
GetPointLeftTangent(int)
Returns the left tangent angle (in degrees) for the point at index
.
public float GetPointLeftTangent(int index)
Parameters
index
int
Returns
GetPointPosition(int)
Returns the curve coordinates for the point at index
.
public Vector2 GetPointPosition(int index)
Parameters
index
int
Returns
GetPointRightMode(int)
Returns the right Curve.TangentMode for the point at index
.
public Curve.TangentMode GetPointRightMode(int index)
Parameters
index
int
Returns
GetPointRightTangent(int)
Returns the right tangent angle (in degrees) for the point at index
.
public float GetPointRightTangent(int index)
Parameters
index
int
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RemovePoint(int)
Removes the point at index
from the curve.
public void RemovePoint(int index)
Parameters
index
int
Sample(float)
Returns the Y value for the point that would exist at the X position offset
along the curve.
public float Sample(float offset)
Parameters
offset
float
Returns
SampleBaked(float)
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.
public float SampleBaked(float offset)
Parameters
offset
float
Returns
SetPointLeftMode(int, TangentMode)
Sets the left Curve.TangentMode for the point at index
to mode
.
public void SetPointLeftMode(int index, Curve.TangentMode mode)
Parameters
index
intmode
Curve.TangentMode
SetPointLeftTangent(int, float)
Sets the left tangent angle for the point at index
to tangent
.
public void SetPointLeftTangent(int index, float tangent)
Parameters
SetPointOffset(int, float)
Sets the offset from 0.5
.
public int SetPointOffset(int index, float offset)
Parameters
Returns
SetPointRightMode(int, TangentMode)
Sets the right Curve.TangentMode for the point at index
to mode
.
public void SetPointRightMode(int index, Curve.TangentMode mode)
Parameters
index
intmode
Curve.TangentMode
SetPointRightTangent(int, float)
Sets the right tangent angle for the point at index
to tangent
.
public void SetPointRightTangent(int index, float tangent)
Parameters
SetPointValue(int, float)
Assigns the vertical position y
to the point at index
.
public void SetPointValue(int index, float y)
Parameters
Events
RangeChanged
public event Action RangeChanged