summaryrefslogtreecommitdiff
path: root/status/00-status.go
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-11-19 13:49:28 +0000
committerhhvn <dev@hhvn.uk>2023-11-19 13:49:28 +0000
commit4722a069233b35efd0b600c973e7a7e9bca01d16 (patch)
treee7caa92c65932651e81b201edfcf704886aa2660 /status/00-status.go
parent1c46de9342a93cf8284d2bd4ed58f524cda60b29 (diff)
Do int2rgb conversions once. In config.go.
Diffstat (limited to 'status/00-status.go')
-rw-r--r--status/00-status.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/status/00-status.go b/status/00-status.go
index e88011d..809297b 100644
--- a/status/00-status.go
+++ b/status/00-status.go
@@ -5,6 +5,7 @@ import (
"time"
"sync"
"image"
+ "image/color"
"hhvn.uk/hbspbar/drw"
"hhvn.uk/hbspbar/config"
@@ -18,13 +19,6 @@ var Updated chan bool
var updates chan *status
const (
- Red = 0xffaa2222
- Orange = 0xffaa7700
- Green = 0xff00aa00
- Black = 0xff000000
- Grey = 0xff888888
- Yellow = 0xffaaaa00
- White = 0xffcccccc
)
func init() {
@@ -83,7 +77,7 @@ func checkError(name string, err error) {
common.Error("status \"%s\": %s\n", name, err)
u := newUpdate(name)
- u.drawText(0, Red, fmt.Sprintf("[err: %s]", name))
+ u.drawText(0, config.Red, fmt.Sprintf("[err: %s]", name))
updates <- u
sleep(5)
@@ -93,8 +87,8 @@ func sleep(s int) {
time.Sleep(time.Duration(s) * time.Second)
}
-func blendGYR(percent int) uint32 {
- return drw.Blend3(Green, Yellow, Red, percent)
+func blendGYR(percent int) color.Color {
+ return drw.Blend3(config.Green, config.Yellow, config.Red, percent)
}
func (s *status) furthest(x int) {
@@ -103,13 +97,13 @@ func (s *status) furthest(x int) {
}
}
-func (s *status) drawText(x int, col uint32, text string) (int, error) {
+func (s *status) drawText(x int, col color.Color, text string) (int, error) {
w, err := drw.DrawText(s.I, x, col, text)
s.furthest(x + w)
return w, err
}
-func (s *status) drawRect(x, y, w, h int, c uint32, fill bool) {
+func (s *status) drawRect(x, y, w, h int, c color.Color, fill bool) {
drw.DrawRect(s.I, x, y, w, h, c, fill)
s.furthest(x + w)
}