summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2015-05-20 00:23:21 +0200
committerWuzzy <almikes@aol.com>2015-05-20 00:23:21 +0200
commitfb2cf988de91682c7da2c6e4e169b8068d11899a (patch)
treefaa782fb358da13e59b7e7231570b55d6b2360d6
parent390c24c1930067bf6ec28a1d8ca933a361d3c7fb (diff)
Bar length is now rounded towards nearest integer
-rw-r--r--init.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 85cd0f1..6a66c90 100644
--- a/init.lua
+++ b/init.lua
@@ -81,9 +81,15 @@ function hb.value_to_barlength(value, max)
return 0
else
if hb.settings.bar_type == "progress_bar" then
- return math.ceil((value/max) * hb.settings.max_bar_length)
+ local x
+ if value < 0 then x=-0.5 else x = 0.5 end
+ local ret = math.modf((value/max) * hb.settings.max_bar_length + x)
+ return ret
else
- return math.ceil((value/max) * 20)
+ local x
+ if value < 0 then x=-0.5 else x = 0.5 end
+ local ret = math.modf((value/max) * 20 + x)
+ return ret
end
end
end