---
title: "Fields, palettes & ramps"
description: "The words every gradient and most textures are drawn with."
group: "paint"
groupTitle: "Painting"
categoryId: "paint"
categorySlug: "paint"
wordCount: 30
curated: true
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/fields.ts"
editUrl: "https://github.com/shader-effects-inc/shaders/edit/main/packages/core/docs/std/paint.md"
---

# Fields, palettes & ramps

The words every gradient and most textures are drawn with. A **field** is a number per pixel
(`Field`): the distance from a point, a noise value, a flow pattern. A **palette** turns a
number into a color (`Palette`): two colors, or a multi-stop ramp, mixed in the color space
your definition declares. [`rampOver`](/docs/primitives/paint/rampover) joins the two and is the single most common line in a
generator.

Everything else here shapes the field before it meets the palette. [`warped`](/docs/primitives/paint/warped) bends the
coordinate so smooth noise turns liquid. [`scaledVolume`](/docs/primitives/paint/scaledvolume) gives noise a zoomable, aspect-correct
coordinate. [`tone`](/docs/primitives/paint/tone) and [`threshold`](/docs/primitives/paint/threshold) reshape the value. [`rings`](/docs/primitives/paint/rings) and [`tiles`](/docs/primitives/paint/tiles) repeat it. [`share`](/docs/primitives/paint/share)
lets two words read one result. Fields nest, so read a recipe from the inside out: the
innermost word is sampled first and each wrapper changes what the next one sees.

The result is a paint: put it in the definition's `paint:` field.

```ts
import {paint} from 'shaders/std'
```

## Reach for it when

| When you need | Use |
|---|---|
| a gradient of any shape, in a chosen color space | [`rampOver`](/docs/primitives/paint/rampover) with a [`dist`](/docs/primitives/paint/dist) field and [`pair`](/docs/primitives/paint/pair) or [`stops`](/docs/primitives/paint/stops) |
| the field should flow like liquid | [`warped`](/docs/primitives/paint/warped) around a [`noiseField`](/docs/primitives/paint/noisefield), inside [`scaledVolume`](/docs/primitives/paint/scaledvolume) |
| noise you can zoom evenly at any canvas size | [`scaledVolume`](/docs/primitives/paint/scaledvolume) |
| the value is too flat or too hot for the palette | [`tone`](/docs/primitives/paint/tone) |
| a signed pattern should become soft color bands | [`threshold`](/docs/primitives/paint/threshold) over [`flowField`](/docs/primitives/paint/flowfield) |
| concentric or repeated bands of one field | [`rings`](/docs/primitives/paint/rings), [`tiles`](/docs/primitives/paint/tiles) |
| two words need the same field without computing it twice | [`share`](/docs/primitives/paint/share) |
| a slow brightness breathing along a pattern | [`pulse`](/docs/primitives/paint/pulse) inside [`shimmered`](/docs/primitives/paint/shimmered) |
| the palette value runs past 1 and must not seam | [`wrapRamp`](/docs/primitives/paint/wrapramp), [`foldRamp`](/docs/primitives/paint/foldramp) |
| a mesh-gradient look, colors scattered across the canvas | [`scatterField`](/docs/primitives/paint/scatterfield) with [`scatteredAnchors`](/docs/primitives/paint/scatteredanchors) |
| three or four colors blended by two values | [`colorLadder3`](/docs/primitives/paint/colorladder3), [`quadBlend`](/docs/primitives/paint/quadblend) |
| a rainbow from a hue number | [`hueWheel`](/docs/primitives/paint/huewheel) |

## Example

```ts
import {defineShader, p, paint, transformColor, transformColorSpace, colorSpaceOptions, colorStopsPropConfig} from 'shaders/std'

const {rampOver, tone, scaledVolume, warped, noiseField, stops} = paint

// Liquid plasma: warped noise on a zoomable slab, tone-shaped, read through the stop ramp.
export const Plasma = defineShader({
  name: 'Plasma',
  animatedTime: {speed: 'speed'},
  props: {
    colorA: {default: '#7018be', transform: transformColor},
    colorB: {default: '#000000', transform: transformColor},
    stops: colorStopsPropConfig(),
    colorSpace: {default: 'oklch', transform: transformColorSpace, compileTime: true, ui: {type: 'select', options: colorSpaceOptions}},
    scale: {default: 2},
    warp: {default: 0.4},
    intensity: {default: 1.5},
    speed: {default: 1},
  },
  paint: rampOver(
    tone(
      scaledVolume(warped(noiseField('mx3'), {amount: p('warp'), amountScale: 4, timeScale: 0.125}), {scale: p('scale')}),
      {glow: p('intensity'), contrast: 1, balance: 50, invert: true},
    ),
    stops(p('colorSpace')),
  ),
})
```

