Documentation is work in progress and not completeEditor
FlashCC/The canvas/Section 7 of 29

Colour and contrast

Why inversion is not contrast, the WCAG maths, the softened poles, and the 168-point sweep that proves bestText always clears 4.5:1.

colour.ts exists because literal RGB inversion is not contrast: #808080 inverts to #7f7f7f, a ratio of about 1.0.

Standard WCAG maths — sRGB linearisation s <= 0.04045 ? s/12.92 : ((s+0.055)/1.055) ** 2.4, relative luminance 0.2126R + 0.7152G + 0.0722B, contrast (max + 0.05) / (min + 0.05).

ConstantValueMeaning
AA4.5WCAG AA body text
INK / PAPER#0e1013 / #f8fafcSoftened poles — pure black and white read harsh on a tinted ground
Luminance crossover0.1791Where bestText switches to a pure pole
Muted target4.6textFor’s second colour

bestText(bg) takes the softened pole with more contrast; if it clears 4.5 it is returned. If not — a mid-blue like #6767e4 tops out at 4.33 — it falls back to pure black or white, which guarantee at least 4.58:1 against any colour.

Tested across a 168-point sweep: hue 0–345 in steps of 15, saturation 70, lightness {8, 20, 35, 50, 65, 80, 95}.