summaryrefslogtreecommitdiff
path: root/drw
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-11-18 19:50:26 +0000
committerhhvn <dev@hhvn.uk>2023-11-18 19:56:13 +0000
commit19781aeb974bd20c421a6b4677ffab348df8faf9 (patch)
tree22bde9a97fdc36f6d412203319f797cf168986d9 /drw
parent505685c6d546cab46f919f6b5296ca73b80d09b2 (diff)
Statuses
Diffstat (limited to 'drw')
-rw-r--r--drw/drw.go10
-rw-r--r--drw/x.go7
2 files changed, 10 insertions, 7 deletions
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 {