Commit b7481132 authored by Michael Natterer's avatar Michael Natterer 😴

app: don't use PROJ_ROUND() for pixel-adjusting canvas item drawing

When PROJ_ROUND()ing e.g. 3.8, it ends up at 4, then we added the 0.5
offset to draw a nice cairo line in the middle of the pixel,
effectively drawing a line that's meant to be at 3.8 at 4.5.  Instead,
we now use floor(x)+0.5 now which snaps the above example to 3.5.

Also, calculate arcs like we calculate rectangles (transform the arc's
bounding box and pixel-align that, then recalculate the center), so
arcs properly align with rectangles.
parent 5a3dc38a
......@@ -235,10 +235,6 @@ gimp_canvas_arc_transform (GimpCanvasItem *item,
gdouble x1, y1;
gdouble x2, y2;
gimp_display_shell_transform_xy_f (shell,
private->center_x,
private->center_y,
center_x, center_y);
gimp_display_shell_transform_xy_f (shell,
private->center_x - private->radius_x,
private->center_y - private->radius_y,
......@@ -248,6 +244,14 @@ gimp_canvas_arc_transform (GimpCanvasItem *item,
private->center_y + private->radius_y,
&x2, &y2);
x1 = floor (x1);
y1 = floor (y1);
x2 = ceil (x2);
y2 = ceil (y2);
*center_x = (x1 + x2) / 2.0;
*center_y = (y1 + y2) / 2.0;
*radius_x = (x2 - x1) / 2.0;
*radius_y = (y2 - y1) / 2.0;
......
......@@ -267,10 +267,10 @@ gimp_canvas_corner_transform (GimpCanvasItem *item,
rw -= rx;
rh -= ry;
rx = PROJ_ROUND (rx) + 0.5;
ry = PROJ_ROUND (ry) + 0.5;
rw = PROJ_ROUND (rw) - 1.0;
rh = PROJ_ROUND (rh) - 1.0;
rx = floor (rx) + 0.5;
ry = floor (ry) + 0.5;
rw = ceil (rw) - 1.0;
rh = ceil (rh) - 1.0;
top_and_bottom_handle_x_offset = (rw - private->corner_width) / 2;
left_and_right_handle_y_offset = (rh - private->corner_height) / 2;
......
......@@ -406,8 +406,8 @@ gimp_canvas_handle_transform (GimpCanvasItem *item,
break;
}
*x = PROJ_ROUND (*x) + 0.5;
*y = PROJ_ROUND (*y) + 0.5;
*x = floor (*x) + 0.5;
*y = floor (*y) + 0.5;
}
static void
......
......@@ -200,10 +200,10 @@ gimp_canvas_line_transform (GimpCanvasItem *item,
private->x2, private->y2,
x2, y2);
*x1 = PROJ_ROUND (*x1) + 0.5;
*y1 = PROJ_ROUND (*y1) + 0.5;
*x2 = PROJ_ROUND (*x2) + 0.5;
*y2 = PROJ_ROUND (*y2) + 0.5;
*x1 = floor (*x1) + 0.5;
*y1 = floor (*y1) + 0.5;
*x2 = floor (*x2) + 0.5;
*y2 = floor (*y2) + 0.5;
}
static void
......
......@@ -213,8 +213,8 @@ gimp_canvas_polygon_transform (GimpCanvasItem *item,
&points[i].x,
&points[i].y);
points[i].x = PROJ_ROUND (points[i].x) + 0.5;
points[i].y = PROJ_ROUND (points[i].y) + 0.5;
points[i].x = floor (points[i].x) + 0.5;
points[i].y = floor (points[i].y) + 0.5;
}
}
......
......@@ -232,10 +232,10 @@ gimp_canvas_rectangle_transform (GimpCanvasItem *item,
}
else
{
*x = PROJ_ROUND (*x) + 0.5;
*y = PROJ_ROUND (*y) + 0.5;
*w = PROJ_ROUND (*w) - 1.0;
*h = PROJ_ROUND (*h) - 1.0;
*x = floor (*x) + 0.5;
*y = floor (*y) + 0.5;
*w = ceil (*w) - 1.0;
*h = ceil (*h) - 1.0;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment