Clean up of code, all macros for filter_param -> real varaible are put in

script.h. Changed filters to reflect this change, and actually plan on writing
some more macors and filters soon.


SVN revision: 2689
This commit is contained in:
Chris Ross 2000-05-22 11:41:40 +00:00
parent 2588c903da
commit e67e249949
4 changed files with 34 additions and 35 deletions

View File

@ -15,33 +15,14 @@
#include "colormod.h"
#include "blend.h"
#define ASSIGN_IMAGE(k, v) \
if (!strcmp((k), par->key)) { \
if (par->type == VAR_PTR) { \
(v) = ((Imlib_Image)par->data); \
} else if (par->type == VAR_CHAR) { \
if (!free_map) \
(v) = imlib_load_image(par->data); \
free_map = 1; \
} \
}
#define ASSIGN_INT(k, v) \
if (!strcmp((k), par->key)) { \
if (par->type == VAR_PTR) { \
(v) = (*(int *)par->data); \
} else if (par->type == VAR_CHAR) { \
(v) = strtol(par->data, 0, 0); \
} \
}
#define PI (4 * atan(1))
static Imlib_Image
bump_map(Imlib_Image im, pIFunctionParam par)
{
Imlib_Image map = im;
double an = 0, el = 30, d = 0x200;
pIFunctionParam ptr;
double an = 0, el = 30, d = 0x200;
double red = 0x200, green = 0x200, blue = 0x200;
double ambient = 0;
@ -51,7 +32,7 @@ bump_map(Imlib_Image im, pIFunctionParam par)
double z, z_2, x2, y2;
int w, h, i, j, w2, h2, wh2, mx, my;
for (; par; par = par->next) {
for (ptr = par; ptr; ptr = ptr->next) {
ASSIGN_IMAGE("map", map);
ASSIGN_INT ("angle", an);
ASSIGN_INT ("elevation", el);
@ -146,6 +127,7 @@ static Imlib_Image
bump_map_point(Imlib_Image im, pIFunctionParam par)
{
Imlib_Image map = im;
pIFunctionParam ptr;
double x = 0, y = 0, z = 30, d = 0x200;
double red = 0x200, green = 0x200, blue = 0x200;
double ambient = 0;
@ -156,7 +138,7 @@ bump_map_point(Imlib_Image im, pIFunctionParam par)
double z_2, x2, y2;
int w, h, i, j, w2, h2, wh2, mx, my;
for (; par; par = par->next) {
for (ptr = par; ptr; ptr = ptr->next) {
ASSIGN_IMAGE("map", map);
ASSIGN_INT ("x", x);
ASSIGN_INT ("y", y);

View File

@ -49,19 +49,16 @@ void *exec( char *filter, void *im, pIFunctionParam params )
printf( "filter_test.c: tint called\n" );
*/
#define ASSIGN_DATA8_VALUE( var, v ) if( strcmp( ptr->key, var ) == 0 ) v = (DATA8)atoi( (char *)ptr->data )
#define ASSIGN_VALUE( var, v ) if( strcmp( ptr->key, var ) == 0 ) v = atoi( (char *)ptr->data )
for( ptr = params; ptr != NULL; ptr = ptr->next )
{
ASSIGN_DATA8_VALUE( "red", r );
ASSIGN_DATA8_VALUE( "blue", b );
ASSIGN_DATA8_VALUE( "green", g );
ASSIGN_VALUE( "x", x );
ASSIGN_VALUE( "y", y );
ASSIGN_VALUE( "w", w );
ASSIGN_VALUE( "h", h );
ASSIGN_DATA8_VALUE( "alpha", a );
ASSIGN_DATA8( "red", r );
ASSIGN_DATA8( "blue", b );
ASSIGN_DATA8( "green", g );
ASSIGN_INT( "x", x );
ASSIGN_INT( "y", y );
ASSIGN_INT( "w", w );
ASSIGN_INT( "h", h );
ASSIGN_DATA8( "alpha", a );
}
/*
printf( "Using values red=%d,blue=%d,green=%d,x=%d,y=%d,height=%d,width=%d,alpha=%d\n", r,b,g,x,y,w,h,a );

View File

@ -23,7 +23,6 @@ struct _imlib_external_filter
pImlibExternalFilter next;
};
void __imlib_dynamic_filters_init();
void __imlib_dynamic_filters_deinit();
pImlibExternalFilter __imlib_get_dynamic_filter( char *name );

View File

@ -8,6 +8,27 @@
#define VAR_CHAR 1
#define VAR_PTR 2
#define ASSIGN_DATA8( var, v ) if( strcmp( ptr->key, var ) == 0 ) v = (DATA8)atoi( (char *)ptr->data )
#define ASSIGN_INT(k, v) \
if (!strcmp((k), ptr->key)) { \
if (ptr->type == VAR_PTR) { \
(v) = (*(int *)ptr->data); \
} else if (ptr->type == VAR_CHAR) { \
(v) = strtol(ptr->data, 0, 0); \
} \
}
#define ASSIGN_IMAGE(k, v) \
if (!strcmp((k), ptr->key)) { \
if (ptr->type == VAR_PTR) { \
(v) = ((Imlib_Image)ptr->data); \
} else if (ptr->type == VAR_CHAR) { \
if (!free_map) \
(v) = imlib_load_image(ptr->data); \
free_map = 1; \
} \
}
typedef struct _imlib_function_param IFunctionParam;
typedef struct _imlib_function_param *pIFunctionParam;
struct _imlib_function_param