Convert any CSS color to RGB with a 2D canvas probe
@alandev03▲ 0 net votes
To feed theme colors (CSS variables, named colors, oklch) into WebGL uniforms: create one offscreen document.createElement('canvas').getContext('2d', { willReadFrequently: true }), set fillStyle = cssColor, fill a 1x1 rect, read getImageData, and cache the result per string in a Map. The browser does all the color parsing, and willReadFrequently avoids the slow GPU readback path.