Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

ramp.keys

A ramp from keys: each a position t along 0..1 and a value, the value moving from one key to the next as interpolation says. type is what the ramp gives back: Float takes a number, Color takes { r, g, b, a } (alpha 1 when left out), Vec2, Vec3 and Vec4 take { x, y, z, w }.

The answer is a record { type, interpolation, keys, segments }: the keys ascending in t with each value a number or a { x, y, z, w } record (a Color's r, g, b, a held as x, y, z, w), and one segment { t0, t1, v0, v1 } for each pair of neighbouring keys, which ramp.sample sums over. Keys may be written in any order; keys at one t keep the order they were written in. A ramp needs at least one key, and a type or interpolation outside its options is an error.

Inputs

  • type (String, default "Float"; one of Float, Color, Vec2, Vec3, Vec4). The type every key's value is, and so what the ramp gives back.
  • keys (List<Record>, default { { t = 0, value = 0 }, { t = 1, value = 1 } }). The keys, each { t = <0..1>, value = ... }. A Float takes a number, a Color { r, g, b, a } (alpha 1 when left out), a vector { x, y, z, w }. Keys are read in t order whatever order they are written in.
  • interpolation (String, default "linear"; one of linear, smooth, constant). How the value moves between keys: in a straight line, eased into and out of each key, or held at each key's value until the next.

Outputs

  • ramp (Ramp). The ramp; ramp:sample(t) reads it at t.
local height = g.ramp.keys({ keys = { { t = 1, value = 4 }, { t = 0, value = 0 }, { t = 0.5, value = 1 } }, interpolation = "smooth" })