diff options
| author | hhvn <dev@hhvn.uk> | 2023-11-19 13:29:12 +0000 |
|---|---|---|
| committer | hhvn <dev@hhvn.uk> | 2023-11-19 13:30:04 +0000 |
| commit | 3ad7ace9c1cc88b4ec4eed8c4eee801e1f659110 (patch) | |
| tree | fb6fe064518626fd44783ab65a1f1c4acc8b1cb3 /drw/drw.go | |
| parent | 19781aeb974bd20c421a6b4677ffab348df8faf9 (diff) | |
Color blending
Diffstat (limited to 'drw/drw.go')
| -rw-r--r-- | drw/drw.go | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -7,6 +7,7 @@ import ( "hhvn.uk/hbspbar/config" "github.com/jezek/xgbutil/xgraphics" + col "github.com/lucasb-eyer/go-colorful" "github.com/BurntSushi/freetype-go/freetype" ) @@ -52,3 +53,20 @@ func AddImg(dst *image.RGBA, x, w int, src *image.RGBA) { r := image.Rect(x, 0, x + w, int(config.H)) draw.Draw(dst, r, src, image.Pt(0,0), draw.Src) } + +func Blend3(a, b, c uint32, percent int) uint32 { + if percent <= 50 { + return Blend(a, b, percent * 2) + } else { + return Blend(b, c, (percent - 50) * 2) + } +} + +// Conversion hell, I know +func Blend(a, b uint32, percent int) uint32 { + ac, _ := col.MakeColor(int2rgb(a)) + bc, _ := col.MakeColor(int2rgb(b)) + + + return rgb2int(ac.BlendHcl(bc, float64(percent) / 100).Clamped()) +} |