(color: string)
| 87 | } |
| 88 | |
| 89 | function parseCssColorToRgb(color: string): { r: number; g: number; b: number } | null { |
| 90 | if (!color) return null |
| 91 | const hex = color.trim() |
| 92 | if (hex.startsWith('#')) { |
| 93 | return hexToRgb(hex) |
| 94 | } |
| 95 | const m = hex.match(/rgba?\(([^)]+)\)/i) |
| 96 | if (!m) return null |
| 97 | const parts = m[1].split(',').map((s) => Number.parseFloat(s.trim())) |
| 98 | if (parts.length < 3 || parts.some((v) => Number.isNaN(v))) return null |
| 99 | return { |
| 100 | r: Math.max(0, Math.min(255, parts[0])), |
| 101 | g: Math.max(0, Math.min(255, parts[1])), |
| 102 | b: Math.max(0, Math.min(255, parts[2])), |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | function mixRgb( |
| 107 | base: { r: number; g: number; b: number }, |
no test coverage detected