added GimpHSV type and functions and gimp_rgb_composite functions

2001-01-14  Sven Neumann  <sven@gimp.org>

	* libgimp/gimpcolor.[ch]: added GimpHSV type and functions and
	gimp_rgb_composite functions

	* libgimp/gimpcolorbutton.c: indentation

	* libgimp/gimpcolorspace.[ch]: added GimpRGB <-> GimpHSV conversion
	routines

	* libgimp/gimpwidgets.[ch]: removed gimp_color_update_uchar function

	* plug-ins/Lighting/lighting_main.[ch]
	* plug-ins/Lighting/lighting_preview.c
	* plug-ins/Lighting/lighting_shade.c
	* plug-ins/MapObject/mapobject_image.c
	* plug-ins/MapObject/mapobject_main.[ch]
	* plug-ins/MapObject/mapobject_shade.c
	* plug-ins/common/mapcolor.c
	* plug-ins/common/nova.c
	* plug-ins/common/papertile.c
	* plug-ins/common/sinus.c
	* plug-ins/ifscompose/ifscompose.c
	* plug-ins/script-fu/script-fu-scripts.c: use GimpRGB and GimpHSV
This commit is contained in:
Sven Neumann 2001-01-14 20:25:46 +00:00 committed by Sven Neumann
parent f504187d5e
commit 70c1ecfdb6
26 changed files with 817 additions and 854 deletions

View File

@ -1,3 +1,28 @@
2001-01-14 Sven Neumann <sven@gimp.org>
* libgimp/gimpcolor.[ch]: added GimpHSV type and functions and
gimp_rgb_composite functions
* libgimp/gimpcolorbutton.c: indentation
* libgimp/gimpcolorspace.[ch]: added GimpRGB <-> GimpHSV conversion
routines
* libgimp/gimpwidgets.[ch]: removed gimp_color_update_uchar function
* plug-ins/Lighting/lighting_main.[ch]
* plug-ins/Lighting/lighting_preview.c
* plug-ins/Lighting/lighting_shade.c
* plug-ins/MapObject/mapobject_image.c
* plug-ins/MapObject/mapobject_main.[ch]
* plug-ins/MapObject/mapobject_shade.c
* plug-ins/common/mapcolor.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/sinus.c
* plug-ins/ifscompose/ifscompose.c
* plug-ins/script-fu/script-fu-scripts.c: use GimpRGB and GimpHSV
2001-01-14 Michael Natterer <mitch@gimp.org>
* app/channel.[ch]

View File

@ -46,6 +46,15 @@ gimp_rgb_set (GimpRGB *rgb,
rgb->b = b;
}
void
gimp_rgb_set_alpha (GimpRGB *rgb,
gdouble a)
{
g_return_if_fail (rgb != NULL);
rgb->a = a;
}
void
gimp_rgb_set_uchar (GimpRGB *rgb,
guchar r,
@ -143,6 +152,7 @@ gimp_rgb_clamp (GimpRGB *rgb)
rgb->r = CLAMP (rgb->r, 0.0, 1.0);
rgb->g = CLAMP (rgb->g, 0.0, 1.0);
rgb->b = CLAMP (rgb->b, 0.0, 1.0);
rgb->a = CLAMP (rgb->a, 0.0, 1.0);
}
void
@ -173,6 +183,41 @@ gimp_rgb_intensity (const GimpRGB *rgb)
INTENSITY_BLUE * rgb->b);
}
void
gimp_rgb_composite (GimpRGB *color1,
const GimpRGB *color2,
GimpRGBCompositeMode mode)
{
gdouble factor;
g_return_if_fail (color1 != NULL);
g_return_if_fail (color2 != NULL);
switch (mode)
{
case GIMP_RGB_COMPOSITE_NONE:
break;
case GIMP_RGB_COMPOSITE_NORMAL:
/* put color2 on top of color1 */
factor = color1->a * (1.0 - color2->a);
color1->r = color1->r * factor + color2->r * color2->a;
color1->g = color1->g * factor + color2->g * color2->a;
color1->b = color1->b * factor + color2->b * color2->a;
color1->a = factor + color2->a;
break;
case GIMP_RGB_COMPOSITE_BEHIND:
/* put color2 below color1 */
factor = color2->a * (1.0 - color1->a);
color1->r = color2->r * factor + color1->r * color1->a;
color1->g = color2->g * factor + color1->g * color1->a;
color1->b = color2->b * factor + color1->b * color1->a;
color1->a = factor + color1->a;
break;
}
}
/* RGBA functions */
void
@ -269,55 +314,52 @@ gimp_rgba_distance (const GimpRGB *rgba1,
fabs (rgba1->b - rgba2->b) + fabs (rgba1->a - rgba2->a));
}
/* These two are probably not needed */
gdouble
gimp_rgba_max (const GimpRGB *rgba)
/* HSV functions */
void
gimp_hsv_set (GimpHSV *hsv,
gdouble h,
gdouble s,
gdouble v)
{
g_return_val_if_fail (rgba != NULL, 0.0);
g_return_if_fail (hsv != NULL);
return MAX (rgba->r, MAX (rgba->g, MAX (rgba->b, rgba->a)));
}
gdouble
gimp_rgba_min (const GimpRGB *rgba)
{
g_return_val_if_fail (rgba != NULL, 0.0);
return MIN (rgba->r, MIN (rgba->g, MIN (rgba->b, rgba->a)));
hsv->h = h;
hsv->s = s;
hsv->v = v;
}
void
gimp_rgba_clamp (GimpRGB *rgba)
gimp_hsv_clamp (GimpHSV *hsv)
{
g_return_if_fail (rgba != NULL);
g_return_if_fail (hsv != NULL);
rgba->r = CLAMP (rgba->r, 0.0, 1.0);
rgba->g = CLAMP (rgba->g, 0.0, 1.0);
rgba->b = CLAMP (rgba->b, 0.0, 1.0);
rgba->a = CLAMP (rgba->a, 0.0, 1.0);
if (hsv->h < 0.0)
hsv->h = GIMP_HSV_UNDEFINED;
hsv->h -= (gint) hsv->h;
hsv->s = CLAMP (hsv->s, 0.0, 1.0);
hsv->v = CLAMP (hsv->v, 0.0, 1.0);
hsv->a = CLAMP (hsv->a, 0.0, 1.0);
}
void
gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma)
gimp_hsva_set (GimpHSV *hsva,
gdouble h,
gdouble s,
gdouble v,
gdouble a)
{
gdouble ig;
g_return_if_fail (hsva != NULL);
g_return_if_fail (rgba != NULL);
if (gamma != 0.0)
ig = 1.0 / gamma;
else
(ig = 0.0);
rgba->r = pow (rgba->r, ig);
rgba->g = pow (rgba->g, ig);
rgba->b = pow (rgba->b, ig);
rgba->a = pow (rgba->a, ig);
hsva->h = h;
hsva->s = s;
hsva->v = v;
hsva->a = a;
}
/* These functions will become the default one day */
gboolean
@ -348,3 +390,30 @@ gimp_palette_get_foreground_rgb (GimpRGB *rgb)
return FALSE;
}
gboolean
gimp_palette_set_background_rgb (const GimpRGB *rgb)
{
guchar r, g, b;
g_return_val_if_fail (rgb != NULL, FALSE);
gimp_rgb_get_uchar (rgb, &r, &g, &b);
return gimp_palette_set_background (r, g, b);
}
gboolean
gimp_palette_get_background_rgb (GimpRGB *rgb)
{
guchar r, g, b;
g_return_val_if_fail (rgb != NULL, FALSE);
if (gimp_palette_get_background (&r, &g, &b))
{
gimp_rgb_set_uchar (rgb, r, g, b);
return TRUE;
}
return FALSE;
}

View File

@ -36,11 +36,27 @@ struct _GimpRGB
gdouble r, g, b, a;
};
typedef struct _GimpHSV GimpHSV;
struct _GimpHSV
{
gdouble h, s, v, a;
};
typedef enum
{
GIMP_RGB_COMPOSITE_NONE = 0,
GIMP_RGB_COMPOSITE_NORMAL,
GIMP_RGB_COMPOSITE_BEHIND
} GimpRGBCompositeMode;
void gimp_rgb_set (GimpRGB *rgb,
gdouble r,
gdouble g,
gdouble b);
void gimp_rgb_set_alpha (GimpRGB *rgb,
gdouble a);
void gimp_rgb_set_uchar (GimpRGB *rgb,
guchar r,
guchar g,
@ -65,6 +81,9 @@ void gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma);
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
void gimp_rgb_composite (GimpRGB *color1,
const GimpRGB *color2,
GimpRGBCompositeMode mode);
void gimp_rgba_set (GimpRGB *rgba,
gdouble r,
@ -90,17 +109,25 @@ void gimp_rgba_multiply (GimpRGB *rgba,
gdouble factor);
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
const GimpRGB *rgba2);
gdouble gimp_rgba_max (const GimpRGB *rgba);
gdouble gimp_rgba_min (const GimpRGB *rgba);
void gimp_rgba_clamp (GimpRGB *rgba);
void gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma);
void gimp_hsv_set (GimpHSV *hsv,
gdouble h,
gdouble s,
gdouble v);
void gimp_hsv_clamp (GimpHSV *hsv);
/* These will become the default one day */
void gimp_hsva_set (GimpHSV *hsva,
gdouble h,
gdouble s,
gdouble v,
gdouble a);
/* These will become the default one day */
gboolean gimp_palette_set_foreground_rgb (const GimpRGB *rgb);
gboolean gimp_palette_get_foreground_rgb (GimpRGB *rgb);
gboolean gimp_palette_set_background_rgb (const GimpRGB *rgb);
gboolean gimp_palette_get_background_rgb (GimpRGB *rgb);
#ifdef __cplusplus

View File

@ -46,31 +46,31 @@ struct _GimpColorButton
};
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static void gimp_color_button_color_changed (GtkObject *object,
gpointer data);
static void gimp_color_button_color_changed (GtkObject *object,
gpointer data);
static GtkItemFactoryEntry menu_items[] =

View File

