mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 15:04:50 +02:00
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:
21
tools/utils/colors.go
Normal file
21
tools/utils/colors.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user