Implemented the ellipse basic shape differently to avoid possible rounding

2004-08-22  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpbezierstroke.c: Implemented the ellipse basic
	shape differently to avoid possible rounding issues with
	the _arcto () command.

	* app/vectors/gimpvectors-import.c: properly close the rounded
	rectangles.
This commit is contained in:
Simon Budig 2004-08-22 12:31:47 +00:00 committed by Simon Budig
parent d6a016b4b4
commit e86dff66da
3 changed files with 61 additions and 21 deletions

View File

@ -1,3 +1,12 @@
2004-08-22 Simon Budig <simon@gimp.org>
* app/vectors/gimpbezierstroke.c: Implemented the ellipse basic
shape differently to avoid possible rounding issues with
the _arcto () command.
* app/vectors/gimpvectors-import.c: properly close the rounded
rectangles.
2004-08-21 Sven Neumann <sven@gimp.org>
* app/vectors/gimpvectors-import.c (parse_svg_transform): support

View File

@ -1759,25 +1759,57 @@ gimp_bezier_stroke_new_ellipse (const GimpCoords *center,
gdouble radius_x,
gdouble radius_y)
{
GimpStroke *stroke;
GimpCoords a = *center;
GimpCoords b = *center;
GimpStroke *stroke;
GimpCoords p1 = *center;
GimpCoords p2 = *center;
GimpCoords p3 = *center;
gdouble cx = center->x;
gdouble cy = center->y;
const gdouble circlemagic = 4.0 * (G_SQRT2 - 1.0) / 3.0;
GimpAnchor *handle;
if (radius_x > radius_y)
{
a.x -= radius_x;
b.x += radius_x;
}
else
{
a.y -= radius_y;
b.y += radius_y;
}
p1.x = cx - radius_x;
p1.y = cy;
stroke = gimp_bezier_stroke_new_moveto (&p1);
stroke = gimp_bezier_stroke_new_moveto (&a);
p1.x = cx - radius_x;
p1.y = cy + radius_y * circlemagic;
p2.x = cx - radius_x * circlemagic;
p2.y = cy + radius_y;
p3.x = cx;
p3.y = cy + radius_y;
gimp_bezier_stroke_arcto (stroke, radius_x, radius_y, 0, TRUE, FALSE, &b);
gimp_bezier_stroke_arcto (stroke, radius_x, radius_y, 0, TRUE, FALSE, &a);
gimp_bezier_stroke_cubicto (stroke, &p1, &p2, &p3);
p1.x = cx + radius_x * circlemagic;
p1.y = cy + radius_y;
p2.x = cx + radius_x;
p2.y = cy + radius_y * circlemagic;
p3.x = cx + radius_x;
p3.y = cy;
gimp_bezier_stroke_cubicto (stroke, &p1, &p2, &p3);
p1.x = cx + radius_x;
p1.y = cy - radius_y * circlemagic;
p2.x = cx + radius_x * circlemagic;
p2.y = cy - radius_y;
p3.x = cx;
p3.y = cy - radius_y;
gimp_bezier_stroke_cubicto (stroke, &p1, &p2, &p3);
handle = g_list_first (GIMP_STROKE (stroke)->anchors)->data;
handle->position.x = cx - radius_x * circlemagic;
handle->position.y = cy - radius_y;
handle = g_list_last (GIMP_STROKE (stroke)->anchors)->data;
handle->position.x = cx - radius_x;
handle->position.y = cy - radius_y * circlemagic;
gimp_stroke_close (stroke);
return stroke;
}

View File

@ -679,13 +679,9 @@ svg_handler_rect_start (SvgHandler *handler,
rx = MIN (rx, width / 2);
ry = MIN (ry, height / 2);
point.x = x + rx;
point.y = y;
stroke = gimp_bezier_stroke_new_moveto (&point);
point.x = x + width - rx;
point.y = y;
gimp_bezier_stroke_lineto (stroke, &point);
stroke = gimp_bezier_stroke_new_moveto (&point);
if (rx)
{
@ -723,6 +719,9 @@ svg_handler_rect_start (SvgHandler *handler,
gimp_bezier_stroke_arcto (stroke, rx, ry, 0, FALSE, TRUE, &end);
}
/* the last line is handled by closing the stroke */
gimp_stroke_close (stroke);
path->strokes = g_list_prepend (path->strokes, stroke);
}