summaryrefslogtreecommitdiff
path: root/status/00-status.go
diff options
context:
space:
mode:
authorhhvn <dev@hhvn.uk>2023-11-19 14:50:06 +0000
committerhhvn <dev@hhvn.uk>2023-11-19 14:50:06 +0000
commitf5e80f5bdcf43b7974064168c3eb0d4e993528df (patch)
treeba3a5214c954ff842f6cce64076c4eabcfa9faf2 /status/00-status.go
parent4722a069233b35efd0b600c973e7a7e9bca01d16 (diff)
Create function for drawing percentage usage bars
Diffstat (limited to 'status/00-status.go')
-rw-r--r--status/00-status.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/status/00-status.go b/status/00-status.go
index 809297b..6fcaf33 100644
--- a/status/00-status.go
+++ b/status/00-status.go
@@ -91,6 +91,10 @@ func blendGYR(percent int) color.Color {
return drw.Blend3(config.Green, config.Yellow, config.Red, percent)
}
+func blendBg(c color.Color) color.Color {
+ return drw.Blend(c, config.Status, 75)
+}
+
func (s *status) furthest(x int) {
if x > s.W {
s.W = x
@@ -107,3 +111,16 @@ 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)
}
+
+func (s *status) drawPercentBar(x, percent int) int {
+ tbpad := 3
+ th := int(config.H) - tbpad * 2 + 1
+ h := int(th * percent / 100)
+ fg := blendGYR(percent)
+ bg := blendBg(fg)
+
+ s.drawRect(x, tbpad - 1, 3, th, bg, true)
+ s.drawRect(x, tbpad + th - h - 1, 3, h, fg, true)
+
+ return 5
+}