@ -33,125 +33,118 @@
void
gimp_rgb_to_hsv (GimpRGB *rgb,
gdouble *hue,
gdouble *saturation,
gdouble *value)
GimpHSV *hsv)
{
gdouble max, min, delta;
g_return_if_fail (rgb != NULL);
g_return_if_fail (hue != NULL);
g_return_if_fail (saturation != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (hsv != NULL);
max = gimp_rgb_max (rgb);
min = gimp_rgb_min (rgb);
*value = max;
if (max != 0.0)
{
*saturation = (max - min) / max;
}
else
{
*saturation = 0.0;
}
hsv->v = max;
if (*saturation == 0.0)
{
*hue = GIMP_HSV_UNDEFINED;
}
else
if (max != 0.0)
{
delta = max - min;
hsv->s = delta / max;
if (rgb->r == max)
{
*hue = (rgb->g - rgb->b) / delta;
hsv->h = (rgb->g - rgb->b) / delta;
}
else if (rgb->g == max)
{
*hue = 2.0 + (rgb->b - rgb->r) / delta;
hsv->h = 2.0 + (rgb->b - rgb->r) / delta;
}
else if (rgb->b == max)
{
*hue = 4.0 + (rgb->r - rgb->g) / delta;
hsv->h = 4.0 + (rgb->r - rgb->g) / delta;
}
*hue = *hue * 60.0;
hsv->h /= 6.0;
if (*hue < 0.0)
*hue = *hue + 360;
if (hsv->h < 0.0)
hsv->h += 1.0;
else if (hsv->h > 1.0)
hsv->h -= 1.0;
}
else
{
hsv->s = 0.0;
hsv->h = GIMP_HSV_UNDEFINED;
}
hsv->a = rgb->a;
}
void
gimp_hsv_to_rgb (gdouble hue,
gdouble saturation,
gdouble value,
gimp_hsv_to_rgb (GimpHSV *hsv,
GimpRGB *rgb)
{
gint i;
gdouble f, w, q, t;
g_return_if_fail (rgb != NULL);
g_return_if_fail (hsv != NULL);
if (saturation == 0.0)
if (hsv->s == 0.0 || hsv->h == GIMP_HSV_UNDEFINED)
{
if (hue == GIMP_HSV_UNDEFINED)
{
rgb->r = value;
rgb->g = value;
rgb->b = value;
}
rgb->r = hsv->v;
rgb->g = hsv->v;
rgb->b = hsv->v;
}
else
{
if (hue == 360.0)
hue = 0.0;
if (hsv->h == 1.0)
hsv->h = 0.0;
hue = hue / 60.0;
hsv->h *= 6.0;
i = (gint) hue;
f = hue - i;
w = value * (1.0 - saturation);
q = value * (1.0 - (saturation * f));
t = value * (1.0 - (saturation * (1.0 - f)));
i = (gint) hsv->h;
f = hsv->h - i;
w = hsv->v * (1.0 - hsv->s);
q = hsv->v * (1.0 - (hsv->s * f));
t = hsv->v * (1.0 - (hsv->s * (1.0 - f)));
switch (i)
{
case 0:
rgb->r = value;
rgb->r = hsv->v;
rgb->g = t;
rgb->b = w;
break;
case 1:
rgb->r = q;
rgb->g = value;
rgb->g = hsv->v;
rgb->b = w;
break;
case 2:
rgb->r = w;
rgb->g = value;
rgb->g = hsv->v;
rgb->b = t;
break;
case 3:
rgb->r = w;
rgb->g = q;
rgb->b = value;
rgb->b = hsv->v;
break;
case 4:
rgb->r = t;
rgb->g = w;
rgb->b = value;
rgb->b = hsv->v;
break;
case 5:
rgb->r = value;
rgb->r = hsv->v;
rgb->g = w;
rgb->b = q;
break;
}
}
rgb->a = hsv->a;
}
void

View File

@ -36,18 +36,16 @@ extern "C" {
#define GIMP_HSL_UNDEFINED -1.0
void gimp_rgb_to_hsv (GimpRGB *rgb,
gdouble *hue,
gdouble *saturation,
gdouble *value);
GimpHSV *hsv);
void gimp_rgb_to_hsl (GimpRGB *rgb,
gdouble *hue,
gdouble *saturation,
gdouble *lightness);
void gimp_hsv_to_rgb (gdouble hue,
gdouble saturation,
gdouble value,
void gimp_hsv_to_rgb (GimpHSV *hsv,
GimpRGB *rgb);
void gimp_hsl_to_rgb (gdouble hue,
gdouble saturation,
gdouble lightness,

View File

@ -27,8 +27,6 @@
#include "gimptypes.h"
#include "gimpuitypes.h"
#include "gimpcolorarea.h"
#include "gimpcolorbutton.h"
#include "gimpchainbutton.h"
#include "gimphelpui.h"
#include "gimppixmap.h"
@ -1339,50 +1337,6 @@ gimp_unit_menu_update (GtkWidget *widget,
}
}
/**
* gimp_color_update:
* @widget: A pointer to a #GimpColorArea or #GimpColorButton.
* @data: A pointer to an array of #guchar that will be set to the new color.
*
* This function will go away.
**/
void
gimp_color_update_uchar (GtkWidget *widget,
gpointer data)
{
GimpRGB color;
gboolean alpha;
guchar *dest;
g_return_if_fail (widget != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (GIMP_IS_COLOR_AREA (widget) ||
GIMP_IS_COLOR_BUTTON (widget));
if (GIMP_IS_COLOR_AREA (widget))
{
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
alpha = gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget));
}
else if (GIMP_IS_COLOR_BUTTON (widget))
{
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
alpha = gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (widget));
}
else
return;
dest = (guchar *) data;
*dest++ = color.r * 255.999;
*dest++ = color.g * 255.999;
*dest++ = color.b * 255.999;
if (alpha)
*dest++ = color.a * 255.999;
}
/*
* Helper Functions

View File

@ -227,8 +227,6 @@ void gimp_double_adjustment_update (GtkAdjustment *adjustment,
void gimp_unit_menu_update (GtkWidget *widget,
gpointer data);
void gimp_color_update_uchar (GtkWidget *widget,
gpointer data);
/*
* Helper Functions

View File

@ -46,31 +46,31 @@ struct _GimpColorButton
};
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_destroy (GtkObject *object);
static void gimp_color_button_clicked (GtkButton *button);
static void gimp_color_button_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_ok (GtkWidget *widget,
gpointer data);
static void gimp_color_button_dialog_cancel (GtkWidget *widget,
gpointer data);
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_fg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static void gimp_color_button_use_bg (gpointer callback_data,
guint callback_action,
GtkWidget *widget);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static gint gimp_color_button_menu_popup (GtkWidget *widget,
GdkEvent *event,
gpointer data);
static gchar * gimp_color_button_menu_translate (const gchar *path,
gpointer func_data);
static void gimp_color_button_color_changed (GtkObject *object,
gpointer data);
static void gimp_color_button_color_changed (GtkObject *object,
gpointer data);
static GtkItemFactoryEntry menu_items[] =

View File

@ -27,8 +27,6 @@
#include "gimptypes.h"
#include "gimpuitypes.h"
#include "gimpcolorarea.h"
#include "gimpcolorbutton.h"
#include "gimpchainbutton.h"
#include "gimphelpui.h"
#include "gimppixmap.h"
@ -1339,50 +1337,6 @@ gimp_unit_menu_update (GtkWidget *widget,
}
}
/**
* gimp_color_update:
* @widget: A pointer to a #GimpColorArea or #GimpColorButton.
* @data: A pointer to an array of #guchar that will be set to the new color.
*
* This function will go away.
**/
void
gimp_color_update_uchar (GtkWidget *widget,
gpointer data)
{
GimpRGB color;
gboolean alpha;
guchar *dest;
g_return_if_fail (widget != NULL);
g_return_if_fail (data != NULL);
g_return_if_fail (GIMP_IS_COLOR_AREA (widget) ||
GIMP_IS_COLOR_BUTTON (widget));
if (GIMP_IS_COLOR_AREA (widget))
{
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
alpha = gimp_color_area_has_alpha (GIMP_COLOR_AREA (widget));
}
else if (GIMP_IS_COLOR_BUTTON (widget))
{
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
alpha = gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (widget));
}
else
return;
dest = (guchar *) data;
*dest++ = color.r * 255.999;
*dest++ = color.g * 255.999;
*dest++ = color.b * 255.999;
if (alpha)
*dest++ = color.a * 255.999;
}
/*
* Helper Functions

View File

@ -227,8 +227,6 @@ void gimp_double_adjustment_update (GtkAdjustment *adjustment,
void gimp_unit_menu_update (GtkWidget *widget,
gpointer data);
void gimp_color_update_uchar (GtkWidget *widget,
gpointer data);
/*
* Helper Functions

View File

@ -54,7 +54,7 @@ set_default_settings (void)
gimp_vector3_set (&mapvals.lightsource.position, 1.0, 0.0, 1.0);
gimp_vector3_set (&mapvals.lightsource.direction, -1.0, -1.0, 1.0);
gimp_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
gimp_rgba_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0, 1.0);
mapvals.lightsource.intensity = 1.0;
mapvals.lightsource.type = POINT_LIGHT;
@ -260,9 +260,10 @@ run (gchar *name,
mapvals.env_mapped = (gint) param[6].data.d_int32;
mapvals.bumpmaptype = (gint) param[7].data.d_int32;
mapvals.lightsource.type = (LightType) param[8].data.d_int32;
mapvals.lightsource.color.r = param[9].data.d_color.red;
mapvals.lightsource.color.g = param[9].data.d_color.green;
mapvals.lightsource.color.b = param[9].data.d_color.blue;
gimp_rgb_set (&mapvals.lightsource.color,
param[9].data.d_color.red,
param[9].data.d_color.green,
param[9].data.d_color.blue);
mapvals.lightsource.position.x = param[10].data.d_float;
mapvals.lightsource.position.y = param[11].data.d_float;
mapvals.lightsource.position.z = param[12].data.d_float;

View File

@ -96,6 +96,5 @@ typedef struct
/* ============================ */
extern LightingValues mapvals;
extern GimpRGB background;
#endif /* __LIGHTING_MAIN_H__ */

View File

@ -212,11 +212,8 @@ blah (void)
gck_rgba_set(&background,0.0,0.0,0.0,0.0);
else
{
gimp_palette_get_background(&r,&g,&b);
background.r=(gdouble)r/255.0;
background.g=(gdouble)g/255.0;
background.b=(gdouble)b/255.0;
background.a=1.0;
gimp_palette_get_background_rgb (&background);
gimp_rgb_set_alpha (&background, 1.0);
}
gck_rgb_set(&lightcheck,0.75,0.75,0.75);

View File

