Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x | export const hexToRgb = (hexRaw: string): { r: number; g: number; b: number } | null => {
const hex = hexRaw.replace('#', '');
if (!/^[0-9a-fA-F]{6}$/u.test(hex)) {
return null;
}
const bigint = Number.parseInt(hex, 16);
// eslint-disable-next-line no-bitwise
const r = (bigint >> 16) & 255;
// eslint-disable-next-line no-bitwise
const g = (bigint >> 8) & 255;
// eslint-disable-next-line no-bitwise
const b = bigint & 255;
return { r, g, b };
};
|