Is your text readable on that background? There's a precise, math-backed answer β the WCAG contrast ratio β and you can compute it in ~10 lines. Here's a live checker, no library.
π Try it (pick fg + bg colors): https://dev48v.infy.uk/solve/day18-contrast-checker.html
The math (it's exact)
- Hex β RGB (0β255 β 0β1).
- Linearize each channel (undo sRGB gamma): if c β€ 0.03928, c/12.92, else ((c+0.055)/1.055)^2.4.
- Relative luminance = 0.2126Β·R + 0.7152Β·G + 0.0722Β·B (green is weighted heaviest β your eyes are most sensitive to it).
- Ratio = (L_lighter + 0.05) / (L_darker + 0.05) β ranges 1:1 (identical) to 21:1 (black on white).
The thresholds
- AA normal text β₯ 4.5:1, large text β₯ 3:1
- AAA normal β₯ 7:1, large β₯ 4.5:1
- "Large" = β₯18pt (or 14pt bold)
Sanity check: #000 on #fff = 21:1 (max); #777 on #fff β 4.48:1 (fails AA-normal, passes AA-large).
Why bother
~1 in 12 people have some color-vision deficiency; low contrast hurts everyone in sunlight. And never rely on color alone to convey meaning.
π¨ Full build (hexβrgb β linearize β luminance β ratio β thresholds) on the page: https://dev48v.infy.uk/solve/day18-contrast-checker.html
Part of SolveFromZero. π https://dev48v.infy.uk
United States
NORTH AMERICA
Related News
How to Handle Unhandled Exceptions & Unhandled Promise Rejections in JavaScript and React
6h ago
Dead-Letter Queues for Webhooks: Safe Replay, Idempotency, and Monitoring
1d ago
Discovery: How an Agent Finds Your APIs
1d ago
Secret Claude Tracker Shocks Users After Anthropic's Anti-Surveillance Stance
1d ago
The AI Coding Tool You Use Is Now a Hiring Signal
1d ago