From f5e80f5bdcf43b7974064168c3eb0d4e993528df Mon Sep 17 00:00:00 2001 From: hhvn Date: Sun, 19 Nov 2023 14:50:06 +0000 Subject: Create function for drawing percentage usage bars --- status/00-status.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'status/00-status.go') 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 +} -- cgit v1.2.3