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

Function hexToRgb

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

Source from the content-addressed store, hash-verified

74}
75
76function hexToRgb(hex: string | undefined) {
77 const match = hex ? hexColorPattern.exec(hex.trim()) : null
78 if (!match) return null
79 return {
80 r: Number.parseInt(match[1] ?? '0', 16),
81 g: Number.parseInt(match[2] ?? '0', 16),
82 b: Number.parseInt(match[3] ?? '0', 16),
83 }
84}
85
86function luminance(hex: string | undefined) {
87 const rgb = hexToRgb(hex)

Callers 1

luminanceFunction · 0.70

Calls 1

execMethod · 0.80

Tested by

no test coverage detected