indent distortion.c

This commit is contained in:
Bill Kendrick 2017-10-15 11:43:55 -07:00
parent aac7e00ba2
commit 3d2cd7d327

View file

@ -64,11 +64,9 @@ int distortion_requires_colors(magic_api * api, int which);
void distortion_shutdown(magic_api * api); void distortion_shutdown(magic_api * api);
void distortion_click(magic_api * api, int which, int mode, void distortion_click(magic_api * api, int which, int mode,
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 distortion_release(magic_api * api, int which, void distortion_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 distortion_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b); void distortion_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
void distortion_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas); void distortion_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
@ -76,12 +74,9 @@ void distortion_switchout(magic_api * api, int which, int mode, SDL_Surface * ca
int distortion_modes(magic_api * api, int which); int distortion_modes(magic_api * api, int which);
void distortion_drag(magic_api * api, int which, SDL_Surface * canvas, void distortion_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);
static void distortion_line_callback(void * ptr, int which, static void distortion_line_callback(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
SDL_Surface * canvas, SDL_Surface * snapshot,
int x, int y);
/* Setup Functions: */ /* Setup Functions: */
@ -99,9 +94,7 @@ int distortion_init(magic_api * api)
{ {
char fname[1024]; char fname[1024];
snprintf(fname, sizeof(fname), snprintf(fname, sizeof(fname), "%s/sounds/magic/distortion.ogg", api->data_directory);
"%s/sounds/magic/distortion.ogg",
api->data_directory);
// Try to load the file! // Try to load the file!
@ -125,8 +118,7 @@ SDL_Surface * distortion_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
{ {
char fname[1024]; char fname[1024];
snprintf(fname, sizeof(fname), "%s/images/magic/distortion.png", snprintf(fname, sizeof(fname), "%s/images/magic/distortion.png", api->data_directory);
api->data_directory);
// Try to load the image, and return the results to Tux Paint: // Try to load the image, and return the results to Tux Paint:
@ -145,7 +137,8 @@ char * distortion_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
// Report our "Magic" tool descriptions // Report our "Magic" tool descriptions
char * distortion_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) char *distortion_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{ {
return (strdup(gettext_noop("Click and drag the mouse to cause distortion in your picture."))); return (strdup(gettext_noop("Click and drag the mouse to cause distortion in your picture.")));
} }
@ -172,8 +165,7 @@ void distortion_shutdown(magic_api * api ATTRIBUTE_UNUSED)
// Affect the canvas on click: // Affect the canvas on click:
void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
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)
{ {
distortion_drag(api, which, canvas, snapshot, x, y, x, y, update_rect); distortion_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
} }
@ -182,15 +174,25 @@ void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
// Affect the canvas on drag: // Affect the canvas on drag:
void distortion_drag(magic_api * api, int which, SDL_Surface * canvas, void distortion_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((void *) api, which, canvas, snapshot, api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, distortion_line_callback);
ox, oy, x, y, 1, distortion_line_callback);
if (ox > x) { int tmp = ox; ox = x; x = tmp; } if (ox > x)
if (oy > y) { int tmp = oy; oy = y; y = tmp; } {
int tmp = ox;
ox = x;
x = tmp;
}
if (oy > y)
{
int tmp = oy;
oy = y;
y = tmp;
}
update_rect->x = ox - 8; update_rect->x = ox - 8;
@ -199,8 +201,7 @@ void distortion_drag(magic_api * api, int which, SDL_Surface * canvas,
update_rect->h = (y + 8) - update_rect->h; update_rect->h = (y + 8) - update_rect->h;
api->playsound(snd_effect, api->playsound(snd_effect, (x * 255) / canvas->w, // pan
(x * 255) / canvas->w, // pan
255); // distance 255); // distance
} }
@ -214,7 +215,8 @@ void distortion_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
} }
void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED) void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
Uint8 b ATTRIBUTE_UNUSED)
{ {
} }
@ -222,8 +224,7 @@ void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UN
// Our "callback" function // Our "callback" function
static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED, static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas, SDL_Surface * snapshot, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
int x, int y)
{ {
magic_api *api = (magic_api *) ptr; magic_api *api = (magic_api *) ptr;
int xx, yy; int xx, yy;
@ -239,19 +240,19 @@ static void distortion_line_callback(void * ptr, int which ATTRIBUTE_UNUSED,
{ {
if (api->in_circle(xx, yy, 8)) if (api->in_circle(xx, yy, 8))
{ {
api->putpixel(canvas, x + xx, y + yy, api->putpixel(canvas, x + xx, y + yy, api->getpixel(snapshot, x + xx / 2, y + yy));
api->getpixel(snapshot,
x + xx / 2, y + yy));
} }
} }
} }
} }
void distortion_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) void distortion_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{ {
} }
void distortion_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED) void distortion_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{ {
} }