2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-09-21 03:58:26 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpdrawable-stroke.c
|
|
|
|
* Copyright (C) 2003 Simon Budig <simon@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-09-21 03:58:26 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-09-21 03:58:26 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-09-21 03:58:26 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
#include <cairo.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2010-02-21 23:46:39 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2012-03-19 03:55:30 +08:00
|
|
|
#include "gegl/gimp-gegl-nodes.h"
|
2012-03-16 05:58:26 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
|
|
|
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "gimp.h"
|
2012-03-19 03:55:30 +08:00
|
|
|
#include "gimp-apply-operation.h"
|
2011-04-11 01:19:43 +08:00
|
|
|
#include "gimpbezierdesc.h"
|
2012-03-19 21:22:41 +08:00
|
|
|
#include "gimpboundary.h"
|
2003-10-01 02:06:19 +08:00
|
|
|
#include "gimpchannel.h"
|
2003-09-30 07:45:06 +08:00
|
|
|
#include "gimpcontext.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "gimpdrawable-stroke.h"
|
2010-11-25 18:31:40 +08:00
|
|
|
#include "gimperror.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
#include "gimpimage.h"
|
2003-09-28 04:04:07 +08:00
|
|
|
#include "gimppattern.h"
|
|
|
|
#include "gimpscanconvert.h"
|
|
|
|
#include "gimpstrokeoptions.h"
|
|
|
|
|
|
|
|
#include "vectors/gimpstroke.h"
|
|
|
|
#include "vectors/gimpvectors.h"
|
2003-09-21 03:58:26 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2003-10-01 02:06:19 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2012-03-19 22:04:20 +08:00
|
|
|
static GimpScanConvert * gimp_drawable_render_boundary (GimpDrawable *drawable,
|
|
|
|
const GimpBoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
|
|
|
static GimpScanConvert * gimp_drawable_render_vectors (GimpDrawable *drawable,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean do_stroke,
|
|
|
|
GError **error);
|
|
|
|
static void gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpScanConvert *scan_convert,
|
|
|
|
gboolean do_stroke,
|
|
|
|
gboolean push_undo);
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2003-09-30 10:44:17 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
void
|
2012-03-19 22:04:20 +08:00
|
|
|
gimp_drawable_fill_boundary (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
const GimpBoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
2008-10-25 21:12:48 +08:00
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
|
|
|
|
g_return_if_fail (bound_segs == NULL || n_bound_segs != 0);
|
2011-03-06 03:26:41 +08:00
|
|
|
g_return_if_fail (gimp_fill_options_get_style (options) !=
|
|
|
|
GIMP_FILL_STYLE_PATTERN ||
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_boundary (drawable,
|
|
|
|
bound_segs, n_bound_segs,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, options,
|
|
|
|
scan_convert, FALSE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-30 10:44:17 +08:00
|
|
|
void
|
2012-03-19 22:04:20 +08:00
|
|
|
gimp_drawable_stroke_boundary (GimpDrawable *drawable,
|
|
|
|
GimpStrokeOptions *options,
|
|
|
|
const GimpBoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
2003-09-30 10:44:17 +08:00
|
|
|
{
|
2003-09-30 23:16:51 +08:00
|
|
|
GimpScanConvert *scan_convert;
|
2008-10-25 21:12:48 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
|
|
|
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
|
|
|
|
g_return_if_fail (bound_segs == NULL || n_bound_segs != 0);
|
2011-03-06 03:26:41 +08:00
|
|
|
g_return_if_fail (gimp_fill_options_get_style (GIMP_FILL_OPTIONS (options)) !=
|
|
|
|
GIMP_FILL_STYLE_PATTERN ||
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL);
|
|
|
|
|
|
|
|
scan_convert = gimp_drawable_render_boundary (drawable,
|
|
|
|
bound_segs, n_bound_segs,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, GIMP_FILL_OPTIONS (options),
|
|
|
|
scan_convert, TRUE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_drawable_fill_vectors (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean push_undo,
|
|
|
|
GError **error)
|
2008-10-25 21:12:48 +08:00
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
2011-03-06 03:26:41 +08:00
|
|
|
g_return_val_if_fail (gimp_fill_options_get_style (options) !=
|
|
|
|
GIMP_FILL_STYLE_PATTERN ||
|
2010-11-25 18:31:40 +08:00
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL,
|
|
|
|
FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
scan_convert = gimp_drawable_render_vectors (drawable, vectors, FALSE, error);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, options,
|
|
|
|
scan_convert, FALSE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
2010-11-25 18:31:40 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2008-10-25 21:12:48 +08:00
|
|
|
}
|
2010-11-25 18:31:40 +08:00
|
|
|
|
|
|
|
return FALSE;
|
2008-10-25 21:12:48 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
gboolean
|
|
|
|
gimp_drawable_stroke_vectors (GimpDrawable *drawable,
|
|
|
|
GimpStrokeOptions *options,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean push_undo,
|
|
|
|
GError **error)
|
2008-10-25 21:12:48 +08:00
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), FALSE);
|
|
|
|
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
2011-03-06 03:26:41 +08:00
|
|
|
g_return_val_if_fail (gimp_fill_options_get_style (GIMP_FILL_OPTIONS (options)) !=
|
|
|
|
GIMP_FILL_STYLE_PATTERN ||
|
2010-11-25 18:31:40 +08:00
|
|
|
gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL,
|
|
|
|
FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
scan_convert = gimp_drawable_render_vectors (drawable, vectors, TRUE, error);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
|
|
|
if (scan_convert)
|
|
|
|
{
|
|
|
|
gimp_drawable_stroke_scan_convert (drawable, GIMP_FILL_OPTIONS (options),
|
|
|
|
scan_convert, TRUE, push_undo);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
2010-11-25 18:31:40 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2008-10-25 21:12:48 +08:00
|
|
|
}
|
2010-11-25 18:31:40 +08:00
|
|
|
|
|
|
|
return FALSE;
|
2008-10-25 21:12:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static GimpScanConvert *
|
2012-03-19 22:04:20 +08:00
|
|
|
gimp_drawable_render_boundary (GimpDrawable *drawable,
|
|
|
|
const GimpBoundSeg *bound_segs,
|
|
|
|
gint n_bound_segs,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2008-10-25 21:12:48 +08:00
|
|
|
{
|
2011-04-11 01:19:43 +08:00
|
|
|
if (bound_segs)
|
|
|
|
{
|
2012-03-19 22:04:20 +08:00
|
|
|
GimpBoundSeg *stroke_segs;
|
|
|
|
gint n_stroke_segs;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2012-03-19 22:04:20 +08:00
|
|
|
stroke_segs = gimp_boundary_sort (bound_segs, n_bound_segs,
|
|
|
|
&n_stroke_segs);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
if (stroke_segs)
|
2003-09-30 23:16:51 +08:00
|
|
|
{
|
2011-04-11 01:19:43 +08:00
|
|
|
GimpBezierDesc *bezier;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
bezier = gimp_bezier_desc_new_from_bound_segs (stroke_segs,
|
|
|
|
n_bound_segs,
|
|
|
|
n_stroke_segs);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
g_free (stroke_segs);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
if (bezier)
|
|
|
|
{
|
|
|
|
GimpScanConvert *scan_convert;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
scan_convert = gimp_scan_convert_new ();
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
gimp_bezier_desc_translate (bezier, offset_x, offset_y);
|
|
|
|
gimp_scan_convert_add_bezier (scan_convert, bezier);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
gimp_bezier_desc_free (bezier);
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
return scan_convert;
|
|
|
|
}
|
|
|
|
}
|
2003-09-30 23:16:51 +08:00
|
|
|
}
|
|
|
|
|
2011-04-11 01:19:43 +08:00
|
|
|
return NULL;
|
2003-09-30 10:44:17 +08:00
|
|
|
}
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
static GimpScanConvert *
|
2010-11-25 18:31:40 +08:00
|
|
|
gimp_drawable_render_vectors (GimpDrawable *drawable,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
gboolean do_stroke,
|
|
|
|
GError **error)
|
2003-09-21 03:58:26 +08:00
|
|
|
{
|
2011-04-11 01:37:20 +08:00
|
|
|
const GimpBezierDesc *bezier;
|
2003-09-27 23:29:21 +08:00
|
|
|
|
2011-04-11 01:37:20 +08:00
|
|
|
bezier = gimp_vectors_get_bezier (vectors);
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2011-04-11 04:43:03 +08:00
|
|
|
if (bezier && (do_stroke ? bezier->num_data >= 2 : bezier->num_data > 4))
|
2003-09-21 03:58:26 +08:00
|
|
|
{
|
2011-04-11 01:37:20 +08:00
|
|
|
GimpScanConvert *scan_convert;
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2011-04-11 01:37:20 +08:00
|
|
|
scan_convert = gimp_scan_convert_new ();
|
|
|
|
gimp_scan_convert_add_bezier (scan_convert, bezier);
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2011-04-11 01:37:20 +08:00
|
|
|
return scan_convert;
|
2003-09-21 03:58:26 +08:00
|
|
|
}
|
|
|
|
|
2010-11-25 18:31:40 +08:00
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
2011-04-11 01:37:20 +08:00
|
|
|
do_stroke ?
|
|
|
|
_("Not enough points to stroke") :
|
|
|
|
_("Not enough points to fill"));
|
2010-11-25 18:31:40 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2003-09-30 23:16:51 +08:00
|
|
|
static void
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|
|
|
GimpFillOptions *options,
|
|
|
|
GimpScanConvert *scan_convert,
|
|
|
|
gboolean do_stroke,
|
|
|
|
gboolean push_undo)
|
2003-09-30 23:16:51 +08:00
|
|
|
{
|
2012-03-23 01:40:40 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
GeglBuffer *base_buffer;
|
|
|
|
GeglBuffer *mask_buffer;
|
|
|
|
GeglNode *apply_opacity;
|
|
|
|
gint x, y, w, h;
|
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
2003-10-01 02:06:19 +08:00
|
|
|
|
2004-10-21 06:06:00 +08:00
|
|
|
/* must call gimp_channel_is_empty() instead of relying on
|
2010-09-08 03:28:00 +08:00
|
|
|
* gimp_item_mask_intersect() because the selection pretends to
|
2004-10-21 06:06:00 +08:00
|
|
|
* be empty while it is being stroked, to prevent masking itself.
|
|
|
|
*/
|
2006-03-29 01:08:36 +08:00
|
|
|
if (gimp_channel_is_empty (gimp_image_get_mask (image)))
|
2004-10-21 06:06:00 +08:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2008-11-03 08:09:01 +08:00
|
|
|
w = gimp_item_get_width (GIMP_ITEM (drawable));
|
|
|
|
h = gimp_item_get_height (GIMP_ITEM (drawable));
|
2004-10-21 06:06:00 +08:00
|
|
|
}
|
2010-09-08 03:28:00 +08:00
|
|
|
else if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &w, &h))
|
2004-10-21 06:06:00 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
if (do_stroke)
|
|
|
|
{
|
|
|
|
GimpStrokeOptions *stroke_options = GIMP_STROKE_OPTIONS (options);
|
2011-03-06 04:00:28 +08:00
|
|
|
gdouble width;
|
|
|
|
GimpUnit unit;
|
2003-09-30 23:16:51 +08:00
|
|
|
|
2011-03-06 04:00:28 +08:00
|
|
|
width = gimp_stroke_options_get_width (stroke_options);
|
|
|
|
unit = gimp_stroke_options_get_unit (stroke_options);
|
|
|
|
|
|
|
|
if (unit != GIMP_UNIT_PIXEL)
|
2008-10-25 21:12:48 +08:00
|
|
|
{
|
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
2003-09-30 07:45:06 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
2003-09-30 07:45:06 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_scan_convert_set_pixel_ratio (scan_convert, yres / xres);
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2011-03-06 04:00:28 +08:00
|
|
|
width = gimp_units_to_pixels (width, unit, yres);
|
2008-10-25 21:12:48 +08:00
|
|
|
}
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2008-10-25 21:12:48 +08:00
|
|
|
gimp_scan_convert_stroke (scan_convert, width,
|
2011-03-06 04:00:28 +08:00
|
|
|
gimp_stroke_options_get_join_style (stroke_options),
|
|
|
|
gimp_stroke_options_get_cap_style (stroke_options),
|
|
|
|
gimp_stroke_options_get_miter_limit (stroke_options),
|
|
|
|
gimp_stroke_options_get_dash_offset (stroke_options),
|
|
|
|
gimp_stroke_options_get_dash_info (stroke_options));
|
2003-09-30 07:45:06 +08:00
|
|
|
}
|
|
|
|
|
2012-03-21 06:34:11 +08:00
|
|
|
/* fill a 1-bpp GeglBuffer with black, this will describe the shape
|
2003-09-28 04:04:07 +08:00
|
|
|
* of the stroke.
|
|
|
|
*/
|
2012-03-23 01:40:40 +08:00
|
|
|
mask_buffer = gegl_buffer_new (GIMP_GEGL_RECT (0, 0, w, h),
|
|
|
|
babl_format ("Y u8"));
|
2012-03-16 05:58:26 +08:00
|
|
|
|
2012-03-19 03:55:30 +08:00
|
|
|
gegl_buffer_clear (mask_buffer, NULL);
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2003-09-21 08:58:04 +08:00
|
|
|
/* render the stroke into it */
|
2008-11-03 07:03:29 +08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
2008-10-25 21:12:48 +08:00
|
|
|
|
2012-03-21 06:34:11 +08:00
|
|
|
gimp_scan_convert_render (scan_convert, mask_buffer,
|
2003-10-07 01:13:57 +08:00
|
|
|
x + off_x, y + off_y,
|
2011-04-11 04:43:03 +08:00
|
|
|
gimp_fill_options_get_antialias (options));
|
2003-09-21 18:45:19 +08:00
|
|
|
|
2012-03-23 01:40:40 +08:00
|
|
|
base_buffer = gimp_gegl_buffer_new (GIMP_GEGL_RECT (0, 0, w, h),
|
|
|
|
gimp_drawable_get_format_with_alpha (drawable));
|
2003-09-23 07:19:22 +08:00
|
|
|
|
2011-03-06 03:26:41 +08:00
|
|
|
switch (gimp_fill_options_get_style (options))
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2008-10-24 05:30:28 +08:00
|
|
|
case GIMP_FILL_STYLE_SOLID:
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2012-03-19 03:55:30 +08:00
|
|
|
GimpRGB fg;
|
2012-03-20 17:27:28 +08:00
|
|
|
GeglColor *color;
|
2003-09-27 23:29:21 +08:00
|
|
|
|
2012-03-19 03:55:30 +08:00
|
|
|
gimp_context_get_foreground (context, &fg);
|
2003-09-28 04:04:07 +08:00
|
|
|
|
2012-03-20 17:27:28 +08:00
|
|
|
color = gimp_gegl_color_new (&fg);
|
|
|
|
gegl_buffer_set_color (base_buffer, NULL, color);
|
2012-03-19 03:55:30 +08:00
|
|
|
g_object_unref (color);
|
2003-09-28 04:04:07 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-10-24 05:30:28 +08:00
|
|
|
case GIMP_FILL_STYLE_PATTERN:
|
2003-09-28 04:04:07 +08:00
|
|
|
{
|
2012-03-20 17:27:28 +08:00
|
|
|
GimpPattern *pattern = gimp_context_get_pattern (context);
|
|
|
|
GeglBuffer *pattern_buffer;
|
2003-09-28 04:04:07 +08:00
|
|
|
|
2012-03-20 17:27:28 +08:00
|
|
|
pattern_buffer = gimp_pattern_create_buffer (pattern);
|
2012-03-19 03:55:30 +08:00
|
|
|
gegl_buffer_set_pattern (base_buffer, NULL, pattern_buffer, 0, 0);
|
|
|
|
g_object_unref (pattern_buffer);
|
2003-09-28 04:04:07 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2012-03-19 09:30:18 +08:00
|
|
|
apply_opacity = gimp_gegl_create_apply_opacity_node (mask_buffer, 1.0,
|
|
|
|
0, 0);
|
2012-03-19 03:55:30 +08:00
|
|
|
|
|
|
|
gimp_apply_operation (base_buffer, NULL, NULL,
|
2012-03-19 09:30:18 +08:00
|
|
|
apply_opacity, 1.0,
|
2012-03-19 03:55:30 +08:00
|
|
|
base_buffer, NULL);
|
|
|
|
|
|
|
|
g_object_unref (apply_opacity);
|
|
|
|
|
|
|
|
g_object_unref (mask_buffer);
|
|
|
|
|
2003-09-21 08:58:04 +08:00
|
|
|
/* Apply to drawable */
|
2012-03-23 01:40:40 +08:00
|
|
|
gimp_drawable_apply_buffer (drawable, base_buffer,
|
|
|
|
GIMP_GEGL_RECT (0, 0, w, h),
|
2010-06-08 19:24:11 +08:00
|
|
|
push_undo, C_("undo-type", "Render Stroke"),
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_context_get_paint_mode (context),
|
2008-11-09 03:52:18 +08:00
|
|
|
NULL, NULL, x, y);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2012-03-23 01:40:40 +08:00
|
|
|
g_object_unref (base_buffer);
|
2003-09-21 03:58:26 +08:00
|
|
|
|
2003-10-07 01:13:57 +08:00
|
|
|
gimp_drawable_update (drawable, x, y, w, h);
|
2003-09-21 03:58:26 +08:00
|
|
|
}
|