MCPcopy Create free account
hub / github.com/freecodexyz/free-code / themeFromOscColor

Function themeFromOscColor

src/utils/systemTheme.ts:60–66  ·  view source on GitHub ↗
(data: string)

Source from the content-addressed store, hash-verified

58 * Returns undefined for unrecognized formats so callers can fall back.
59 */
60export 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
68type Rgb = { r: number; g: number; b: number }
69

Callers

nothing calls this directly

Calls 1

parseOscRgbFunction · 0.85

Tested by

no test coverage detected