hints kitten: Workaround for some broken light color themes that make the hints text color too low contrast to read

Fixes #7330
This commit is contained in:
Kovid Goyal
2025-01-17 20:22:10 +05:30
parent 182bd9c7b3
commit 8931062a70
5 changed files with 77 additions and 2 deletions

21
tools/utils/colors.go Normal file
View File

@@ -0,0 +1,21 @@
package utils
import (
"fmt"
)
var _ = fmt.Print
func RGBLuminance(r, g, b float32) float32 {
// From ITU BT 601 https://www.itu.int/rec/R-REC-BT.601
return 0.299*r + 0.587*g + 0.114*b
}
func RGBContrast(r1, g1, b1, r2, g2, b2 float32) float32 {
al := RGBLuminance(r1, g1, b1)
bl := RGBLuminance(r2, g2, b2)
if al < bl {
al, bl = bl, al
}
return (al + 0.05) / (bl + 0.05)
}