(s: string)
| 173 | // oklab L is 0–1 — both map linearly to 0–255, plenty for the harmony |
| 174 | // assertion below. |
| 175 | const parse = (s: string) => { |
| 176 | const rgb = s.match(/rgba?\(([^)]+)\)/); |
| 177 | if (rgb) { |
| 178 | const parts = rgb[1].split(",").map((p) => parseFloat(p.trim())); |
| 179 | return { r: parts[0], g: parts[1], b: parts[2], a: parts[3] ?? 1 }; |
| 180 | } |
| 181 | const oklab = s.match(/^oklab\(\s*([\d.\-]+)/); |
| 182 | if (oklab) { |
| 183 | const gray = Math.round(parseFloat(oklab[1]) * 255); |
| 184 | return { r: gray, g: gray, b: gray, a: 1 }; |
| 185 | } |
| 186 | const lab = s.match(/^lab\(\s*([\d.\-]+)\s+([\d.\-]+)\s+([\d.\-]+)/); |
| 187 | if (lab) { |
| 188 | const L = parseFloat(lab[1]); |
| 189 | const gray = Math.round((L / 100) * 255); |
| 190 | return { r: gray, g: gray, b: gray, a: 1 }; |
| 191 | } |
| 192 | return null; |
| 193 | }; |
| 194 | const shellRgb = parse(shellBg); |
| 195 | const blockRgb = parse(blockBg); |
| 196 |
no outgoing calls
no test coverage detected