Skip to content
UniKit

Color midpoint and gradient

Compute the midpoint and an n-step gradient between two colors, interpolating either in sRGB (gamma-encoded channels) or in linear RGB. Every stop reports HEX / RGB / HSL and its linear-light value, and the 50% midpoint is compared across both spaces — for example black to white is #808080 in sRGB but #BCBCBC in linear light.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Endpoint colors

Accepts #rgb / #rrggbb, rgb() and hsl(). The scale is interpolated in the selected space; the linear space linearizes first.

5

Midpoint and scale

Every stop shows its position, HEX / RGB / HSL and linear-light value; above it, the 50% midpoint in both spaces is compared.

50% midpoint comparison

The same position differs per space: sRGB averages the encoded values, linear RGB averages in linear light.

sRGB space#800080
linear space#BC00BC
Max channel difference60 / 255 · The linear midpoint is lighter
Scale
  • #FF0000Position 0%rgb: 255, 0, 0hsl: 0, 100%, 50%
  • #BF0040Position 25%rgb: 191, 0, 64hsl: 339.9, 100%, 37.45%
  • #800080Position 50%rgb: 128, 0, 128hsl: 300, 100%, 25.1%
  • #4000BFPosition 75%rgb: 64, 0, 191hsl: 260.1, 100%, 37.45%
  • #0000FFPosition 100%rgb: 0, 0, 255hsl: 240, 100%, 50%
Plain text result
a=#FF0000
b=#0000FF
space=srgb
stops=5
0% #FF0000 rgb(255, 0, 0)
25% #BF0040 rgb(191, 0, 64)
50% #800080 rgb(128, 0, 128)
75% #4000BF rgb(64, 0, 191)
100% #0000FF rgb(0, 0, 255)

What this tool does

  • Find the color that looks like the true middle of a gradient: set the endpoints and the step count, then copy the stops as CSS linear-gradient stops.
  • Explain why the same midpoint differs between sRGB and linear light, with the concrete numbers for both spaces.
  • Write a scale into a chart palette: ask for as many even steps as you need, or give uneven positions such as 0, 0.1, 0.5, 1.

Example

Input

A=#FF0000, B=#0000FF, 3 steps, linear space

Output

#FF0000
#BC00BC
#0000FF

The same 50% position: #800080 in sRGB (averaging encoded values) versus #BC00BC in linear light.

Frequently asked questions

How is the midpoint computed?

Each channel is interpolated linearly by position. In sRGB the gamma-encoded values are interpolated directly; in linear space the channels are first linearized with the IEC 61966-2-1 sRGB transfer function (c / 12.92 when c ≤ 0.04045, otherwise ((c + 0.055) / 1.055) ^ 2.4), interpolated, and converted back to sRGB.

How far apart are the two spaces?

The 50% midpoint from black to white is #808080 in sRGB and #BCBCBC in linear light — a 60-byte difference per channel. Darker colors differ more, because the gamma curve compresses shadows the hardest. The tool reports both midpoints and the maximum channel difference.

How do I use the custom positions field?

Give comma-separated, strictly increasing numbers between 0 and 1, for example 0, 0.1, 0.5, 1, at most 33 of them. When set, the step count is ignored, and invalid positions (out of order, out of range, not a number) are rejected with an error.

Which color notations are supported?

All of #rgb, #rrggbb, rgb() / rgba() and hsl() / hsla(). CSS named colors are not accepted, and 8-digit HEX with alpha (#rrggbbaa) is not parsed.

What does this tool deliberately not do?

It only interpolates between sRGB and linear RGB — no HSL, Lab or OKLab interpolation. There is no ICC color management or gamut mapping, and it does not render images: the scale is text only.

Keywords:color midpointlinear-light blendinggradient stops

Related tools