Commit 075195d1 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added "gboolean reverse" to gimp_gradient_get_color_at() so all gradients

2003-07-22  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpgradient.[ch]: added "gboolean reverse" to
	gimp_gradient_get_color_at() so all gradients can be used
	reversed.

	* app/core/gimpdrawable-blend.[ch] (gimp_drawable_blend)
	* app/core/gimppalette-import.[ch] (gimp_palette_import_from_gradient):
	added "gboolean reverse".

	* app/paint/paint-enums.[ch]: removed enum GimpGradientRepeatMode
	since it is identical to GimpRepeatMode, except for the now
	obsolete ONCE_BACKWARD value.

	* app/paint/gimppaintcore.[ch]: removed
	gimp_paint_core_get_color_from_gradient()...

	* app/paint/gimppaintoptions.[ch]: ...and added
	gimp_paint_options_get_gradient_color(), which is much more
	general. Added a "reverse" property to GimpGradientOptions and
	changed the type of the "repeat" property to GimpRepeatMode.

	* app/paint/gimppaintbrush.c: use
	gimp_paint_options_get_gradient_color().

	* app/tools/gimpblendoptions.[ch]: removed the "repeat" property
	since it is in the parent class now.

	* app/gui/gradient-select.c
	* app/gui/palette-import-dialog.c
	* app/widgets/gimpgradienteditor.c
	* app/tools/gimpblendtool.c
	* tools/pdbgen/pdb/gradients.pdb
	* tools/pdbgen/pdb/misc_tools.pdb: changed accordingly.

	* app/tools/gimppaintoptions-gui.c: added a "Reverse" toggle right
	of the gradient preview.

	* app/widgets/gimppreviewrenderergradient.[ch]: added "gboolean
	reverse" member and gimp_preview_renderer_gradient_set_reverse()
	API.

	* tools/pdbgen/pdb/paint_tools.pdb: fixed the paintbrush invoker
	to set GimpPaintOption's "use-fade" and "use-gradient" properties
	correctly.

	* app/pdb/gradients_cmds.c
	* app/pdb/misc_tools_cmds.c
	* app/pdb/paint_tools_cmds.c
	* libgimp/gimpenums.h
	* libgimp/gimpmisctools_pdb.[ch]
	* plug-ins/pygimp/gimpenums.py
	* plug-ins/script-fu/script-fu-constants.c
	* tools/pdbgen/enums.pl: regenerated.

	* libgimp/gimpcompat.h
	* plug-ins/script-fu/siod-wrapper.c: removed GimpGradientPaintMode
	here too since it was only exported accidentially (it's not used
	by any external API).

	* plug-ins/script-fu/scripts/3dTruchet.scm
	* plug-ins/script-fu/scripts/alien-glow-arrow.scm
	* plug-ins/script-fu/scripts/alien-glow-bar.scm
	* plug-ins/script-fu/scripts/alien-glow-bullet.scm
	* plug-ins/script-fu/scripts/alien-glow-button.scm
	* plug-ins/script-fu/scripts/alien-glow-logo.scm
	* plug-ins/script-fu/scripts/basic1-logo.scm
	* plug-ins/script-fu/scripts/basic2-logo.scm
	* plug-ins/script-fu/scripts/beveled-button.scm
	* plug-ins/script-fu/scripts/blended-logo.scm
	* plug-ins/script-fu/scripts/burn-in-anim.scm
	* plug-ins/script-fu/scripts/coffee.scm
	* plug-ins/script-fu/scripts/comic-logo.scm
	* plug-ins/script-fu/scripts/coolmetal-logo.scm
	* plug-ins/script-fu/scripts/glossy.scm
	* plug-ins/script-fu/scripts/gradient-bevel-logo.scm
	* plug-ins/script-fu/scripts/gradient-example.scm
	* plug-ins/script-fu/scripts/pupi-button.scm
	* plug-ins/script-fu/scripts/rendermap.scm
	* plug-ins/script-fu/scripts/sphere.scm
	* plug-ins/script-fu/scripts/starscape-logo.scm
	* plug-ins/script-fu/scripts/test-sphere.scm
	* plug-ins/script-fu/scripts/textured-logo.scm
	* plug-ins/script-fu/scripts/title-header.scm
	* plug-ins/script-fu/scripts/weave.scm: pass "reverse" to
	gimp_blend(). Pass FALSE in most cases and added script
	parameters were it makes sense.
