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 | 4x | export const RGBAToHexA = (rgba: string, forceRemoveAlpha = false): string => { return "#" + rgba.replace(/^rgba?\(|\s+|\)$/g, '') // Get's rgba / rgb string values .split(',') // splits them at "," .filter((string, index) => !forceRemoveAlpha || index !== 3) .map(string => parseFloat(string)) // Converts them to numbers .map((number, index) => index === 3 ? Math.round(number * 255) : number) // Converts alpha to 255 number .map(number => number.toString(16)) // Converts numbers to hex .map(string => string.length === 1 ? "0" + string : string) // Adds 0 when length of one number is 1 .join(""); // Puts the array to togehter to a string } |