From: oetiker Date: Fri, 16 Dec 2011 17:40:15 +0000 (+0000) Subject: backport improved grid-fitting X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1a3301876b5ab7bc193d01dc0392fd59e9ae580b;p=rrdtool-all.git backport improved grid-fitting git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@2244 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_gfx.c b/program/src/rrd_gfx.c index ac0e96fd..c977d566 100644 --- a/program/src/rrd_gfx.c +++ b/program/src/rrd_gfx.c @@ -293,10 +293,10 @@ void gfx_line_fit( line_width = cairo_get_line_width(cr); line_height = line_width; cairo_user_to_device_distance(cr, &line_width, &line_height); - line_width = line_width / 2.0 - (long) (line_width / 2.0); - line_height = line_height / 2.0 - (long) (line_height / 2.0); - *x = (double) ((long) (*x + 0.5)) - line_width; - *y = (double) ((long) (*y + 0.5)) + line_height; + line_width = line_width / 2.0 - ceil(line_width / 2.0); + line_height = line_height / 2.0 - ceil(line_height / 2.0); + *x = ceil(*x - 0.5) - line_width; + *y = ceil(*y + 0.5) + line_height; cairo_device_to_user(cr, x, y); } @@ -312,7 +312,7 @@ void gfx_area_fit( if (!im->gridfit) return; cairo_user_to_device(cr, x, y); - *x = (double) ((long) (*x + 0.5)); - *y = (double) ((long) (*y + 0.5)); + *x = floor(*x); + *y = ceil(*y); cairo_device_to_user(cr, x, y); }