[gimp] Bug 672793 - GFig cannot paint closed paths outside of the layer
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 672793 - GFig cannot paint closed paths outside of the layer
- Date: Sun, 25 Mar 2012 13:38:24 +0000 (UTC)
commit 34000d4ce24f19687748d00f9a1f064d9c6f5e4b
Author: Alexis Wilhelm <alexiswilhelm gmail com>
Date: Sun Mar 25 13:24:55 2012 +0200
Bug 672793 - GFig cannot paint closed paths outside of the layer
plug-ins/gfig/gfig-circle.c | 27 ++++++++++++++++++++++-----
plug-ins/gfig/gfig-dialog.c | 2 --
plug-ins/gfig/gfig-ellipse.c | 25 +++++++++++++++++++------
plug-ins/gfig/gfig-poly.c | 3 ++-
plug-ins/gfig/gfig-rectangle.c | 9 ++++++++-
plug-ins/gfig/gfig-star.c | 3 ++-
6 files changed, 53 insertions(+), 16 deletions(-)
---
diff --git a/plug-ins/gfig/gfig-circle.c b/plug-ins/gfig/gfig-circle.c
index 0b58524..0120a0a 100644
--- a/plug-ins/gfig/gfig-circle.c
+++ b/plug-ins/gfig/gfig-circle.c
@@ -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 *
diff --git a/plug-ins/gfig/gfig-dialog.c b/plug-ins/gfig/gfig-dialog.c
index 6924f32..ad6c5a5 100644
--- a/plug-ins/gfig/gfig-dialog.c
+++ b/plug-ins/gfig/gfig-dialog.c
@@ -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);
diff --git a/plug-ins/gfig/gfig-ellipse.c b/plug-ins/gfig/gfig-ellipse.c
index 1e9dd81..5ff0aff 100644
--- a/plug-ins/gfig/gfig-ellipse.c
+++ b/plug-ins/gfig/gfig-ellipse.c
@@ -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 *
diff --git a/plug-ins/gfig/gfig-poly.c b/plug-ins/gfig/gfig-poly.c
index 4b48048..7a073c5 100644
--- a/plug-ins/gfig/gfig-poly.c
+++ b/plug-ins/gfig/gfig-poly.c
@@ -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);
diff --git a/plug-ins/gfig/gfig-rectangle.c b/plug-ins/gfig/gfig-rectangle.c
index 2178638..6baf6a9 100644
--- a/plug-ins/gfig/gfig-rectangle.c
+++ b/plug-ins/gfig/gfig-rectangle.c
@@ -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 *
diff --git a/plug-ins/gfig/gfig-star.c b/plug-ins/gfig/gfig-star.c
index feb1f5a..ca995c7 100644
--- a/plug-ins/gfig/gfig-star.c
+++ b/plug-ins/gfig/gfig-star.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]