Commit e86dff66 authored by Simon Budig's avatar Simon Budig Committed by Simon Budig

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.
parent d6a016b4
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
......
......@@ -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);
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);
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;
stroke = gimp_bezier_stroke_new_moveto (&a);
handle->position.x = cx - radius_x;
handle->position.y = cy - radius_y * circlemagic;
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_stroke_close (stroke);
return stroke;
}
......
......@@ -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);
}
......
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