({ r, g, b })
| 91 | } |
| 92 | |
| 93 | function rgbToHex({ r, g, b }) { |
| 94 | const toHex = (value) => { |
| 95 | const hex = Math.round(value * 255).toString(16); |
| 96 | return hex.length === 1 ? "0" + hex : hex; |
| 97 | }; |
| 98 | |
| 99 | const hex = [toHex(r), toHex(g), toHex(b)].join(""); |
| 100 | return `#${hex}`; |
| 101 | } |
no test coverage detected