ratioOfTones

fun ratioOfTones(tone1: Double, tone2: Double): Double

Contrast ratio of two tones. T in HCT, L* in Lab*. Also known as luminance or perpetual luminance.

Contrast ratio is defined using Y in XYZ, relative luminance. However, relative luminance is linear to number of photons, not to perception of lightness. Perceptual luminance, L* in Lab*, T in HCT, is. Designers prefer color spaces with perceptual luminance since they're accurate to the eye.

Y and L* are pure functions of each other, so it possible to use perceptually accurate color spaces, and measure contrast, and measure contrast in a much more understandable way: instead of a ratio, a linear difference. This allows a designer to determine what they need to adjust a color's lightness to in order to reach their desired contrast, instead of guessing & checking with hex codes.

Return

Contrast ratio of two tones. T in HCT, L* in Lab*.

Parameters

tone1

T in HCT, L* in Lab*.

tone2

T in HCT, L* in Lab*.