From 47495c50e32628b7120781a072ba0f275da6718c Mon Sep 17 00:00:00 2001 From: marco candrian Date: Thu, 17 Apr 2008 05:03:37 +0200 Subject: [PATCH] [draw] provide the middle of a pixel to make sure it draws/fills that particular pixel/line Fixes FS#162 now also on my PC in any way (it filled the pixels on the right when a gradient was given, else the one on the left of x. Signed-off-by: Julien Danjou --- common/draw.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/draw.c b/common/draw.c index fc80a7237..bc2342b64 100644 --- a/common/draw.c +++ b/common/draw.c @@ -431,13 +431,15 @@ draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index, Position grow, area_t patt_rect, XColor *pcolor, XColor *pcolor_center, XColor *pcolor_end) { - int i, x, y, w; + int i, y, w; + float x; cairo_pattern_t *pat; pat = draw_setup_cairo_color_source(ctx, patt_rect, pcolor, pcolor_center, pcolor_end); - x = rect.x; + /* middle of a pixel */ + x = rect.x + 0.5; y = rect.y; w = rect.width; @@ -449,7 +451,7 @@ draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index, { cairo_move_to(ctx->cr, x, y - from[cur_index]); cairo_line_to(ctx->cr, x, y - to[cur_index]); - x--; + x -= 1.0; if (--cur_index < 0) cur_index = w - 1; @@ -461,7 +463,7 @@ draw_graph(DrawCtx *ctx, area_t rect, int *from, int *to, int cur_index, { cairo_move_to(ctx->cr, x, y - from[cur_index]); cairo_line_to(ctx->cr, x, y - to[cur_index]); - x++; + x += 1.0; if (--cur_index < 0) cur_index = w - 1; @@ -536,7 +538,6 @@ draw_graph_line(DrawCtx *ctx, area_t rect, int *to, int cur_index, if (--cur_index < 0) /* cycles around the index */ cur_index = w - 1; - } cairo_stroke(ctx->cr);