(rgb: RGBA)
| 126 | } |
| 127 | |
| 128 | export function rgbToString(rgb: RGBA): string { |
| 129 | const {r, g, b, a} = rgb; |
| 130 | if (a != null && a < 1) { |
| 131 | return `rgba(${toFixed(r)}, ${toFixed(g)}, ${toFixed(b)}, ${toFixed(a, 2)})`; |
| 132 | } |
| 133 | return `rgb(${toFixed(r)}, ${toFixed(g)}, ${toFixed(b)})`; |
| 134 | } |
| 135 | |
| 136 | export function rgbToHexString({r, g, b, a}: RGBA): string { |
| 137 | return `#${(a != null && a < 1 ? [r, g, b, Math.round(a * 255)] : [r, g, b]).map((x) => { |
no test coverage detected