(data: string)
| 58 | * Returns undefined for unrecognized formats so callers can fall back. |
| 59 | */ |
| 60 | export function themeFromOscColor(data: string): SystemTheme | undefined { |
| 61 | const rgb = parseOscRgb(data) |
| 62 | if (!rgb) return undefined |
| 63 | // ITU-R BT.709 relative luminance. Midpoint split: > 0.5 is light. |
| 64 | const luminance = 0.2126 * rgb.r + 0.7152 * rgb.g + 0.0722 * rgb.b |
| 65 | return luminance > 0.5 ? 'light' : 'dark' |
| 66 | } |
| 67 | |
| 68 | type Rgb = { r: number; g: number; b: number } |
| 69 |
nothing calls this directly
no test coverage detected