murattunalı.

Relative luminance.

Relative luminance is the value expressing a colour’s perceived lightness between 0 and 1, and it is the basis of the contrast ratio calculation.

The contrast ratio is not computed directly from colour values; the relative luminance of each colour is found first, then the ratio of the two is taken. That intermediate step also explains why the calculation can produce results that run against intuition.

The calculation has two stages. First each colour channel is reduced to the 0–1 range and gamma correction is undone — a necessary step, because displays produce colours along a non-linear curve. Then the three channels are summed with weights.

The weights are not equal, and the difference is large: green 0.7152, red 0.2126, blue 0.0722. In other words the green channel determines roughly three quarters of a colour’s perceived lightness. That reflects the dominance of the eye’s green-sensitive cone cells.

  1. Practical consequence one: if two colours have close green values, the contrast between them stays low — however different their red and blue may be.
  2. Practical consequence two: for a designer wanting to darken or lighten a palette, the most effective channel is green.
  3. Practical consequence three: pure blue text on a white background gives higher contrast than expected; pure yellow gives much lower.

The ratio formula also carries a constant: 0.05 is added to both luminance values. That constant represents the assumption that displays never produce absolute black and that there is always some ambient reflection. As a result the ratio is never infinite; the ceiling is 21:1 — the value between pure black and pure white.

This calculation need not be done by hand, but knowing how it works teaches one thing: the eye deceives. White text on bright yellow looks vivid and measures 1.1:1. Contrast is not looked at, it is computed.

Another practical consequence of the formula appears in dark theme design. A dark blue that measures 10:1 on a light background falls to 1.5:1 on a dark one and becomes unreadable — because its luminance has moved close to the background’s. That is why serious palette systems define a separate accent tone for dark backgrounds and measure the two themes separately.

Automating the calculation is easy too: a function of a few lines can scan every colour pair in a palette file and report those falling below the threshold. That turns contrast decisions from a one-off measurement into a standing guard — and stops them going stale when the palette is edited.

SOURCES