corrected wrong position of declaration for variables in some magic tools.
This commit is contained in:
parent
7403371265
commit
82a232dca8
7 changed files with 26 additions and 22 deletions
|
|
@ -72,11 +72,11 @@ Uint32 alien_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
|||
|
||||
//Load sounds
|
||||
int alien_init(magic_api * api){
|
||||
srand(time(0));
|
||||
|
||||
int i;
|
||||
char fname[1024];
|
||||
|
||||
srand(time(0));
|
||||
|
||||
for (i = 0; i < alien_NUM_TOOLS; i++){
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s", api->data_directory, alien_snd_filenames[i]);
|
||||
alien_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
|
|
@ -113,9 +113,9 @@ static void do_alien_pixel(void * ptr, int which,
|
|||
|
||||
Uint8 temp[3];
|
||||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
int k;
|
||||
for (k =0;k<3;k++){
|
||||
temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255);
|
||||
}
|
||||
|
|
@ -176,10 +176,12 @@ void alien_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
int use_sound = 1;
|
||||
|
||||
Mix_Chunk * magic_loadsound(char* file){
|
||||
Mix_Chunk * temp;
|
||||
|
||||
if (!use_sound){
|
||||
return (Mix_Chunk*)-1;
|
||||
}
|
||||
Mix_Chunk * temp = Mix_LoadWAV(file);
|
||||
temp = Mix_LoadWAV(file);
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,17 +105,17 @@ static void do_blur_pixel(void * ptr, int which,
|
|||
int i,j,k;
|
||||
Uint8 temp[3];
|
||||
double blurValue[3];
|
||||
|
||||
for (k =0;k<3;k++){
|
||||
blurValue[k] = 0;
|
||||
}
|
||||
|
||||
//5x5 gaussiann weighting window
|
||||
const int weight[5][5] = { {1,4,7,4,1},
|
||||
{4,16,26,16,4},
|
||||
{7,26,41,26,7},
|
||||
{4,16,26,16,4},
|
||||
{1,4,7,4,1}};
|
||||
|
||||
for (k =0;k<3;k++){
|
||||
blurValue[k] = 0;
|
||||
}
|
||||
|
||||
for (i=-2;i<3;i++){
|
||||
for (j=-2;j<3;j++){
|
||||
//Add the pixels around the current one wieghted
|
||||
|
|
|
|||
|
|
@ -217,9 +217,9 @@ static void mosaic_noise_pixel(void * ptr, SDL_Surface * canvas, int noise_AMOUN
|
|||
|
||||
Uint8 temp[3];
|
||||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
int k;
|
||||
for (k =0;k<3;k++){
|
||||
temp2[k] = clamp(0.0, (int)temp[k] - (rand()%noise_AMOUNT) + noise_AMOUNT/2.0, 255.0);
|
||||
}
|
||||
|
|
@ -232,17 +232,17 @@ static void mosaic_blur_pixel(void * ptr, SDL_Surface * canvas, SDL_Surface * la
|
|||
int i,j,k;
|
||||
Uint8 temp[3];
|
||||
double blurValue[3];
|
||||
|
||||
for (k =0;k<3;k++){
|
||||
blurValue[k] = 0;
|
||||
}
|
||||
|
||||
//5x5 gaussiann weighting window
|
||||
const int weight[5][5] = { {1,4,7,4,1},
|
||||
{4,16,26,16,4},
|
||||
{7,26,41,26,7},
|
||||
{4,16,26,16,4},
|
||||
{1,4,7,4,1}};
|
||||
|
||||
for (k =0;k<3;k++){
|
||||
blurValue[k] = 0;
|
||||
}
|
||||
|
||||
for (i=-2;i<3;i++){
|
||||
for (j=-2;j<3;j++){
|
||||
//Add the pixels around the current one wieghted
|
||||
|
|
@ -269,6 +269,7 @@ static void mosaic_sharpen_pixel(void * ptr,
|
|||
int grey;
|
||||
int i,j;
|
||||
double sobel_1=0,sobel_2=0;
|
||||
double temp;
|
||||
|
||||
//Sobel weighting masks
|
||||
const int sobel_weights_1[3][3] = { {1,2,1},
|
||||
|
|
@ -290,7 +291,7 @@ static void mosaic_sharpen_pixel(void * ptr,
|
|||
}
|
||||
}
|
||||
|
||||
double temp = sqrt(sobel_1*sobel_1 + sobel_2*sobel_2);
|
||||
temp = sqrt(sobel_1*sobel_1 + sobel_2*sobel_2);
|
||||
temp = (temp/1443)*255.0;
|
||||
|
||||
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r1, &g1, &b1);
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ Uint32 noise_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
|||
|
||||
//Load sounds
|
||||
int noise_init(magic_api * api){
|
||||
srand(time(0));
|
||||
|
||||
int i;
|
||||
char fname[1024];
|
||||
|
||||
srand(time(0));
|
||||
|
||||
for (i = 0; i < noise_NUM_TOOLS; i++){
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s", api->data_directory, noise_snd_filenames[i]);
|
||||
noise_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
|
|
@ -112,9 +112,9 @@ static void do_noise_pixel(void * ptr, int which,
|
|||
|
||||
Uint8 temp[3];
|
||||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
int k;
|
||||
for (k =0;k<3;k++){
|
||||
temp2[k] = clamp(0.0, (int)temp[k] - (rand()%noise_AMOUNT) + noise_AMOUNT/2.0, 255.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ static void do_sharpen_pixel(void * ptr, int which,
|
|||
int grey;
|
||||
int i,j;
|
||||
double sobel_1=0,sobel_2=0;
|
||||
double temp;
|
||||
|
||||
//Sobel weighting masks
|
||||
const int sobel_weights_1[3][3] = { {1,2,1},
|
||||
|
|
@ -160,7 +161,7 @@ static void do_sharpen_pixel(void * ptr, int which,
|
|||
}
|
||||
}
|
||||
|
||||
double temp = sqrt(sobel_1*sobel_1 + sobel_2*sobel_2);
|
||||
temp = sqrt(sobel_1*sobel_1 + sobel_2*sobel_2);
|
||||
temp = (temp/1443)*255.0;
|
||||
|
||||
// set image to white where edge value is below THRESHOLD
|
||||
|
|
|
|||
|
|
@ -313,9 +313,9 @@ void string_draw_triangle_preview(magic_api * api, int which,
|
|||
SDL_Surface * canvas, SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
scale_coords(&ox, &oy,&x, &y);
|
||||
int middle_x, middle_y;
|
||||
int w, h;
|
||||
scale_coords(&ox, &oy,&x, &y);
|
||||
w=max(string_ox,x)-min(string_ox,x);
|
||||
h=max(string_oy,y)-min(string_oy,y);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ int toothpaste_init(magic_api * api){
|
|||
|
||||
int i;
|
||||
char fname[1024];
|
||||
int k,j;
|
||||
//Load sounds
|
||||
for (i = 0; i < toothpaste_NUM_TOOLS; i++){
|
||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/%s", api->data_directory, toothpaste_snd_filenames[i]);
|
||||
|
|
@ -88,7 +89,6 @@ int toothpaste_init(magic_api * api){
|
|||
return(0);
|
||||
}
|
||||
|
||||
int k,j;
|
||||
for (k = - toothpaste_RADIUS; k < + toothpaste_RADIUS; k++){
|
||||
for (j = - toothpaste_RADIUS; j < + toothpaste_RADIUS; j++){
|
||||
if (api->in_circle(j , k, toothpaste_RADIUS)){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue