gimp/app/pdb/gradient_edit_cmds.c

2617 lines
70 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2003 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 "config.h"
#include <string.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
#include "libgimpcolor/gimpcolor.h"
#include "pdb-types.h"
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdatafactory.h"
#include "core/gimpgradient.h"
#include "core/gimplist.h"
static ProcRecord gradient_segment_get_left_color_proc;
static ProcRecord gradient_segment_set_left_color_proc;
static ProcRecord gradient_segment_get_right_color_proc;
static ProcRecord gradient_segment_set_right_color_proc;
static ProcRecord gradient_segment_get_left_pos_proc;
static ProcRecord gradient_segment_set_left_pos_proc;
static ProcRecord gradient_segment_get_middle_pos_proc;
static ProcRecord gradient_segment_set_middle_pos_proc;
static ProcRecord gradient_segment_get_right_pos_proc;
static ProcRecord gradient_segment_set_right_pos_proc;
static ProcRecord gradient_segment_get_blending_function_proc;
static ProcRecord gradient_segment_get_coloring_type_proc;
static ProcRecord gradient_segment_range_set_blending_function_proc;
static ProcRecord gradient_segment_range_set_coloring_type_proc;
static ProcRecord gradient_segment_range_flip_proc;
static ProcRecord gradient_segment_range_replicate_proc;
static ProcRecord gradient_segment_range_split_midpoint_proc;
static ProcRecord gradient_segment_range_split_uniform_proc;
static ProcRecord gradient_segment_range_delete_proc;
static ProcRecord gradient_segment_range_redistribute_handles_proc;
static ProcRecord gradient_segment_range_blend_colors_proc;
static ProcRecord gradient_segment_range_blend_opacity_proc;
static ProcRecord gradient_segment_range_move_proc;
void
register_gradient_edit_procs (Gimp *gimp)
{
procedural_db_register (gimp, &gradient_segment_get_left_color_proc);
procedural_db_register (gimp, &gradient_segment_set_left_color_proc);
procedural_db_register (gimp, &gradient_segment_get_right_color_proc);
procedural_db_register (gimp, &gradient_segment_set_right_color_proc);
procedural_db_register (gimp, &gradient_segment_get_left_pos_proc);
procedural_db_register (gimp, &gradient_segment_set_left_pos_proc);
procedural_db_register (gimp, &gradient_segment_get_middle_pos_proc);
procedural_db_register (gimp, &gradient_segment_set_middle_pos_proc);
procedural_db_register (gimp, &gradient_segment_get_right_pos_proc);
procedural_db_register (gimp, &gradient_segment_set_right_pos_proc);
procedural_db_register (gimp, &gradient_segment_get_blending_function_proc);
procedural_db_register (gimp, &gradient_segment_get_coloring_type_proc);
procedural_db_register (gimp, &gradient_segment_range_set_blending_function_proc);
procedural_db_register (gimp, &gradient_segment_range_set_coloring_type_proc);
procedural_db_register (gimp, &gradient_segment_range_flip_proc);
procedural_db_register (gimp, &gradient_segment_range_replicate_proc);
procedural_db_register (gimp, &gradient_segment_range_split_midpoint_proc);
procedural_db_register (gimp, &gradient_segment_range_split_uniform_proc);
procedural_db_register (gimp, &gradient_segment_range_delete_proc);
procedural_db_register (gimp, &gradient_segment_range_redistribute_handles_proc);
procedural_db_register (gimp, &gradient_segment_range_blend_colors_proc);
procedural_db_register (gimp, &gradient_segment_range_blend_opacity_proc);
procedural_db_register (gimp, &gradient_segment_range_move_proc);
}
static Argument *
gradient_segment_get_left_color_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
GimpRGB color;
gdouble opacity = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
gimp_gradient_segment_get_left_color (gradient, seg, &color);
opacity = color.a * 100.0;
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_left_color_proc, success);
if (success)
{
return_args[1].value.pdb_color = color;
return_args[2].value.pdb_float = opacity;
}
return return_args;
}
static ProcArg gradient_segment_get_left_color_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_left_color_outargs[] =
{
{
GIMP_PDB_COLOR,
"color",
"The return color"
},
{
GIMP_PDB_FLOAT,
"opacity",
"The opacity of the endpoint"
}
};
static ProcRecord gradient_segment_get_left_color_proc =
{
"gimp_gradient_segment_get_left_color",
"Retrieves the left endpoint color of the specified gradient and segment",
"This procedure retrieves the left endpoint color of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_left_color_inargs,
2,
gradient_segment_get_left_color_outargs,
{ { gradient_segment_get_left_color_invoker } }
};
static Argument *
gradient_segment_set_left_color_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 segment;
GimpRGB color;
gdouble opacity;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
color = args[2].value.pdb_color;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
color.a = opacity / 100.0;
gimp_gradient_segment_set_left_color (gradient, seg, &color);
}
}
}
return procedural_db_return_args (&gradient_segment_set_left_color_proc, success);
}
static ProcArg gradient_segment_set_left_color_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
},
{
GIMP_PDB_COLOR,
"color",
"The color to set"
},
{
GIMP_PDB_FLOAT,
"opacity",
"The opacity to set for the endpoint"
}
};
static ProcRecord gradient_segment_set_left_color_proc =
{
"gimp_gradient_segment_set_left_color",
"Retrieves the left endpoint color of the specified gradient and segment",
"This procedure retrieves the left endpoint color of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_set_left_color_inargs,
0,
NULL,
{ { gradient_segment_set_left_color_invoker } }
};
static Argument *
gradient_segment_get_right_color_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
GimpRGB color;
gdouble opacity = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
gimp_gradient_segment_get_right_color (gradient, seg, &color);
opacity = color.a * 100.0;
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_right_color_proc, success);
if (success)
{
return_args[1].value.pdb_color = color;
return_args[2].value.pdb_float = opacity;
}
return return_args;
}
static ProcArg gradient_segment_get_right_color_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_right_color_outargs[] =
{
{
GIMP_PDB_COLOR,
"color",
"The return color"
},
{
GIMP_PDB_FLOAT,
"opacity",
"The opacity of the endpoint"
}
};
static ProcRecord gradient_segment_get_right_color_proc =
{
"gimp_gradient_segment_get_right_color",
"Retrieves the right endpoint color of the specified gradient and segment",
"This procedure retrieves the right endpoint color of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_right_color_inargs,
2,
gradient_segment_get_right_color_outargs,
{ { gradient_segment_get_right_color_invoker } }
};
static Argument *
gradient_segment_set_right_color_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 segment;
GimpRGB color;
gdouble opacity;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
color = args[2].value.pdb_color;
opacity = args[3].value.pdb_float;
if (opacity < 0.0 || opacity > 100.0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
color.a = opacity / 100.0;
gimp_gradient_segment_set_right_color (gradient, seg, &color);
}
}
}
return procedural_db_return_args (&gradient_segment_set_right_color_proc, success);
}
static ProcArg gradient_segment_set_right_color_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
},
{
GIMP_PDB_COLOR,
"color",
"The color to set"
},
{
GIMP_PDB_FLOAT,
"opacity",
"The opacity to set for the endpoint"
}
};
static ProcRecord gradient_segment_set_right_color_proc =
{
"gimp_gradient_segment_set_right_color",
"Retrieves the right endpoint color of the specified gradient and segment",
"This procedure retrieves the right endpoint color of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_set_right_color_inargs,
0,
NULL,
{ { gradient_segment_set_right_color_invoker } }
};
static Argument *
gradient_segment_get_left_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
pos = gimp_gradient_segment_get_left_pos (gradient, seg);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_left_pos_proc, success);
if (success)
return_args[1].value.pdb_float = pos;
return return_args;
}
static ProcArg gradient_segment_get_left_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_left_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"pos",
"The return position"
}
};
static ProcRecord gradient_segment_get_left_pos_proc =
{
"gimp_gradient_segment_get_left_pos",
"Retrieves the left endpoint position of the specified gradient and segment",
"This procedure retrieves the left endpoint position of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_left_pos_inargs,
1,
gradient_segment_get_left_pos_outargs,
{ { gradient_segment_get_left_pos_invoker } }
};
static Argument *
gradient_segment_set_left_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos;
gdouble final_pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
final_pos =
gimp_gradient_segment_set_left_pos (gradient, seg, pos);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_set_left_pos_proc, success);
if (success)
return_args[1].value.pdb_float = final_pos;
return return_args;
}
static ProcArg gradient_segment_set_left_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
},
{
GIMP_PDB_FLOAT,
"pos",
"The position to set the guidepoint in."
}
};
static ProcArg gradient_segment_set_left_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"final_pos",
"The return position"
}
};
static ProcRecord gradient_segment_set_left_pos_proc =
{
"gimp_gradient_segment_set_left_pos",
"Sets the left endpoint position of the specified gradient and segment",
"This procedure sets the left endpoint position of the specified segment of the specified gradient. The final position will be between the position of the middle point to the left to the middle point of the current segement. This procedure returns the final position.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_set_left_pos_inargs,
1,
gradient_segment_set_left_pos_outargs,
{ { gradient_segment_set_left_pos_invoker } }
};
static Argument *
gradient_segment_get_middle_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
pos = gimp_gradient_segment_get_middle_pos (gradient, seg);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_middle_pos_proc, success);
if (success)
return_args[1].value.pdb_float = pos;
return return_args;
}
static ProcArg gradient_segment_get_middle_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_middle_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"pos",
"The return position"
}
};
static ProcRecord gradient_segment_get_middle_pos_proc =
{
"gimp_gradient_segment_get_middle_pos",
"Retrieves the middle point position of the specified gradient and segment",
"This procedure retrieves the middle point position of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_middle_pos_inargs,
1,
gradient_segment_get_middle_pos_outargs,
{ { gradient_segment_get_middle_pos_invoker } }
};
static Argument *
gradient_segment_set_middle_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos;
gdouble final_pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
final_pos =
gimp_gradient_segment_set_middle_pos (gradient, seg, pos);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_set_middle_pos_proc, success);
if (success)
return_args[1].value.pdb_float = final_pos;
return return_args;
}
static ProcArg gradient_segment_set_middle_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
},
{
GIMP_PDB_FLOAT,
"pos",
"The position to set the guidepoint in."
}
};
static ProcArg gradient_segment_set_middle_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"final_pos",
"The return position"
}
};
static ProcRecord gradient_segment_set_middle_pos_proc =
{
"gimp_gradient_segment_set_middle_pos",
"Sets the middle point position of the specified gradient and segment",
"This procedure sets the middle point position of the specified segment of the specified gradient. The final position will be between the two endpoints of the segment. This procedure returns the final position.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_set_middle_pos_inargs,
1,
gradient_segment_set_middle_pos_outargs,
{ { gradient_segment_set_middle_pos_invoker } }
};
static Argument *
gradient_segment_get_right_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
pos = gimp_gradient_segment_get_right_pos (gradient, seg);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_right_pos_proc, success);
if (success)
return_args[1].value.pdb_float = pos;
return return_args;
}
static ProcArg gradient_segment_get_right_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_right_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"pos",
"The return position"
}
};
static ProcRecord gradient_segment_get_right_pos_proc =
{
"gimp_gradient_segment_get_right_pos",
"Retrieves the right endpoint position of the specified gradient and segment",
"This procedure retrieves the right endpoint position of the specified segment of the specified gradient.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_right_pos_inargs,
1,
gradient_segment_get_right_pos_outargs,
{ { gradient_segment_get_right_pos_invoker } }
};
static Argument *
gradient_segment_set_right_pos_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gdouble pos;
gdouble final_pos = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
pos = args[2].value.pdb_float;
if (pos < 0.0 || pos > 1.0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
final_pos =
gimp_gradient_segment_set_right_pos (gradient, seg, pos);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_set_right_pos_proc, success);
if (success)
return_args[1].value.pdb_float = final_pos;
return return_args;
}
static ProcArg gradient_segment_set_right_pos_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
},
{
GIMP_PDB_FLOAT,
"pos",
"The position to set the guidepoint in."
}
};
static ProcArg gradient_segment_set_right_pos_outargs[] =
{
{
GIMP_PDB_FLOAT,
"final_pos",
"The return position"
}
};
static ProcRecord gradient_segment_set_right_pos_proc =
{
"gimp_gradient_segment_set_right_pos",
"Sets the right endpoint position of the specified gradient and segment",
"This procedure sets the right endpoint position of the specified segment of the specified gradient. The final position will be between the position of the middle point of the current segment and the middle point of the segment to the right. This procedure returns the final position.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_set_right_pos_inargs,
1,
gradient_segment_set_right_pos_outargs,
{ { gradient_segment_set_right_pos_invoker } }
};
static Argument *
gradient_segment_get_blending_function_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gint32 blend_func = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
blend_func =
gimp_gradient_segment_get_blending_function (gradient, seg);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_blending_function_proc, success);
if (success)
return_args[1].value.pdb_int = blend_func;
return return_args;
}
static ProcArg gradient_segment_get_blending_function_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_blending_function_outargs[] =
{
{
GIMP_PDB_INT32,
"blend_func",
"The blending function of the segment: { GIMP_GRADIENT_SEGMENT_LINEAR (0), GIMP_GRADIENT_SEGMENT_CURVED (1), GIMP_GRADIENT_SEGMENT_SINE (2), GIMP_GRADIENT_SEGMENT_SPHERE_INCREASING (3), GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING (4) }"
}
};
static ProcRecord gradient_segment_get_blending_function_proc =
{
"gimp_gradient_segment_get_blending_function",
"Retrieves the gradient segment's blending function",
"This procedure retrieves the blending function of the segment at the specified gradient name and segment index.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_blending_function_inargs,
1,
gradient_segment_get_blending_function_outargs,
{ { gradient_segment_get_blending_function_invoker } }
};
static Argument *
gradient_segment_get_coloring_type_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 segment;
gint32 coloring_type = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
segment = args[1].value.pdb_int;
if (segment < 0)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
success = (gradient != NULL);
if (success)
{
GimpGradientSegment *seg;
seg = gimp_gradient_segment_get_nth (gradient->segments, segment);
success = (seg != NULL);
if (success)
{
coloring_type =
gimp_gradient_segment_get_coloring_type (gradient, seg);
}
}
}
return_args = procedural_db_return_args (&gradient_segment_get_coloring_type_proc, success);
if (success)
return_args[1].value.pdb_int = coloring_type;
return return_args;
}
static ProcArg gradient_segment_get_coloring_type_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on"
},
{
GIMP_PDB_INT32,
"segment",
"The index of the segment within the gradient"
}
};
static ProcArg gradient_segment_get_coloring_type_outargs[] =
{
{
GIMP_PDB_INT32,
"coloring_type",
"The coloring type of the segment: { GIMP_GRADIENT_SEGMENT_RGB (0), GIMP_GRADIENT_SEGMENT_HSV_CCW (1), GIMP_GRADIENT_SEGMENT_HSV_CW (2) }"
}
};
static ProcRecord gradient_segment_get_coloring_type_proc =
{
"gimp_gradient_segment_get_coloring_type",
"Retrieves the gradient segment's coloring type",
"This procedure retrieves the coloring type of the segment at the specified gradient name and segment index.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
2,
gradient_segment_get_coloring_type_inargs,
1,
gradient_segment_get_coloring_type_outargs,
{ { gradient_segment_get_coloring_type_invoker } }
};
static Argument *
gradient_segment_range_set_blending_function_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
gint32 blending_function;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
blending_function = args[3].value.pdb_int;
if (blending_function < GIMP_GRADIENT_SEGMENT_LINEAR || blending_function > GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_set_blending_function (gradient,
start_seg,
end_seg,
blending_function);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_set_blending_function_proc, success);
}
static ProcArg gradient_segment_range_set_blending_function_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
},
{
GIMP_PDB_INT32,
"blending_function",
"The Blending Function: { GIMP_GRADIENT_SEGMENT_LINEAR (0), GIMP_GRADIENT_SEGMENT_CURVED (1), GIMP_GRADIENT_SEGMENT_SINE (2), GIMP_GRADIENT_SEGMENT_SPHERE_INCREASING (3), GIMP_GRADIENT_SEGMENT_SPHERE_DECREASING (4) }"
}
};
static ProcRecord gradient_segment_range_set_blending_function_proc =
{
"gimp_gradient_segment_range_set_blending_function",
"Change the blending function of a segments range",
"This function changes the blending function of a segment range to the specified blending function.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_range_set_blending_function_inargs,
0,
NULL,
{ { gradient_segment_range_set_blending_function_invoker } }
};
static Argument *
gradient_segment_range_set_coloring_type_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
gint32 coloring_type;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
coloring_type = args[3].value.pdb_int;
if (coloring_type < GIMP_GRADIENT_SEGMENT_RGB || coloring_type > GIMP_GRADIENT_SEGMENT_HSV_CW)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_set_coloring_type (gradient,
start_seg,
end_seg,
coloring_type);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_set_coloring_type_proc, success);
}
static ProcArg gradient_segment_range_set_coloring_type_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
},
{
GIMP_PDB_INT32,
"coloring_type",
"The Coloring Type: { GIMP_GRADIENT_SEGMENT_RGB (0), GIMP_GRADIENT_SEGMENT_HSV_CCW (1), GIMP_GRADIENT_SEGMENT_HSV_CW (2) }"
}
};
static ProcRecord gradient_segment_range_set_coloring_type_proc =
{
"gimp_gradient_segment_range_set_coloring_type",
"Change the coloring type of a segments range",
"This function changes the coloring type of a segment range to the specified coloring type.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_range_set_coloring_type_inargs,
0,
NULL,
{ { gradient_segment_range_set_coloring_type_invoker } }
};
static Argument *
gradient_segment_range_flip_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_flip (gradient,
start_seg,
end_seg,
NULL, NULL);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_flip_proc, success);
}
static ProcArg gradient_segment_range_flip_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_flip_proc =
{
"gimp_gradient_segment_range_flip",
"Flip the segment range",
"This function flips a segment range.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_flip_inargs,
0,
NULL,
{ { gradient_segment_range_flip_invoker } }
};
static Argument *
gradient_segment_range_replicate_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
gint32 replicate_times;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
replicate_times = args[3].value.pdb_int;
if (replicate_times < 2 || replicate_times > 20)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_replicate (gradient,
start_seg,
end_seg,
replicate_times,
NULL, NULL);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_replicate_proc, success);
}
static ProcArg gradient_segment_range_replicate_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
},
{
GIMP_PDB_INT32,
"replicate_times",
"The number of times to replicate"
}
};
static ProcRecord gradient_segment_range_replicate_proc =
{
"gimp_gradient_segment_range_replicate",
"Replicate the segment range",
"This function replicates a segment range a given number of times. Instead of the original segment range, several smaller scaled copies of it will appear in equal widths.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_range_replicate_inargs,
0,
NULL,
{ { gradient_segment_range_replicate_invoker } }
};
static Argument *
gradient_segment_range_split_midpoint_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_split_midpoint (gradient,
start_seg,
end_seg,
NULL, NULL);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_split_midpoint_proc, success);
}
static ProcArg gradient_segment_range_split_midpoint_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_split_midpoint_proc =
{
"gimp_gradient_segment_range_split_midpoint",
"Splits each segment in the segment range at midpoint",
"This function splits each segment in the segment range at its midpoint.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_split_midpoint_inargs,
0,
NULL,
{ { gradient_segment_range_split_midpoint_invoker } }
};
static Argument *
gradient_segment_range_split_uniform_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
gint32 split_parts;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
split_parts = args[3].value.pdb_int;
if (split_parts < 2 || split_parts > 20)
success = FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_split_uniform (gradient,
start_seg,
end_seg,
split_parts,
NULL, NULL);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_split_uniform_proc, success);
}
static ProcArg gradient_segment_range_split_uniform_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
},
{
GIMP_PDB_INT32,
"split_parts",
"The number of uniform divisions to split each segment to"
}
};
static ProcRecord gradient_segment_range_split_uniform_proc =
{
"gimp_gradient_segment_range_split_uniform",
"Splits each segment in the segment range uniformly",
"This function splits each segment in the segment range uniformly according to the number of times specified by the parameter.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
4,
gradient_segment_range_split_uniform_inargs,
0,
NULL,
{ { gradient_segment_range_split_uniform_invoker } }
};
static Argument *
gradient_segment_range_delete_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_delete (gradient,
start_seg,
end_seg,
NULL, NULL);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_delete_proc, success);
}
static ProcArg gradient_segment_range_delete_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_delete_proc =
{
"gimp_gradient_segment_range_delete",
"Delete the segment range",
"This function deletes a segment range.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_delete_inargs,
0,
NULL,
{ { gradient_segment_range_delete_invoker } }
};
static Argument *
gradient_segment_range_redistribute_handles_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_redistribute_handles (gradient,
start_seg,
end_seg);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_redistribute_handles_proc, success);
}
static ProcArg gradient_segment_range_redistribute_handles_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_redistribute_handles_proc =
{
"gimp_gradient_segment_range_redistribute_handles",
"Uniformly redistribute the segment range's handles",
"This function redistributes the handles of the specified segment range of the specified gradient, so they'll be evenly spaced.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_redistribute_handles_inargs,
0,
NULL,
{ { gradient_segment_range_redistribute_handles_invoker } }
};
static Argument *
gradient_segment_range_blend_colors_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_blend (gradient,
start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
TRUE, FALSE);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_blend_colors_proc, success);
}
static ProcArg gradient_segment_range_blend_colors_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_blend_colors_proc =
{
"gimp_gradient_segment_range_blend_colors",
"Blend the colors of the segment range.",
"This function blends the colors (but not the opacity) of the segments' range of the gradient. Using it, the colors' transition will be uniform across the range.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_blend_colors_inargs,
0,
NULL,
{ { gradient_segment_range_blend_colors_invoker } }
};
static Argument *
gradient_segment_range_blend_opacity_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
gchar *name;
gint32 start_segment;
gint32 end_segment;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
gimp_gradient_segment_range_blend (gradient,
start_seg, end_seg,
&start_seg->left_color,
&end_seg->right_color,
FALSE, TRUE);
}
}
else
{
success = FALSE;
}
}
}
return procedural_db_return_args (&gradient_segment_range_blend_opacity_proc, success);
}
static ProcArg gradient_segment_range_blend_opacity_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
}
};
static ProcRecord gradient_segment_range_blend_opacity_proc =
{
"gimp_gradient_segment_range_blend_opacity",
"Blend the opacity of the segment range.",
"This function blends the opacity (but not the colors) of the segments' range of the gradient. Using it, the opacity's transition will be uniform across the range.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
3,
gradient_segment_range_blend_opacity_inargs,
0,
NULL,
{ { gradient_segment_range_blend_opacity_invoker } }
};
static Argument *
gradient_segment_range_move_invoker (Gimp *gimp,
GimpContext *context,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
gchar *name;
gint32 start_segment;
gint32 end_segment;
gdouble delta;
gboolean control_compress;
gdouble final_delta = 0;
GimpGradient *gradient = NULL;
name = (gchar *) args[0].value.pdb_pointer;
if (name == NULL || !g_utf8_validate (name, -1, NULL))
success = FALSE;
start_segment = args[1].value.pdb_int;
if (start_segment < 0)
success = FALSE;
end_segment = args[2].value.pdb_int;
delta = args[3].value.pdb_float;
if (delta < -1.0 || delta > 1.0)
success = FALSE;
control_compress = args[4].value.pdb_int ? TRUE : FALSE;
if (success)
{
if (strlen (name))
{
gradient = (GimpGradient *)
gimp_container_get_child_by_name (gimp->gradient_factory->container,
name);
}
else
{
gradient = gimp_context_get_gradient (context);
}
if (gradient)
{
GimpGradientSegment *start_seg, *end_seg;
start_seg = gimp_gradient_segment_get_nth (gradient->segments,
start_segment);
if (start_seg)
{
if ((end_segment < start_segment) && (end_segment >= 0))
{
/* Do Nothing */
success = FALSE;
}
else
{
if (end_segment < 0)
{
end_seg = NULL;
}
else
{
end_seg = gimp_gradient_segment_get_nth (start_seg,
end_segment -
start_segment);
}
/* Success */
final_delta = gimp_gradient_segment_range_move (gradient,
start_seg,
end_seg,
delta,
control_compress);
}
}
else
{
success = FALSE;
}
}
}
return_args = procedural_db_return_args (&gradient_segment_range_move_proc, success);
if (success)
return_args[1].value.pdb_float = final_delta;
return return_args;
}
static ProcArg gradient_segment_range_move_inargs[] =
{
{
GIMP_PDB_STRING,
"name",
"The name of the gradient to operate on."
},
{
GIMP_PDB_INT32,
"start_segment",
"The index of the first segment to operate on"
},
{
GIMP_PDB_INT32,
"end_segment",
"The index of the last segment to operate on. If negative, the selection will extend to the end of the string."
},
{
GIMP_PDB_FLOAT,
"delta",
"The delta to move the segment range"
},
{
GIMP_PDB_INT32,
"control_compress",
"Whether or not to compress the neighboring segments"
}
};
static ProcArg gradient_segment_range_move_outargs[] =
{
{
GIMP_PDB_FLOAT,
"final_delta",
"The final delta by which the range moved"
}
};
static ProcRecord gradient_segment_range_move_proc =
{
"gimp_gradient_segment_range_move",
"Move the position of an entire segment range by a delta.",
"This funtions moves the position of an entire segment range by a delta. The actual delta (which is returned) will be limited by the control points of the neighboring segments.",
"Shlomi Fish",
"Shlomi Fish",
"2003",
GIMP_INTERNAL,
5,
gradient_segment_range_move_inargs,
1,
gradient_segment_range_move_outargs,
{ { gradient_segment_range_move_invoker } }
};