From 3ad7ace9c1cc88b4ec4eed8c4eee801e1f659110 Mon Sep 17 00:00:00 2001 From: hhvn Date: Sun, 19 Nov 2023 13:29:12 +0000 Subject: Color blending --- drw/x.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'drw/x.go') diff --git a/drw/x.go b/drw/x.go index 1806410..c004d78 100644 --- a/drw/x.go +++ b/drw/x.go @@ -77,6 +77,24 @@ func int2rgb(argb uint32) (color.RGBA) { A: uint8((argb & 0xff000000) >> 24) } } +func rgb2int(c color.Color) uint32 { + r, g, b, a := c.RGBA() + + r /= 256 + g /= 256 + b /= 256 + a /= 256 + + var ret uint32 = 0 + + ret |= (a << 24) + ret |= (r << 16) + ret |= (g << 8) + ret |= b + + return ret +} + type Window struct { id xproto.Window } -- cgit v1.2.3