mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
internal/f32color: add support for light widgets to Hovered
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -151,11 +151,15 @@ func Disabled(c color.NRGBA) (d color.NRGBA) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hovered blends color towards a brighter color. It is approximate
|
// Hovered blends dark colors towards white, and light colors towards
|
||||||
// because it operates in non-linear sRGB space.
|
// black. It is approximate because it operates in non-linear sRGB space.
|
||||||
func Hovered(c color.NRGBA) (h color.NRGBA) {
|
func Hovered(c color.NRGBA) (h color.NRGBA) {
|
||||||
const r = 0x20 // lighten ratio
|
const ratio = 0x20
|
||||||
return mix(color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: c.A}, c, r)
|
m := color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: c.A}
|
||||||
|
if approxLuminance(c) > 128 {
|
||||||
|
m = color.NRGBA{A: c.A}
|
||||||
|
}
|
||||||
|
return mix(m, c, ratio)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mix mixes c1 and c2 weighted by (1 - a/256) and a/256 respectively.
|
// mix mixes c1 and c2 weighted by (1 - a/256) and a/256 respectively.
|
||||||
|
|||||||
Reference in New Issue
Block a user