## Types

| Type | What it is |
|---|---|
| `Field` | A number per pixel, computed from a coordinate. |
| `FieldScalar` | A number input: a prop `p('name')`, a plain number, or a prop remapped as `{base, add, mul}`. |
| `NoiseBasis` | The noise flavors `noiseField` can sample. |
| `Paint` | What a generator's `paint:` field takes: a function that returns the color at this pixel. |
| `Palette` | A color for a field value between 0 and 1. |

## Words

- [`rampOver`](/docs/primitives/paint/rampover) — A paint that colors each pixel by looking its field value up in a palette.
- [`pair`](/docs/primitives/paint/pair) — A palette of two color props, mixed in the color space named by the `space` prop.
- [`stops`](/docs/primitives/paint/stops) — The standard multi-stop palette, read from the `stops`, `colorA` and `colorB` props.
- [`standardPalette`](/docs/primitives/paint/standardpalette) — The color for a 0–1 value from the standard palette props: `colorA`, `colorB`, `stops`, `colorSpace`.
- [`dist`](/docs/primitives/paint/dist) — Distance fields: the shape of a gradient, as a number that grows away from a line or point.
- [`noiseField`](/docs/primitives/paint/noisefield) — A field of smooth noise in the chosen flavor.
- [`warped`](/docs/primitives/paint/warped) — Makes a field flow like liquid by bending its coordinate with moving noise.
- [`scaledVolume`](/docs/primitives/paint/scaledvolume) — Gives a noise field a zoomable, aspect-correct coordinate.
- [`tone`](/docs/primitives/paint/tone) — Reshapes a 0–1 field with glow, contrast and balance controls, then flips it.
- [`threshold`](/docs/primitives/paint/threshold) — Turns a signed field (−1 to 1) into a soft 0–1 mask.
- [`rings`](/docs/primitives/paint/rings) — Repeats a field as concentric bands.
- [`tiles`](/docs/primitives/paint/tiles) — Repeats a field `count` times, always wrapping.
- [`share`](/docs/primitives/paint/share) — Evaluates a field once and lets several words read the same result.
- [`flowField`](/docs/primitives/paint/flowfield) — A swirling, animated wave pattern from −1 to 1.
- [`pulse`](/docs/primitives/paint/pulse) — A gentle brightness pulse that follows a pattern field, hovering around 1.
- [`shimmered`](/docs/primitives/paint/shimmered) — Multiplies a paint's color and alpha by a gain field, for a slow shimmer over a pattern.
- [`wrapRamp`](/docs/primitives/paint/wrapramp) — Runs a palette value back and forth `cycles` times so a ramp repeats without a seam.
- [`foldRamp`](/docs/primitives/paint/foldramp) — Folds any number into 0–1 as a seamless zigzag: up from 0 to 1, back down, every 2 units.
- [`warpedPoint`](/docs/primitives/paint/warpedpoint) — A 3D position pushed around by moving noise, for reading several fields at one warped spot.
- [`warpStep`](/docs/primitives/paint/warpstep) — One step of a chained warp: pushes a 2D position by two noise reads and hands them back.
- [`scatterField`](/docs/primitives/paint/scatterfield) — A mesh-gradient field: up to 8 drifting points scattered across the canvas, blended by nearness.
- [`scatteredAnchors`](/docs/primitives/paint/scatteredanchors) — Computes the `scatterField` points once per frame instead of once per pixel.
- [`quadBlend`](/docs/primitives/paint/quadblend) — A four-color blend on a square: `a` to `b` across the top, `c` to `d` across the bottom, then top to bottom.
- [`colorLadder3`](/docs/primitives/paint/colorladder3) — A three-color blend: `a` to `b` by the first value, then on to `c` by the second.
- [`hueWheel`](/docs/primitives/paint/huewheel) — A rainbow color for a hue value: 0 is red, cycling through the spectrum and back every 1.
- [`dist.conic`](/docs/primitives/paint/dist-conic) — A sweep around a center, like a clock hand: 0 to 1 once around.
- [`dist.diamond`](/docs/primitives/paint/dist-diamond) — A diamond-shaped gradient spreading out from a center.
- [`dist.linear`](/docs/primitives/paint/dist-linear) — A straight gradient from one point to another.
- [`dist.radial`](/docs/primitives/paint/dist-radial) — A round or elliptical gradient spreading out from a center.
- [`dist.spiral`](/docs/primitives/paint/dist-spiral) — A turning spiral stripe: 0 on the background, 1 on the stroke.