diff options
| author | hhvn <dev@hhvn.uk> | 2023-11-18 19:50:26 +0000 |
|---|---|---|
| committer | hhvn <dev@hhvn.uk> | 2023-11-18 19:56:13 +0000 |
| commit | 19781aeb974bd20c421a6b4677ffab348df8faf9 (patch) | |
| tree | 22bde9a97fdc36f6d412203319f797cf168986d9 /drw | |
| parent | 505685c6d546cab46f919f6b5296ca73b80d09b2 (diff) | |
Statuses
Diffstat (limited to 'drw')
| -rw-r--r-- | drw/drw.go | 10 | ||||
| -rw-r--r-- | drw/x.go | 7 |
2 files changed, 10 insertions, 7 deletions
@@ -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) +} @@ -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 { |