Luawe All pages

curve

Curves: a number along a line, from 0 to 1, with an envelope round it (how far a value may stray), as a particle's size over its life has them. A curve is a value like a color: it can't be changed, and functions give new ones.

curve.newfunction

curve.new(keys: table): curve

A curve from its keypoints, each written [time] = value or [time] = { value, envelope }: its time from 0 to 1, its value, and its envelope (how far each particle's own value may stray from it, either way; 0 when it is a value alone): curve.new({ [0] = 0.2, [0.3] = { 0.5, 0.1 }, [1] = 0 }). A list is spread evenly (curve.new({ 0, 1, 0 })). 16 keypoints at most.

ValueType
keystable

Gives: curve.

curve.lerpfunction

curve.lerp(a: curve, b: curve, t: number): curve

The same as a:lerp(b, t).

ValueType
acurve
bcurve
tnumber

Gives: curve.

curve.keysfunction

c.keys: list of table

Its keypoints, in order: a list of tables with time, value and envelope. (A new list each time: changing it changes nothing.)

curve:valueAtfunction

c:valueAt(time: number): number

Its value at a time (the time runs from 0 to 1; the value is any number), in a straight line between two keypoints.

ValueType
timenumber

Gives: number.

curve:envelopeAtfunction

c:envelopeAt(time: number): number

Its envelope at a time, from 0 to 1.

ValueType
timenumber

Gives: number.

curve:reversefunction

c:reverse(): curve

A new curve: the same keypoints the other way round.

Gives: curve.

curve:lerpfunction

c:lerp(other: curve, t: number): curve

A curve between this one (t = 0) and the other (t = 1). With as many keypoints as each other, each keypoint glides to the other's, its time too. t is kept from 0 to 1.

ValueType
othercurve
tnumber

Gives: curve.