MCPcopy Create free account
hub / github.com/GCWing/BitFun / relative_luminance

Function relative_luminance

src/apps/cli/src/ui/theme.rs:576–587  ·  view source on GitHub ↗
(r: u8, g: u8, b: u8)

Source from the content-addressed store, hash-verified

574}
575
576fn relative_luminance(r: u8, g: u8, b: u8) -> f64 {
577 fn channel(v: u8) -> f64 {
578 let v = v as f64 / 255.0;
579 if v <= 0.03928 {
580 v / 12.92
581 } else {
582 ((v + 0.055) / 1.055).powf(2.4)
583 }
584 }
585
586 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b)
587}
588
589fn to_ansi16(c: Color) -> Color {
590 match c {

Callers 1

readable_foreground_forFunction · 0.85

Calls 1

channelFunction · 0.85

Tested by

no test coverage detected