# Perceptual Gradient Generator (OKLCH, OKLab, CSS) > Build smooth multi-stop CSS gradients in OKLab or OKLCH, with a fallback for every browser. Enter 2–16 color stops in any CSS color syntax. Get a modern CSS gradient that interpolates in OKLab, OKLCH, Lab, LCH or linear light, a fallback with dense HEX stops and its measured error, evenly spaced palette steps and an optional bilinear mesh gradient as PNG. Part of usefulweb.app (https://usefulweb.app/). Part of [Lumina](https://lumina.usefulweb.app/) (ownerApp: lumina). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://luminagradientgenerator.usefulweb.app/ (interactive tool at https://luminagradientgenerator.usefulweb.app/tool) - JSON API: POST https://luminagradientgenerator.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://luminagradientgenerator.usefulweb.app/api/v1/tool) - OpenAPI: https://luminagradientgenerator.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://luminagradientgenerator.usefulweb.app/mcp - tool `lumina_gradient_generator` ## Inputs - stops (textarea): Color stops (one per line: color and optional position in %) - space (select): Interpolation space - hue (select): Hue path (OKLCH and LCH) - kind (select): Gradient shape - angle (number): Angle (degrees; linear direction or conic start) - steps (integer): Palette steps and fallback stops - mesh (textarea): Mesh gradient grid (optional; one row of colors per line, 2–6 per side) ## Method - Parse each stop with CSS Color 4 syntax and fix positions like CSS Images 3: the first and last stop default to 0 % and 100 %, a position smaller than an earlier one is raised to it, and stops without a position are spaced evenly between their neighbours. - Interpolate between neighbouring stops in the chosen space (CSS Color 4 §12). In OKLCH and LCH the hue follows the chosen path; a grey stop has no hue and takes its neighbour's, so grey to blue never passes through red. Colors outside sRGB are brought back with the CSS Color 4 gamut mapping (chroma reduction in OKLCH). - The modern rule uses the CSS syntax "in " so the browser interpolates itself. The fallback samples the same gradient at the step count plus every original stop and lets the browser mix those HEX stops in sRGB; its largest deviation from the true gradient is reported as an OKLab distance × 100 over 513 samples (about 2 is barely visible). - The mesh gradient puts the grid colors at the corners of equal cells and mixes them bilinearly (first across, then down) in the chosen space; the PNG is 480 × 320 pixels.