FCurve

@Serializable
data class FCurve(val segments: List<Segment2D>)(source)

Represents a functional curve composed of multiple 2D segments. It provides utilities to manipulate and query the curve, such as reversing its direction, changing its speed, sampling values, and visualizing it as contours.

Parameters

segments

a list of 2D segments that define the curve

Constructors

Link copied to clipboard
constructor(segments: List<Segment2D>)

Properties

Link copied to clipboard
val bounds: Rectangle
Link copied to clipboard

The duration of the FCurve, calculated as the difference between its start and end points. Returns 0.0 if the FCurve has no segments.

Link copied to clipboard
val end: Double

Represents the x-coordinate of the endpoint of the last segment in the FCurve.

Link copied to clipboard
val max: Double

Represents the maximum y-coordinate value of the FCurve at its bounds.

Link copied to clipboard
val min: Double

Represents the minimum value of the curve.

Link copied to clipboard
val segments: List<Segment2D>
Link copied to clipboard

Represents the starting x-coordinate of the first segment in the FCurve. If the segments list is empty, it defaults to 0.0.

Functions

Link copied to clipboard

Change the duration of the Fcurve

Link copied to clipboard
fun contours(scale: Vector2 = Vector2(1.0, -1.0), offset: Vector2 = Vector2.ZERO): List<ShapeContour>

Return a list of contours that can be used to visualize the Fcurve

Link copied to clipboard

Reverse the fcurve

Link copied to clipboard
fun sampler(normalized: Boolean = false): (Double) -> Double

Creates a function to sample the FCurve at a specific time.

Link copied to clipboard
fun value(t: Double, segment: Segment2D? = null): Double

Evaluate the Fcurve at t

Link copied to clipboard
fun valueWithSegment(t: Double, cachedSegment: Segment2D? = null): Pair<Double, Segment2D?>

Evaluate the Fcurve at t