foldRamp

Folds any number into 0–1 as a seamless zigzag: up from 0 to 1, back down, every 2 units.

foldRamp(t: Expr): Expr

Import paint from shaders/std and use paint.foldRamp.

Scale the value first to set the cycle length. Safe anywhere, including inside a guarded branch.

Parameters

NameTypeNotes
tExpr

Example

const rgb = stops(p('colorSpace'))(foldRamp(phase), params).member('rgb')

See also

  • wrapRamp — Runs a palette value back and forth cycles times so a ramp repeats without a seam.

Used by

Obsidian