mirror of https://github.com/GNOME/gimp.git
new file, containes the PDB stuff for most of the tools
* app/tools_cmds.c: new file, containes the PDB stuff for most of the tools * app/gimprc_cmds.c: new file, PDB interface stuff for gimprc access * app/Makefile.am: added tools_cmds.c and gimprc_cmds.c * app/airbrush.[ch] * app/blend.[ch] * app/bucket_fill.[ch] * app/by_color_select.[ch] * app/clone.[ch] * app/color_picker.[ch] * app/convolve.[ch] * app/crop.[ch] * app/ellipse_select.[ch] * app/eraser.[ch] * app/flip_tool.[ch] * app/free_select.[ch] * app/fuzzy_select.[ch] * app/gimprc.[ch] * app/paintbrush.[ch] * app/pencil.[ch] * app/perspective_tool.[ch] * app/rect_select.c app/rect_select.h * app/rotate_tool.[ch] * app/scale_tool.[ch] * app/shear_tool.[ch]: bye bye PDB stuff (exported necessary enums functions, vars, etc.) * app/internal_procs.c: use register_foo functions * app/blend.[ch]: GradientType enum case changed * app/bucket_fill.[ch]: s/FillMode/BucketFillMode/, made the enum more consistent * app/clone.[ch]: capitalized the CloneType enum * app/color_picker.[ch]: changed get_color to pick_color so we don't conflict with colormaps.c get_color * app/convolve.[ch]: capitalized the ConvolveType enum * app/paint_core.h: made a GradientPaintMode enum * app/transform_core.h: BoundingBox enum * app/scale_tool.c: use the generic bounding box enum for X1, Y1, etc. * app/shear_tool.[ch]: turned HORZ and VERT into a ShearType enum -Yosh
This commit is contained in:
parent
03724da09d
commit
ccac10a4b0
63
ChangeLog
63
ChangeLog
|
@ -1,9 +1,64 @@
|
|||
Sun Apr 18 14:19:36 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/tools_cmds.c: new file, containes the PDB stuff for most
|
||||
of the tools
|
||||
|
||||
* app/gimprc_cmds.c: new file, PDB interface stuff for gimprc
|
||||
access
|
||||
|
||||
* app/Makefile.am: added tools_cmds.c and gimprc_cmds.c
|
||||
|
||||
* app/airbrush.[ch]
|
||||
* app/blend.[ch]
|
||||
* app/bucket_fill.[ch]
|
||||
* app/by_color_select.[ch]
|
||||
* app/clone.[ch]
|
||||
* app/color_picker.[ch]
|
||||
* app/convolve.[ch]
|
||||
* app/crop.[ch]
|
||||
* app/ellipse_select.[ch]
|
||||
* app/eraser.[ch]
|
||||
* app/flip_tool.[ch]
|
||||
* app/free_select.[ch]
|
||||
* app/fuzzy_select.[ch]
|
||||
* app/gimprc.[ch]
|
||||
* app/paintbrush.[ch]
|
||||
* app/pencil.[ch]
|
||||
* app/perspective_tool.[ch]
|
||||
* app/rect_select.c app/rect_select.h
|
||||
* app/rotate_tool.[ch]
|
||||
* app/scale_tool.[ch]
|
||||
* app/shear_tool.[ch]: bye bye PDB stuff (exported necessary enums
|
||||
functions, vars, etc.)
|
||||
|
||||
* app/internal_procs.c: use register_foo functions
|
||||
|
||||
* app/blend.[ch]: GradientType enum case changed
|
||||
|
||||
* app/bucket_fill.[ch]: s/FillMode/BucketFillMode/, made the enum
|
||||
more consistent
|
||||
|
||||
* app/clone.[ch]: capitalized the CloneType enum
|
||||
|
||||
* app/color_picker.[ch]: changed get_color to pick_color so we don't
|
||||
conflict with colormaps.c get_color
|
||||
|
||||
* app/convolve.[ch]: capitalized the ConvolveType enum
|
||||
|
||||
* app/paint_core.h: made a GradientPaintMode enum
|
||||
|
||||
* app/transform_core.h: BoundingBox enum
|
||||
|
||||
* app/scale_tool.c: use the generic bounding box enum for X1, Y1, etc.
|
||||
|
||||
* app/shear_tool.[ch]: turned HORZ and VERT into a ShearType enum
|
||||
|
||||
1999-04-18 Seth Burgess <sjburges@gimp.org>
|
||||
|
||||
* app/internal_procs.c
|
||||
* app/gimprc.h
|
||||
* app/gimprc.c: wrote a function to save arbitrary "token" "value" pairs
|
||||
in the user gimprc and added gimprc_set to the PDB.
|
||||
* app/internal_procs.c
|
||||
* app/gimprc.h
|
||||
* app/gimprc.c: wrote a function to save arbitrary "token" "value"
|
||||
pairs in the user gimprc and added gimprc_set to the PDB.
|
||||
|
||||
1999-04-18 Michael Natterer <mitschel@cs.tu-berlin.de>
|
||||
|
||||
|
|
|
@ -181,6 +181,10 @@ gimp_SOURCES = \
|
|||
gimpbrushlist.h \
|
||||
gimpbrushlistF.h \
|
||||
gimpbrushlistP.h \
|
||||
gimphistogram.c \
|
||||
gimphistogram.h \
|
||||
gimphistogramP.h \
|
||||
gimphistogramF.h \
|
||||
gimplist.c \
|
||||
gimplist.h \
|
||||
gimplistF.h \
|
||||
|
@ -195,10 +199,7 @@ gimp_SOURCES = \
|
|||
gimpprogress.h \
|
||||
gimprc.c \
|
||||
gimprc.h \
|
||||
gimphistogram.c \
|
||||
gimphistogram.h \
|
||||
gimphistogramP.h \
|
||||
gimphistogramF.h \
|
||||
gimprc_cmds.c \
|
||||
gimpunit.c \
|
||||
global_edit.c \
|
||||
global_edit.h \
|
||||
|
@ -354,6 +355,7 @@ gimp_SOURCES = \
|
|||
tools.c \
|
||||
tools.h \
|
||||
toolsF.h \
|
||||
tools_cmds.c \
|
||||
transform_core.c \
|
||||
transform_core.h \
|
||||
transform_tool.c \
|
||||
|
|
116
app/airbrush.c
116
app/airbrush.c
|
@ -76,7 +76,6 @@ static double non_gui_pressure;
|
|||
/* forward function declarations */
|
||||
static void airbrush_motion (PaintCore *, GimpDrawable *, double);
|
||||
static gint airbrush_time_out (gpointer);
|
||||
static Argument * airbrush_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -313,108 +312,18 @@ airbrush_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The airbrush procedure definition */
|
||||
ProcArg airbrush_args[] =
|
||||
gboolean
|
||||
airbrush_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"The pressure of the airbrush strokes: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord airbrush_proc =
|
||||
{
|
||||
"gimp_airbrush",
|
||||
"Paint in the current brush with varying pressure. Paint application is time-dependent",
|
||||
"This tool simulates the use of an airbrush. Paint pressure represents the relative intensity of the paint application. High pressure results in a thicker layer of paint while low pressure results in a thinner layer.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
airbrush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { airbrush_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
airbrush_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
non_gui_pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -434,12 +343,13 @@ airbrush_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&airbrush_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_airbrush (void);
|
||||
void tools_free_airbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord airbrush_proc;
|
||||
|
||||
#endif /* __AIRBRUSH_H__ */
|
||||
|
|
312
app/blend.c
312
app/blend.c
|
@ -161,17 +161,6 @@ static void blend_motion (Tool *, GdkEventMotion *, gpointer)
|
|||
static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void blend_control (Tool *, int, gpointer);
|
||||
|
||||
static void blend (GImage *gimage, GimpDrawable *drawable,
|
||||
BlendMode blend_mode, int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity, double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
static double gradient_calc_conical_asym_factor (double dist, double *axis, double offset,
|
||||
|
@ -211,8 +200,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
||||
static Argument *blend_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -303,27 +290,27 @@ blend_options_new ()
|
|||
static MenuItem gradient_option_items[] =
|
||||
{
|
||||
{ N_("Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Linear, NULL, NULL },
|
||||
(gpointer) LINEAR, NULL, NULL },
|
||||
{ N_("Bi-Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) BiLinear, NULL, NULL },
|
||||
(gpointer) BILINEAR, NULL, NULL },
|
||||
{ N_("Radial"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Radial, NULL, NULL },
|
||||
(gpointer) RADIAL, NULL, NULL },
|
||||
{ N_("Square"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Square, NULL, NULL },
|
||||
(gpointer) SQUARE, NULL, NULL },
|
||||
{ N_("Conical (symmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalSymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_SYMMETRIC, NULL, NULL },
|
||||
{ N_("Conical (asymmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalAsymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_ASYMMETRIC, NULL, NULL },
|
||||
{ N_("Shapeburst (angular)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstAngular, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_ANGULAR, NULL, NULL },
|
||||
{ N_("Shapeburst (spherical)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstSpherical, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_SPHERICAL, NULL, NULL },
|
||||
{ N_("Shapeburst (dimpled)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstDimpled, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_DIMPLED, NULL, NULL },
|
||||
{ N_("Spiral (clockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_CLOCKWISE, NULL, NULL },
|
||||
{ N_("Spiral (anticlockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralAntiClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_ANTICLOCKWISE, NULL, NULL },
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
static MenuItem repeat_option_items[] =
|
||||
|
@ -346,7 +333,7 @@ blend_options_new ()
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->offset = options->offset_d = 0.0;
|
||||
options->blend_mode = options->blend_mode_d = FG_BG_RGB_MODE;
|
||||
options->gradient_type = options->gradient_type_d = Linear;
|
||||
options->gradient_type = options->gradient_type_d = LINEAR;
|
||||
options->repeat = options->repeat_d = REPEAT_NONE;
|
||||
options->supersample = options->supersample_d = FALSE;
|
||||
options->max_depth = options->max_depth_d = 3;
|
||||
|
@ -821,7 +808,7 @@ blend_control (Tool *tool,
|
|||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
|
@ -1317,54 +1304,54 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data)
|
|||
|
||||
switch (rbd->gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
factor = gradient_calc_radial_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case CONICAL_SYMMETRIC:
|
||||
factor = gradient_calc_conical_sym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalAsymmetric:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
factor = gradient_calc_conical_asym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
factor = gradient_calc_square_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
case LINEAR:
|
||||
factor = gradient_calc_linear_factor(rbd->dist, rbd->vec,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case BiLinear:
|
||||
case BILINEAR:
|
||||
factor = gradient_calc_bilinear_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
factor = gradient_calc_shapeburst_angular_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstSpherical:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
factor = gradient_calc_shapeburst_spherical_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
factor = gradient_calc_shapeburst_dimpled_factor(x, y);
|
||||
break;
|
||||
|
||||
case SpiralClockwise:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,TRUE);
|
||||
break;
|
||||
|
||||
case SpiralAntiClockwise:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,FALSE);
|
||||
break;
|
||||
|
@ -1514,20 +1501,20 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
switch (gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
rbd.dist = MAXIMUM(fabs(ex - sx), fabs(ey - sy));
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case ConicalAsymmetric:
|
||||
case SpiralClockwise:
|
||||
case SpiralAntiClockwise:
|
||||
case Linear:
|
||||
case BiLinear:
|
||||
case CONICAL_SYMMETRIC:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
|
@ -1538,9 +1525,9 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case ShapeburstSpherical:
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
@ -1843,232 +1830,3 @@ tools_free_blend (Tool *tool)
|
|||
|
||||
g_free (blend_tool);
|
||||
}
|
||||
|
||||
|
||||
/* The blend procedure definition */
|
||||
ProcArg blend_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"blend_mode",
|
||||
"The type of blend: { FG-BG-RGB (0), FG-BG-HSV (1), FG-TRANS (2), CUSTOM (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"gradient_type",
|
||||
"The type of gradient: { LINEAR (0), BILINEAR (1), RADIAL (2), SQUARE (3), CONICAL-SYMMETRIC (4), CONICAL-ASYMMETRIC (5), SHAPEBURST-ANGULAR (6), SHAPEBURST-SPHERICAL (7), SHAPEBURST-DIMPLED (8), SPIRAL-CLOCKWISE(9), SPRIAL-ANTICLOCKWISE(10) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The opacity of the final blend (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"offset",
|
||||
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode depndent (0 <= offset)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"repeat",
|
||||
"Repeat mode: { REPEAT-NONE (0), REPEAT-SAWTOOTH (1), REPEAT-TRIANGULAR (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"supersample",
|
||||
"Do adaptive supersampling (true / false)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"max_depth",
|
||||
"Maximum recursion levels for supersampling"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"Supersampling threshold"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"The x coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"The y coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"The x coordinate of this blend's ending point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"The y coordinate of this blend's ending point"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord blend_proc =
|
||||
{
|
||||
"gimp_blend",
|
||||
"Blend between the starting and ending coordinates with the specified blend mode and gradient type.",
|
||||
"This tool requires information on the paint application mode, the blend mode, and the gradient type. It creates the specified variety of blend using the starting and ending coordinates as defined for each gradient type.",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
14,
|
||||
blend_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { blend_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
blend_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
BlendMode blend_mode;
|
||||
int paint_mode;
|
||||
GradientType gradient_type;
|
||||
double opacity;
|
||||
double offset;
|
||||
RepeatMode repeat;
|
||||
int supersample;
|
||||
int max_depth;
|
||||
double threshold;
|
||||
double x1, y1;
|
||||
double x2, y2;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
blend_mode = FG_BG_RGB_MODE;
|
||||
paint_mode = NORMAL_MODE;
|
||||
gradient_type = Linear;
|
||||
opacity = 100.0;
|
||||
offset = 0.0;
|
||||
repeat = REPEAT_NONE;
|
||||
supersample = FALSE;
|
||||
max_depth = 0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* blend mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < BLEND_MODE_LAST)
|
||||
blend_mode = (BlendMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= DIVIDE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* gradient type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < GradientTypeLast)
|
||||
gradient_type = (GradientType) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* offset */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[5].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
offset = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* repeat */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < REPEAT_LAST)
|
||||
repeat = (RepeatMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* supersampling */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
|
||||
supersample = (int_value ? TRUE : FALSE);
|
||||
}
|
||||
/* max_depth */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
|
||||
if (((int_value >= 1) && (int_value <= 9)) || !supersample)
|
||||
max_depth = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[9].value.pdb_float;
|
||||
|
||||
if (((fp_value >= 0.0) && (fp_value <= 4.0)) || !supersample)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* x1, y1, x2, y2 */
|
||||
if (success)
|
||||
{
|
||||
x1 = args[10].value.pdb_float;
|
||||
y1 = args[11].value.pdb_float;
|
||||
x2 = args[12].value.pdb_float;
|
||||
y2 = args[13].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
}
|
||||
|
|
37
app/blend.h
37
app/blend.h
|
@ -18,26 +18,28 @@
|
|||
#ifndef __BLEND_H__
|
||||
#define __BLEND_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Linear,
|
||||
BiLinear,
|
||||
Radial,
|
||||
Square,
|
||||
ConicalSymmetric,
|
||||
ConicalAsymmetric,
|
||||
ShapeburstAngular,
|
||||
ShapeburstSpherical,
|
||||
ShapeburstDimpled,
|
||||
SpiralClockwise,
|
||||
SpiralAntiClockwise,
|
||||
GradientTypeLast /*< skip >*/
|
||||
LINEAR,
|
||||
BILINEAR,
|
||||
RADIAL,
|
||||
SQUARE,
|
||||
CONICAL_SYMMETRIC,
|
||||
CONICAL_ASYMMETRIC,
|
||||
SHAPEBURST_ANGULAR,
|
||||
SHAPEBURST_SPHERICAL,
|
||||
SHAPEBURST_DIMPLED,
|
||||
SPIRAL_CLOCKWISE,
|
||||
SPIRAL_ANTICLOCKWISE,
|
||||
GRADIENT_TYPE_LAST /*< skip >*/
|
||||
} GradientType;
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_MODE >*/
|
||||
{
|
||||
FG_BG_RGB_MODE,
|
||||
FG_BG_HSV_MODE,
|
||||
|
@ -54,10 +56,11 @@ typedef enum
|
|||
REPEAT_LAST /*< skip >*/
|
||||
} RepeatMode;
|
||||
|
||||
void blend (GimpImage *, GimpDrawable *, BlendMode, int, GradientType,
|
||||
double, double, RepeatMode, int, int, double, double,
|
||||
double, double, double, progress_func_t, void *);
|
||||
|
||||
Tool * tools_new_blend (void);
|
||||
void tools_free_blend (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord blend_proc;
|
||||
|
||||
#endif /* __BLEND_H__ */
|
||||
|
|
|
@ -47,27 +47,27 @@ struct _BucketTool
|
|||
typedef struct _BucketOptions BucketOptions;
|
||||
struct _BucketOptions
|
||||
{
|
||||
ToolOptions tool_options;
|
||||
ToolOptions tool_options;
|
||||
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
|
||||
FillMode fill_mode;
|
||||
FillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
BucketFillMode fill_mode;
|
||||
BucketFillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,11 +82,7 @@ static void bucket_fill_motion (Tool *, GdkEventMotion *, gpointer);
|
|||
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void bucket_fill_control (Tool *, int, gpointer);
|
||||
|
||||
static void bucket_fill (GImage *, GimpDrawable *, FillMode,
|
||||
int, double, double,
|
||||
int, double, double);
|
||||
|
||||
static void bucket_fill_region (FillMode, PixelRegion *, PixelRegion *,
|
||||
static void bucket_fill_region (BucketFillMode, PixelRegion *, PixelRegion *,
|
||||
unsigned char *, TempBuf *,
|
||||
int, int, int);
|
||||
static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
||||
|
@ -94,8 +90,6 @@ static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
|||
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
|
||||
TempBuf *, int, int, int, int, int);
|
||||
|
||||
static Argument *bucket_fill_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -103,7 +97,7 @@ static void
|
|||
bucket_fill_mode_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
bucket_options->fill_mode = (FillMode) client_data;
|
||||
bucket_options->fill_mode = (BucketFillMode) client_data;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -128,7 +122,7 @@ bucket_options_reset (void)
|
|||
options->sample_merged_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w),
|
||||
options->threshold_d);
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FgColorFill) ?
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FG_BUCKET_FILL) ?
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[1])),
|
||||
TRUE);
|
||||
|
@ -168,7 +162,7 @@ bucket_options_new (void)
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->sample_merged = options->sample_merged_d = FALSE;
|
||||
options->threshold = options->threshold_d = 15.0;
|
||||
options->fill_mode = options->fill_mode_d = FgColorFill;
|
||||
options->fill_mode = options->fill_mode_d = FG_BUCKET_FILL;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = options->tool_options.main_vbox;
|
||||
|
@ -269,7 +263,7 @@ bucket_options_new (void)
|
|||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
|
||||
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
|
||||
(GtkSignalFunc) bucket_fill_mode_callback,
|
||||
(gpointer) ((long) (i == 1 ? PatternFill : FgColorFill))); /* kludgy */
|
||||
(gpointer) ((long) (i == 1 ? PATTERN_BUCKET_FILL : FG_BUCKET_FILL))); /* kludgy */
|
||||
gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (radio_button);
|
||||
|
||||
|
@ -318,7 +312,7 @@ bucket_fill_button_release (Tool *tool,
|
|||
{
|
||||
GDisplay * gdisp;
|
||||
BucketTool * bucket_tool;
|
||||
FillMode fill_mode;
|
||||
BucketFillMode fill_mode;
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
|
@ -334,8 +328,8 @@ bucket_fill_button_release (Tool *tool,
|
|||
fill_mode = bucket_options->fill_mode;
|
||||
|
||||
/* If the mode is color filling, and shift mask is down, fill with background */
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FgColorFill)
|
||||
fill_mode = BgColorFill;
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FG_BUCKET_FILL)
|
||||
fill_mode = BG_BUCKET_FILL;
|
||||
|
||||
return_vals = procedural_db_run_proc ("gimp_bucket_fill",
|
||||
&nreturn_vals,
|
||||
|
@ -411,16 +405,16 @@ bucket_fill_control (Tool *tool,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
bucket_fill (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
FillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
void
|
||||
bucket_fill (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BucketFillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR, maskPR;
|
||||
|
@ -435,11 +429,11 @@ bucket_fill (GImage *gimage,
|
|||
|
||||
pat_buf = NULL;
|
||||
|
||||
if (fill_mode == FgColorFill)
|
||||
if (fill_mode == FG_BUCKET_FILL)
|
||||
gimage_get_foreground (gimage, drawable, col);
|
||||
else if (fill_mode == BgColorFill)
|
||||
else if (fill_mode == BG_BUCKET_FILL)
|
||||
gimage_get_background (gimage, drawable, col);
|
||||
else if (fill_mode == PatternFill)
|
||||
else if (fill_mode == PATTERN_BUCKET_FILL)
|
||||
{
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
|
@ -629,14 +623,14 @@ bucket_fill_line_pattern (unsigned char *buf,
|
|||
|
||||
|
||||
static void
|
||||
bucket_fill_region (FillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
bucket_fill_region (BucketFillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
{
|
||||
unsigned char *s, *m;
|
||||
int y;
|
||||
|
@ -654,11 +648,11 @@ bucket_fill_region (FillMode fill_mode,
|
|||
{
|
||||
switch (fill_mode)
|
||||
{
|
||||
case FgColorFill:
|
||||
case BgColorFill:
|
||||
case FG_BUCKET_FILL:
|
||||
case BG_BUCKET_FILL:
|
||||
bucket_fill_line_color (s, m, col, has_alpha, bufPR->bytes, bufPR->w);
|
||||
break;
|
||||
case PatternFill:
|
||||
case PATTERN_BUCKET_FILL:
|
||||
bucket_fill_line_pattern (s, m, pattern, has_alpha, bufPR->bytes,
|
||||
off_x + bufPR->x, off_y + y + bufPR->y, bufPR->w);
|
||||
break;
|
||||
|
@ -722,158 +716,3 @@ tools_free_bucket_fill (Tool *tool)
|
|||
|
||||
g_free (bucket_tool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The bucket fill procedure definition */
|
||||
ProcArg bucket_fill_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_mode",
|
||||
"the type of fill: { FG-BUCKET-FILL (0), BG-BUCKET-FILL (1), PATTERN-BUCKET-FILL (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the opacity of the final bucket fill (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"the threshold determines how extensive the seed fill will be. It's value is specified in terms of intensity levels (0 <= threshold <= 255). This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"the x coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"the y coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord bucket_fill_proc =
|
||||
{
|
||||
"gimp_bucket_fill",
|
||||
"Fill the area specified either by the current selection if there is one, or by a seed fill starting at the specified coordinates.",
|
||||
"This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x,y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
bucket_fill_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { bucket_fill_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
bucket_fill_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
FillMode fill_mode;
|
||||
int paint_mode;
|
||||
double opacity;
|
||||
double threshold;
|
||||
int sample_merged;
|
||||
double x, y;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
fill_mode = BgColorFill;
|
||||
paint_mode = NORMAL_MODE;
|
||||
opacity = 100.0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fill mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: fill_mode = FgColorFill; break;
|
||||
case 1: fill_mode = BgColorFill; break;
|
||||
case 2: fill_mode = PatternFill; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= VALUE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[3].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 255.0)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* sample_merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[6].value.pdb_float;
|
||||
y = args[7].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
bucket_fill (gimage, drawable, fill_mode, paint_mode,
|
||||
opacity, threshold, sample_merged, x, y);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&bucket_fill_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,20 +18,21 @@
|
|||
#ifndef __BUCKET_FILL_H__
|
||||
#define __BUCKET_FILL_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FgColorFill,
|
||||
BgColorFill,
|
||||
PatternFill
|
||||
} FillMode;
|
||||
FG_BUCKET_FILL,
|
||||
BG_BUCKET_FILL,
|
||||
PATTERN_BUCKET_FILL
|
||||
} BucketFillMode;
|
||||
|
||||
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
|
||||
double, double, int, double, double);
|
||||
|
||||
Tool * tools_new_bucket_fill (void);
|
||||
void tools_free_bucket_fill (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord bucket_fill_proc;
|
||||
|
||||
#endif /* __BUCKET_FILL_H__ */
|
||||
|
|
|
@ -90,9 +90,6 @@ static void by_color_select_preview_button_press (ByColorDialog *, G
|
|||
|
||||
static int is_pixel_sufficiently_different (unsigned char *, unsigned char *, int, int, int, int);
|
||||
static Channel * by_color_select_color (GImage *, GimpDrawable *, unsigned char *, int, int, int);
|
||||
static void by_color_select (GImage *, GimpDrawable *, unsigned char *, int, int, int, int, double, int);
|
||||
static Argument * by_color_select_invoker (Argument *);
|
||||
|
||||
|
||||
/* by_color selection machinery */
|
||||
|
||||
|
@ -243,7 +240,7 @@ by_color_select_color (GImage *gimage,
|
|||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
by_color_select (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
unsigned char *color,
|
||||
|
@ -972,157 +969,3 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
by_color_select_render (bcd, bcd->gimage);
|
||||
by_color_select_draw (bcd, bcd->gimage);
|
||||
}
|
||||
|
||||
|
||||
/* The by_color_select procedure definition */
|
||||
ProcArg by_color_select_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_COLOR,
|
||||
"color",
|
||||
"the color to select"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"threshold",
|
||||
"threshold in intensity levels: 0 <= threshold <= 255"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord by_color_select_proc =
|
||||
{
|
||||
"gimp_by_color_select",
|
||||
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
|
||||
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
by_color_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { by_color_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
by_color_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int op;
|
||||
int threshold;
|
||||
int antialias;
|
||||
int feather;
|
||||
int sample_merged;
|
||||
unsigned char color[3];
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
drawable = NULL;
|
||||
op = REPLACE;
|
||||
threshold = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* color */
|
||||
if (success)
|
||||
{
|
||||
int i;
|
||||
unsigned char *color_array;
|
||||
|
||||
color_array = (unsigned char *) args[1].value.pdb_pointer;
|
||||
for (i = 0; i < 3; i++)
|
||||
color[i] = color_array[i];
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= 0 && int_value <= 255)
|
||||
threshold = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[6].value.pdb_float;
|
||||
}
|
||||
/* sample merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* call the ellipse_select procedure */
|
||||
if (success)
|
||||
by_color_select (gimage, drawable, color, threshold, op,
|
||||
antialias, feather, feather_radius, sample_merged);
|
||||
|
||||
return procedural_db_return_args (&by_color_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -19,18 +19,17 @@
|
|||
#define __BY_COLOR_SELECT_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gdisplayF.h"
|
||||
#include "gimage.h"
|
||||
|
||||
/* by_color select functions */
|
||||
void by_color_select (GimpImage *, GimpDrawable *, guchar *, int,
|
||||
int, int, int, double, int);
|
||||
|
||||
Tool * tools_new_by_color_select (void);
|
||||
void tools_free_by_color_select (Tool *);
|
||||
|
||||
void by_color_select_initialize (GDisplay *);
|
||||
void by_color_select_initialize_by_image (GImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord by_color_select_proc;
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
169
app/clone.c
169
app/clone.c
|
@ -89,8 +89,6 @@ static void clone_line_image (GImage *, GImage *, GimpDrawable *, GimpD
|
|||
static void clone_line_pattern (GImage *, GimpDrawable *, GPatternP, unsigned char *,
|
||||
int, int, int, int);
|
||||
|
||||
static Argument * clone_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -146,7 +144,7 @@ clone_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Clone Tool Options"),
|
||||
clone_options_reset);
|
||||
options->type = options->type_d = ImageClone;
|
||||
options->type = options->type_d = IMAGE_CLONE;
|
||||
options->aligned = options->aligned_d = AlignNo;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -303,7 +301,7 @@ clone_paint_func (PaintCore *paint_core,
|
|||
orig_src_x = src_x;
|
||||
orig_src_y = src_y;
|
||||
}
|
||||
if (clone_options->type == PatternClone)
|
||||
if (clone_options->type == PATTERN_CLONE)
|
||||
if (!get_active_pattern ())
|
||||
g_message (_("No patterns available for this operation."));
|
||||
break;
|
||||
|
@ -382,7 +380,7 @@ clone_draw (Tool *tool)
|
|||
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
if (clone_options->type == ImageClone)
|
||||
if (clone_options->type == IMAGE_CLONE)
|
||||
{
|
||||
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
|
||||
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
|
||||
|
@ -418,7 +416,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pattern = NULL;
|
||||
|
||||
/* Make sure we still have a source if we are doing image cloning */
|
||||
if (type == ImageClone)
|
||||
if (type == IMAGE_CLONE)
|
||||
{
|
||||
if (!src_drawable)
|
||||
return;
|
||||
|
@ -438,7 +436,7 @@ clone_motion (PaintCore *paint_core,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
/* Set the paint area to transparent */
|
||||
memset (temp_buf_data (area), 0, area->width * area->height * area->bytes);
|
||||
|
||||
|
@ -500,7 +498,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
break;
|
||||
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
if (!pattern)
|
||||
|
@ -525,12 +523,12 @@ clone_motion (PaintCore *paint_core,
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
clone_line_image (gimage, src_gimage, drawable, src_drawable, s, d,
|
||||
has_alpha, srcPR.bytes, destPR.bytes, destPR.w);
|
||||
s += srcPR.rowstride;
|
||||
break;
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
clone_line_pattern (gimage, drawable, pattern, d,
|
||||
area->x + offset_x, area->y + y + offset_y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
@ -630,141 +628,25 @@ clone_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The clone procedure definition */
|
||||
ProcArg clone_args[] =
|
||||
gboolean
|
||||
clone_non_gui (GimpDrawable *drawable,
|
||||
GimpDrawable *src_drawable,
|
||||
CloneType clone_type,
|
||||
double src_x,
|
||||
double src_y,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_DRAWABLE,
|
||||
"src_drawable",
|
||||
"the source drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"clone_type",
|
||||
"the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_x",
|
||||
"the x coordinate in the source image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_y",
|
||||
"the y coordinate in the source image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord clone_proc =
|
||||
{
|
||||
"gimp_clone",
|
||||
"Clone from the source to the dest drawable using the current brush",
|
||||
"This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \"clone_type\" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \"src_drawable\" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
clone_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { clone_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
clone_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable *src_drawable;
|
||||
double src_x, src_y;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the src drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
src_drawable = drawable_get_ID (int_value);
|
||||
if (src_drawable == NULL || gimage != drawable_gimage (src_drawable))
|
||||
success = FALSE;
|
||||
else
|
||||
non_gui_src_drawable = src_drawable;
|
||||
}
|
||||
/* the clone type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: non_gui_type = ImageClone; break;
|
||||
case 1: non_gui_type = PatternClone; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* x, y offsets */
|
||||
if (success)
|
||||
{
|
||||
src_x = args[3].value.pdb_float;
|
||||
src_y = args[4].value.pdb_float;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[6].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
|
||||
|
||||
non_gui_src_drawable = src_drawable;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
|
@ -785,12 +667,13 @@ clone_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&clone_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
10
app/clone.h
10
app/clone.h
|
@ -19,20 +19,18 @@
|
|||
#define __CLONE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ImageClone,
|
||||
PatternClone
|
||||
IMAGE_CLONE,
|
||||
PATTERN_CLONE
|
||||
} CloneType;
|
||||
|
||||
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
|
||||
double, double, int, double *);
|
||||
Tool * tools_new_clone (void);
|
||||
void tools_free_clone (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord clone_proc;
|
||||
|
||||
#endif /* __CLONE_H__ */
|
||||
|
|
|
@ -66,8 +66,10 @@ struct _ColourPickerTool
|
|||
/* the color picker tool options */
|
||||
static ColorPickerOptions * color_picker_options = NULL;
|
||||
|
||||
/* the color value */
|
||||
int col_value[5] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
/* the color picker dialog */
|
||||
static int col_value [5] = { 0, 0, 0, 0, 0 };
|
||||
static GimpDrawable * active_drawable;
|
||||
static int update_type;
|
||||
static int sample_type;
|
||||
|
@ -89,11 +91,8 @@ static void color_picker_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
|||
static void color_picker_control (Tool *, int, void *);
|
||||
static void color_picker_info_window_close_callback (GtkWidget *, gpointer);
|
||||
|
||||
static int get_color (GimpImage *, GimpDrawable *, int, int, gboolean, gboolean, double, int);
|
||||
static void color_picker_info_update (Tool *, int);
|
||||
|
||||
static Argument *color_picker_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -282,20 +281,20 @@ color_picker_button_press (Tool *tool,
|
|||
*/
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_NEW));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_NEW));
|
||||
update_type = COLOR_UPDATE_NEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_UPDATE));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_UPDATE));
|
||||
update_type = COLOR_UPDATE;
|
||||
}
|
||||
|
||||
|
@ -321,11 +320,11 @@ color_picker_button_release (Tool *tool,
|
|||
/* First, transform the coordinates to gimp image space */
|
||||
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
|
||||
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
|
||||
draw_core_stop (cp_tool->core, tool);
|
||||
tool->state = INACTIVE;
|
||||
|
@ -351,11 +350,11 @@ color_picker_motion (Tool *tool,
|
|||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &cp_tool->centerx, &cp_tool->centery, FALSE, TRUE);
|
||||
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
/* redraw the current tool */
|
||||
draw_core_resume (cp_tool->core, tool);
|
||||
}
|
||||
|
@ -402,15 +401,15 @@ color_picker_control (Tool *tool,
|
|||
|
||||
typedef guchar * (*GetColorFunc) (GtkObject *, int, int);
|
||||
|
||||
static int
|
||||
get_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int x,
|
||||
int y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
double average_radius,
|
||||
int final)
|
||||
int
|
||||
pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int x,
|
||||
int y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
double average_radius,
|
||||
int final)
|
||||
{
|
||||
guchar *color;
|
||||
int offx, offy;
|
||||
|
@ -652,133 +651,6 @@ tools_free_color_picker (Tool *tool)
|
|||
g_free(cp_tool);
|
||||
}
|
||||
|
||||
/* The color_picker procedure definition */
|
||||
ProcArg color_picker_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"save_color",
|
||||
"save the color to the active palette"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg color_picker_out_args[] =
|
||||
{
|
||||
{ PDB_COLOR,
|
||||
"color",
|
||||
"the return color"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord color_picker_proc =
|
||||
{
|
||||
"gimp_color_picker",
|
||||
"Determine the color at the given drawable coordinates",
|
||||
"This tool determines the color at the specified coordinates. The returned color is an RGB triplet even for grayscale and indexed drawables. If the coordinates lie outside of the extents of the specified drawable, then an error is returned. If the drawable has an alpha channel, the algorithm examines the alpha value of the drawable at the coordinates. If the alpha value is completely transparent (0), then an error is returned. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
color_picker_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
color_picker_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { color_picker_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
color_picker_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
int success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
double x, y;
|
||||
int sample_merged;
|
||||
int save_color;
|
||||
int int_value;
|
||||
Argument *return_args;
|
||||
unsigned char *color;
|
||||
|
||||
drawable = NULL;
|
||||
x = 0;
|
||||
y = 0;
|
||||
sample_merged = FALSE;
|
||||
save_color = COLOR_UPDATE;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
}
|
||||
/* sample_merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* save_color */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
save_color = (int_value) ? COLOR_NEW : COLOR_UPDATE;
|
||||
}
|
||||
|
||||
/* Make sure that if we're not using the composite, the specified drawable is valid */
|
||||
if (success && !sample_merged)
|
||||
if (!drawable || (drawable_gimage (drawable)) != gimage)
|
||||
success = FALSE;
|
||||
|
||||
/* call the color_picker procedure */
|
||||
if (success)
|
||||
success = get_color (gimage, drawable, (int) x, (int) y, sample_merged, FALSE, 1.0, save_color);
|
||||
|
||||
return_args = procedural_db_return_args (&color_picker_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
color = (unsigned char *) g_malloc (3);
|
||||
color[RED_PIX] = col_value[RED_PIX];
|
||||
color[GREEN_PIX] = col_value[GREEN_PIX];
|
||||
color[BLUE_PIX] = col_value[BLUE_PIX];
|
||||
return_args[1].value.pdb_pointer = color;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static void
|
||||
color_picker_info_window_close_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
|
|
|
@ -18,13 +18,16 @@
|
|||
#ifndef __COLOR_PICKER_H__
|
||||
#define __COLOR_PICKER_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "tools.h"
|
||||
|
||||
int pick_color (GimpImage *, GimpDrawable *, int , int,
|
||||
gboolean, gboolean, double, int);
|
||||
|
||||
Tool * tools_new_color_picker (void);
|
||||
void tools_free_color_picker (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord color_picker_proc;
|
||||
extern int col_value[5];
|
||||
|
||||
#endif /* __COLOR_PICKER_H__ */
|
||||
|
|
144
app/convolve.c
144
app/convolve.c
|
@ -98,7 +98,6 @@ static void copy_matrix (float *, float *, int);
|
|||
static int sum_matrix (int *, int);
|
||||
|
||||
static void convolve_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * convolve_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -147,7 +146,7 @@ convolve_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Convolver Options"),
|
||||
convolve_options_reset);
|
||||
options->type = options->type_d = Blur;
|
||||
options->type = options->type_d = BLUR_CONVOLVE;
|
||||
options->pressure = options->pressure_d = 50.0;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -364,19 +363,19 @@ calculate_matrix (ConvolveType type,
|
|||
/* get the appropriate convolution matrix and size and divisor */
|
||||
switch (type)
|
||||
{
|
||||
case Blur:
|
||||
case BLUR_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
blur_matrix [12] = MIN_BLUR + percent * (MAX_BLUR - MIN_BLUR);
|
||||
copy_matrix (blur_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Sharpen:
|
||||
case SHARPEN_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
sharpen_matrix [12] = MIN_SHARPEN + percent * (MAX_SHARPEN - MIN_SHARPEN);
|
||||
copy_matrix (sharpen_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Custom:
|
||||
case CUSTOM_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
break;
|
||||
}
|
||||
|
@ -437,128 +436,18 @@ convolve_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The convolve procedure definition */
|
||||
ProcArg convolve_args[] =
|
||||
gboolean
|
||||
convolve_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"the pressure: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"convolve_type",
|
||||
"convolve type: { BLUR (0), SHARPEN (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord convolve_proc =
|
||||
{
|
||||
"gimp_convolve",
|
||||
"Convolve (Blur, Sharpen) using the current brush",
|
||||
"This tool convolves the specified drawable with either a sharpening or blurring kernel. The pressure parameter controls the magnitude of the operation. Like the paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
convolve_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { convolve_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
convolve_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
double pressure;
|
||||
ConvolveType type;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
ConvolveType int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
pressure = 100.0;
|
||||
type = Blur;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_int;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* the convolve type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: type = Blur; break;
|
||||
case 1: type = Sharpen; break;
|
||||
case 2: success = FALSE; break; /*type = Custom; break;*/
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[4].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = convolve_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -578,12 +467,13 @@ convolve_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&convolve_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,21 +19,18 @@
|
|||
#define __CONVOLVE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_CONVOLVE >*/
|
||||
{
|
||||
Blur,
|
||||
Sharpen,
|
||||
Custom
|
||||
BLUR_CONVOLVE,
|
||||
SHARPEN_CONVOLVE,
|
||||
CUSTOM_CONVOLVE
|
||||
} ConvolveType;
|
||||
|
||||
void * convolve_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean convolve_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_convolve (void);
|
||||
void tools_free_convolve (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord convolve_proc;
|
||||
|
||||
#endif /* __CONVOLVE_H__ */
|
||||
|
|
|
@ -161,17 +161,6 @@ static void blend_motion (Tool *, GdkEventMotion *, gpointer)
|
|||
static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void blend_control (Tool *, int, gpointer);
|
||||
|
||||
static void blend (GImage *gimage, GimpDrawable *drawable,
|
||||
BlendMode blend_mode, int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity, double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
static double gradient_calc_conical_asym_factor (double dist, double *axis, double offset,
|
||||
|
@ -211,8 +200,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
||||
static Argument *blend_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -303,27 +290,27 @@ blend_options_new ()
|
|||
static MenuItem gradient_option_items[] =
|
||||
{
|
||||
{ N_("Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Linear, NULL, NULL },
|
||||
(gpointer) LINEAR, NULL, NULL },
|
||||
{ N_("Bi-Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) BiLinear, NULL, NULL },
|
||||
(gpointer) BILINEAR, NULL, NULL },
|
||||
{ N_("Radial"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Radial, NULL, NULL },
|
||||
(gpointer) RADIAL, NULL, NULL },
|
||||
{ N_("Square"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Square, NULL, NULL },
|
||||
(gpointer) SQUARE, NULL, NULL },
|
||||
{ N_("Conical (symmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalSymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_SYMMETRIC, NULL, NULL },
|
||||
{ N_("Conical (asymmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalAsymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_ASYMMETRIC, NULL, NULL },
|
||||
{ N_("Shapeburst (angular)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstAngular, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_ANGULAR, NULL, NULL },
|
||||
{ N_("Shapeburst (spherical)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstSpherical, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_SPHERICAL, NULL, NULL },
|
||||
{ N_("Shapeburst (dimpled)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstDimpled, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_DIMPLED, NULL, NULL },
|
||||
{ N_("Spiral (clockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_CLOCKWISE, NULL, NULL },
|
||||
{ N_("Spiral (anticlockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralAntiClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_ANTICLOCKWISE, NULL, NULL },
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
static MenuItem repeat_option_items[] =
|
||||
|
@ -346,7 +333,7 @@ blend_options_new ()
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->offset = options->offset_d = 0.0;
|
||||
options->blend_mode = options->blend_mode_d = FG_BG_RGB_MODE;
|
||||
options->gradient_type = options->gradient_type_d = Linear;
|
||||
options->gradient_type = options->gradient_type_d = LINEAR;
|
||||
options->repeat = options->repeat_d = REPEAT_NONE;
|
||||
options->supersample = options->supersample_d = FALSE;
|
||||
options->max_depth = options->max_depth_d = 3;
|
||||
|
@ -821,7 +808,7 @@ blend_control (Tool *tool,
|
|||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
|
@ -1317,54 +1304,54 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data)
|
|||
|
||||
switch (rbd->gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
factor = gradient_calc_radial_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case CONICAL_SYMMETRIC:
|
||||
factor = gradient_calc_conical_sym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalAsymmetric:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
factor = gradient_calc_conical_asym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
factor = gradient_calc_square_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
case LINEAR:
|
||||
factor = gradient_calc_linear_factor(rbd->dist, rbd->vec,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case BiLinear:
|
||||
case BILINEAR:
|
||||
factor = gradient_calc_bilinear_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
factor = gradient_calc_shapeburst_angular_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstSpherical:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
factor = gradient_calc_shapeburst_spherical_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
factor = gradient_calc_shapeburst_dimpled_factor(x, y);
|
||||
break;
|
||||
|
||||
case SpiralClockwise:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,TRUE);
|
||||
break;
|
||||
|
||||
case SpiralAntiClockwise:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,FALSE);
|
||||
break;
|
||||
|
@ -1514,20 +1501,20 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
switch (gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
rbd.dist = MAXIMUM(fabs(ex - sx), fabs(ey - sy));
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case ConicalAsymmetric:
|
||||
case SpiralClockwise:
|
||||
case SpiralAntiClockwise:
|
||||
case Linear:
|
||||
case BiLinear:
|
||||
case CONICAL_SYMMETRIC:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
|
@ -1538,9 +1525,9 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case ShapeburstSpherical:
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
@ -1843,232 +1830,3 @@ tools_free_blend (Tool *tool)
|
|||
|
||||
g_free (blend_tool);
|
||||
}
|
||||
|
||||
|
||||
/* The blend procedure definition */
|
||||
ProcArg blend_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"blend_mode",
|
||||
"The type of blend: { FG-BG-RGB (0), FG-BG-HSV (1), FG-TRANS (2), CUSTOM (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"gradient_type",
|
||||
"The type of gradient: { LINEAR (0), BILINEAR (1), RADIAL (2), SQUARE (3), CONICAL-SYMMETRIC (4), CONICAL-ASYMMETRIC (5), SHAPEBURST-ANGULAR (6), SHAPEBURST-SPHERICAL (7), SHAPEBURST-DIMPLED (8), SPIRAL-CLOCKWISE(9), SPRIAL-ANTICLOCKWISE(10) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The opacity of the final blend (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"offset",
|
||||
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode depndent (0 <= offset)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"repeat",
|
||||
"Repeat mode: { REPEAT-NONE (0), REPEAT-SAWTOOTH (1), REPEAT-TRIANGULAR (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"supersample",
|
||||
"Do adaptive supersampling (true / false)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"max_depth",
|
||||
"Maximum recursion levels for supersampling"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"Supersampling threshold"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"The x coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"The y coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"The x coordinate of this blend's ending point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"The y coordinate of this blend's ending point"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord blend_proc =
|
||||
{
|
||||
"gimp_blend",
|
||||
"Blend between the starting and ending coordinates with the specified blend mode and gradient type.",
|
||||
"This tool requires information on the paint application mode, the blend mode, and the gradient type. It creates the specified variety of blend using the starting and ending coordinates as defined for each gradient type.",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
14,
|
||||
blend_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { blend_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
blend_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
BlendMode blend_mode;
|
||||
int paint_mode;
|
||||
GradientType gradient_type;
|
||||
double opacity;
|
||||
double offset;
|
||||
RepeatMode repeat;
|
||||
int supersample;
|
||||
int max_depth;
|
||||
double threshold;
|
||||
double x1, y1;
|
||||
double x2, y2;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
blend_mode = FG_BG_RGB_MODE;
|
||||
paint_mode = NORMAL_MODE;
|
||||
gradient_type = Linear;
|
||||
opacity = 100.0;
|
||||
offset = 0.0;
|
||||
repeat = REPEAT_NONE;
|
||||
supersample = FALSE;
|
||||
max_depth = 0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* blend mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < BLEND_MODE_LAST)
|
||||
blend_mode = (BlendMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= DIVIDE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* gradient type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < GradientTypeLast)
|
||||
gradient_type = (GradientType) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* offset */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[5].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
offset = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* repeat */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < REPEAT_LAST)
|
||||
repeat = (RepeatMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* supersampling */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
|
||||
supersample = (int_value ? TRUE : FALSE);
|
||||
}
|
||||
/* max_depth */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
|
||||
if (((int_value >= 1) && (int_value <= 9)) || !supersample)
|
||||
max_depth = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[9].value.pdb_float;
|
||||
|
||||
if (((fp_value >= 0.0) && (fp_value <= 4.0)) || !supersample)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* x1, y1, x2, y2 */
|
||||
if (success)
|
||||
{
|
||||
x1 = args[10].value.pdb_float;
|
||||
y1 = args[11].value.pdb_float;
|
||||
x2 = args[12].value.pdb_float;
|
||||
y2 = args[13].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
}
|
||||
|
|
104
app/crop.c
104
app/crop.c
|
@ -110,8 +110,6 @@ static void crop_control (Tool *, int, gpointer);
|
|||
static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer);
|
||||
|
||||
/* Crop helper functions */
|
||||
static void crop_image (GImage *gimage,
|
||||
int, int, int, int, int, int);
|
||||
static void crop_recalc (Tool *, Crop *);
|
||||
static void crop_start (Tool *, Crop *);
|
||||
static void crop_adjust_guides (GImage *, int, int, int, int);
|
||||
|
@ -143,8 +141,6 @@ static int crop_colors_alpha (guchar *, guchar *, int);
|
|||
static void crop_orig_changed (GtkWidget *, gpointer);
|
||||
static void crop_size_changed (GtkWidget *, gpointer);
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
|
@ -837,7 +833,7 @@ tools_free_crop (Tool *tool)
|
|||
g_free (crop);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
crop_image (GImage *gimage,
|
||||
int x1,
|
||||
int y1,
|
||||
|
@ -1548,101 +1544,3 @@ crop_size_changed (GtkWidget *w,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg crop_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_width",
|
||||
"new image width: (0 < new_width <= width)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_height",
|
||||
"new image height: (0 < new_height <= height)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offx",
|
||||
"x offset: (0 <= offx <= (width - new_width))"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offy",
|
||||
"y offset: (0 <= offy <= (height - new_height))"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord crop_proc =
|
||||
{
|
||||
"gimp_crop",
|
||||
"Crop the image to the specified extents.",
|
||||
"This procedure crops the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. All channels and layers within the image are cropped to the new image extents; this includes the image selection mask. If any parameters are out of range, an error is returned.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
crop_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { crop_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
crop_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
int success;
|
||||
int int_value;
|
||||
int new_width, new_height;
|
||||
int offx, offy;
|
||||
int layer_only, crop_layers ;
|
||||
|
||||
new_width = 1;
|
||||
new_height = 1;
|
||||
offx = 0;
|
||||
offy = 0;
|
||||
layer_only = FALSE;
|
||||
crop_layers = TRUE;
|
||||
|
||||
success = TRUE;
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if ((gimage = gimage_get_ID (int_value)) == NULL)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
new_width = args[1].value.pdb_int;
|
||||
new_height = args[2].value.pdb_int;
|
||||
|
||||
if (new_width <= 0 || new_height <= 0)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offx = args[3].value.pdb_int;
|
||||
offy = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if ((new_width <= 0 || new_width > gimage->width) ||
|
||||
(new_height <= 0 || new_height > gimage->height) ||
|
||||
(offx < 0 || offx > (gimage->width - new_width)) ||
|
||||
(offy < 0 || offy > (gimage->height - new_height)))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
layer_only, crop_layers);
|
||||
|
||||
return procedural_db_return_args (&crop_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
#ifndef __CROP_H__
|
||||
#define __CROP_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
/* select functions */
|
||||
void crop_draw (Tool *);
|
||||
void crop_image (GimpImage *gimage, int, int, int, int, int, int);
|
||||
|
||||
Tool * tools_new_crop (void);
|
||||
void tools_free_crop (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord crop_proc;
|
||||
|
||||
#endif /* __CROP_H__ */
|
||||
|
||||
|
||||
|
|
|
@ -33,25 +33,19 @@
|
|||
SelectionOptions * ellipse_options = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
static Argument *ellipse_select_invoker (Argument *);
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Ellipsoidal selection apparatus */
|
||||
|
||||
void
|
||||
ellipse_select (GImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
ellipse_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
|
||||
|
@ -161,136 +155,3 @@ tools_free_ellipse_select (Tool *tool)
|
|||
draw_core_free (ellipse_sel->core);
|
||||
g_free (ellipse_sel);
|
||||
}
|
||||
|
||||
/* The ellipse_select procedure definition */
|
||||
ProcArg ellipse_select_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of upper-left corner of ellipse bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of upper-left corner of ellipse bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"width",
|
||||
"the width of the ellipse: width > 0"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"height",
|
||||
"the height of the ellipse: height > 0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord ellipse_select_proc =
|
||||
{
|
||||
"gimp_ellipse_select",
|
||||
"Create an elliptical selection over the specified image",
|
||||
"This tool creates an elliptical selection over the specified image. The elliptical region can be either added to, subtracted from, or replace the contents of the previous selection mask. If antialiasing is turned on, the edges of the elliptical region will contain intermediate values which give the appearance of a sharper, less pixelized edge. This should be set as TRUE most of the time. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
9,
|
||||
ellipse_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { ellipse_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
ellipse_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
int op;
|
||||
int antialias;
|
||||
int feather;
|
||||
double x, y;
|
||||
double w, h;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
op = REPLACE;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
/* x, y, w, h */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
w = args[3].value.pdb_float;
|
||||
h = args[4].value.pdb_float;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[8].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the ellipse_select procedure */
|
||||
if (success)
|
||||
ellipse_select (gimage, (int) x, (int) y, (int) w, (int) h,
|
||||
op, antialias, feather, feather_radius);
|
||||
|
||||
return procedural_db_return_args (&ellipse_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
#ifndef __ELLIPSE_SELECT_H__
|
||||
#define __ELLIPSE_SELECT_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
|
||||
/* ellipse select functions */
|
||||
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select (GimpImage *, int, int, int, int, int,
|
||||
int, int, double);
|
||||
|
||||
Tool * tools_new_ellipse_select (void);
|
||||
void tools_free_ellipse_select (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord ellipse_select_proc;
|
||||
|
||||
#endif /* __ELLIPSE_SELECT_H__ */
|
||||
|
|
236
app/eraser.c
236
app/eraser.c
|
@ -59,8 +59,6 @@ static gboolean non_gui_incremental;
|
|||
/* forward function declarations */
|
||||
static void eraser_motion (PaintCore *, GimpDrawable *,
|
||||
gboolean, gboolean);
|
||||
static Argument * eraser_invoker (Argument *);
|
||||
static Argument * eraser_extended_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -217,141 +215,22 @@ eraser_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The eraser procedure definition */
|
||||
ProcArg eraser_extended_args[] =
|
||||
gboolean
|
||||
eraser_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array,
|
||||
int hardness,
|
||||
int method)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"hardness",
|
||||
"SOFT(0) or HARD(1)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"method",
|
||||
"CONTINUOUS(0) or INCREMENTAL(1)"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg eraser_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord eraser_proc =
|
||||
{
|
||||
"gimp_eraser",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
eraser_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_invoker } },
|
||||
};
|
||||
|
||||
ProcRecord eraser_extended_proc =
|
||||
{
|
||||
"gimp_eraser_extended",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
eraser_extended_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_extended_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
eraser_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
non_gui_hard = hardness;
|
||||
non_gui_incremental = method;
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard=0; non_gui_incremental = 0;
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -371,94 +250,13 @@ eraser_invoker (args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
eraser_extended_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard = args[3].value.pdb_int;
|
||||
non_gui_incremental = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
if (num_strokes == 1)
|
||||
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
||||
|
||||
for (i = 1; i < num_strokes; i++)
|
||||
{
|
||||
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
||||
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
||||
|
||||
paint_core_interpolate (&non_gui_paint_core, drawable);
|
||||
|
||||
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
||||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
paint_core_cleanup ();
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
#define __ERASER_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean eraser_non_gui (GimpDrawable *, int, double *, int, int);
|
||||
|
||||
Tool * tools_new_eraser (void);
|
||||
void tools_free_eraser (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord eraser_proc;
|
||||
extern ProcRecord eraser_extended_proc;
|
||||
|
||||
#endif /* __ERASER_H__ */
|
||||
|
|
133
app/flip_tool.c
133
app/flip_tool.c
|
@ -52,12 +52,7 @@ static FlipOptions *flip_options = NULL;
|
|||
/* forward function declarations */
|
||||
static Tool * tools_new_flip_horz (void);
|
||||
static Tool * tools_new_flip_vert (void);
|
||||
static TileManager * flip_tool_flip_horz (GImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
static TileManager * flip_tool_flip_vert (GImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
static void flip_change_type (int);
|
||||
static Argument * flip_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -259,7 +254,7 @@ tools_new_flip_vert ()
|
|||
return tool;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
TileManager *
|
||||
flip_tool_flip_horz (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
|
@ -300,7 +295,7 @@ flip_tool_flip_horz (GImage *gimage,
|
|||
return new;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
TileManager *
|
||||
flip_tool_flip_vert (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
|
@ -352,127 +347,3 @@ flip_change_type (int new_type)
|
|||
tools_select (flip_options->type);
|
||||
}
|
||||
}
|
||||
|
||||
/* The flip procedure definition */
|
||||
ProcArg flip_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"flip_type",
|
||||
"Type of flip: { HORIZONTAL (0), VERTICAL (1) }"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg flip_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the flipped drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord flip_proc =
|
||||
{
|
||||
"gimp_flip",
|
||||
"Flip the specified drawable about its center either vertically or horizontally",
|
||||
"This tool flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipd by the specified amount. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipd drawable. The flip type parameter indicates whether the flip will be applied horizontally or vertically.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
2,
|
||||
flip_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
flip_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { flip_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
flip_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int flip_type;
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
flip_type = 0;
|
||||
new_tiles = NULL;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* flip type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: flip_type = 0; break;
|
||||
case 1: flip_type = 1; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* call the flip procedure */
|
||||
if (success)
|
||||
{
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* flip the buffer */
|
||||
switch (flip_type)
|
||||
{
|
||||
case 0: /* horz */
|
||||
new_tiles = flip_tool_flip_horz (gimage, drawable, float_tiles, -1);
|
||||
break;
|
||||
case 1: /* vert */
|
||||
new_tiles = flip_tool_flip_vert (gimage, drawable, float_tiles, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&flip_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,17 @@
|
|||
#define __FLIP_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
/* Flip tool functions */
|
||||
|
||||
void * flip_tool_transform (Tool *, gpointer, int);
|
||||
void * flip_tool_transform (Tool *, gpointer, int);
|
||||
|
||||
TileManager * flip_tool_flip_horz (GimpImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
TileManager * flip_tool_flip_vert (GimpImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
|
||||
Tool * tools_new_flip (void);
|
||||
void tools_free_flip_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord flip_proc;
|
||||
|
||||
#endif /* __FLIP_TOOL_H__ */
|
||||
|
|
|
@ -44,7 +44,6 @@ struct _free_select
|
|||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
typedef struct _FreeSelectPoint FreeSelectPoint;
|
||||
struct _FreeSelectPoint
|
||||
{
|
||||
double x, y;
|
||||
|
@ -59,10 +58,6 @@ static GdkPoint * global_pts = NULL;
|
|||
static int max_segs = 0;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static Argument *free_select_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
static int
|
||||
|
@ -277,7 +272,7 @@ scan_convert (GimpImage* gimage, int num_pts, FreeSelectPoint *pts,
|
|||
/*************************************/
|
||||
/* Polygonal selection apparatus */
|
||||
|
||||
static void
|
||||
void
|
||||
free_select (GImage *gimage, int num_pts, FreeSelectPoint *pts, int op,
|
||||
int antialias, int feather, double feather_radius)
|
||||
{
|
||||
|
@ -502,133 +497,3 @@ tools_free_free_select (Tool *tool)
|
|||
draw_core_free (free_sel->core);
|
||||
g_free (free_sel);
|
||||
}
|
||||
|
||||
/* The free_select procedure definition */
|
||||
ProcArg free_select_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_pts",
|
||||
"number of points (count 1 coordinate as two points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"segs",
|
||||
"array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing option for selections"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord free_select_proc =
|
||||
{
|
||||
"gimp_free_select",
|
||||
"Create a polygonal selection over the specified image",
|
||||
"This tool creates a polygonal selection over the specified image. The polygonal region can be either added to, subtracted from, or replace the contents of the previous selection mask. The polygon is specified through an array of floating point numbers and its length. The length of array must be 2n, where n is the number of points. Each point is defined by 2 floating point values which correspond to the x and y coordinates. If the final point does not connect to the starting point, a connecting segment is automatically added. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
free_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { free_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
free_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
int op;
|
||||
int antialias;
|
||||
int feather;
|
||||
int num_pts;
|
||||
FreeSelectPoint *pt_array;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
op = REPLACE;
|
||||
num_pts = 0;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
/* num pts */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value >= 2)
|
||||
num_pts = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* point array */
|
||||
if (success)
|
||||
pt_array = (FreeSelectPoint *) args[2].value.pdb_pointer;
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[6].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the free_select procedure */
|
||||
if (success)
|
||||
free_select (gimage, num_pts, pt_array,
|
||||
op, antialias, feather, feather_radius);
|
||||
|
||||
return procedural_db_return_args (&free_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
#ifndef __FREE_SELECT_H__
|
||||
#define __FREE_SELECT_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
|
||||
typedef struct _FreeSelectPoint FreeSelectPoint;
|
||||
|
||||
void free_select (GimpImage *, int, FreeSelectPoint *, int, int, int,
|
||||
double);
|
||||
|
||||
/* free select action functions */
|
||||
|
||||
|
@ -34,7 +39,4 @@ void free_select_draw (Tool *);
|
|||
Tool * tools_new_free_select (void);
|
||||
void tools_free_free_select (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord free_select_proc;
|
||||
|
||||
#endif /* __FREE_SELECT_H__ */
|
||||
|
|
|
@ -54,7 +54,8 @@ static SelectionOptions *fuzzy_options = NULL;
|
|||
/* XSegments which make up the fuzzy selection boundary */
|
||||
static GdkSegment *segs = NULL;
|
||||
static int num_segs = 0;
|
||||
static Channel * fuzzy_mask = NULL;
|
||||
|
||||
Channel *fuzzy_mask = NULL;
|
||||
|
||||
|
||||
/* fuzzy select action functions */
|
||||
|
@ -67,10 +68,6 @@ static void fuzzy_select_control (Tool *, int, gpointer);
|
|||
/* fuzzy select action functions */
|
||||
static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *);
|
||||
|
||||
static void fuzzy_select (GImage *, GimpDrawable *,
|
||||
int, int, double);
|
||||
static Argument * fuzzy_select_invoker (Argument *);
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Fuzzy selection apparatus */
|
||||
|
@ -296,7 +293,7 @@ find_contiguous_region (GImage *gimage, GimpDrawable *drawable, int antialias,
|
|||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
fuzzy_select (GImage *gimage, GimpDrawable *drawable, int op, int feather,
|
||||
double feather_radius)
|
||||
{
|
||||
|
@ -592,167 +589,3 @@ tools_free_fuzzy_select (Tool *tool)
|
|||
draw_core_free (fuzzy_sel->core);
|
||||
g_free (fuzzy_sel);
|
||||
}
|
||||
|
||||
/* The fuzzy_select procedure definition */
|
||||
ProcArg fuzzy_select_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of initial seed fill point: (image coordinates)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of initial seed fill point: (image coordinates)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"threshold",
|
||||
"threshold in intensity levels: 0 <= threshold <= 255"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord fuzzy_select_proc =
|
||||
{
|
||||
"gimp_fuzzy_select",
|
||||
"Create a fuzzy selection starting at the specified coordinates on the specified drawable",
|
||||
"This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored. If the sample is merged, the specified coordinates are relative to the image origin; otherwise, they are relative to the drawable's origin.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
9,
|
||||
fuzzy_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { fuzzy_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
fuzzy_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int op;
|
||||
int threshold;
|
||||
int antialias;
|
||||
int feather;
|
||||
int sample_merged;
|
||||
double x, y;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
drawable = NULL;
|
||||
op = REPLACE;
|
||||
threshold = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value >= 0 && int_value <= 255)
|
||||
threshold = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[7].value.pdb_float;
|
||||
}
|
||||
/* sample merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* call the fuzzy_select procedure */
|
||||
if (success)
|
||||
{
|
||||
Channel *new;
|
||||
Channel *old_fuzzy_mask;
|
||||
|
||||
new = find_contiguous_region (gimage, drawable, antialias, threshold, x, y, sample_merged);
|
||||
old_fuzzy_mask = fuzzy_mask;
|
||||
fuzzy_mask = new;
|
||||
|
||||
drawable = (sample_merged) ? NULL : drawable;
|
||||
fuzzy_select (gimage, drawable, op, feather, feather_radius);
|
||||
|
||||
fuzzy_mask = old_fuzzy_mask;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&fuzzy_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "gimage.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/* fuzzy select functions */
|
||||
|
@ -29,9 +28,11 @@ void tools_free_fuzzy_select (Tool *);
|
|||
|
||||
|
||||
/* functions */
|
||||
Channel * find_contiguous_region (GImage *, GimpDrawable *, int, int, int, int, int);
|
||||
Channel * find_contiguous_region (GimpImage *, GimpDrawable *, int, int,
|
||||
int, int, int);
|
||||
void fuzzy_select (GimpImage *, GimpDrawable *, int, int,
|
||||
double);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord fuzzy_select_proc;
|
||||
extern Channel *fuzzy_mask;
|
||||
|
||||
#endif /* __FUZZY_SELECT_H__ */
|
||||
|
|
127
app/gimprc.c
127
app/gimprc.c
|
@ -193,7 +193,6 @@ static inline char* preview_size_to_str (gpointer val1p, gpointer val2p);
|
|||
static inline char* units_to_str (gpointer val1p, gpointer val2p);
|
||||
|
||||
static char* transform_path (char *path, int destroy);
|
||||
static char* gimprc_find_token (char *token);
|
||||
static void gimprc_set_token (char *token, char *value);
|
||||
static Argument * gimprc_query (Argument *args);
|
||||
static void add_gimp_directory_token (char *gimp_dir);
|
||||
|
@ -2514,7 +2513,7 @@ open_backup_file (char *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
char*
|
||||
gimprc_find_token (char *token)
|
||||
{
|
||||
GList *list;
|
||||
|
@ -2556,127 +2555,3 @@ gimprc_set_token (char *token,
|
|||
list = list->next;
|
||||
}
|
||||
}
|
||||
|
||||
/******************/
|
||||
/* GIMPRC_QUERY */
|
||||
|
||||
static Argument *
|
||||
gimprc_query (Argument *args)
|
||||
{
|
||||
Argument *return_args;
|
||||
int success = TRUE;
|
||||
char *token;
|
||||
char *value;
|
||||
|
||||
token = (char *) args[0].value.pdb_pointer;
|
||||
|
||||
success = ((value = gimprc_find_token (token)) != NULL);
|
||||
return_args = procedural_db_return_args (&gimprc_query_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (value);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gimprc_query_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"token",
|
||||
"the token to query for"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg gimprc_query_out_args[] =
|
||||
{
|
||||
{ PDB_STRING,
|
||||
"value",
|
||||
"the value associated with the queried token"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord gimprc_query_proc =
|
||||
{
|
||||
"gimp_gimprc_query",
|
||||
"Queries the gimprc file parser for information on a specified token",
|
||||
"This procedure is used to locate additional information contained in the gimprc file considered extraneous to the operation of the GIMP. Plug-ins that need configuration information can expect it will be stored in the user's gimprc file and can use this procedure to retrieve it. This query procedure will return the value associated with the specified token. This corresponds _only_ to entries with the format: (<token> <value>). The value must be a string. Entries not corresponding to this format will cause warnings to be issued on gimprc parsing and will not be queryable.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
1,
|
||||
gimprc_query_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
gimprc_query_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { gimprc_query } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
gimprc_set_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *token;
|
||||
gchar *value;
|
||||
|
||||
token = (gchar *) args[0].value.pdb_pointer;
|
||||
if (token == NULL)
|
||||
success = FALSE;
|
||||
|
||||
value = (gchar *) args[1].value.pdb_pointer;
|
||||
if (value == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
save_gimprc_strings(token, value);
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&gimprc_set_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gimprc_set_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"token",
|
||||
"The token to modify"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"value",
|
||||
"The value to set the token to"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord gimprc_set_proc =
|
||||
{
|
||||
"gimp_gimprc_set",
|
||||
"Sets a gimprc token to a value and saves it in the gimprc.",
|
||||
"This procedure is used to add or change additional information in the gimprc file
|
||||
that is considered extraneous to the operation of the GIMP. Plug-ins that need conf
|
||||
iguration information can use this function to store it, and gimp_gimprc_query to re
|
||||
trieve it. This will accept _only_ parameters in the format of (<token> <value>), wh
|
||||
ere <token> and <value> must be strings. Entrys not corresponding to this format wil
|
||||
l be eaten and no action will be performed. If the gimprc can not be written for wha
|
||||
tever reason, gimp will complain loudly and the old gimprc will be saved in gimprc.o
|
||||
ld.",
|
||||
"Seth Burgess",
|
||||
"Seth Burgess",
|
||||
"1999",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
gimprc_set_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gimprc_set_invoker } }
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define __GIMPRC_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "procedural_db.h"
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
||||
/* global gimprc variables */
|
||||
|
@ -83,9 +82,7 @@ void init_parse_buffers (); /* this has to be called before any file
|
|||
void parse_gimprc (void);
|
||||
void parse_gimprc_file (char *filename);
|
||||
void save_gimprc (GList **updated_options, GList **conflicting_options);
|
||||
|
||||
/* procedural database procs */
|
||||
extern ProcRecord gimprc_query_proc;
|
||||
extern ProcRecord gimprc_set_proc;
|
||||
char * gimprc_find_token (char *token);
|
||||
void save_gimprc_strings (gchar *token, gchar *value);
|
||||
|
||||
#endif /* __GIMPRC_H__ */
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-1999 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
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl. */
|
||||
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
static ProcRecord gimprc_query_proc;
|
||||
static ProcRecord gimprc_set_proc;
|
||||
|
||||
void
|
||||
register_gimprc_procs (void)
|
||||
{
|
||||
procedural_db_register (&gimprc_query_proc);
|
||||
procedural_db_register (&gimprc_set_proc);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
gimprc_query_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
gchar *token;
|
||||
gchar *value = NULL;
|
||||
|
||||
token = (gchar *) args[0].value.pdb_pointer;
|
||||
if (token == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = (value = gimprc_find_token (token)) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&gimprc_query_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (value);
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg gimprc_query_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"token",
|
||||
"The token to query for"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcArg gimprc_query_outargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"value",
|
||||
"The value associated with the queried token"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gimprc_query_proc =
|
||||
{
|
||||
"gimp_gimprc_query",
|
||||
"Queries the gimprc file parser for information on a specified token.",
|
||||
"This procedure is used to locate additional information contained in the gimprc file considered extraneous to the operation of the GIMP. Plug-ins that need configuration information can expect it will be stored in the user gimprc file and can use this procedure to retrieve it. This query procedure will return the value associated with the specified token. This corresponds _only_ to entries with the format: (<token> <value>). The value must be a string. Entries not corresponding to this format will cause warnings to be issued on gimprc parsing a nd will not be queryable.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1997",
|
||||
PDB_INTERNAL,
|
||||
1,
|
||||
gimprc_query_inargs,
|
||||
1,
|
||||
gimprc_query_outargs,
|
||||
{ { gimprc_query_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
gimprc_set_invoker (Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *token;
|
||||
gchar *value;
|
||||
|
||||
token = (gchar *) args[0].value.pdb_pointer;
|
||||
if (token == NULL)
|
||||
success = FALSE;
|
||||
|
||||
value = (gchar *) args[1].value.pdb_pointer;
|
||||
if (value == NULL)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
save_gimprc_strings(token, value);
|
||||
|
||||
return procedural_db_return_args (&gimprc_set_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg gimprc_set_inargs[] =
|
||||
{
|
||||
{
|
||||
PDB_STRING,
|
||||
"token",
|
||||
"The token to modify"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
"value",
|
||||
"The value to set the token to"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord gimprc_set_proc =
|
||||
{
|
||||
"gimp_gimprc_set",
|
||||
"Sets a gimprc token to a value and saves it in the gimprc.",
|
||||
"This procedure is used to add or change additional information in the gimprc file that is considered extraneous to the operation of the GIMP. Plug-ins that need configuration information can use this function to store it, and gimp_gimprc_query to retrieve it. This will accept _only_ parameters in the format of (<token> <value>), where <token> and <value> must be strings. Entries not corresponding to this format will be eaten and no action will be performed. If the gimprc can not be written for whatever reason, gimp will complain loudly and the old gimprc will be saved in gimprc.old.",
|
||||
"Seth Burgess",
|
||||
"Seth Burgess",
|
||||
"1999",
|
||||
PDB_INTERNAL,
|
||||
2,
|
||||
gimprc_set_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { gimprc_set_invoker } }
|
||||
};
|
|
@ -20,28 +20,15 @@
|
|||
#include <string.h>
|
||||
#include "appenv.h"
|
||||
#include "app_procs.h"
|
||||
#include "airbrush.h"
|
||||
#include "blend.h"
|
||||
#include "brush_select.h"
|
||||
#include "bucket_fill.h"
|
||||
#include "gimpbrushlist.h"
|
||||
#include "by_color_select.h"
|
||||
#include "channel_cmds.h"
|
||||
#include "channel_ops.h"
|
||||
#include "clone.h"
|
||||
#include "color_balance.h"
|
||||
#include "color_picker.h"
|
||||
#include "convolve.h"
|
||||
#include "crop.h"
|
||||
#include "curves.h"
|
||||
#include "desaturate.h"
|
||||
#include "drawable_cmds.h"
|
||||
#include "ellipse_select.h"
|
||||
#include "equalize.h"
|
||||
#include "eraser.h"
|
||||
#include "flip_tool.h"
|
||||
#include "free_select.h"
|
||||
#include "fuzzy_select.h"
|
||||
#include "gimage_cmds.h"
|
||||
#include "gimage_mask_cmds.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -51,15 +38,8 @@
|
|||
#include "invert.h"
|
||||
#include "layer_cmds.h"
|
||||
#include "internal_procs.h"
|
||||
#include "paintbrush.h"
|
||||
#include "patterns.h"
|
||||
#include "pattern_select.h"
|
||||
#include "pencil.h"
|
||||
#include "perspective_tool.h"
|
||||
#include "rect_select.h"
|
||||
#include "rotate_tool.h"
|
||||
#include "scale_tool.h"
|
||||
#include "shear_tool.h"
|
||||
#include "threshold.h"
|
||||
#include "parasite_cmds.h"
|
||||
#include "procedural_db.h"
|
||||
|
@ -77,6 +57,8 @@ void register_unit_procs (void);
|
|||
void register_text_tool_procs (void);
|
||||
void register_color_procs (void);
|
||||
void register_misc_procs (void);
|
||||
void register_tools_procs (void);
|
||||
void register_gimprc_procs (void);
|
||||
|
||||
void
|
||||
internal_procs_init ()
|
||||
|
@ -89,30 +71,9 @@ internal_procs_init ()
|
|||
pcount/total_pcount);
|
||||
|
||||
/* Tool procedures */
|
||||
procedural_db_register (&airbrush_proc); pcount++;
|
||||
procedural_db_register (&blend_proc); pcount++;
|
||||
procedural_db_register (&bucket_fill_proc); pcount++;
|
||||
procedural_db_register (&by_color_select_proc); pcount++;
|
||||
procedural_db_register (&clone_proc); pcount++;
|
||||
procedural_db_register (&color_picker_proc); pcount++;
|
||||
procedural_db_register (&convolve_proc); pcount++;
|
||||
procedural_db_register (&crop_proc); pcount++;
|
||||
procedural_db_register (&ellipse_select_proc); pcount++;
|
||||
procedural_db_register (&eraser_proc); pcount++;
|
||||
procedural_db_register (&eraser_extended_proc); pcount++;
|
||||
procedural_db_register (&flip_proc); pcount++;
|
||||
procedural_db_register (&free_select_proc); pcount++;
|
||||
procedural_db_register (&fuzzy_select_proc); pcount++;
|
||||
procedural_db_register (&paintbrush_proc); pcount++;
|
||||
procedural_db_register (&paintbrush_extended_proc); pcount++;
|
||||
procedural_db_register (&paintbrush_extended_gradient_proc); pcount++;
|
||||
procedural_db_register (&pencil_proc); pcount++;
|
||||
procedural_db_register (&perspective_proc); pcount++;
|
||||
procedural_db_register (&rect_select_proc); pcount++;
|
||||
procedural_db_register (&rotate_proc); pcount++;
|
||||
procedural_db_register (&scale_proc); pcount++;
|
||||
procedural_db_register (&shear_proc); pcount++;
|
||||
|
||||
register_tools_procs ();
|
||||
pcount += 21;
|
||||
|
||||
register_text_tool_procs ();
|
||||
pcount += 6;
|
||||
|
||||
|
@ -392,8 +353,8 @@ internal_procs_init ()
|
|||
app_init_update_status(NULL, _("gimprc ops"),
|
||||
pcount/total_pcount);
|
||||
/* Gimprc procedures */
|
||||
procedural_db_register (&gimprc_query_proc); pcount++;
|
||||
procedural_db_register (&gimprc_set_proc); pcount++;
|
||||
register_gimprc_procs ();
|
||||
pcount += 2;
|
||||
|
||||
app_init_update_status(NULL, _("parasites"),
|
||||
pcount/total_pcount);
|
||||
|
|
|
@ -76,7 +76,6 @@ static double non_gui_pressure;
|
|||
/* forward function declarations */
|
||||
static void airbrush_motion (PaintCore *, GimpDrawable *, double);
|
||||
static gint airbrush_time_out (gpointer);
|
||||
static Argument * airbrush_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -313,108 +312,18 @@ airbrush_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The airbrush procedure definition */
|
||||
ProcArg airbrush_args[] =
|
||||
gboolean
|
||||
airbrush_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"The pressure of the airbrush strokes: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord airbrush_proc =
|
||||
{
|
||||
"gimp_airbrush",
|
||||
"Paint in the current brush with varying pressure. Paint application is time-dependent",
|
||||
"This tool simulates the use of an airbrush. Paint pressure represents the relative intensity of the paint application. High pressure results in a thicker layer of paint while low pressure results in a thinner layer.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
airbrush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { airbrush_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
airbrush_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
non_gui_pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -434,12 +343,13 @@ airbrush_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&airbrush_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_airbrush (void);
|
||||
void tools_free_airbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord airbrush_proc;
|
||||
|
||||
#endif /* __AIRBRUSH_H__ */
|
||||
|
|
|
@ -89,8 +89,6 @@ static void clone_line_image (GImage *, GImage *, GimpDrawable *, GimpD
|
|||
static void clone_line_pattern (GImage *, GimpDrawable *, GPatternP, unsigned char *,
|
||||
int, int, int, int);
|
||||
|
||||
static Argument * clone_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -146,7 +144,7 @@ clone_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Clone Tool Options"),
|
||||
clone_options_reset);
|
||||
options->type = options->type_d = ImageClone;
|
||||
options->type = options->type_d = IMAGE_CLONE;
|
||||
options->aligned = options->aligned_d = AlignNo;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -303,7 +301,7 @@ clone_paint_func (PaintCore *paint_core,
|
|||
orig_src_x = src_x;
|
||||
orig_src_y = src_y;
|
||||
}
|
||||
if (clone_options->type == PatternClone)
|
||||
if (clone_options->type == PATTERN_CLONE)
|
||||
if (!get_active_pattern ())
|
||||
g_message (_("No patterns available for this operation."));
|
||||
break;
|
||||
|
@ -382,7 +380,7 @@ clone_draw (Tool *tool)
|
|||
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
if (clone_options->type == ImageClone)
|
||||
if (clone_options->type == IMAGE_CLONE)
|
||||
{
|
||||
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
|
||||
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
|
||||
|
@ -418,7 +416,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pattern = NULL;
|
||||
|
||||
/* Make sure we still have a source if we are doing image cloning */
|
||||
if (type == ImageClone)
|
||||
if (type == IMAGE_CLONE)
|
||||
{
|
||||
if (!src_drawable)
|
||||
return;
|
||||
|
@ -438,7 +436,7 @@ clone_motion (PaintCore *paint_core,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
/* Set the paint area to transparent */
|
||||
memset (temp_buf_data (area), 0, area->width * area->height * area->bytes);
|
||||
|
||||
|
@ -500,7 +498,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
break;
|
||||
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
if (!pattern)
|
||||
|
@ -525,12 +523,12 @@ clone_motion (PaintCore *paint_core,
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
clone_line_image (gimage, src_gimage, drawable, src_drawable, s, d,
|
||||
has_alpha, srcPR.bytes, destPR.bytes, destPR.w);
|
||||
s += srcPR.rowstride;
|
||||
break;
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
clone_line_pattern (gimage, drawable, pattern, d,
|
||||
area->x + offset_x, area->y + y + offset_y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
@ -630,141 +628,25 @@ clone_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The clone procedure definition */
|
||||
ProcArg clone_args[] =
|
||||
gboolean
|
||||
clone_non_gui (GimpDrawable *drawable,
|
||||
GimpDrawable *src_drawable,
|
||||
CloneType clone_type,
|
||||
double src_x,
|
||||
double src_y,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_DRAWABLE,
|
||||
"src_drawable",
|
||||
"the source drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"clone_type",
|
||||
"the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_x",
|
||||
"the x coordinate in the source image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_y",
|
||||
"the y coordinate in the source image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord clone_proc =
|
||||
{
|
||||
"gimp_clone",
|
||||
"Clone from the source to the dest drawable using the current brush",
|
||||
"This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \"clone_type\" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \"src_drawable\" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
clone_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { clone_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
clone_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable *src_drawable;
|
||||
double src_x, src_y;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the src drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
src_drawable = drawable_get_ID (int_value);
|
||||
if (src_drawable == NULL || gimage != drawable_gimage (src_drawable))
|
||||
success = FALSE;
|
||||
else
|
||||
non_gui_src_drawable = src_drawable;
|
||||
}
|
||||
/* the clone type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: non_gui_type = ImageClone; break;
|
||||
case 1: non_gui_type = PatternClone; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* x, y offsets */
|
||||
if (success)
|
||||
{
|
||||
src_x = args[3].value.pdb_float;
|
||||
src_y = args[4].value.pdb_float;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[6].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
|
||||
|
||||
non_gui_src_drawable = src_drawable;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
|
@ -785,12 +667,13 @@ clone_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&clone_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,18 @@
|
|||
#define __CLONE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ImageClone,
|
||||
PatternClone
|
||||
IMAGE_CLONE,
|
||||
PATTERN_CLONE
|
||||
} CloneType;
|
||||
|
||||
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
|
||||
double, double, int, double *);
|
||||
Tool * tools_new_clone (void);
|
||||
void tools_free_clone (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord clone_proc;
|
||||
|
||||
#endif /* __CLONE_H__ */
|
||||
|
|
|
@ -98,7 +98,6 @@ static void copy_matrix (float *, float *, int);
|
|||
static int sum_matrix (int *, int);
|
||||
|
||||
static void convolve_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * convolve_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -147,7 +146,7 @@ convolve_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Convolver Options"),
|
||||
convolve_options_reset);
|
||||
options->type = options->type_d = Blur;
|
||||
options->type = options->type_d = BLUR_CONVOLVE;
|
||||
options->pressure = options->pressure_d = 50.0;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -364,19 +363,19 @@ calculate_matrix (ConvolveType type,
|
|||
/* get the appropriate convolution matrix and size and divisor */
|
||||
switch (type)
|
||||
{
|
||||
case Blur:
|
||||
case BLUR_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
blur_matrix [12] = MIN_BLUR + percent * (MAX_BLUR - MIN_BLUR);
|
||||
copy_matrix (blur_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Sharpen:
|
||||
case SHARPEN_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
sharpen_matrix [12] = MIN_SHARPEN + percent * (MAX_SHARPEN - MIN_SHARPEN);
|
||||
copy_matrix (sharpen_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Custom:
|
||||
case CUSTOM_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
break;
|
||||
}
|
||||
|
@ -437,128 +436,18 @@ convolve_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The convolve procedure definition */
|
||||
ProcArg convolve_args[] =
|
||||
gboolean
|
||||
convolve_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"the pressure: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"convolve_type",
|
||||
"convolve type: { BLUR (0), SHARPEN (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord convolve_proc =
|
||||
{
|
||||
"gimp_convolve",
|
||||
"Convolve (Blur, Sharpen) using the current brush",
|
||||
"This tool convolves the specified drawable with either a sharpening or blurring kernel. The pressure parameter controls the magnitude of the operation. Like the paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
convolve_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { convolve_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
convolve_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
double pressure;
|
||||
ConvolveType type;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
ConvolveType int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
pressure = 100.0;
|
||||
type = Blur;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_int;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* the convolve type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: type = Blur; break;
|
||||
case 1: type = Sharpen; break;
|
||||
case 2: success = FALSE; break; /*type = Custom; break;*/
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[4].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = convolve_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -578,12 +467,13 @@ convolve_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&convolve_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,21 +19,18 @@
|
|||
#define __CONVOLVE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_CONVOLVE >*/
|
||||
{
|
||||
Blur,
|
||||
Sharpen,
|
||||
Custom
|
||||
BLUR_CONVOLVE,
|
||||
SHARPEN_CONVOLVE,
|
||||
CUSTOM_CONVOLVE
|
||||
} ConvolveType;
|
||||
|
||||
void * convolve_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean convolve_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_convolve (void);
|
||||
void tools_free_convolve (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord convolve_proc;
|
||||
|
||||
#endif /* __CONVOLVE_H__ */
|
||||
|
|
|
@ -59,8 +59,6 @@ static gboolean non_gui_incremental;
|
|||
/* forward function declarations */
|
||||
static void eraser_motion (PaintCore *, GimpDrawable *,
|
||||
gboolean, gboolean);
|
||||
static Argument * eraser_invoker (Argument *);
|
||||
static Argument * eraser_extended_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -217,141 +215,22 @@ eraser_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The eraser procedure definition */
|
||||
ProcArg eraser_extended_args[] =
|
||||
gboolean
|
||||
eraser_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array,
|
||||
int hardness,
|
||||
int method)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"hardness",
|
||||
"SOFT(0) or HARD(1)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"method",
|
||||
"CONTINUOUS(0) or INCREMENTAL(1)"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg eraser_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord eraser_proc =
|
||||
{
|
||||
"gimp_eraser",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
eraser_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_invoker } },
|
||||
};
|
||||
|
||||
ProcRecord eraser_extended_proc =
|
||||
{
|
||||
"gimp_eraser_extended",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
eraser_extended_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_extended_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
eraser_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
non_gui_hard = hardness;
|
||||
non_gui_incremental = method;
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard=0; non_gui_incremental = 0;
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -371,94 +250,13 @@ eraser_invoker (args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
eraser_extended_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard = args[3].value.pdb_int;
|
||||
non_gui_incremental = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
if (num_strokes == 1)
|
||||
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
||||
|
||||
for (i = 1; i < num_strokes; i++)
|
||||
{
|
||||
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
||||
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
||||
|
||||
paint_core_interpolate (&non_gui_paint_core, drawable);
|
||||
|
||||
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
||||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
paint_core_cleanup ();
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
#define __ERASER_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean eraser_non_gui (GimpDrawable *, int, double *, int, int);
|
||||
|
||||
Tool * tools_new_eraser (void);
|
||||
void tools_free_eraser (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord eraser_proc;
|
||||
extern ProcRecord eraser_extended_proc;
|
||||
|
||||
#endif /* __ERASER_H__ */
|
||||
|
|
|
@ -38,7 +38,6 @@ static ToolOptions * pencil_options = NULL;
|
|||
|
||||
/* forward function declarations */
|
||||
static void pencil_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * pencil_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -68,7 +67,7 @@ pencil_paint_func (PaintCore *paint_core,
|
|||
}
|
||||
|
||||
Tool *
|
||||
tools_new_pencil ()
|
||||
tools_new_pencil (void)
|
||||
{
|
||||
Tool * tool;
|
||||
PaintCore * private;
|
||||
|
@ -135,92 +134,17 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
|
|||
}
|
||||
|
||||
|
||||
/* The pencil procedure definition */
|
||||
ProcArg pencil_args[] =
|
||||
gboolean
|
||||
pencil_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord pencil_proc =
|
||||
{
|
||||
"gimp_pencil",
|
||||
"Paint in the current brush without sub-pixel sampling",
|
||||
"This tool is the standard pencil. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The brush mask is treated as though it contains only black and white values. Any value below half is treated as black; any above half, as white.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
pencil_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { pencil_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
pencil_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = pencil_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -240,12 +164,13 @@ pencil_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&pencil_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * pencil_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
Tool * tools_new_pencil (void);
|
||||
void tools_free_pencil (Tool *);
|
||||
void * pencil_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean pencil_non_gui (GimpDrawable *, int, double *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord pencil_proc;
|
||||
Tool * tools_new_pencil (void);
|
||||
void tools_free_pencil (Tool *);
|
||||
|
||||
#endif /* __PENCIL_H__ */
|
||||
|
|
|
@ -89,8 +89,6 @@ static void clone_line_image (GImage *, GImage *, GimpDrawable *, GimpD
|
|||
static void clone_line_pattern (GImage *, GimpDrawable *, GPatternP, unsigned char *,
|
||||
int, int, int, int);
|
||||
|
||||
static Argument * clone_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -146,7 +144,7 @@ clone_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Clone Tool Options"),
|
||||
clone_options_reset);
|
||||
options->type = options->type_d = ImageClone;
|
||||
options->type = options->type_d = IMAGE_CLONE;
|
||||
options->aligned = options->aligned_d = AlignNo;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -303,7 +301,7 @@ clone_paint_func (PaintCore *paint_core,
|
|||
orig_src_x = src_x;
|
||||
orig_src_y = src_y;
|
||||
}
|
||||
if (clone_options->type == PatternClone)
|
||||
if (clone_options->type == PATTERN_CLONE)
|
||||
if (!get_active_pattern ())
|
||||
g_message (_("No patterns available for this operation."));
|
||||
break;
|
||||
|
@ -382,7 +380,7 @@ clone_draw (Tool *tool)
|
|||
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
if (clone_options->type == ImageClone)
|
||||
if (clone_options->type == IMAGE_CLONE)
|
||||
{
|
||||
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
|
||||
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
|
||||
|
@ -418,7 +416,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pattern = NULL;
|
||||
|
||||
/* Make sure we still have a source if we are doing image cloning */
|
||||
if (type == ImageClone)
|
||||
if (type == IMAGE_CLONE)
|
||||
{
|
||||
if (!src_drawable)
|
||||
return;
|
||||
|
@ -438,7 +436,7 @@ clone_motion (PaintCore *paint_core,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
/* Set the paint area to transparent */
|
||||
memset (temp_buf_data (area), 0, area->width * area->height * area->bytes);
|
||||
|
||||
|
@ -500,7 +498,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
break;
|
||||
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
if (!pattern)
|
||||
|
@ -525,12 +523,12 @@ clone_motion (PaintCore *paint_core,
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
clone_line_image (gimage, src_gimage, drawable, src_drawable, s, d,
|
||||
has_alpha, srcPR.bytes, destPR.bytes, destPR.w);
|
||||
s += srcPR.rowstride;
|
||||
break;
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
clone_line_pattern (gimage, drawable, pattern, d,
|
||||
area->x + offset_x, area->y + y + offset_y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
@ -630,141 +628,25 @@ clone_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The clone procedure definition */
|
||||
ProcArg clone_args[] =
|
||||
gboolean
|
||||
clone_non_gui (GimpDrawable *drawable,
|
||||
GimpDrawable *src_drawable,
|
||||
CloneType clone_type,
|
||||
double src_x,
|
||||
double src_y,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_DRAWABLE,
|
||||
"src_drawable",
|
||||
"the source drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"clone_type",
|
||||
"the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_x",
|
||||
"the x coordinate in the source image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_y",
|
||||
"the y coordinate in the source image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord clone_proc =
|
||||
{
|
||||
"gimp_clone",
|
||||
"Clone from the source to the dest drawable using the current brush",
|
||||
"This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \"clone_type\" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \"src_drawable\" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
clone_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { clone_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
clone_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable *src_drawable;
|
||||
double src_x, src_y;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the src drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
src_drawable = drawable_get_ID (int_value);
|
||||
if (src_drawable == NULL || gimage != drawable_gimage (src_drawable))
|
||||
success = FALSE;
|
||||
else
|
||||
non_gui_src_drawable = src_drawable;
|
||||
}
|
||||
/* the clone type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: non_gui_type = ImageClone; break;
|
||||
case 1: non_gui_type = PatternClone; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* x, y offsets */
|
||||
if (success)
|
||||
{
|
||||
src_x = args[3].value.pdb_float;
|
||||
src_y = args[4].value.pdb_float;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[6].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
|
||||
|
||||
non_gui_src_drawable = src_drawable;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
|
@ -785,12 +667,13 @@ clone_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&clone_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,18 @@
|
|||
#define __CLONE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ImageClone,
|
||||
PatternClone
|
||||
IMAGE_CLONE,
|
||||
PATTERN_CLONE
|
||||
} CloneType;
|
||||
|
||||
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
|
||||
double, double, int, double *);
|
||||
Tool * tools_new_clone (void);
|
||||
void tools_free_clone (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord clone_proc;
|
||||
|
||||
#endif /* __CLONE_H__ */
|
||||
|
|
|
@ -46,12 +46,13 @@ typedef enum
|
|||
} PaintApplicationMode;
|
||||
|
||||
/* gradient paint modes */
|
||||
#define ONCE_FORWARD 0 /* paint through once, then stop */
|
||||
#define ONCE_BACKWARDS 1 /* paint once, then stop, but run the gradient the other way */
|
||||
#define LOOP_SAWTOOTH 2 /* keep painting, looping through the grad start->end,start->end /|/|/| */
|
||||
#define LOOP_TRIANGLE 3 /* keep paiting, looping though the grad start->end,end->start /\/\/\/ */
|
||||
#define ONCE_END_COLOR 4 /* paint once, but keep painting with the end color */
|
||||
|
||||
typedef enum {
|
||||
ONCE_FORWARD, /* paint through once, then stop */
|
||||
ONCE_BACKWARDS, /* paint once, then stop, but run the gradient the other way */
|
||||
LOOP_SAWTOOTH, /* keep painting, looping through the grad start->end,start->end /|/|/| */
|
||||
LOOP_TRIANGLE, /* keep paiting, looping though the grad start->end,end->start /\/\/\/ */
|
||||
ONCE_END_COLOR, /* paint once, but keep painting with the end color */
|
||||
} GradientPaintMode;
|
||||
|
||||
typedef struct _paint_core PaintCore;
|
||||
typedef void * (* PaintFunc) (PaintCore *, GimpDrawable *, int);
|
||||
|
|
428
app/paintbrush.c
428
app/paintbrush.c
|
@ -77,9 +77,6 @@ static double non_gui_incremental;
|
|||
|
||||
/* forward function declarations */
|
||||
static void paintbrush_motion (PaintCore *, GimpDrawable *, double, double, gboolean, int);
|
||||
static Argument * paintbrush_invoker (Argument *);
|
||||
static Argument * paintbrush_extended_invoker (Argument *);
|
||||
static Argument * paintbrush_extended_gradient_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -166,7 +163,7 @@ paintbrush_options_new (void)
|
|||
options->incremental = options->incremental_d = FALSE;
|
||||
options->use_gradient = options->use_gradient_d = FALSE;
|
||||
options->gradient_length = options->gradient_length_d = 10.0;
|
||||
options->gradient_type = options->gradient_type_d = 3;
|
||||
options->gradient_type = options->gradient_type_d = LOOP_TRIANGLE;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = options->tool_options.main_vbox;
|
||||
|
@ -457,212 +454,25 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The paintbrush procedure definition */
|
||||
ProcArg paintbrush_args[] =
|
||||
gboolean
|
||||
paintbrush_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array,
|
||||
double fade_out,
|
||||
int method,
|
||||
double gradient_length)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"fade_out",
|
||||
"fade out parameter: fade_out > 0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg paintbrush_extended_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"fade_out",
|
||||
"fade out parameter: fade_out > 0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"method",
|
||||
"CONTINUOUS(0) or INCREMENTAL(1)"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg paintbrush_extended_gradient_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"fade_out",
|
||||
"fade out parameter: fade_out > 0"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"gradient_length",
|
||||
"Length of gradient to draw: gradient_lengtth >0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"method",
|
||||
"CONTINUOUS(0) or INCREMENTAL(1)"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord paintbrush_proc =
|
||||
{
|
||||
"gimp_paintbrush",
|
||||
"Paint in the current brush with optional fade out parameter",
|
||||
"This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
paintbrush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { paintbrush_invoker } },
|
||||
};
|
||||
|
||||
ProcRecord paintbrush_extended_proc =
|
||||
{
|
||||
"gimp_paintbrush_extended",
|
||||
"Paint in the current brush with optional fade out parameter",
|
||||
"This tool is the standard paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
paintbrush_extended_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { paintbrush_extended_invoker } },
|
||||
};
|
||||
|
||||
ProcRecord paintbrush_extended_gradient_proc =
|
||||
{
|
||||
"gimp_paintbrush_extended_gradient",
|
||||
"Paint in the current brush with optional fade out parameter and a pull colors from a gradient",
|
||||
"This tool is the gradient paintbrush. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable with colors drawn from the current active gradient with the active brush. The \"fade_out\" parameter is measured in pixels and allows the brush stroke to linearly fall off. The pressure is set to the maximum at the beginning of the stroke. As the distance of the stroke nears the fade_out value, the pressure will approach zero. The gradient_length is the distance to spread the gradient over. It is measured in pixels.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
6,
|
||||
paintbrush_extended_gradient_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { paintbrush_extended_gradient_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
paintbrush_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
non_gui_gradient_length = gradient_length;
|
||||
non_gui_gradient_type = LOOP_TRIANGLE;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fade out */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
non_gui_fade_out = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* FIXME FIXME FIXME */
|
||||
/* but we need to change the pdb call to gimp_paintbrush...ouch!! */
|
||||
/* should this be enough to do this without breaking PDB? */
|
||||
if (success)
|
||||
{
|
||||
non_gui_gradient_length = 0.0;
|
||||
non_gui_gradient_type = 0;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_incremental = 0;
|
||||
/* set the paint core's paint func */
|
||||
non_gui_incremental = method;
|
||||
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -682,209 +492,13 @@ paintbrush_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&paintbrush_proc, success);
|
||||
}
|
||||
|
||||
|
||||
static Argument *
|
||||
paintbrush_extended_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fade out */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
non_gui_fade_out = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* FIXME FIXME FIXME */
|
||||
/* but we need to change the pdb call to gimp_paintbrush...ouch!! */
|
||||
/* should this be enough to do this without breaking PDB? */
|
||||
if (success)
|
||||
{
|
||||
non_gui_gradient_length = 0.0;
|
||||
non_gui_gradient_type = 3;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_incremental = args[4].value.pdb_int;
|
||||
/* set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
if (num_strokes == 1)
|
||||
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
||||
|
||||
for (i = 1; i < num_strokes; i++)
|
||||
{
|
||||
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
||||
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
||||
|
||||
paint_core_interpolate (&non_gui_paint_core, drawable);
|
||||
|
||||
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
||||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
paint_core_cleanup ();
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&paintbrush_extended_proc, success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static Argument *
|
||||
paintbrush_extended_gradient_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fade out */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
non_gui_fade_out = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* gradient length */
|
||||
if(success)
|
||||
{
|
||||
fp_value = args[2].value.pdb_float;
|
||||
if(fp_value >= 0.0)
|
||||
non_gui_gradient_length = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[4].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_incremental = args[5].value.pdb_int;
|
||||
/* set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = paintbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
if (num_strokes == 1)
|
||||
paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
||||
|
||||
for (i = 1; i < num_strokes; i++)
|
||||
{
|
||||
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
||||
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
||||
|
||||
paint_core_interpolate (&non_gui_paint_core, drawable);
|
||||
|
||||
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
||||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
paint_core_cleanup ();
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&paintbrush_extended_gradient_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,14 +20,12 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * paintbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
void * paintbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean paintbrush_non_gui (GimpDrawable *, int, double *, double,
|
||||
int, double);
|
||||
|
||||
Tool * tools_new_paintbrush (void);
|
||||
void tools_free_paintbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord paintbrush_proc;
|
||||
extern ProcRecord paintbrush_extended_proc;
|
||||
extern ProcRecord paintbrush_extended_gradient_proc;
|
||||
#endif /* __PAINTBRUSH_H__ */
|
||||
|
|
101
app/pencil.c
101
app/pencil.c
|
@ -38,7 +38,6 @@ static ToolOptions * pencil_options = NULL;
|
|||
|
||||
/* forward function declarations */
|
||||
static void pencil_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * pencil_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -68,7 +67,7 @@ pencil_paint_func (PaintCore *paint_core,
|
|||
}
|
||||
|
||||
Tool *
|
||||
tools_new_pencil ()
|
||||
tools_new_pencil (void)
|
||||
{
|
||||
Tool * tool;
|
||||
PaintCore * private;
|
||||
|
@ -135,92 +134,17 @@ pencil_non_gui_paint_func (PaintCore *paint_core,
|
|||
}
|
||||
|
||||
|
||||
/* The pencil procedure definition */
|
||||
ProcArg pencil_args[] =
|
||||
gboolean
|
||||
pencil_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord pencil_proc =
|
||||
{
|
||||
"gimp_pencil",
|
||||
"Paint in the current brush without sub-pixel sampling",
|
||||
"This tool is the standard pencil. It draws linearly interpolated lines through the specified stroke coordinates. It operates on the specified drawable in the foreground color with the active brush. The brush mask is treated as though it contains only black and white values. Any value below half is treated as black; any above half, as white.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
pencil_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { pencil_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
pencil_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = pencil_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -240,12 +164,13 @@ pencil_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&pencil_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
10
app/pencil.h
10
app/pencil.h
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * pencil_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
Tool * tools_new_pencil (void);
|
||||
void tools_free_pencil (Tool *);
|
||||
void * pencil_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean pencil_non_gui (GimpDrawable *, int, double *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord pencil_proc;
|
||||
Tool * tools_new_pencil (void);
|
||||
void tools_free_pencil (Tool *);
|
||||
|
||||
#endif /* __PENCIL_H__ */
|
||||
|
|
|
@ -31,27 +31,14 @@
|
|||
|
||||
#include "tile_manager_pvt.h"
|
||||
|
||||
#define X0 0
|
||||
#define Y0 1
|
||||
#define X1 2
|
||||
#define Y1 3
|
||||
#define X2 4
|
||||
#define Y2 5
|
||||
#define X3 6
|
||||
#define Y3 7
|
||||
|
||||
/* storage for information dialog fields */
|
||||
static char matrix_row_buf [3][MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *,
|
||||
GDisplay *, TileManager *,
|
||||
int, GimpMatrix);
|
||||
static void perspective_find_transform (double *, GimpMatrix);
|
||||
static void * perspective_tool_recalc (Tool *, void *);
|
||||
static void perspective_tool_motion (Tool *, void *);
|
||||
static void perspective_info_update (Tool *);
|
||||
static Argument * perspective_invoker (Argument *);
|
||||
|
||||
void *
|
||||
perspective_tool_transform (Tool *tool,
|
||||
|
@ -259,7 +246,7 @@ perspective_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
perspective_find_transform (double *coords,
|
||||
GimpMatrix m)
|
||||
{
|
||||
|
@ -308,7 +295,7 @@ perspective_find_transform (double *coords,
|
|||
}
|
||||
|
||||
|
||||
static void *
|
||||
void *
|
||||
perspective_tool_perspective (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
|
@ -329,184 +316,3 @@ perspective_tool_perspective (GImage *gimage,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* The perspective procedure definition */
|
||||
ProcArg perspective_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"interpolation",
|
||||
"whether to use interpolation"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x0",
|
||||
"the new x coordinate of upper-left corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y0",
|
||||
"the new y coordinate of upper-left corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"the new x coordinate of upper-right corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"the new y coordinate of upper-right corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"the new x coordinate of lower-left corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"the new y coordinate of lower-left corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x3",
|
||||
"the new x coordinate of lower-right corner of original bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y3",
|
||||
"the new y coordinate of lower-right corner of original bounding box"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg perspective_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the newly mapped drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord perspective_proc =
|
||||
{
|
||||
"gimp_perspective",
|
||||
"Perform a possibly non-affine transformation on the specified drawable",
|
||||
"This tool performs a possibly non-affine transformation on the specified drawable by allowing the corners of the original bounding box to be arbitrarily remapped to any values. The specified drawable is remapped if no selection exists. However, if a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then remapped as specified. The interpolation parameter can be set to TRUE to indicate that either linear or cubic interpolation should be used to smooth the resulting remapped drawable. The return value is the ID of the remapped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and remapped drawable. The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed drawable will appear to have been projected via a perspective transform.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
10,
|
||||
perspective_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
perspective_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { perspective_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
perspective_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int interpolation;
|
||||
double trans_info[8];
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
GimpMatrix matrix;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* interpolation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
interpolation = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* perspective extents */
|
||||
if (success)
|
||||
{
|
||||
trans_info[X0] = args[2].value.pdb_float;
|
||||
trans_info[Y0] = args[3].value.pdb_float;
|
||||
trans_info[X1] = args[4].value.pdb_float;
|
||||
trans_info[Y1] = args[5].value.pdb_float;
|
||||
trans_info[X2] = args[6].value.pdb_float;
|
||||
trans_info[Y2] = args[7].value.pdb_float;
|
||||
trans_info[X3] = args[8].value.pdb_float;
|
||||
trans_info[Y3] = args[9].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the perspective procedure */
|
||||
if (success)
|
||||
{
|
||||
double cx, cy;
|
||||
double scalex, scaley;
|
||||
GimpMatrix m;
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
|
||||
cx = float_tiles->x;
|
||||
cy = float_tiles->y;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
if (float_tiles->width)
|
||||
scalex = 1.0 / float_tiles->width;
|
||||
if (float_tiles->height)
|
||||
scaley = 1.0 / float_tiles->height;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_mult (m, matrix);
|
||||
|
||||
/* perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&perspective_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
#define __PERSPECTIVE_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * perspective_tool_transform (Tool *, gpointer, int);
|
||||
void * perspective_tool_transform (Tool *, gpointer, int);
|
||||
void * perspective_tool_perspective (GimpImage *, GimpDrawable *,
|
||||
GDisplay *, TileManager *,
|
||||
int, GimpMatrix);
|
||||
void perspective_find_transform (double *, GimpMatrix);
|
||||
|
||||
|
||||
Tool * tools_new_perspective_tool (void);
|
||||
void tools_free_perspective_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord perspective_proc;
|
||||
|
||||
#endif /* __PERSPECTIVE_TOOL_H__ */
|
||||
|
|
|
@ -40,23 +40,18 @@ extern SelectionOptions *ellipse_options;
|
|||
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
|
||||
/* local functions */
|
||||
static void rect_select (GImage *, int, int, int, int, int, int, double);
|
||||
static Argument *rect_select_invoker (Argument *);
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Rectangular selection apparatus */
|
||||
|
||||
static void
|
||||
rect_select (GImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
void
|
||||
rect_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
|
||||
|
@ -561,125 +556,3 @@ tools_free_rect_select (Tool *tool)
|
|||
draw_core_free (rect_sel->core);
|
||||
g_free (rect_sel);
|
||||
}
|
||||
|
||||
/* The rect_select procedure definition */
|
||||
ProcArg rect_select_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"width",
|
||||
"the width of the rectangle: width > 0"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"height",
|
||||
"the height of the rectangle: height > 0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord rect_select_proc =
|
||||
{
|
||||
"gimp_rect_select",
|
||||
"Create a rectangular selection over the specified image",
|
||||
"This tool creates a rectangular selection over the specified image. The rectangular region can be either added to, subtracted from, or replace the contents of the previous selection mask. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
rect_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { rect_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
rect_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
int op;
|
||||
int feather;
|
||||
double x, y;
|
||||
double w, h;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
op = REPLACE;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
/* x, y, w, h */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
w = args[3].value.pdb_float;
|
||||
h = args[4].value.pdb_float;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[7].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the rect_select procedure */
|
||||
if (success)
|
||||
rect_select (gimage, (int) x, (int) y, (int) w, (int) h,
|
||||
op, feather, feather_radius);
|
||||
|
||||
return procedural_db_return_args (&rect_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef __RECT_SELECT_H__
|
||||
#define __RECT_SELECT_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
|
||||
/* rect select action functions */
|
||||
|
@ -29,11 +29,12 @@ void rect_select_cursor_update (Tool *, GdkEventMotion *, gpointer)
|
|||
void rect_select_control (Tool *, int, gpointer);
|
||||
|
||||
/* rect select functions */
|
||||
void rect_select_draw (Tool *);
|
||||
void rect_select_draw (Tool *);
|
||||
void rect_select (GimpImage *, int, int, int, int, int, int,
|
||||
double);
|
||||
|
||||
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord rect_select_proc;
|
||||
|
||||
#endif /* __RECT_SELECT_H__ */
|
||||
|
|
|
@ -55,12 +55,9 @@ static gfloat center_vals[2];
|
|||
static GtkWidget *sizeentry;
|
||||
|
||||
/* forward function declarations */
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, GDisplay *,
|
||||
double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_recalc (Tool *, void *);
|
||||
static void rotate_tool_motion (Tool *, void *);
|
||||
static void rotate_info_update (Tool *);
|
||||
static Argument * rotate_invoker (Argument *);
|
||||
|
||||
/* callback functions for the info dialog entries */
|
||||
static void rotate_angle_changed (GtkWidget *entry, gpointer data);
|
||||
|
@ -378,7 +375,7 @@ rotate_tool_recalc (Tool *tool,
|
|||
* requested angle is a multiple of 90 degrees...
|
||||
*/
|
||||
|
||||
static void *
|
||||
void *
|
||||
rotate_tool_rotate (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
|
@ -400,134 +397,3 @@ rotate_tool_rotate (GImage *gimage,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* The rotate procedure definition */
|
||||
ProcArg rotate_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"interpolation",
|
||||
"whether to use interpolation"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"angle",
|
||||
"the angle of rotation (radians)",
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg rotate_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the rotated drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord rotate_proc =
|
||||
{
|
||||
"gimp_rotate",
|
||||
"Rotate the specified drawable about its center through the specified angle",
|
||||
"This tool rotates the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The interpolation parameter can be set to TRUE to indicate that either linear or cubic interpolation should be used to smooth the resulting rotated drawable. The return value is the ID of the rotated drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and rotated drawable.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
rotate_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
rotate_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { rotate_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
rotate_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int interpolation;
|
||||
double angle;
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
GimpMatrix matrix;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* interpolation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
interpolation = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* angle of rotation */
|
||||
if (success)
|
||||
angle = args[2].value.pdb_float;
|
||||
|
||||
/* call the rotate procedure */
|
||||
if (success)
|
||||
{
|
||||
double cx, cy;
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
gimp_matrix_rotate (matrix, angle);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&rotate_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
#define __ROTATE_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * rotate_tool_transform (Tool *, gpointer, int);
|
||||
void * rotate_tool_transform (Tool *, gpointer, int);
|
||||
void * rotate_tool_rotate (GimpImage *, GimpDrawable *, GDisplay *,
|
||||
double, TileManager *, int, GimpMatrix);
|
||||
|
||||
Tool * tools_new_rotate_tool (void);
|
||||
void tools_free_rotate_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord rotate_proc;
|
||||
|
||||
#endif /* __ROTATE_TOOL_H__ */
|
||||
|
|
242
app/scale_tool.c
242
app/scale_tool.c
|
@ -31,11 +31,6 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define X1 0
|
||||
#define Y1 1
|
||||
#define X2 2
|
||||
#define Y2 3
|
||||
|
||||
/* storage for information dialog fields */
|
||||
static gchar orig_width_buf [MAX_INFO_BUF];
|
||||
static gchar orig_height_buf [MAX_INFO_BUF];
|
||||
|
@ -47,12 +42,9 @@ static gchar y_ratio_buf [MAX_INFO_BUF];
|
|||
static GtkWidget *sizeentry;
|
||||
|
||||
/* forward function declarations */
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, GDisplay *,
|
||||
double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_recalc (Tool *, void *);
|
||||
static void scale_tool_motion (Tool *, void *);
|
||||
static void scale_info_update (Tool *);
|
||||
static Argument * scale_invoker (Argument *);
|
||||
|
||||
/* callback functions for the info dialog fields */
|
||||
static void scale_size_changed (GtkWidget *w, gpointer data);
|
||||
|
@ -129,10 +121,10 @@ scale_tool_transform (Tool *tool,
|
|||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
||||
0, transform_core->y2- transform_core->y1);
|
||||
|
||||
transform_core->trans_info [X1] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y1;
|
||||
transform_core->trans_info [X2] = (double) transform_core->x2;
|
||||
transform_core->trans_info [Y2] = (double) transform_core->y2;
|
||||
transform_core->trans_info [X0] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y0] = (double) transform_core->y1;
|
||||
transform_core->trans_info [X1] = (double) transform_core->x2;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y2;
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
@ -174,10 +166,10 @@ tools_new_scale_tool ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = scale_tool_transform;
|
||||
private->trans_info[X0] = 0;
|
||||
private->trans_info[Y0] = 0;
|
||||
private->trans_info[X1] = 0;
|
||||
private->trans_info[Y1] = 0;
|
||||
private->trans_info[X2] = 0;
|
||||
private->trans_info[Y2] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (private->transform);
|
||||
|
@ -236,10 +228,10 @@ scale_info_update (Tool *tool)
|
|||
}
|
||||
|
||||
/* Find current sizes */
|
||||
x3 = (int) transform_core->trans_info [X1];
|
||||
y3 = (int) transform_core->trans_info [Y1];
|
||||
x4 = (int) transform_core->trans_info [X2];
|
||||
y4 = (int) transform_core->trans_info [Y2];
|
||||
x3 = (int) transform_core->trans_info [X0];
|
||||
y3 = (int) transform_core->trans_info [Y0];
|
||||
x4 = (int) transform_core->trans_info [X1];
|
||||
y4 = (int) transform_core->trans_info [Y1];
|
||||
|
||||
size_vals[0] = x4 - x3;
|
||||
size_vals[1] = y4 - y3;
|
||||
|
@ -278,16 +270,16 @@ scale_size_changed (GtkWidget *w,
|
|||
width = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (w), 0);
|
||||
height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (w), 1);
|
||||
|
||||
if ((width != (transform_core->trans_info[X2] -
|
||||
transform_core->trans_info[X1])) ||
|
||||
(height != (transform_core->trans_info[Y2] -
|
||||
transform_core->trans_info[Y1])))
|
||||
if ((width != (transform_core->trans_info[X1] -
|
||||
transform_core->trans_info[X0])) ||
|
||||
(height != (transform_core->trans_info[Y1] -
|
||||
transform_core->trans_info[Y0])))
|
||||
{
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
transform_core->trans_info[X2] =
|
||||
transform_core->trans_info[X1] + width;
|
||||
transform_core->trans_info[Y2] =
|
||||
transform_core->trans_info[Y1] + height;
|
||||
transform_core->trans_info[X1] =
|
||||
transform_core->trans_info[X0] + width;
|
||||
transform_core->trans_info[Y1] =
|
||||
transform_core->trans_info[Y0] + height;
|
||||
scale_tool_recalc (tool, gdisp);
|
||||
draw_core_resume (transform_core->core, tool);
|
||||
}
|
||||
|
@ -323,33 +315,33 @@ scale_tool_motion (Tool *tool,
|
|||
switch (transform_core->function)
|
||||
{
|
||||
case HANDLE_1 :
|
||||
x1 = &transform_core->trans_info [X1];
|
||||
y1 = &transform_core->trans_info [Y1];
|
||||
x2 = &transform_core->trans_info [X2];
|
||||
y2 = &transform_core->trans_info [Y2];
|
||||
x1 = &transform_core->trans_info [X0];
|
||||
y1 = &transform_core->trans_info [Y0];
|
||||
x2 = &transform_core->trans_info [X1];
|
||||
y2 = &transform_core->trans_info [Y1];
|
||||
dir_x = dir_y = 1;
|
||||
break;
|
||||
case HANDLE_2 :
|
||||
x1 = &transform_core->trans_info [X2];
|
||||
y1 = &transform_core->trans_info [Y1];
|
||||
x2 = &transform_core->trans_info [X1];
|
||||
y2 = &transform_core->trans_info [Y2];
|
||||
x1 = &transform_core->trans_info [X1];
|
||||
y1 = &transform_core->trans_info [Y0];
|
||||
x2 = &transform_core->trans_info [X0];
|
||||
y2 = &transform_core->trans_info [Y1];
|
||||
dir_x = -1;
|
||||
dir_y = 1;
|
||||
break;
|
||||
case HANDLE_3 :
|
||||
x1 = &transform_core->trans_info [X1];
|
||||
y1 = &transform_core->trans_info [Y2];
|
||||
x2 = &transform_core->trans_info [X2];
|
||||
y2 = &transform_core->trans_info [Y1];
|
||||
x1 = &transform_core->trans_info [X0];
|
||||
y1 = &transform_core->trans_info [Y1];
|
||||
x2 = &transform_core->trans_info [X1];
|
||||
y2 = &transform_core->trans_info [Y0];
|
||||
dir_x = 1;
|
||||
dir_y = -1;
|
||||
break;
|
||||
case HANDLE_4 :
|
||||
x1 = &transform_core->trans_info [X2];
|
||||
y1 = &transform_core->trans_info [Y2];
|
||||
x2 = &transform_core->trans_info [X1];
|
||||
y2 = &transform_core->trans_info [Y1];
|
||||
x1 = &transform_core->trans_info [X1];
|
||||
y1 = &transform_core->trans_info [Y1];
|
||||
x2 = &transform_core->trans_info [X0];
|
||||
y2 = &transform_core->trans_info [Y0];
|
||||
dir_x = dir_y = -1;
|
||||
break;
|
||||
default :
|
||||
|
@ -416,10 +408,10 @@ scale_tool_recalc (Tool *tool,
|
|||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
x1 = (int) transform_core->trans_info [X1];
|
||||
y1 = (int) transform_core->trans_info [Y1];
|
||||
x2 = (int) transform_core->trans_info [X2];
|
||||
y2 = (int) transform_core->trans_info [Y2];
|
||||
x1 = (int) transform_core->trans_info [X0];
|
||||
y1 = (int) transform_core->trans_info [Y0];
|
||||
x2 = (int) transform_core->trans_info [X1];
|
||||
y2 = (int) transform_core->trans_info [Y1];
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (transform_core->x2 - transform_core->x1)
|
||||
|
@ -470,7 +462,7 @@ scale_tool_recalc (Tool *tool,
|
|||
return (void *) 1;
|
||||
}
|
||||
|
||||
static void *
|
||||
void *
|
||||
scale_tool_scale (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
|
@ -492,159 +484,3 @@ scale_tool_scale (GImage *gimage,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* The scale procedure definition */
|
||||
ProcArg scale_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"interpolation",
|
||||
"whether to use interpolation"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"the x coordinate of the upper-left corner of newly scaled region"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"the y coordinate of the upper-left corner of newly scaled region"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"the x coordinate of the lower-right corner of newly scaled region"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"the y coordinate of the lower-right corner of newly scaled region"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg scale_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the scaled drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord scale_proc =
|
||||
{
|
||||
"gimp_scale",
|
||||
"Scale the specified drawable",
|
||||
"This tool scales the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled by the specified amount. The interpolation parameter can be set to TRUE to indicate that either linear or cubic interpolation should be used to smooth the resulting scaled drawable. The return value is the ID of the scaled drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and scaled drawable.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
6,
|
||||
scale_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
scale_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { scale_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
scale_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int interpolation;
|
||||
double trans_info[4];
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
GimpMatrix matrix;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* interpolation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
interpolation = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* scale extents */
|
||||
if (success)
|
||||
{
|
||||
trans_info[X1] = args[2].value.pdb_float;
|
||||
trans_info[Y1] = args[3].value.pdb_float;
|
||||
trans_info[X2] = args[4].value.pdb_float;
|
||||
trans_info[Y2] = args[5].value.pdb_float;
|
||||
|
||||
if (trans_info[X1] >= trans_info[X2] ||
|
||||
trans_info[Y1] >= trans_info[Y2])
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* call the scale procedure */
|
||||
if (success)
|
||||
{
|
||||
double scalex, scaley;
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (float_tiles->width)
|
||||
scalex = (trans_info[X2] - trans_info[X1]) / (double) float_tiles->width;
|
||||
if (float_tiles->height)
|
||||
scaley = (trans_info[Y2] - trans_info[Y1]) / (double) float_tiles->height;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, float_tiles->x, float_tiles->y);
|
||||
gimp_matrix_scale (matrix, scalex, scaley);
|
||||
gimp_matrix_translate (matrix, trans_info[X1], trans_info[Y1]);
|
||||
|
||||
/* scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&scale_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,12 @@
|
|||
#define __SCALE_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * scale_tool_transform (Tool *, gpointer, int);
|
||||
void * scale_tool_transform (Tool *, gpointer, int);
|
||||
void * scale_tool_scale (GimpImage *, GimpDrawable *, GDisplay *,
|
||||
double *, TileManager *, int, GimpMatrix);
|
||||
|
||||
Tool * tools_new_scale_tool (void);
|
||||
void tools_free_scale_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord scale_proc;
|
||||
|
||||
#endif /* __SCALE_TOOL_H__ */
|
||||
|
|
182
app/shear_tool.c
182
app/shear_tool.c
|
@ -38,10 +38,6 @@
|
|||
#define XSHEAR 1
|
||||
#define YSHEAR 2
|
||||
|
||||
/* types of shearing */
|
||||
#define HORZ 1
|
||||
#define VERT 2
|
||||
|
||||
/* the minimum movement before direction of shear can be determined (pixels) */
|
||||
#define MIN_MOVE 5
|
||||
|
||||
|
@ -51,12 +47,9 @@ static float xshear_val;
|
|||
static float yshear_val;
|
||||
|
||||
/* forward function declarations */
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, GDisplay *,
|
||||
TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_recalc (Tool *, void *);
|
||||
static void shear_tool_motion (Tool *, void *);
|
||||
static void shear_info_update (Tool *);
|
||||
static Argument * shear_invoker (Argument *);
|
||||
|
||||
/* Info dialog callback funtions */
|
||||
static void shear_x_mag_changed (GtkWidget *, gpointer);
|
||||
|
@ -94,7 +87,7 @@ shear_tool_transform (Tool *tool,
|
|||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
direction_unknown = 1;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ_SHEAR;
|
||||
transform_core->trans_info[XSHEAR] = 0.0;
|
||||
transform_core->trans_info[YSHEAR] = 0.0;
|
||||
|
||||
|
@ -246,13 +239,13 @@ shear_tool_motion (Tool *tool,
|
|||
{
|
||||
if (abs(diffx) > abs(diffy))
|
||||
{
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ;
|
||||
transform_core->trans_info[VERT] = 0.0;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ_SHEAR;
|
||||
transform_core->trans_info[VERT_SHEAR] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform_core->trans_info[HORZ_OR_VERT] = VERT;
|
||||
transform_core->trans_info[HORZ] = 0.0;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = VERT_SHEAR;
|
||||
transform_core->trans_info[HORZ_SHEAR] = 0.0;
|
||||
}
|
||||
|
||||
direction_unknown = 0;
|
||||
|
@ -272,25 +265,25 @@ shear_tool_motion (Tool *tool,
|
|||
switch (transform_core->function)
|
||||
{
|
||||
case HANDLE_1 :
|
||||
if (dir == HORZ)
|
||||
if (dir == HORZ_SHEAR)
|
||||
transform_core->trans_info[XSHEAR] -= diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] -= diffy;
|
||||
break;
|
||||
case HANDLE_2 :
|
||||
if (dir == HORZ)
|
||||
if (dir == HORZ_SHEAR)
|
||||
transform_core->trans_info[XSHEAR] -= diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] += diffy;
|
||||
break;
|
||||
case HANDLE_3 :
|
||||
if (dir == HORZ)
|
||||
if (dir == HORZ_SHEAR)
|
||||
transform_core->trans_info[XSHEAR] += diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] -= diffy;
|
||||
break;
|
||||
case HANDLE_4 :
|
||||
if (dir == HORZ)
|
||||
if (dir == HORZ_SHEAR)
|
||||
transform_core->trans_info[XSHEAR] += diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] += diffy;
|
||||
|
@ -330,7 +323,7 @@ shear_tool_recalc (Tool *tool,
|
|||
gimp_matrix_translate (transform_core->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == HORZ)
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == HORZ_SHEAR)
|
||||
gimp_matrix_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
else
|
||||
|
@ -349,7 +342,7 @@ shear_tool_recalc (Tool *tool,
|
|||
}
|
||||
|
||||
|
||||
static void *
|
||||
void *
|
||||
shear_tool_shear (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
|
@ -370,156 +363,3 @@ shear_tool_shear (GImage *gimage,
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* The shear procedure definition */
|
||||
ProcArg shear_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"interpolation",
|
||||
"whether to use interpolation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"shear_type",
|
||||
"Type of shear: { HORIZONTAL (0), VERTICAL (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"magnitude",
|
||||
"the magnitude of the shear"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg shear_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the sheard drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord shear_proc =
|
||||
{
|
||||
"gimp_shear",
|
||||
"Shear the specified drawable about its center by the specified magnitude",
|
||||
"This tool shears the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheard by the specified amount. The interpolation parameter can be set to TRUE to indicate that either linear or cubic interpolation should be used to smooth the resulting sheard drawable. The return value is the ID of the sheard drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and sheard drawable. The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
shear_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
shear_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { shear_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
shear_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int interpolation;
|
||||
int shear_type;
|
||||
double shear_magnitude;
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
GimpMatrix matrix;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
shear_type = HORZ;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* interpolation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
interpolation = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* shear type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: shear_type = HORZ; break;
|
||||
case 1: shear_type = VERT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* shear extents */
|
||||
if (success)
|
||||
{
|
||||
shear_magnitude = args[3].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the shear procedure */
|
||||
if (success)
|
||||
{
|
||||
double cx, cy;
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
cx = float_tiles->x + float_tiles->width / 2.0;
|
||||
cy = float_tiles->y + float_tiles->height / 2.0;
|
||||
|
||||
gimp_matrix_identity (matrix);
|
||||
gimp_matrix_translate (matrix, -cx, -cy);
|
||||
/* shear matrix */
|
||||
if (shear_type == HORZ)
|
||||
gimp_matrix_xshear (matrix, shear_magnitude / float_tiles->height);
|
||||
else if (shear_type == VERT)
|
||||
gimp_matrix_yshear (matrix, shear_magnitude / float_tiles->width);
|
||||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&shear_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,18 @@
|
|||
#define __SHEAR_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * shear_tool_transform (Tool *, gpointer, int);
|
||||
typedef enum
|
||||
{
|
||||
HORZ_SHEAR, /*< nick=HORIZONTAL >*/
|
||||
VERT_SHEAR /*< nick=VERTICAL >*/
|
||||
} ShearType;
|
||||
|
||||
void * shear_tool_transform (Tool *, gpointer, int);
|
||||
void * shear_tool_shear (GimpImage *, GimpDrawable *, GDisplay *,
|
||||
TileManager *, int, GimpMatrix);
|
||||
|
||||
Tool * tools_new_shear_tool (void);
|
||||
void tools_free_shear_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord shear_proc;
|
||||
|
||||
#endif /* __SHEAR_TOOL_H__ */
|
||||
|
|
|
@ -219,7 +219,7 @@ static ProcArg text_fontname_inargs[] =
|
|||
{
|
||||
PDB_INT32,
|
||||
"size_type",
|
||||
"The units of specified size: PIXELS (0), POINTS (1)"
|
||||
"The units of specified size: PIXELS (0) or POINTS (1)"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
|
@ -323,7 +323,7 @@ static ProcArg text_get_extents_fontname_inargs[] =
|
|||
{
|
||||
PDB_INT32,
|
||||
"size_type",
|
||||
"The units of specified size: PIXELS (0), POINTS (1)"
|
||||
"The units of specified size: PIXELS (0) or POINTS (1)"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
|
@ -484,7 +484,7 @@ static ProcArg text_inargs[] =
|
|||
{
|
||||
PDB_INT32,
|
||||
"size_type",
|
||||
"The units of specified size: PIXELS (0), POINTS (1)"
|
||||
"The units of specified size: PIXELS (0) or POINTS (1)"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
|
@ -636,7 +636,7 @@ static ProcArg text_get_extents_inargs[] =
|
|||
{
|
||||
PDB_INT32,
|
||||
"size_type",
|
||||
"The units of specified size: PIXELS (0), POINTS (1)"
|
||||
"The units of specified size: PIXELS (0) or POINTS (1)"
|
||||
},
|
||||
{
|
||||
PDB_STRING,
|
||||
|
|
|
@ -76,7 +76,6 @@ static double non_gui_pressure;
|
|||
/* forward function declarations */
|
||||
static void airbrush_motion (PaintCore *, GimpDrawable *, double);
|
||||
static gint airbrush_time_out (gpointer);
|
||||
static Argument * airbrush_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -313,108 +312,18 @@ airbrush_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The airbrush procedure definition */
|
||||
ProcArg airbrush_args[] =
|
||||
gboolean
|
||||
airbrush_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"The pressure of the airbrush strokes: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord airbrush_proc =
|
||||
{
|
||||
"gimp_airbrush",
|
||||
"Paint in the current brush with varying pressure. Paint application is time-dependent",
|
||||
"This tool simulates the use of an airbrush. Paint pressure represents the relative intensity of the paint application. High pressure results in a thicker layer of paint while low pressure results in a thinner layer.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
airbrush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { airbrush_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
airbrush_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
non_gui_pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -434,12 +343,13 @@ airbrush_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&airbrush_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_airbrush (void);
|
||||
void tools_free_airbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord airbrush_proc;
|
||||
|
||||
#endif /* __AIRBRUSH_H__ */
|
||||
|
|
|
@ -161,17 +161,6 @@ static void blend_motion (Tool *, GdkEventMotion *, gpointer)
|
|||
static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void blend_control (Tool *, int, gpointer);
|
||||
|
||||
static void blend (GImage *gimage, GimpDrawable *drawable,
|
||||
BlendMode blend_mode, int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity, double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
static double gradient_calc_conical_asym_factor (double dist, double *axis, double offset,
|
||||
|
@ -211,8 +200,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
||||
static Argument *blend_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -303,27 +290,27 @@ blend_options_new ()
|
|||
static MenuItem gradient_option_items[] =
|
||||
{
|
||||
{ N_("Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Linear, NULL, NULL },
|
||||
(gpointer) LINEAR, NULL, NULL },
|
||||
{ N_("Bi-Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) BiLinear, NULL, NULL },
|
||||
(gpointer) BILINEAR, NULL, NULL },
|
||||
{ N_("Radial"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Radial, NULL, NULL },
|
||||
(gpointer) RADIAL, NULL, NULL },
|
||||
{ N_("Square"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Square, NULL, NULL },
|
||||
(gpointer) SQUARE, NULL, NULL },
|
||||
{ N_("Conical (symmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalSymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_SYMMETRIC, NULL, NULL },
|
||||
{ N_("Conical (asymmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalAsymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_ASYMMETRIC, NULL, NULL },
|
||||
{ N_("Shapeburst (angular)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstAngular, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_ANGULAR, NULL, NULL },
|
||||
{ N_("Shapeburst (spherical)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstSpherical, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_SPHERICAL, NULL, NULL },
|
||||
{ N_("Shapeburst (dimpled)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstDimpled, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_DIMPLED, NULL, NULL },
|
||||
{ N_("Spiral (clockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_CLOCKWISE, NULL, NULL },
|
||||
{ N_("Spiral (anticlockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralAntiClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_ANTICLOCKWISE, NULL, NULL },
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
static MenuItem repeat_option_items[] =
|
||||
|
@ -346,7 +333,7 @@ blend_options_new ()
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->offset = options->offset_d = 0.0;
|
||||
options->blend_mode = options->blend_mode_d = FG_BG_RGB_MODE;
|
||||
options->gradient_type = options->gradient_type_d = Linear;
|
||||
options->gradient_type = options->gradient_type_d = LINEAR;
|
||||
options->repeat = options->repeat_d = REPEAT_NONE;
|
||||
options->supersample = options->supersample_d = FALSE;
|
||||
options->max_depth = options->max_depth_d = 3;
|
||||
|
@ -821,7 +808,7 @@ blend_control (Tool *tool,
|
|||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
|
@ -1317,54 +1304,54 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data)
|
|||
|
||||
switch (rbd->gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
factor = gradient_calc_radial_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case CONICAL_SYMMETRIC:
|
||||
factor = gradient_calc_conical_sym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalAsymmetric:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
factor = gradient_calc_conical_asym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
factor = gradient_calc_square_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
case LINEAR:
|
||||
factor = gradient_calc_linear_factor(rbd->dist, rbd->vec,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case BiLinear:
|
||||
case BILINEAR:
|
||||
factor = gradient_calc_bilinear_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
factor = gradient_calc_shapeburst_angular_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstSpherical:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
factor = gradient_calc_shapeburst_spherical_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
factor = gradient_calc_shapeburst_dimpled_factor(x, y);
|
||||
break;
|
||||
|
||||
case SpiralClockwise:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,TRUE);
|
||||
break;
|
||||
|
||||
case SpiralAntiClockwise:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,FALSE);
|
||||
break;
|
||||
|
@ -1514,20 +1501,20 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
switch (gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
rbd.dist = MAXIMUM(fabs(ex - sx), fabs(ey - sy));
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case ConicalAsymmetric:
|
||||
case SpiralClockwise:
|
||||
case SpiralAntiClockwise:
|
||||
case Linear:
|
||||
case BiLinear:
|
||||
case CONICAL_SYMMETRIC:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
|
@ -1538,9 +1525,9 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case ShapeburstSpherical:
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
@ -1843,232 +1830,3 @@ tools_free_blend (Tool *tool)
|
|||
|
||||
g_free (blend_tool);
|
||||
}
|
||||
|
||||
|
||||
/* The blend procedure definition */
|
||||
ProcArg blend_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"blend_mode",
|
||||
"The type of blend: { FG-BG-RGB (0), FG-BG-HSV (1), FG-TRANS (2), CUSTOM (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"gradient_type",
|
||||
"The type of gradient: { LINEAR (0), BILINEAR (1), RADIAL (2), SQUARE (3), CONICAL-SYMMETRIC (4), CONICAL-ASYMMETRIC (5), SHAPEBURST-ANGULAR (6), SHAPEBURST-SPHERICAL (7), SHAPEBURST-DIMPLED (8), SPIRAL-CLOCKWISE(9), SPRIAL-ANTICLOCKWISE(10) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The opacity of the final blend (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"offset",
|
||||
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode depndent (0 <= offset)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"repeat",
|
||||
"Repeat mode: { REPEAT-NONE (0), REPEAT-SAWTOOTH (1), REPEAT-TRIANGULAR (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"supersample",
|
||||
"Do adaptive supersampling (true / false)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"max_depth",
|
||||
"Maximum recursion levels for supersampling"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"Supersampling threshold"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"The x coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"The y coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"The x coordinate of this blend's ending point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"The y coordinate of this blend's ending point"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord blend_proc =
|
||||
{
|
||||
"gimp_blend",
|
||||
"Blend between the starting and ending coordinates with the specified blend mode and gradient type.",
|
||||
"This tool requires information on the paint application mode, the blend mode, and the gradient type. It creates the specified variety of blend using the starting and ending coordinates as defined for each gradient type.",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
14,
|
||||
blend_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { blend_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
blend_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
BlendMode blend_mode;
|
||||
int paint_mode;
|
||||
GradientType gradient_type;
|
||||
double opacity;
|
||||
double offset;
|
||||
RepeatMode repeat;
|
||||
int supersample;
|
||||
int max_depth;
|
||||
double threshold;
|
||||
double x1, y1;
|
||||
double x2, y2;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
blend_mode = FG_BG_RGB_MODE;
|
||||
paint_mode = NORMAL_MODE;
|
||||
gradient_type = Linear;
|
||||
opacity = 100.0;
|
||||
offset = 0.0;
|
||||
repeat = REPEAT_NONE;
|
||||
supersample = FALSE;
|
||||
max_depth = 0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* blend mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < BLEND_MODE_LAST)
|
||||
blend_mode = (BlendMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= DIVIDE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* gradient type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < GradientTypeLast)
|
||||
gradient_type = (GradientType) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* offset */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[5].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
offset = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* repeat */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < REPEAT_LAST)
|
||||
repeat = (RepeatMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* supersampling */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
|
||||
supersample = (int_value ? TRUE : FALSE);
|
||||
}
|
||||
/* max_depth */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
|
||||
if (((int_value >= 1) && (int_value <= 9)) || !supersample)
|
||||
max_depth = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[9].value.pdb_float;
|
||||
|
||||
if (((fp_value >= 0.0) && (fp_value <= 4.0)) || !supersample)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* x1, y1, x2, y2 */
|
||||
if (success)
|
||||
{
|
||||
x1 = args[10].value.pdb_float;
|
||||
y1 = args[11].value.pdb_float;
|
||||
x2 = args[12].value.pdb_float;
|
||||
y2 = args[13].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,26 +18,28 @@
|
|||
#ifndef __BLEND_H__
|
||||
#define __BLEND_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Linear,
|
||||
BiLinear,
|
||||
Radial,
|
||||
Square,
|
||||
ConicalSymmetric,
|
||||
ConicalAsymmetric,
|
||||
ShapeburstAngular,
|
||||
ShapeburstSpherical,
|
||||
ShapeburstDimpled,
|
||||
SpiralClockwise,
|
||||
SpiralAntiClockwise,
|
||||
GradientTypeLast /*< skip >*/
|
||||
LINEAR,
|
||||
BILINEAR,
|
||||
RADIAL,
|
||||
SQUARE,
|
||||
CONICAL_SYMMETRIC,
|
||||
CONICAL_ASYMMETRIC,
|
||||
SHAPEBURST_ANGULAR,
|
||||
SHAPEBURST_SPHERICAL,
|
||||
SHAPEBURST_DIMPLED,
|
||||
SPIRAL_CLOCKWISE,
|
||||
SPIRAL_ANTICLOCKWISE,
|
||||
GRADIENT_TYPE_LAST /*< skip >*/
|
||||
} GradientType;
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_MODE >*/
|
||||
{
|
||||
FG_BG_RGB_MODE,
|
||||
FG_BG_HSV_MODE,
|
||||
|
@ -54,10 +56,11 @@ typedef enum
|
|||
REPEAT_LAST /*< skip >*/
|
||||
} RepeatMode;
|
||||
|
||||
void blend (GimpImage *, GimpDrawable *, BlendMode, int, GradientType,
|
||||
double, double, RepeatMode, int, int, double, double,
|
||||
double, double, double, progress_func_t, void *);
|
||||
|
||||
Tool * tools_new_blend (void);
|
||||
void tools_free_blend (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord blend_proc;
|
||||
|
||||
#endif /* __BLEND_H__ */
|
||||
|
|
|
@ -47,27 +47,27 @@ struct _BucketTool
|
|||
typedef struct _BucketOptions BucketOptions;
|
||||
struct _BucketOptions
|
||||
{
|
||||
ToolOptions tool_options;
|
||||
ToolOptions tool_options;
|
||||
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
|
||||
FillMode fill_mode;
|
||||
FillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
BucketFillMode fill_mode;
|
||||
BucketFillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,11 +82,7 @@ static void bucket_fill_motion (Tool *, GdkEventMotion *, gpointer);
|
|||
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void bucket_fill_control (Tool *, int, gpointer);
|
||||
|
||||
static void bucket_fill (GImage *, GimpDrawable *, FillMode,
|
||||
int, double, double,
|
||||
int, double, double);
|
||||
|
||||
static void bucket_fill_region (FillMode, PixelRegion *, PixelRegion *,
|
||||
static void bucket_fill_region (BucketFillMode, PixelRegion *, PixelRegion *,
|
||||
unsigned char *, TempBuf *,
|
||||
int, int, int);
|
||||
static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
||||
|
@ -94,8 +90,6 @@ static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
|||
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
|
||||
TempBuf *, int, int, int, int, int);
|
||||
|
||||
static Argument *bucket_fill_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -103,7 +97,7 @@ static void
|
|||
bucket_fill_mode_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
bucket_options->fill_mode = (FillMode) client_data;
|
||||
bucket_options->fill_mode = (BucketFillMode) client_data;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -128,7 +122,7 @@ bucket_options_reset (void)
|
|||
options->sample_merged_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w),
|
||||
options->threshold_d);
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FgColorFill) ?
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FG_BUCKET_FILL) ?
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[1])),
|
||||
TRUE);
|
||||
|
@ -168,7 +162,7 @@ bucket_options_new (void)
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->sample_merged = options->sample_merged_d = FALSE;
|
||||
options->threshold = options->threshold_d = 15.0;
|
||||
options->fill_mode = options->fill_mode_d = FgColorFill;
|
||||
options->fill_mode = options->fill_mode_d = FG_BUCKET_FILL;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = options->tool_options.main_vbox;
|
||||
|
@ -269,7 +263,7 @@ bucket_options_new (void)
|
|||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
|
||||
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
|
||||
(GtkSignalFunc) bucket_fill_mode_callback,
|
||||
(gpointer) ((long) (i == 1 ? PatternFill : FgColorFill))); /* kludgy */
|
||||
(gpointer) ((long) (i == 1 ? PATTERN_BUCKET_FILL : FG_BUCKET_FILL))); /* kludgy */
|
||||
gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (radio_button);
|
||||
|
||||
|
@ -318,7 +312,7 @@ bucket_fill_button_release (Tool *tool,
|
|||
{
|
||||
GDisplay * gdisp;
|
||||
BucketTool * bucket_tool;
|
||||
FillMode fill_mode;
|
||||
BucketFillMode fill_mode;
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
|
@ -334,8 +328,8 @@ bucket_fill_button_release (Tool *tool,
|
|||
fill_mode = bucket_options->fill_mode;
|
||||
|
||||
/* If the mode is color filling, and shift mask is down, fill with background */
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FgColorFill)
|
||||
fill_mode = BgColorFill;
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FG_BUCKET_FILL)
|
||||
fill_mode = BG_BUCKET_FILL;
|
||||
|
||||
return_vals = procedural_db_run_proc ("gimp_bucket_fill",
|
||||
&nreturn_vals,
|
||||
|
@ -411,16 +405,16 @@ bucket_fill_control (Tool *tool,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
bucket_fill (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
FillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
void
|
||||
bucket_fill (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BucketFillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR, maskPR;
|
||||
|
@ -435,11 +429,11 @@ bucket_fill (GImage *gimage,
|
|||
|
||||
pat_buf = NULL;
|
||||
|
||||
if (fill_mode == FgColorFill)
|
||||
if (fill_mode == FG_BUCKET_FILL)
|
||||
gimage_get_foreground (gimage, drawable, col);
|
||||
else if (fill_mode == BgColorFill)
|
||||
else if (fill_mode == BG_BUCKET_FILL)
|
||||
gimage_get_background (gimage, drawable, col);
|
||||
else if (fill_mode == PatternFill)
|
||||
else if (fill_mode == PATTERN_BUCKET_FILL)
|
||||
{
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
|
@ -629,14 +623,14 @@ bucket_fill_line_pattern (unsigned char *buf,
|
|||
|
||||
|
||||
static void
|
||||
bucket_fill_region (FillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
bucket_fill_region (BucketFillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
{
|
||||
unsigned char *s, *m;
|
||||
int y;
|
||||
|
@ -654,11 +648,11 @@ bucket_fill_region (FillMode fill_mode,
|
|||
{
|
||||
switch (fill_mode)
|
||||
{
|
||||
case FgColorFill:
|
||||
case BgColorFill:
|
||||
case FG_BUCKET_FILL:
|
||||
case BG_BUCKET_FILL:
|
||||
bucket_fill_line_color (s, m, col, has_alpha, bufPR->bytes, bufPR->w);
|
||||
break;
|
||||
case PatternFill:
|
||||
case PATTERN_BUCKET_FILL:
|
||||
bucket_fill_line_pattern (s, m, pattern, has_alpha, bufPR->bytes,
|
||||
off_x + bufPR->x, off_y + y + bufPR->y, bufPR->w);
|
||||
break;
|
||||
|
@ -722,158 +716,3 @@ tools_free_bucket_fill (Tool *tool)
|
|||
|
||||
g_free (bucket_tool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The bucket fill procedure definition */
|
||||
ProcArg bucket_fill_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_mode",
|
||||
"the type of fill: { FG-BUCKET-FILL (0), BG-BUCKET-FILL (1), PATTERN-BUCKET-FILL (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the opacity of the final bucket fill (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"the threshold determines how extensive the seed fill will be. It's value is specified in terms of intensity levels (0 <= threshold <= 255). This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"the x coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"the y coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord bucket_fill_proc =
|
||||
{
|
||||
"gimp_bucket_fill",
|
||||
"Fill the area specified either by the current selection if there is one, or by a seed fill starting at the specified coordinates.",
|
||||
"This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x,y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
bucket_fill_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { bucket_fill_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
bucket_fill_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
FillMode fill_mode;
|
||||
int paint_mode;
|
||||
double opacity;
|
||||
double threshold;
|
||||
int sample_merged;
|
||||
double x, y;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
fill_mode = BgColorFill;
|
||||
paint_mode = NORMAL_MODE;
|
||||
opacity = 100.0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fill mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: fill_mode = FgColorFill; break;
|
||||
case 1: fill_mode = BgColorFill; break;
|
||||
case 2: fill_mode = PatternFill; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= VALUE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[3].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 255.0)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* sample_merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[6].value.pdb_float;
|
||||
y = args[7].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
bucket_fill (gimage, drawable, fill_mode, paint_mode,
|
||||
opacity, threshold, sample_merged, x, y);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&bucket_fill_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,20 +18,21 @@
|
|||
#ifndef __BUCKET_FILL_H__
|
||||
#define __BUCKET_FILL_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FgColorFill,
|
||||
BgColorFill,
|
||||
PatternFill
|
||||
} FillMode;
|
||||
FG_BUCKET_FILL,
|
||||
BG_BUCKET_FILL,
|
||||
PATTERN_BUCKET_FILL
|
||||
} BucketFillMode;
|
||||
|
||||
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
|
||||
double, double, int, double, double);
|
||||
|
||||
Tool * tools_new_bucket_fill (void);
|
||||
void tools_free_bucket_fill (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord bucket_fill_proc;
|
||||
|
||||
#endif /* __BUCKET_FILL_H__ */
|
||||
|
|
|
@ -90,9 +90,6 @@ static void by_color_select_preview_button_press (ByColorDialog *, G
|
|||
|
||||
static int is_pixel_sufficiently_different (unsigned char *, unsigned char *, int, int, int, int);
|
||||
static Channel * by_color_select_color (GImage *, GimpDrawable *, unsigned char *, int, int, int);
|
||||
static void by_color_select (GImage *, GimpDrawable *, unsigned char *, int, int, int, int, double, int);
|
||||
static Argument * by_color_select_invoker (Argument *);
|
||||
|
||||
|
||||
/* by_color selection machinery */
|
||||
|
||||
|
@ -243,7 +240,7 @@ by_color_select_color (GImage *gimage,
|
|||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
by_color_select (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
unsigned char *color,
|
||||
|
@ -972,157 +969,3 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
by_color_select_render (bcd, bcd->gimage);
|
||||
by_color_select_draw (bcd, bcd->gimage);
|
||||
}
|
||||
|
||||
|
||||
/* The by_color_select procedure definition */
|
||||
ProcArg by_color_select_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_COLOR,
|
||||
"color",
|
||||
"the color to select"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"threshold",
|
||||
"threshold in intensity levels: 0 <= threshold <= 255"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord by_color_select_proc =
|
||||
{
|
||||
"gimp_by_color_select",
|
||||
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
|
||||
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
by_color_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { by_color_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
by_color_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int op;
|
||||
int threshold;
|
||||
int antialias;
|
||||
int feather;
|
||||
int sample_merged;
|
||||
unsigned char color[3];
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
drawable = NULL;
|
||||
op = REPLACE;
|
||||
threshold = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* color */
|
||||
if (success)
|
||||
{
|
||||
int i;
|
||||
unsigned char *color_array;
|
||||
|
||||
color_array = (unsigned char *) args[1].value.pdb_pointer;
|
||||
for (i = 0; i < 3; i++)
|
||||
color[i] = color_array[i];
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= 0 && int_value <= 255)
|
||||
threshold = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[6].value.pdb_float;
|
||||
}
|
||||
/* sample merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* call the ellipse_select procedure */
|
||||
if (success)
|
||||
by_color_select (gimage, drawable, color, threshold, op,
|
||||
antialias, feather, feather_radius, sample_merged);
|
||||
|
||||
return procedural_db_return_args (&by_color_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -19,18 +19,17 @@
|
|||
#define __BY_COLOR_SELECT_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gdisplayF.h"
|
||||
#include "gimage.h"
|
||||
|
||||
/* by_color select functions */
|
||||
void by_color_select (GimpImage *, GimpDrawable *, guchar *, int,
|
||||
int, int, int, double, int);
|
||||
|
||||
Tool * tools_new_by_color_select (void);
|
||||
void tools_free_by_color_select (Tool *);
|
||||
|
||||
void by_color_select_initialize (GDisplay *);
|
||||
void by_color_select_initialize_by_image (GImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord by_color_select_proc;
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
|
@ -89,8 +89,6 @@ static void clone_line_image (GImage *, GImage *, GimpDrawable *, GimpD
|
|||
static void clone_line_pattern (GImage *, GimpDrawable *, GPatternP, unsigned char *,
|
||||
int, int, int, int);
|
||||
|
||||
static Argument * clone_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -146,7 +144,7 @@ clone_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Clone Tool Options"),
|
||||
clone_options_reset);
|
||||
options->type = options->type_d = ImageClone;
|
||||
options->type = options->type_d = IMAGE_CLONE;
|
||||
options->aligned = options->aligned_d = AlignNo;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -303,7 +301,7 @@ clone_paint_func (PaintCore *paint_core,
|
|||
orig_src_x = src_x;
|
||||
orig_src_y = src_y;
|
||||
}
|
||||
if (clone_options->type == PatternClone)
|
||||
if (clone_options->type == PATTERN_CLONE)
|
||||
if (!get_active_pattern ())
|
||||
g_message (_("No patterns available for this operation."));
|
||||
break;
|
||||
|
@ -382,7 +380,7 @@ clone_draw (Tool *tool)
|
|||
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
if (clone_options->type == ImageClone)
|
||||
if (clone_options->type == IMAGE_CLONE)
|
||||
{
|
||||
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
|
||||
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
|
||||
|
@ -418,7 +416,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pattern = NULL;
|
||||
|
||||
/* Make sure we still have a source if we are doing image cloning */
|
||||
if (type == ImageClone)
|
||||
if (type == IMAGE_CLONE)
|
||||
{
|
||||
if (!src_drawable)
|
||||
return;
|
||||
|
@ -438,7 +436,7 @@ clone_motion (PaintCore *paint_core,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
/* Set the paint area to transparent */
|
||||
memset (temp_buf_data (area), 0, area->width * area->height * area->bytes);
|
||||
|
||||
|
@ -500,7 +498,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
break;
|
||||
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
if (!pattern)
|
||||
|
@ -525,12 +523,12 @@ clone_motion (PaintCore *paint_core,
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
clone_line_image (gimage, src_gimage, drawable, src_drawable, s, d,
|
||||
has_alpha, srcPR.bytes, destPR.bytes, destPR.w);
|
||||
s += srcPR.rowstride;
|
||||
break;
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
clone_line_pattern (gimage, drawable, pattern, d,
|
||||
area->x + offset_x, area->y + y + offset_y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
@ -630,141 +628,25 @@ clone_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The clone procedure definition */
|
||||
ProcArg clone_args[] =
|
||||
gboolean
|
||||
clone_non_gui (GimpDrawable *drawable,
|
||||
GimpDrawable *src_drawable,
|
||||
CloneType clone_type,
|
||||
double src_x,
|
||||
double src_y,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_DRAWABLE,
|
||||
"src_drawable",
|
||||
"the source drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"clone_type",
|
||||
"the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_x",
|
||||
"the x coordinate in the source image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_y",
|
||||
"the y coordinate in the source image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord clone_proc =
|
||||
{
|
||||
"gimp_clone",
|
||||
"Clone from the source to the dest drawable using the current brush",
|
||||
"This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \"clone_type\" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \"src_drawable\" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
clone_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { clone_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
clone_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable *src_drawable;
|
||||
double src_x, src_y;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the src drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
src_drawable = drawable_get_ID (int_value);
|
||||
if (src_drawable == NULL || gimage != drawable_gimage (src_drawable))
|
||||
success = FALSE;
|
||||
else
|
||||
non_gui_src_drawable = src_drawable;
|
||||
}
|
||||
/* the clone type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: non_gui_type = ImageClone; break;
|
||||
case 1: non_gui_type = PatternClone; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* x, y offsets */
|
||||
if (success)
|
||||
{
|
||||
src_x = args[3].value.pdb_float;
|
||||
src_y = args[4].value.pdb_float;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[6].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
|
||||
|
||||
non_gui_src_drawable = src_drawable;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
|
@ -785,12 +667,13 @@ clone_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&clone_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,18 @@
|
|||
#define __CLONE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ImageClone,
|
||||
PatternClone
|
||||
IMAGE_CLONE,
|
||||
PATTERN_CLONE
|
||||
} CloneType;
|
||||
|
||||
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
|
||||
double, double, int, double *);
|
||||
Tool * tools_new_clone (void);
|
||||
void tools_free_clone (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord clone_proc;
|
||||
|
||||
#endif /* __CLONE_H__ */
|
||||
|
|
|
@ -66,8 +66,10 @@ struct _ColourPickerTool
|
|||
/* the color picker tool options */
|
||||
static ColorPickerOptions * color_picker_options = NULL;
|
||||
|
||||
/* the color value */
|
||||
int col_value[5] = { 0, 0, 0, 0, 0 };
|
||||
|
||||
/* the color picker dialog */
|
||||
static int col_value [5] = { 0, 0, 0, 0, 0 };
|
||||
static GimpDrawable * active_drawable;
|
||||
static int update_type;
|
||||
static int sample_type;
|
||||
|
@ -89,11 +91,8 @@ static void color_picker_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
|||
static void color_picker_control (Tool *, int, void *);
|
||||
static void color_picker_info_window_close_callback (GtkWidget *, gpointer);
|
||||
|
||||
static int get_color (GimpImage *, GimpDrawable *, int, int, gboolean, gboolean, double, int);
|
||||
static void color_picker_info_update (Tool *, int);
|
||||
|
||||
static Argument *color_picker_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -282,20 +281,20 @@ color_picker_button_press (Tool *tool,
|
|||
*/
|
||||
if (bevent->state & GDK_SHIFT_MASK)
|
||||
{
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_NEW));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_NEW));
|
||||
update_type = COLOR_UPDATE_NEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_UPDATE));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
COLOR_UPDATE));
|
||||
update_type = COLOR_UPDATE;
|
||||
}
|
||||
|
||||
|
@ -321,11 +320,11 @@ color_picker_button_release (Tool *tool,
|
|||
/* First, transform the coordinates to gimp image space */
|
||||
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
|
||||
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
|
||||
draw_core_stop (cp_tool->core, tool);
|
||||
tool->state = INACTIVE;
|
||||
|
@ -351,11 +350,11 @@ color_picker_motion (Tool *tool,
|
|||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &cp_tool->centerx, &cp_tool->centery, FALSE, TRUE);
|
||||
|
||||
color_picker_info_update (tool, get_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
color_picker_info_update (tool, pick_color (gdisp->gimage, active_drawable, x, y,
|
||||
color_picker_options->sample_merged,
|
||||
color_picker_options->sample_average,
|
||||
color_picker_options->average_radius,
|
||||
update_type));
|
||||
/* redraw the current tool */
|
||||
draw_core_resume (cp_tool->core, tool);
|
||||
}
|
||||
|
@ -402,15 +401,15 @@ color_picker_control (Tool *tool,
|
|||
|
||||
typedef guchar * (*GetColorFunc) (GtkObject *, int, int);
|
||||
|
||||
static int
|
||||
get_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int x,
|
||||
int y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
double average_radius,
|
||||
int final)
|
||||
int
|
||||
pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
int x,
|
||||
int y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
double average_radius,
|
||||
int final)
|
||||
{
|
||||
guchar *color;
|
||||
int offx, offy;
|
||||
|
@ -652,133 +651,6 @@ tools_free_color_picker (Tool *tool)
|
|||
g_free(cp_tool);
|
||||
}
|
||||
|
||||
/* The color_picker procedure definition */
|
||||
ProcArg color_picker_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of upper-left corner of rectangle"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"save_color",
|
||||
"save the color to the active palette"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg color_picker_out_args[] =
|
||||
{
|
||||
{ PDB_COLOR,
|
||||
"color",
|
||||
"the return color"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord color_picker_proc =
|
||||
{
|
||||
"gimp_color_picker",
|
||||
"Determine the color at the given drawable coordinates",
|
||||
"This tool determines the color at the specified coordinates. The returned color is an RGB triplet even for grayscale and indexed drawables. If the coordinates lie outside of the extents of the specified drawable, then an error is returned. If the drawable has an alpha channel, the algorithm examines the alpha value of the drawable at the coordinates. If the alpha value is completely transparent (0), then an error is returned. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
color_picker_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
color_picker_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { color_picker_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
color_picker_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
int success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
double x, y;
|
||||
int sample_merged;
|
||||
int save_color;
|
||||
int int_value;
|
||||
Argument *return_args;
|
||||
unsigned char *color;
|
||||
|
||||
drawable = NULL;
|
||||
x = 0;
|
||||
y = 0;
|
||||
sample_merged = FALSE;
|
||||
save_color = COLOR_UPDATE;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
}
|
||||
/* sample_merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* save_color */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
save_color = (int_value) ? COLOR_NEW : COLOR_UPDATE;
|
||||
}
|
||||
|
||||
/* Make sure that if we're not using the composite, the specified drawable is valid */
|
||||
if (success && !sample_merged)
|
||||
if (!drawable || (drawable_gimage (drawable)) != gimage)
|
||||
success = FALSE;
|
||||
|
||||
/* call the color_picker procedure */
|
||||
if (success)
|
||||
success = get_color (gimage, drawable, (int) x, (int) y, sample_merged, FALSE, 1.0, save_color);
|
||||
|
||||
return_args = procedural_db_return_args (&color_picker_proc, success);
|
||||
|
||||
if (success)
|
||||
{
|
||||
color = (unsigned char *) g_malloc (3);
|
||||
color[RED_PIX] = col_value[RED_PIX];
|
||||
color[GREEN_PIX] = col_value[GREEN_PIX];
|
||||
color[BLUE_PIX] = col_value[BLUE_PIX];
|
||||
return_args[1].value.pdb_pointer = color;
|
||||
}
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static void
|
||||
color_picker_info_window_close_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
|
|
|
@ -18,13 +18,16 @@
|
|||
#ifndef __COLOR_PICKER_H__
|
||||
#define __COLOR_PICKER_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "tools.h"
|
||||
|
||||
int pick_color (GimpImage *, GimpDrawable *, int , int,
|
||||
gboolean, gboolean, double, int);
|
||||
|
||||
Tool * tools_new_color_picker (void);
|
||||
void tools_free_color_picker (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord color_picker_proc;
|
||||
extern int col_value[5];
|
||||
|
||||
#endif /* __COLOR_PICKER_H__ */
|
||||
|
|
|
@ -98,7 +98,6 @@ static void copy_matrix (float *, float *, int);
|
|||
static int sum_matrix (int *, int);
|
||||
|
||||
static void convolve_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * convolve_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -147,7 +146,7 @@ convolve_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Convolver Options"),
|
||||
convolve_options_reset);
|
||||
options->type = options->type_d = Blur;
|
||||
options->type = options->type_d = BLUR_CONVOLVE;
|
||||
options->pressure = options->pressure_d = 50.0;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -364,19 +363,19 @@ calculate_matrix (ConvolveType type,
|
|||
/* get the appropriate convolution matrix and size and divisor */
|
||||
switch (type)
|
||||
{
|
||||
case Blur:
|
||||
case BLUR_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
blur_matrix [12] = MIN_BLUR + percent * (MAX_BLUR - MIN_BLUR);
|
||||
copy_matrix (blur_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Sharpen:
|
||||
case SHARPEN_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
sharpen_matrix [12] = MIN_SHARPEN + percent * (MAX_SHARPEN - MIN_SHARPEN);
|
||||
copy_matrix (sharpen_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Custom:
|
||||
case CUSTOM_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
break;
|
||||
}
|
||||
|
@ -437,128 +436,18 @@ convolve_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The convolve procedure definition */
|
||||
ProcArg convolve_args[] =
|
||||
gboolean
|
||||
convolve_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"the pressure: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"convolve_type",
|
||||
"convolve type: { BLUR (0), SHARPEN (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord convolve_proc =
|
||||
{
|
||||
"gimp_convolve",
|
||||
"Convolve (Blur, Sharpen) using the current brush",
|
||||
"This tool convolves the specified drawable with either a sharpening or blurring kernel. The pressure parameter controls the magnitude of the operation. Like the paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
convolve_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { convolve_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
convolve_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
double pressure;
|
||||
ConvolveType type;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
ConvolveType int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
pressure = 100.0;
|
||||
type = Blur;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_int;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* the convolve type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: type = Blur; break;
|
||||
case 1: type = Sharpen; break;
|
||||
case 2: success = FALSE; break; /*type = Custom; break;*/
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[4].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = convolve_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -578,12 +467,13 @@ convolve_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&convolve_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,21 +19,18 @@
|
|||
#define __CONVOLVE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_CONVOLVE >*/
|
||||
{
|
||||
Blur,
|
||||
Sharpen,
|
||||
Custom
|
||||
BLUR_CONVOLVE,
|
||||
SHARPEN_CONVOLVE,
|
||||
CUSTOM_CONVOLVE
|
||||
} ConvolveType;
|
||||
|
||||
void * convolve_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean convolve_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_convolve (void);
|
||||
void tools_free_convolve (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord convolve_proc;
|
||||
|
||||
#endif /* __CONVOLVE_H__ */
|
||||
|
|
104
app/tools/crop.c
104
app/tools/crop.c
|
@ -110,8 +110,6 @@ static void crop_control (Tool *, int, gpointer);
|
|||
static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer);
|
||||
|
||||
/* Crop helper functions */
|
||||
static void crop_image (GImage *gimage,
|
||||
int, int, int, int, int, int);
|
||||
static void crop_recalc (Tool *, Crop *);
|
||||
static void crop_start (Tool *, Crop *);
|
||||
static void crop_adjust_guides (GImage *, int, int, int, int);
|
||||
|
@ -143,8 +141,6 @@ static int crop_colors_alpha (guchar *, guchar *, int);
|
|||
static void crop_orig_changed (GtkWidget *, gpointer);
|
||||
static void crop_size_changed (GtkWidget *, gpointer);
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
|
@ -837,7 +833,7 @@ tools_free_crop (Tool *tool)
|
|||
g_free (crop);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
crop_image (GImage *gimage,
|
||||
int x1,
|
||||
int y1,
|
||||
|
@ -1548,101 +1544,3 @@ crop_size_changed (GtkWidget *w,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg crop_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_width",
|
||||
"new image width: (0 < new_width <= width)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_height",
|
||||
"new image height: (0 < new_height <= height)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offx",
|
||||
"x offset: (0 <= offx <= (width - new_width))"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offy",
|
||||
"y offset: (0 <= offy <= (height - new_height))"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord crop_proc =
|
||||
{
|
||||
"gimp_crop",
|
||||
"Crop the image to the specified extents.",
|
||||
"This procedure crops the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. All channels and layers within the image are cropped to the new image extents; this includes the image selection mask. If any parameters are out of range, an error is returned.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
crop_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { crop_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
crop_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
int success;
|
||||
int int_value;
|
||||
int new_width, new_height;
|
||||
int offx, offy;
|
||||
int layer_only, crop_layers ;
|
||||
|
||||
new_width = 1;
|
||||
new_height = 1;
|
||||
offx = 0;
|
||||
offy = 0;
|
||||
layer_only = FALSE;
|
||||
crop_layers = TRUE;
|
||||
|
||||
success = TRUE;
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if ((gimage = gimage_get_ID (int_value)) == NULL)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
new_width = args[1].value.pdb_int;
|
||||
new_height = args[2].value.pdb_int;
|
||||
|
||||
if (new_width <= 0 || new_height <= 0)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offx = args[3].value.pdb_int;
|
||||
offy = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if ((new_width <= 0 || new_width > gimage->width) ||
|
||||
(new_height <= 0 || new_height > gimage->height) ||
|
||||
(offx < 0 || offx > (gimage->width - new_width)) ||
|
||||
(offy < 0 || offy > (gimage->height - new_height)))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
layer_only, crop_layers);
|
||||
|
||||
return procedural_db_return_args (&crop_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,17 +18,16 @@
|
|||
#ifndef __CROP_H__
|
||||
#define __CROP_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
/* select functions */
|
||||
void crop_draw (Tool *);
|
||||
void crop_image (GimpImage *gimage, int, int, int, int, int, int);
|
||||
|
||||
Tool * tools_new_crop (void);
|
||||
void tools_free_crop (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord crop_proc;
|
||||
|
||||
#endif /* __CROP_H__ */
|
||||
|
||||
|
||||
|
|
|
@ -33,25 +33,19 @@
|
|||
SelectionOptions * ellipse_options = NULL;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
static Argument *ellipse_select_invoker (Argument *);
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Ellipsoidal selection apparatus */
|
||||
|
||||
void
|
||||
ellipse_select (GImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
ellipse_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
|
||||
|
@ -161,136 +155,3 @@ tools_free_ellipse_select (Tool *tool)
|
|||
draw_core_free (ellipse_sel->core);
|
||||
g_free (ellipse_sel);
|
||||
}
|
||||
|
||||
/* The ellipse_select procedure definition */
|
||||
ProcArg ellipse_select_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of upper-left corner of ellipse bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of upper-left corner of ellipse bounding box"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"width",
|
||||
"the width of the ellipse: width > 0"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"height",
|
||||
"the height of the ellipse: height > 0"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord ellipse_select_proc =
|
||||
{
|
||||
"gimp_ellipse_select",
|
||||
"Create an elliptical selection over the specified image",
|
||||
"This tool creates an elliptical selection over the specified image. The elliptical region can be either added to, subtracted from, or replace the contents of the previous selection mask. If antialiasing is turned on, the edges of the elliptical region will contain intermediate values which give the appearance of a sharper, less pixelized edge. This should be set as TRUE most of the time. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
9,
|
||||
ellipse_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { ellipse_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
ellipse_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
int op;
|
||||
int antialias;
|
||||
int feather;
|
||||
double x, y;
|
||||
double w, h;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
op = REPLACE;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
/* x, y, w, h */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
w = args[3].value.pdb_float;
|
||||
h = args[4].value.pdb_float;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[8].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the ellipse_select procedure */
|
||||
if (success)
|
||||
ellipse_select (gimage, (int) x, (int) y, (int) w, (int) h,
|
||||
op, antialias, feather, feather_radius);
|
||||
|
||||
return procedural_db_return_args (&ellipse_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
#ifndef __ELLIPSE_SELECT_H__
|
||||
#define __ELLIPSE_SELECT_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
|
||||
/* ellipse select functions */
|
||||
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select (GimpImage *, int, int, int, int, int,
|
||||
int, int, double);
|
||||
|
||||
Tool * tools_new_ellipse_select (void);
|
||||
void tools_free_ellipse_select (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord ellipse_select_proc;
|
||||
|
||||
#endif /* __ELLIPSE_SELECT_H__ */
|
||||
|
|
|
@ -59,8 +59,6 @@ static gboolean non_gui_incremental;
|
|||
/* forward function declarations */
|
||||
static void eraser_motion (PaintCore *, GimpDrawable *,
|
||||
gboolean, gboolean);
|
||||
static Argument * eraser_invoker (Argument *);
|
||||
static Argument * eraser_extended_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -217,141 +215,22 @@ eraser_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The eraser procedure definition */
|
||||
ProcArg eraser_extended_args[] =
|
||||
gboolean
|
||||
eraser_non_gui (GimpDrawable *drawable,
|
||||
int num_strokes,
|
||||
double *stroke_array,
|
||||
int hardness,
|
||||
int method)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"hardness",
|
||||
"SOFT(0) or HARD(1)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"method",
|
||||
"CONTINUOUS(0) or INCREMENTAL(1)"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg eraser_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord eraser_proc =
|
||||
{
|
||||
"gimp_eraser",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
3,
|
||||
eraser_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_invoker } },
|
||||
};
|
||||
|
||||
ProcRecord eraser_extended_proc =
|
||||
{
|
||||
"gimp_eraser_extended",
|
||||
"Erase using the current brush",
|
||||
"This tool erases using the current brush mask. If the specified drawable contains an alpha channel, then the erased pixels will become transparent. Otherwise, the eraser tool replaces the contents of the drawable with the background color. Like paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
eraser_extended_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { eraser_extended_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
eraser_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
non_gui_hard = hardness;
|
||||
non_gui_incremental = method;
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard=0; non_gui_incremental = 0;
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -371,94 +250,13 @@ eraser_invoker (args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
}
|
||||
|
||||
static Argument *
|
||||
eraser_extended_invoker (args)
|
||||
Argument *args;
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[2].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
non_gui_hard = args[3].value.pdb_int;
|
||||
non_gui_incremental = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = eraser_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
if (num_strokes == 1)
|
||||
eraser_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
|
||||
|
||||
for (i = 1; i < num_strokes; i++)
|
||||
{
|
||||
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
|
||||
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
|
||||
|
||||
paint_core_interpolate (&non_gui_paint_core, drawable);
|
||||
|
||||
non_gui_paint_core.lastx = non_gui_paint_core.curx;
|
||||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
paint_core_cleanup ();
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&eraser_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,12 @@
|
|||
#define __ERASER_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
void * eraser_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean eraser_non_gui (GimpDrawable *, int, double *, int, int);
|
||||
|
||||
Tool * tools_new_eraser (void);
|
||||
void tools_free_eraser (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord eraser_proc;
|
||||
extern ProcRecord eraser_extended_proc;
|
||||
|
||||
#endif /* __ERASER_H__ */
|
||||
|
|
|
@ -52,12 +52,7 @@ static FlipOptions *flip_options = NULL;
|
|||
/* forward function declarations */
|
||||
static Tool * tools_new_flip_horz (void);
|
||||
static Tool * tools_new_flip_vert (void);
|
||||
static TileManager * flip_tool_flip_horz (GImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
static TileManager * flip_tool_flip_vert (GImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
static void flip_change_type (int);
|
||||
static Argument * flip_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -259,7 +254,7 @@ tools_new_flip_vert ()
|
|||
return tool;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
TileManager *
|
||||
flip_tool_flip_horz (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
|
@ -300,7 +295,7 @@ flip_tool_flip_horz (GImage *gimage,
|
|||
return new;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
TileManager *
|
||||
flip_tool_flip_vert (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
|
@ -352,127 +347,3 @@ flip_change_type (int new_type)
|
|||
tools_select (flip_options->type);
|
||||
}
|
||||
}
|
||||
|
||||
/* The flip procedure definition */
|
||||
ProcArg flip_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"flip_type",
|
||||
"Type of flip: { HORIZONTAL (0), VERTICAL (1) }"
|
||||
}
|
||||
};
|
||||
|
||||
ProcArg flip_out_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the flipped drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord flip_proc =
|
||||
{
|
||||
"gimp_flip",
|
||||
"Flip the specified drawable about its center either vertically or horizontally",
|
||||
"This tool flips the specified drawable if no selection exists. If a selection exists, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipd by the specified amount. The return value is the ID of the flipped drawable. If there was no selection, this will be equal to the drawable ID supplied as input. Otherwise, this will be the newly created and flipd drawable. The flip type parameter indicates whether the flip will be applied horizontally or vertically.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
2,
|
||||
flip_args,
|
||||
|
||||
/* Output arguments */
|
||||
1,
|
||||
flip_out_args,
|
||||
|
||||
/* Exec method */
|
||||
{ { flip_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
flip_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int flip_type;
|
||||
int int_value;
|
||||
TileManager *float_tiles;
|
||||
TileManager *new_tiles;
|
||||
int new_layer;
|
||||
Layer *layer;
|
||||
Argument *return_args;
|
||||
|
||||
drawable = NULL;
|
||||
flip_type = 0;
|
||||
new_tiles = NULL;
|
||||
layer = NULL;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* flip type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: flip_type = 0; break;
|
||||
case 1: flip_type = 1; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* call the flip procedure */
|
||||
if (success)
|
||||
{
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = transform_core_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* flip the buffer */
|
||||
switch (flip_type)
|
||||
{
|
||||
case 0: /* horz */
|
||||
new_tiles = flip_tool_flip_horz (gimage, drawable, float_tiles, -1);
|
||||
break;
|
||||
case 1: /* vert */
|
||||
new_tiles = flip_tool_flip_vert (gimage, drawable, float_tiles, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = (layer = transform_core_paste (gimage, drawable, new_tiles, new_layer)) != NULL;
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&flip_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE(layer));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
|
|
@ -19,15 +19,17 @@
|
|||
#define __FLIP_TOOL_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
/* Flip tool functions */
|
||||
|
||||
void * flip_tool_transform (Tool *, gpointer, int);
|
||||
void * flip_tool_transform (Tool *, gpointer, int);
|
||||
|
||||
TileManager * flip_tool_flip_horz (GimpImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
TileManager * flip_tool_flip_vert (GimpImage *, GimpDrawable *,
|
||||
TileManager *, int);
|
||||
|
||||
Tool * tools_new_flip (void);
|
||||
void tools_free_flip_tool (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord flip_proc;
|
||||
|
||||
#endif /* __FLIP_TOOL_H__ */
|
||||
|
|
|
@ -44,7 +44,6 @@ struct _free_select
|
|||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
typedef struct _FreeSelectPoint FreeSelectPoint;
|
||||
struct _FreeSelectPoint
|
||||
{
|
||||
double x, y;
|
||||
|
@ -59,10 +58,6 @@ static GdkPoint * global_pts = NULL;
|
|||
static int max_segs = 0;
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
static Argument *free_select_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
static int
|
||||
|
@ -277,7 +272,7 @@ scan_convert (GimpImage* gimage, int num_pts, FreeSelectPoint *pts,
|
|||
/*************************************/
|
||||
/* Polygonal selection apparatus */
|
||||
|
||||
static void
|
||||
void
|
||||
free_select (GImage *gimage, int num_pts, FreeSelectPoint *pts, int op,
|
||||
int antialias, int feather, double feather_radius)
|
||||
{
|
||||
|
@ -502,133 +497,3 @@ tools_free_free_select (Tool *tool)
|
|||
draw_core_free (free_sel->core);
|
||||
g_free (free_sel);
|
||||
}
|
||||
|
||||
/* The free_select procedure definition */
|
||||
ProcArg free_select_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_pts",
|
||||
"number of points (count 1 coordinate as two points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"segs",
|
||||
"array of points: { p1.x, p1.y, p2.x, p2.y, ..., pn.x, pn.y}"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing option for selections"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord free_select_proc =
|
||||
{
|
||||
"gimp_free_select",
|
||||
"Create a polygonal selection over the specified image",
|
||||
"This tool creates a polygonal selection over the specified image. The polygonal region can be either added to, subtracted from, or replace the contents of the previous selection mask. The polygon is specified through an array of floating point numbers and its length. The length of array must be 2n, where n is the number of points. Each point is defined by 2 floating point values which correspond to the x and y coordinates. If the final point does not connect to the starting point, a connecting segment is automatically added. If the feather option is enabled, the resulting selection is blurred before combining. The blur is a gaussian blur with the specified feather radius.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
free_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { free_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
free_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
int op;
|
||||
int antialias;
|
||||
int feather;
|
||||
int num_pts;
|
||||
FreeSelectPoint *pt_array;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
op = REPLACE;
|
||||
num_pts = 0;
|
||||
|
||||
/* the gimage */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if (! (gimage = gimage_get_ID (int_value)))
|
||||
success = FALSE;
|
||||
}
|
||||
/* num pts */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
if (int_value >= 2)
|
||||
num_pts = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* point array */
|
||||
if (success)
|
||||
pt_array = (FreeSelectPoint *) args[2].value.pdb_pointer;
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[6].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the free_select procedure */
|
||||
if (success)
|
||||
free_select (gimage, num_pts, pt_array,
|
||||
op, antialias, feather, feather_radius);
|
||||
|
||||
return procedural_db_return_args (&free_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
#ifndef __FREE_SELECT_H__
|
||||
#define __FREE_SELECT_H__
|
||||
|
||||
#include "procedural_db.h"
|
||||
#include "gimpimageF.h"
|
||||
|
||||
typedef struct _FreeSelectPoint FreeSelectPoint;
|
||||
|
||||
void free_select (GimpImage *, int, FreeSelectPoint *, int, int, int,
|
||||
double);
|
||||
|
||||
/* free select action functions */
|
||||
|
||||
|
@ -34,7 +39,4 @@ void free_select_draw (Tool *);
|
|||
Tool * tools_new_free_select (void);
|
||||
void tools_free_free_select (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord free_select_proc;
|
||||
|
||||
#endif /* __FREE_SELECT_H__ */
|
||||
|
|
|
@ -54,7 +54,8 @@ static SelectionOptions *fuzzy_options = NULL;
|
|||
/* XSegments which make up the fuzzy selection boundary */
|
||||
static GdkSegment *segs = NULL;
|
||||
static int num_segs = 0;
|
||||
static Channel * fuzzy_mask = NULL;
|
||||
|
||||
Channel *fuzzy_mask = NULL;
|
||||
|
||||
|
||||
/* fuzzy select action functions */
|
||||
|
@ -67,10 +68,6 @@ static void fuzzy_select_control (Tool *, int, gpointer);
|
|||
/* fuzzy select action functions */
|
||||
static GdkSegment * fuzzy_select_calculate (Tool *, void *, int *);
|
||||
|
||||
static void fuzzy_select (GImage *, GimpDrawable *,
|
||||
int, int, double);
|
||||
static Argument * fuzzy_select_invoker (Argument *);
|
||||
|
||||
|
||||
/*************************************/
|
||||
/* Fuzzy selection apparatus */
|
||||
|
@ -296,7 +293,7 @@ find_contiguous_region (GImage *gimage, GimpDrawable *drawable, int antialias,
|
|||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
fuzzy_select (GImage *gimage, GimpDrawable *drawable, int op, int feather,
|
||||
double feather_radius)
|
||||
{
|
||||
|
@ -592,167 +589,3 @@ tools_free_fuzzy_select (Tool *tool)
|
|||
draw_core_free (fuzzy_sel->core);
|
||||
g_free (fuzzy_sel);
|
||||
}
|
||||
|
||||
/* The fuzzy_select procedure definition */
|
||||
ProcArg fuzzy_select_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"x coordinate of initial seed fill point: (image coordinates)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"y coordinate of initial seed fill point: (image coordinates)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"threshold",
|
||||
"threshold in intensity levels: 0 <= threshold <= 255"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord fuzzy_select_proc =
|
||||
{
|
||||
"gimp_fuzzy_select",
|
||||
"Create a fuzzy selection starting at the specified coordinates on the specified drawable",
|
||||
"This tool creates a fuzzy selection over the specified image. A fuzzy selection is determined by a seed fill under the constraints of the specified threshold. Essentially, the color at the specified coordinates (in the drawable) is measured and the selection expands outwards from that point to any adjacent pixels which are not significantly different (as determined by the threshold value). This process continues until no more expansion is possible. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar at pixels along the seed fill boundary. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored. If the sample is merged, the specified coordinates are relative to the image origin; otherwise, they are relative to the drawable's origin.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
9,
|
||||
fuzzy_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { fuzzy_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
fuzzy_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int op;
|
||||
int threshold;
|
||||
int antialias;
|
||||
int feather;
|
||||
int sample_merged;
|
||||
double x, y;
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
drawable = NULL;
|
||||
op = REPLACE;
|
||||
threshold = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[1].value.pdb_float;
|
||||
y = args[2].value.pdb_float;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value >= 0 && int_value <= 255)
|
||||
threshold = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[7].value.pdb_float;
|
||||
}
|
||||
/* sample merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* call the fuzzy_select procedure */
|
||||
if (success)
|
||||
{
|
||||
Channel *new;
|
||||
Channel *old_fuzzy_mask;
|
||||
|
||||
new = find_contiguous_region (gimage, drawable, antialias, threshold, x, y, sample_merged);
|
||||
old_fuzzy_mask = fuzzy_mask;
|
||||
fuzzy_mask = new;
|
||||
|
||||
drawable = (sample_merged) ? NULL : drawable;
|
||||
fuzzy_select (gimage, drawable, op, feather, feather_radius);
|
||||
|
||||
fuzzy_mask = old_fuzzy_mask;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&fuzzy_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "gimage.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
|
||||
/* fuzzy select functions */
|
||||
|
@ -29,9 +28,11 @@ void tools_free_fuzzy_select (Tool *);
|
|||
|
||||
|
||||
/* functions */
|
||||
Channel * find_contiguous_region (GImage *, GimpDrawable *, int, int, int, int, int);
|
||||
Channel * find_contiguous_region (GimpImage *, GimpDrawable *, int, int,
|
||||
int, int, int);
|
||||
void fuzzy_select (GimpImage *, GimpDrawable *, int, int,
|
||||
double);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord fuzzy_select_proc;
|
||||
extern Channel *fuzzy_mask;
|
||||
|
||||
#endif /* __FUZZY_SELECT_H__ */
|
||||
|
|
|
@ -76,7 +76,6 @@ static double non_gui_pressure;
|
|||
/* forward function declarations */
|
||||
static void airbrush_motion (PaintCore *, GimpDrawable *, double);
|
||||
static gint airbrush_time_out (gpointer);
|
||||
static Argument * airbrush_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -313,108 +312,18 @@ airbrush_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The airbrush procedure definition */
|
||||
ProcArg airbrush_args[] =
|
||||
gboolean
|
||||
airbrush_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"The pressure of the airbrush strokes: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord airbrush_proc =
|
||||
{
|
||||
"gimp_airbrush",
|
||||
"Paint in the current brush with varying pressure. Paint application is time-dependent",
|
||||
"This tool simulates the use of an airbrush. Paint pressure represents the relative intensity of the paint application. High pressure results in a thicker layer of paint while low pressure results in a thinner layer.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
4,
|
||||
airbrush_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { airbrush_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
airbrush_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
non_gui_pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[3].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = airbrush_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -434,12 +343,13 @@ airbrush_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&airbrush_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
|
||||
#include "tools.h"
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean airbrush_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_airbrush (void);
|
||||
void tools_free_airbrush (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord airbrush_proc;
|
||||
|
||||
#endif /* __AIRBRUSH_H__ */
|
||||
|
|
|
@ -161,17 +161,6 @@ static void blend_motion (Tool *, GdkEventMotion *, gpointer)
|
|||
static void blend_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void blend_control (Tool *, int, gpointer);
|
||||
|
||||
static void blend (GImage *gimage, GimpDrawable *drawable,
|
||||
BlendMode blend_mode, int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity, double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
static double gradient_calc_conical_asym_factor (double dist, double *axis, double offset,
|
||||
|
@ -211,8 +200,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
||||
static Argument *blend_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -303,27 +290,27 @@ blend_options_new ()
|
|||
static MenuItem gradient_option_items[] =
|
||||
{
|
||||
{ N_("Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Linear, NULL, NULL },
|
||||
(gpointer) LINEAR, NULL, NULL },
|
||||
{ N_("Bi-Linear"), 0, 0, gradient_type_callback,
|
||||
(gpointer) BiLinear, NULL, NULL },
|
||||
(gpointer) BILINEAR, NULL, NULL },
|
||||
{ N_("Radial"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Radial, NULL, NULL },
|
||||
(gpointer) RADIAL, NULL, NULL },
|
||||
{ N_("Square"), 0, 0, gradient_type_callback,
|
||||
(gpointer) Square, NULL, NULL },
|
||||
(gpointer) SQUARE, NULL, NULL },
|
||||
{ N_("Conical (symmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalSymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_SYMMETRIC, NULL, NULL },
|
||||
{ N_("Conical (asymmetric)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ConicalAsymmetric, NULL, NULL },
|
||||
(gpointer) CONICAL_ASYMMETRIC, NULL, NULL },
|
||||
{ N_("Shapeburst (angular)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstAngular, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_ANGULAR, NULL, NULL },
|
||||
{ N_("Shapeburst (spherical)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstSpherical, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_SPHERICAL, NULL, NULL },
|
||||
{ N_("Shapeburst (dimpled)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) ShapeburstDimpled, NULL, NULL },
|
||||
(gpointer) SHAPEBURST_DIMPLED, NULL, NULL },
|
||||
{ N_("Spiral (clockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_CLOCKWISE, NULL, NULL },
|
||||
{ N_("Spiral (anticlockwise)"), 0, 0, gradient_type_callback,
|
||||
(gpointer) SpiralAntiClockwise, NULL, NULL },
|
||||
(gpointer) SPIRAL_ANTICLOCKWISE, NULL, NULL },
|
||||
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
static MenuItem repeat_option_items[] =
|
||||
|
@ -346,7 +333,7 @@ blend_options_new ()
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->offset = options->offset_d = 0.0;
|
||||
options->blend_mode = options->blend_mode_d = FG_BG_RGB_MODE;
|
||||
options->gradient_type = options->gradient_type_d = Linear;
|
||||
options->gradient_type = options->gradient_type_d = LINEAR;
|
||||
options->repeat = options->repeat_d = REPEAT_NONE;
|
||||
options->supersample = options->supersample_d = FALSE;
|
||||
options->max_depth = options->max_depth_d = 3;
|
||||
|
@ -821,7 +808,7 @@ blend_control (Tool *tool,
|
|||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
|
@ -1317,54 +1304,54 @@ gradient_render_pixel(double x, double y, color_t *color, void *render_data)
|
|||
|
||||
switch (rbd->gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
factor = gradient_calc_radial_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case CONICAL_SYMMETRIC:
|
||||
factor = gradient_calc_conical_sym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ConicalAsymmetric:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
factor = gradient_calc_conical_asym_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
factor = gradient_calc_square_factor(rbd->dist, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case Linear:
|
||||
case LINEAR:
|
||||
factor = gradient_calc_linear_factor(rbd->dist, rbd->vec,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case BiLinear:
|
||||
case BILINEAR:
|
||||
factor = gradient_calc_bilinear_factor(rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy);
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
factor = gradient_calc_shapeburst_angular_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstSpherical:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
factor = gradient_calc_shapeburst_spherical_factor(x, y);
|
||||
break;
|
||||
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
factor = gradient_calc_shapeburst_dimpled_factor(x, y);
|
||||
break;
|
||||
|
||||
case SpiralClockwise:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,TRUE);
|
||||
break;
|
||||
|
||||
case SpiralAntiClockwise:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
factor = gradient_calc_spiral_factor (rbd->dist, rbd->vec, rbd->offset,
|
||||
x - rbd->sx, y - rbd->sy,FALSE);
|
||||
break;
|
||||
|
@ -1514,20 +1501,20 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
switch (gradient_type)
|
||||
{
|
||||
case Radial:
|
||||
case RADIAL:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
break;
|
||||
|
||||
case Square:
|
||||
case SQUARE:
|
||||
rbd.dist = MAXIMUM(fabs(ex - sx), fabs(ey - sy));
|
||||
break;
|
||||
|
||||
case ConicalSymmetric:
|
||||
case ConicalAsymmetric:
|
||||
case SpiralClockwise:
|
||||
case SpiralAntiClockwise:
|
||||
case Linear:
|
||||
case BiLinear:
|
||||
case CONICAL_SYMMETRIC:
|
||||
case CONICAL_ASYMMETRIC:
|
||||
case SPIRAL_CLOCKWISE:
|
||||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
|
@ -1538,9 +1525,9 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
break;
|
||||
|
||||
case ShapeburstAngular:
|
||||
case ShapeburstSpherical:
|
||||
case ShapeburstDimpled:
|
||||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
@ -1843,232 +1830,3 @@ tools_free_blend (Tool *tool)
|
|||
|
||||
g_free (blend_tool);
|
||||
}
|
||||
|
||||
|
||||
/* The blend procedure definition */
|
||||
ProcArg blend_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"blend_mode",
|
||||
"The type of blend: { FG-BG-RGB (0), FG-BG-HSV (1), FG-TRANS (2), CUSTOM (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"gradient_type",
|
||||
"The type of gradient: { LINEAR (0), BILINEAR (1), RADIAL (2), SQUARE (3), CONICAL-SYMMETRIC (4), CONICAL-ASYMMETRIC (5), SHAPEBURST-ANGULAR (6), SHAPEBURST-SPHERICAL (7), SHAPEBURST-DIMPLED (8), SPIRAL-CLOCKWISE(9), SPRIAL-ANTICLOCKWISE(10) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"The opacity of the final blend (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"offset",
|
||||
"Offset relates to the starting and ending coordinates specified for the blend. This parameter is mode depndent (0 <= offset)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"repeat",
|
||||
"Repeat mode: { REPEAT-NONE (0), REPEAT-SAWTOOTH (1), REPEAT-TRIANGULAR (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"supersample",
|
||||
"Do adaptive supersampling (true / false)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"max_depth",
|
||||
"Maximum recursion levels for supersampling"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"Supersampling threshold"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x1",
|
||||
"The x coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y1",
|
||||
"The y coordinate of this blend's starting point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x2",
|
||||
"The x coordinate of this blend's ending point"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y2",
|
||||
"The y coordinate of this blend's ending point"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord blend_proc =
|
||||
{
|
||||
"gimp_blend",
|
||||
"Blend between the starting and ending coordinates with the specified blend mode and gradient type.",
|
||||
"This tool requires information on the paint application mode, the blend mode, and the gradient type. It creates the specified variety of blend using the starting and ending coordinates as defined for each gradient type.",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"Spencer Kimball & Peter Mattis & Federico Mena Quintero",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
14,
|
||||
blend_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { blend_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
blend_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
BlendMode blend_mode;
|
||||
int paint_mode;
|
||||
GradientType gradient_type;
|
||||
double opacity;
|
||||
double offset;
|
||||
RepeatMode repeat;
|
||||
int supersample;
|
||||
int max_depth;
|
||||
double threshold;
|
||||
double x1, y1;
|
||||
double x2, y2;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
blend_mode = FG_BG_RGB_MODE;
|
||||
paint_mode = NORMAL_MODE;
|
||||
gradient_type = Linear;
|
||||
opacity = 100.0;
|
||||
offset = 0.0;
|
||||
repeat = REPEAT_NONE;
|
||||
supersample = FALSE;
|
||||
max_depth = 0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* blend mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < BLEND_MODE_LAST)
|
||||
blend_mode = (BlendMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= DIVIDE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* gradient type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < GradientTypeLast)
|
||||
gradient_type = (GradientType) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* offset */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[5].value.pdb_float;
|
||||
if (fp_value >= 0.0)
|
||||
offset = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* repeat */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[6].value.pdb_int;
|
||||
|
||||
if (int_value >= 0 && int_value < REPEAT_LAST)
|
||||
repeat = (RepeatMode) int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* supersampling */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
|
||||
supersample = (int_value ? TRUE : FALSE);
|
||||
}
|
||||
/* max_depth */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[8].value.pdb_int;
|
||||
|
||||
if (((int_value >= 1) && (int_value <= 9)) || !supersample)
|
||||
max_depth = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[9].value.pdb_float;
|
||||
|
||||
if (((fp_value >= 0.0) && (fp_value <= 4.0)) || !supersample)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* x1, y1, x2, y2 */
|
||||
if (success)
|
||||
{
|
||||
x1 = args[10].value.pdb_float;
|
||||
y1 = args[11].value.pdb_float;
|
||||
x2 = args[12].value.pdb_float;
|
||||
y2 = args[13].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,26 +18,28 @@
|
|||
#ifndef __BLEND_H__
|
||||
#define __BLEND_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Linear,
|
||||
BiLinear,
|
||||
Radial,
|
||||
Square,
|
||||
ConicalSymmetric,
|
||||
ConicalAsymmetric,
|
||||
ShapeburstAngular,
|
||||
ShapeburstSpherical,
|
||||
ShapeburstDimpled,
|
||||
SpiralClockwise,
|
||||
SpiralAntiClockwise,
|
||||
GradientTypeLast /*< skip >*/
|
||||
LINEAR,
|
||||
BILINEAR,
|
||||
RADIAL,
|
||||
SQUARE,
|
||||
CONICAL_SYMMETRIC,
|
||||
CONICAL_ASYMMETRIC,
|
||||
SHAPEBURST_ANGULAR,
|
||||
SHAPEBURST_SPHERICAL,
|
||||
SHAPEBURST_DIMPLED,
|
||||
SPIRAL_CLOCKWISE,
|
||||
SPIRAL_ANTICLOCKWISE,
|
||||
GRADIENT_TYPE_LAST /*< skip >*/
|
||||
} GradientType;
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_MODE >*/
|
||||
{
|
||||
FG_BG_RGB_MODE,
|
||||
FG_BG_HSV_MODE,
|
||||
|
@ -54,10 +56,11 @@ typedef enum
|
|||
REPEAT_LAST /*< skip >*/
|
||||
} RepeatMode;
|
||||
|
||||
void blend (GimpImage *, GimpDrawable *, BlendMode, int, GradientType,
|
||||
double, double, RepeatMode, int, int, double, double,
|
||||
double, double, double, progress_func_t, void *);
|
||||
|
||||
Tool * tools_new_blend (void);
|
||||
void tools_free_blend (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord blend_proc;
|
||||
|
||||
#endif /* __BLEND_H__ */
|
||||
|
|
|
@ -47,27 +47,27 @@ struct _BucketTool
|
|||
typedef struct _BucketOptions BucketOptions;
|
||||
struct _BucketOptions
|
||||
{
|
||||
ToolOptions tool_options;
|
||||
ToolOptions tool_options;
|
||||
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
double opacity;
|
||||
double opacity_d;
|
||||
GtkObject *opacity_w;
|
||||
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
int paint_mode;
|
||||
int paint_mode_d;
|
||||
GtkWidget *paint_mode_w;
|
||||
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
double threshold;
|
||||
double threshold_d;
|
||||
GtkObject *threshold_w;
|
||||
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
int sample_merged;
|
||||
int sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
|
||||
FillMode fill_mode;
|
||||
FillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
BucketFillMode fill_mode;
|
||||
BucketFillMode fill_mode_d;
|
||||
GtkWidget *fill_mode_w[2]; /* 2 radio buttons */
|
||||
};
|
||||
|
||||
|
||||
|
@ -82,11 +82,7 @@ static void bucket_fill_motion (Tool *, GdkEventMotion *, gpointer);
|
|||
static void bucket_fill_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
||||
static void bucket_fill_control (Tool *, int, gpointer);
|
||||
|
||||
static void bucket_fill (GImage *, GimpDrawable *, FillMode,
|
||||
int, double, double,
|
||||
int, double, double);
|
||||
|
||||
static void bucket_fill_region (FillMode, PixelRegion *, PixelRegion *,
|
||||
static void bucket_fill_region (BucketFillMode, PixelRegion *, PixelRegion *,
|
||||
unsigned char *, TempBuf *,
|
||||
int, int, int);
|
||||
static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
||||
|
@ -94,8 +90,6 @@ static void bucket_fill_line_color (unsigned char *, unsigned char *,
|
|||
static void bucket_fill_line_pattern (unsigned char *, unsigned char *,
|
||||
TempBuf *, int, int, int, int, int);
|
||||
|
||||
static Argument *bucket_fill_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -103,7 +97,7 @@ static void
|
|||
bucket_fill_mode_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
bucket_options->fill_mode = (FillMode) client_data;
|
||||
bucket_options->fill_mode = (BucketFillMode) client_data;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -128,7 +122,7 @@ bucket_options_reset (void)
|
|||
options->sample_merged_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->threshold_w),
|
||||
options->threshold_d);
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FgColorFill) ?
|
||||
gtk_toggle_button_set_active (((options->fill_mode_d == FG_BUCKET_FILL) ?
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->fill_mode_w[1])),
|
||||
TRUE);
|
||||
|
@ -168,7 +162,7 @@ bucket_options_new (void)
|
|||
options->paint_mode = options->paint_mode_d = NORMAL;
|
||||
options->sample_merged = options->sample_merged_d = FALSE;
|
||||
options->threshold = options->threshold_d = 15.0;
|
||||
options->fill_mode = options->fill_mode_d = FgColorFill;
|
||||
options->fill_mode = options->fill_mode_d = FG_BUCKET_FILL;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = options->tool_options.main_vbox;
|
||||
|
@ -269,7 +263,7 @@ bucket_options_new (void)
|
|||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
|
||||
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
|
||||
(GtkSignalFunc) bucket_fill_mode_callback,
|
||||
(gpointer) ((long) (i == 1 ? PatternFill : FgColorFill))); /* kludgy */
|
||||
(gpointer) ((long) (i == 1 ? PATTERN_BUCKET_FILL : FG_BUCKET_FILL))); /* kludgy */
|
||||
gtk_box_pack_start (GTK_BOX (radio_box), radio_button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (radio_button);
|
||||
|
||||
|
@ -318,7 +312,7 @@ bucket_fill_button_release (Tool *tool,
|
|||
{
|
||||
GDisplay * gdisp;
|
||||
BucketTool * bucket_tool;
|
||||
FillMode fill_mode;
|
||||
BucketFillMode fill_mode;
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
|
||||
|
@ -334,8 +328,8 @@ bucket_fill_button_release (Tool *tool,
|
|||
fill_mode = bucket_options->fill_mode;
|
||||
|
||||
/* If the mode is color filling, and shift mask is down, fill with background */
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FgColorFill)
|
||||
fill_mode = BgColorFill;
|
||||
if (bevent->state & GDK_SHIFT_MASK && fill_mode == FG_BUCKET_FILL)
|
||||
fill_mode = BG_BUCKET_FILL;
|
||||
|
||||
return_vals = procedural_db_run_proc ("gimp_bucket_fill",
|
||||
&nreturn_vals,
|
||||
|
@ -411,16 +405,16 @@ bucket_fill_control (Tool *tool,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
bucket_fill (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
FillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
void
|
||||
bucket_fill (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BucketFillMode fill_mode,
|
||||
int paint_mode,
|
||||
double opacity,
|
||||
double threshold,
|
||||
int sample_merged,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR, maskPR;
|
||||
|
@ -435,11 +429,11 @@ bucket_fill (GImage *gimage,
|
|||
|
||||
pat_buf = NULL;
|
||||
|
||||
if (fill_mode == FgColorFill)
|
||||
if (fill_mode == FG_BUCKET_FILL)
|
||||
gimage_get_foreground (gimage, drawable, col);
|
||||
else if (fill_mode == BgColorFill)
|
||||
else if (fill_mode == BG_BUCKET_FILL)
|
||||
gimage_get_background (gimage, drawable, col);
|
||||
else if (fill_mode == PatternFill)
|
||||
else if (fill_mode == PATTERN_BUCKET_FILL)
|
||||
{
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
|
@ -629,14 +623,14 @@ bucket_fill_line_pattern (unsigned char *buf,
|
|||
|
||||
|
||||
static void
|
||||
bucket_fill_region (FillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
bucket_fill_region (BucketFillMode fill_mode,
|
||||
PixelRegion *bufPR,
|
||||
PixelRegion *maskPR,
|
||||
unsigned char *col,
|
||||
TempBuf *pattern,
|
||||
int off_x,
|
||||
int off_y,
|
||||
int has_alpha)
|
||||
{
|
||||
unsigned char *s, *m;
|
||||
int y;
|
||||
|
@ -654,11 +648,11 @@ bucket_fill_region (FillMode fill_mode,
|
|||
{
|
||||
switch (fill_mode)
|
||||
{
|
||||
case FgColorFill:
|
||||
case BgColorFill:
|
||||
case FG_BUCKET_FILL:
|
||||
case BG_BUCKET_FILL:
|
||||
bucket_fill_line_color (s, m, col, has_alpha, bufPR->bytes, bufPR->w);
|
||||
break;
|
||||
case PatternFill:
|
||||
case PATTERN_BUCKET_FILL:
|
||||
bucket_fill_line_pattern (s, m, pattern, has_alpha, bufPR->bytes,
|
||||
off_x + bufPR->x, off_y + y + bufPR->y, bufPR->w);
|
||||
break;
|
||||
|
@ -722,158 +716,3 @@ tools_free_bucket_fill (Tool *tool)
|
|||
|
||||
g_free (bucket_tool);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* The bucket fill procedure definition */
|
||||
ProcArg bucket_fill_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the affected drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"fill_mode",
|
||||
"the type of fill: { FG-BUCKET-FILL (0), BG-BUCKET-FILL (1), PATTERN-BUCKET-FILL (2) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"paint_mode",
|
||||
"the paint application mode: { NORMAL (0), DISSOLVE (1), BEHIND (2), MULTIPLY/BURN (3), SCREEN (4), OVERLAY (5) DIFFERENCE (6), ADDITION (7), SUBTRACT (8), DARKEN-ONLY (9), LIGHTEN-ONLY (10), HUE (11), SATURATION (12), COLOR (13), VALUE (14), DIVIDE/DODGE (15) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"opacity",
|
||||
"the opacity of the final bucket fill (0 <= opacity <= 100)"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"threshold",
|
||||
"the threshold determines how extensive the seed fill will be. It's value is specified in terms of intensity levels (0 <= threshold <= 255). This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"x",
|
||||
"the x coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"y",
|
||||
"the y coordinate of this bucket fill's application. This parameter is only valid when there is no selection in the specified image."
|
||||
},
|
||||
};
|
||||
|
||||
ProcRecord bucket_fill_proc =
|
||||
{
|
||||
"gimp_bucket_fill",
|
||||
"Fill the area specified either by the current selection if there is one, or by a seed fill starting at the specified coordinates.",
|
||||
"This tool requires information on the paint application mode, and the fill mode, which can either be in the foreground color, or in the currently active pattern. If there is no selection, a seed fill is executed at the specified coordinates and extends outward in keeping with the threshold parameter. If there is a selection in the target image, the threshold, sample merged, x, and y arguments are unused. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of merged sampling, the x,y coordinates are relative to the image's origin; otherwise, they are relative to the drawable's origin.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
bucket_fill_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { bucket_fill_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
bucket_fill_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
FillMode fill_mode;
|
||||
int paint_mode;
|
||||
double opacity;
|
||||
double threshold;
|
||||
int sample_merged;
|
||||
double x, y;
|
||||
int int_value;
|
||||
double fp_value;
|
||||
|
||||
drawable = NULL;
|
||||
fill_mode = BgColorFill;
|
||||
paint_mode = NORMAL_MODE;
|
||||
opacity = 100.0;
|
||||
threshold = 0.0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* fill mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: fill_mode = FgColorFill; break;
|
||||
case 1: fill_mode = BgColorFill; break;
|
||||
case 2: fill_mode = PatternFill; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* paint mode */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= NORMAL_MODE && int_value <= VALUE_MODE)
|
||||
paint_mode = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* opacity */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[3].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
opacity = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[4].value.pdb_float;
|
||||
if (fp_value >= 0.0 && fp_value <= 255.0)
|
||||
threshold = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* sample_merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* x, y */
|
||||
if (success)
|
||||
{
|
||||
x = args[6].value.pdb_float;
|
||||
y = args[7].value.pdb_float;
|
||||
}
|
||||
|
||||
/* call the blend procedure */
|
||||
if (success)
|
||||
{
|
||||
bucket_fill (gimage, drawable, fill_mode, paint_mode,
|
||||
opacity, threshold, sample_merged, x, y);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&bucket_fill_proc, success);
|
||||
}
|
||||
|
|
|
@ -18,20 +18,21 @@
|
|||
#ifndef __BUCKET_FILL_H__
|
||||
#define __BUCKET_FILL_H__
|
||||
|
||||
#include "gimpimageF.h"
|
||||
#include "gimpdrawableF.h"
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FgColorFill,
|
||||
BgColorFill,
|
||||
PatternFill
|
||||
} FillMode;
|
||||
FG_BUCKET_FILL,
|
||||
BG_BUCKET_FILL,
|
||||
PATTERN_BUCKET_FILL
|
||||
} BucketFillMode;
|
||||
|
||||
void bucket_fill (GimpImage *, GimpDrawable *, BucketFillMode, int,
|
||||
double, double, int, double, double);
|
||||
|
||||
Tool * tools_new_bucket_fill (void);
|
||||
void tools_free_bucket_fill (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord bucket_fill_proc;
|
||||
|
||||
#endif /* __BUCKET_FILL_H__ */
|
||||
|
|
|
@ -90,9 +90,6 @@ static void by_color_select_preview_button_press (ByColorDialog *, G
|
|||
|
||||
static int is_pixel_sufficiently_different (unsigned char *, unsigned char *, int, int, int, int);
|
||||
static Channel * by_color_select_color (GImage *, GimpDrawable *, unsigned char *, int, int, int);
|
||||
static void by_color_select (GImage *, GimpDrawable *, unsigned char *, int, int, int, int, double, int);
|
||||
static Argument * by_color_select_invoker (Argument *);
|
||||
|
||||
|
||||
/* by_color selection machinery */
|
||||
|
||||
|
@ -243,7 +240,7 @@ by_color_select_color (GImage *gimage,
|
|||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
by_color_select (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
unsigned char *color,
|
||||
|
@ -972,157 +969,3 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
by_color_select_render (bcd, bcd->gimage);
|
||||
by_color_select_draw (bcd, bcd->gimage);
|
||||
}
|
||||
|
||||
|
||||
/* The by_color_select procedure definition */
|
||||
ProcArg by_color_select_args[] =
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_COLOR,
|
||||
"color",
|
||||
"the color to select"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"threshold",
|
||||
"threshold in intensity levels: 0 <= threshold <= 255"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"operation",
|
||||
"the selection operation: { ADD (0), SUB (1), REPLACE (2), INTERSECT (3) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"antialias",
|
||||
"antialiasing On/Off"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"feather",
|
||||
"feather option for selections"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"feather_radius",
|
||||
"radius for feather operation"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"sample_merged",
|
||||
"use the composite image, not the drawable"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord by_color_select_proc =
|
||||
{
|
||||
"gimp_by_color_select",
|
||||
"Create a selection by selecting all pixels (in the specified drawable) with the same (or similar) color to that specified.",
|
||||
"This tool creates a selection over the specified image. A by-color selection is determined by the supplied color under the constraints of the specified threshold. Essentially, all pixels (in the drawable) that have color sufficiently close to the specified color (as determined by the threshold value) are included in the selection. The antialiasing parameter allows the final selection mask to contain intermediate values based on close misses to the threshold bar. Feathering can be enabled optionally and is controlled with the \"feather_radius\" paramter. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
8,
|
||||
by_color_select_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { by_color_select_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
by_color_select_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
int op;
|
||||
int threshold;
|
||||
int antialias;
|
||||
int feather;
|
||||
int sample_merged;
|
||||
unsigned char color[3];
|
||||
double feather_radius;
|
||||
int int_value;
|
||||
|
||||
drawable = NULL;
|
||||
op = REPLACE;
|
||||
threshold = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* color */
|
||||
if (success)
|
||||
{
|
||||
int i;
|
||||
unsigned char *color_array;
|
||||
|
||||
color_array = (unsigned char *) args[1].value.pdb_pointer;
|
||||
for (i = 0; i < 3; i++)
|
||||
color[i] = color_array[i];
|
||||
}
|
||||
/* threshold */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
if (int_value >= 0 && int_value <= 255)
|
||||
threshold = int_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* operation */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: op = ADD; break;
|
||||
case 1: op = SUB; break;
|
||||
case 2: op = REPLACE; break;
|
||||
case 3: op = INTERSECT; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* antialiasing? */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[4].value.pdb_int;
|
||||
antialias = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feathering */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
feather = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
/* feather radius */
|
||||
if (success)
|
||||
{
|
||||
feather_radius = args[6].value.pdb_float;
|
||||
}
|
||||
/* sample merged */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[7].value.pdb_int;
|
||||
sample_merged = (int_value) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/* call the ellipse_select procedure */
|
||||
if (success)
|
||||
by_color_select (gimage, drawable, color, threshold, op,
|
||||
antialias, feather, feather_radius, sample_merged);
|
||||
|
||||
return procedural_db_return_args (&by_color_select_proc, success);
|
||||
}
|
||||
|
|
|
@ -19,18 +19,17 @@
|
|||
#define __BY_COLOR_SELECT_H__
|
||||
|
||||
#include "tools.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gdisplayF.h"
|
||||
#include "gimage.h"
|
||||
|
||||
/* by_color select functions */
|
||||
void by_color_select (GimpImage *, GimpDrawable *, guchar *, int,
|
||||
int, int, int, double, int);
|
||||
|
||||
Tool * tools_new_by_color_select (void);
|
||||
void tools_free_by_color_select (Tool *);
|
||||
|
||||
void by_color_select_initialize (GDisplay *);
|
||||
void by_color_select_initialize_by_image (GImage *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord by_color_select_proc;
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
|
@ -89,8 +89,6 @@ static void clone_line_image (GImage *, GImage *, GimpDrawable *, GimpD
|
|||
static void clone_line_pattern (GImage *, GimpDrawable *, GPatternP, unsigned char *,
|
||||
int, int, int, int);
|
||||
|
||||
static Argument * clone_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
|
@ -146,7 +144,7 @@ clone_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Clone Tool Options"),
|
||||
clone_options_reset);
|
||||
options->type = options->type_d = ImageClone;
|
||||
options->type = options->type_d = IMAGE_CLONE;
|
||||
options->aligned = options->aligned_d = AlignNo;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -303,7 +301,7 @@ clone_paint_func (PaintCore *paint_core,
|
|||
orig_src_x = src_x;
|
||||
orig_src_y = src_y;
|
||||
}
|
||||
if (clone_options->type == PatternClone)
|
||||
if (clone_options->type == PATTERN_CLONE)
|
||||
if (!get_active_pattern ())
|
||||
g_message (_("No patterns available for this operation."));
|
||||
break;
|
||||
|
@ -382,7 +380,7 @@ clone_draw (Tool *tool)
|
|||
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
if (clone_options->type == ImageClone)
|
||||
if (clone_options->type == IMAGE_CLONE)
|
||||
{
|
||||
gdk_draw_line (paint_core->core->win, paint_core->core->gc,
|
||||
trans_tx - (TARGET_WIDTH >> 1), trans_ty,
|
||||
|
@ -418,7 +416,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pattern = NULL;
|
||||
|
||||
/* Make sure we still have a source if we are doing image cloning */
|
||||
if (type == ImageClone)
|
||||
if (type == IMAGE_CLONE)
|
||||
{
|
||||
if (!src_drawable)
|
||||
return;
|
||||
|
@ -438,7 +436,7 @@ clone_motion (PaintCore *paint_core,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
/* Set the paint area to transparent */
|
||||
memset (temp_buf_data (area), 0, area->width * area->height * area->bytes);
|
||||
|
||||
|
@ -500,7 +498,7 @@ clone_motion (PaintCore *paint_core,
|
|||
pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
break;
|
||||
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
pattern = get_active_pattern ();
|
||||
|
||||
if (!pattern)
|
||||
|
@ -525,12 +523,12 @@ clone_motion (PaintCore *paint_core,
|
|||
{
|
||||
switch (type)
|
||||
{
|
||||
case ImageClone:
|
||||
case IMAGE_CLONE:
|
||||
clone_line_image (gimage, src_gimage, drawable, src_drawable, s, d,
|
||||
has_alpha, srcPR.bytes, destPR.bytes, destPR.w);
|
||||
s += srcPR.rowstride;
|
||||
break;
|
||||
case PatternClone:
|
||||
case PATTERN_CLONE:
|
||||
clone_line_pattern (gimage, drawable, pattern, d,
|
||||
area->x + offset_x, area->y + y + offset_y,
|
||||
destPR.bytes, destPR.w);
|
||||
|
@ -630,141 +628,25 @@ clone_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The clone procedure definition */
|
||||
ProcArg clone_args[] =
|
||||
gboolean
|
||||
clone_non_gui (GimpDrawable *drawable,
|
||||
GimpDrawable *src_drawable,
|
||||
CloneType clone_type,
|
||||
double src_x,
|
||||
double src_y,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_DRAWABLE,
|
||||
"src_drawable",
|
||||
"the source drawable"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"clone_type",
|
||||
"the type of clone: { IMAGE-CLONE (0), PATTERN-CLONE (1) }"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_x",
|
||||
"the x coordinate in the source image"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"src_y",
|
||||
"the y coordinate in the source image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord clone_proc =
|
||||
{
|
||||
"gimp_clone",
|
||||
"Clone from the source to the dest drawable using the current brush",
|
||||
"This tool clones (copies) from the source drawable starting at the specified source coordinates to the dest drawable. If the \"clone_type\" argument is set to PATTERN-CLONE, then the current pattern is used as the source and the \"src_drawable\" argument is ignored. Pattern cloning assumes a tileable pattern and mods the sum of the src coordinates and subsequent stroke offsets with the width and height of the pattern. For image cloning, if the sum of the src coordinates and subsequent stroke offsets exceeds the extents of the src drawable, then no paint is transferred. The clone tool is capable of transforming between any image types including RGB->Indexed--although converting from any type to indexed is significantly slower.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
7,
|
||||
clone_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { clone_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
clone_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GimpDrawable *src_drawable;
|
||||
double src_x, src_y;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
int int_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the src drawable */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[1].value.pdb_int;
|
||||
src_drawable = drawable_get_ID (int_value);
|
||||
if (src_drawable == NULL || gimage != drawable_gimage (src_drawable))
|
||||
success = FALSE;
|
||||
else
|
||||
non_gui_src_drawable = src_drawable;
|
||||
}
|
||||
/* the clone type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: non_gui_type = ImageClone; break;
|
||||
case 1: non_gui_type = PatternClone; break;
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* x, y offsets */
|
||||
if (success)
|
||||
{
|
||||
src_x = args[3].value.pdb_float;
|
||||
src_y = args[4].value.pdb_float;
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[5].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[6].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = clone_non_gui_paint_func;
|
||||
|
||||
non_gui_src_drawable = src_drawable;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
|
||||
|
||||
|
@ -785,12 +667,13 @@ clone_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&clone_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,18 @@
|
|||
#define __CLONE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ImageClone,
|
||||
PatternClone
|
||||
IMAGE_CLONE,
|
||||
PATTERN_CLONE
|
||||
} CloneType;
|
||||
|
||||
void * clone_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean clone_non_gui (GimpDrawable *, GimpDrawable *, CloneType,
|
||||
double, double, int, double *);
|
||||
Tool * tools_new_clone (void);
|
||||
void tools_free_clone (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord clone_proc;
|
||||
|
||||
#endif /* __CLONE_H__ */
|
||||
|
|
|
@ -98,7 +98,6 @@ static void copy_matrix (float *, float *, int);
|
|||
static int sum_matrix (int *, int);
|
||||
|
||||
static void convolve_motion (PaintCore *, GimpDrawable *);
|
||||
static Argument * convolve_invoker (Argument *);
|
||||
|
||||
|
||||
/* functions */
|
||||
|
@ -147,7 +146,7 @@ convolve_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
_("Convolver Options"),
|
||||
convolve_options_reset);
|
||||
options->type = options->type_d = Blur;
|
||||
options->type = options->type_d = BLUR_CONVOLVE;
|
||||
options->pressure = options->pressure_d = 50.0;
|
||||
|
||||
/* the main vbox */
|
||||
|
@ -364,19 +363,19 @@ calculate_matrix (ConvolveType type,
|
|||
/* get the appropriate convolution matrix and size and divisor */
|
||||
switch (type)
|
||||
{
|
||||
case Blur:
|
||||
case BLUR_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
blur_matrix [12] = MIN_BLUR + percent * (MAX_BLUR - MIN_BLUR);
|
||||
copy_matrix (blur_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Sharpen:
|
||||
case SHARPEN_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
sharpen_matrix [12] = MIN_SHARPEN + percent * (MAX_SHARPEN - MIN_SHARPEN);
|
||||
copy_matrix (sharpen_matrix, custom_matrix, matrix_size);
|
||||
break;
|
||||
|
||||
case Custom:
|
||||
case CUSTOM_CONVOLVE:
|
||||
matrix_size = 5;
|
||||
break;
|
||||
}
|
||||
|
@ -437,128 +436,18 @@ convolve_non_gui_paint_func (PaintCore *paint_core,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* The convolve procedure definition */
|
||||
ProcArg convolve_args[] =
|
||||
gboolean
|
||||
convolve_non_gui (GimpDrawable *drawable,
|
||||
double pressure,
|
||||
int num_strokes,
|
||||
double *stroke_array)
|
||||
{
|
||||
{ PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"the drawable"
|
||||
},
|
||||
{ PDB_FLOAT,
|
||||
"pressure",
|
||||
"the pressure: 0 <= pressure <= 100"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"convolve_type",
|
||||
"convolve type: { BLUR (0), SHARPEN (1) }"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"num_strokes",
|
||||
"number of stroke control points (count each coordinate as 2 points)"
|
||||
},
|
||||
{ PDB_FLOATARRAY,
|
||||
"strokes",
|
||||
"array of stroke coordinates: {s1.x, s1.y, s2.x, s2.y, ..., sn.x, sn.y}"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ProcRecord convolve_proc =
|
||||
{
|
||||
"gimp_convolve",
|
||||
"Convolve (Blur, Sharpen) using the current brush",
|
||||
"This tool convolves the specified drawable with either a sharpening or blurring kernel. The pressure parameter controls the magnitude of the operation. Like the paintbrush, this tool linearly interpolates between the specified stroke coordinates.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
convolve_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { convolve_invoker } },
|
||||
};
|
||||
|
||||
|
||||
static Argument *
|
||||
convolve_invoker (Argument *args)
|
||||
{
|
||||
int success = TRUE;
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
double pressure;
|
||||
ConvolveType type;
|
||||
int num_strokes;
|
||||
double *stroke_array;
|
||||
ConvolveType int_value;
|
||||
double fp_value;
|
||||
int i;
|
||||
|
||||
drawable = NULL;
|
||||
pressure = 100.0;
|
||||
type = Blur;
|
||||
num_strokes = 0;
|
||||
|
||||
/* the drawable */
|
||||
if (success)
|
||||
if (paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]))
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
drawable = drawable_get_ID (int_value);
|
||||
if (drawable == NULL)
|
||||
success = FALSE;
|
||||
else
|
||||
gimage = drawable_gimage (drawable);
|
||||
}
|
||||
/* the pressure */
|
||||
if (success)
|
||||
{
|
||||
fp_value = args[1].value.pdb_int;
|
||||
if (fp_value >= 0.0 && fp_value <= 100.0)
|
||||
pressure = fp_value;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
/* the convolve type */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[2].value.pdb_int;
|
||||
switch (int_value)
|
||||
{
|
||||
case 0: type = Blur; break;
|
||||
case 1: type = Sharpen; break;
|
||||
case 2: success = FALSE; break; /*type = Custom; break;*/
|
||||
default: success = FALSE;
|
||||
}
|
||||
}
|
||||
/* num strokes */
|
||||
if (success)
|
||||
{
|
||||
int_value = args[3].value.pdb_int;
|
||||
if (int_value > 0)
|
||||
num_strokes = int_value / 2;
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
/* point array */
|
||||
if (success)
|
||||
stroke_array = (double *) args[4].value.pdb_pointer;
|
||||
|
||||
if (success)
|
||||
/* init the paint core */
|
||||
success = paint_core_init (&non_gui_paint_core, drawable,
|
||||
stroke_array[0], stroke_array[1]);
|
||||
|
||||
if (success)
|
||||
{
|
||||
/* set the paint core's paint func */
|
||||
/* Set the paint core's paint func */
|
||||
non_gui_paint_core.paint_func = convolve_non_gui_paint_func;
|
||||
|
||||
non_gui_paint_core.startx = non_gui_paint_core.lastx = stroke_array[0];
|
||||
|
@ -578,12 +467,13 @@ convolve_invoker (Argument *args)
|
|||
non_gui_paint_core.lasty = non_gui_paint_core.cury;
|
||||
}
|
||||
|
||||
/* finish the painting */
|
||||
/* Finish the painting */
|
||||
paint_core_finish (&non_gui_paint_core, drawable, -1);
|
||||
|
||||
/* cleanup */
|
||||
/* Cleanup */
|
||||
paint_core_cleanup ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&convolve_proc, success);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -19,21 +19,18 @@
|
|||
#define __CONVOLVE_H__
|
||||
|
||||
#include "paint_core.h"
|
||||
#include "procedural_db.h"
|
||||
#include "tools.h"
|
||||
|
||||
typedef enum
|
||||
typedef enum /*< chop=_CONVOLVE >*/
|
||||
{
|
||||
Blur,
|
||||
Sharpen,
|
||||
Custom
|
||||
BLUR_CONVOLVE,
|
||||
SHARPEN_CONVOLVE,
|
||||
CUSTOM_CONVOLVE
|
||||
} ConvolveType;
|
||||
|
||||
void * convolve_paint_func (PaintCore *, GimpDrawable *, int);
|
||||
gboolean convolve_non_gui (GimpDrawable *, double, int, double *);
|
||||
Tool * tools_new_convolve (void);
|
||||
void tools_free_convolve (Tool *);
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord convolve_proc;
|
||||
|
||||
#endif /* __CONVOLVE_H__ */
|
||||
|
|
|
@ -110,8 +110,6 @@ static void crop_control (Tool *, int, gpointer);
|
|||
static void crop_arrow_keys_func (Tool *, GdkEventKey *, gpointer);
|
||||
|
||||
/* Crop helper functions */
|
||||
static void crop_image (GImage *gimage,
|
||||
int, int, int, int, int, int);
|
||||
static void crop_recalc (Tool *, Crop *);
|
||||
static void crop_start (Tool *, Crop *);
|
||||
static void crop_adjust_guides (GImage *, int, int, int, int);
|
||||
|
@ -143,8 +141,6 @@ static int crop_colors_alpha (guchar *, guchar *, int);
|
|||
static void crop_orig_changed (GtkWidget *, gpointer);
|
||||
static void crop_size_changed (GtkWidget *, gpointer);
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
|
@ -837,7 +833,7 @@ tools_free_crop (Tool *tool)
|
|||
g_free (crop);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
crop_image (GImage *gimage,
|
||||
int x1,
|
||||
int y1,
|
||||
|
@ -1548,101 +1544,3 @@ crop_size_changed (GtkWidget *w,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The procedure definition */
|
||||
ProcArg crop_args[] =
|
||||
{
|
||||
{ PDB_IMAGE,
|
||||
"image",
|
||||
"the image"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_width",
|
||||
"new image width: (0 < new_width <= width)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"new_height",
|
||||
"new image height: (0 < new_height <= height)"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offx",
|
||||
"x offset: (0 <= offx <= (width - new_width))"
|
||||
},
|
||||
{ PDB_INT32,
|
||||
"offy",
|
||||
"y offset: (0 <= offy <= (height - new_height))"
|
||||
}
|
||||
};
|
||||
|
||||
ProcRecord crop_proc =
|
||||
{
|
||||
"gimp_crop",
|
||||
"Crop the image to the specified extents.",
|
||||
"This procedure crops the image so that it's new width and height are equal to the supplied parameters. Offsets are also provided which describe the position of the previous image's content. All channels and layers within the image are cropped to the new image extents; this includes the image selection mask. If any parameters are out of range, an error is returned.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
PDB_INTERNAL,
|
||||
|
||||
/* Input arguments */
|
||||
5,
|
||||
crop_args,
|
||||
|
||||
/* Output arguments */
|
||||
0,
|
||||
NULL,
|
||||
|
||||
/* Exec method */
|
||||
{ { crop_invoker } },
|
||||
};
|
||||
|
||||
static Argument *
|
||||
crop_invoker (Argument *args)
|
||||
{
|
||||
GImage *gimage;
|
||||
int success;
|
||||
int int_value;
|
||||
int new_width, new_height;
|
||||
int offx, offy;
|
||||
int layer_only, crop_layers ;
|
||||
|
||||
new_width = 1;
|
||||
new_height = 1;
|
||||
offx = 0;
|
||||
offy = 0;
|
||||
layer_only = FALSE;
|
||||
crop_layers = TRUE;
|
||||
|
||||
success = TRUE;
|
||||
if (success)
|
||||
{
|
||||
int_value = args[0].value.pdb_int;
|
||||
if ((gimage = gimage_get_ID (int_value)) == NULL)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
new_width = args[1].value.pdb_int;
|
||||
new_height = args[2].value.pdb_int;
|
||||
|
||||
if (new_width <= 0 || new_height <= 0)
|
||||
success = FALSE;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
offx = args[3].value.pdb_int;
|
||||
offy = args[4].value.pdb_int;
|
||||
}
|
||||
|
||||
if ((new_width <= 0 || new_width > gimage->width) ||
|
||||
(new_height <= 0 || new_height > gimage->height) ||
|
||||
(offx < 0 || offx > (gimage->width - new_width)) ||
|
||||
(offy < 0 || offy > (gimage->height - new_height)))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
crop_image (gimage, offx, offy, offx + new_width, offy + new_height,
|
||||
layer_only, crop_layers);
|
||||
|
||||
return procedural_db_return_args (&crop_proc, success);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue