Bug 672793 - GFig cannot paint closed paths outside of the layer

This commit is contained in:
Alexis Wilhelm 2012-03-25 13:24:55 +02:00 committed by Mikael Magnusson
parent c3230a7a2f
commit 34000d4ce2
6 changed files with 53 additions and 16 deletions

View File

@ -93,10 +93,6 @@ d_paint_circle (GfigObject *obj)
g_assert (obj != NULL);
/* Drawing circles is hard .
* 1) select circle
* 2) stroke it
*/
center_pnt = obj->points;
if (!center_pnt)
@ -135,9 +131,30 @@ d_paint_circle (GfigObject *obj)
center_pnt->pnt.y - radius,
center_pnt->pnt.x + radius,
center_pnt->pnt.y + radius);
gimp_selection_none (gfig_context->image_id);
/* Drawing a circle may be harder than stroking a circular selection,
* but we have to do it or we will not be able to draw outside of the
* layer. */
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
{
const gdouble r = dpnts[2] / 2;
const gdouble cx = dpnts[0] + r, cy = dpnts[1] + r;
gdouble line_pnts[362];
gdouble angle = 0;
gint i = 0;
while (i < 362)
{
static const gdouble step = 2 * G_PI / 180;
line_pnts[i++] = cx + r * cos (angle);
line_pnts[i++] = cy + r * sin (angle);
angle += step;
}
gfig_paint (selvals.brshtype, gfig_context->drawable_id, i, line_pnts);
}
}
static GfigObject *

View File

@ -2009,8 +2009,6 @@ gfig_paint_callback (void)
gfig_context_get_current_style ()->fill_type = object->style.fill_type;
object->class->paintfunc (object);
gfig_context_get_current_style ()->fill_type = saved_filltype;
gimp_selection_none (gfig_context->image_id);
}
objs = g_list_next (objs);

View File

@ -86,11 +86,6 @@ d_paint_ellipse (GfigObject *obj)
gint top_y;
gdouble dpnts[4];
/* Drawing ellipse is hard .
* 1) select ellipse
* 2) stroke it
*/
g_assert (obj != NULL);
center_pnt = obj->points;
@ -140,9 +135,27 @@ d_paint_ellipse (GfigObject *obj)
gimp_context_pop ();
paint_layer_fill (top_x, top_y, top_x + bound_wx, top_y + bound_wy);
gimp_selection_none (gfig_context->image_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
{
const gdouble rx = dpnts[2] / 2, ry = dpnts[3] / 2;
const gdouble cx = dpnts[0] + rx, cy = dpnts[1] + ry;
gdouble line_pnts[362];
gdouble angle = 0;
gint i = 0;
while (i < 362)
{
static const gdouble step = 2 * G_PI / 180;
line_pnts[i++] = cx + rx * cos (angle);
line_pnts[i++] = cy + ry * sin (angle);
angle += step;
}
gfig_paint (selvals.brshtype, gfig_context->drawable_id, i, line_pnts);
}
}
static GfigObject *

View File

@ -258,9 +258,10 @@ d_paint_poly (GfigObject *obj)
gimp_context_pop ();
paint_layer_fill (min_max[0], min_max[1], min_max[2], min_max[3]);
gimp_selection_none (gfig_context->image_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
gfig_paint (selvals.brshtype, gfig_context->drawable_id, i, line_pnts);
g_free (line_pnts);
g_free (min_max);

View File

@ -126,9 +126,16 @@ d_paint_rectangle (GfigObject *obj)
gimp_context_pop ();
paint_layer_fill (dpnts[0], dpnts[1], dpnts[2], dpnts[3]);
gimp_selection_none (gfig_context->image_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
{
gdouble line_pnts[] = { dpnts[0], dpnts[1], dpnts[2], dpnts[1],
dpnts[2], dpnts[3], dpnts[0], dpnts[3],
dpnts[0], dpnts[1] };
gfig_paint (selvals.brshtype, gfig_context->drawable_id, 10, line_pnts);
}
}
static GfigObject *

View File

@ -319,9 +319,10 @@ d_paint_star (GfigObject *obj)
gimp_context_pop ();
paint_layer_fill (min_max[0], min_max[1], min_max[2], min_max[3]);
gimp_selection_none (gfig_context->image_id);
if (obj->style.paint_type == PAINT_BRUSH_TYPE)
gimp_edit_stroke (gfig_context->drawable_id);
gfig_paint (selvals.brshtype, gfig_context->drawable_id, i, line_pnts);
g_free (line_pnts);
g_free (min_max);