Resolves any colour the rendering engine accepts into sRGB.
The engine does the work: the colour is painted onto a one-pixel canvas and read back. That is
deliberately not a CSS parser — it means every syntax the engine supports is supported here for
free, today and after any upgrade, including lab(), oklch() and color(display-p3 …), which
a hand-written parser would either miss or approximate.
Wide-gamut inputs survive: the scratch surface holds floats, so a colour beyond sRGB comes back
as extended sRGB rather than clipped to the edge of it.
Resolves any colour the rendering engine accepts into sRGB.
The engine does the work: the colour is painted onto a one-pixel canvas and read back. That is deliberately not a CSS parser — it means every syntax the engine supports is supported here for free, today and after any upgrade, including
lab(),oklch()andcolor(display-p3 …), which a hand-written parser would either miss or approximate.Wide-gamut inputs survive: the scratch surface holds floats, so a colour beyond sRGB comes back as extended sRGB rather than clipped to the edge of it.