(color: string, alpha: number)
| 93 | * fully opaque, otherwise `rgba(r,g,b,a)`. Accepts hex with or without `#`. |
| 94 | */ |
| 95 | export function toCssColor(color: string, alpha: number): string { |
| 96 | const hex = color.startsWith('#') ? color : `#${color}` |
| 97 | if (alpha >= 1) return hex |
| 98 | const { r, g, b } = hexToRgb(hex) |
| 99 | return `rgba(${r},${g},${b},${alpha.toFixed(3)})` |
| 100 | } |
no test coverage detected