progressbar/graph: fix rounding and graph drawing
Signed-off-by: Lukas Hrazky <lukkash@email.cz> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
7f7ffca497
commit
5f38aadc25
|
@ -112,9 +112,10 @@ local function update(graph)
|
||||||
if value >= 0 then
|
if value >= 0 then
|
||||||
value = value / max_value
|
value = value / max_value
|
||||||
img:draw_line(data[graph].width - border_width - i - 1,
|
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,
|
data[graph].width - border_width - i - 1,
|
||||||
border_width,
|
border_width - 1,
|
||||||
data[graph].background_color or "#000000aa")
|
data[graph].background_color or "#000000aa")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,7 +98,7 @@ local function update(pbar)
|
||||||
rel_height,
|
rel_height,
|
||||||
true, data[pbar].background_color or "#000000aa")
|
true, data[pbar].background_color or "#000000aa")
|
||||||
else
|
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,
|
img:draw_rectangle(border_width + rel_x,
|
||||||
border_width,
|
border_width,
|
||||||
over_drawn_width - rel_x,
|
over_drawn_width - rel_x,
|
||||||
|
|
Loading…
Reference in New Issue