Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

colorSequence

Roblox-shaped RGB keyframe-curve value type. A `ColorSequence` is an immutable curve of up to 64 keypoints, each carrying `(time, value, envelope)` where `value` is a `{r, g, b}` triple and `envelope` is a per-channel random range half-width. The per-channel envelope is a notable…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

colorSequence

Roblox-shaped RGB keyframe-curve value type. A ColorSequence is an immutable curve of up to 64 keypoints, each carrying (time, value, envelope) where value is a {r, g, b} triple and envelope is a per-channel random range half-width. The per-channel envelope is a notable improvement over Roblox, where ColorSequence ships with no envelope at all — a long-standing community wishlist item.

Exposed as the ColorSequence Luau global via --!global. Authored scripts call ColorSequence.new(...) directly without a require. The Rust FFI lives at __sequences.* (registered by crates/zero_scripting/src/ffi/bindings/curves.rs); this module is the typed Luau wrapper.

Exports

  • ColorSequence.new(...) -> ColorSequenceObj:

    • ColorSequence.new({r, g, b}) — constant color (accepts a 3-array or {r=, g=, b=} record).
    • ColorSequence.new(c0, c1) — two-point lerp from c0 to c1.
    • ColorSequence.new({ keypoint, ... }) — explicit keypoints. envelope may be omitted (= {0,0,0}), a single number (broadcast to all channels), or a 3-array. First key must anchor at time = 0, last at time = 1. NaN / Inf rejected.
  • ColorSequence.deserialize(payload) -> ColorSequenceObj — rebuild from a { kind = "ColorSequence", keypoints = {...} } payload produced by :serialize().

Keypoint shapes

An entry of a keypoint list takes any of three written shapes, and the shapes mix within one list:

WrittenRead as
{ time = 0.5, value = {1,0,0}, envelope = 0.05 }the named record
{ 0.5, {1,0,0}, 0.05 }time, then colour, then envelope
{ 1, 0, 0 }a bare colour, timed by its place in the list

A bare colour takes its time from its place: the entries spread evenly across [0, 1], so { {1,0.85,0.35}, {1,0.35,0.05} } is a ramp from the first colour at t = 0 to the second at t = 1, and a list of one colour holds that colour across the whole domain.

@builtin::systems.particles.curves exposes a ColorSequence.new that reads these same three shapes, so a colour ramp written for an emitter spec is the literal this constructor takes. The two differ in what they do with the times: this one keeps the written times and leaves the first at 0, last at 1 rule to raise, while the particles reader sorts, clamps and forces the endpoints. The particles reader also carries an alpha channel this one drops, and holds 16 stops where this one holds 64, resampling a longer list down to its own width.

Methods (called via :)

  • seq:evaluate(t) -> (r, g, b) — deterministic linear interpolation at t (multiret). t clamps to [0, 1]; NaN coerces to 0.
  • seq:sample(t) -> (r, g, b) — evaluate(t) plus per-channel (math.random() − 0.5)·2·envelope(t) jitter. Per-VM math.randomseed controls jitter reproducibility.
  • seq:keypoints() -> { { time, value = {r,g,b}, envelope = {r,g,b} } } — array snapshot, sorted ascending by time.
  • seq:duration() -> number — always 1.0 for a well-formed sequence.
  • seq:serialize() -> { kind, keypoints } — scene-save payload.
  • seq:destroy() — drop the FFI handle. Luau removed __gc on tables, so eager cleanup is the caller's responsibility for per-frame-rebuild patterns; otherwise the entry dies with the VM.

Substrate

Backed by zero_curves::Channel (Linear interp). Each sequence builds the value and envelope channels once at construct time and reaches into them on every sample — zero per-call allocation, safe for hot particle loops. Validation errors name the specific rule ("first keypoint must anchor at time = 0", "too many keypoints (max 64)", …).

Foundation for VFX property-over-lifetime: declarative particles (#2572), GPU emitter (#873), beams, trails. Issue: #2673.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

global ColorSequence

isArray(v: any) → boolean

argtypedescription
vany

normalizeTriple(v: any) → void

argtypedescription
vany

normalizeEnvelope(v: any) → void

argtypedescription
vany

normalizeInput(...: ?) → void

argtypedescription
...?

evaluate(self: any, t: number) → void

argtypedescription
selfany
tnumber

sample(self: any, t: number) → void

argtypedescription
selfany
tnumber

keypoints(self: any) → any

argtypedescription
selfany

duration(self: any) → number

argtypedescription
selfany

serialize(self: any) → any

argtypedescription
selfany

destroy(self: any) → void

argtypedescription
selfany

__tostring(self: any) → void

argtypedescription
selfany

new(...: any) → ColorSequenceObj

Construct a ColorSequence from a constant color (3-array `{r,g,b}` or `{r=,g=,b=}` record), a two-point lerp from `c0` to `c1`, or a keypoints array. An entry of that array is a named `{ time =, value =, envelope? = }` record, a `{ time, {r,g,b}, envelope? }` pair, or a bare `{r,g,b}` colour whose time is its place in the list — so a list of colours is a ramp through them. `envelope` is optional and may be a single number (broadcast across channels) or a 3-array. Up to 64 keypoints; the first must anchor at `time = 0`, the last at `time = 1`. NaN / Inf rejected. `@builtin::systems.particles.curves` reads the same three keypoint shapes.

argtypedescription
...any`(color)`, `(c0, c1)`, or `({ keypoint, ... })` where a keypoint is `{time =, value =, envelope? =}`, `{time, {r,g,b}, envelope?}`, or `{r,g,b}`.

examples

local solid = ColorSequence.new({ 1, 0.5, 0.25 })
local fade  = ColorSequence.new({ 1, 1, 1 }, { 0, 0, 0 })
local bow   = ColorSequence.new({ { time = 0, value = {1,0,0} }, { time = 0.5, value = {0,1,0} }, { time = 1, value = {0,0,1} } })
local stops = ColorSequence.new({ { 0, {1,0,0} }, { 1, {0,0,1} } })
local ramp  = ColorSequence.new({ { 1, 0.85, 0.35 }, { 1, 0.35, 0.05 } })

deserialize(data: any) → ColorSequenceObj

Rebuild a ColorSequence from a `{kind = "ColorSequence", keypoints = {...}}` payload produced by `:serialize()`. Used by scene save/load.

argtypedescription
dataanyThe serialized payload.

examples

local c = ColorSequence.deserialize(savedData)
⌬ Types
ColorTriple = { number } | { r: number, g: number, b: number }ColorKeypoint = {ColorKeypointInput = ColorKeypoint | ColorTriple | { any }ColorSequenceObj = {

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

2items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · modules/colorSequence.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.