2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +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
|
1997-11-25 06:05:25 +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/>.
|
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
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "paint-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2012-04-01 00:33:04 +08:00
|
|
|
#include "gegl/gimp-gegl-utils.h"
|
2001-04-07 23:58:26 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2009-10-11 21:41:54 +08:00
|
|
|
#include "core/gimpdynamics.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
#include "gimperaser.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimperaseroptions.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2005-12-08 05:11:53 +08:00
|
|
|
static void gimp_eraser_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2009-05-03 18:08:21 +08:00
|
|
|
const GimpCoords *coords,
|
2005-12-08 05:11:53 +08:00
|
|
|
GimpPaintState paint_state,
|
|
|
|
guint32 time);
|
|
|
|
static void gimp_eraser_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2009-05-03 18:08:21 +08:00
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
const GimpCoords *coords);
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1999-07-20 06:42:49 +08:00
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpEraser, gimp_eraser, GIMP_TYPE_BRUSH_CORE)
|
2001-03-12 12:40:17 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2002-02-27 21:57:49 +08:00
|
|
|
void
|
|
|
|
gimp_eraser_register (Gimp *gimp,
|
|
|
|
GimpPaintRegisterCallback callback)
|
|
|
|
{
|
2003-02-14 22:14:29 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_ERASER,
|
|
|
|
GIMP_TYPE_ERASER_OPTIONS,
|
2005-12-28 02:57:01 +08:00
|
|
|
"gimp-eraser",
|
|
|
|
_("Eraser"),
|
|
|
|
"gimp-tool-eraser");
|
2002-02-27 21:57:49 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_class_init (GimpEraserClass *klass)
|
1998-03-01 09:18:45 +08:00
|
|
|
{
|
2004-05-26 04:41:09 +08:00
|
|
|
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
|
2004-05-28 04:48:49 +08:00
|
|
|
GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass);
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2002-02-15 03:31:16 +08:00
|
|
|
paint_core_class->paint = gimp_eraser_paint;
|
2004-05-28 04:48:49 +08:00
|
|
|
|
|
|
|
brush_core_class->handles_changing_brush = TRUE;
|
1998-03-01 09:18:45 +08:00
|
|
|
}
|
1999-08-14 04:50:30 +08:00
|
|
|
|
|
|
|
static void
|
2002-02-15 03:31:16 +08:00
|
|
|
gimp_eraser_init (GimpEraser *eraser)
|
1999-08-14 04:50:30 +08:00
|
|
|
{
|
2001-12-02 06:59:48 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 12:40:17 +08:00
|
|
|
static void
|
2004-07-19 22:37:40 +08:00
|
|
|
gimp_eraser_paint (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpPaintOptions *paint_options,
|
2009-05-03 18:08:21 +08:00
|
|
|
const GimpCoords *coords,
|
2004-07-19 22:37:40 +08:00
|
|
|
GimpPaintState paint_state,
|
|
|
|
guint32 time)
|
2001-03-12 12:40:17 +08:00
|
|
|
{
|
2002-02-15 03:31:16 +08:00
|
|
|
switch (paint_state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-19 22:37:40 +08:00
|
|
|
case GIMP_PAINT_STATE_MOTION:
|
2009-05-03 18:08:21 +08:00
|
|
|
gimp_eraser_motion (paint_core, drawable, paint_options, coords);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2002-02-22 00:02:30 +08:00
|
|
|
gimp_eraser_motion (GimpPaintCore *paint_core,
|
|
|
|
GimpDrawable *drawable,
|
2009-05-03 18:08:21 +08:00
|
|
|
GimpPaintOptions *paint_options,
|
|
|
|
const GimpCoords *coords)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2012-04-28 17:42:33 +08:00
|
|
|
GimpEraserOptions *options = GIMP_ERASER_OPTIONS (paint_options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
|
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
gdouble fade_point;
|
|
|
|
gdouble opacity;
|
|
|
|
GeglBuffer *paint_buffer;
|
|
|
|
gint paint_buffer_x;
|
|
|
|
gint paint_buffer_y;
|
|
|
|
GimpRGB background;
|
|
|
|
GeglColor *color;
|
|
|
|
gdouble force;
|
|
|
|
|
|
|
|
fade_point = gimp_paint_options_get_fade (paint_options, image,
|
2009-10-14 02:27:55 +08:00
|
|
|
paint_core->pixel_dist);
|
|
|
|
|
2012-04-28 17:42:33 +08:00
|
|
|
opacity = gimp_dynamics_get_linear_value (dynamics,
|
|
|
|
GIMP_DYNAMICS_OUTPUT_OPACITY,
|
|
|
|
coords,
|
|
|
|
paint_options,
|
|
|
|
fade_point);
|
2003-07-16 19:25:37 +08:00
|
|
|
if (opacity == 0.0)
|
|
|
|
return;
|
|
|
|
|
2012-04-01 00:33:04 +08:00
|
|
|
paint_buffer = gimp_paint_core_get_paint_buffer (paint_core, drawable,
|
|
|
|
paint_options, coords,
|
|
|
|
&paint_buffer_x,
|
|
|
|
&paint_buffer_y);
|
|
|
|
if (! paint_buffer)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2012-04-01 00:33:04 +08:00
|
|
|
gimp_context_get_background (context, &background);
|
|
|
|
color = gimp_gegl_color_new (&background);
|
2004-05-26 17:32:03 +08:00
|
|
|
|
2012-04-01 00:33:04 +08:00
|
|
|
gegl_buffer_set_color (paint_buffer, NULL, color);
|
|
|
|
g_object_unref (color);
|
2001-11-26 03:01:23 +08:00
|
|
|
|
2012-04-28 17:42:33 +08:00
|
|
|
force = gimp_dynamics_get_linear_value (dynamics,
|
|
|
|
GIMP_DYNAMICS_OUTPUT_FORCE,
|
|
|
|
coords,
|
|
|
|
paint_options,
|
|
|
|
fade_point);
|
2008-05-23 00:38:57 +08:00
|
|
|
|
2004-05-26 04:41:09 +08:00
|
|
|
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
|
2009-05-18 04:45:06 +08:00
|
|
|
coords,
|
2006-04-12 20:49:29 +08:00
|
|
|
MIN (opacity, GIMP_OPACITY_OPAQUE),
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
(options->anti_erase ?
|
2002-03-19 23:05:38 +08:00
|
|
|
GIMP_ANTI_ERASE_MODE : GIMP_ERASE_MODE),
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_paint_options_get_brush_mode (paint_options),
|
2010-04-09 05:44:52 +08:00
|
|
|
force,
|
2006-04-12 20:49:29 +08:00
|
|
|
paint_options->application_mode);
|
2001-10-31 06:59:06 +08:00
|
|
|
}
|