diff options
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()) +} |