Builtin Library
README.md
ramp (nodebox)
Ramps: a value that moves along a position from 0 to 1, made from keys or from a blackbody's colours, and read at every element by a 0..1 field. Use them for colour over a particle's age, a height-to-colour map on terrain, a falloff curve, or any one-dimensional lookup a graph shapes by hand.
ramp.keysmakes a ramp from keys{ t, value }of one type (Float, Color, Vec2, Vec3 or Vec4), moving between keys linearly, smoothly or in steps.ramp.blackbodymakes a Color ramp of the colours a blackbody glows at over a range of temperatures.ramp.samplereads a ramp at every element at the position a field names, answering a field of the ramp's type.
A ramp is a value of type Ramp: { type, interpolation, keys, segments } with its keys ascending in t. ramp:sample(t) answers its value at t as numbers (one per component) and ramp:count() its key count, so a ramp also reads outside a graph. field.ramp reads a ramp at an element's own attribute (its life, its speed) taken from a range onto 0..1.
local fade = g.ramp.keys({ type = "Color", keys = { { t = 0, value = { r = 1, g = 0.5, b = 0 } }, { t = 1, value = { r = 0, g = 0, b = 1 } } } })
local spots = g.points.grid({ countX = 3, countZ = 1, spacing = 0.5 })
spots.point.Cd = g.ramp.sample({ ramp = fade, u = spots.point.P.x + 0.5 })