gradient
Gradients: colors and their alpha along a line, from 0 to 1, as a Gradient child and particles have them. A gradient is a value like a color: it can't be changed, and functions give new ones.
gradient.newfunction
gradient.new(keys: table): gradientA gradient from its keypoints, each written [time] = { color, alpha }: its time from 0 to 1, its color, and its alpha (1 solid, 0 gone): gradient.new({ [0] = { color.red, 1 }, [1] = { color.blue, 0.5 } }). A color alone has alpha 1 ([0.5] = color.white), a list of colors is spread evenly (gradient.new({ color.red, color.blue })), and a color may be a cat.Theme item, which the gradient then follows. 16 keypoints at most.
| Value | Type | |
|---|---|---|
keys | table |
Gives: gradient.
gradient.lerpfunction
gradient.lerp(a: gradient, b: gradient, t: number): gradientThe same as a:lerp(b, t).
| Value | Type | |
|---|---|---|
a | gradient | |
b | gradient | |
t | number |
Gives: gradient.
gradient.keysfunction
g.keys: list of tableIts keypoints, in order: a list of tables with time, color and alpha. (A new list each time: changing it changes nothing.)
gradient:colorAtfunction
g:colorAt(time: number): colorIts color at a time, from 0 to 1.
| Value | Type | |
|---|---|---|
time | number |
Gives: color.
gradient:alphaAtfunction
g:alphaAt(time: number): numberIts alpha at a time, from 0 to 1.
| Value | Type | |
|---|---|---|
time | number |
Gives: number.
gradient:reversefunction
g:reverse(): gradientA new gradient: the same keypoints the other way round.
Gives: gradient.
gradient:lerpfunction
g:lerp(other: gradient, t: number): gradientA gradient 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.
| Value | Type | |
|---|---|---|
other | gradient | |
t | number |
Gives: gradient.