HDR Color Support - q5js/q5.js GitHub Wiki
Most modern devices support the "display-p3" HDR color space. If a device doesn't support it, q5 will fall back to "srgb".
In q5, colorMode
accepts 'rgb', 'srgb', and 'oklch'. The default mode is 'rgb', which upgrades rgb colors to HDR on supported displays. Specifying 'srgb' on an HDR capable device enables sRGB gamut correction for rgb colors.
The oklch color format is the best way to work with HDR colors!
https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl
colorMode('oklch');
// (lightness, chroma, hue, alpha)
let c = color(0.637, 0.287, 16.57, 1);
The color
function doesn't accept percentages so you'll have to convert those to decimal values. Also its string parsing capability is limited to simple named colors and the hex "#RRGGBB" or "#RRGGBBAA" formats.
Use new Color()
to create color objects without any parsing overhead.
q5 also exposes color components as single letter properties of Color
objects. For example, you can easily change the red of rgb colors like this c.r = 128
or the hue of oklch colors like this c.h = 180
.
Support for the HSV color format was removed in q5 v1.9.3 because color experts thought HSV was flawed, outdated, and ought to be abandoned way back in 1997! oklch is superior in every way.