1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpbrush.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gdisplay.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "selection.h"
|
|
|
|
#include "temp_buf.h"
|
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimppaintbrushtool.h"
|
1999-04-22 22:34:00 +08:00
|
|
|
#include "paint_options.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "tool_manager.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-05-14 08:04:29 +08:00
|
|
|
#define WANT_PAINT_BRUSH_BITS
|
|
|
|
#include "icons.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
#define PAINT_LEFT_THRESHOLD 0.05
|
|
|
|
#define PAINTBRUSH_DEFAULT_INCREMENTAL FALSE
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void gimp_paintbrush_tool_class_init (GimpPaintbrushToolClass *klass);
|
|
|
|
static void gimp_paintbrush_tool_init (GimpPaintbrushTool *tool);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void gimp_paintbrush_tool_paint (GimpPaintTool *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state);
|
|
|
|
|
|
|
|
static void gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
2001-04-07 19:01:22 +08:00
|
|
|
PaintPressureOptions *pressure_options,
|
|
|
|
PaintGradientOptions *gradient_options,
|
|
|
|
gdouble fade_out,
|
|
|
|
gdouble gradient_length,
|
|
|
|
gboolean incremental,
|
|
|
|
GradientPaintMode gradient_type);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* local variables */
|
|
|
|
static gboolean non_gui_incremental = PAINTBRUSH_DEFAULT_INCREMENTAL;
|
2001-02-28 10:53:27 +08:00
|
|
|
|
2001-04-01 04:41:39 +08:00
|
|
|
static PaintOptions *paintbrush_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static GimpPaintToolClass *parent_class = NULL;
|
2001-02-28 03:18:01 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
void
|
|
|
|
gimp_paintbrush_tool_register (void)
|
|
|
|
{
|
|
|
|
tool_manager_register_tool (GIMP_TYPE_PAINTBRUSH_TOOL,
|
|
|
|
TRUE,
|
|
|
|
"gimp:paintbrush_tool",
|
|
|
|
_("Paintbrush"),
|
|
|
|
_("Paint fuzzy brush strokes"),
|
|
|
|
N_("/Tools/Paint Tools/Paintbrush"), "P",
|
|
|
|
NULL, "tools/paintbrush.html",
|
2001-05-14 08:04:29 +08:00
|
|
|
(const gchar **) paint_brush_bits);
|
2001-03-12 12:40:17 +08:00
|
|
|
}
|
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
GtkType
|
|
|
|
gimp_paintbrush_tool_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType tool_type = 0;
|
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo tool_info =
|
|
|
|
{
|
|
|
|
"GimpPaintbrushTool",
|
|
|
|
sizeof (GimpPaintbrushTool),
|
|
|
|
sizeof (GimpPaintbrushToolClass),
|
|
|
|
(GtkClassInitFunc) gimp_paintbrush_tool_class_init,
|
2001-02-28 03:18:01 +08:00
|
|
|
(GtkObjectInitFunc) gimp_paintbrush_tool_init,
|
2001-02-27 13:21:12 +08:00
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
tool_type = gtk_type_unique (GIMP_TYPE_PAINT_TOOL, &tool_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_paintbrush_tool_class_init (GimpPaintbrushToolClass *klass)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-03-12 12:40:17 +08:00
|
|
|
GimpPaintToolClass *paint_tool_class;
|
1999-04-22 22:34:00 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
paint_tool_class = (GimpPaintToolClass *) klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class (GIMP_TYPE_PAINT_TOOL);
|
|
|
|
|
|
|
|
paint_tool_class->paint = gimp_paintbrush_tool_paint;
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1999-03-28 13:27:34 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
|
|
|
gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-12 12:40:17 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpPaintTool *paint_tool;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
tool = GIMP_TOOL (paintbrush);
|
|
|
|
paint_tool = GIMP_PAINT_TOOL (paintbrush);
|
1999-09-09 09:47:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
if (! paintbrush_options)
|
|
|
|
{
|
2001-04-01 04:41:39 +08:00
|
|
|
paintbrush_options = paint_options_new (GIMP_TYPE_PAINTBRUSH_TOOL,
|
|
|
|
paint_options_reset);
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
tool_manager_register_tool_options (GIMP_TYPE_PAINTBRUSH_TOOL,
|
|
|
|
(ToolOptions *) paintbrush_options);
|
|
|
|
}
|
|
|
|
|
|
|
|
tool->tool_cursor = GIMP_PAINTBRUSH_TOOL_CURSOR;
|
|
|
|
|
2001-04-07 19:01:22 +08:00
|
|
|
paint_tool->pick_colors = TRUE;
|
2001-03-12 12:40:17 +08:00
|
|
|
paint_tool->flags |= TOOL_CAN_HANDLE_CHANGING_BRUSH;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
static void
|
2001-02-28 03:18:01 +08:00
|
|
|
gimp_paintbrush_tool_paint (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintState state)
|
2001-02-27 13:21:12 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
PaintPressureOptions *pressure_options;
|
|
|
|
PaintGradientOptions *gradient_options;
|
|
|
|
gboolean incremental;
|
|
|
|
GimpImage *gimage;
|
|
|
|
gdouble fade_out;
|
|
|
|
gdouble gradient_length;
|
|
|
|
gdouble unit_factor;
|
|
|
|
|
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
|
|
|
|
g_return_if_fail (gimage != NULL);
|
|
|
|
|
|
|
|
if (! gimage)
|
|
|
|
return;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
if (paintbrush_options)
|
|
|
|
{
|
2001-04-01 04:41:39 +08:00
|
|
|
pressure_options = paintbrush_options->pressure_options;
|
|
|
|
gradient_options = paintbrush_options->gradient_options;
|
|
|
|
incremental = paintbrush_options->incremental;
|
2001-02-28 07:20:51 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pressure_options = &non_gui_pressure_options;
|
|
|
|
gradient_options = &non_gui_gradient_options;
|
|
|
|
incremental = non_gui_incremental;
|
|
|
|
}
|
1999-09-26 03:49:58 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case INIT_PAINT:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case MOTION_PAINT:
|
2001-02-28 07:20:51 +08:00
|
|
|
switch (gradient_options->fade_unit)
|
1999-09-26 03:49:58 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
2001-02-28 07:20:51 +08:00
|
|
|
fade_out = gradient_options->fade_out;
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
2001-02-28 07:20:51 +08:00
|
|
|
fade_out = (MAX (gimage->width, gimage->height) *
|
|
|
|
gradient_options->fade_out / 100);
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
|
|
|
default:
|
2001-02-28 07:20:51 +08:00
|
|
|
unit_factor = gimp_unit_get_factor (gradient_options->fade_unit);
|
|
|
|
fade_out = (gradient_options->fade_out *
|
|
|
|
MAX (gimage->xresolution,
|
|
|
|
gimage->yresolution) / unit_factor);
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
switch (gradient_options->gradient_unit)
|
1999-09-26 03:49:58 +08:00
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PIXEL:
|
2001-02-28 07:20:51 +08:00
|
|
|
gradient_length = gradient_options->gradient_length;
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
2000-02-08 04:35:13 +08:00
|
|
|
case GIMP_UNIT_PERCENT:
|
2001-02-28 07:20:51 +08:00
|
|
|
gradient_length = (MAX (gimage->width, gimage->height) *
|
|
|
|
gradient_options->gradient_length / 100);
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
|
|
|
default:
|
2001-02-28 07:20:51 +08:00
|
|
|
unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit);
|
|
|
|
gradient_length = (gradient_options->gradient_length *
|
|
|
|
MAX (gimage->xresolution,
|
|
|
|
gimage->yresolution) / unit_factor);
|
1999-09-26 03:49:58 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-02-27 13:21:12 +08:00
|
|
|
|
|
|
|
gimp_paintbrush_tool_motion (paint_tool, drawable,
|
2001-02-28 07:20:51 +08:00
|
|
|
pressure_options,
|
|
|
|
gradient_options,
|
|
|
|
gradient_options->use_fade ? fade_out : 0,
|
|
|
|
gradient_options->use_gradient ? gradient_length : 0,
|
|
|
|
incremental,
|
|
|
|
gradient_options->gradient_type);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
case FINISH_PAINT:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-02-28 03:18:01 +08:00
|
|
|
gimp_paintbrush_tool_motion (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
PaintPressureOptions *pressure_options,
|
2001-02-28 07:20:51 +08:00
|
|
|
PaintGradientOptions *gradient_options,
|
2001-04-07 19:01:22 +08:00
|
|
|
gdouble fade_out,
|
|
|
|
gdouble gradient_length,
|
|
|
|
gboolean incremental,
|
2001-02-28 03:18:01 +08:00
|
|
|
GradientPaintMode gradient_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-07 19:01:22 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
TempBuf *area;
|
|
|
|
gdouble x, paint_left;
|
|
|
|
guchar local_blend = OPAQUE_OPACITY;
|
|
|
|
guchar temp_blend = OPAQUE_OPACITY;
|
|
|
|
guchar col[MAX_CHANNELS];
|
|
|
|
GimpRGB color;
|
|
|
|
gint mode;
|
|
|
|
gint opacity;
|
|
|
|
gdouble scale;
|
|
|
|
PaintApplicationMode paint_appl_mode = incremental ? INCREMENTAL : CONSTANT;
|
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->size)
|
2001-02-27 13:21:12 +08:00
|
|
|
scale = paint_tool->curpressure;
|
1999-09-09 09:47:54 +08:00
|
|
|
else
|
|
|
|
scale = 1.0;
|
1999-08-17 09:05:59 +08:00
|
|
|
|
1999-11-13 09:02:27 +08:00
|
|
|
if (pressure_options->color)
|
|
|
|
gradient_length = 1.0; /* not really used, only for if cases */
|
|
|
|
|
1999-05-15 08:02:47 +08:00
|
|
|
/* Get a region which can be used to paint to */
|
2001-02-27 13:21:12 +08:00
|
|
|
if (! (area = gimp_paint_tool_get_paint_area (paint_tool, drawable, scale)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* factor in the fade out value */
|
|
|
|
if (fade_out)
|
|
|
|
{
|
|
|
|
/* Model the amount of paint left as a gaussian curve */
|
2001-02-27 13:21:12 +08:00
|
|
|
x = ((double) paint_tool->pixel_dist / fade_out);
|
1999-09-26 03:49:58 +08:00
|
|
|
paint_left = exp (- x * x * 5.541); /* ln (1/255) */
|
1999-03-19 08:42:27 +08:00
|
|
|
local_blend = (int) (255 * paint_left);
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
|
|
|
|
1999-03-19 08:42:27 +08:00
|
|
|
if (local_blend)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* set the alpha channel */
|
1999-03-19 08:42:27 +08:00
|
|
|
temp_blend = local_blend;
|
1999-03-28 13:27:34 +08:00
|
|
|
mode = gradient_type;
|
1999-03-19 08:42:27 +08:00
|
|
|
|
1999-08-20 03:53:30 +08:00
|
|
|
if (gradient_length)
|
1999-03-17 13:40:16 +08:00
|
|
|
{
|
1999-11-13 09:02:27 +08:00
|
|
|
if (pressure_options->color)
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_gradient_get_color_at (gimp_context_get_gradient (NULL),
|
2001-02-27 13:21:12 +08:00
|
|
|
paint_tool->curpressure, &color);
|
1999-11-13 09:02:27 +08:00
|
|
|
else
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paint_tool_get_color_from_gradient (paint_tool, gradient_length,
|
2001-02-28 03:18:01 +08:00
|
|
|
&color, mode);
|
2001-01-21 00:28:05 +08:00
|
|
|
|
|
|
|
temp_blend = (gint) ((color.a * local_blend));
|
|
|
|
|
|
|
|
gimp_rgb_get_uchar (&color,
|
|
|
|
&col[RED_PIX],
|
|
|
|
&col[GREEN_PIX],
|
|
|
|
&col[BLUE_PIX]);
|
|
|
|
col[ALPHA_PIX] = OPAQUE_OPACITY;
|
|
|
|
|
1999-03-19 08:42:27 +08:00
|
|
|
/* always use incremental mode with gradients */
|
|
|
|
/* make the gui cool later */
|
1999-08-20 03:53:30 +08:00
|
|
|
paint_appl_mode = INCREMENTAL;
|
1999-11-13 09:02:27 +08:00
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
1999-08-17 09:05:59 +08:00
|
|
|
/* we check to see if this is a pixmap, if so composite the
|
2001-04-07 19:01:22 +08:00
|
|
|
* pixmap image into the area instead of the color
|
|
|
|
*/
|
2001-02-27 13:21:12 +08:00
|
|
|
else if (paint_tool->brush && paint_tool->brush->pixmap)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paint_tool_color_area_with_pixmap (paint_tool, gimage, drawable,
|
2001-02-28 03:18:01 +08:00
|
|
|
area,
|
|
|
|
scale, SOFT);
|
1999-08-20 03:53:30 +08:00
|
|
|
paint_appl_mode = INCREMENTAL;
|
1999-08-14 04:50:30 +08:00
|
|
|
}
|
2001-02-27 13:21:12 +08:00
|
|
|
else
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
gimp_image_get_foreground (gimage, drawable, col);
|
1999-11-13 09:02:27 +08:00
|
|
|
col[area->bytes - 1] = OPAQUE_OPACITY;
|
1999-08-14 04:50:30 +08:00
|
|
|
color_pixels (temp_buf_data (area), col,
|
|
|
|
area->width * area->height, area->bytes);
|
|
|
|
}
|
1999-09-09 09:47:54 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
opacity = (gdouble) temp_blend;
|
|
|
|
|
1999-09-09 09:47:54 +08:00
|
|
|
if (pressure_options->opacity)
|
2001-02-27 13:21:12 +08:00
|
|
|
opacity = opacity * 2.0 * paint_tool->curpressure;
|
1999-09-09 09:47:54 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paint_tool_paste_canvas (paint_tool, drawable,
|
2001-02-28 03:18:01 +08:00
|
|
|
MIN (opacity, 255),
|
|
|
|
gimp_context_get_opacity (NULL) * 255,
|
|
|
|
gimp_context_get_paint_mode (NULL),
|
|
|
|
pressure_options->pressure ? PRESSURE : SOFT,
|
|
|
|
scale, paint_appl_mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
/* non-gui stuff */
|
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
static GimpPaintbrushTool *non_gui_paintbrush = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
gboolean
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paintbrush_tool_non_gui_default (GimpDrawable *drawable,
|
2001-02-28 03:18:01 +08:00
|
|
|
gint num_strokes,
|
2001-04-07 19:01:22 +08:00
|
|
|
gdouble *stroke_array)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (! non_gui_paintbrush)
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
non_gui_paintbrush = gtk_type_new (GIMP_TYPE_PAINTBRUSH_TOOL);
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (non_gui_paintbrush);
|
1999-10-01 06:12:58 +08:00
|
|
|
|
2001-02-27 13:21:12 +08:00
|
|
|
/* Hmmm... PDB paintbrush should have gradient type added to it!
|
|
|
|
* thats why the code below is duplicated.
|
|
|
|
*/
|
2001-02-28 07:20:51 +08:00
|
|
|
if (gimp_paint_tool_start (paint_tool, drawable,
|
|
|
|
stroke_array[0],
|
|
|
|
stroke_array[1]))
|
1999-07-20 06:42:49 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool->startx = paint_tool->lastx = stroke_array[0];
|
|
|
|
paint_tool->starty = paint_tool->lasty = stroke_array[1];
|
1999-09-02 08:17:25 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
gimp_paint_tool_paint (paint_tool, drawable, MOTION_PAINT);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
|
|
|
paint_tool->curx = stroke_array[i * 2 + 0];
|
|
|
|
paint_tool->cury = stroke_array[i * 2 + 1];
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
gimp_paint_tool_interpolate (paint_tool, drawable);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
paint_tool->lastx = paint_tool->curx;
|
|
|
|
paint_tool->lasty = paint_tool->cury;
|
|
|
|
}
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
gimp_paint_tool_finish (paint_tool, drawable);
|
1999-07-20 06:42:49 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
return FALSE;
|
1999-07-20 06:42:49 +08:00
|
|
|
}
|
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
gboolean
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_paintbrush_tool_non_gui (GimpDrawable *drawable,
|
2001-02-28 03:18:01 +08:00
|
|
|
gint num_strokes,
|
|
|
|
gdouble *stroke_array,
|
|
|
|
gdouble fade_out,
|
|
|
|
gint method,
|
|
|
|
gdouble gradient_length)
|
1999-03-17 13:40:16 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
GimpPaintTool *paint_tool;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
if (! non_gui_paintbrush)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
non_gui_paintbrush = gtk_type_new (GIMP_TYPE_PAINTBRUSH_TOOL);
|
|
|
|
}
|
1999-04-21 07:03:31 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool = GIMP_PAINT_TOOL (non_gui_paintbrush);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
/* Code duplicated above */
|
|
|
|
if (gimp_paint_tool_start (paint_tool, drawable,
|
|
|
|
stroke_array[0],
|
|
|
|
stroke_array[1]))
|
|
|
|
{
|
|
|
|
non_gui_gradient_options.fade_out = fade_out;
|
|
|
|
non_gui_gradient_options.gradient_length = gradient_length;
|
|
|
|
non_gui_gradient_options.gradient_type = LOOP_TRIANGLE;
|
|
|
|
non_gui_incremental = method;
|
1999-03-17 13:40:16 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool->startx = paint_tool->lastx = stroke_array[0];
|
|
|
|
paint_tool->starty = paint_tool->lasty = stroke_array[1];
|
1999-09-02 08:17:25 +08:00
|
|
|
|
2001-04-07 19:01:22 +08:00
|
|
|
gimp_paint_tool_paint (paint_tool, drawable, MOTION_PAINT);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
|
|
|
for (i = 1; i < num_strokes; i++)
|
1999-04-23 14:07:09 +08:00
|
|
|
{
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool->curx = stroke_array[i * 2 + 0];
|
|
|
|
paint_tool->cury = stroke_array[i * 2 + 1];
|
1999-03-17 13:40:16 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
gimp_paint_tool_interpolate (paint_tool, drawable);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
paint_tool->lastx = paint_tool->curx;
|
|
|
|
paint_tool->lasty = paint_tool->cury;
|
1999-04-23 14:07:09 +08:00
|
|
|
}
|
1999-03-17 13:40:16 +08:00
|
|
|
|
2001-02-28 07:20:51 +08:00
|
|
|
gimp_paint_tool_finish (paint_tool, drawable);
|
1999-03-17 13:40:16 +08:00
|
|
|
|
1999-04-19 05:22:41 +08:00
|
|
|
return TRUE;
|
1999-03-17 13:40:16 +08:00
|
|
|
}
|
2001-03-12 12:40:17 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|