Skip to content

ColorCurve

Global · ColorCurve · server and client scripts

ColorCurve creates an immutable curve of Color values over normalized time from 0 to 1, such as a particle color ramp over a particle's lifetime. To inspect a curve's points, see ColorCurve.

new

Function
new(points: { { Time: number, Color: Color } }) -> ColorCurve

ColorCurve.new creates a curve from an array of 2 to 8 point tables { Time = t, Color = color }. The first point must be at time 0, the last at time 1, and times must be in non-decreasing order.

Example

-- Server script.
local fire = ColorCurve.new({
    { Time = 0, Color = Color.new(1, 0.9, 0.4) },
    { Time = 0.4, Color = Color.new(1, 0.4, 0) },
    { Time = 1, Color = Color.new(0.2, 0.2, 0.2, 0) },
})
print(#fire.Points) -- prints 3

linear

Function
linear(c0: Color, c1: Color?) -> ColorCurve

ColorCurve.linear creates a constant color curve at c0 or a linear ramp from c0 at time 0 to c1 at time 1.

Example

-- Server script.
local cool = ColorCurve.linear(Color.new(1, 1, 0), Color.new(1, 0, 0))
print(#cool.Points) -- prints 2