Mesh gradients are everywhere: landing page backgrounds, covers, wallpapers. I wanted my own, one where I could drag the colors around, see it full screen and take it away as a PNG, CSS or a link. That became the mesh gradient generator in the tools section.
Along the way, three decisions turned out to separate a good gradient from a muddy one. This post walks through them, each with a demo you can touch.

Blend in OKLab, not sRGB
At heart, a gradient is mixing colors. The naive way is to average the RGB values, and that is where the trouble starts: sRGB is not spaced the way eyes see it. Halfway between two saturated colors, the mix loses chroma and drifts toward a dull grey.
OKLab is a color space built so that numeric distances match perceived ones. Mix there and the midpoint keeps the brightness and color of both ends. CSS already supports it with linear-gradient(in oklab, …), so you can compare without a line of JavaScript:
In the tool, each color is converted to OKLab once, on the CPU, and the shader blends in that space before going back to sRGB to paint.
Gaussian weights, not inverse distance
With several colors spread over the canvas, each pixel has to decide how much of each it gets. My first version used inverse distance: the closer to a dot, the more weight, with 1 / dⁿ. It works, but it has a flaw you see right away: the weight shoots up as you near a dot, so every color sits in a round spot with a hard center.
The fix was switching to a Gaussian bell, exp(-d² / r²). It has no peak at the dot: the color rises softly and falls softly, and neighbours melt together. The softness setting only changes the bell's radius.
float reach = mix(0.12, 0.44, uSoftness);
float spread = 1.0 / (reach * reach);
float weight = exp(-dot(delta, delta) * spread) + 0.000001;
lab += uLab[i] * weight;
total += weight;The + 0.000001 avoids a division by zero far from every dot, where all the bells are close to nothing.
The swirl: move where each pixel looks
With OKLab and Gaussian weights the gradient is already clean, but also a little predictable: round, well-blended blobs. What gives it that organic feel, like smoke or silk, is the swirl.
The trick is called domain warping. The colors do not move. Before computing the blend, each pixel shifts its position by a smooth noise field (fbm, four octaves of value noise) and looks the colors up from there. Neighbouring pixels shift almost the same amount, so the image bends without breaking.
The swirl amount is how far pixels shift; the swirl size is the noise frequency. With animation on, the noise field drifts slowly over time and the gradient breathes.
Grain and export
The last step is grain: a little per-pixel noise that takes away the plastic look and hides banding in very soft gradients. Exporting surfaced a detail here. If the grain is one pixel, a 4K PNG makes it so fine that it disappears when viewed scaled down.
The fix is grain in blocks that grow with the output, measured against a preview of about 900 pixels. That way a 3840 × 2160 PNG has the same grain you see on screen.
The CSS is an approximation: one radial-gradient layer per dot over the average color. CSS cannot blend in OKLab per pixel or swirl, so it reads softer than the canvas, but it works as a background with no JavaScript. The link keeps the whole state in the URL, so sharing is copying the address bar.
Try it
The mesh gradient generator is free, runs in the browser and needs no sign-up. It comes with eight presets, a randomize button and PNG export up to 4K. For more utilities in the same spirit, the same section has the layered shadow generator and the OKLCH color scale.