From 5f38aadc25533c0d7ddd0b4b87d98361e93aafd1 Mon Sep 17 00:00:00 2001 From: Lukas Hrazky Date: Sun, 25 Oct 2009 12:59:25 +0100 Subject: [PATCH] progressbar/graph: fix rounding and graph drawing Signed-off-by: Lukas Hrazky Signed-off-by: Julien Danjou --- lib/awful/widget/graph.lua.in | 5 +++-- lib/awful/widget/progressbar.lua.in | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/awful/widget/graph.lua.in b/lib/awful/widget/graph.lua.in index a65647df..1841a0cb 100644 --- a/lib/awful/widget/graph.lua.in +++ b/lib/awful/widget/graph.lua.in @@ -112,9 +112,10 @@ local function update(graph) if value >= 0 then value = value / max_value img:draw_line(data[graph].width - border_width - i - 1, - border_width + ((data[graph].height - 2 * border_width) * (1 - value)), + border_width - 1 + + math.floor(((data[graph].height - 2 * border_width) * (1 - value)) + 0.5), data[graph].width - border_width - i - 1, - border_width, + border_width - 1, data[graph].background_color or "#000000aa") end end diff --git a/lib/awful/widget/progressbar.lua.in b/lib/awful/widget/progressbar.lua.in index c12e7b9d..761e7862 100644 --- a/lib/awful/widget/progressbar.lua.in +++ b/lib/awful/widget/progressbar.lua.in @@ -98,7 +98,7 @@ local function update(pbar) rel_height, true, data[pbar].background_color or "#000000aa") else - local rel_x = math.floor(over_drawn_width * data[pbar].value) + local rel_x = math.floor((over_drawn_width * data[pbar].value) + 0.5) img:draw_rectangle(border_width + rel_x, border_width, over_drawn_width - rel_x,