@ -458,7 +458,7 @@ get_ray_color (GimpVector3 *position)
if (mapvals.transparent_background && heights[1][x] == 0)
{
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
else
{
@ -510,7 +510,7 @@ get_ray_color_ref (GimpVector3 *position)
if (mapvals.transparent_background && heights[1][x] == 0)
{
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
else
{
@ -574,7 +574,7 @@ get_ray_color_no_bilinear (GimpVector3 *position)
if (mapvals.transparent_background && heights[1][x] == 0)
{
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
else
{
@ -626,7 +626,7 @@ get_ray_color_no_bilinear_ref (GimpVector3 *position)
if (mapvals.transparent_background && heights[1][x] == 0)
{
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
else
{

View File

@ -347,7 +347,6 @@ image_setup (GimpDrawable *drawable,
gint interactive)
{
glong numbytes;
guchar r, g, b;
/* Set the tile cache size */
/* ======================= */
@ -378,11 +377,8 @@ image_setup (GimpDrawable *drawable,
}
else
{
gimp_palette_get_background (&r,&g,&b);
background.r = (gdouble) r / 255.0;
background.g = (gdouble) g / 255.0;
background.b = (gdouble) b / 255.0;
background.a = 1.0;
gimp_palette_get_background_rgb (&background);
gimp_rgb_set_alpha (&background, 1.0);
}
/* Assume at least RGB */

View File

@ -89,7 +89,7 @@ set_default_settings (void)
mapvals.tooltips_enabled = TRUE;
mapvals.lightsource.intensity = 1.0;
gimp_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
gimp_rgba_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0, 1.0);
mapvals.material.ambient_int = 0.3;
mapvals.material.diffuse_int = 1.0;
@ -297,9 +297,10 @@ run (gchar *name,
mapvals.beta = param[17].data.d_float;
mapvals.gamma = param[18].data.d_float;
mapvals.lightsource.type = (LightType) param[19].data.d_int32;
mapvals.lightsource.color.r = param[20].data.d_color.red;
mapvals.lightsource.color.g = param[20].data.d_color.green;
mapvals.lightsource.color.b = param[20].data.d_color.blue;
gimp_rgb_set_uchar (&mapvals.lightsource.color,
param[20].data.d_color.red,
param[20].data.d_color.green,
param[20].data.d_color.blue);
mapvals.lightsource.position.x = param[21].data.d_float;
mapvals.lightsource.position.y = param[22].data.d_float;
mapvals.lightsource.position.z = param[23].data.d_float;

View File

@ -82,6 +82,5 @@ typedef struct
/* ============================ */
extern MapObjectValues mapvals;
extern GimpRGB background;
#endif /* __MAPOBJECT_MAIN_H__ */

View File

@ -201,7 +201,7 @@ get_ray_color_plane (GimpVector3 *pos)
{
color = get_image_color (vx, vy, &inside);
if (color.a!=0.0 && inside == TRUE &&
if (color.a != 0.0 && inside == TRUE &&
mapvals.lightsource.type != NO_LIGHT)
{
/* Compute shading at this point */
@ -320,9 +320,9 @@ sphere_intersect (GimpVector3 *dir,
GimpRGB
get_ray_color_sphere (GimpVector3 *pos)
{
GimpRGB color=background;
GimpRGB color = background;
static GimpRGB color2;
static GimpRGB color2;
static gint inside = FALSE;
static GimpVector3 normal, ray, spos1, spos2;
static gdouble vx, vy;
@ -369,7 +369,7 @@ get_ray_color_sphere (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
gimp_vector3_sub (&normal, &spos2, &mapvals.position);
gimp_vector3_normalize (&normal);
@ -389,28 +389,21 @@ get_ray_color_sphere (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color2);
gimp_rgb_clamp (&color2);
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
color2.r = (color2.r*color2.a)+(background.r*(1.0-color2.a));
color2.g = (color2.g*color2.a)+(background.g*(1.0-color2.a));
color2.b = (color2.b*color2.a)+(background.b*(1.0-color2.a));
color2.a = 1.0;
}
{
gimp_rgb_composite (&color2, &background, GIMP_RGB_COMPOSITE_BEHIND);
}
/* Compute a mix of the first and second colors */
/* ============================================ */
color.r = color.r*color.a+(1.0-color.a)*color2.r;
color.g = color.g*color.a+(1.0-color.a)*color2.g;
color.b = color.b*color.a+(1.0-color.a)*color2.b;
color.a = color.a+color2.a;
gimp_rgba_clamp (&color);
gimp_rgb_composite (&color, &color2, GIMP_RGB_COMPOSITE_NORMAL);
gimp_rgb_clamp (&color);
}
else if (color.a!=0.0 &&
inside==TRUE &&
else if (color.a != 0.0 &&
inside == TRUE &&
mapvals.lightsource.type!=NO_LIGHT)
{
/* Compute shading at this point */
@ -424,7 +417,7 @@ get_ray_color_sphere (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
}
}
@ -931,7 +924,7 @@ get_ray_color_box (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
color2 = get_box_image_color (face_intersect[1].face,
face_intersect[1].u,
@ -950,25 +943,19 @@ get_ray_color_box (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color2);
gimp_rgb_clamp (&color2);
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
color2.r = (color2.r * color2.a) + (background.r * (1.0-color2.a));
color2.g = (color2.g * color2.a) + (background.g * (1.0-color2.a));
color2.b = (color2.b * color2.a) + (background.b * (1.0-color2.a));
color2.a = 1.0;
}
gimp_rgb_composite (&color2, &background,
GIMP_RGB_COMPOSITE_BEHIND);
}
/* Compute a mix of the first and second colors */
/* ============================================ */
color.r = color.r * color.a + (1.0 - color.a) * color2.r;
color.g = color.g * color.a + (1.0 - color.a) * color2.g;
color.b = color.b * color.a + (1.0 - color.a) * color2.b;
color.a = color.a + color2.a;
gimp_rgba_clamp (&color);
gimp_rgb_composite (&color, &color2, GIMP_RGB_COMPOSITE_NORMAL);
gimp_rgb_clamp (&color);
}
else if (color.a != 0.0 && mapvals.lightsource.type != NO_LIGHT)
{
@ -980,13 +967,13 @@ get_ray_color_box (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
}
}
else
{
if (mapvals.transparent_background == TRUE)
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
return color;
@ -1216,7 +1203,7 @@ get_ray_color_cylinder (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
color2 = get_cylinder_color (face_intersect[1].face,
face_intersect[1].u,
@ -1235,25 +1222,19 @@ get_ray_color_cylinder (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color2);
gimp_rgb_clamp (&color2);
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
{
color2.r = (color2.r*color2.a) + (background.r*(1.0-color2.a));
color2.g = (color2.g*color2.a) + (background.g*(1.0-color2.a));
color2.b = (color2.b*color2.a) + (background.b*(1.0-color2.a));
color2.a = 1.0;
gimp_rgb_composite (&color2, &background,
GIMP_RGB_COMPOSITE_BEHIND);
}
/* Compute a mix of the first and second colors */
/* ============================================ */
color.r = color.r*color.a + (1.0-color.a)*color2.r;
color.g = color.g*color.a + (1.0-color.a)*color2.g;
color.b = color.b*color.a + (1.0-color.a)*color2.b;
color.a = color.a+color2.a;
gimp_rgba_clamp (&color);
gimp_rgb_composite (&color, &color2, GIMP_RGB_COMPOSITE_NORMAL);
gimp_rgb_clamp (&color);
}
else if (color.a != 0.0 && mapvals.lightsource.type != NO_LIGHT)
{
@ -1265,13 +1246,13 @@ get_ray_color_cylinder (GimpVector3 *pos)
&mapvals.lightsource.color,
mapvals.lightsource.type);
gimp_rgba_clamp (&color);
gimp_rgb_clamp (&color);
}
}
else
{
if (mapvals.transparent_background == TRUE)
color.a = 0.0;
gimp_rgb_set_alpha (&color, 0.0);
}
return color;

View File

@ -53,17 +53,17 @@ static char ident[] = "@(#) GIMP mapcolor plug-in v1.03 22-May-00";
typedef struct
{
guchar colors[4][3];
gint32 map_mode;
GimpRGB colors[4];
gint32 map_mode;
} PluginValues;
PluginValues plvals =
{
{
{ 0, 0, 0},
{ 255, 255, 255 },
{ 0, 0, 0 },
{ 255, 255, 255 }
{ 0.0, 0.0, 0.0, 1.0 },
{ 1.0, 1.0, 1.0, 1.0 },
{ 0.0, 0.0, 0.0, 1.0 },
{ 1.0, 1.0, 1.0, 1.0 },
},
0
};
@ -115,14 +115,17 @@ static IMG_PREVIEW *img_preview_create_from_drawable (guint maxsize,
static void update_img_preview (void);
static gboolean dialog (gint32 drawable_ID);
static gboolean dialog (gint32 drawable_ID);
static void mapcolor_ok_callback (GtkWidget *widget,
gpointer data);
static void get_mapping (guchar *src_col1, guchar *src_col2,
guchar *dst_col1, guchar *dst_col2, gint32 map_mode,
guchar *redmap, guchar *greenmap, guchar *bluemap);
static void color_button_color_changed_callback (GtkWidget *widget,
gpointer data);
static void get_mapping (GimpRGB *src_col1,
GimpRGB *src_col2,
GimpRGB *dst_col1,
GimpRGB *dst_col2,
gint32 map_mode,
guchar *redmap,
guchar *greenmap,
guchar *bluemap);
static void add_color_button (gint csel_index,
gint left,
gint top,
@ -147,21 +150,23 @@ static PLInterface plinterface;
/* Allocate image preview structure and preview memory */
static IMG_PREVIEW *
img_preview_alloc (guint width, guint height)
img_preview_alloc (guint width,
guint height)
{IMG_PREVIEW *ip;
{
IMG_PREVIEW *ip;
ip = (IMG_PREVIEW *)g_malloc (sizeof (IMG_PREVIEW));
ip->img = (guchar *)g_malloc (width*height*3);
if (ip->img == NULL)
{
g_free (ip);
return NULL;
}
ip->width = width;
ip->height = height;
return ip;
ip = (IMG_PREVIEW *)g_malloc (sizeof (IMG_PREVIEW));
ip->img = (guchar *)g_malloc (width*height*3);
if (ip->img == NULL)
{
g_free (ip);
return NULL;
}
ip->width = width;
ip->height = height;
return ip;
}
@ -183,12 +188,14 @@ img_preview_free (IMG_PREVIEW *ip)
}
/* Copy image preview. Create/modify destinataion preview */
/* Copy image preview. Create/modify destination preview */
static void
img_preview_copy (IMG_PREVIEW *src, IMG_PREVIEW **dst)
img_preview_copy (IMG_PREVIEW *src,
IMG_PREVIEW **dst)
{int numbytes;
IMG_PREVIEW *dst_p;
{
gint numbytes;
IMG_PREVIEW *dst_p;
if ((src == NULL) || (src->img == NULL) || (dst == NULL)) return;
@ -234,7 +241,7 @@ img_preview_create_from_drawable (guint maxsize,
guint prv_width, prv_height;
gint src_x, src_y, x, y;
guchar *prv_data, *img_data, *cu_row;
double xfactor, yfactor;
gdouble xfactor, yfactor;
gint tile_height, row_start, row_end;
gint bpp;
IMG_PREVIEW *ip;
@ -416,17 +423,11 @@ run (gchar *name,
break;
}
c = &(plvals.colors[0][0]); /* First source color */
gimp_palette_get_foreground (c, c+1, c+2);
gimp_palette_get_foreground_rgb (plvals.colors);
gimp_palette_get_background_rgb (plvals.colors + 1);
c = &(plvals.colors[1][0]); /* Second source color */
gimp_palette_get_background (c, c+1, c+2);
c = &(plvals.colors[2][0]); /* First destination color */
c[0] = c[1] = c[2] = 0; /* Foreground mapped to black */
c = &(plvals.colors[3][0]); /* Second destination color */
c[0] = c[1] = c[2] = 255; /* Background mapped to white */
gimp_rgb_set (plvals.colors + 2, 0.0, 0.0, 0.0);
gimp_rgb_set (plvals.colors + 3, 1.0, 1.0, 1.0);
plvals.map_mode = 0;
@ -449,9 +450,10 @@ run (gchar *name,
for (j = 0; j < 4; j++)
{
plvals.colors[j][0] = param[3+j].data.d_color.red;
plvals.colors[j][1] = param[3+j].data.d_color.green;
plvals.colors[j][2] = param[3+j].data.d_color.blue;
gimp_rgb_set_uchar (plvals.colors + j,
param[3+j].data.d_color.red,
param[3+j].data.d_color.green,
param[3+j].data.d_color.blue);
}
plvals.map_mode = param[7].data.d_int32;
}
@ -459,11 +461,8 @@ run (gchar *name,
{
gimp_get_data (name, &plvals);
c = &(plvals.colors[0][0]); /* First source color */
gimp_palette_get_foreground (c, c+1, c+2);
c = &(plvals.colors[1][0]); /* Second source color */
gimp_palette_get_background (c, c+1, c+2);
gimp_palette_get_foreground_rgb (plvals.colors);
gimp_palette_get_background_rgb (plvals.colors + 1);
if (!dialog (param[2].data.d_drawable))
break;
@ -502,39 +501,42 @@ run (gchar *name,
static void
update_img_preview (void)
{IMG_PREVIEW *dst_ip = plinterface.map_preview;
IMG_PREVIEW *src_ip = plinterface.img_preview;
guchar *src, *dst;
GtkWidget *preview = plinterface.preview;
int j;
unsigned char redmap[256], greenmap[256], bluemap[256];
unsigned char *src_col1 = plvals.colors[0];
unsigned char *src_col2 = plvals.colors[1];
unsigned char *dst_col1 = plvals.colors[2];
unsigned char *dst_col2 = plvals.colors[3];
{
IMG_PREVIEW *dst_ip = plinterface.map_preview;
IMG_PREVIEW *src_ip = plinterface.img_preview;
GtkWidget *preview = plinterface.preview;
guchar redmap[256], greenmap[256], bluemap[256];
guchar *src, *dst;
gint j;
if ((dst_ip == NULL) || (src_ip == NULL)) return;
get_mapping (plvals.colors,
plvals.colors + 1,
plvals.colors + 2,
plvals.colors + 3,
plvals.map_mode,
redmap, greenmap, bluemap);
j = dst_ip->width*dst_ip->height;
src = src_ip->img;
dst = dst_ip->img;
if ((dst_ip == NULL) || (src_ip == NULL)) return;
while (j-- > 0)
{
*(dst++) = redmap[*(src++)];
*(dst++) = greenmap[*(src++)];
*(dst++) = bluemap[*(src++)];
}
get_mapping (src_col1, src_col2, dst_col1, dst_col2, plvals.map_mode,
redmap, greenmap, bluemap);
for (j = 0; j < dst_ip->height; j++)
gtk_preview_draw_row (GTK_PREVIEW (preview),
dst_ip->img + dst_ip->width*3*j,
0, j, dst_ip->width);
j = dst_ip->width*dst_ip->height;
src = src_ip->img;
dst = dst_ip->img;
while (j-- > 0)
{
*(dst++) = redmap[*(src++)];
*(dst++) = greenmap[*(src++)];
*(dst++) = bluemap[*(src++)];
}
for (j = 0; j < dst_ip->height; j++)
gtk_preview_draw_row (GTK_PREVIEW (preview), dst_ip->img + dst_ip->width*3*j,
0, j, dst_ip->width);
gtk_widget_draw (preview, NULL);
gdk_flush ();
gtk_widget_queue_draw (preview);
}
static gboolean
dialog (gint32 drawable_ID)
{
@ -631,14 +633,6 @@ dialog (gint32 drawable_ID)
return run_flag;
}
static void
color_button_color_changed_callback (GtkWidget *widget,
gpointer data)
{
update_img_preview ();
}
static void
add_color_button (gint csel_index,
gint left,
@ -648,7 +642,6 @@ add_color_button (gint csel_index,
{
GtkWidget *label;
GtkWidget *button;
GimpRGB color;
label = gtk_label_new ((left == 0) ? _("From:") : _("To:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
@ -656,19 +649,14 @@ add_color_button (gint csel_index,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
gimp_rgb_set (&color,
(gdouble) plvals.colors[csel_index][0] / 255.0,
(gdouble) plvals.colors[csel_index][1] / 255.0,
(gdouble) plvals.colors[csel_index][2] / 255.0);
button = gimp_color_button_new (gettext (csel_title[csel_index]),
PRV_WIDTH, PRV_HEIGHT,
&color, FALSE);
&plvals.colors[csel_index], FALSE);
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
(GtkSignalFunc) gimp_color_update_uchar,
plvals.colors[csel_index]);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
&plvals.colors[csel_index]);
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
GTK_SIGNAL_FUNC (color_button_color_changed_callback),
GTK_SIGNAL_FUNC (update_img_preview),
NULL);
gtk_table_attach (GTK_TABLE (table), button, left+1, left+2, top, top+1,
GTK_FILL, GTK_FILL, 0, 0);
@ -691,17 +679,21 @@ mapcolor_ok_callback (GtkWidget *widget,
}
static void
get_mapping (guchar *src_col1,
guchar *src_col2,
guchar *dst_col1,
guchar *dst_col2,
gint32 map_mode,
guchar *redmap,
guchar *greenmap,
guchar *bluemap)
get_mapping (GimpRGB *src_col1,
GimpRGB *src_col2,
GimpRGB *dst_col1,
GimpRGB *dst_col2,
gint32 map_mode,
guchar *redmap,
guchar *greenmap,
guchar *bluemap)
{
int rgb, i, j, a, as, b, bs;
guchar src1[3];
guchar src2[3];
guchar dst1[3];
guchar dst2[3];
gint rgb, i, j, a, as, b, bs;
guchar *colormap[3];
/* Currently we always do a linear mapping */
@ -710,21 +702,24 @@ get_mapping (guchar *src_col1,
colormap[1] = greenmap;
colormap[2] = bluemap;
gimp_rgb_get_uchar (src_col1, src1, src1 + 1, src1 + 2);
gimp_rgb_get_uchar (src_col2, src2, src2 + 1, src2 + 2);
gimp_rgb_get_uchar (dst_col1, dst1, dst1 + 1, dst1 + 2);
gimp_rgb_get_uchar (dst_col2, dst2, dst2 + 1, dst2 + 2);
switch (map_mode)
{
case 0:
default:
for (rgb = 0; rgb < 3; rgb++)
{
a = src_col1[rgb]; as = dst_col1[rgb];
b = src_col2[rgb]; bs = dst_col2[rgb];
if (b == a) b = a+1;
a = src1[rgb]; as = dst1[rgb];
b = src2[rgb]; bs = dst2[rgb];
if (b == a)
b = a + 1;
for (i = 0; i < 256; i++)
{
j = ((i - a) * (bs - as)) / (b - a) + as;
if (j > 255) j = 255; else if (j < 0) j = 0;
colormap[rgb][i] = j;
}
j = CLAMP (((i - a) * (bs - as)) / (b - a) + as, 0, 255);
}
break;
}
@ -734,21 +729,19 @@ static void
color_mapping (GimpDrawable *drawable)
{
int processed, total;
gint x, y, xmin, xmax, ymin, ymax, bpp = (gint)drawable->bpp;
unsigned char *src, *dest;
GimpPixelRgn src_rgn, dest_rgn;
gint processed, total;
guint x, y, xmin, xmax, ymin, ymax;
guint bpp = drawable->bpp;
guchar *src;
guchar *dest;
GimpPixelRgn src_rgn;
GimpPixelRgn dest_rgn;
gpointer pr;
double progress;
unsigned char redmap[256], greenmap[256], bluemap[256];
unsigned char *src_col1 = plvals.colors[0];
unsigned char *src_col2 = plvals.colors[1];
unsigned char *dst_col1 = plvals.colors[2];
unsigned char *dst_col2 = plvals.colors[3];
gdouble progress;
guchar redmap[256], greenmap[256], bluemap[256];
if ( (src_col1[0] == src_col2[0])
|| (src_col1[1] == src_col2[1])
|| (src_col1[2] == src_col2[2])) return;
if (gimp_rgb_distance (&plvals.colors[0], &plvals.colors[1]) < 0.0001)
return;
if (!gimp_drawable_is_rgb (drawable->id))
{
@ -768,11 +761,16 @@ color_mapping (GimpDrawable *drawable)
pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
get_mapping (src_col1, src_col2, dst_col1, dst_col2, plvals.map_mode,
get_mapping (plvals.colors,
plvals.colors + 1,
plvals.colors + 2,
plvals.colors + 3,
plvals.map_mode,
redmap, greenmap, bluemap);
processed = 0;
progress = 0.0;
progress = 0.0;
for (; pr != NULL; pr = gimp_pixel_rgns_process (pr))
{
for (y = 0; y < src_rgn.h; y++)
@ -792,9 +790,9 @@ color_mapping (GimpDrawable *drawable)
}
if (l_run_mode != GIMP_RUN_NONINTERACTIVE)
{
if ((double)processed/(double)total - progress > 0.1)
if ((gdouble) processed / (gdouble) total - progress > 0.1)
{
progress = (double)processed/(double)total;
progress = (gdouble) processed / (gdouble) total;
gimp_progress_update (progress);
}
}
@ -804,5 +802,6 @@ color_mapping (GimpDrawable *drawable)
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->id, TRUE);
gimp_drawable_update (drawable->id, xmin, ymin, (xmax - xmin), (ymax - ymin));
gimp_drawable_update (drawable->id,
xmin, ymin, (xmax - xmin), (ymax - ymin));
}

View File

@ -22,7 +22,6 @@
/*
* version 1.200
* This plug-in requires GIMP v0.99.10 or above.
*
* This plug-in produces an effect like a supernova burst.
*
@ -110,8 +109,9 @@ static gboolean show_cursor = FALSE;
typedef struct
{
gint xcenter, ycenter;
guchar color[3];
gint xcenter;
gint ycenter;
GimpRGB color;
gint radius;
gint nspoke;
gint randomhue;
@ -125,39 +125,39 @@ typedef struct
typedef struct
{
GimpDrawable *drawable;
gint dwidth;
gint dheight;
gint bpp;
GtkObject *xadj;
GtkObject *yadj;
gint cursor;
gint curx, cury; /* x,y of cursor in preview */
gint oldx, oldy;
gint in_call;
gint dwidth;
gint dheight;
gint bpp;
GtkObject *xadj;
GtkObject *yadj;
gint cursor;
gint curx, cury; /* x,y of cursor in preview */
gint oldx, oldy;
gboolean in_call;
} NovaCenter;
/* Declare a local function.
*/
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void fill_preview_with_thumb (GtkWidget *preview_widget,
gint32 drawable_ID);
static void fill_preview_with_thumb (GtkWidget *preview_widget,
gint32 drawable_ID);
static GtkWidget *preview_widget (GimpDrawable *drawable);
static void nova (GimpDrawable *drawable,
gboolean preview_mode);
gboolean preview_mode);
static gint nova_dialog (GimpDrawable *drawable);
static void nova_ok_callback (GtkWidget *widget,
gpointer data);
static void nova_ok_callback (GtkWidget *widget,
gpointer data);
static GtkWidget * nova_center_create (GimpDrawable *drawable);
static GtkWidget * nova_center_create (GimpDrawable *drawable);
static void nova_center_destroy (GtkWidget *widget,
gpointer data);
static void nova_center_draw (NovaCenter *center,
@ -182,11 +182,11 @@ GimpPlugInInfo PLUG_IN_INFO =
static NovaValues pvals =
{
128, 128, /* xcenter, ycenter */
{ 90, 100, 255 }, /* color */
20, /* radius */
100, /* nspoke */
0 /* random hue */
128, 128, /* xcenter, ycenter */
{ 0.35, 0.39, 1.0, 1.0 }, /* color */
20, /* radius */
100, /* nspoke */
0 /* random hue */
};
static NovaInterface pint =
@ -232,16 +232,16 @@ query (void)
}
static void
run (gchar *name,
gint nparams,
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpDrawable *drawable;
GimpRunModeType run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
static GimpParam values[1];
GimpDrawable *drawable;
GimpRunModeType run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
INIT_I18N_UI();
@ -278,13 +278,15 @@ run (gchar *name,
{
pvals.xcenter = param[3].data.d_int32;
pvals.ycenter = param[4].data.d_int32;
pvals.color[0] = param[5].data.d_color.red;
pvals.color[1] = param[5].data.d_color.green;
pvals.color[2] = param[5].data.d_color.blue;
gimp_rgb_set_uchar (&pvals.color,
param[5].data.d_color.red,
param[5].data.d_color.green,
param[5].data.d_color.blue);
pvals.radius = param[6].data.d_int32;
pvals.nspoke = param[7].data.d_int32;
pvals.randomhue = param[8].data.d_int32;
}
if ((status == GIMP_PDB_SUCCESS) &&
pvals.radius <= 0)
status = GIMP_PDB_CALLING_ERROR;
@ -338,7 +340,10 @@ preview_widget (GimpDrawable *drawable)
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
fill_preview_with_thumb (preview, drawable->id);
size = GTK_PREVIEW (preview)->rowstride * GTK_PREVIEW (preview)->buffer_height;
size = GTK_PREVIEW (preview)->rowstride *
GTK_PREVIEW (preview)->buffer_height;
preview_bits = g_malloc (size);
memcpy (preview_bits, GTK_PREVIEW (preview)->buffer, size);
@ -355,7 +360,7 @@ fill_preview_with_thumb (GtkWidget *widget,
gint width = PREVIEW_SIZE;
gint height = PREVIEW_SIZE;
guchar *src;
gdouble r, g, b, a;
GimpRGB color;
gdouble c0, c1;
guchar *p0, *p1;
guchar *even, *odd;
@ -369,13 +374,17 @@ fill_preview_with_thumb (GtkWidget *widget,
return;
gtk_preview_size (GTK_PREVIEW (widget), width, height);
preview_scale_x = (gdouble)width / (gdouble)gimp_drawable_width (drawable_ID);
preview_scale_y = (gdouble)height / (gdouble)gimp_drawable_height (drawable_ID);
preview_scale_x =
(gdouble) width / (gdouble) gimp_drawable_width (drawable_ID);
preview_scale_y =
(gdouble) height / (gdouble) gimp_drawable_height (drawable_ID);
even = g_malloc (width * 3);
odd = g_malloc (width * 3);
src = drawable_data;
gimp_rgba_set (&color, 1.0, 1.0, 1.0, 1.0);
for (y = 0; y < height; y++)
{
p0 = even;
@ -383,28 +392,36 @@ fill_preview_with_thumb (GtkWidget *widget,
for (x = 0; x < width; x++)
{
if(bpp == 4)
switch (bpp)
{
r = ((gdouble)src[x*4+0])/255.0;
g = ((gdouble)src[x*4+1])/255.0;
b = ((gdouble)src[x*4+2])/255.0;
a = ((gdouble)src[x*4+3])/255.0;
}
else if(bpp == 3)
{
r = ((gdouble)src[x*3+0])/255.0;
g = ((gdouble)src[x*3+1])/255.0;
b = ((gdouble)src[x*3+2])/255.0;
a = 1.0;
}
else
{
r = ((gdouble)src[x*bpp+0])/255.0;
g = b = r;
if(bpp == 2)
a = ((gdouble)src[x*bpp+1])/255.0;
else
a = 1.0;
case 4:
gimp_rgba_set_uchar (&color,
src[x*4+0],
src[x*4+1],
src[x*4+2],
src[x*4+3]);
break;
case 3:
gimp_rgb_set_uchar (&color,
src[x*3+0],
src[x*3+1],
src[x*3+2]);
break;
case 2:
gimp_rgba_set_uchar (&color,
src[x*2+0],
src[x*2+0],
src[x*2+0],
src[x*2+1]);
break;
case 1:
gimp_rgb_set_uchar (&color,
src[x*2+0],
src[x*2+0],
src[x*2+0]);
}
if ((x / GIMP_CHECK_SIZE_SM) & 1)
@ -418,20 +435,22 @@ fill_preview_with_thumb (GtkWidget *widget,
c1 = GIMP_CHECK_LIGHT;
}
*p0++ = (c0 + (r - c0) * a) * 255.0;
*p0++ = (c0 + (g - c0) * a) * 255.0;
*p0++ = (c0 + (b - c0) * a) * 255.0;
*p0++ = (c0 + (color.r - c0) * color.a) * 255.0;
*p0++ = (c0 + (color.g - c0) * color.a) * 255.0;
*p0++ = (c0 + (color.b - c0) * color.a) * 255.0;
*p1++ = (c1 + (r - c1) * a) * 255.0;
*p1++ = (c1 + (g - c1) * a) * 255.0;
*p1++ = (c1 + (b - c1) * a) * 255.0;
*p1++ = (c1 + (color.r - c1) * color.a) * 255.0;
*p1++ = (c1 + (color.g - c1) * color.a) * 255.0;
*p1++ = (c1 + (color.b - c1) * color.a) * 255.0;
} /* for */
if ((y / GIMP_CHECK_SIZE_SM) & 1)
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)odd, 0, y, width);
gtk_preview_draw_row (GTK_PREVIEW (widget),
(guchar *)odd, 0, y, width);
else
gtk_preview_draw_row (GTK_PREVIEW (widget), (guchar *)even, 0, y, width);
gtk_preview_draw_row (GTK_PREVIEW (widget),
(guchar *)even, 0, y, width);
src += width * bpp;
}
@ -455,7 +474,6 @@ nova_dialog (GimpDrawable *drawable)
GtkWidget *button;
GtkWidget *center_frame;
GtkObject *adj;
GimpRGB color;
gimp_ui_init ("nova", TRUE);
@ -491,16 +509,12 @@ nova_dialog (GimpDrawable *drawable)
gtk_table_attach (GTK_TABLE (table), center_frame, 0, 3, 0, 1,
0, 0, 0, 0);
gimp_rgb_set (&color,
(gdouble) pvals.color[0] / 255.0,
(gdouble) pvals.color[1] / 255.0,
(gdouble) pvals.color[2] / 255.0);
button = gimp_color_button_new (_("SuperNova Color Picker"),
SCALE_WIDTH - 8, 16,
&color, FALSE);
&pvals.color, FALSE);
gtk_signal_connect (GTK_OBJECT (button), "color_changed",
(GtkSignalFunc) gimp_color_update_uchar,
pvals.color);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
&pvals.color);
gtk_signal_connect_object (GTK_OBJECT (button), "color_changed",
GTK_SIGNAL_FUNC (nova),
(gpointer)drawable);
@ -740,7 +754,7 @@ nova_center_draw (NovaCenter *center,
gdk_draw_line (preview->window,
preview->style->black_gc,
1, center->oldy,
(GTK_PREVIEW (preview)->buffer_width)-1, center->oldy);
(GTK_PREVIEW (preview)->buffer_width) - 1, center->oldy);
}
gdk_draw_line (preview->window,
@ -750,8 +764,9 @@ nova_center_draw (NovaCenter *center,
gdk_draw_line (preview->window,
preview->style->black_gc,
1, center->cury,
(GTK_PREVIEW (preview)->buffer_width)-1, center->cury);
(GTK_PREVIEW (preview)->buffer_width) - 1, center->cury);
}
/* current position of cursor is updated */
center->oldx = center->curx;
center->oldy = center->cury;
@ -790,8 +805,10 @@ nova_center_adjustment_update (GtkAdjustment *adjustment,
static void
nova_center_cursor_update (NovaCenter *center)
{
center->curx = pvals.xcenter * GTK_PREVIEW (preview)->buffer_width / center->dwidth;
center->cury = pvals.ycenter * GTK_PREVIEW (preview)->buffer_height / center->dheight;
center->curx = pvals.xcenter *
GTK_PREVIEW (preview)->buffer_width / center->dwidth;
center->cury = pvals.ycenter *
GTK_PREVIEW (preview)->buffer_height / center->dheight;
if (center->curx < 0)
center->curx = 0;
@ -894,67 +911,64 @@ gauss (void)
static void
nova (GimpDrawable *drawable,
gboolean preview_mode)
gboolean preview_mode)
{
GimpPixelRgn src_rgn, dest_rgn;
gpointer pr;
guchar *src_row, *dest_row;
guchar *src, *dest, *save_dest;
gint x1, y1, x2, y2;
gint row, col;
gint x, y;
gint alpha, has_alpha, bpp;
gint progress, max_progress;
/****************/
gint xc, yc; /* center of image */
gdouble u, v;
gdouble l, l0;
gdouble w, w1, c;
gdouble *spoke;
gdouble nova_alpha;
gdouble src_alpha;
gdouble new_alpha;
gdouble compl_ratio;
gdouble ratio;
gdouble h, s;
gdouble spokecol;
gint i, j;
gint color[4];
guchar *spokecolor;
GimpPixelRgn src_rgn;
GimpPixelRgn dest_rgn;
guchar *src_row, *dest_row;
guchar *src, *dest;
gint x1, y1, x2, y2;
gint row, col;
gint x, y;
gint alpha, bpp;
gint progress, max_progress;
gboolean has_alpha;
gint xc, yc; /* center of nova */
gdouble u, v;
gdouble l;
gdouble w, w1, c;
gdouble *spoke;
gdouble nova_alpha;
GimpRGB color;
GimpRGB src_color;
GimpRGB *spokecolor;
GimpHSV hsv;
gint i;
/* initialize */
new_alpha = 0.0;
has_alpha = gimp_drawable_has_alpha (drawable->id);
srand (time (NULL));
spoke = g_new (gdouble, pvals.nspoke);
spokecolor = g_new (guchar, 3 * pvals.nspoke);
spokecolor = g_new (GimpRGB, pvals.nspoke);
gimp_rgb_to_hsv4 (pvals.color, &h, &s, &v);
gimp_rgb_set_alpha (&pvals.color, 1.0);
gimp_rgb_to_hsv (&pvals.color, &hsv);
for (i = 0; i < pvals.nspoke; i++)
{
spoke[i] = gauss();
h += ((gdouble) pvals.randomhue / 360.0 *
((gdouble) rand() / (gdouble) G_MAXRAND - 0.5));
if (h < 0)
h += 1.0;
else if (h >= 1.0)
h -= 1.0;
gimp_hsv_to_rgb4 (&spokecolor[3*i], h, s, v);
hsv.h += ((gdouble) pvals.randomhue / 360.0) *
((gdouble) rand() / (gdouble) G_MAXRAND - 0.5);
if (hsv.h < 0)
hsv.h += 1.0;
else if (hsv.h >= 1.0)
hsv.h -= 1.0;
gimp_hsv_to_rgb (&hsv, spokecolor + i);
}
has_alpha = gimp_drawable_has_alpha (drawable->id);
if (preview_mode)
{
xc = (gdouble)pvals.xcenter * preview_scale_x;
yc = (gdouble)pvals.ycenter * preview_scale_y;
xc = (gdouble) pvals.xcenter * preview_scale_x;
yc = (gdouble) pvals.ycenter * preview_scale_y;
x1 = y1 = 0;
x2 = GTK_PREVIEW (preview)->buffer_width;
y2 = GTK_PREVIEW (preview)->buffer_height;
bpp = GTK_PREVIEW (preview)->bpp;
has_alpha = 0;
has_alpha = FALSE;
alpha = bpp;
}
else
@ -965,95 +979,89 @@ nova (GimpDrawable *drawable,
xc = pvals.xcenter;
yc = pvals.ycenter;
gimp_pixel_rgn_init (&src_rgn, drawable, x1, y1, x2-x1, y2-y1, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, x2-x1, y2-y1, TRUE, TRUE);
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, x2-x1, y2-y1, FALSE, FALSE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
x1, y1, x2-x1, y2-y1, TRUE, TRUE);
}
l0 = (x2-xc)/4+1; /* standard length */
/* Initialize progress */
progress = 0;
progress = 0;
max_progress = (x2 - x1) * (y2 - y1);
if (preview_mode)
{
/* thanks to this pixel rgn register
stuff, i have to duplicate the
entire loop. why not just use
get_row??? */
src_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
src_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
memcpy (src_row, preview_bits, y2 * GTK_PREVIEW (preview)->rowstride);
dest_row = g_malloc (y2 * GTK_PREVIEW (preview)->rowstride);
save_dest = dest_row;
dest_row = g_malloc (GTK_PREVIEW (preview)->rowstride);
for (row = 0, y = 0; row < y2; row++, y++)
{
src = src_row;
src = src_row;
dest = dest_row;
for (col = 0, x = 0; col < x2; col++, x++)
{
u = (gdouble) (x-xc) / (pvals.radius * preview_scale_x);
v = (gdouble) (y-yc) / (pvals.radius * preview_scale_y);
l = sqrt(u*u + v*v);
u = (gdouble) (x - xc) / (pvals.radius * preview_scale_x);
v = (gdouble) (y - yc) / (pvals.radius * preview_scale_y);
l = sqrt (u*u + v*v);
/* This algorithm is still under construction. */
c = (atan2 (u, v) / (2 * G_PI) + .51) * pvals.nspoke;
i = (int) floor (c);
i = (gint) floor (c);
c -= i;
i %= pvals.nspoke;
w1 = spoke[i] * (1 - c) + spoke[(i + 1) % pvals.nspoke] * c;
w1 = w1 * w1;
w = 1/(l+0.001)*0.9;
w = 1.0 / (l + 0.001) * 0.9;
nova_alpha = CLAMP (w, 0.0, 1.0);
/* blend two neighbored spokecolors */
color = spokecolor[i];
gimp_rgb_set_alpha (&color, 1.0);
gimp_rgb_set_alpha (spokecolor + ((i + 1) % pvals.nspoke), c);
gimp_rgb_composite (&color,
spokecolor + (i + 1) % pvals.nspoke,
GIMP_RGB_COMPOSITE_NORMAL);
if (has_alpha)
{
src_alpha = (gdouble) src[alpha] / 255.0;
new_alpha = src_alpha + (1.0 - src_alpha) * nova_alpha;
if (new_alpha != 0.0)
ratio = nova_alpha / new_alpha;
else
ratio = 0.0;
}
else
ratio = nova_alpha;
compl_ratio = 1.0 - ratio;
for (j = 0; j < alpha; j++)
{
spokecol = (gdouble)spokecolor[3*i+j]*(1.0-c) +
(gdouble)spokecolor[3*((i + 1) % pvals.nspoke)+j]*c;
if (w > 1.0)
color[j] = CLAMP (spokecol * w, 0, 255);
else
color[j] = src[j] * compl_ratio + spokecol * ratio;
c = CLAMP (w1 * w, 0, 1);
color[j] = color[j] + 255 * c;
dest[j]= CLAMP (color[j], 0, 255);
}
if (has_alpha)
dest[alpha] = new_alpha * 255.0;
src += bpp;
if (w > 1.0)
{
gimp_rgb_multiply (&color, w);
gimp_rgb_clamp (&color);
}
else
{
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], 1.0);
gimp_rgb_set_alpha (&color, nova_alpha);
gimp_rgb_composite (&color, &src_color,
GIMP_RGB_COMPOSITE_BEHIND);
}
/* c = CLAMP (w1 * w, 0.0, 1.0); */
/* gimp_rgb_add (&color, c); */
gimp_rgb_get_uchar (&color,
dest, dest + 1, dest + 2);
src += bpp;
dest += bpp;
}
src_row += GTK_PREVIEW (preview)->rowstride;
dest_row += GTK_PREVIEW (preview)->rowstride;
gtk_preview_draw_row (GTK_PREVIEW (preview), dest_row, 0, row, y2);
}
memcpy (GTK_PREVIEW(preview)->buffer, save_dest, y2 * GTK_PREVIEW (preview)->rowstride);
gtk_widget_queue_draw (preview);
}
else
{ /* normal mode */
#ifdef EEEEK
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL; pr = gimp_pixel_rgns_process (pr))
{
@ -1073,7 +1081,7 @@ nova (GimpDrawable *drawable,
/* This algorithm is still under construction. */
c = (atan2 (u, v) / (2 * G_PI) + .51) * pvals.nspoke;
i = (int) floor (c);
i = (gint) floor (c);
c -= i;
i %= pvals.nspoke;
w1 = spoke[i] * (1 - c) + spoke[(i + 1) % pvals.nspoke] * c;
@ -1083,6 +1091,26 @@ nova (GimpDrawable *drawable,
nova_alpha = CLAMP (w, 0.0, 1.0);
switch (bpp)
{
case 1:
gimp_rgba_set_uchar (&src_color,
src[0], src[0], src[0], 1.0);
break;
case 2:
gimp_rgba_set_uchar (&src_color,
src[0], src[0], src[0], src[1]);
break;
case 3:
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], 1.0);
break;
case 4:
gimp_rgba_set_uchar (&src_color,
src[0], src[1], src[2], src[3]);
break;
}
if (has_alpha)
{
src_alpha = (gdouble) src[alpha] / 255.0;
@ -1125,12 +1153,17 @@ nova (GimpDrawable *drawable,
/* Update progress */
progress += src_rgn.w * src_rgn.h;
gimp_progress_update ((double) progress / (double) max_progress);
gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
}
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->id, TRUE);
gimp_drawable_update (drawable->id, x1, y1, (x2 - x1), (y2 - y1));
#else
gimp_message ("Sorry, the SuperNova effect\n"
"is broken at the moment and\n"
"has been temporarily disabled.");
#endif
}
g_free (spoke);

View File

@ -69,7 +69,7 @@ struct _PluginParams
gboolean centering;
gboolean wrap_around;
BackgroundType background_type;
guchar background_color[4];
GimpRGB background_color;
};
/*============================================================================*/
@ -81,7 +81,7 @@ static struct
PluginParams params;
gint32 image;
GimpDrawable *drawable;
GimpDrawable *drawable;
gboolean drawable_has_alpha;
struct
@ -95,7 +95,7 @@ static struct
} selection;
GimpRunModeType run_mode;
gboolean run;
gboolean run;
} p =
{
{
@ -107,7 +107,7 @@ static struct
TRUE, /* centering */
FALSE, /* wrap_around */
BACKGROUND_TYPE_INVERTED, /* background_type */
{ 0, 0, 255, 255 } /* background_color[4] */
{ 0.0, 0.0, 1.0, 1.0 } /* background_color */
},
0, /* image */
@ -116,7 +116,7 @@ static struct
{ 0, 0, 0, 0, 0, 0 }, /* selection */
GIMP_RUN_INTERACTIVE, /* run_mode */
GIMP_RUN_INTERACTIVE, /* run_mode */
FALSE /* run */
};
@ -155,7 +155,7 @@ params_load_from_gimp (void)
{
p.params.background_type = BACKGROUND_TYPE_INVERTED;
}
p.params.background_color[3] = 255;
gimp_rgb_set_alpha (&p.params.background_color, 1.0);
}
}
@ -239,8 +239,7 @@ open_dialog (void)
GtkWidget *box;
GtkWidget *color_button;
GtkWidget *sep;
GimpRGB color;
gimp_ui_init ("papertile", TRUE);
dialog = gimp_dialog_new (_("Paper Tile"), "papertile",
@ -395,17 +394,12 @@ open_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gimp_rgba_set (&color,
(gdouble) p.params.background_color[0] / 255.0,
(gdouble) p.params.background_color[1] / 255.0,
(gdouble) p.params.background_color[2] / 255.0,
(gdouble) p.params.background_color[3] / 255.0);
color_button = gimp_color_button_new (_("Background Color"), 100, 16,
&color, p.drawable_has_alpha);
&p.params.background_color,
p.drawable_has_alpha);
gtk_signal_connect (GTK_OBJECT (color_button), "color_changed",
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
p.params.background_color);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
&p.params.background_color);
gtk_container_add (GTK_CONTAINER (button), color_button);
gtk_widget_show (color_button);
@ -742,10 +736,8 @@ filter (void)
break;
case BACKGROUND_TYPE_COLOR:
pixel[0] = p.params.background_color[0];
pixel[1] = p.params.background_color[1];
pixel[2] = p.params.background_color[2];
pixel[3] = p.params.background_color[3];
gimp_rgba_get_uchar (&p.params.background_color,
pixel, pixel + 1, pixel + 2, pixel + 3);
for (y = clear_y0; y < clear_y1; y++)
{
for (x = clear_x0; x < clear_x1; x++)
@ -888,18 +880,19 @@ plugin_run (gchar *name,
case GIMP_RUN_NONINTERACTIVE:
if (numof_params == 11)
{
p.params.tile_size = params[3].data.d_int32;
p.params.division_x = p.drawable->width / p.params.tile_size;
p.params.division_y = p.drawable->height / p.params.tile_size;
p.params.move_max_rate = params[4].data.d_float;
p.params.tile_size = params[3].data.d_int32;
p.params.division_x = p.drawable->width / p.params.tile_size;
p.params.division_y = p.drawable->height / p.params.tile_size;
p.params.move_max_rate = params[4].data.d_float;
p.params.fractional_type = (FractionalType)params[5].data.d_int32;
p.params.wrap_around = params[6].data.d_int32;
p.params.centering = params[7].data.d_int32;
p.params.wrap_around = params[6].data.d_int32;
p.params.centering = params[7].data.d_int32;
p.params.background_type = (BackgroundType)params[8].data.d_int32;
p.params.background_color[0] = params[9].data.d_color.red;
p.params.background_color[1] = params[9].data.d_color.green;
p.params.background_color[2] = params[9].data.d_color.blue;
p.params.background_color[3] = params[10].data.d_int32;
gimp_rgba_set_uchar (&p.params.background_color,
params[9].data.d_color.red,
params[9].data.d_color.green,
params[9].data.d_color.blue,
params[10].data.d_int32);
p.run = TRUE;
}
else

View File

@ -1033,8 +1033,8 @@ typedef struct
glong perturbation;
glong colorization;
glong colors;
guchar col1[4];
guchar col2[4];
GimpRGB col1;
GimpRGB col2;
} SinusVals;
static SinusVals svals =
@ -1048,17 +1048,17 @@ static SinusVals svals =
PERTURBED,
LINEAR,
USE_COLORS,
{ 255, 255, 0, 255 },
{ 0, 0, 255, 255 }
{ 1.0, 1.0, 0.0, 1.0 },
{ 0.0, 0.0, 1.0, 1.0 }
};
typedef struct
{
gint height, width;
double c11, c12, c13, c21, c22, c23, c31, c32, c33;
double (*blend) (double );
guchar r, g, b, a;
int dr, dg, db, da;
gint height, width;
gdouble c11, c12, c13, c21, c22, c23, c31, c32, c33;
gdouble (*blend) (double );
guchar r, g, b, a;
gint dr, dg, db, da;
} params;
@ -1216,14 +1216,16 @@ run (gchar *name,
svals.tiling = param[7].data.d_int32;
svals.perturbation = param[8].data.d_int32;
svals.colors = param[9].data.d_int32;
svals.col1[0] = param[10].data.d_color.red;
svals.col1[1] = param[10].data.d_color.green;
svals.col1[2] = param[10].data.d_color.blue;
svals.col2[0] = param[11].data.d_color.red;
svals.col2[1] = param[11].data.d_color.green;
svals.col2[2] = param[11].data.d_color.blue;
svals.col1[3] = param[12].data.d_float * 255.0;
svals.col2[3] = param[13].data.d_float * 255.0;
gimp_rgb_set_uchar (&svals.col1,
param[10].data.d_color.red,
param[10].data.d_color.green,
param[10].data.d_color.blue);
gimp_rgb_set_uchar (&svals.col2,
param[11].data.d_color.red,
param[11].data.d_color.green,
param[11].data.d_color.blue);
gimp_rgb_set_alpha (&svals.col1, param[12].data.d_float);
gimp_rgb_set_alpha (&svals.col2, param[13].data.d_float);
svals.colorization = param[14].data.d_int32;
svals.blend_power = param[15].data.d_float;
}
@ -1274,10 +1276,10 @@ run (gchar *name,
static void
prepare_coef (params *p)
{
typedef struct { guchar r, g, b, a; } type_color;
type_color col1,col2;
double scalex = svals.scalex;
double scaley = svals.scaley;
GimpRGB color1;
GimpRGB color2;
gdouble scalex = svals.scalex;
gdouble scaley = svals.scaley;
srand(svals.seed);
switch (svals.colorization)
@ -1328,44 +1330,38 @@ prepare_coef (params *p)
p->c32= ROUND (p->c32/(2*G_PI))*2*G_PI;
}
col2.a=svals.col2[3];
col1.a=svals.col1[3];
color1 = svals.col1;
color2 = svals.col2;
if (drawable_is_grayscale)
{
col1.r=col1.g=col1.b=255;
col2.r=col2.g=col2.b=0;
gimp_rgb_set (&color1, 1.0, 1.0, 1.0);
gimp_rgb_set (&color2, 0.0, 0.0, 0.0);
}
else
{
switch (svals.colors)
{
case USE_COLORS:
col1.r=svals.col1[0];
col1.g=svals.col1[1];
col1.b=svals.col1[2];
col2.r=svals.col2[0];
col2.g=svals.col2[1];
col2.b=svals.col2[2];
break;
case B_W:
col1.r=col1.g=col1.b=255;
col2.r=col2.g=col2.b=0;
gimp_rgb_set (&color1, 1.0, 1.0, 1.0);
gimp_rgb_set (&color2, 0.0, 0.0, 0.0);
break;
case USE_FG_BG:
gimp_palette_get_foreground(&col2.r, &col2.g, &col2.b);
gimp_palette_get_background(&col1.r, &col1.g, &col1.b);
gimp_palette_get_background_rgb (&color1);
gimp_palette_get_foreground_rgb (&color2);
break;
}
}
p->r = col1.r;
p->g = col1.g;
p->b = col1.b;
p->a = col1.a;
p->dr=(int)col2.r-col1.r;
p->dg=(int)col2.g-col1.g;
p->db=(int)col2.b-col1.b;
p->da=(int)col2.a-col1.a;
gimp_rgba_get_uchar (&color1, &p->r, &p->g, &p->b, &p->a);
gimp_rgba_subtract (&color2, &color1);
p->dr = color2.r * 255.0;
p->dg = color2.g * 255.0;
p->db = color2.b * 255.0;
p->da = color2.a * 255.0;
}
static void
@ -1386,7 +1382,8 @@ sinus (void)
p.height = drawable->height;
bytes = drawable->bpp;
gimp_pixel_rgn_init(&dest_rgn, drawable, ix1, iy1, ix2-ix1, iy2-iy1, TRUE,TRUE);
gimp_pixel_rgn_init (&dest_rgn, drawable,
ix1, iy1, ix2-ix1, iy2-iy1, TRUE,TRUE);
progress = 0;
max_progress = (ix2-ix1)*(iy2-iy1);
@ -1454,26 +1451,26 @@ compute_block_4 (guchar *dest_row,
gint h,
params *p)
{
gint i,j;
double x,y, grey;
guchar *dest;
gint i, j;
gdouble x, y, grey;
guchar *dest;
for (j = y0; j < (y0 + h); j++)
{
y=((double)j)/p->height;
y=((gdouble)j)/p->height;
dest = dest_row;
for (i= x0; i<(x0+w); i++)
{
x=((double)i)/p->width;
x=((gdouble)i)/p->width;
grey = sin(p->c11*x + p->c12*y + p->c13) * (0.5+0.5*sin(p->c31*x + p->c32*y +p->c33)) \
+ sin(p->c21*x + p->c22*y + p->c23) * (0.5-0.5*sin(p->c31*x + p->c32*y +p->c33));
grey=pow(p->blend(svals.cmplx*(0.5+0.5*grey)),exp(svals.blend_power));
*dest++= p->r+(int)(grey*p->dr);
*dest++= p->g+(int)(grey*p->dg);
*dest++= p->b+(int)(grey*p->db);
*dest++= p->a+(int)(grey*p->da);
*dest++= p->r+(gint)(grey*p->dr);
*dest++= p->g+(gint)(grey*p->dg);
*dest++= p->b+(gint)(grey*p->db);
*dest++= p->a+(gint)(grey*p->da);
}
dest_row += rowstride;
}
@ -1488,25 +1485,25 @@ compute_block_3 (guchar *dest_row,
gint h,
params *p)
{
gint i,j;
double x,y, grey;
guchar *dest;
gint i, j;
gdouble x, y, grey;
guchar *dest;
for (j=y0; j<(y0+h); j++)
{
y=((double)j)/p->height;
y=((gdouble)j)/p->height;
dest = dest_row;
for (i= x0; i<(x0+w); i++)
{
x=((double)i)/p->width;
x=((gdouble)i)/p->width;
grey = sin(p->c11*x + p->c12*y + p->c13) * (0.5+0.5*sin(p->c31*x + p->c32*y +p->c33)) \
+ sin(p->c21*x + p->c22*y + p->c23) * (0.5-0.5*sin(p->c31*x + p->c32*y +p->c33));
grey=pow(p->blend(svals.cmplx*(0.5+0.5*grey)),exp(svals.blend_power));
*dest++= p->r+(int)(grey*p->dr);
*dest++= p->g+(int)(grey*p->dg);
*dest++= p->b+(int)(grey*p->db);
*dest++= p->r+(gint)(grey*p->dr);
*dest++= p->g+(gint)(grey*p->dg);
*dest++= p->b+(gint)(grey*p->db);
}
dest_row += rowstride;
}
@ -1521,24 +1518,24 @@ compute_block_2 (guchar *dest_row,
gint h,
params *p)
{
gint i,j;
double x,y, grey;
guchar *dest;
gint i, j;
gdouble x, y, grey;
guchar *dest;
for (j=y0; j<(y0+h); j++)
{
y=((double)j)/p->height;
y=((gdouble)j)/p->height;
dest = dest_row;
for (i= x0; i<(x0+w); i++)
{
x=((double)i)/p->width;
x=((gdouble)i)/p->width;
grey = sin(p->c11*x + p->c12*y + p->c13) * (0.5+0.5*sin(p->c31*x + p->c32*y +p->c33)) \
+ sin(p->c21*x + p->c22*y + p->c23) * (0.5-0.5*sin(p->c31*x + p->c32*y +p->c33));
grey=pow(p->blend(svals.cmplx*(0.5+0.5*grey)),exp(svals.blend_power));
*dest++= (guchar)(grey*255.0);
*dest++= p->a+(int)(grey*p->da);
*dest++= p->a+(gint)(grey*p->da);
}
dest_row += rowstride;
}
@ -1583,18 +1580,16 @@ static void
alpha_scale_cb (GtkAdjustment *adj,
gpointer data)
{
guchar *val;
GtkWidget *color_button;
GimpRGB color;
GimpColorButton *color_button;
GimpRGB color;
val = (guchar*) data;
if (!data)
return;
*val = (guchar)(adj->value * 255.0);
color_button = gtk_object_get_user_data (GTK_OBJECT (adj));
color_button = GIMP_COLOR_BUTTON (data);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (color_button), &color);
color.a = adj->value;
gimp_rgb_set_alpha (&color, adj->value);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (color_button), &color);
}
@ -1602,15 +1597,13 @@ static void
alpha_scale_update (GtkWidget *color_button,
gpointer data)
{
guchar *val;
GtkWidget *adj;
GtkObject *adj;
GimpRGB color;
val = (guchar*)data;
adj = GTK_OBJECT (data);
adj = gtk_object_get_user_data (GTK_OBJECT (color_button));
gtk_signal_handler_block_by_data (GTK_OBJECT (adj), data);
gtk_adjustment_set_value (GTK_ADJUSTMENT (adj), (gfloat)(*val) / 255.0);
gtk_signal_handler_unblock_by_data (GTK_OBJECT (adj), data);
gimp_color_button_get_color (GIMP_COLOR_BUTTON (color_button), &color);
gtk_adjustment_set_value (GTK_ADJUSTMENT (adj), color.a);
if (do_preview)
sinus_do_preview (NULL);
@ -1691,10 +1684,9 @@ sinus_dialog (void)
GtkWidget *spinbutton;
GtkObject *adj;
GtkWidget *logo;
GimpRGB color;
gint x, y;
gchar buf[3*100];
gchar buf[3 * 100];
guchar *data;
gint x, y;
gimp_ui_init ("sinus", TRUE);
@ -1900,29 +1892,19 @@ sinus_dialog (void)
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gimp_rgba_set (&color,
(gdouble) svals.col1[0] / 255.0,
(gdouble) svals.col1[1] / 255.0,
(gdouble) svals.col1[2] / 255.0,
(gdouble) svals.col1[3] / 255.0);
push_col1 = gimp_color_button_new (_("First Color"),
32, 32, &color, TRUE);
push_col1 = gimp_color_button_new (_("First Color"), 32, 32,
&svals.col1, TRUE);
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
(GtkSignalFunc) gimp_color_update_uchar,
svals.col1);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
&svals.col1);
gtk_box_pack_start (GTK_BOX (hbox), push_col1, FALSE, FALSE, 0);
gtk_widget_show (push_col1);
gimp_rgba_set (&color,
(gdouble) svals.col2[0] / 255.0,
(gdouble) svals.col2[1] / 255.0,
(gdouble) svals.col2[2] / 255.0,
(gdouble) svals.col2[3] / 255.0);
push_col2 = gimp_color_button_new (_("Second Color"),
32, 32, &color, TRUE);
push_col2 = gimp_color_button_new (_("Second Color"), 32, 32,
&svals.col2, TRUE);
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
(GtkSignalFunc) gimp_color_update_uchar,
svals.col2);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
&svals.col2);
gtk_box_pack_start (GTK_BOX (hbox), push_col2, FALSE, FALSE, 0);
gtk_widget_show (push_col2);
@ -1942,41 +1924,33 @@ sinus_dialog (void)
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("First Color:"), 0, 0,
svals.col1[3] / 255.0, 0.0, 1.0, 0.01, 0.1, 2,
svals.col1.a, 0.0, 1.0, 0.01, 0.1, 2,
TRUE, 0, 0,
NULL, NULL);
gtk_object_set_user_data (GTK_OBJECT (adj), push_col1);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (alpha_scale_cb),
&svals.col1[3]);
push_col1);
if (push_col1)
{
gtk_object_set_user_data (GTK_OBJECT (push_col1), adj);
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
GTK_SIGNAL_FUNC (alpha_scale_update),
&svals.col1[3]);
}
gtk_signal_connect (GTK_OBJECT (push_col1), "color_changed",
GTK_SIGNAL_FUNC (alpha_scale_update),
adj);
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Second Color:"), 0, 0,
svals.col2[3] / 255.0, 0.0, 1.0, 0.01, 0.1, 2,
svals.col2.a, 0.0, 1.0, 0.01, 0.1, 2,
TRUE, 0, 0,
NULL, NULL);
gtk_object_set_user_data (GTK_OBJECT (adj), push_col2);
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
GTK_SIGNAL_FUNC (alpha_scale_cb),
&svals.col2[3]);
push_col2);
if (push_col2)
{
gtk_object_set_user_data (GTK_OBJECT (push_col2), adj);
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
GTK_SIGNAL_FUNC (alpha_scale_update),
&svals.col2[3]);
}
gtk_signal_connect (GTK_OBJECT (push_col2), "color_changed",
GTK_SIGNAL_FUNC (alpha_scale_update),
adj);
gtk_widget_show (table);

View File

@ -2430,14 +2430,8 @@ ifs_compose_set_defaults (void)
{
gint i;
GimpRGB color;
guchar r, g, b;
gimp_palette_get_foreground (&r, &g, &b);
gimp_rgb_set (&color,
(gdouble) r / 255.0,
(gdouble) g / 255.0,
(gdouble) b / 255.0);
gimp_palette_get_foreground_rgb (&color);
ifsvals.aspect_ratio = (gdouble)ifsD->drawable_height/ifsD->drawable_width;
@ -2446,33 +2440,32 @@ ifs_compose_set_defaults (void)
count_for_naming = 0;
ifsvals.num_elements = 3;
elements = g_realloc(elements, ifsvals.num_elements*sizeof(AffElement *));
element_selected = g_realloc(element_selected,
ifsvals.num_elements*sizeof(gint));
elements = g_realloc (elements, ifsvals.num_elements * sizeof(AffElement *));
element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof(gint));
elements[0] = aff_element_new(0.3,0.37*ifsvals.aspect_ratio, &color,
++count_for_naming);
elements[0] = aff_element_new (0.3, 0.37 * ifsvals.aspect_ratio, &color,
++count_for_naming);
element_selected[0] = FALSE;
elements[1] = aff_element_new(0.7,0.37*ifsvals.aspect_ratio, &color,
++count_for_naming);
elements[1] = aff_element_new (0.7, 0.37 * ifsvals.aspect_ratio, &color,
++count_for_naming);
element_selected[1] = FALSE;
elements[2] = aff_element_new(0.5,0.7*ifsvals.aspect_ratio, &color,
++count_for_naming);
elements[2] = aff_element_new (0.5, 0.7 * ifsvals.aspect_ratio, &color,
++count_for_naming);
element_selected[2] = FALSE;
ifsvals.center_x = 0.5;
ifsvals.center_y = 0.5*ifsvals.aspect_ratio;
ifsvals.iterations = ifsD->drawable_height*ifsD->drawable_width;
ifsvals.subdivide = 3;
ifsvals.center_x = 0.5;
ifsvals.center_y = 0.5 * ifsvals.aspect_ratio;
ifsvals.iterations = ifsD->drawable_height * ifsD->drawable_width;
ifsvals.subdivide = 3;
ifsvals.max_memory = 4096;
if (ifsOptD)
{
value_pair_update(ifsOptD->iterations_pair);
value_pair_update(ifsOptD->subdivide_pair);
value_pair_update(ifsOptD->radius_pair);
value_pair_update(ifsOptD->memory_pair);
value_pair_update (ifsOptD->iterations_pair);
value_pair_update (ifsOptD->subdivide_pair);
value_pair_update (ifsOptD->radius_pair);
value_pair_update (ifsOptD->memory_pair);
}
ifsvals.radius = 0.7;
@ -2484,7 +2477,7 @@ ifs_compose_set_defaults (void)
if (ifsD->selected_orig)
g_free(ifsD->selected_orig);
ifsD->selected_orig = g_new(AffElement,ifsvals.num_elements);
ifsD->selected_orig = g_new (AffElement, ifsvals.num_elements);
}
static void
@ -2492,51 +2485,46 @@ ifs_compose_defaults_callback (GtkWidget *widget,
gpointer data)
{
gint i;
gdouble width = ifsDesign->area->allocation.width;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
undo_begin();
for (i=0;i<ifsvals.num_elements;i++)
undo_begin ();
for (i = 0; i < ifsvals.num_elements; i++)
undo_update(i);
ifs_compose_set_defaults();
if (ifsD->auto_preview)
ifs_compose_preview_callback(NULL, ifsD->preview);
ifs_compose_preview_callback (NULL, ifsD->preview);
for (i=0;i<ifsvals.num_elements;i++)
aff_element_compute_trans(elements[i],width,height,
ifsvals.center_x, ifsvals.center_y);
for (i = 0; i < ifsvals.num_elements; i++)
aff_element_compute_trans (elements[i], width, height,
ifsvals.center_x, ifsvals.center_y);
design_area_redraw();
design_area_redraw ();
}
static void
ifs_compose_new_callback (GtkWidget *widget,
gpointer data)
{
GimpRGB color;
guchar r, g, b;
gint i;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
GimpRGB color;
gdouble width = ifsDesign->area->allocation.width;
gdouble height = ifsDesign->area->allocation.height;
gint i;
AffElement *elem;
undo_begin();
gimp_palette_get_foreground (&r, &g, &b);
gimp_rgb_set (&color,
(gdouble) r / 255.0,
(gdouble) g / 255.0,
(gdouble) b / 255.0);
gimp_palette_get_foreground_rgb (&color);
elem = aff_element_new(0.5, 0.5*height/width, &color,
++count_for_naming);
elem = aff_element_new (0.5, 0.5 * height / width, &color,
++count_for_naming);
ifsvals.num_elements++;
elements = g_realloc(elements, ifsvals.num_elements*sizeof(AffElement *));
element_selected = g_realloc(element_selected,
ifsvals.num_elements*sizeof(gint));
elements = g_realloc (elements, ifsvals.num_elements * sizeof (AffElement *));
element_selected = g_realloc (element_selected,
ifsvals.num_elements * sizeof (gint));
for (i=0;i<ifsvals.num_elements-1;i++)
element_selected[i] = FALSE;

View File

@ -383,7 +383,7 @@ script_fu_add_script (LISP a)
SFScript *script;
gchar *val;
gint i;
guchar color[3];
guchar r, g, b;
LISP color_list;
LISP adj_list;
LISP brush_list;
@ -532,19 +532,14 @@ script_fu_add_script (LISP a)
if (!TYPEP (car (a), tc_cons))
return my_err ("script-fu-register: color defaults must be a list of 3 integers", NIL);
color_list = car (a);
color[0] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
r = CLAMP (get_c_long (car (color_list)), 0, 255);
color_list = cdr (color_list);
color[1] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
g = CLAMP (get_c_long (car (color_list)), 0, 255);
color_list = cdr (color_list);
color[2] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
b = CLAMP (get_c_long (car (color_list)), 0, 255);
gimp_rgb_set (&script->arg_defaults[i].sfa_color,
color[0] / 255.0,
color[1] / 255.0,
color[2] / 255.0);
gimp_rgb_set_uchar (&script->arg_defaults[i].sfa_color,
r, g, b);
script->arg_values[i].sfa_color =
script->arg_defaults[i].sfa_color;
@ -1703,6 +1698,7 @@ script_fu_ok_callback (GtkWidget *widget,
gchar *text = NULL;
gchar *command;
gchar *c;
guchar r, g, b;
gchar buffer[MAX_STRING_LENGTH];
gint length;
gint i;
@ -1807,10 +1803,8 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_COLOR:
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
(gint) (script->arg_values[i].sfa_color.r * 255.999),
(gint) (script->arg_values[i].sfa_color.g * 255.999),
(gint) (script->arg_values[i].sfa_color.b * 255.999));
gimp_rgb_get_uchar (&script->arg_values[i].sfa_color, &r, &g, &b);
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)", (gint) r, (gint) g, (gint) b);
text = buffer;
break;
@ -2078,8 +2072,7 @@ script_fu_reset_callback (GtkWidget *widget,
break;
case SF_COLOR:
script->arg_values[i].sfa_color =
script->arg_defaults[i].sfa_color;
script->arg_values[i].sfa_color = script->arg_defaults[i].sfa_color;
gimp_color_button_set_color (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]),
&script->arg_values[i].sfa_color);
break;

View File

@ -383,7 +383,7 @@ script_fu_add_script (LISP a)
SFScript *script;
gchar *val;
gint i;
guchar color[3];
guchar r, g, b;
LISP color_list;
LISP adj_list;
LISP brush_list;
@ -532,19 +532,14 @@ script_fu_add_script (LISP a)
if (!TYPEP (car (a), tc_cons))
return my_err ("script-fu-register: color defaults must be a list of 3 integers", NIL);
color_list = car (a);
color[0] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
r = CLAMP (get_c_long (car (color_list)), 0, 255);
color_list = cdr (color_list);
color[1] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
g = CLAMP (get_c_long (car (color_list)), 0, 255);
color_list = cdr (color_list);
color[2] =
(guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
b = CLAMP (get_c_long (car (color_list)), 0, 255);
gimp_rgb_set (&script->arg_defaults[i].sfa_color,
color[0] / 255.0,
color[1] / 255.0,
color[2] / 255.0);
gimp_rgb_set_uchar (&script->arg_defaults[i].sfa_color,
r, g, b);
script->arg_values[i].sfa_color =
script->arg_defaults[i].sfa_color;
@ -1703,6 +1698,7 @@ script_fu_ok_callback (GtkWidget *widget,
gchar *text = NULL;
gchar *command;
gchar *c;
guchar r, g, b;
gchar buffer[MAX_STRING_LENGTH];
gint length;
gint i;
@ -1807,10 +1803,8 @@ script_fu_ok_callback (GtkWidget *widget,
break;
case SF_COLOR:
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)",
(gint) (script->arg_values[i].sfa_color.r * 255.999),
(gint) (script->arg_values[i].sfa_color.g * 255.999),
(gint) (script->arg_values[i].sfa_color.b * 255.999));
gimp_rgb_get_uchar (&script->arg_values[i].sfa_color, &r, &g, &b);
g_snprintf (buffer, sizeof (buffer), "'(%d %d %d)", (gint) r, (gint) g, (gint) b);
text = buffer;
break;
@ -2078,8 +2072,7 @@ script_fu_reset_callback (GtkWidget *widget,
break;
case SF_COLOR:
script->arg_values[i].sfa_color =
script->arg_defaults[i].sfa_color;
script->arg_values[i].sfa_color = script->arg_defaults[i].sfa_color;
gimp_color_button_set_color (GIMP_COLOR_BUTTON (sf_interface->args_widgets[i]),
&script->arg_values[i].sfa_color);
break;