rampOver

A paint that colors each pixel by looking its field value up in a palette.

rampOver(field: Field, palette: Palette, opts?: {edges?: PropRef}): Paint

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

Pass an edges prop (values stretch, transparent, mirror, wrap, marked compileTime) to choose what happens where the field runs past 0–1: hold the end colors, fade to transparent, bounce back, or repeat. Without it the value goes to the palette as is, which is right for fields that already stay in range such as rings or tone.

Parameters

NameTypeNotes
fieldField
palettePalette
opts{edges?: PropRef}Optional.

Example

paint: rampOver(dist.linear({from: p('start'), to: p('end'), angle: p('angle')}), stops(p('colorSpace')), {edges: p('edges')})

Tip. This is the whole recipe for a gradient: a dist.* field, a palette, done.

See also

  • dist — Distance fields: the shape of a gradient, as a number that grows away from a line or point.
  • pair — A palette of two color props, mixed in the color space named by the space prop.
  • stops — The standard multi-stop palette, read from the stops, colorA and colorB props.
  • rings — Repeats a field as concentric bands.
  • tiles — Repeats a field count times, always wrapping.

Used by

BlockNoise, BlueNoise, ConicGradient, CurlNoise, DiamondGradient, ErosionNoise, GaborNoise, LinearGradient, PerlinNoise, Plasma, RadialGradient, Scratches, SimplexNoise, Spiral, Swirl, Voronoi, WaveletNoise