From 2c212214fe3f25cb70c29dcaf97ab0b7d0865119 Mon Sep 17 00:00:00 2001 From: Simon Budig Date: Mon, 22 Sep 2003 23:19:22 +0000 Subject: [PATCH] Fixed vectors stroking on GRAY* and INDEXED* layers. 2003-09-23 Simon Budig * app/core/gimpdrawable-stroke.c: Fixed vectors stroking on GRAY* and INDEXED* layers. * app/tools/gimpvectortool.c: Made the polygonal mode more consistent. --- ChangeLog | 8 ++++++ app/core/gimpdrawable-stroke.c | 11 ++++++-- app/tools/gimpvectortool.c | 48 ++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index d485f0a03c..760d17376e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2003-09-23 Simon Budig + + * app/core/gimpdrawable-stroke.c: Fixed vectors stroking on + GRAY* and INDEXED* layers. + + * app/tools/gimpvectortool.c: Made the polygonal mode more + consistent. + 2003-09-23 Jakub Steiner * themes/Default/images/stock-close-12.png diff --git a/app/core/gimpdrawable-stroke.c b/app/core/gimpdrawable-stroke.c index 20969ff26e..26030323f4 100644 --- a/app/core/gimpdrawable-stroke.c +++ b/app/core/gimpdrawable-stroke.c @@ -66,8 +66,9 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable, TileManager *base; TileManager *mask; gint x1, x2, y1, y2, bytes, w, h; - guchar ucolor[4] = { 255, 127, 0, 255 }; + guchar ucolor[4] = { 0, 0, 0, 255 }; guchar bg[1] = { 0, }; + guchar *src_bytes; PixelRegion maskPR, basePR; /* what area do we operate on? */ @@ -137,12 +138,18 @@ gimp_drawable_stroke_vectors (GimpDrawable *drawable, if (!gimp_drawable_has_alpha (drawable)) bytes++; + src_bytes = g_malloc0 (bytes); + /* Fill a TileManager with the stroke color */ gimp_rgb_get_uchar (color, &(ucolor[0]), &(ucolor[1]), &(ucolor[2])); + src_bytes[bytes - 1] = OPAQUE_OPACITY; + gimp_image_transform_color (GIMP_ITEM (drawable)->gimage, drawable, + src_bytes, GIMP_RGB, ucolor); base = tile_manager_new (w, h, bytes); tile_manager_set_offsets (base, x1+x2, y1+y2); pixel_region_init (&basePR, base, 0, 0, w, h, TRUE); - color_region (&basePR, ucolor); + color_region (&basePR, src_bytes); + g_free (src_bytes); /* combine mask and stroke color TileManager */ pixel_region_init (&basePR, base, 0, 0, w, h, TRUE); diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c index 95842d81ec..f05ffd2d20 100644 --- a/app/tools/gimpvectortool.c +++ b/app/tools/gimpvectortool.c @@ -453,8 +453,6 @@ gimp_vector_tool_button_press (GimpTool *tool, if (vector_tool->cur_anchor->selected == FALSE) vector_tool->function = VECTORS_FINISHED; } - vector_tool->last_x = coords->x; - vector_tool->last_y = coords->y; } @@ -513,8 +511,6 @@ gimp_vector_tool_button_press (GimpTool *tool, vector_tool->function == VECTORS_MOVE_VECTORS) { /* Work is being done in gimp_vector_tool_motion ()... */ - vector_tool->last_x = coords->x; - vector_tool->last_y = coords->y; } @@ -584,6 +580,9 @@ gimp_vector_tool_button_press (GimpTool *tool, vector_tool->function = VECTORS_FINISHED; } + vector_tool->last_x = coords->x; + vector_tool->last_y = coords->y; + gimp_vectors_thaw (vector_tool->vectors); if (! gimp_draw_tool_is_active (draw_tool)) @@ -677,20 +676,25 @@ gimp_vector_tool_motion (GimpTool *tool, break; case VECTORS_MOVE_CURVE: - gimp_stroke_point_move_absolute (vector_tool->cur_stroke, - vector_tool->cur_anchor, - vector_tool->cur_position, - coords, vector_tool->restriction); + if (options->polygonal) + { + gimp_vector_tool_move_selected_anchors (vector_tool, + coords->x - vector_tool->last_x, + coords->y - vector_tool->last_y); + } + else + { + gimp_stroke_point_move_absolute (vector_tool->cur_stroke, + vector_tool->cur_anchor, + vector_tool->cur_position, + coords, vector_tool->restriction); + } break; case VECTORS_MOVE_ANCHORSET: gimp_vector_tool_move_selected_anchors (vector_tool, coords->x - vector_tool->last_x, coords->y - vector_tool->last_y); - - vector_tool->last_x = coords->x; - vector_tool->last_y = coords->y; - break; case VECTORS_MOVE_STROKE: @@ -706,24 +710,21 @@ gimp_vector_tool_motion (GimpTool *tool, coords->x - vector_tool->last_x, coords->y - vector_tool->last_y); } - vector_tool->last_x = coords->x; - vector_tool->last_y = coords->y; - break; case VECTORS_MOVE_VECTORS: gimp_item_translate (GIMP_ITEM (vector_tool->vectors), coords->x - vector_tool->last_x, coords->y - vector_tool->last_y, FALSE); - vector_tool->last_x = coords->x; - vector_tool->last_y = coords->y; - break; default: break; } + vector_tool->last_x = coords->x; + vector_tool->last_y = coords->y; + gimp_vectors_thaw (vector_tool->vectors); } @@ -1002,9 +1003,16 @@ gimp_vector_tool_oper_update (GimpTool *tool, else { if (state & TOGGLE_MASK) - vector_tool->function = VECTORS_DELETE_ANCHOR; + { + vector_tool->function = VECTORS_DELETE_ANCHOR; + } else - vector_tool->function = VECTORS_MOVE_HANDLE; + { + if (options->polygonal) + vector_tool->function = VECTORS_MOVE_ANCHOR; + else + vector_tool->function = VECTORS_MOVE_HANDLE; + } } } else