Curve
A mathematical curve.
Curve.swift:25class Curve
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
.
This object emits the following signals:
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var bakeResolution: Int32
The number of points to include in the baked (i.e. cached) curve data.
var maxValue: Double
The maximum value the curve can reach.
var minValue: Double
The minimum value the curve can reach.
var pointCount: Int32
The number of points describing the curve.
var rangeChanged: SimpleSignal
func addPoint(position: Vector2, leftTangent: Double, rightTangent: Double, leftMode: Curve.TangentMode, rightMode: Curve.TangentMode
) -> Int32 Adds a point to the curve. For each side, if the
*_mode
is .tangentLinear, 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 .tangentFree.func bake(
) Recomputes the baked cache of points for the curve.
func cleanDupes(
) Removes duplicate points, i.e. points that are less than 0.00001 units (engine epsilon value) away from their neighbor on the curve.
func clearPoints(
) Removes all points from the curve.
func getPointLeftMode(index: Int32
) -> Curve.TangentMode Returns the left
TangentMode
for the point atindex
.func getPointLeftTangent(index: Int32
) -> Double Returns the left tangent angle (in degrees) for the point at
index
.func getPointPosition(index: Int32
) -> Vector2 Returns the curve coordinates for the point at
index
.func getPointRightMode(index: Int32
) -> Curve.TangentMode Returns the right
TangentMode
for the point atindex
.func getPointRightTangent(index: Int32
) -> Double Returns the right tangent angle (in degrees) for the point at
index
.func removePoint(index: Int32
) Removes the point at
index
from the curve.func sample(offset: Double
) -> Double Returns the Y value for the point that would exist at the X position
offset
along the curve.func sampleBaked(offset: Double
) -> Double 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.func setPointLeftMode(index: Int32, mode: Curve.TangentMode
) Sets the left
TangentMode
for the point atindex
tomode
.func setPointLeftTangent(index: Int32, tangent: Double
) Sets the left tangent angle for the point at
index
totangent
.func setPointOffset(index: Int32, offset: Double
) -> Int32 Sets the offset from
0.5
.func setPointRightMode(index: Int32, mode: Curve.TangentMode
) Sets the right
TangentMode
for the point atindex
tomode
.func setPointRightTangent(index: Int32, tangent: Double
) Sets the right tangent angle for the point at
index
totangent
.func setPointValue(index: Int32, y: Double
) Assigns the vertical position
y
to the point atindex
.