2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
* Copyright (C) 1999 Adrian Likins and Tor Lillqvist
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
1999-08-23 14:06:12 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2003-02-27 21:59:41 +08:00
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
#include "gimpbrushpipe.h"
|
2006-10-03 20:29:07 +08:00
|
|
|
#include "gimpbrushpipe-load.h"
|
2000-02-24 19:39:26 +08:00
|
|
|
|
2000-05-27 09:30:21 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
static void gimp_brush_pipe_finalize (GObject *object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64 gimp_brush_pipe_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
gint *popup_width,
|
|
|
|
gint *popup_height);
|
2003-02-27 21:59:41 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush,
|
|
|
|
GimpCoords *last_coords,
|
|
|
|
GimpCoords *cur_coords);
|
|
|
|
static gboolean gimp_brush_pipe_want_null_motion (GimpBrush *brush,
|
|
|
|
GimpCoords *last_coords,
|
|
|
|
GimpCoords *cur_coords);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-08-23 14:06:12 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
G_DEFINE_TYPE (GimpBrushPipe, gimp_brush_pipe, GIMP_TYPE_BRUSH);
|
2001-01-10 08:36:54 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
#define parent_class gimp_brush_pipe_parent_class
|
2001-01-10 08:36:54 +08:00
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_brush_pipe_class_init (GimpBrushPipeClass *klass)
|
|
|
|
{
|
2004-06-25 21:41:24 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
GimpBrushClass *brush_class = GIMP_BRUSH_CLASS (klass);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
object_class->finalize = gimp_brush_pipe_finalize;
|
|
|
|
|
|
|
|
gimp_object_class->get_memsize = gimp_brush_pipe_get_memsize;
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2003-02-27 21:59:41 +08:00
|
|
|
viewable_class->get_popup_size = gimp_brush_pipe_get_popup_size;
|
|
|
|
|
2002-01-31 00:14:26 +08:00
|
|
|
brush_class->select_brush = gimp_brush_pipe_select_brush;
|
|
|
|
brush_class->want_null_motion = gimp_brush_pipe_want_null_motion;
|
2001-08-11 22:39:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_brush_pipe_init (GimpBrushPipe *pipe)
|
|
|
|
{
|
|
|
|
pipe->current = NULL;
|
|
|
|
pipe->dimension = 0;
|
|
|
|
pipe->rank = NULL;
|
|
|
|
pipe->stride = NULL;
|
|
|
|
pipe->nbrushes = 0;
|
|
|
|
pipe->brushes = NULL;
|
|
|
|
pipe->select = NULL;
|
|
|
|
pipe->index = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_brush_pipe_finalize (GObject *object)
|
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
if (pipe->rank)
|
|
|
|
{
|
|
|
|
g_free (pipe->rank);
|
|
|
|
pipe->rank = NULL;
|
|
|
|
}
|
|
|
|
if (pipe->stride)
|
|
|
|
{
|
|
|
|
g_free (pipe->stride);
|
|
|
|
pipe->stride = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pipe->brushes)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < pipe->nbrushes; i++)
|
2006-04-12 20:49:29 +08:00
|
|
|
if (pipe->brushes[i])
|
|
|
|
g_object_unref (pipe->brushes[i]);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
g_free (pipe->brushes);
|
|
|
|
pipe->brushes = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pipe->select)
|
|
|
|
{
|
|
|
|
g_free (pipe->select);
|
|
|
|
pipe->select = NULL;
|
|
|
|
}
|
|
|
|
if (pipe->index)
|
|
|
|
{
|
|
|
|
g_free (pipe->index);
|
|
|
|
pipe->index = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_BRUSH (pipe)->mask = NULL;
|
|
|
|
GIMP_BRUSH (pipe)->pixmap = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
gimp_brush_pipe_get_memsize (GimpObject *object,
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 *gui_size)
|
2002-01-31 00:14:26 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (object);
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
gint i;
|
|
|
|
|
|
|
|
memsize += pipe->dimension * (sizeof (gint) /* rank */ +
|
|
|
|
sizeof (gint) /* stride */ +
|
|
|
|
sizeof (PipeSelectModes));
|
|
|
|
|
|
|
|
for (i = 0; i < pipe->nbrushes; i++)
|
2003-08-25 18:49:33 +08:00
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (pipe->brushes[i]),
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
}
|
|
|
|
|
2003-02-27 21:59:41 +08:00
|
|
|
static gboolean
|
2006-10-03 20:29:07 +08:00
|
|
|
gimp_brush_pipe_get_popup_size (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
gint *popup_width,
|
|
|
|
gint *popup_height)
|
2003-02-27 21:59:41 +08:00
|
|
|
{
|
2005-05-25 18:05:17 +08:00
|
|
|
return gimp_viewable_get_size (viewable, popup_width, popup_height);
|
2003-02-27 21:59:41 +08:00
|
|
|
}
|
|
|
|
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
static GimpBrush *
|
2001-12-02 06:59:48 +08:00
|
|
|
gimp_brush_pipe_select_brush (GimpBrush *brush,
|
|
|
|
GimpCoords *last_coords,
|
|
|
|
GimpCoords *cur_coords)
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (brush);
|
2001-01-14 11:55:56 +08:00
|
|
|
gint i, brushix, ix;
|
2006-02-01 04:20:51 +08:00
|
|
|
gdouble angle, velocity, spacing;
|
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 17:27:48 +08:00
|
|
|
|
Implement the selection of brush based on cursor direction, pressure,
1999-08-28 Tor Lillqvist <tml@iki.fi>
* app/gimpbrushpipe.c: Implement the selection of brush based on
cursor direction, pressure, tilt, or a random value. (Hmm, forgot
velocity, later.) (In addition to just incrementally stepping.)
Read the brush pipe parameters from the gih file's second line.
There is no way to tune the parameters in the GIMP, they must
currently be set when saving the gih file (in the gpb plug-in).
* app/gimpbrushpipe.h
* app/gimpbrushpipeP.h: Move the PipeSelectModes enum to the
"private" header. Add a stride array to GimpBrushPipe to make
indexing easier.
* plug-ins/common/gpb.c: Add selection mode fields to the dialog.
Attach the pipe parameters entered as a parasite, too.
* docs/parasites.txt
* plug-ins/common/psp.c: Use "placement", not "spacing" (which
means another thing).
1999-08-28 09:14:42 +08:00
|
|
|
if (pipe->nbrushes == 1)
|
|
|
|
return GIMP_BRUSH (pipe->current);
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
|
2006-04-07 18:51:22 +08:00
|
|
|
|
2006-02-01 04:20:51 +08:00
|
|
|
/* calculates brush native spacing in pixels, based on it's width)*/
|
2006-12-06 08:01:27 +08:00
|
|
|
spacing = ((gdouble) gimp_brush_get_spacing (pipe->current) / 100) *
|
2006-02-01 04:20:51 +08:00
|
|
|
MAX (brush->mask->width, brush->mask->height);
|
|
|
|
|
Implement the selection of brush based on cursor direction, pressure,
1999-08-28 Tor Lillqvist <tml@iki.fi>
* app/gimpbrushpipe.c: Implement the selection of brush based on
cursor direction, pressure, tilt, or a random value. (Hmm, forgot
velocity, later.) (In addition to just incrementally stepping.)
Read the brush pipe parameters from the gih file's second line.
There is no way to tune the parameters in the GIMP, they must
currently be set when saving the gih file (in the gpb plug-in).
* app/gimpbrushpipe.h
* app/gimpbrushpipeP.h: Move the PipeSelectModes enum to the
"private" header. Add a stride array to GimpBrushPipe to make
indexing easier.
* plug-ins/common/gpb.c: Add selection mode fields to the dialog.
Attach the pipe parameters entered as a parasite, too.
* docs/parasites.txt
* plug-ins/common/psp.c: Use "placement", not "spacing" (which
means another thing).
1999-08-28 09:14:42 +08:00
|
|
|
brushix = 0;
|
|
|
|
for (i = 0; i < pipe->dimension; i++)
|
|
|
|
{
|
|
|
|
switch (pipe->select[i])
|
2004-06-25 21:41:24 +08:00
|
|
|
{
|
|
|
|
case PIPE_SELECT_INCREMENTAL:
|
|
|
|
ix = (pipe->index[i] + 1) % pipe->rank[i];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIPE_SELECT_ANGULAR:
|
|
|
|
angle = atan2 (cur_coords->y - last_coords->y,
|
|
|
|
cur_coords->x - last_coords->x);
|
|
|
|
/* Offset angle to be compatible with PSP tubes */
|
|
|
|
angle += G_PI_2;
|
|
|
|
/* Map it to the [0..2*G_PI) interval */
|
|
|
|
if (angle < 0)
|
|
|
|
angle += 2.0 * G_PI;
|
|
|
|
else if (angle > 2.0 * G_PI)
|
|
|
|
angle -= 2.0 * G_PI;
|
|
|
|
ix = RINT (angle / (2.0 * G_PI) * pipe->rank[i]);
|
|
|
|
break;
|
|
|
|
|
2006-02-01 04:20:51 +08:00
|
|
|
case PIPE_SELECT_VELOCITY:
|
|
|
|
velocity = sqrt (SQR (cur_coords->x - last_coords->x) +
|
|
|
|
SQR (cur_coords->y - last_coords->y));
|
|
|
|
|
|
|
|
/* I don't know how much velocity is enough velocity. I will assume 0 to
|
|
|
|
brush' saved spacing (converted to pixels) to be 'enough' velocity */
|
|
|
|
ix = ROUND ((1.0 - MIN (1.0, velocity / (spacing))) * pipe->rank[i]);
|
|
|
|
break;
|
|
|
|
|
2004-06-25 21:41:24 +08:00
|
|
|
case PIPE_SELECT_RANDOM:
|
|
|
|
/* This probably isn't the right way */
|
2004-12-10 05:34:48 +08:00
|
|
|
ix = g_random_int_range (0, pipe->rank[i]);
|
2004-06-25 21:41:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PIPE_SELECT_PRESSURE:
|
|
|
|
ix = RINT (cur_coords->pressure * (pipe->rank[i] - 1));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIPE_SELECT_TILT_X:
|
|
|
|
ix = RINT (cur_coords->xtilt / 2.0 * pipe->rank[i]) + pipe->rank[i] / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIPE_SELECT_TILT_Y:
|
|
|
|
ix = RINT (cur_coords->ytilt / 2.0 * pipe->rank[i]) + pipe->rank[i] / 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PIPE_SELECT_CONSTANT:
|
|
|
|
default:
|
|
|
|
ix = pipe->index[i];
|
|
|
|
break;
|
|
|
|
}
|
2003-01-26 22:27:53 +08:00
|
|
|
|
2004-01-30 00:19:57 +08:00
|
|
|
pipe->index[i] = CLAMP (ix, 0, pipe->rank[i] - 1);
|
1999-08-28 19:23:58 +08:00
|
|
|
brushix += pipe->stride[i] * pipe->index[i];
|
Implement the selection of brush based on cursor direction, pressure,
1999-08-28 Tor Lillqvist <tml@iki.fi>
* app/gimpbrushpipe.c: Implement the selection of brush based on
cursor direction, pressure, tilt, or a random value. (Hmm, forgot
velocity, later.) (In addition to just incrementally stepping.)
Read the brush pipe parameters from the gih file's second line.
There is no way to tune the parameters in the GIMP, they must
currently be set when saving the gih file (in the gpb plug-in).
* app/gimpbrushpipe.h
* app/gimpbrushpipeP.h: Move the PipeSelectModes enum to the
"private" header. Add a stride array to GimpBrushPipe to make
indexing easier.
* plug-ins/common/gpb.c: Add selection mode fields to the dialog.
Attach the pipe parameters entered as a parasite, too.
* docs/parasites.txt
* plug-ins/common/psp.c: Use "placement", not "spacing" (which
means another thing).
1999-08-28 09:14:42 +08:00
|
|
|
}
|
|
|
|
|
1999-08-28 19:23:58 +08:00
|
|
|
/* Make sure is inside bounds */
|
2004-01-30 00:19:57 +08:00
|
|
|
brushix = CLAMP (brushix, 0, pipe->nbrushes - 1);
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
|
Implement the selection of brush based on cursor direction, pressure,
1999-08-28 Tor Lillqvist <tml@iki.fi>
* app/gimpbrushpipe.c: Implement the selection of brush based on
cursor direction, pressure, tilt, or a random value. (Hmm, forgot
velocity, later.) (In addition to just incrementally stepping.)
Read the brush pipe parameters from the gih file's second line.
There is no way to tune the parameters in the GIMP, they must
currently be set when saving the gih file (in the gpb plug-in).
* app/gimpbrushpipe.h
* app/gimpbrushpipeP.h: Move the PipeSelectModes enum to the
"private" header. Add a stride array to GimpBrushPipe to make
indexing easier.
* plug-ins/common/gpb.c: Add selection mode fields to the dialog.
Attach the pipe parameters entered as a parasite, too.
* docs/parasites.txt
* plug-ins/common/psp.c: Use "placement", not "spacing" (which
means another thing).
1999-08-28 09:14:42 +08:00
|
|
|
pipe->current = pipe->brushes[brushix];
|
|
|
|
|
|
|
|
return GIMP_BRUSH (pipe->current);
|
Overhaul of pixmap brushes and pipes: No separate pixmap pipe
brush tool any longer. The paintbrush, airbrush and pencil
tools, which already knew how to handle the single-pixmap
brushes now also handle the pipes as well.
* app/pixmapbrush.{h,c}
* app/gimpbrushpixmap.{h,c}: Removed these files.
* app/Makefile.am
* app/makefile.{cygwin,msc}: Remove from here, too.
* app/gimpbrushpipe.{h,c}: Total overhaul.
* app/paint_core.h
* app/apptypes.h: Some more types moved to apptypes.h
* app/context_manager.c
* app/tool_options.c
* app/tools.c
* app/toolsF.h: Remove PIXMAPBRUSH tool.
* app/gimpbrush.h: New method: select_brush. Used to change the
brush in paint_core, for pipe brushes.
* app/gimpbrush.c: Add gimp_brush_select_brush, which is dummy for
the normal brushes (returns the same brush).
* app/paint_core.c: Call the brush's select_brush method to get a
potential new brush before calling the paint_func.
* app/gimpbrushlist.c: Various changes related to the pixmap and
pipe overhaul.
* app/airbrush.c
* app/pencil.c: Reorder code a bit in the tool motion function to
avoid executing unnecessary code in the case of a pixmap brush.
Other changes in the same commit:
* app/install.c: Make quote_spaces extern.
* app/appenv.h: Declare it.
* libgimp/gimpui.def: Add missing entry points.
* libgimp/makefile.{cygwin,msc}: Add missing objects to gimpui.
1999-08-26 08:54:30 +08:00
|
|
|
}
|
1999-08-23 14:06:12 +08:00
|
|
|
|
1999-08-31 05:24:13 +08:00
|
|
|
static gboolean
|
2001-12-02 06:59:48 +08:00
|
|
|
gimp_brush_pipe_want_null_motion (GimpBrush *brush,
|
|
|
|
GimpCoords *last_coords,
|
|
|
|
GimpCoords *cur_coords)
|
1999-08-31 05:24:13 +08:00
|
|
|
{
|
2004-01-30 00:19:57 +08:00
|
|
|
GimpBrushPipe *pipe = GIMP_BRUSH_PIPE (brush);
|
2001-01-14 11:55:56 +08:00
|
|
|
gint i;
|
1999-08-31 05:24:13 +08:00
|
|
|
|
|
|
|
if (pipe->nbrushes == 1)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
for (i = 0; i < pipe->dimension; i++)
|
|
|
|
if (pipe->select[i] == PIPE_SELECT_ANGULAR)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|