(colorHex: string)
| 16 | * @returns RGBA value as a 32-bit integer, or 0 if invalid hex color |
| 17 | */ |
| 18 | export function hexStringToRGBAInt(colorHex: string): number { |
| 19 | if (!isHexColor(colorHex)) { |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | let hex = colorHex.replace('#', ''); |
| 24 | |
| 25 | // Add alpha if it's not included |
| 26 | hex = hex.length === 6 ? `${hex}ff` : hex; |
| 27 | |
| 28 | return parseInt(hex, 16); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Converts a hex color string to RGBA float components in [0, 1]. |
no test coverage detected
searching dependent graphs…