The Node.js® Website
at main 272 B view raw
1export const hexToRGBA = (hex: string = '', alpha = 0.9) => { 2 hex = hex.replace(/^#/, ''); 3 4 const bigint = parseInt(hex, 16); 5 const r = (bigint >> 16) & 255; 6 const g = (bigint >> 8) & 255; 7 const b = bigint & 255; 8 9 return `rgba(${r}, ${g}, ${b}, ${alpha})`; 10};