mirror of https://github.com/GNOME/gimp.git
add a small EPSILON to the brush coordinates before rounding them (fixes
2003-07-16 Michael Natterer <mitch@gimp.org> * app/tools/gimppainttool.c (gimp_paint_tool_draw): add a small EPSILON to the brush coordinates before rounding them (fixes off-by-one floating point rounding fnord for "hard edge" painting where e.g. (5.0 - (3.0 / 2.0)) was rounded to 3.0 instead of 4.0). * app/tools/gimpdrawtool.c (gimp_draw_tool_draw_boundary): use RINT() instead of floor() to round the transformed boundary to GdkSegments.
This commit is contained in:
parent
30934d2395
commit
30e041cd79
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2003-07-16 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimppainttool.c (gimp_paint_tool_draw): add a small
|
||||
EPSILON to the brush coordinates before rounding them (fixes
|
||||
off-by-one floating point rounding fnord for "hard edge" painting
|
||||
where e.g. (5.0 - (3.0 / 2.0)) was rounded to 3.0 instead of 4.0).
|
||||
|
||||
* app/tools/gimpdrawtool.c (gimp_draw_tool_draw_boundary): use
|
||||
RINT() instead of floor() to round the transformed boundary to
|
||||
GdkSegments.
|
||||
|
||||
2003-07-16 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimptransformtool.[ch]: implemented transforming of
|
||||
|
|
|
@ -182,8 +182,8 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
|||
|
||||
paint_tool->brush_bound_segs = NULL;
|
||||
paint_tool->n_brush_bound_segs = 0;
|
||||
paint_tool->brush_x = 0;
|
||||
paint_tool->brush_y = 0;
|
||||
paint_tool->brush_x = 0.0;
|
||||
paint_tool->brush_y = 0.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -734,8 +734,16 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||
|
||||
if (paint_options->hard)
|
||||
{
|
||||
brush_x = RINT (brush_x);
|
||||
brush_y = RINT (brush_y);
|
||||
#define EPSILON 0.000001
|
||||
|
||||
/* Add EPSILON before rounding since e.g.
|
||||
* (5.0 - 0.5) may end up at (4.499999999....)
|
||||
* due to floating point fnords
|
||||
*/
|
||||
brush_x = RINT (brush_x + EPSILON);
|
||||
brush_y = RINT (brush_y + EPSILON);
|
||||
|
||||
#undef EPSILON
|
||||
}
|
||||
|
||||
gimp_draw_tool_draw_boundary (draw_tool,
|
||||
|
|
|
@ -835,8 +835,8 @@ gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
|
|||
&x, &y,
|
||||
FALSE);
|
||||
|
||||
gdk_segs[n_gdk_segs].x1 = floor (CLAMP (x, -1, xmax));
|
||||
gdk_segs[n_gdk_segs].y1 = floor (CLAMP (y, -1, ymax));
|
||||
gdk_segs[n_gdk_segs].x1 = RINT (CLAMP (x, -1, xmax));
|
||||
gdk_segs[n_gdk_segs].y1 = RINT (CLAMP (y, -1, ymax));
|
||||
|
||||
gimp_display_shell_transform_xy_f (shell,
|
||||
bound_segs[i].x2 + offset_x,
|
||||
|
@ -844,8 +844,8 @@ gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
|
|||
&x, &y,
|
||||
FALSE);
|
||||
|
||||
gdk_segs[n_gdk_segs].x2 = floor (CLAMP (x, -1, xmax));
|
||||
gdk_segs[n_gdk_segs].y2 = floor (CLAMP (y, -1, ymax));
|
||||
gdk_segs[n_gdk_segs].x2 = RINT (CLAMP (x, -1, xmax));
|
||||
gdk_segs[n_gdk_segs].y2 = RINT (CLAMP (y, -1, ymax));
|
||||
|
||||
if (gdk_segs[n_gdk_segs].x1 == gdk_segs[n_gdk_segs].x2 &&
|
||||
gdk_segs[n_gdk_segs].y1 == gdk_segs[n_gdk_segs].y2)
|
||||
|
|
|
@ -182,8 +182,8 @@ gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
|||
|
||||
paint_tool->brush_bound_segs = NULL;
|
||||
paint_tool->n_brush_bound_segs = 0;
|
||||
paint_tool->brush_x = 0;
|
||||
paint_tool->brush_y = 0;
|
||||
paint_tool->brush_x = 0.0;
|
||||
paint_tool->brush_y = 0.0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -734,8 +734,16 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||
|
||||
if (paint_options->hard)
|
||||
{
|
||||
brush_x = RINT (brush_x);
|
||||
brush_y = RINT (brush_y);
|
||||
#define EPSILON 0.000001
|
||||
|
||||
/* Add EPSILON before rounding since e.g.
|
||||
* (5.0 - 0.5) may end up at (4.499999999....)
|
||||
* due to floating point fnords
|
||||
*/
|
||||
brush_x = RINT (brush_x + EPSILON);
|
||||
brush_y = RINT (brush_y + EPSILON);
|
||||
|
||||
#undef EPSILON
|
||||
}
|
||||
|
||||
gimp_draw_tool_draw_boundary (draw_tool,
|
||||
|
|
Loading…
Reference in New Issue