parent a1d33d15
2003-07-22 Michael Natterer <mitch@gimp.org>
* app/core/gimpgradient.[ch]: added "gboolean reverse" to
gimp_gradient_get_color_at() so all gradients can be used
reversed.
* app/core/gimpdrawable-blend.[ch] (gimp_drawable_blend)
* app/core/gimppalette-import.[ch] (gimp_palette_import_from_gradient):
added "gboolean reverse".
* app/paint/paint-enums.[ch]: removed enum GimpGradientRepeatMode
since it is identical to GimpRepeatMode, except for the now
obsolete ONCE_BACKWARD value.
* app/paint/gimppaintcore.[ch]: removed
gimp_paint_core_get_color_from_gradient()...
* app/paint/gimppaintoptions.[ch]: ...and added
gimp_paint_options_get_gradient_color(), which is much more
general. Added a "reverse" property to GimpGradientOptions and
changed the type of the "repeat" property to GimpRepeatMode.
* app/paint/gimppaintbrush.c: use
gimp_paint_options_get_gradient_color().
* app/tools/gimpblendoptions.[ch]: removed the "repeat" property
since it is in the parent class now.
* app/gui/gradient-select.c
* app/gui/palette-import-dialog.c
* app/widgets/gimpgradienteditor.c
* app/tools/gimpblendtool.c
* tools/pdbgen/pdb/gradients.pdb
* tools/pdbgen/pdb/misc_tools.pdb: changed accordingly.
* app/tools/gimppaintoptions-gui.c: added a "Reverse" toggle right
of the gradient preview.
* app/widgets/gimppreviewrenderergradient.[ch]: added "gboolean
reverse" member and gimp_preview_renderer_gradient_set_reverse()
API.
* tools/pdbgen/pdb/paint_tools.pdb: fixed the paintbrush invoker
to set GimpPaintOption's "use-fade" and "use-gradient" properties
correctly.
* app/pdb/gradients_cmds.c
* app/pdb/misc_tools_cmds.c
* app/pdb/paint_tools_cmds.c
* libgimp/gimpenums.h
* libgimp/gimpmisctools_pdb.[ch]
* plug-ins/pygimp/gimpenums.py
* plug-ins/script-fu/script-fu-constants.c
* tools/pdbgen/enums.pl: regenerated.
* libgimp/gimpcompat.h
* plug-ins/script-fu/siod-wrapper.c: removed GimpGradientPaintMode
here too since it was only exported accidentially (it's not used
by any external API).
* plug-ins/script-fu/scripts/3dTruchet.scm
* plug-ins/script-fu/scripts/alien-glow-arrow.scm
* plug-ins/script-fu/scripts/alien-glow-bar.scm
* plug-ins/script-fu/scripts/alien-glow-bullet.scm
* plug-ins/script-fu/scripts/alien-glow-button.scm
* plug-ins/script-fu/scripts/alien-glow-logo.scm
* plug-ins/script-fu/scripts/basic1-logo.scm
* plug-ins/script-fu/scripts/basic2-logo.scm
* plug-ins/script-fu/scripts/beveled-button.scm
* plug-ins/script-fu/scripts/blended-logo.scm
* plug-ins/script-fu/scripts/burn-in-anim.scm
* plug-ins/script-fu/scripts/coffee.scm
* plug-ins/script-fu/scripts/comic-logo.scm
* plug-ins/script-fu/scripts/coolmetal-logo.scm
* plug-ins/script-fu/scripts/glossy.scm
* plug-ins/script-fu/scripts/gradient-bevel-logo.scm
* plug-ins/script-fu/scripts/gradient-example.scm
* plug-ins/script-fu/scripts/pupi-button.scm
* plug-ins/script-fu/scripts/rendermap.scm
* plug-ins/script-fu/scripts/sphere.scm
* plug-ins/script-fu/scripts/starscape-logo.scm
* plug-ins/script-fu/scripts/test-sphere.scm
* plug-ins/script-fu/scripts/textured-logo.scm
* plug-ins/script-fu/scripts/title-header.scm
* plug-ins/script-fu/scripts/weave.scm: pass "reverse" to
gimp_blend(). Pass FALSE in most cases and added script
parameters were it makes sense.
2003-07-22 Jakub Steiner <jimmac@ximian.com>
* data/images/gimp_splash.png: special Gimpcon splash
......@@ -50,6 +50,7 @@ typedef gdouble (* BlendRepeatFunc) (gdouble);
typedef struct
{
GimpGradient *gradient;
gboolean reverse;
gdouble offset;
gdouble sx, sy;
GimpBlendMode blend_mode;
......@@ -120,7 +121,7 @@ static gdouble gradient_repeat_sawtooth (gdouble val);
static gdouble gradient_repeat_triangular (gdouble val);
static void gradient_precalc_shapeburst (GimpImage *gimage,
GimpDrawable *drawable,
GimpDrawable *drawable,
PixelRegion *PR,
gdouble dist);
......@@ -142,7 +143,8 @@ static void gradient_fill_region (GimpImage *gimage,
GimpGradientType gradient_type,
gdouble offset,
GimpRepeatMode repeat,
gint supersample,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
......@@ -171,23 +173,24 @@ static PixelRegion distR =
/* public functions */
void
gimp_drawable_blend (GimpDrawable *drawable,
GimpBlendMode blend_mode,
int paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gint supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble startx,
gdouble starty,
gdouble endx,
gdouble endy,
GimpProgressFunc progress_callback,
gpointer progress_data)
gimp_drawable_blend (GimpDrawable *drawable,
GimpBlendMode blend_mode,
GimpLayerModeEffects paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble startx,
gdouble starty,
gdouble endx,
gdouble endy,
GimpProgressFunc progress_callback,
gpointer progress_data)
{
GimpImage *gimage;
TileManager *buf_tiles;
......@@ -222,7 +225,7 @@ gimp_drawable_blend (GimpDrawable *drawable,
gradient_fill_region (gimage, drawable,
&bufPR, (x2 - x1), (y2 - y1),
blend_mode, gradient_type, offset, repeat,
blend_mode, gradient_type, offset, repeat, reverse,
supersample, max_depth, threshold, dither,
(startx - x1), (starty - y1),
(endx - x1), (endy - y1),
......@@ -684,9 +687,9 @@ gradient_precalc_shapeburst (GimpImage *gimage,
static void
gradient_render_pixel (double x,
double y,
GimpRGB *color,
gradient_render_pixel (double x,
double y,
GimpRGB *color,
gpointer render_data)
{
RenderBlendData *rbd;
......@@ -763,12 +766,15 @@ gradient_render_pixel (double x,
if (rbd->blend_mode == GIMP_CUSTOM_MODE)
{
gimp_gradient_get_color_at (rbd->gradient, factor, color);
gimp_gradient_get_color_at (rbd->gradient, factor, rbd->reverse, color);
}
else
{
/* Blend values */
if (rbd->reverse)
factor = 1.0 - factor;
color->r = rbd->fg.r + (rbd->bg.r - rbd->fg.r) * factor;
color->g = rbd->fg.g + (rbd->bg.g - rbd->fg.g) * factor;
color->b = rbd->fg.b + (rbd->bg.b - rbd->fg.b) * factor;
......@@ -786,9 +792,9 @@ gradient_render_pixel (double x,
}
static void
gradient_put_pixel (int x,
int y,
GimpRGB *color,
gradient_put_pixel (int x,
int y,
GimpRGB *color,
void *put_pixel_data)
{
PutPixelData *ppd;
......@@ -823,13 +829,13 @@ gradient_put_pixel (int x,
ftmp = color->b * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if(g_rand_double (ppd->dither_rand) < dither_prob)
if (g_rand_double (ppd->dither_rand) < dither_prob)
color->b += (1.0 / 255.0);
ftmp = color->a * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if(g_rand_double (ppd->dither_rand) < dither_prob)
if (g_rand_double (ppd->dither_rand) < dither_prob)
color->a += (1.0 / 255.0);
if (color->r > 1.0) color->r = 1.0;
......@@ -847,25 +853,25 @@ gradient_put_pixel (int x,
{
/* Convert to grayscale */
gdouble gray = INTENSITY (color->r, color->g, color->b);
if (ppd->dither)
{
gdouble dither_prob;
gdouble ftmp;
gint itmp;
ftmp = gray * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if (g_rand_double (ppd->dither_rand) < dither_prob)
gray += (1.0 / 255.0);
ftmp = color->a * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if (g_rand_double (ppd->dither_rand) < dither_prob)
color->a += (1.0 / 255.0);
if (color->a > 1.0) color->a = 1.0;
}
......@@ -889,7 +895,8 @@ gradient_fill_region (GimpImage *gimage,
GimpGradientType gradient_type,
gdouble offset,
GimpRepeatMode repeat,
gint supersample,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
......@@ -913,6 +920,7 @@ gradient_fill_region (GimpImage *gimage,
context = gimp_get_current_context (gimage->gimp);
rbd.gradient = gimp_context_get_gradient (context);
rbd.reverse = reverse;
/* Get foreground and background colors, normalized */
......@@ -1080,7 +1088,7 @@ gradient_fill_region (GimpImage *gimage,
gdouble dither_prob;
gdouble ftmp;
gint itmp;
ftmp = color.r * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
......@@ -1104,7 +1112,7 @@ gradient_fill_region (GimpImage *gimage,
dither_prob = ftmp - itmp;
if (g_rand_double (dither_rand) < dither_prob)
color.a += (1.0 / 255.0);
if (color.r > 1.0) color.r = 1.0;
if (color.g > 1.0) color.g = 1.0;
if (color.b > 1.0) color.b = 1.0;
......@@ -1120,25 +1128,25 @@ gradient_fill_region (GimpImage *gimage,
{
/* Convert to grayscale */
gdouble gray = INTENSITY (color.r, color.g, color.b);
if (dither)
{
gdouble dither_prob;
gdouble ftmp;
gint itmp;
ftmp = gray * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if (g_rand_double (dither_rand) < dither_prob)
gray += (1.0 / 255.0);
ftmp = color.a * 255.0;
itmp = ftmp;
dither_prob = ftmp - itmp;
if (g_rand_double (dither_rand) < dither_prob)
color.a += (1.0 / 255.0);
if (color.a > 1.0) color.a = 1.0;
}
......
......@@ -20,23 +20,24 @@
#define __GIMP_DRAWABLE_BLEND_H__
void gimp_drawable_blend (GimpDrawable *drawable,
GimpBlendMode blend_mode,
gint paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gint supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble startx,
gdouble starty,
gdouble endx,
gdouble endy,
GimpProgressFunc progress_callback,
gpointer progress_data);
void gimp_drawable_blend (GimpDrawable *drawable,
GimpBlendMode blend_mode,
GimpLayerModeEffects paint_mode,
GimpGradientType gradient_type,
gdouble opacity,
gdouble offset,
GimpRepeatMode repeat,
gboolean reverse,
gboolean supersample,
gint max_depth,
gdouble threshold,
gboolean dither,
gdouble startx,
gdouble starty,
gdouble endx,
gdouble endy,
GimpProgressFunc progress_callback,
gpointer progress_data);
#endif /* __GIMP_DRAWABLE_BLEND_H__ */
......@@ -238,7 +238,7 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
for (x = 0; x < width; x++)
{
gimp_gradient_get_color_at (gradient, cur_x, &color);
gimp_gradient_get_color_at (gradient, cur_x, FALSE, &color);
*p++ = color.r * 255.0;
*p++ = color.g * 255.0;
......@@ -253,7 +253,7 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
buf = temp_buf_data (temp_buf);
for (y = 0; y < height; y++)
memcpy (buf + (width * y * 4), row, width * 4);
memcpy (buf + (width * y * 4), row, width * 4);
g_free (row);
......@@ -380,7 +380,7 @@ gimp_gradient_load (const gchar *filename,
}
else
{
g_message (_("Invalid UTF-8 string in gradient file '%s'."),
g_message (_("Invalid UTF-8 string in gradient file '%s'."),
filename);
gimp_object_set_name (GIMP_OBJECT (gradient), _("Unnamed"));
}
......@@ -440,7 +440,7 @@ gimp_gradient_load (const gchar *filename,
seg->left_color.b = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->left_color.a = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
seg->right_color.r = g_ascii_strtod (end, &end);
if (end && errno != ERANGE)
......@@ -601,13 +601,13 @@ gimp_gradient_save_as_pov (GimpGradient *gradient,
/* Left */
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left);
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.r);
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.g);
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->left_color.b);
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - seg->left_color.a);
fprintf (file, "\t[%s color rgbt <%s, %s, %s, %s>]\n",
......@@ -617,13 +617,13 @@ gimp_gradient_save_as_pov (GimpGradient *gradient,
/* Middle */
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->middle);
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.r + seg->right_color.r) / 2.0);
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.g + seg->right_color.g) / 2.0);
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
(seg->left_color.b + seg->right_color.b) / 2.0);
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - (seg->left_color.a + seg->right_color.a) / 2.0);
fprintf (file, "\t[%s color rgbt <%s, %s, %s, %s>]\n",
......@@ -633,13 +633,13 @@ gimp_gradient_save_as_pov (GimpGradient *gradient,
/* Right */
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right);
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[0], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.r);
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[1], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.g);
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[2], G_ASCII_DTOSTR_BUF_SIZE, "%f",
seg->right_color.b);
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
g_ascii_formatd (color_buf[3], G_ASCII_DTOSTR_BUF_SIZE, "%f",
1.0 - seg->right_color.a);
fprintf (file, "\t[%s color rgbt <%s, %s, %s, %s>]\n",
......@@ -657,6 +657,7 @@ gimp_gradient_save_as_pov (GimpGradient *gradient,
void
gimp_gradient_get_color_at (GimpGradient *gradient,
gdouble pos,
gboolean reverse,
GimpRGB *color)
{
gdouble factor = 0.0;
......@@ -668,17 +669,10 @@ gimp_gradient_get_color_at (GimpGradient *gradient,
g_return_if_fail (GIMP_IS_GRADIENT (gradient));
g_return_if_fail (color != NULL);
/* if there is no gradient return a totally transparent black */
if (gradient == NULL)
{
gimp_rgba_set (color, 0.0, 0.0, 0.0, 0.0);
return;
}
pos = CLAMP (pos, 0.0, 1.0);
if (pos < 0.0)
pos = 0.0;
else if (pos > 1.0)
pos = 1.0;
if (reverse)
pos = 1.0 - pos;
seg = gimp_gradient_get_segment_at (gradient, pos);
......@@ -718,7 +712,7 @@ gimp_gradient_get_color_at (GimpGradient *gradient,
break;
default:
g_warning ("%s: Unknown gradient type %d.",
g_warning ("%s: Unknown gradient type %d.",
G_GNUC_PRETTY_FUNCTION, seg->type);
break;
}
......@@ -727,7 +721,7 @@ gimp_gradient_get_color_at (GimpGradient *gradient,
if (seg->color == GIMP_GRAD_RGB)
{
rgb.r =
rgb.r =
seg->left_color.r + (seg->right_color.r - seg->left_color.r) * factor;
rgb.g =
......@@ -985,7 +979,7 @@ gimp_gradient_segment_split_midpoint (GimpGradient *gradient,
g_return_if_fail (newr != NULL);
/* Get color at original segment's midpoint */
gimp_gradient_get_color_at (gradient, lseg->middle, &color);
gimp_gradient_get_color_at (gradient, lseg->middle, FALSE, &color);
/* Create a new segment and insert it in the list */
......@@ -1063,8 +1057,8 @@ gimp_gradient_segment_split_uniform (GimpGradient *gradient,
seg->right = lseg->left + (i + 1) * seg_len;
seg->middle = (seg->left + seg->right) / 2.0;
gimp_gradient_get_color_at (gradient, seg->left, &seg->left_color);
gimp_gradient_get_color_at (gradient, seg->right, &seg->right_color);
gimp_gradient_get_color_at (gradient, seg->left, FALSE, &seg->left_color);
gimp_gradient_get_color_at (gradient, seg->right, FALSE, &seg->right_color);
seg->type = lseg->type;
seg->color = lseg->color;
......
......@@ -82,6 +82,7 @@ gboolean gimp_gradient_save_as_pov (GimpGradient *gradient,
void gimp_gradient_get_color_at (GimpGradient *gradient,
gdouble pos,
gboolean reverse,
GimpRGB *color);
GimpGradientSegment * gimp_gradient_get_segment_at (GimpGradient *grad,
gdouble pos);
......
......@@ -44,6 +44,7 @@
GimpPalette *
gimp_palette_import_from_gradient (GimpGradient *gradient,
gboolean reverse,
const gchar *palette_name,
gint n_colors)
{
......@@ -62,7 +63,7 @@ gimp_palette_import_from_gradient (GimpGradient *gradient,
for (loop = 0, cur_x = 0; loop < n_colors; loop++, cur_x += dx)
{
gimp_gradient_get_color_at (gradient, cur_x, &color);
gimp_gradient_get_color_at (gradient, cur_x, reverse, &color);
gimp_palette_add_entry (palette, NULL, &color);
}
......@@ -88,9 +89,9 @@ struct _ImgColors
static gint count_color_entries = 0;
static GHashTable *
gimp_palette_import_store_colors (GHashTable *h_array,
gimp_palette_import_store_colors (GHashTable *h_array,
guchar *colors,
guchar *colors_real,
guchar *colors_real,
gint n_colors)
{
gpointer found_color = NULL;
......@@ -206,8 +207,8 @@ gimp_palette_import_create_image_palette (gpointer data,
/* Adjust the colors to the mean of the the sample */
gimp_rgba_set_uchar
(&color,
(guchar) color_tab->r + (color_tab->r_adj / color_tab->count),
(guchar) color_tab->g + (color_tab->g_adj / color_tab->count),
(guchar) color_tab->r + (color_tab->r_adj / color_tab->count),
(guchar) color_tab->g + (color_tab->g_adj / color_tab->count),
(guchar) color_tab->b + (color_tab->b_adj / color_tab->count),
255);
......
......@@ -21,6 +21,7 @@
GimpPalette * gimp_palette_import_from_gradient (GimpGradient *gradient,
gboolean reverse,
const gchar *palette_name,
gint n_colors);
GimpPalette * gimp_palette_import_from_image (GimpImage *gimage,
......
......@@ -599,6 +599,7 @@ palette_import_make_palette (ImportDialog *import_dialog)
{
case GRADIENT_IMPORT:
palette = gimp_palette_import_from_gradient (gradient,
FALSE,
palette_name,
n_colors);
break;
......@@ -606,7 +607,7 @@ palette_import_make_palette (ImportDialog *import_dialog)
case IMAGE_IMPORT:
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
palette =
palette =
gimp_palette_import_from_indexed_image (gimage,
palette_name);
}
......
......@@ -161,7 +161,7 @@ gradient_select_free (GradientSelect *gsp)
if (gsp->context)
g_object_unref (gsp->context);
g_free (gsp);
}
......@@ -199,7 +199,7 @@ gradient_select_dialogs_check (void)
if (gsp->callback_name)
{
if (! procedural_db_lookup (gsp->context->gimp, gsp->callback_name))
gradient_select_close_callback (NULL, gsp);
gradient_select_close_callback (NULL, gsp);
}
}
}
......@@ -228,7 +228,7 @@ gradient_select_change_callbacks (GradientSelect *gsp,
if (proc && gradient)
{
Argument *return_vals;
Argument *return_vals;
gint nreturn_vals;
gdouble *values, *pv;
double pos, delta;
......@@ -238,13 +238,13 @@ gradient_select_change_callbacks (GradientSelect *gsp,
i = gsp->sample_size;
pos = 0.0;
delta = 1.0 / (i - 1);
values = g_new (gdouble, 4 * i);
pv = values;
while (i--)
{
gimp_gradient_get_color_at (gradient, pos, &color);
gimp_gradient_get_color_at (gradient, pos, FALSE, &color);
*pv++ = color.r;
*pv++ = color.g;
......@@ -263,7 +263,7 @@ gradient_select_change_callbacks (GradientSelect *gsp,
GIMP_PDB_FLOATARRAY, values,
GIMP_PDB_INT32, (gint) closing,
GIMP_PDB_END);
if (!return_vals || return_vals[0].value.pdb_int != GIMP_PDB_SUCCESS)
g_message (_("Unable to run gradient callback.\n"
"The corresponding plug-in may have crashed."));
......
......@@ -599,6 +599,7 @@ palette_import_make_palette (ImportDialog *import_dialog)
{
case GRADIENT_IMPORT:
palette = gimp_palette_import_from_gradient (gradient,
FALSE,
palette_name,
n_colors);
break;
......@@ -606,7 +607,7 @@ palette_import_make_palette (ImportDialog *import_dialog)
case IMAGE_IMPORT:
if (gimp_image_base_type (gimage) == GIMP_INDEXED)
{
palette =
palette =
gimp_palette_import_from_indexed_image (gimage,
palette_name);
}
......
......@@ -143,8 +143,8 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
GimpGradientOptions *gradient_options;
GimpContext *context;
GimpImage *gimage;
GimpRGB gradient_color;
TempBuf *area;
gdouble gradient_length;
guchar col[MAX_CHANNELS];
gdouble scale;
GimpPaintApplicationMode paint_appl_mode;
......@@ -166,35 +166,6 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->application_mode;
if (gradient_options->use_gradient)
{
gdouble unit_factor;
switch (gradient_options->gradient_unit)
{
case GIMP_UNIT_PIXEL:
gradient_length = gradient_options->gradient_length;
break;
case GIMP_UNIT_PERCENT:
gradient_length = (MAX (gimage->width, gimage->height) *
gradient_options->gradient_length / 100);
break;
default:
unit_factor = gimp_unit_get_factor (gradient_options->gradient_unit);
gradient_length = (gradient_options->gradient_length *
MAX (gimage->xresolution,
gimage->yresolution) / unit_factor);
break;
}
}
else
{
gradient_length = 0.0;
}
if (pressure_options->color)
gradient_length = 1.0; /* not really used, only for if cases */
if (pressure_options->size)
scale = paint_core->cur_coords.pressure