(color: RGB | RGBA)
| 3 | |
| 4 | // ---- Color Format Conversion ---- |
| 5 | export const rgbTo6hex = (color: RGB | RGBA): string => { |
| 6 | const hex = |
| 7 | ((color.r * 255) | (1 << 8)).toString(16).slice(1) + |
| 8 | ((color.g * 255) | (1 << 8)).toString(16).slice(1) + |
| 9 | ((color.b * 255) | (1 << 8)).toString(16).slice(1); |
| 10 | |
| 11 | return hex; |
| 12 | }; |
| 13 | |
| 14 | export const rgbTo8hex = (color: RGB, alpha: number): string => { |
| 15 | // when color is RGBA, alpha is set automatically |
no test coverage detected