From 846acda3cf76d9cb53d968dc107e5516a0eb9bc2 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 16 Dec 2011 17:39:14 +0000 Subject: [PATCH] fix grid fitting for corner cases git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2243 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_gfx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/program/src/rrd_gfx.c b/program/src/rrd_gfx.c index 416b8a32..c01a6618 100644 --- a/program/src/rrd_gfx.c +++ b/program/src/rrd_gfx.c @@ -329,10 +329,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); } @@ -348,7 +348,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); } -- 2.30.2