mirror of https://github.com/GNOME/gimp.git
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's
2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
This commit is contained in:
parent
40916e0951
commit
4245ab65d3
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,51 @@
|
|||
2001-01-01 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/libgck/gck/gck.h
|
||||
* plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type
|
||||
and all it's functions.
|
||||
|
||||
* libgimp/Makefile.am
|
||||
* libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color
|
||||
type and assorted functions.
|
||||
|
||||
* libgimp/gimpcolorspace.[ch]: colorspace conversion routines for
|
||||
the new GimpRGB type. Also taken from LibGCK.
|
||||
|
||||
* libgimp/gimp.h
|
||||
* libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include
|
||||
it in both files but unavoidable to follow our new "*.c" file include
|
||||
policy. This will go away as libgimp will be chopped up into pieces
|
||||
anyway.
|
||||
|
||||
* app/apptypes.h
|
||||
* app/asupsample.[ch]
|
||||
* app/blend.c
|
||||
* app/color_transfer.h
|
||||
* app/gradient_header.h: removed "color_t" and use GimpRGB instead.
|
||||
|
||||
* plug-ins/Lighting/lighting_apply.c
|
||||
* plug-ins/Lighting/lighting_image.c
|
||||
* plug-ins/Lighting/lighting_image.h
|
||||
* plug-ins/Lighting/lighting_main.c
|
||||
* plug-ins/Lighting/lighting_main.h
|
||||
* plug-ins/Lighting/lighting_preview.c
|
||||
* plug-ins/Lighting/lighting_shade.c
|
||||
* plug-ins/Lighting/lighting_shade.h
|
||||
* plug-ins/MapObject/mapobject_apply.c
|
||||
* plug-ins/MapObject/mapobject_image.c
|
||||
* plug-ins/MapObject/mapobject_image.h
|
||||
* plug-ins/MapObject/mapobject_main.c
|
||||
* plug-ins/MapObject/mapobject_main.h
|
||||
* plug-ins/MapObject/mapobject_preview.c
|
||||
* plug-ins/MapObject/mapobject_shade.c
|
||||
* plug-ins/MapObject/mapobject_shade.h
|
||||
* modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g
|
||||
|
||||
* plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor
|
||||
version when deciding if to add a missing PDB wrapper.
|
||||
(All this compat cruft including libgimp/gimpcompat.h should go
|
||||
away ASAP)
|
||||
|
||||
2000-12-31 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
More preparation for LibGCK removal:
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
*/
|
||||
|
||||
#include "undo_types.h"
|
||||
|
||||
/* these will go into a general purpose library */
|
||||
#include "libgimp/gimpcolor.h"
|
||||
#include "libgimp/gimpmatrix.h"
|
||||
#include "libgimp/gimpvector.h"
|
||||
#include "libgimp/gimpunit.h"
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
typedef struct
|
||||
{
|
||||
gchar ready;
|
||||
color_t color;
|
||||
GimpRGB color;
|
||||
} sample_t;
|
||||
|
||||
|
||||
|
@ -64,12 +64,9 @@ static gulong render_sub_pixel (gint max_depth,
|
|||
gdouble threshold,
|
||||
gint sub_pixel_size,
|
||||
render_func_t render_func,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
|
||||
static gdouble color_dist (color_t c1,
|
||||
color_t c2);
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
|
@ -91,7 +88,7 @@ adaptive_supersample_area (gint x1,
|
|||
int xt, xtt, yt; /* Temporary counters */
|
||||
int sub_pixel_size; /* Numbe of samples per pixel (1D) */
|
||||
size_t row_size; /* Memory needed for one row */
|
||||
color_t color; /* Rendered pixel's color */
|
||||
GimpRGB color; /* Rendered pixel's color */
|
||||
sample_t tmp_sample; /* For swapping samples */
|
||||
sample_t *top_row, *bot_row, *tmp_row; /* Sample rows */
|
||||
sample_t **block; /* Sample block matrix */
|
||||
|
@ -253,13 +250,13 @@ render_sub_pixel (gint max_depth,
|
|||
double threshold,
|
||||
gint sub_pixel_size,
|
||||
render_func_t render_func,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data)
|
||||
{
|
||||
int x2, y2; /* Coords of center sample */
|
||||
double dx1, dy1; /* Delta to upper left sample */
|
||||
double dx3, dy3; /* Delta to lower right sample */
|
||||
color_t c1, c2, c3, c4; /* Sample colors */
|
||||
GimpRGB c1, c2, c3, c4; /* Sample colors */
|
||||
unsigned long num_samples;
|
||||
|
||||
/* Get offsets for corners */
|
||||
|
@ -338,12 +335,12 @@ render_sub_pixel (gint max_depth,
|
|||
{
|
||||
/* Check whether we have tu supersample */
|
||||
|
||||
if ((color_dist(c1, c2) >= threshold) ||
|
||||
(color_dist(c1, c3) >= threshold) ||
|
||||
(color_dist(c1, c4) >= threshold) ||
|
||||
(color_dist(c2, c3) >= threshold) ||
|
||||
(color_dist(c2, c4) >= threshold) ||
|
||||
(color_dist(c3, c4) >= threshold)) {
|
||||
if ((gimp_rgba_dist (&c1, &c2) >= threshold) ||
|
||||
(gimp_rgba_dist (&c1, &c3) >= threshold) ||
|
||||
(gimp_rgba_dist (&c1, &c4) >= threshold) ||
|
||||
(gimp_rgba_dist (&c2, &c3) >= threshold) ||
|
||||
(gimp_rgba_dist (&c2, &c4) >= threshold) ||
|
||||
(gimp_rgba_dist (&c3, &c4) >= threshold)) {
|
||||
/* Calc coordinates of center subsample */
|
||||
|
||||
x2 = (x1 + x3) / 2;
|
||||
|
@ -376,13 +373,3 @@ render_sub_pixel (gint max_depth,
|
|||
|
||||
return num_samples;
|
||||
}
|
||||
|
||||
static gdouble
|
||||
color_dist (color_t c1,
|
||||
color_t c2)
|
||||
{
|
||||
return (fabs (c1.r - c2.r) +
|
||||
fabs (c1.g - c2.g) +
|
||||
fabs (c1.b - c2.b) +
|
||||
fabs (c1.a - c2.a));
|
||||
}
|
||||
|
|
|
@ -24,18 +24,13 @@
|
|||
#define __ASUPSAMPLE_H__
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gdouble r, g, b, a; /* Range is [0, 1] */
|
||||
} color_t;
|
||||
|
||||
typedef void (* render_func_t) (gdouble x,
|
||||
gdouble y,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
typedef void (* put_pixel_func_t) (gint x,
|
||||
gint y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
gpointer put_pixel_data);
|
||||
|
||||
|
||||
|
|
515
app/blend.c
515
app/blend.c
|
@ -121,7 +121,7 @@ typedef struct
|
|||
gdouble sx, sy;
|
||||
BlendMode blend_mode;
|
||||
GradientType gradient_type;
|
||||
color_t fg, bg;
|
||||
GimpRGB fg, bg;
|
||||
gdouble dist;
|
||||
gdouble vec[2];
|
||||
RepeatFunc repeat_func;
|
||||
|
@ -181,47 +181,47 @@ static void blend_control (Tool *tool,
|
|||
ToolAction action,
|
||||
GDisplay *gdisp);
|
||||
|
||||
static void blend_options_drop_gradient (GtkWidget *,
|
||||
gradient_t *,
|
||||
gpointer );
|
||||
static void blend_options_drop_tool (GtkWidget *,
|
||||
ToolType ,
|
||||
gpointer );
|
||||
static void blend_options_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
gpointer data);
|
||||
static void blend_options_drop_tool (GtkWidget *widget,
|
||||
ToolType gradient,
|
||||
gpointer data);
|
||||
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
|
||||
static gdouble gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y);
|
||||
|
@ -241,11 +241,11 @@ static void gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
static void gradient_render_pixel (gdouble x,
|
||||
gdouble y,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
static void gradient_put_pixel (gint x,
|
||||
gint y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
gpointer put_pixel_data);
|
||||
|
||||
static void gradient_fill_region (GImage *gimage,
|
||||
|
@ -541,9 +541,9 @@ blend_button_release (Tool *tool,
|
|||
BlendTool *blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
gint nreturn_vals;
|
||||
#else
|
||||
GimpProgress *progress;
|
||||
GimpProgress *progress;
|
||||
#endif
|
||||
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -801,9 +801,8 @@ blend_options_drop_tool (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
|
@ -865,70 +864,71 @@ blend (GImage *gimage,
|
|||
/* free the temporary buffer */
|
||||
tile_manager_destroy (buf_tiles);
|
||||
|
||||
gimp_remove_busy_cursors(NULL);
|
||||
gimp_remove_busy_cursors (NULL);
|
||||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_conical_sym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double vec[2];
|
||||
double r;
|
||||
double rat;
|
||||
gdouble vec[2];
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt (x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos (rat) / G_PI;
|
||||
rat = pow (rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP (rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt(x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos(rat) / G_PI;
|
||||
rat = pow(rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rat = 0.5;
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_sym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_conical_asym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x != 0) || (y != 0))
|
||||
|
@ -947,26 +947,27 @@ gradient_calc_conical_asym_factor (double dist,
|
|||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
rat = 0.5; /* We are on middle point */
|
||||
} /* else */
|
||||
{
|
||||
rat = 0.5; /* We are on middle point */
|
||||
}
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_asym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_square_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate offset from start as a value in [0, 1] */
|
||||
|
@ -982,25 +983,24 @@ gradient_calc_square_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_square_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_radial_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate radial offset from start as a value in [0, 1] */
|
||||
|
@ -1016,26 +1016,25 @@ gradient_calc_radial_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_radial_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_linear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = offset / 100.0;
|
||||
|
@ -1049,26 +1048,25 @@ gradient_calc_linear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_linear_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_bilinear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate linear offset from the start line outward */
|
||||
|
@ -1084,25 +1082,27 @@ gradient_calc_bilinear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (fabs(rat) - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_bilinear_factor */
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_spiral_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y,
|
||||
gint cwise)
|
||||
static gdouble
|
||||
gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang, r;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang, r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x != 0.0 || y != 0.0)
|
||||
|
@ -1128,13 +1128,13 @@ gradient_calc_spiral_factor (double dist,
|
|||
return rat;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_angular_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1146,18 +1146,18 @@ gradient_calc_shapeburst_angular_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_spherical_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_spherical_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
tile = tile_manager_get_tile (distR.tiles, ix, iy, TRUE, FALSE);
|
||||
value = *((float *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = *((gfloat *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = 1.0 - sin (0.5 * G_PI * value);
|
||||
tile_release (tile, FALSE);
|
||||
|
||||
|
@ -1165,13 +1165,13 @@ gradient_calc_shapeburst_spherical_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_dimpled_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_dimpled_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1183,25 +1183,25 @@ gradient_calc_shapeburst_dimpled_factor (double x,
|
|||
return value;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_none (double val)
|
||||
static gdouble
|
||||
gradient_repeat_none (gdouble val)
|
||||
{
|
||||
return CLAMP(val, 0.0, 1.0);
|
||||
return CLAMP (val, 0.0, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_sawtooth (double val)
|
||||
static gdouble
|
||||
gradient_repeat_sawtooth (gdouble val)
|
||||
{
|
||||
if (val >= 0.0)
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
else
|
||||
return 1.0 - fmod(-val, 1.0);
|
||||
return 1.0 - fmod (-val, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_triangular (double val)
|
||||
static gdouble
|
||||
gradient_repeat_triangular (gdouble val)
|
||||
{
|
||||
int ival;
|
||||
gint ival;
|
||||
|
||||
if (val < 0.0)
|
||||
val = -val;
|
||||
|
@ -1209,9 +1209,9 @@ gradient_repeat_triangular (double val)
|
|||
ival = (int) val;
|
||||
|
||||
if (ival & 1)
|
||||
return 1.0 - fmod(val, 1.0);
|
||||
return 1.0 - fmod (val, 1.0);
|
||||
else
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
@ -1219,20 +1219,20 @@ static void
|
|||
gradient_precalc_shapeburst (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
double dist)
|
||||
gdouble dist)
|
||||
{
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
float max_iteration;
|
||||
float *distp;
|
||||
int size;
|
||||
void * pr;
|
||||
unsigned char white[1] = { OPAQUE_OPACITY };
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
gfloat max_iteration;
|
||||
gfloat *distp;
|
||||
gint size;
|
||||
gpointer pr;
|
||||
guchar white[1] = { OPAQUE_OPACITY };
|
||||
|
||||
/* allocate the distance map */
|
||||
if (distR.tiles)
|
||||
tile_manager_destroy (distR.tiles);
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (float));
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (gfloat));
|
||||
|
||||
/* allocate the selection mask copy */
|
||||
tempR.tiles = tile_manager_new (PR->w, PR->h, 1);
|
||||
|
@ -1264,13 +1264,16 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
PixelRegion drawableR;
|
||||
|
||||
pixel_region_init (&drawableR, drawable_data (drawable), PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
pixel_region_init (&drawableR, drawable_data (drawable),
|
||||
PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
|
||||
extract_alpha_region (&drawableR, NULL, &tempR);
|
||||
}
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
else
|
||||
color_region (&tempR, white);
|
||||
{
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
color_region (&tempR, white);
|
||||
}
|
||||
}
|
||||
|
||||
pixel_region_init (&tempR, tempR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
@ -1282,10 +1285,12 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
pixel_region_init (&distR, distR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (1, &distR); pr != NULL; pr = pixel_regions_process (pr))
|
||||
for (pr = pixel_regions_register (1, &distR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
distp = (float *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
distp = (gfloat *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
|
||||
while (size--)
|
||||
*distp++ /= max_iteration;
|
||||
|
@ -1299,13 +1304,13 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
|
||||
static void
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
color_t *color,
|
||||
void *render_data)
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
GimpRGB *color,
|
||||
gpointer render_data)
|
||||
{
|
||||
RenderBlendData *rbd;
|
||||
double factor;
|
||||
gdouble factor;
|
||||
|
||||
rbd = render_data;
|
||||
|
||||
|
@ -1397,11 +1402,11 @@ gradient_render_pixel (double x,
|
|||
static void
|
||||
gradient_put_pixel (int x,
|
||||
int y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
void *put_pixel_data)
|
||||
{
|
||||
PutPixelData *ppd;
|
||||
unsigned char *data;
|
||||
guchar *data;
|
||||
|
||||
ppd = put_pixel_data;
|
||||
|
||||
|
@ -1434,19 +1439,19 @@ static void
|
|||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
gint width,
|
||||
gint height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
gdouble offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
gint supersample,
|
||||
gint max_depth,
|
||||
gdouble threshold,
|
||||
gdouble sx,
|
||||
gdouble sy,
|
||||
gdouble ex,
|
||||
gdouble ey,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
|
@ -1457,7 +1462,7 @@ gradient_fill_region (GImage *gimage,
|
|||
gint endx, endy;
|
||||
gpointer *pr;
|
||||
guchar *data;
|
||||
color_t color;
|
||||
GimpRGB color;
|
||||
|
||||
/* Get foreground and background colors, normalized */
|
||||
|
||||
|
@ -1483,8 +1488,8 @@ gradient_fill_region (GImage *gimage,
|
|||
case FG_BG_HSV_MODE:
|
||||
/* Convert to HSV */
|
||||
|
||||
gimp_rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1500,8 +1505,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown blend mode %d",
|
||||
(int) blend_mode);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown blend mode %d",
|
||||
(gint) blend_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1528,7 @@ gradient_fill_region (GImage *gimage,
|
|||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
{
|
||||
|
@ -1536,13 +1541,13 @@ gradient_fill_region (GImage *gimage,
|
|||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown gradient type %d",
|
||||
(int) gradient_type);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown gradient type %d",
|
||||
(gint) gradient_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1563,8 +1568,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(int) repeat);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(gint) repeat);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1583,28 +1588,30 @@ gradient_fill_region (GImage *gimage,
|
|||
/* Initialize put pixel data */
|
||||
|
||||
ppd.PR = PR;
|
||||
ppd.row_data = g_malloc(width * PR->bytes);
|
||||
ppd.row_data = g_malloc (width * PR->bytes);
|
||||
ppd.bytes = PR->bytes;
|
||||
ppd.width = width;
|
||||
|
||||
/* Render! */
|
||||
|
||||
adaptive_supersample_area(0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
adaptive_supersample_area (0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
g_free(ppd.row_data);
|
||||
g_free (ppd.row_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
gint max_progress = PR->w * PR->h;
|
||||
gint progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
for (pr = pixel_regions_register(1, PR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
endx = PR->x + PR->w;
|
||||
|
@ -1633,7 +1640,7 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
(* progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1643,10 +1650,10 @@ gradient_fill_region (GImage *gimage,
|
|||
/****************************/
|
||||
|
||||
Tool *
|
||||
tools_new_blend ()
|
||||
tools_new_blend (void)
|
||||
{
|
||||
Tool * tool;
|
||||
BlendTool * private;
|
||||
Tool *tool;
|
||||
BlendTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! blend_options)
|
||||
|
@ -1676,7 +1683,7 @@ tools_new_blend ()
|
|||
void
|
||||
tools_free_blend (Tool *tool)
|
||||
{
|
||||
BlendTool * blend_tool;
|
||||
BlendTool *blend_tool;
|
||||
|
||||
blend_tool = (BlendTool *) tool->private;
|
||||
|
||||
|
|
|
@ -15,23 +15,27 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_TRANSFER_H__
|
||||
#define __COLOR_TRANSFER_H__
|
||||
|
||||
|
||||
/*************************/
|
||||
/* color transfer data */
|
||||
|
||||
/* for lightening */
|
||||
extern double highlights_add[];
|
||||
extern double midtones_add[];
|
||||
extern double shadows_add[];
|
||||
extern gdouble highlights_add[];
|
||||
extern gdouble midtones_add[];
|
||||
extern gdouble shadows_add[];
|
||||
|
||||
/* for darkening */
|
||||
extern double highlights_sub[];
|
||||
extern double midtones_sub[];
|
||||
extern double shadows_sub[];
|
||||
extern gdouble highlights_sub[];
|
||||
extern gdouble midtones_sub[];
|
||||
extern gdouble shadows_sub[];
|
||||
|
||||
|
||||
/* color transfer functions */
|
||||
void color_transfer_init (void);
|
||||
void color_transfer_init (void);
|
||||
|
||||
|
||||
#endif /* __COLOR_TRANSFER_H__ */
|
||||
|
|
|
@ -121,7 +121,7 @@ typedef struct
|
|||
gdouble sx, sy;
|
||||
BlendMode blend_mode;
|
||||
GradientType gradient_type;
|
||||
color_t fg, bg;
|
||||
GimpRGB fg, bg;
|
||||
gdouble dist;
|
||||
gdouble vec[2];
|
||||
RepeatFunc repeat_func;
|
||||
|
@ -181,47 +181,47 @@ static void blend_control (Tool *tool,
|
|||
ToolAction action,
|
||||
GDisplay *gdisp);
|
||||
|
||||
static void blend_options_drop_gradient (GtkWidget *,
|
||||
gradient_t *,
|
||||
gpointer );
|
||||
static void blend_options_drop_tool (GtkWidget *,
|
||||
ToolType ,
|
||||
gpointer );
|
||||
static void blend_options_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
gpointer data);
|
||||
static void blend_options_drop_tool (GtkWidget *widget,
|
||||
ToolType gradient,
|
||||
gpointer data);
|
||||
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
|
||||
static gdouble gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y);
|
||||
|
@ -241,11 +241,11 @@ static void gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
static void gradient_render_pixel (gdouble x,
|
||||
gdouble y,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
static void gradient_put_pixel (gint x,
|
||||
gint y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
gpointer put_pixel_data);
|
||||
|
||||
static void gradient_fill_region (GImage *gimage,
|
||||
|
@ -541,9 +541,9 @@ blend_button_release (Tool *tool,
|
|||
BlendTool *blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
gint nreturn_vals;
|
||||
#else
|
||||
GimpProgress *progress;
|
||||
GimpProgress *progress;
|
||||
#endif
|
||||
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -801,9 +801,8 @@ blend_options_drop_tool (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
|
@ -865,70 +864,71 @@ blend (GImage *gimage,
|
|||
/* free the temporary buffer */
|
||||
tile_manager_destroy (buf_tiles);
|
||||
|
||||
gimp_remove_busy_cursors(NULL);
|
||||
gimp_remove_busy_cursors (NULL);
|
||||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_conical_sym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double vec[2];
|
||||
double r;
|
||||
double rat;
|
||||
gdouble vec[2];
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt (x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos (rat) / G_PI;
|
||||
rat = pow (rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP (rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt(x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos(rat) / G_PI;
|
||||
rat = pow(rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rat = 0.5;
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_sym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_conical_asym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x != 0) || (y != 0))
|
||||
|
@ -947,26 +947,27 @@ gradient_calc_conical_asym_factor (double dist,
|
|||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
rat = 0.5; /* We are on middle point */
|
||||
} /* else */
|
||||
{
|
||||
rat = 0.5; /* We are on middle point */
|
||||
}
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_asym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_square_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate offset from start as a value in [0, 1] */
|
||||
|
@ -982,25 +983,24 @@ gradient_calc_square_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_square_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_radial_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate radial offset from start as a value in [0, 1] */
|
||||
|
@ -1016,26 +1016,25 @@ gradient_calc_radial_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_radial_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_linear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = offset / 100.0;
|
||||
|
@ -1049,26 +1048,25 @@ gradient_calc_linear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_linear_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_bilinear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate linear offset from the start line outward */
|
||||
|
@ -1084,25 +1082,27 @@ gradient_calc_bilinear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (fabs(rat) - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_bilinear_factor */
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_spiral_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y,
|
||||
gint cwise)
|
||||
static gdouble
|
||||
gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang, r;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang, r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x != 0.0 || y != 0.0)
|
||||
|
@ -1128,13 +1128,13 @@ gradient_calc_spiral_factor (double dist,
|
|||
return rat;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_angular_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1146,18 +1146,18 @@ gradient_calc_shapeburst_angular_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_spherical_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_spherical_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
tile = tile_manager_get_tile (distR.tiles, ix, iy, TRUE, FALSE);
|
||||
value = *((float *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = *((gfloat *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = 1.0 - sin (0.5 * G_PI * value);
|
||||
tile_release (tile, FALSE);
|
||||
|
||||
|
@ -1165,13 +1165,13 @@ gradient_calc_shapeburst_spherical_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_dimpled_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_dimpled_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1183,25 +1183,25 @@ gradient_calc_shapeburst_dimpled_factor (double x,
|
|||
return value;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_none (double val)
|
||||
static gdouble
|
||||
gradient_repeat_none (gdouble val)
|
||||
{
|
||||
return CLAMP(val, 0.0, 1.0);
|
||||
return CLAMP (val, 0.0, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_sawtooth (double val)
|
||||
static gdouble
|
||||
gradient_repeat_sawtooth (gdouble val)
|
||||
{
|
||||
if (val >= 0.0)
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
else
|
||||
return 1.0 - fmod(-val, 1.0);
|
||||
return 1.0 - fmod (-val, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_triangular (double val)
|
||||
static gdouble
|
||||
gradient_repeat_triangular (gdouble val)
|
||||
{
|
||||
int ival;
|
||||
gint ival;
|
||||
|
||||
if (val < 0.0)
|
||||
val = -val;
|
||||
|
@ -1209,9 +1209,9 @@ gradient_repeat_triangular (double val)
|
|||
ival = (int) val;
|
||||
|
||||
if (ival & 1)
|
||||
return 1.0 - fmod(val, 1.0);
|
||||
return 1.0 - fmod (val, 1.0);
|
||||
else
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
@ -1219,20 +1219,20 @@ static void
|
|||
gradient_precalc_shapeburst (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
double dist)
|
||||
gdouble dist)
|
||||
{
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
float max_iteration;
|
||||
float *distp;
|
||||
int size;
|
||||
void * pr;
|
||||
unsigned char white[1] = { OPAQUE_OPACITY };
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
gfloat max_iteration;
|
||||
gfloat *distp;
|
||||
gint size;
|
||||
gpointer pr;
|
||||
guchar white[1] = { OPAQUE_OPACITY };
|
||||
|
||||
/* allocate the distance map */
|
||||
if (distR.tiles)
|
||||
tile_manager_destroy (distR.tiles);
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (float));
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (gfloat));
|
||||
|
||||
/* allocate the selection mask copy */
|
||||
tempR.tiles = tile_manager_new (PR->w, PR->h, 1);
|
||||
|
@ -1264,13 +1264,16 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
PixelRegion drawableR;
|
||||
|
||||
pixel_region_init (&drawableR, drawable_data (drawable), PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
pixel_region_init (&drawableR, drawable_data (drawable),
|
||||
PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
|
||||
extract_alpha_region (&drawableR, NULL, &tempR);
|
||||
}
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
else
|
||||
color_region (&tempR, white);
|
||||
{
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
color_region (&tempR, white);
|
||||
}
|
||||
}
|
||||
|
||||
pixel_region_init (&tempR, tempR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
@ -1282,10 +1285,12 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
pixel_region_init (&distR, distR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (1, &distR); pr != NULL; pr = pixel_regions_process (pr))
|
||||
for (pr = pixel_regions_register (1, &distR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
distp = (float *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
distp = (gfloat *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
|
||||
while (size--)
|
||||
*distp++ /= max_iteration;
|
||||
|
@ -1299,13 +1304,13 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
|
||||
static void
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
color_t *color,
|
||||
void *render_data)
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
GimpRGB *color,
|
||||
gpointer render_data)
|
||||
{
|
||||
RenderBlendData *rbd;
|
||||
double factor;
|
||||
gdouble factor;
|
||||
|
||||
rbd = render_data;
|
||||
|
||||
|
@ -1397,11 +1402,11 @@ gradient_render_pixel (double x,
|
|||
static void
|
||||
gradient_put_pixel (int x,
|
||||
int y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
void *put_pixel_data)
|
||||
{
|
||||
PutPixelData *ppd;
|
||||
unsigned char *data;
|
||||
guchar *data;
|
||||
|
||||
ppd = put_pixel_data;
|
||||
|
||||
|
@ -1434,19 +1439,19 @@ static void
|
|||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
gint width,
|
||||
gint height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
gdouble offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
gint supersample,
|
||||
gint max_depth,
|
||||
gdouble threshold,
|
||||
gdouble sx,
|
||||
gdouble sy,
|
||||
gdouble ex,
|
||||
gdouble ey,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
|
@ -1457,7 +1462,7 @@ gradient_fill_region (GImage *gimage,
|
|||
gint endx, endy;
|
||||
gpointer *pr;
|
||||
guchar *data;
|
||||
color_t color;
|
||||
GimpRGB color;
|
||||
|
||||
/* Get foreground and background colors, normalized */
|
||||
|
||||
|
@ -1483,8 +1488,8 @@ gradient_fill_region (GImage *gimage,
|
|||
case FG_BG_HSV_MODE:
|
||||
/* Convert to HSV */
|
||||
|
||||
gimp_rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1500,8 +1505,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown blend mode %d",
|
||||
(int) blend_mode);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown blend mode %d",
|
||||
(gint) blend_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1528,7 @@ gradient_fill_region (GImage *gimage,
|
|||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
{
|
||||
|
@ -1536,13 +1541,13 @@ gradient_fill_region (GImage *gimage,
|
|||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown gradient type %d",
|
||||
(int) gradient_type);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown gradient type %d",
|
||||
(gint) gradient_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1563,8 +1568,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(int) repeat);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(gint) repeat);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1583,28 +1588,30 @@ gradient_fill_region (GImage *gimage,
|
|||
/* Initialize put pixel data */
|
||||
|
||||
ppd.PR = PR;
|
||||
ppd.row_data = g_malloc(width * PR->bytes);
|
||||
ppd.row_data = g_malloc (width * PR->bytes);
|
||||
ppd.bytes = PR->bytes;
|
||||
ppd.width = width;
|
||||
|
||||
/* Render! */
|
||||
|
||||
adaptive_supersample_area(0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
adaptive_supersample_area (0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
g_free(ppd.row_data);
|
||||
g_free (ppd.row_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
gint max_progress = PR->w * PR->h;
|
||||
gint progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
for (pr = pixel_regions_register(1, PR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
endx = PR->x + PR->w;
|
||||
|
@ -1633,7 +1640,7 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
(* progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1643,10 +1650,10 @@ gradient_fill_region (GImage *gimage,
|
|||
/****************************/
|
||||
|
||||
Tool *
|
||||
tools_new_blend ()
|
||||
tools_new_blend (void)
|
||||
{
|
||||
Tool * tool;
|
||||
BlendTool * private;
|
||||
Tool *tool;
|
||||
BlendTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! blend_options)
|
||||
|
@ -1676,7 +1683,7 @@ tools_new_blend ()
|
|||
void
|
||||
tools_free_blend (Tool *tool)
|
||||
{
|
||||
BlendTool * blend_tool;
|
||||
BlendTool *blend_tool;
|
||||
|
||||
blend_tool = (BlendTool *) tool->private;
|
||||
|
||||
|
|
|
@ -56,11 +56,11 @@ struct _gradient_t
|
|||
|
||||
struct _grad_segment_t
|
||||
{
|
||||
double left, middle, right; /* Left pos, midpoint, right pos */
|
||||
double r0, g0, b0, a0; /* Left color */
|
||||
double r1, g1, b1, a1; /* Right color */
|
||||
grad_type_t type; /* Segment's blending function */
|
||||
grad_color_t color; /* Segment's coloring type */
|
||||
gdouble left, middle, right; /* Left pos, midpoint, right pos */
|
||||
gdouble r0, g0, b0, a0; /* Left color */
|
||||
gdouble r1, g1, b1, a1; /* Right color */
|
||||
grad_type_t type; /* Segment's blending function */
|
||||
grad_color_t color; /* Segment's coloring type */
|
||||
|
||||
struct _grad_segment_t *prev, *next; /* For linked list of segments */
|
||||
};
|
||||
|
|
|
@ -121,7 +121,7 @@ typedef struct
|
|||
gdouble sx, sy;
|
||||
BlendMode blend_mode;
|
||||
GradientType gradient_type;
|
||||
color_t fg, bg;
|
||||
GimpRGB fg, bg;
|
||||
gdouble dist;
|
||||
gdouble vec[2];
|
||||
RepeatFunc repeat_func;
|
||||
|
@ -181,47 +181,47 @@ static void blend_control (Tool *tool,
|
|||
ToolAction action,
|
||||
GDisplay *gdisp);
|
||||
|
||||
static void blend_options_drop_gradient (GtkWidget *,
|
||||
gradient_t *,
|
||||
gpointer );
|
||||
static void blend_options_drop_tool (GtkWidget *,
|
||||
ToolType ,
|
||||
gpointer );
|
||||
static void blend_options_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
gpointer data);
|
||||
static void blend_options_drop_tool (GtkWidget *widget,
|
||||
ToolType gradient,
|
||||
gpointer data);
|
||||
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
|
||||
static gdouble gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y);
|
||||
|
@ -241,11 +241,11 @@ static void gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
static void gradient_render_pixel (gdouble x,
|
||||
gdouble y,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
static void gradient_put_pixel (gint x,
|
||||
gint y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
gpointer put_pixel_data);
|
||||
|
||||
static void gradient_fill_region (GImage *gimage,
|
||||
|
@ -541,9 +541,9 @@ blend_button_release (Tool *tool,
|
|||
BlendTool *blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
gint nreturn_vals;
|
||||
#else
|
||||
GimpProgress *progress;
|
||||
GimpProgress *progress;
|
||||
#endif
|
||||
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -801,9 +801,8 @@ blend_options_drop_tool (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
|
@ -865,70 +864,71 @@ blend (GImage *gimage,
|
|||
/* free the temporary buffer */
|
||||
tile_manager_destroy (buf_tiles);
|
||||
|
||||
gimp_remove_busy_cursors(NULL);
|
||||
gimp_remove_busy_cursors (NULL);
|
||||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_conical_sym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double vec[2];
|
||||
double r;
|
||||
double rat;
|
||||
gdouble vec[2];
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt (x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos (rat) / G_PI;
|
||||
rat = pow (rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP (rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt(x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos(rat) / G_PI;
|
||||
rat = pow(rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rat = 0.5;
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_sym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_conical_asym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x != 0) || (y != 0))
|
||||
|
@ -947,26 +947,27 @@ gradient_calc_conical_asym_factor (double dist,
|
|||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
rat = 0.5; /* We are on middle point */
|
||||
} /* else */
|
||||
{
|
||||
rat = 0.5; /* We are on middle point */
|
||||
}
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_asym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_square_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate offset from start as a value in [0, 1] */
|
||||
|
@ -982,25 +983,24 @@ gradient_calc_square_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_square_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_radial_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate radial offset from start as a value in [0, 1] */
|
||||
|
@ -1016,26 +1016,25 @@ gradient_calc_radial_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_radial_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_linear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = offset / 100.0;
|
||||
|
@ -1049,26 +1048,25 @@ gradient_calc_linear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_linear_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_bilinear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate linear offset from the start line outward */
|
||||
|
@ -1084,25 +1082,27 @@ gradient_calc_bilinear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (fabs(rat) - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_bilinear_factor */
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_spiral_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y,
|
||||
gint cwise)
|
||||
static gdouble
|
||||
gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang, r;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang, r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x != 0.0 || y != 0.0)
|
||||
|
@ -1128,13 +1128,13 @@ gradient_calc_spiral_factor (double dist,
|
|||
return rat;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_angular_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1146,18 +1146,18 @@ gradient_calc_shapeburst_angular_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_spherical_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_spherical_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
tile = tile_manager_get_tile (distR.tiles, ix, iy, TRUE, FALSE);
|
||||
value = *((float *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = *((gfloat *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = 1.0 - sin (0.5 * G_PI * value);
|
||||
tile_release (tile, FALSE);
|
||||
|
||||
|
@ -1165,13 +1165,13 @@ gradient_calc_shapeburst_spherical_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_dimpled_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_dimpled_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1183,25 +1183,25 @@ gradient_calc_shapeburst_dimpled_factor (double x,
|
|||
return value;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_none (double val)
|
||||
static gdouble
|
||||
gradient_repeat_none (gdouble val)
|
||||
{
|
||||
return CLAMP(val, 0.0, 1.0);
|
||||
return CLAMP (val, 0.0, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_sawtooth (double val)
|
||||
static gdouble
|
||||
gradient_repeat_sawtooth (gdouble val)
|
||||
{
|
||||
if (val >= 0.0)
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
else
|
||||
return 1.0 - fmod(-val, 1.0);
|
||||
return 1.0 - fmod (-val, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_triangular (double val)
|
||||
static gdouble
|
||||
gradient_repeat_triangular (gdouble val)
|
||||
{
|
||||
int ival;
|
||||
gint ival;
|
||||
|
||||
if (val < 0.0)
|
||||
val = -val;
|
||||
|
@ -1209,9 +1209,9 @@ gradient_repeat_triangular (double val)
|
|||
ival = (int) val;
|
||||
|
||||
if (ival & 1)
|
||||
return 1.0 - fmod(val, 1.0);
|
||||
return 1.0 - fmod (val, 1.0);
|
||||
else
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
@ -1219,20 +1219,20 @@ static void
|
|||
gradient_precalc_shapeburst (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
double dist)
|
||||
gdouble dist)
|
||||
{
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
float max_iteration;
|
||||
float *distp;
|
||||
int size;
|
||||
void * pr;
|
||||
unsigned char white[1] = { OPAQUE_OPACITY };
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
gfloat max_iteration;
|
||||
gfloat *distp;
|
||||
gint size;
|
||||
gpointer pr;
|
||||
guchar white[1] = { OPAQUE_OPACITY };
|
||||
|
||||
/* allocate the distance map */
|
||||
if (distR.tiles)
|
||||
tile_manager_destroy (distR.tiles);
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (float));
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (gfloat));
|
||||
|
||||
/* allocate the selection mask copy */
|
||||
tempR.tiles = tile_manager_new (PR->w, PR->h, 1);
|
||||
|
@ -1264,13 +1264,16 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
PixelRegion drawableR;
|
||||
|
||||
pixel_region_init (&drawableR, drawable_data (drawable), PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
pixel_region_init (&drawableR, drawable_data (drawable),
|
||||
PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
|
||||
extract_alpha_region (&drawableR, NULL, &tempR);
|
||||
}
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
else
|
||||
color_region (&tempR, white);
|
||||
{
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
color_region (&tempR, white);
|
||||
}
|
||||
}
|
||||
|
||||
pixel_region_init (&tempR, tempR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
@ -1282,10 +1285,12 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
pixel_region_init (&distR, distR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (1, &distR); pr != NULL; pr = pixel_regions_process (pr))
|
||||
for (pr = pixel_regions_register (1, &distR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
distp = (float *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
distp = (gfloat *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
|
||||
while (size--)
|
||||
*distp++ /= max_iteration;
|
||||
|
@ -1299,13 +1304,13 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
|
||||
static void
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
color_t *color,
|
||||
void *render_data)
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
GimpRGB *color,
|
||||
gpointer render_data)
|
||||
{
|
||||
RenderBlendData *rbd;
|
||||
double factor;
|
||||
gdouble factor;
|
||||
|
||||
rbd = render_data;
|
||||
|
||||
|
@ -1397,11 +1402,11 @@ gradient_render_pixel (double x,
|
|||
static void
|
||||
gradient_put_pixel (int x,
|
||||
int y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
void *put_pixel_data)
|
||||
{
|
||||
PutPixelData *ppd;
|
||||
unsigned char *data;
|
||||
guchar *data;
|
||||
|
||||
ppd = put_pixel_data;
|
||||
|
||||
|
@ -1434,19 +1439,19 @@ static void
|
|||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
gint width,
|
||||
gint height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
gdouble offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
gint supersample,
|
||||
gint max_depth,
|
||||
gdouble threshold,
|
||||
gdouble sx,
|
||||
gdouble sy,
|
||||
gdouble ex,
|
||||
gdouble ey,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
|
@ -1457,7 +1462,7 @@ gradient_fill_region (GImage *gimage,
|
|||
gint endx, endy;
|
||||
gpointer *pr;
|
||||
guchar *data;
|
||||
color_t color;
|
||||
GimpRGB color;
|
||||
|
||||
/* Get foreground and background colors, normalized */
|
||||
|
||||
|
@ -1483,8 +1488,8 @@ gradient_fill_region (GImage *gimage,
|
|||
case FG_BG_HSV_MODE:
|
||||
/* Convert to HSV */
|
||||
|
||||
gimp_rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1500,8 +1505,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown blend mode %d",
|
||||
(int) blend_mode);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown blend mode %d",
|
||||
(gint) blend_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1528,7 @@ gradient_fill_region (GImage *gimage,
|
|||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
{
|
||||
|
@ -1536,13 +1541,13 @@ gradient_fill_region (GImage *gimage,
|
|||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown gradient type %d",
|
||||
(int) gradient_type);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown gradient type %d",
|
||||
(gint) gradient_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1563,8 +1568,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(int) repeat);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(gint) repeat);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1583,28 +1588,30 @@ gradient_fill_region (GImage *gimage,
|
|||
/* Initialize put pixel data */
|
||||
|
||||
ppd.PR = PR;
|
||||
ppd.row_data = g_malloc(width * PR->bytes);
|
||||
ppd.row_data = g_malloc (width * PR->bytes);
|
||||
ppd.bytes = PR->bytes;
|
||||
ppd.width = width;
|
||||
|
||||
/* Render! */
|
||||
|
||||
adaptive_supersample_area(0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
adaptive_supersample_area (0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
g_free(ppd.row_data);
|
||||
g_free (ppd.row_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
gint max_progress = PR->w * PR->h;
|
||||
gint progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
for (pr = pixel_regions_register(1, PR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
endx = PR->x + PR->w;
|
||||
|
@ -1633,7 +1640,7 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
(* progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1643,10 +1650,10 @@ gradient_fill_region (GImage *gimage,
|
|||
/****************************/
|
||||
|
||||
Tool *
|
||||
tools_new_blend ()
|
||||
tools_new_blend (void)
|
||||
{
|
||||
Tool * tool;
|
||||
BlendTool * private;
|
||||
Tool *tool;
|
||||
BlendTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! blend_options)
|
||||
|
@ -1676,7 +1683,7 @@ tools_new_blend ()
|
|||
void
|
||||
tools_free_blend (Tool *tool)
|
||||
{
|
||||
BlendTool * blend_tool;
|
||||
BlendTool *blend_tool;
|
||||
|
||||
blend_tool = (BlendTool *) tool->private;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ typedef struct
|
|||
gdouble sx, sy;
|
||||
BlendMode blend_mode;
|
||||
GradientType gradient_type;
|
||||
color_t fg, bg;
|
||||
GimpRGB fg, bg;
|
||||
gdouble dist;
|
||||
gdouble vec[2];
|
||||
RepeatFunc repeat_func;
|
||||
|
@ -181,47 +181,47 @@ static void blend_control (Tool *tool,
|
|||
ToolAction action,
|
||||
GDisplay *gdisp);
|
||||
|
||||
static void blend_options_drop_gradient (GtkWidget *,
|
||||
gradient_t *,
|
||||
gpointer );
|
||||
static void blend_options_drop_tool (GtkWidget *,
|
||||
ToolType ,
|
||||
gpointer );
|
||||
static void blend_options_drop_gradient (GtkWidget *widget,
|
||||
gradient_t *gradient,
|
||||
gpointer data);
|
||||
static void blend_options_drop_tool (GtkWidget *widget,
|
||||
ToolType gradient,
|
||||
gpointer data);
|
||||
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
static gdouble gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
static gdouble gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise);
|
||||
|
||||
static gdouble gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y);
|
||||
|
@ -241,11 +241,11 @@ static void gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
static void gradient_render_pixel (gdouble x,
|
||||
gdouble y,
|
||||
color_t *color,
|
||||
GimpRGB *color,
|
||||
gpointer render_data);
|
||||
static void gradient_put_pixel (gint x,
|
||||
gint y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
gpointer put_pixel_data);
|
||||
|
||||
static void gradient_fill_region (GImage *gimage,
|
||||
|
@ -541,9 +541,9 @@ blend_button_release (Tool *tool,
|
|||
BlendTool *blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
gint nreturn_vals;
|
||||
#else
|
||||
GimpProgress *progress;
|
||||
GimpProgress *progress;
|
||||
#endif
|
||||
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -801,9 +801,8 @@ blend_options_drop_tool (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
/* The actual blending procedure */
|
||||
|
||||
void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
|
@ -865,70 +864,71 @@ blend (GImage *gimage,
|
|||
/* free the temporary buffer */
|
||||
tile_manager_destroy (buf_tiles);
|
||||
|
||||
gimp_remove_busy_cursors(NULL);
|
||||
gimp_remove_busy_cursors (NULL);
|
||||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_conical_sym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_sym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double vec[2];
|
||||
double r;
|
||||
double rat;
|
||||
gdouble vec[2];
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt (x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos (rat) / G_PI;
|
||||
rat = pow (rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP (rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
if ((x != 0) || (y != 0))
|
||||
{
|
||||
/* Calculate offset from the start in pixels */
|
||||
|
||||
r = sqrt(x * x + y * y);
|
||||
|
||||
vec[0] = x / r;
|
||||
vec[1] = y / r;
|
||||
|
||||
rat = axis[0] * vec[0] + axis[1] * vec[1]; /* Dot product */
|
||||
|
||||
if (rat > 1.0)
|
||||
rat = 1.0;
|
||||
else if (rat < -1.0)
|
||||
rat = -1.0;
|
||||
|
||||
/* This cool idea is courtesy Josh MacDonald,
|
||||
* Ali Rahimi --- two more XCF losers. */
|
||||
|
||||
rat = acos(rat) / G_PI;
|
||||
rat = pow(rat, (offset / 10) + 1);
|
||||
|
||||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rat = 0.5;
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_sym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_conical_asym_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_conical_asym_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x != 0) || (y != 0))
|
||||
|
@ -947,26 +947,27 @@ gradient_calc_conical_asym_factor (double dist,
|
|||
rat = CLAMP(rat, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
rat = 0.5; /* We are on middle point */
|
||||
} /* else */
|
||||
{
|
||||
rat = 0.5; /* We are on middle point */
|
||||
}
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_conical_asym_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_square_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_square_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate offset from start as a value in [0, 1] */
|
||||
|
@ -982,25 +983,24 @@ gradient_calc_square_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_square_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_radial_factor (double dist,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_radial_factor (gdouble dist,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate radial offset from start as a value in [0, 1] */
|
||||
|
@ -1016,26 +1016,25 @@ gradient_calc_radial_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_radial_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_linear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_linear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = offset / 100.0;
|
||||
|
@ -1049,26 +1048,25 @@ gradient_calc_linear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (rat - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_linear_factor */
|
||||
}
|
||||
|
||||
|
||||
/*****/
|
||||
|
||||
static double
|
||||
gradient_calc_bilinear_factor (double dist,
|
||||
double *vec,
|
||||
double offset,
|
||||
double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_bilinear_factor (gdouble dist,
|
||||
gdouble *vec,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
double r;
|
||||
double rat;
|
||||
gdouble r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Calculate linear offset from the start line outward */
|
||||
|
@ -1084,25 +1082,27 @@ gradient_calc_bilinear_factor (double dist,
|
|||
rat = (rat>=1) ? 1 : 0;
|
||||
else
|
||||
rat = (fabs(rat) - offset) / (1.0 - offset);
|
||||
} /* else */
|
||||
}
|
||||
|
||||
return rat;
|
||||
} /* gradient_calc_bilinear_factor */
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_spiral_factor (double dist,
|
||||
double *axis,
|
||||
double offset,
|
||||
double x,
|
||||
double y,
|
||||
gint cwise)
|
||||
static gdouble
|
||||
gradient_calc_spiral_factor (gdouble dist,
|
||||
gdouble *axis,
|
||||
gdouble offset,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gint cwise)
|
||||
{
|
||||
double ang0, ang1;
|
||||
double ang, r;
|
||||
double rat;
|
||||
gdouble ang0, ang1;
|
||||
gdouble ang, r;
|
||||
gdouble rat;
|
||||
|
||||
if (dist == 0.0)
|
||||
rat = 0.0;
|
||||
{
|
||||
rat = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x != 0.0 || y != 0.0)
|
||||
|
@ -1128,13 +1128,13 @@ gradient_calc_spiral_factor (double dist,
|
|||
return rat;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_angular_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_angular_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1146,18 +1146,18 @@ gradient_calc_shapeburst_angular_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_spherical_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_spherical_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
tile = tile_manager_get_tile (distR.tiles, ix, iy, TRUE, FALSE);
|
||||
value = *((float *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = *((gfloat *) tile_data_pointer (tile, ix % TILE_WIDTH, iy % TILE_HEIGHT));
|
||||
value = 1.0 - sin (0.5 * G_PI * value);
|
||||
tile_release (tile, FALSE);
|
||||
|
||||
|
@ -1165,13 +1165,13 @@ gradient_calc_shapeburst_spherical_factor (double x,
|
|||
}
|
||||
|
||||
|
||||
static double
|
||||
gradient_calc_shapeburst_dimpled_factor (double x,
|
||||
double y)
|
||||
static gdouble
|
||||
gradient_calc_shapeburst_dimpled_factor (gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
int ix, iy;
|
||||
Tile *tile;
|
||||
float value;
|
||||
gint ix, iy;
|
||||
Tile *tile;
|
||||
gfloat value;
|
||||
|
||||
ix = (int) CLAMP (x, 0, distR.w);
|
||||
iy = (int) CLAMP (y, 0, distR.h);
|
||||
|
@ -1183,25 +1183,25 @@ gradient_calc_shapeburst_dimpled_factor (double x,
|
|||
return value;
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_none (double val)
|
||||
static gdouble
|
||||
gradient_repeat_none (gdouble val)
|
||||
{
|
||||
return CLAMP(val, 0.0, 1.0);
|
||||
return CLAMP (val, 0.0, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_sawtooth (double val)
|
||||
static gdouble
|
||||
gradient_repeat_sawtooth (gdouble val)
|
||||
{
|
||||
if (val >= 0.0)
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
else
|
||||
return 1.0 - fmod(-val, 1.0);
|
||||
return 1.0 - fmod (-val, 1.0);
|
||||
}
|
||||
|
||||
static double
|
||||
gradient_repeat_triangular (double val)
|
||||
static gdouble
|
||||
gradient_repeat_triangular (gdouble val)
|
||||
{
|
||||
int ival;
|
||||
gint ival;
|
||||
|
||||
if (val < 0.0)
|
||||
val = -val;
|
||||
|
@ -1209,9 +1209,9 @@ gradient_repeat_triangular (double val)
|
|||
ival = (int) val;
|
||||
|
||||
if (ival & 1)
|
||||
return 1.0 - fmod(val, 1.0);
|
||||
return 1.0 - fmod (val, 1.0);
|
||||
else
|
||||
return fmod(val, 1.0);
|
||||
return fmod (val, 1.0);
|
||||
}
|
||||
|
||||
/*****/
|
||||
|
@ -1219,20 +1219,20 @@ static void
|
|||
gradient_precalc_shapeburst (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
double dist)
|
||||
gdouble dist)
|
||||
{
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
float max_iteration;
|
||||
float *distp;
|
||||
int size;
|
||||
void * pr;
|
||||
unsigned char white[1] = { OPAQUE_OPACITY };
|
||||
Channel *mask;
|
||||
PixelRegion tempR;
|
||||
gfloat max_iteration;
|
||||
gfloat *distp;
|
||||
gint size;
|
||||
gpointer pr;
|
||||
guchar white[1] = { OPAQUE_OPACITY };
|
||||
|
||||
/* allocate the distance map */
|
||||
if (distR.tiles)
|
||||
tile_manager_destroy (distR.tiles);
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (float));
|
||||
distR.tiles = tile_manager_new (PR->w, PR->h, sizeof (gfloat));
|
||||
|
||||
/* allocate the selection mask copy */
|
||||
tempR.tiles = tile_manager_new (PR->w, PR->h, 1);
|
||||
|
@ -1264,13 +1264,16 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
PixelRegion drawableR;
|
||||
|
||||
pixel_region_init (&drawableR, drawable_data (drawable), PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
pixel_region_init (&drawableR, drawable_data (drawable),
|
||||
PR->x, PR->y, PR->w, PR->h, FALSE);
|
||||
|
||||
extract_alpha_region (&drawableR, NULL, &tempR);
|
||||
}
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
else
|
||||
color_region (&tempR, white);
|
||||
{
|
||||
/* Otherwise, just fill the shapeburst to white */
|
||||
color_region (&tempR, white);
|
||||
}
|
||||
}
|
||||
|
||||
pixel_region_init (&tempR, tempR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
@ -1282,10 +1285,12 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
{
|
||||
pixel_region_init (&distR, distR.tiles, 0, 0, PR->w, PR->h, TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (1, &distR); pr != NULL; pr = pixel_regions_process (pr))
|
||||
for (pr = pixel_regions_register (1, &distR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
distp = (float *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
distp = (gfloat *) distR.data;
|
||||
size = distR.w * distR.h;
|
||||
|
||||
while (size--)
|
||||
*distp++ /= max_iteration;
|
||||
|
@ -1299,13 +1304,13 @@ gradient_precalc_shapeburst (GImage *gimage,
|
|||
|
||||
|
||||
static void
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
color_t *color,
|
||||
void *render_data)
|
||||
gradient_render_pixel (double x,
|
||||
double y,
|
||||
GimpRGB *color,
|
||||
gpointer render_data)
|
||||
{
|
||||
RenderBlendData *rbd;
|
||||
double factor;
|
||||
gdouble factor;
|
||||
|
||||
rbd = render_data;
|
||||
|
||||
|
@ -1397,11 +1402,11 @@ gradient_render_pixel (double x,
|
|||
static void
|
||||
gradient_put_pixel (int x,
|
||||
int y,
|
||||
color_t color,
|
||||
GimpRGB color,
|
||||
void *put_pixel_data)
|
||||
{
|
||||
PutPixelData *ppd;
|
||||
unsigned char *data;
|
||||
guchar *data;
|
||||
|
||||
ppd = put_pixel_data;
|
||||
|
||||
|
@ -1434,19 +1439,19 @@ static void
|
|||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
gint width,
|
||||
gint height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
gdouble offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
gint supersample,
|
||||
gint max_depth,
|
||||
gdouble threshold,
|
||||
gdouble sx,
|
||||
gdouble sy,
|
||||
gdouble ex,
|
||||
gdouble ey,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data)
|
||||
{
|
||||
|
@ -1457,7 +1462,7 @@ gradient_fill_region (GImage *gimage,
|
|||
gint endx, endy;
|
||||
gpointer *pr;
|
||||
guchar *data;
|
||||
color_t color;
|
||||
GimpRGB color;
|
||||
|
||||
/* Get foreground and background colors, normalized */
|
||||
|
||||
|
@ -1483,8 +1488,8 @@ gradient_fill_region (GImage *gimage,
|
|||
case FG_BG_HSV_MODE:
|
||||
/* Convert to HSV */
|
||||
|
||||
gimp_rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
|
||||
gimp_rgb_to_hsv_double (&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1500,8 +1505,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown blend mode %d",
|
||||
(int) blend_mode);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown blend mode %d",
|
||||
(gint) blend_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1523,7 +1528,7 @@ gradient_fill_region (GImage *gimage,
|
|||
case SPIRAL_ANTICLOCKWISE:
|
||||
case LINEAR:
|
||||
case BILINEAR:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
|
||||
if (rbd.dist > 0.0)
|
||||
{
|
||||
|
@ -1536,13 +1541,13 @@ gradient_fill_region (GImage *gimage,
|
|||
case SHAPEBURST_ANGULAR:
|
||||
case SHAPEBURST_SPHERICAL:
|
||||
case SHAPEBURST_DIMPLED:
|
||||
rbd.dist = sqrt(SQR(ex - sx) + SQR(ey - sy));
|
||||
gradient_precalc_shapeburst(gimage, drawable, PR, rbd.dist);
|
||||
rbd.dist = sqrt (SQR (ex - sx) + SQR (ey - sy));
|
||||
gradient_precalc_shapeburst (gimage, drawable, PR, rbd.dist);
|
||||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown gradient type %d",
|
||||
(int) gradient_type);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown gradient type %d",
|
||||
(gint) gradient_type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1563,8 +1568,8 @@ gradient_fill_region (GImage *gimage,
|
|||
break;
|
||||
|
||||
default:
|
||||
gimp_fatal_error("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(int) repeat);
|
||||
gimp_fatal_error ("gradient_fill_region(): Unknown repeat mode %d",
|
||||
(gint) repeat);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1583,28 +1588,30 @@ gradient_fill_region (GImage *gimage,
|
|||
/* Initialize put pixel data */
|
||||
|
||||
ppd.PR = PR;
|
||||
ppd.row_data = g_malloc(width * PR->bytes);
|
||||
ppd.row_data = g_malloc (width * PR->bytes);
|
||||
ppd.bytes = PR->bytes;
|
||||
ppd.width = width;
|
||||
|
||||
/* Render! */
|
||||
|
||||
adaptive_supersample_area(0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
adaptive_supersample_area (0, 0, (width - 1), (height - 1),
|
||||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
g_free(ppd.row_data);
|
||||
g_free (ppd.row_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
gint max_progress = PR->w * PR->h;
|
||||
gint progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
for (pr = pixel_regions_register(1, PR);
|
||||
pr != NULL;
|
||||
pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
endx = PR->x + PR->w;
|
||||
|
@ -1633,7 +1640,7 @@ gradient_fill_region (GImage *gimage,
|
|||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
(* progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1643,10 +1650,10 @@ gradient_fill_region (GImage *gimage,
|
|||
/****************************/
|
||||
|
||||
Tool *
|
||||
tools_new_blend ()
|
||||
tools_new_blend (void)
|
||||
{
|
||||
Tool * tool;
|
||||
BlendTool * private;
|
||||
Tool *tool;
|
||||
BlendTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! blend_options)
|
||||
|
@ -1676,7 +1683,7 @@ tools_new_blend ()
|
|||
void
|
||||
tools_free_blend (Tool *tool)
|
||||
{
|
||||
BlendTool * blend_tool;
|
||||
BlendTool *blend_tool;
|
||||
|
||||
blend_tool = (BlendTool *) tool->private;
|
||||
|
||||
|
|
|
@ -97,8 +97,8 @@ PDB_WRAPPERS_H = \
|
|||
gimpunit_pdb.h
|
||||
|
||||
libgimpi_a_SOURCES = \
|
||||
gimpenv.c \
|
||||
gimpenv.h \
|
||||
gimpcolor.c \
|
||||
gimpcolor.h \
|
||||
gimpchainbutton.c \
|
||||
gimpchainbutton.h \
|
||||
gimpcolorbutton.c \
|
||||
|
@ -106,6 +106,8 @@ libgimpi_a_SOURCES = \
|
|||
gimpcolorspace.h \
|
||||
gimpdialog.c \
|
||||
gimpdialog.h \
|
||||
gimpenv.c \
|
||||
gimpenv.h \
|
||||
gimpfileselection.c \
|
||||
gimpfileselection.h \
|
||||
gimphelpui.c \
|
||||
|
@ -154,6 +156,8 @@ libgimp_la_SOURCES = \
|
|||
gimp.h \
|
||||
${PDB_WRAPPERS_C} \
|
||||
${PDB_WRAPPERS_H} \
|
||||
gimpcolor.c \
|
||||
gimpcolor.h \
|
||||
gimpcolorspace.c \
|
||||
gimpcolorspace.h \
|
||||
gimpchannel.c \
|
||||
|
@ -225,6 +229,7 @@ gimpinclude_HEADERS = \
|
|||
${PDB_WRAPPERS_H} \
|
||||
gimpchainbutton.h \
|
||||
gimpchannel.h \
|
||||
gimpcolor.h \
|
||||
gimpcolorbutton.h \
|
||||
gimpcolordisplay.h \
|
||||
gimpcolorselector.h \
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <libgimp/gimptypes.h>
|
||||
|
||||
#include <libgimp/gimpchannel.h>
|
||||
#include <libgimp/gimpcolor.h>
|
||||
#include <libgimp/gimpcolorspace.h>
|
||||
#include <libgimp/gimpdrawable.h>
|
||||
#include <libgimp/gimpfeatures.h>
|
||||
|
|
|
@ -0,0 +1,252 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gimpcolor.h"
|
||||
#include "gimpmath.h"
|
||||
|
||||
|
||||
/***************************
|
||||
* channels operations *
|
||||
***************************/
|
||||
|
||||
|
||||
/* RGB functions */
|
||||
|
||||
void
|
||||
gimp_rgb_set (GimpRGB *rgb,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b)
|
||||
{
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
rgb->r = r;
|
||||
rgb->g = g;
|
||||
rgb->b = b;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_add (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2)
|
||||
{
|
||||
g_return_if_fail (rgb1 != NULL);
|
||||
g_return_if_fail (rgb2 != NULL);
|
||||
|
||||
rgb1->r = rgb1->r + rgb2->r;
|
||||
rgb1->g = rgb1->g + rgb2->g;
|
||||
rgb1->b = rgb1->b + rgb2->b;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_sub (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2)
|
||||
{
|
||||
g_return_if_fail (rgb1 != NULL);
|
||||
g_return_if_fail (rgb2 != NULL);
|
||||
|
||||
rgb1->r = rgb1->r - rgb2->r;
|
||||
rgb1->g = rgb1->g - rgb2->g;
|
||||
rgb1->b = rgb1->b - rgb2->b;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_mul (GimpRGB *rgb,
|
||||
gdouble factor)
|
||||
{
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
rgb->r *= factor;
|
||||
rgb->g *= factor;
|
||||
rgb->b *= factor;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_rgb_dist (const GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2)
|
||||
{
|
||||
g_return_val_if_fail (rgb1 != NULL, 0.0);
|
||||
g_return_val_if_fail (rgb2 != NULL, 0.0);
|
||||
|
||||
return (fabs (rgb1->r - rgb2->r) +
|
||||
fabs (rgb1->g - rgb2->g) +
|
||||
fabs (rgb1->b - rgb2->b));
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_rgb_max (const GimpRGB *rgb)
|
||||
{
|
||||
g_return_val_if_fail (rgb != NULL, 0.0);
|
||||
|
||||
return MAX (rgb->r, MAX (rgb->g, rgb->b));
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_rgb_min (const GimpRGB *rgb)
|
||||
{
|
||||
g_return_val_if_fail (rgb != NULL, 0.0);
|
||||
|
||||
return MIN (rgb->r, MIN (rgb->g, rgb->b));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_clamp (GimpRGB *rgb)
|
||||
{
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_gamma (GimpRGB *rgb,
|
||||
gdouble gamma)
|
||||
{
|
||||
gdouble ig;
|
||||
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
if (gamma != 0.0)
|
||||
ig = 1.0 / gamma;
|
||||
else
|
||||
ig = 0.0;
|
||||
|
||||
rgb->r = pow (rgb->r, ig);
|
||||
rgb->g = pow (rgb->g, ig);
|
||||
rgb->b = pow (rgb->b, ig);
|
||||
}
|
||||
|
||||
|
||||
/* RGBA functions */
|
||||
|
||||
void
|
||||
gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b,
|
||||
gdouble a)
|
||||
{
|
||||
g_return_if_fail (rgba != NULL);
|
||||
|
||||
rgba->r = r;
|
||||
rgba->g = g;
|
||||
rgba->b = b;
|
||||
rgba->a = a;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgba_add (GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2)
|
||||
{
|
||||
g_return_if_fail (rgba1 != NULL);
|
||||
g_return_if_fail (rgba2 != NULL);
|
||||
|
||||
rgba1->r = rgba1->r + rgba2->r;
|
||||
rgba1->g = rgba1->g + rgba2->g;
|
||||
rgba1->b = rgba1->b + rgba2->b;
|
||||
rgba1->a = rgba1->a + rgba2->a;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgba_sub (GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2)
|
||||
{
|
||||
g_return_if_fail (rgba1 != NULL);
|
||||
g_return_if_fail (rgba2 != NULL);
|
||||
|
||||
rgba1->r = rgba1->r - rgba2->r;
|
||||
rgba1->g = rgba1->g - rgba2->g;
|
||||
rgba1->b = rgba1->b - rgba2->b;
|
||||
rgba1->a = rgba1->a - rgba2->a;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgba_mul (GimpRGB *rgba,
|
||||
gdouble factor)
|
||||
{
|
||||
g_return_if_fail (rgba != NULL);
|
||||
|
||||
rgba->r = rgba->r * factor;
|
||||
rgba->g = rgba->g * factor;
|
||||
rgba->b = rgba->b * factor;
|
||||
rgba->a = rgba->a * factor;
|
||||
}
|
||||
|
||||
gdouble
|
||||
gimp_rgba_dist (const GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2)
|
||||
{
|
||||
g_return_val_if_fail (rgba1 != NULL, 0.0);
|
||||
g_return_val_if_fail (rgba2 != NULL, 0.0);
|
||||
|
||||
return (fabs (rgba1->r - rgba2->r) + fabs (rgba1->g - rgba2->g) +
|
||||
fabs (rgba1->b - rgba2->b) + fabs (rgba1->a - rgba2->a));
|
||||
}
|
||||
|
||||
/* These two are probably not needed */
|
||||
|
||||
gdouble
|
||||
gimp_rgba_max (const GimpRGB *rgba)
|
||||
{
|
||||
g_return_val_if_fail (rgba != NULL, 0.0);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgba_clamp (GimpRGB *rgba)
|
||||
{
|
||||
g_return_if_fail (rgba != 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);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgba_gamma (GimpRGB *rgba,
|
||||
gdouble gamma)
|
||||
{
|
||||
gdouble ig;
|
||||
|
||||
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);
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_H__
|
||||
#define __GIMP_COLOR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
/* RGB and RGBA color types and operations taken from LibGCK */
|
||||
|
||||
typedef struct _GimpRGB GimpRGB;
|
||||
|
||||
struct _GimpRGB
|
||||
{
|
||||
gdouble r, g, b, a;
|
||||
};
|
||||
|
||||
|
||||
void gimp_rgb_set (GimpRGB *rgb,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b);
|
||||
|
||||
void gimp_rgb_add (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
void gimp_rgb_sub (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
void gimp_rgb_mul (GimpRGB *rgb1,
|
||||
gdouble factor);
|
||||
gdouble gimp_rgb_dist (const GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
gdouble gimp_rgb_max (const GimpRGB *rgb);
|
||||
gdouble gimp_rgb_min (const GimpRGB *rgb);
|
||||
void gimp_rgb_clamp (GimpRGB *rgb);
|
||||
void gimp_rgb_gamma (GimpRGB *rgb,
|
||||
gdouble gamma);
|
||||
|
||||
|
||||
void gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b,
|
||||
gdouble a);
|
||||
|
||||
void gimp_rgba_add (GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2);
|
||||
void gimp_rgba_sub (GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2);
|
||||
void gimp_rgba_mul (GimpRGB *rgba,
|
||||
gdouble factor);
|
||||
gdouble gimp_rgba_dist (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);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_COLOR_H__ */
|
|
@ -19,12 +19,343 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "gimpcolor.h"
|
||||
#include "gimpcolorspace.h"
|
||||
#include "gimpmath.h"
|
||||
|
||||
|
||||
/*********************************
|
||||
* color conversion routines *
|
||||
*********************************/
|
||||
|
||||
|
||||
/* GimpRGB functions */
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *value)
|
||||
{
|
||||
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);
|
||||
|
||||
max = gimp_rgb_max (rgb);
|
||||
min = gimp_rgb_min (rgb);
|
||||
|
||||
*value = max;
|
||||
if (max != 0.0)
|
||||
{
|
||||
*saturation = (max - min) / max;
|
||||
}
|
||||
else
|
||||
{
|
||||
*saturation = 0.0;
|
||||
}
|
||||
|
||||
if (*saturation == 0.0)
|
||||
{
|
||||
*hue = GIMP_HSV_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
|
||||
if (rgb->r == max)
|
||||
{
|
||||
*hue = (rgb->g - rgb->b) / delta;
|
||||
}
|
||||
else if (rgb->g == max)
|
||||
{
|
||||
*hue = 2.0 + (rgb->b - rgb->r) / delta;
|
||||
}
|
||||
else if (rgb->b == max)
|
||||
{
|
||||
*hue = 4.0 + (rgb->r - rgb->g) / delta;
|
||||
}
|
||||
|
||||
*hue = *hue * 60.0;
|
||||
|
||||
if (*hue < 0.0)
|
||||
*hue = *hue + 360;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_hsv_to_rgb (gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble value,
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
gint i;
|
||||
gdouble f, w, q, t;
|
||||
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
if (saturation == 0.0)
|
||||
{
|
||||
if (hue == GIMP_HSV_UNDEFINED)
|
||||
{
|
||||
rgb->r = value;
|
||||
rgb->g = value;
|
||||
rgb->b = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hue == 360.0)
|
||||
hue = 0.0;
|
||||
|
||||
hue = hue / 60.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)));
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
rgb->r = value;
|
||||
rgb->g = t;
|
||||
rgb->b = w;
|
||||
break;
|
||||
case 1:
|
||||
rgb->r = q;
|
||||
rgb->g = value;
|
||||
rgb->b = w;
|
||||
break;
|
||||
case 2:
|
||||
rgb->r = w;
|
||||
rgb->g = value;
|
||||
rgb->b = t;
|
||||
break;
|
||||
case 3:
|
||||
rgb->r = w;
|
||||
rgb->g = q;
|
||||
rgb->b = value;
|
||||
break;
|
||||
case 4:
|
||||
rgb->r = t;
|
||||
rgb->g = w;
|
||||
rgb->b = value;
|
||||
break;
|
||||
case 5:
|
||||
rgb->r = value;
|
||||
rgb->g = w;
|
||||
rgb->b = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsl (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *lightness)
|
||||
{
|
||||
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 (lightness != NULL);
|
||||
|
||||
max = gimp_rgb_max (rgb);
|
||||
min = gimp_rgb_min (rgb);
|
||||
|
||||
*lightness = (max + min) / 2.0;
|
||||
|
||||
if (max == min)
|
||||
{
|
||||
*saturation = 0.0;
|
||||
*hue = GIMP_HSL_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*lightness <= 0.5)
|
||||
*saturation = (max - min) / (max + min);
|
||||
else
|
||||
*saturation = (max - min) / (2.0 - max - min);
|
||||
|
||||
delta = max - min;
|
||||
|
||||
if (rgb->r == max)
|
||||
{
|
||||
*hue = (rgb->g - rgb->b) / delta;
|
||||
}
|
||||
else if (rgb->g == max)
|
||||
{
|
||||
*hue = 2.0 + (rgb->b - rgb->r) / delta;
|
||||
}
|
||||
else if (rgb->b == max)
|
||||
{
|
||||
*hue = 4.0 + (rgb->r - rgb->g) / delta;
|
||||
}
|
||||
|
||||
*hue = *hue * 60.0;
|
||||
|
||||
if (*hue < 0.0)
|
||||
*hue = *hue + 360.0;
|
||||
}
|
||||
}
|
||||
|
||||
static gdouble
|
||||
_gimp_color_value (gdouble n1,
|
||||
gdouble n2,
|
||||
gdouble hue)
|
||||
{
|
||||
gdouble val;
|
||||
|
||||
if (hue > 360.0)
|
||||
hue = hue - 360.0;
|
||||
else if (hue < 0.0)
|
||||
hue = hue + 360.0;
|
||||
if (hue < 60.0)
|
||||
val = n1 + (n2 - n1) * hue / 60.0;
|
||||
else if (hue < 180.0)
|
||||
val = n2;
|
||||
else if (hue < 240.0)
|
||||
val = n1 + (n2 - n1) * (240.0 - hue) / 60.0;
|
||||
else
|
||||
val = n1;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_hsl_to_rgb (gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble lightness,
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
gdouble m1, m2;
|
||||
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
if (lightness <= 0.5)
|
||||
m2 = lightness * (lightness + saturation);
|
||||
else
|
||||
m2 = lightness + saturation + lightness * saturation;
|
||||
m1 = 2.0 * lightness - m2;
|
||||
|
||||
if (saturation == 0)
|
||||
{
|
||||
if (hue == GIMP_HSV_UNDEFINED)
|
||||
rgb->r = rgb->g = rgb->b = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rgb->r = _gimp_color_value (m1, m2, hue + 120.0);
|
||||
rgb->g = _gimp_color_value (m1, m2, hue);
|
||||
rgb->b = _gimp_color_value (m1, m2, hue - 120.0);
|
||||
}
|
||||
}
|
||||
|
||||
#define GIMP_RETURN_RGB(x, y, z) { rgb->r = x; rgb->g = y; rgb->b = z; return; }
|
||||
|
||||
/*****************************************************************************
|
||||
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms.
|
||||
* Pure red always maps to 6 in this implementation. Therefore UNDEFINED can
|
||||
* be defined as 0 in situations where only unsigned numbers are desired.
|
||||
*****************************************************************************/
|
||||
|
||||
void
|
||||
gimp_rgb_to_hwb (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *whiteness,
|
||||
gdouble *blackness)
|
||||
{
|
||||
/* RGB are each on [0, 1]. W and B are returned on [0, 1] and H is */
|
||||
/* returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B. */
|
||||
/* ====================================================================== */
|
||||
|
||||
gdouble R = rgb->r, G = rgb->g, B = rgb->b, w, v, b, f;
|
||||
gint i;
|
||||
|
||||
w = gimp_rgb_min (rgb);
|
||||
v = gimp_rgb_max (rgb);
|
||||
b = 1.0 - v;
|
||||
|
||||
if (v == w)
|
||||
{
|
||||
*hue = GIMP_HSV_UNDEFINED;
|
||||
*whiteness = w;
|
||||
*blackness = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
|
||||
i = (R == w) ? 3.0 : ((G == w) ? 5.0 : 1.0);
|
||||
|
||||
*hue = (360.0 / 6.0) * (i - f / (v - w));
|
||||
*whiteness = w;
|
||||
*blackness = b;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_hwb_to_rgb (gdouble hue,
|
||||
gdouble whiteness,
|
||||
gdouble blackness,
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
/* H is given on [0, 6] or UNDEFINED. whiteness and
|
||||
* blackness are given on [0, 1].
|
||||
* RGB are each returned on [0, 1].
|
||||
*/
|
||||
|
||||
gdouble h = hue, w = whiteness, b = blackness, v, n, f;
|
||||
gint i;
|
||||
|
||||
h = 6.0 * h/ 360.0;
|
||||
|
||||
v = 1.0 - b;
|
||||
if (h == GIMP_HSV_UNDEFINED)
|
||||
{
|
||||
rgb->r = v;
|
||||
rgb->g = v;
|
||||
rgb->b = v;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = floor (h);
|
||||
f = h - i;
|
||||
|
||||
if (i & 1)
|
||||
f = 1.0 - f; /* if i is odd */
|
||||
|
||||
n = w + f * (v - w); /* linear interpolation between w and v */
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 6:
|
||||
case 0: GIMP_RETURN_RGB (v, n, w);
|
||||
break;
|
||||
case 1: GIMP_RETURN_RGB (n, v, w);
|
||||
break;
|
||||
case 2: GIMP_RETURN_RGB (w, v, n);
|
||||
break;
|
||||
case 3: GIMP_RETURN_RGB (w, n, v);
|
||||
break;
|
||||
case 4: GIMP_RETURN_RGB (n, w, v);
|
||||
break;
|
||||
case 5: GIMP_RETURN_RGB (v, w, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* gint functions */
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv_int (gint *red,
|
||||
gint *green,
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMPCOLORSPACE_H__
|
||||
#define __GIMPCOLORSPACE_H__
|
||||
#ifndef __GIMP_COLOR_SPACE_H__
|
||||
#define __GIMP_COLOR_SPACE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -30,6 +30,39 @@ extern "C" {
|
|||
/* Color conversion routines */
|
||||
|
||||
|
||||
/* GimpRGB function */
|
||||
|
||||
#define GIMP_HSV_UNDEFINED -1.0
|
||||
#define GIMP_HSL_UNDEFINED -1.0
|
||||
|
||||
void gimp_rgb_to_hsv (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *value);
|
||||
void gimp_rgb_to_hsl (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *lightness);
|
||||
|
||||
void gimp_hsv_to_rgb (gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble value,
|
||||
GimpRGB *rgb);
|
||||
void gimp_hsl_to_rgb (gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble lightness,
|
||||
GimpRGB *rgb);
|
||||
|
||||
void gimp_rgb_to_hwb (GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *whiteness,
|
||||
gdouble *blackness);
|
||||
void gimp_hwb_to_rgb (gdouble hue,
|
||||
gdouble whiteness,
|
||||
gdouble blackness,
|
||||
GimpRGB *rgb);
|
||||
|
||||
|
||||
/* gint functions */
|
||||
|
||||
void gimp_rgb_to_hsv_int (gint *red /* returns hue */,
|
||||
|
@ -83,4 +116,4 @@ void gimp_hsv_to_rgb4 (guchar *rgb,
|
|||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMPCOLORSPACE_H__ */
|
||||
#endif /* __GIMP_COLOR_SPACE_H__ */
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#define __GIMP_TYPES_H__
|
||||
|
||||
|
||||
/* these will go to a separate library soon */
|
||||
#include "gimpcolor.h"
|
||||
#include "gimpunit.h"
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "gimpmodregister.h"
|
||||
|
||||
#include <libgimp/gimpcolorselector.h>
|
||||
#include <libgimp/gimpcolor.h>
|
||||
#include <libgimp/gimpcolorspace.h>
|
||||
#include <libgimp/gimpmodule.h>
|
||||
#include <libgimp/gimpmath.h>
|
||||
|
|
|
@ -29,7 +29,7 @@ init_compute (void)
|
|||
static void
|
||||
render (gdouble x,
|
||||
gdouble y,
|
||||
GckRGB *col)
|
||||
GimpRGB *col)
|
||||
{
|
||||
GimpVector3 pos;
|
||||
|
||||
|
@ -51,7 +51,7 @@ void
|
|||
compute_image (void)
|
||||
{
|
||||
gint xcount, ycount;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
glong progress_counter = 0;
|
||||
GimpVector3 p;
|
||||
gint32 new_image_id = -1;
|
||||
|
|
|
@ -27,7 +27,7 @@ GdkImage *image = NULL;
|
|||
|
||||
glong maxcounter;
|
||||
gint imgtype, width, height, env_width, env_height, in_channels, out_channels;
|
||||
GckRGB background;
|
||||
GimpRGB background;
|
||||
|
||||
gint border_x1, border_y1, border_x2, border_y2;
|
||||
|
||||
|
@ -49,12 +49,12 @@ peek_map (GimpPixelRgn *region,
|
|||
return data;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
peek (gint x,
|
||||
gint y)
|
||||
{
|
||||
guchar data[4];
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_pixel_rgn_get_pixel (&source_region,data, x, y);
|
||||
|
||||
|
@ -77,12 +77,12 @@ peek (gint x,
|
|||
return color;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
peek_env_map (gint x,
|
||||
gint y)
|
||||
{
|
||||
guchar data[4];
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
|
@ -106,7 +106,7 @@ peek_env_map (gint x,
|
|||
void
|
||||
poke (gint x,
|
||||
gint y,
|
||||
GckRGB *color)
|
||||
GimpRGB *color)
|
||||
{
|
||||
static guchar data[4];
|
||||
|
||||
|
@ -235,13 +235,13 @@ pos_to_float (gdouble x,
|
|||
/* Quartics bilinear interpolation stuff. */
|
||||
/**********************************************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_image_color (gdouble u,
|
||||
gdouble v,
|
||||
gint *inside)
|
||||
{
|
||||
gint x1, y1, x2, y2;
|
||||
GckRGB p[4];
|
||||
GimpRGB p[4];
|
||||
|
||||
x1 = RINT (u);
|
||||
y1 = RINT (v);
|
||||
|
|
|
@ -15,7 +15,7 @@ extern GdkImage *image;
|
|||
|
||||
extern glong maxcounter;
|
||||
extern gint imgtype,width,height,env_width,env_height,in_channels,out_channels;
|
||||
extern GckRGB background;
|
||||
extern GimpRGB background;
|
||||
|
||||
extern gint border_x1,border_y1,border_x2,border_y2;
|
||||
|
||||
|
@ -24,13 +24,13 @@ extern guchar sinemap[256], spheremap[256], logmap[256];
|
|||
guchar peek_map (GimpPixelRgn *region,
|
||||
gint x,
|
||||
gint y);
|
||||
GckRGB peek (gint x,
|
||||
GimpRGB peek (gint x,
|
||||
gint y);
|
||||
GckRGB peek_env_map (gint x,
|
||||
GimpRGB peek_env_map (gint x,
|
||||
gint y);
|
||||
void poke (gint x,
|
||||
gint y,
|
||||
GckRGB *color);
|
||||
GimpRGB *color);
|
||||
gint check_bounds (gint x,
|
||||
gint y);
|
||||
GimpVector3 int_to_pos (gint x,
|
||||
|
@ -45,7 +45,7 @@ void pos_to_float (gdouble x,
|
|||
gdouble y,
|
||||
gdouble *xf,
|
||||
gdouble *yf);
|
||||
GckRGB get_image_color (gdouble u,
|
||||
GimpRGB get_image_color (gdouble u,
|
||||
gdouble v,
|
||||
gint *inside);
|
||||
gdouble get_map_value (GimpPixelRgn *region,
|
||||
|
|
|
@ -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);
|
||||
|
||||
gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
|
||||
gimp_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
|
||||
mapvals.lightsource.intensity = 1.0;
|
||||
mapvals.lightsource.type = POINT_LIGHT;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ typedef struct
|
|||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
} MaterialSettings;
|
||||
|
||||
typedef struct
|
||||
|
@ -46,7 +46,7 @@ typedef struct
|
|||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
||||
|
@ -96,6 +96,6 @@ typedef struct
|
|||
/* ============================ */
|
||||
|
||||
extern LightingValues mapvals;
|
||||
extern GckRGB background;
|
||||
extern GimpRGB background;
|
||||
|
||||
#endif /* __LIGHTING_MAIN_H__ */
|
||||
|
|
|
@ -39,7 +39,7 @@ compute_preview (gint startx,
|
|||
gint xcnt, ycnt, f1, f2;
|
||||
gdouble imagex, imagey;
|
||||
gint32 index = 0;
|
||||
GckRGB color, darkcheck, lightcheck, temp;
|
||||
GimpRGB color, darkcheck, lightcheck, temp;
|
||||
GimpVector3 pos;
|
||||
get_ray_func ray_func;
|
||||
|
||||
|
@ -80,9 +80,9 @@ compute_preview (gint startx,
|
|||
init_compute ();
|
||||
precompute_init (width, height);
|
||||
|
||||
gck_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
|
||||
gck_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
|
||||
gck_rgb_set (&color, 0.3, 0.7, 1.0);
|
||||
gimp_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
|
||||
gimp_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
|
||||
gimp_rgb_set (&color, 0.3, 0.7, 1.0);
|
||||
|
||||
if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
|
||||
{
|
||||
|
@ -146,10 +146,10 @@ compute_preview (gint startx,
|
|||
}
|
||||
else
|
||||
{
|
||||
gck_rgb_mul (&color, color.a);
|
||||
gimp_rgb_mul (&color, color.a);
|
||||
temp = lightcheck;
|
||||
gck_rgb_mul (&temp, 1.0 - color.a);
|
||||
gck_rgb_add (&color, &temp);
|
||||
gimp_rgb_mul (&temp, 1.0 - color.a);
|
||||
gimp_rgb_add (&color, &temp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -160,10 +160,10 @@ compute_preview (gint startx,
|
|||
}
|
||||
else
|
||||
{
|
||||
gck_rgb_mul (&color, color.a);
|
||||
gimp_rgb_mul (&color, color.a);
|
||||
temp = darkcheck;
|
||||
gck_rgb_mul (&temp, 1.0 - color.a);
|
||||
gck_rgb_add (&color, &temp);
|
||||
gimp_rgb_mul (&temp, 1.0 - color.a);
|
||||
gimp_rgb_add (&color, &temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,16 +25,16 @@ static gint pre_h = -1;
|
|||
/* Phong shading */
|
||||
/*****************/
|
||||
|
||||
static GckRGB
|
||||
static GimpRGB
|
||||
phong_shade (GimpVector3 *position,
|
||||
GimpVector3 *viewpoint,
|
||||
GimpVector3 *normal,
|
||||
GimpVector3 *lightposition,
|
||||
GckRGB *diff_col,
|
||||
GckRGB *spec_col,
|
||||
GimpRGB *diff_col,
|
||||
GimpRGB *spec_col,
|
||||
LightType light_type)
|
||||
{
|
||||
GckRGB ambient_color, diffuse_color, specular_color;
|
||||
GimpRGB ambient_color, diffuse_color, specular_color;
|
||||
gdouble nl, rv, dist;
|
||||
GimpVector3 l, nn, v, n;
|
||||
|
||||
|
@ -43,7 +43,7 @@ phong_shade (GimpVector3 *position,
|
|||
|
||||
n = *normal;
|
||||
ambient_color = *diff_col;
|
||||
gck_rgb_mul (&ambient_color, mapvals.material.ambient_int);
|
||||
gimp_rgb_mul (&ambient_color, mapvals.material.ambient_int);
|
||||
|
||||
/* Compute (N*L) term of Phong's equation */
|
||||
/* ====================================== */
|
||||
|
@ -77,21 +77,21 @@ phong_shade (GimpVector3 *position,
|
|||
/* =================================================== */
|
||||
|
||||
diffuse_color = *diff_col;
|
||||
gck_rgb_mul (&diffuse_color, mapvals.material.diffuse_ref);
|
||||
gck_rgb_mul (&diffuse_color, nl);
|
||||
gimp_rgb_mul (&diffuse_color, mapvals.material.diffuse_ref);
|
||||
gimp_rgb_mul (&diffuse_color, nl);
|
||||
|
||||
specular_color = *spec_col;
|
||||
gck_rgb_mul (&specular_color, mapvals.material.specular_ref);
|
||||
gck_rgb_mul (&specular_color, rv);
|
||||
gimp_rgb_mul (&specular_color, mapvals.material.specular_ref);
|
||||
gimp_rgb_mul (&specular_color, rv);
|
||||
|
||||
gck_rgb_add (&diffuse_color, &specular_color);
|
||||
gck_rgb_mul (&diffuse_color, mapvals.material.diffuse_int);
|
||||
gck_rgb_clamp (&diffuse_color);
|
||||
gimp_rgb_add (&diffuse_color, &specular_color);
|
||||
gimp_rgb_mul (&diffuse_color, mapvals.material.diffuse_int);
|
||||
gimp_rgb_clamp (&diffuse_color);
|
||||
|
||||
gck_rgb_add (&ambient_color, &diffuse_color);
|
||||
gimp_rgb_add (&ambient_color, &diffuse_color);
|
||||
}
|
||||
|
||||
gck_rgb_clamp (&ambient_color);
|
||||
gimp_rgb_clamp (&ambient_color);
|
||||
|
||||
return ambient_color;
|
||||
}
|
||||
|
@ -444,10 +444,10 @@ sphere_to_image (GimpVector3 *normal,
|
|||
/* These routines computes the color of the surface at a given point */
|
||||
/*********************************************************************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color (GimpVector3 *position)
|
||||
{
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
gint x, f;
|
||||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p;
|
||||
|
@ -496,10 +496,10 @@ get_ray_color (GimpVector3 *position)
|
|||
return color;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_ref (GimpVector3 *position)
|
||||
{
|
||||
GckRGB color, env_color;
|
||||
GimpRGB color, env_color;
|
||||
gint x, f;
|
||||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p, v, r;
|
||||
|
@ -560,10 +560,10 @@ get_ray_color_ref (GimpVector3 *position)
|
|||
return color;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_no_bilinear (GimpVector3 *position)
|
||||
{
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
gint x;
|
||||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p;
|
||||
|
@ -612,10 +612,10 @@ get_ray_color_no_bilinear (GimpVector3 *position)
|
|||
return color;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_no_bilinear_ref (GimpVector3 *position)
|
||||
{
|
||||
GckRGB color, env_color;
|
||||
GimpRGB color, env_color;
|
||||
gint x;
|
||||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p, v, r;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#ifndef __LIGHTING_SHADE_H__
|
||||
#define __LIGHTING_SHADE_H__
|
||||
|
||||
typedef GckRGB (* get_ray_func) (GimpVector3 *vector);
|
||||
typedef GimpRGB (* get_ray_func) (GimpVector3 *vector);
|
||||
|
||||
GckRGB get_ray_color (GimpVector3 *position);
|
||||
GckRGB get_ray_color_no_bilinear (GimpVector3 *position);
|
||||
GckRGB get_ray_color_ref (GimpVector3 *position);
|
||||
GckRGB get_ray_color_no_bilinear_ref (GimpVector3 *position);
|
||||
GimpRGB get_ray_color (GimpVector3 *position);
|
||||
GimpRGB get_ray_color_no_bilinear (GimpVector3 *position);
|
||||
GimpRGB get_ray_color_ref (GimpVector3 *position);
|
||||
GimpRGB get_ray_color_no_bilinear_ref (GimpVector3 *position);
|
||||
|
||||
void precompute_init (gint w,
|
||||
gint h);
|
||||
void precompute_normals (gint x1,
|
||||
gint x2,
|
||||
gint y);
|
||||
void precompute_init (gint w,
|
||||
gint h);
|
||||
void precompute_normals (gint x1,
|
||||
gint x2,
|
||||
gint y);
|
||||
|
||||
#endif /* __LIGHTING_SHADE_H__ */
|
||||
|
|
|
@ -189,7 +189,7 @@ init_compute (void)
|
|||
void
|
||||
render (gdouble x,
|
||||
gdouble y,
|
||||
GckRGB *col)
|
||||
GimpRGB *col)
|
||||
{
|
||||
GimpVector3 pos;
|
||||
|
||||
|
@ -217,7 +217,7 @@ void
|
|||
compute_image (void)
|
||||
{
|
||||
gint xcount, ycount;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
glong progress_counter = 0;
|
||||
GimpVector3 p;
|
||||
gint32 new_image_id = -1;
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include "mapobject_main.h"
|
||||
#include "mapobject_preview.h"
|
||||
#include "mapobject_shade.h"
|
||||
|
@ -35,7 +35,7 @@ GdkImage *image = NULL;
|
|||
|
||||
glong maxcounter,old_depth,max_depth;
|
||||
gint imgtype,width,height,in_channels,out_channels;
|
||||
GckRGB background;
|
||||
GimpRGB background;
|
||||
gdouble oldtreshold;
|
||||
|
||||
gint border_x1, border_y1, border_x2, border_y2;
|
||||
|
@ -44,13 +44,13 @@ gint border_x1, border_y1, border_x2, border_y2;
|
|||
/* Implementation */
|
||||
/******************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
peek (gint x,
|
||||
gint y)
|
||||
{
|
||||
static guchar data[4];
|
||||
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_pixel_rgn_get_pixel (&source_region, data, x, y);
|
||||
|
||||
|
@ -73,14 +73,14 @@ peek (gint x,
|
|||
return color;
|
||||
}
|
||||
|
||||
static GckRGB
|
||||
static GimpRGB
|
||||
peek_box_image (gint image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
static guchar data[4];
|
||||
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_pixel_rgn_get_pixel (&box_regions[image], data, x, y);
|
||||
|
||||
|
@ -103,14 +103,14 @@ peek_box_image (gint image,
|
|||
return color;
|
||||
}
|
||||
|
||||
static GckRGB
|
||||
static GimpRGB
|
||||
peek_cylinder_image (gint image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
static guchar data[4];
|
||||
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_pixel_rgn_get_pixel (&cylinder_regions[image],data, x, y);
|
||||
|
||||
|
@ -136,7 +136,7 @@ peek_cylinder_image (gint image,
|
|||
void
|
||||
poke (gint x,
|
||||
gint y,
|
||||
GckRGB *color)
|
||||
GimpRGB *color)
|
||||
{
|
||||
static guchar data[4];
|
||||
|
||||
|
@ -218,13 +218,13 @@ pos_to_int (gdouble x,
|
|||
/* Quartics bilinear interpolation stuff. */
|
||||
/**********************************************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_image_color (gdouble u,
|
||||
gdouble v,
|
||||
gint *inside)
|
||||
{
|
||||
gint x1, y1, x2, y2;
|
||||
GckRGB p[4];
|
||||
GimpRGB p[4];
|
||||
|
||||
pos_to_int (u, v, &x1, &y1);
|
||||
|
||||
|
@ -276,13 +276,13 @@ get_image_color (gdouble u,
|
|||
return gck_bilinear_rgba (u * width, v * height, p);
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_box_image_color (gint image,
|
||||
gdouble u,
|
||||
gdouble v)
|
||||
{
|
||||
gint w,h, x1, y1, x2, y2;
|
||||
GckRGB p[4];
|
||||
GimpRGB p[4];
|
||||
|
||||
w = box_drawables[image]->width;
|
||||
h = box_drawables[image]->height;
|
||||
|
@ -307,13 +307,13 @@ get_box_image_color (gint image,
|
|||
return gck_bilinear_rgba (u * w, v * h, p);
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_cylinder_image_color (gint image,
|
||||
gdouble u,
|
||||
gdouble v)
|
||||
{
|
||||
gint w,h, x1, y1, x2, y2;
|
||||
GckRGB p[4];
|
||||
GimpRGB p[4];
|
||||
|
||||
w = cylinder_drawables[image]->width;
|
||||
h = cylinder_drawables[image]->height;
|
||||
|
@ -374,7 +374,7 @@ image_setup (GimpDrawable *drawable,
|
|||
|
||||
if (mapvals.transparent_background == TRUE)
|
||||
{
|
||||
gck_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
|
||||
gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ extern GdkImage *image;
|
|||
|
||||
extern glong maxcounter, old_depth, max_depth;
|
||||
extern gint imgtype, width,height, in_channels, out_channels;
|
||||
extern GckRGB background;
|
||||
extern GimpRGB background;
|
||||
extern gdouble oldtreshold;
|
||||
|
||||
extern gint border_x1, border_y1, border_x2, border_y2;
|
||||
|
@ -36,11 +36,11 @@ extern glong out_xy_to_index (gint x,
|
|||
gint y);
|
||||
extern gint checkbounds (gint x,
|
||||
gint y);
|
||||
extern GckRGB peek (gint x,
|
||||
extern GimpRGB peek (gint x,
|
||||
gint y);
|
||||
extern void poke (gint x,
|
||||
gint y,
|
||||
GckRGB *color);
|
||||
GimpRGB *color);
|
||||
extern GimpVector3 int_to_pos (gint x,
|
||||
gint y);
|
||||
extern void pos_to_int (gdouble x,
|
||||
|
@ -48,13 +48,13 @@ extern void pos_to_int (gdouble x,
|
|||
gint *scr_x,
|
||||
gint *scr_y);
|
||||
|
||||
extern GckRGB get_image_color (gdouble u,
|
||||
extern GimpRGB get_image_color (gdouble u,
|
||||
gdouble v,
|
||||
gint *inside);
|
||||
extern GckRGB get_box_image_color (gint image,
|
||||
extern GimpRGB get_box_image_color (gint image,
|
||||
gdouble u,
|
||||
gdouble v);
|
||||
extern GckRGB get_cylinder_image_color (gint image,
|
||||
extern GimpRGB get_cylinder_image_color (gint image,
|
||||
gdouble u,
|
||||
gdouble v);
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include "arcball.h"
|
||||
#include "mapobject_ui.h"
|
||||
#include "mapobject_image.h"
|
||||
|
@ -89,7 +89,7 @@ set_default_settings (void)
|
|||
mapvals.tooltips_enabled = TRUE;
|
||||
|
||||
mapvals.lightsource.intensity = 1.0;
|
||||
gck_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
|
||||
gimp_rgb_set (&mapvals.lightsource.color, 1.0, 1.0, 1.0);
|
||||
|
||||
mapvals.material.ambient_int = 0.3;
|
||||
mapvals.material.diffuse_int = 1.0;
|
||||
|
|
|
@ -34,7 +34,7 @@ typedef struct
|
|||
gdouble diffuse_ref;
|
||||
gdouble specular_ref;
|
||||
gdouble highlight;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
} MaterialSettings;
|
||||
|
||||
typedef struct
|
||||
|
@ -42,7 +42,7 @@ typedef struct
|
|||
LightType type;
|
||||
GimpVector3 position;
|
||||
GimpVector3 direction;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
gdouble intensity;
|
||||
} LightSettings;
|
||||
|
||||
|
@ -82,6 +82,6 @@ typedef struct
|
|||
/* ============================ */
|
||||
|
||||
extern MapObjectValues mapvals;
|
||||
extern GckRGB background;
|
||||
extern GimpRGB background;
|
||||
|
||||
#endif /* __MAPOBJECT_MAIN_H__ */
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
||||
#include <gck/gck.h>
|
||||
|
||||
#include "arcball.h"
|
||||
#include "mapobject_main.h"
|
||||
#include "mapobject_ui.h"
|
||||
|
@ -165,9 +165,9 @@ compute_preview (gint x,
|
|||
gdouble realw;
|
||||
gdouble realh;
|
||||
GimpVector3 p1, p2;
|
||||
GckRGB color;
|
||||
GckRGB lightcheck, darkcheck;
|
||||
GckRGB temp;
|
||||
GimpRGB color;
|
||||
GimpRGB lightcheck, darkcheck;
|
||||
GimpRGB temp;
|
||||
guchar r, g, b;
|
||||
gint xcnt, ycnt, f1, f2;
|
||||
glong index = 0;
|
||||
|
@ -194,7 +194,7 @@ compute_preview (gint x,
|
|||
|
||||
if (mapvals.transparent_background == TRUE)
|
||||
{
|
||||
gck_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
|
||||
gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -205,8 +205,8 @@ compute_preview (gint x,
|
|||
background.a = 1.0;
|
||||
}
|
||||
|
||||
gck_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
|
||||
gck_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
|
||||
gimp_rgb_set (&lightcheck, 0.75, 0.75, 0.75);
|
||||
gimp_rgb_set (&darkcheck, 0.50, 0.50, 0.50);
|
||||
gimp_vector3_set (&p2, -1.0, -1.0, 0.0);
|
||||
|
||||
for (ycnt = 0; ycnt < ph; ycnt++)
|
||||
|
@ -233,10 +233,10 @@ compute_preview (gint x,
|
|||
}
|
||||
else
|
||||
{
|
||||
gck_rgb_mul (&color, color.a);
|
||||
gimp_rgb_mul (&color, color.a);
|
||||
temp = lightcheck;
|
||||
gck_rgb_mul (&temp, 1.0 - color.a);
|
||||
gck_rgb_add (&color, &temp);
|
||||
gimp_rgb_mul (&temp, 1.0 - color.a);
|
||||
gimp_rgb_add (&color, &temp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -247,10 +247,10 @@ compute_preview (gint x,
|
|||
}
|
||||
else
|
||||
{
|
||||
gck_rgb_mul (&color, color.a);
|
||||
gimp_rgb_mul (&color, color.a);
|
||||
temp = darkcheck;
|
||||
gck_rgb_mul (&temp, 1.0 - color.a);
|
||||
gck_rgb_add (&color, &temp);
|
||||
gimp_rgb_mul (&temp, 1.0 - color.a);
|
||||
gimp_rgb_add (&color, &temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,16 +31,16 @@ typedef struct
|
|||
/* Phong shading */
|
||||
/*****************/
|
||||
|
||||
static GckRGB
|
||||
static GimpRGB
|
||||
phong_shade (GimpVector3 *pos,
|
||||
GimpVector3 *viewpoint,
|
||||
GimpVector3 *normal,
|
||||
GimpVector3 *light,
|
||||
GckRGB *diff_col,
|
||||
GckRGB *spec_col,
|
||||
GimpRGB *diff_col,
|
||||
GimpRGB *spec_col,
|
||||
gint type)
|
||||
{
|
||||
GckRGB ambientcolor, diffusecolor, specularcolor;
|
||||
GimpRGB ambientcolor, diffusecolor, specularcolor;
|
||||
gdouble NL, RV, dist;
|
||||
GimpVector3 L, NN, V, N;
|
||||
|
||||
|
@ -49,7 +49,7 @@ phong_shade (GimpVector3 *pos,
|
|||
|
||||
N = *normal;
|
||||
ambientcolor = *diff_col;
|
||||
gck_rgb_mul (&ambientcolor, mapvals.material.ambient_int);
|
||||
gimp_rgb_mul (&ambientcolor, mapvals.material.ambient_int);
|
||||
|
||||
/* Compute (N*L) term of Phong's equation */
|
||||
/* ====================================== */
|
||||
|
@ -83,18 +83,18 @@ phong_shade (GimpVector3 *pos,
|
|||
/* =================================================== */
|
||||
|
||||
diffusecolor = *diff_col;
|
||||
gck_rgb_mul (&diffusecolor, mapvals.material.diffuse_ref);
|
||||
gck_rgb_mul (&diffusecolor, NL);
|
||||
gimp_rgb_mul (&diffusecolor, mapvals.material.diffuse_ref);
|
||||
gimp_rgb_mul (&diffusecolor, NL);
|
||||
|
||||
specularcolor = *spec_col;
|
||||
gck_rgb_mul (&specularcolor, mapvals.material.specular_ref);
|
||||
gck_rgb_mul (&specularcolor, RV);
|
||||
gimp_rgb_mul (&specularcolor, mapvals.material.specular_ref);
|
||||
gimp_rgb_mul (&specularcolor, RV);
|
||||
|
||||
gck_rgb_add (&diffusecolor, &specularcolor);
|
||||
gck_rgb_mul (&diffusecolor, mapvals.material.diffuse_int);
|
||||
gck_rgb_clamp (&diffusecolor);
|
||||
gimp_rgb_add (&diffusecolor, &specularcolor);
|
||||
gimp_rgb_mul (&diffusecolor, mapvals.material.diffuse_int);
|
||||
gimp_rgb_clamp (&diffusecolor);
|
||||
|
||||
gck_rgb_add (&ambientcolor, &diffusecolor);
|
||||
gimp_rgb_add (&ambientcolor, &diffusecolor);
|
||||
}
|
||||
|
||||
return ambientcolor;
|
||||
|
@ -179,10 +179,10 @@ plane_intersect (GimpVector3 *dir,
|
|||
* of the plane at a given point
|
||||
*****************************************************************************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_plane (GimpVector3 *pos)
|
||||
{
|
||||
GckRGB color = background;
|
||||
GimpRGB color = background;
|
||||
|
||||
static gint inside = FALSE;
|
||||
static GimpVector3 ray, spos;
|
||||
|
@ -215,7 +215,7 @@ get_ray_color_plane (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgb_clamp (&color);
|
||||
gimp_rgb_clamp (&color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,12 +317,12 @@ sphere_intersect (GimpVector3 *dir,
|
|||
* of the sphere at a given point
|
||||
*****************************************************************************/
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_sphere (GimpVector3 *pos)
|
||||
{
|
||||
GckRGB color=background;
|
||||
GimpRGB color=background;
|
||||
|
||||
static GckRGB 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);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
|
||||
gimp_vector3_sub (&normal, &spos2, &mapvals.position);
|
||||
gimp_vector3_normalize (&normal);
|
||||
|
@ -389,7 +389,7 @@ get_ray_color_sphere (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color2);
|
||||
gimp_rgba_clamp (&color2);
|
||||
|
||||
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
|
||||
{
|
||||
|
@ -407,7 +407,7 @@ get_ray_color_sphere (GimpVector3 *pos)
|
|||
color.b = color.b*color.a+(1.0-color.a)*color2.b;
|
||||
color.a = color.a+color2.a;
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
else if (color.a!=0.0 &&
|
||||
inside==TRUE &&
|
||||
|
@ -424,7 +424,7 @@ get_ray_color_sphere (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -840,11 +840,11 @@ intersect_box (GimpVector3 scale,
|
|||
return result;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_box (GimpVector3 *pos)
|
||||
{
|
||||
GimpVector3 lvp, ldir, vp, p, dir, ns, nn;
|
||||
GckRGB color, color2;
|
||||
GimpRGB color, color2;
|
||||
gfloat m[16];
|
||||
gint i;
|
||||
FaceIntersectInfo face_intersect[2];
|
||||
|
@ -931,7 +931,7 @@ get_ray_color_box (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
|
||||
color2 = get_box_image_color (face_intersect[1].face,
|
||||
face_intersect[1].u,
|
||||
|
@ -950,7 +950,7 @@ get_ray_color_box (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color2);
|
||||
gimp_rgba_clamp (&color2);
|
||||
|
||||
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
|
||||
{
|
||||
|
@ -968,7 +968,7 @@ get_ray_color_box (GimpVector3 *pos)
|
|||
color.b = color.b * color.a + (1.0 - color.a) * color2.b;
|
||||
color.a = color.a + color2.a;
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
else if (color.a != 0.0 && mapvals.lightsource.type != NO_LIGHT)
|
||||
{
|
||||
|
@ -980,7 +980,7 @@ get_ray_color_box (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1121,12 +1121,12 @@ intersect_cylinder (GimpVector3 vp,
|
|||
return result;
|
||||
}
|
||||
|
||||
static GckRGB
|
||||
static GimpRGB
|
||||
get_cylinder_color (gint face,
|
||||
gdouble u,
|
||||
gdouble v)
|
||||
{
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
gint inside;
|
||||
|
||||
if (face == 0)
|
||||
|
@ -1137,11 +1137,11 @@ get_cylinder_color (gint face,
|
|||
return color;
|
||||
}
|
||||
|
||||
GckRGB
|
||||
GimpRGB
|
||||
get_ray_color_cylinder (GimpVector3 *pos)
|
||||
{
|
||||
GimpVector3 lvp, ldir, vp, p, dir, ns, nn;
|
||||
GckRGB color, color2;
|
||||
GimpRGB color, color2;
|
||||
gfloat m[16];
|
||||
gint i;
|
||||
FaceIntersectInfo face_intersect[2];
|
||||
|
@ -1216,7 +1216,7 @@ get_ray_color_cylinder (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
|
||||
color2 = get_cylinder_color (face_intersect[1].face,
|
||||
face_intersect[1].u,
|
||||
|
@ -1235,7 +1235,7 @@ get_ray_color_cylinder (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color2);
|
||||
gimp_rgba_clamp (&color2);
|
||||
|
||||
if (mapvals.transparent_background == FALSE && color2.a < 1.0)
|
||||
{
|
||||
|
@ -1253,7 +1253,7 @@ get_ray_color_cylinder (GimpVector3 *pos)
|
|||
color.b = color.b*color.a + (1.0-color.a)*color2.b;
|
||||
color.a = color.a+color2.a;
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
else if (color.a != 0.0 && mapvals.lightsource.type != NO_LIGHT)
|
||||
{
|
||||
|
@ -1265,7 +1265,7 @@ get_ray_color_cylinder (GimpVector3 *pos)
|
|||
&mapvals.lightsource.color,
|
||||
mapvals.lightsource.type);
|
||||
|
||||
gck_rgba_clamp (&color);
|
||||
gimp_rgba_clamp (&color);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#ifndef __MAPOBJECT_SHADE_H__
|
||||
#define __MAPOBJECT_SHADE_H__
|
||||
|
||||
typedef GckRGB (* get_ray_color_func) (GimpVector3 *pos);
|
||||
typedef GimpRGB (* get_ray_color_func) (GimpVector3 *pos);
|
||||
|
||||
extern get_ray_color_func get_ray_color;
|
||||
|
||||
GckRGB get_ray_color_plane (GimpVector3 *pos);
|
||||
GckRGB get_ray_color_sphere (GimpVector3 *pos);
|
||||
GckRGB get_ray_color_box (GimpVector3 *pos);
|
||||
GckRGB get_ray_color_cylinder (GimpVector3 *pos);
|
||||
GimpRGB get_ray_color_plane (GimpVector3 *pos);
|
||||
GimpRGB get_ray_color_sphere (GimpVector3 *pos);
|
||||
GimpRGB get_ray_color_box (GimpVector3 *pos);
|
||||
GimpRGB get_ray_color_cylinder (GimpVector3 *pos);
|
||||
void compute_bounding_box (void);
|
||||
|
||||
void vecmulmat (GimpVector3 *u,
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef enum
|
|||
|
||||
|
||||
/* gimp-1.1.14+ function names reorganization forgotten something */
|
||||
#if defined(GIMP_HAVE_PARASITES) && GIMP_MICRO_VERSION < 14
|
||||
#if defined(GIMP_HAVE_PARASITES) && GIMP_MINOR_VERSION < 2 && GIMP_MICRO_VERSION < 14
|
||||
# warning Replacing missing function 'gimp_drawable_parasite_find'
|
||||
# define gimp_drawable_parasite_find gimp_drawable_parasite_find
|
||||
#endif
|
||||
|
|
|
@ -36,20 +36,12 @@ extern "C" {
|
|||
#define GCK_CONSTRAIN_INDEXEDA 1<<5
|
||||
#define GCK_CONSTRAIN_ALL 0xff
|
||||
|
||||
#define GCK_HSV_UNDEFINED -1.0
|
||||
#define GCK_HSL_UNDEFINED -1.0
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DITHER_NONE,
|
||||
DITHER_FLOYD_STEINBERG
|
||||
} GckDitherType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gdouble r, g, b, a;
|
||||
} GckRGB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkVisual *visual;
|
||||
|
@ -64,10 +56,10 @@ typedef struct
|
|||
GckDitherType dithermethod;
|
||||
} GckVisualInfo;
|
||||
|
||||
typedef void (* GckRenderFunction) (gdouble, gdouble, GckRGB *);
|
||||
typedef void (* GckPutPixelFunction) (gint, gint, GckRGB *);
|
||||
typedef void (* GckRenderFunction) (gdouble, gdouble, GimpRGB *);
|
||||
typedef void (* GckPutPixelFunction) (gint, gint, GimpRGB *);
|
||||
typedef void (* GckProgressFunction) (gint, gint, gint);
|
||||
typedef void (* GckColorUpdateFunction) (GckRGB *);
|
||||
typedef void (* GckColorUpdateFunction) (GimpRGB *);
|
||||
|
||||
|
||||
GckVisualInfo *gck_visualinfo_new (void);
|
||||
|
@ -96,37 +88,8 @@ double gck_bilinear (double x,double y, double *values);
|
|||
guchar gck_bilinear_8 (double x,double y, guchar *values);
|
||||
guint16 gck_bilinear_16 (double x,double y, guint16 *values);
|
||||
guint32 gck_bilinear_32 (double x,double y, guint32 *values);
|
||||
GckRGB gck_bilinear_rgb (double x,double y, GckRGB *values);
|
||||
GckRGB gck_bilinear_rgba (double x,double y, GckRGB *values);
|
||||
|
||||
/* RGB pixel operations */
|
||||
/* ==================== */
|
||||
|
||||
void gck_rgb_add (GckRGB *p,GckRGB *q);
|
||||
void gck_rgb_sub (GckRGB *p,GckRGB *q);
|
||||
void gck_rgb_mul (GckRGB *p,double b);
|
||||
void gck_rgb_clamp (GckRGB *p);
|
||||
void gck_rgb_set (GckRGB *p,double r,double g,double b);
|
||||
void gck_rgb_gamma (GckRGB *p,double gamma);
|
||||
|
||||
void gck_rgba_add (GckRGB *p,GckRGB *q);
|
||||
void gck_rgba_sub (GckRGB *p,GckRGB *q);
|
||||
void gck_rgba_mul (GckRGB *p,double b);
|
||||
void gck_rgba_clamp (GckRGB *p);
|
||||
void gck_rgba_set (GckRGB *p,double r,double g,double b,double a);
|
||||
void gck_rgba_gamma (GckRGB *p,double gamma);
|
||||
|
||||
/* Colorspace conversions */
|
||||
/* ====================== */
|
||||
|
||||
void gck_rgb_to_hsv (GckRGB *p, double *h,double *s,double *v);
|
||||
void gck_rgb_to_hsl (GckRGB *p, double *h,double *s,double *l);
|
||||
|
||||
void gck_hsv_to_rgb (double h,double s,double v, GckRGB *p);
|
||||
void gck_hsl_to_rgb (double h,double s,double l, GckRGB *p);
|
||||
|
||||
void gck_rgb_to_hwb (GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness);
|
||||
void gck_hwb_to_rgb (gdouble H,gdouble W, gdouble B, GckRGB *rgb);
|
||||
GimpRGB gck_bilinear_rgb (double x,double y, GimpRGB *values);
|
||||
GimpRGB gck_bilinear_rgba (double x,double y, GimpRGB *values);
|
||||
|
||||
/* Supersampling */
|
||||
/* ============= */
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "libgimp/gimpcolor.h"
|
||||
#include "libgimp/gimpcolorspace.h"
|
||||
#include "libgimp/gimpmath.h"
|
||||
|
||||
#include "gck.h"
|
||||
|
@ -43,7 +45,7 @@
|
|||
typedef struct
|
||||
{
|
||||
guchar ready;
|
||||
GckRGB color;
|
||||
GimpRGB color;
|
||||
} _GckSampleType;
|
||||
|
||||
|
||||
|
@ -1365,11 +1367,11 @@ guint32 gck_bilinear_32(double x, double y, guint32 * values)
|
|||
return ((guint32) ((1.0 - yy) * m0 + yy * m1));
|
||||
}
|
||||
|
||||
GckRGB gck_bilinear_rgb(double x, double y, GckRGB *values)
|
||||
GimpRGB gck_bilinear_rgb(double x, double y, GimpRGB *values)
|
||||
{
|
||||
double m0, m1;
|
||||
double ix, iy;
|
||||
GckRGB v;
|
||||
GimpRGB v;
|
||||
|
||||
g_assert(values!=NULL);
|
||||
|
||||
|
@ -1411,11 +1413,11 @@ GckRGB gck_bilinear_rgb(double x, double y, GckRGB *values)
|
|||
return (v);
|
||||
} /* bilinear */
|
||||
|
||||
GckRGB gck_bilinear_rgba(double x, double y, GckRGB *values)
|
||||
GimpRGB gck_bilinear_rgba(double x, double y, GimpRGB *values)
|
||||
{
|
||||
double m0, m1;
|
||||
double ix, iy;
|
||||
GckRGB v;
|
||||
GimpRGB v;
|
||||
|
||||
g_assert(values!=NULL);
|
||||
|
||||
|
@ -1465,540 +1467,6 @@ GckRGB gck_bilinear_rgba(double x, double y, GckRGB *values)
|
|||
return (v);
|
||||
} /* bilinear */
|
||||
|
||||
/********************************/
|
||||
/* Multiple channels operations */
|
||||
/********************************/
|
||||
|
||||
void gck_rgb_add(GckRGB * p, GckRGB * q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
p->r = p->r + q->r;
|
||||
p->g = p->g + q->g;
|
||||
p->b = p->b + q->b;
|
||||
|
||||
}
|
||||
|
||||
void gck_rgb_sub(GckRGB * p, GckRGB * q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
p->r = p->r - q->r;
|
||||
p->g = p->g - q->g;
|
||||
p->b = p->b - q->b;
|
||||
}
|
||||
|
||||
void gck_rgb_mul(GckRGB * p, double b)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
p->r = p->r * b;
|
||||
p->g = p->g * b;
|
||||
p->b = p->b * b;
|
||||
}
|
||||
|
||||
double gck_rgb_dist(GckRGB * p, GckRGB * q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
return (fabs(p->r - q->r) + fabs(p->g - q->g) + fabs(p->b - q->b));
|
||||
}
|
||||
|
||||
double gck_rgb_max(GckRGB * p)
|
||||
{
|
||||
double max;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
max = p->r;
|
||||
if (p->g > max)
|
||||
max = p->g;
|
||||
if (p->b > max)
|
||||
max = p->b;
|
||||
|
||||
return (max);
|
||||
}
|
||||
|
||||
double gck_rgb_min(GckRGB * p)
|
||||
{
|
||||
double min;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
min=p->r;
|
||||
if (p->g < min)
|
||||
min = p->g;
|
||||
if (p->b < min)
|
||||
min = p->b;
|
||||
|
||||
return (min);
|
||||
}
|
||||
|
||||
void gck_rgb_clamp(GckRGB * p)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (p->r > 1.0)
|
||||
p->r = 1.0;
|
||||
if (p->g > 1.0)
|
||||
p->g = 1.0;
|
||||
if (p->b > 1.0)
|
||||
p->b = 1.0;
|
||||
if (p->r < 0.0)
|
||||
p->r = 0.0;
|
||||
if (p->g < 0.0)
|
||||
p->g = 0.0;
|
||||
if (p->b < 0.0)
|
||||
p->b = 0.0;
|
||||
}
|
||||
|
||||
void gck_rgb_set(GckRGB * p, double r, double g, double b)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
p->r = r;
|
||||
p->g = g;
|
||||
p->b = b;
|
||||
|
||||
}
|
||||
|
||||
void gck_rgb_gamma(GckRGB * p, double gamma)
|
||||
{
|
||||
double ig;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (gamma != 0.0)
|
||||
ig = 1.0 / gamma;
|
||||
else
|
||||
(ig = 0.0);
|
||||
|
||||
p->r = pow(p->r, ig);
|
||||
p->g = pow(p->g, ig);
|
||||
p->b = pow(p->b, ig);
|
||||
}
|
||||
|
||||
void gck_rgba_add(GckRGB * p, GckRGB * q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
p->r = p->r + q->r;
|
||||
p->g = p->g + q->g;
|
||||
p->b = p->b + q->b;
|
||||
p->a = p->a + q->a;
|
||||
}
|
||||
|
||||
void gck_rgba_sub(GckRGB * p, GckRGB * q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
p->r = p->r - q->r;
|
||||
p->g = p->g - q->g;
|
||||
p->b = p->b - q->b;
|
||||
p->a = p->a - q->a;
|
||||
}
|
||||
|
||||
void gck_rgba_mul(GckRGB * p, double b)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
p->r = p->r * b;
|
||||
p->g = p->g * b;
|
||||
p->b = p->b * b;
|
||||
p->a = p->a * b;
|
||||
}
|
||||
|
||||
double gck_rgba_dist(GckRGB *p, GckRGB *q)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
g_assert(q!=NULL);
|
||||
|
||||
return (fabs(p->r - q->r) + fabs(p->g - q->g) +
|
||||
fabs(p->b - q->b) + fabs(p->a - q->a));
|
||||
}
|
||||
|
||||
/* These two are probably not needed */
|
||||
|
||||
double gck_rgba_max(GckRGB * p)
|
||||
{
|
||||
double max;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
max = p->r;
|
||||
|
||||
if (p->g > max)
|
||||
max = p->g;
|
||||
if (p->b > max)
|
||||
max = p->b;
|
||||
if (p->a > max)
|
||||
max = p->a;
|
||||
|
||||
return (max);
|
||||
}
|
||||
|
||||
double gck_rgba_min(GckRGB * p)
|
||||
{
|
||||
double min;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
min = p->r;
|
||||
if (p->g < min)
|
||||
min = p->g;
|
||||
if (p->b < min)
|
||||
min = p->b;
|
||||
if (p->a < min)
|
||||
min = p->a;
|
||||
|
||||
return (min);
|
||||
}
|
||||
|
||||
void gck_rgba_clamp(GckRGB * p)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (p->r > 1.0)
|
||||
p->r = 1.0;
|
||||
if (p->g > 1.0)
|
||||
p->g = 1.0;
|
||||
if (p->b > 1.0)
|
||||
p->b = 1.0;
|
||||
if (p->a > 1.0)
|
||||
p->a = 1.0;
|
||||
if (p->r < 0.0)
|
||||
p->r = 0.0;
|
||||
if (p->g < 0.0)
|
||||
p->g = 0.0;
|
||||
if (p->b < 0.0)
|
||||
p->b = 0.0;
|
||||
if (p->a < 0.0)
|
||||
p->a = 0.0;
|
||||
}
|
||||
|
||||
void gck_rgba_set(GckRGB * p, double r, double g, double b, double a)
|
||||
{
|
||||
g_assert(p!=NULL);
|
||||
|
||||
p->r = r;
|
||||
p->g = g;
|
||||
p->b = b;
|
||||
p->a = a;
|
||||
}
|
||||
|
||||
/* This one is also not needed */
|
||||
|
||||
void gck_rgba_gamma(GckRGB * p, double gamma)
|
||||
{
|
||||
double ig;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (gamma != 0.0)
|
||||
ig = 1.0 / gamma;
|
||||
else
|
||||
(ig = 0.0);
|
||||
|
||||
p->r = pow(p->r, ig);
|
||||
p->g = pow(p->g, ig);
|
||||
p->b = pow(p->b, ig);
|
||||
p->a = pow(p->a, ig);
|
||||
}
|
||||
|
||||
/**************************/
|
||||
/* Colorspace conversions */
|
||||
/**************************/
|
||||
|
||||
/***********************************************/
|
||||
/* (Red,Green,Blue) <-> (Hue,Saturation,Value) */
|
||||
/***********************************************/
|
||||
|
||||
void gck_rgb_to_hsv(GckRGB * p, double *h, double *s, double *v)
|
||||
{
|
||||
double max,min,delta;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
g_assert(h!=NULL);
|
||||
g_assert(s!=NULL);
|
||||
g_assert(v!=NULL);
|
||||
|
||||
max = gck_rgb_max(p);
|
||||
min = gck_rgb_min(p);
|
||||
|
||||
*v = max;
|
||||
if (max != 0.0)
|
||||
{
|
||||
*s = (max - min) / max;
|
||||
}
|
||||
else
|
||||
*s = 0.0;
|
||||
if (*s == 0.0)
|
||||
*h = GCK_HSV_UNDEFINED;
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
if (p->r == max)
|
||||
{
|
||||
*h = (p->g - p->b) / delta;
|
||||
}
|
||||
else if (p->g == max)
|
||||
{
|
||||
*h = 2.0 + (p->b - p->r) / delta;
|
||||
}
|
||||
else if (p->b == max)
|
||||
{
|
||||
*h = 4.0 + (p->r - p->g) / delta;
|
||||
}
|
||||
*h = *h * 60.0;
|
||||
if (*h < 0.0)
|
||||
*h = *h + 360;
|
||||
}
|
||||
}
|
||||
|
||||
void gck_hsv_to_rgb(double h, double s, double v, GckRGB * p)
|
||||
{
|
||||
int i;
|
||||
double f, w, q, t;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (s == 0.0)
|
||||
{
|
||||
if (h == GCK_HSV_UNDEFINED)
|
||||
{
|
||||
p->r = v;
|
||||
p->g = v;
|
||||
p->b = v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h == 360.0)
|
||||
h = 0.0;
|
||||
h = h / 60.0;
|
||||
i = (int)h;
|
||||
f = h - i;
|
||||
w = v * (1.0 - s);
|
||||
q = v * (1.0 - (s * f));
|
||||
t = v * (1.0 - (s * (1.0 - f)));
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
p->r = v;
|
||||
p->g = t;
|
||||
p->b = w;
|
||||
break;
|
||||
case 1:
|
||||
p->r = q;
|
||||
p->g = v;
|
||||
p->b = w;
|
||||
break;
|
||||
case 2:
|
||||
p->r = w;
|
||||
p->g = v;
|
||||
p->b = t;
|
||||
break;
|
||||
case 3:
|
||||
p->r = w;
|
||||
p->g = q;
|
||||
p->b = v;
|
||||
break;
|
||||
case 4:
|
||||
p->r = t;
|
||||
p->g = w;
|
||||
p->b = v;
|
||||
break;
|
||||
case 5:
|
||||
p->r = v;
|
||||
p->g = w;
|
||||
p->b = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************/
|
||||
/* (Red,Green,Blue) <-> (Hue,Saturation,Lightness) */
|
||||
/***************************************************/
|
||||
|
||||
void gck_rgb_to_hsl(GckRGB * p, double *h, double *s, double *l)
|
||||
{
|
||||
double max,min,delta;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
g_assert(h!=NULL);
|
||||
g_assert(s!=NULL);
|
||||
g_assert(l!=NULL);
|
||||
|
||||
max = gck_rgb_max(p);
|
||||
min = gck_rgb_min(p);
|
||||
|
||||
*l = (max + min) / 2.0;
|
||||
|
||||
if (max == min)
|
||||
{
|
||||
*s = 0.0;
|
||||
*h = GCK_HSL_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*l <= 0.5)
|
||||
*s = (max - min) / (max + min);
|
||||
else
|
||||
*s = (max - min) / (2.0 - max - min);
|
||||
|
||||
delta = max - min;
|
||||
if (p->r == max)
|
||||
{
|
||||
*h = (p->g - p->b) / delta;
|
||||
}
|
||||
else if (p->g == max)
|
||||
{
|
||||
*h = 2.0 + (p->b - p->r) / delta;
|
||||
}
|
||||
else if (p->b == max)
|
||||
{
|
||||
*h = 4.0 + (p->r - p->g) / delta;
|
||||
}
|
||||
*h = *h * 60.0;
|
||||
if (*h < 0.0)
|
||||
*h = *h + 360.0;
|
||||
}
|
||||
}
|
||||
|
||||
double _gck_value(double n1, double n2, double hue)
|
||||
{
|
||||
double val;
|
||||
|
||||
if (hue > 360.0)
|
||||
hue = hue - 360.0;
|
||||
else if (hue < 0.0)
|
||||
hue = hue + 360.0;
|
||||
if (hue < 60.0)
|
||||
val = n1 + (n2 - n1) * hue / 60.0;
|
||||
else if (hue < 180.0)
|
||||
val = n2;
|
||||
else if (hue < 240.0)
|
||||
val = n1 + (n2 - n1) * (240.0 - hue) / 60.0;
|
||||
else
|
||||
val = n1;
|
||||
|
||||
return (val);
|
||||
}
|
||||
|
||||
void gck_hsl_to_rgb(double h, double s, double l, GckRGB * p)
|
||||
{
|
||||
double m1, m2;
|
||||
|
||||
g_assert(p!=NULL);
|
||||
|
||||
if (l <= 0.5)
|
||||
m2 = l * (l + s);
|
||||
else
|
||||
m2 = l + s + l * s;
|
||||
m1 = 2.0 * l - m2;
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
if (h == GCK_HSV_UNDEFINED)
|
||||
p->r = p->g = p->b = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->r = _gck_value(m1, m2, h + 120.0);
|
||||
p->g = _gck_value(m1, m2, h);
|
||||
p->b = _gck_value(m1, m2, h - 120.0);
|
||||
}
|
||||
}
|
||||
|
||||
#define GCK_RETURN_RGB(x, y, z) {rgb->r = x; rgb->g = y; rgb->b = z; return; }
|
||||
|
||||
/***********************************************************************************/
|
||||
/* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure */
|
||||
/* red always maps to 6 in this implementation. Therefore UNDEFINED can be */
|
||||
/* defined as 0 in situations where only unsigned numbers are desired. */
|
||||
/***********************************************************************************/
|
||||
|
||||
void gck_rgb_to_hwb(GckRGB *rgb, gdouble *hue,gdouble *whiteness,gdouble *blackness)
|
||||
{
|
||||
/* RGB are each on [0, 1]. W and B are returned on [0, 1] and H is */
|
||||
/* returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B. */
|
||||
/* ====================================================================== */
|
||||
|
||||
gdouble R = rgb->r, G = rgb->g, B = rgb->b, w, v, b, f;
|
||||
gint i;
|
||||
|
||||
w = gck_rgb_min(rgb);
|
||||
v = gck_rgb_max(rgb);
|
||||
b = 1.0 - v;
|
||||
|
||||
if (v == w)
|
||||
{
|
||||
*hue=GCK_HSV_UNDEFINED;
|
||||
*whiteness=w;
|
||||
*blackness=b;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
|
||||
i = (R == w) ? 3.0 : ((G == w) ? 5.0 : 1.0);
|
||||
|
||||
*hue=(360.0/6.0)*(i - f /(v - w));
|
||||
*whiteness=w;
|
||||
*blackness=b;
|
||||
}
|
||||
}
|
||||
|
||||
void gck_hwb_to_rgb(gdouble H,gdouble W, gdouble B, GckRGB *rgb)
|
||||
{
|
||||
/* H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1]. */
|
||||
/* RGB are each returned on [0, 1]. */
|
||||
/* =============================================================== */
|
||||
|
||||
gdouble h = H, w = W, b = B, v, n, f;
|
||||
gint i;
|
||||
|
||||
h=6.0*h/360.0;
|
||||
|
||||
v = 1.0 - b;
|
||||
if (h == GCK_HSV_UNDEFINED)
|
||||
{
|
||||
rgb->r=v;
|
||||
rgb->g=v;
|
||||
rgb->b=v;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = floor(h);
|
||||
f = h - i;
|
||||
if (i & 1) f = 1.0 - f; /* if i is odd */
|
||||
n = w + f * (v - w); /* linear interpolation between w and v */
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 6:
|
||||
case 0: GCK_RETURN_RGB(v, n, w);
|
||||
break;
|
||||
case 1: GCK_RETURN_RGB(n, v, w);
|
||||
break;
|
||||
case 2: GCK_RETURN_RGB(w, v, n);
|
||||
break;
|
||||
case 3: GCK_RETURN_RGB(w, n, v);
|
||||
break;
|
||||
case 4: GCK_RETURN_RGB(n, w, v);
|
||||
break;
|
||||
case 5: GCK_RETURN_RGB(v, w, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************/
|
||||
/* Sumpersampling code (Quartic) */
|
||||
/* This code is *largely* based on the sources for POV-Ray 3.0. I am */
|
||||
|
@ -2010,12 +1478,12 @@ void gck_hwb_to_rgb(gdouble H,gdouble W, gdouble B, GckRGB *rgb)
|
|||
|
||||
gulong gck_render_sub_pixel(int max_depth, int depth, _GckSampleType ** block,
|
||||
int x, int y, int x1, int y1, int x3, int y3, double threshold,
|
||||
int sub_pixel_size, GckRenderFunction render_func, GckRGB * color)
|
||||
int sub_pixel_size, GckRenderFunction render_func, GimpRGB * color)
|
||||
{
|
||||
int x2, y2, cnt; /* Coords of center sample */
|
||||
double dx1, dy1; /* Delta to upper left sample */
|
||||
double dx3, dy3, weight; /* Delta to lower right sample */
|
||||
GckRGB c[4],tmpcol;
|
||||
GimpRGB c[4],tmpcol;
|
||||
unsigned long num_samples = 0;
|
||||
|
||||
/* Get offsets for corners */
|
||||
|
@ -2087,12 +1555,12 @@ gulong gck_render_sub_pixel(int max_depth, int depth, _GckSampleType ** block,
|
|||
/* Check whether we have to supersample */
|
||||
/* ==================================== */
|
||||
|
||||
if ((gck_rgba_dist(&c[0], &c[1]) >= threshold) ||
|
||||
(gck_rgba_dist(&c[0], &c[2]) >= threshold) ||
|
||||
(gck_rgba_dist(&c[0], &c[3]) >= threshold) ||
|
||||
(gck_rgba_dist(&c[1], &c[2]) >= threshold) ||
|
||||
(gck_rgba_dist(&c[1], &c[3]) >= threshold) ||
|
||||
(gck_rgba_dist(&c[2], &c[3]) >= threshold))
|
||||
if ((gimp_rgba_dist(&c[0], &c[1]) >= threshold) ||
|
||||
(gimp_rgba_dist(&c[0], &c[2]) >= threshold) ||
|
||||
(gimp_rgba_dist(&c[0], &c[3]) >= threshold) ||
|
||||
(gimp_rgba_dist(&c[1], &c[2]) >= threshold) ||
|
||||
(gimp_rgba_dist(&c[1], &c[3]) >= threshold) ||
|
||||
(gimp_rgba_dist(&c[2], &c[3]) >= threshold))
|
||||
{
|
||||
/* Calc coordinates of center subsample */
|
||||
/* ==================================== */
|
||||
|
@ -2161,7 +1629,7 @@ gulong gck_adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_dep
|
|||
int xt, xtt, yt; /* Temporary counters */
|
||||
int sub_pixel_size; /* Numbe of samples per pixel (1D) */
|
||||
size_t row_size; /* Memory needed for one row */
|
||||
GckRGB color; /* Rendered pixel's color */
|
||||
GimpRGB color; /* Rendered pixel's color */
|
||||
_GckSampleType tmp_sample; /* For swapping samples */
|
||||
_GckSampleType *top_row, *bot_row, *tmp_row; /* Sample rows */
|
||||
_GckSampleType **block; /* Sample block matrix */
|
||||
|
|
Loading…
Reference in New Issue