indent fisheye.c

This commit is contained in:
Bill Kendrick 2017-10-15 11:44:41 -07:00
parent 0608ce4c34
commit b11972979c

View file

@ -44,17 +44,13 @@ char * fisheye_get_name(magic_api * api, int which);
char *fisheye_get_description(magic_api * api, int which, int mode); char *fisheye_get_description(magic_api * api, int which, int mode);
int fisheye_requires_colors(magic_api * api, int which); int fisheye_requires_colors(magic_api * api, int which);
void fisheye_release(magic_api * api, int which, void fisheye_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * snapshot, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
int x, int y, SDL_Rect * update_rect);
void fisheye_shutdown(magic_api * api); void fisheye_shutdown(magic_api * api);
void fisheye_draw(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last, void fisheye_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
int x, int y);
void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas, void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
SDL_Rect * update_rect);
void fisheye_click(magic_api * api, int which, int mode, void fisheye_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
int x, int y, SDL_Rect * update_rect);
void fisheye_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); void fisheye_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void fisheye_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas); void fisheye_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
int fisheye_modes(magic_api * api, int which); int fisheye_modes(magic_api * api, int which);
@ -63,15 +59,15 @@ int fisheye_modes(magic_api * api, int which);
// Housekeeping functions // Housekeeping functions
void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas, void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
SDL_Rect * update_rect);
Uint32 fisheye_api_version(void) Uint32 fisheye_api_version(void)
{ {
return (TP_MAGIC_API_VERSION); return (TP_MAGIC_API_VERSION);
} }
void fisheye_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED) void fisheye_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
Uint8 b ATTRIBUTE_UNUSED)
{ {
} }
@ -95,17 +91,25 @@ SDL_Surface * fisheye_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
{ {
char fname[1024]; char fname[1024];
snprintf(fname, sizeof(fname), "%s/images/magic/fisheye.png", snprintf(fname, sizeof(fname), "%s/images/magic/fisheye.png", api->data_directory);
api->data_directory);
return (IMG_Load(fname)); return (IMG_Load(fname));
} }
char * fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Fisheye")); } //Needs better name char *fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return strdup(gettext_noop("Fisheye"));
} //Needs better name
char * fisheye_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) { return strdup(gettext_noop("Click on part of your picture to create a fisheye effect.")); } char *fisheye_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return strdup(gettext_noop("Click on part of your picture to create a fisheye effect."));
}
int fisheye_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED) { return 0; } int fisheye_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return 0;
}
void fisheye_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, void fisheye_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
@ -115,7 +119,9 @@ void fisheye_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
} }
void fisheye_shutdown(magic_api * api ATTRIBUTE_UNUSED) void fisheye_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{ Mix_FreeChunk(fisheye_snd); } {
Mix_FreeChunk(fisheye_snd);
}
// do-fisheye // do-fisheye
@ -129,16 +135,19 @@ void fisheye_draw(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
int xx, yy; int xx, yy;
unsigned short int i; unsigned short int i;
if(api->in_circle(last_x - x, last_y - y, 80)) return; if (api->in_circle(last_x - x, last_y - y, 80))
return;
last_x = x; last_x = x;
last_y = y; last_y = y;
oryg = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel, oryg = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
output = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel, output = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 80, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
rect.x = x - 40; rect.x = x - 40;
rect.y = y - 40; rect.y = y - 40;
@ -150,7 +159,8 @@ void fisheye_draw(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
for (i = 0; i < 40; i++) for (i = 0; i < 40; i++)
{ {
temp_src = SDL_CreateRGBSurface(SDL_ANYFORMAT, 1, 80, canvas->format->BitsPerPixel, temp_src = SDL_CreateRGBSurface(SDL_ANYFORMAT, 1, 80, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
//let's take a smooth bar of scaled bitmap and copy it to temp //let's take a smooth bar of scaled bitmap and copy it to temp
//left side first //left side first
@ -161,7 +171,8 @@ void fisheye_draw(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
SDL_BlitSurface(oryg, &rect, temp_src, NULL); //this bar is copied to temp_src SDL_BlitSurface(oryg, &rect, temp_src, NULL); //this bar is copied to temp_src
temp_dest = SDL_CreateRGBSurface(SDL_ANYFORMAT, 1, 80 + 2 * i, canvas->format->BitsPerPixel, temp_dest = SDL_CreateRGBSurface(SDL_ANYFORMAT, 1, 80 + 2 * i, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
temp_dest = api->scale(temp_src, 1, 80 + 2 * i, 0); //temp_dest stores scaled temp_src temp_dest = api->scale(temp_src, 1, 80 + 2 * i, 0); //temp_dest stores scaled temp_src
@ -187,10 +198,12 @@ void fisheye_draw(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
for (i = 0; i < 40; i++) for (i = 0; i < 40; i++)
{ {
temp_src = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 1, canvas->format->BitsPerPixel, temp_src = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80, 1, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
temp_dest = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80 + 2 * i, 1, canvas->format->BitsPerPixel, temp_dest = SDL_CreateRGBSurface(SDL_ANYFORMAT, 80 + 2 * i, 1, canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask); canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask,
canvas->format->Amask);
//upper side first //upper side first
rect.x = 0; rect.x = 0;
@ -240,8 +253,7 @@ void fisheye_draw(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
} }
void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas, void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
SDL_Rect * update_rect)
{ {
api->line(api, which, canvas, snapshot, ox, oy, x, y, 1, fisheye_draw); api->line(api, which, canvas, snapshot, ox, oy, x, y, 1, fisheye_draw);
@ -252,20 +264,21 @@ void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
} }
void fisheye_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void fisheye_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas, SDL_Surface * last, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
int x, int y, SDL_Rect * update_rect)
{ {
last_x = -80; /* A value that will be beyond any clicked position */ last_x = -80; /* A value that will be beyond any clicked position */
last_y = -80; last_y = -80;
fisheye_drag(api, which, canvas, last, x, y, x, y, update_rect); fisheye_drag(api, which, canvas, last, x, y, x, y, update_rect);
} }
void fisheye_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) void fisheye_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{ {
} }
void fisheye_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) void fisheye_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{ {
} }