From 19781aeb974bd20c421a6b4677ffab348df8faf9 Mon Sep 17 00:00:00 2001 From: hhvn Date: Sat, 18 Nov 2023 19:50:26 +0000 Subject: Statuses --- drw/drw.go | 10 ++++++++++ drw/x.go | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'drw') diff --git a/drw/drw.go b/drw/drw.go index a0844c8..a0b3579 100644 --- a/drw/drw.go +++ b/drw/drw.go @@ -2,6 +2,7 @@ package drw // import "hhvn.uk/hbspbar/drw" import ( "image" + "image/draw" "hhvn.uk/hbspbar/config" @@ -10,6 +11,10 @@ import ( ) func DrawText(i *image.RGBA, x int, col uint32, text string) (int, error) { + ft := freetype.NewContext() + ft.SetDPI(72) + ft.SetFont(font) + ft.SetFontSize(config.FontSize) ft.SetClip(i.Bounds()) ft.SetDst(i) @@ -42,3 +47,8 @@ func DrawRect(i *image.RGBA, x, y, w, h int, c uint32, fill bool) { } } } + +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) +} diff --git a/drw/x.go b/drw/x.go index 808c1fb..1806410 100644 --- a/drw/x.go +++ b/drw/x.go @@ -14,7 +14,6 @@ import ( "github.com/jezek/xgbutil/icccm" "github.com/jezek/xgbutil/ewmh" "github.com/jezek/xgbutil/xgraphics" - "github.com/BurntSushi/freetype-go/freetype" "github.com/BurntSushi/freetype-go/freetype/truetype" ) @@ -30,7 +29,6 @@ var xc *xgb.Conn var xu *xgbutil.XUtil var screen *xproto.ScreenInfo var font *truetype.Font -var ft *freetype.Context func init() { var err error @@ -62,11 +60,6 @@ func init() { return } - ft = freetype.NewContext() - ft.SetDPI(72) - ft.SetFont(font) - ft.SetFontSize(config.FontSize) - Events := make(chan *eventwrap) go func() { for { -- cgit v1.2.3