MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / luminance

Function luminance

desktop/runtime-host/theme-service.ts:86–94  ·  view source on GitHub ↗
(hex: string | undefined)

Source from the content-addressed store, hash-verified

84}
85
86function luminance(hex: string | undefined) {
87 const rgb = hexToRgb(hex)
88 if (!rgb) return 0
89 const channel = (value: number) => {
90 const normalized = value / 255
91 return normalized <= 0.03928 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4
92 }
93 return 0.2126 * channel(rgb.r) + 0.7152 * channel(rgb.g) + 0.0722 * channel(rgb.b)
94}
95
96function isResolvedLightTheme(
97 themeName: string,

Callers 1

isResolvedLightThemeFunction · 0.70

Calls 2

hexToRgbFunction · 0.70
channelFunction · 0.70

Tested by

no test coverage detected