indent cartoon.c

This commit is contained in:
Bill Kendrick 2017-10-15 11:43:06 -07:00
parent 0a167dbc71
commit 44286395b3

View file

@ -49,17 +49,13 @@ int cartoon_get_tool_count(magic_api * api);
SDL_Surface *cartoon_get_icon(magic_api * api, int which);
char *cartoon_get_name(magic_api * api, int which);
char *cartoon_get_description(magic_api * api, int which, int mode);
static void do_cartoon(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last,
int x, int y);
static void do_cartoon(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect);
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
void cartoon_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void cartoon_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void cartoon_shutdown(magic_api * api);
void cartoon_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
int cartoon_requires_colors(magic_api * api, int which);
@ -74,14 +70,16 @@ int cartoon_init(magic_api * api)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%s/sounds/magic/cartoon.wav",
api->data_directory);
snprintf(fname, sizeof(fname), "%s/sounds/magic/cartoon.wav", api->data_directory);
cartoon_snd = Mix_LoadWAV(fname);
return (1);
}
Uint32 cartoon_api_version(void) { return(TP_MAGIC_API_VERSION); }
Uint32 cartoon_api_version(void)
{
return (TP_MAGIC_API_VERSION);
}
// We have multiple tools:
int cartoon_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
@ -94,8 +92,7 @@ SDL_Surface * cartoon_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%s/images/magic/cartoon.png",
api->data_directory);
snprintf(fname, sizeof(fname), "%s/images/magic/cartoon.png", api->data_directory);
return (IMG_Load(fname));
}
@ -109,14 +106,12 @@ char * cartoon_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
// Return our descriptions, localized:
char *cartoon_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return(strdup(gettext_noop(
"Click and drag the mouse around to turn the picture into a cartoon.")));
return (strdup(gettext_noop("Click and drag the mouse around to turn the picture into a cartoon.")));
}
// Do the effect:
static void do_cartoon(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last,
int x, int y)
static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
{
magic_api *api = (magic_api *) ptr;
int xx, yy;
@ -171,27 +166,20 @@ static void do_cartoon(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * can
SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b);
SDL_GetRGB(api->getpixel(last, xx + 1, yy),
last->format, &r1, &g1, &b1);
SDL_GetRGB(api->getpixel(last, xx + 1, yy), last->format, &r1, &g1, &b1);
SDL_GetRGB(api->getpixel(last, xx + 1, yy + 1),
last->format, &r2, &g2, &b2);
SDL_GetRGB(api->getpixel(last, xx + 1, yy + 1), last->format, &r2, &g2, &b2);
if (abs(((r + g + b) / 3) - (r1 + g1 + b1) / 3) > OUTLINE_THRESH
|| abs(((r + g + b) / 3) - (r2 + g2 + b2) / 3) >
OUTLINE_THRESH || abs(r - r1) > OUTLINE_THRESH
|| abs(g - g1) > OUTLINE_THRESH
|| abs(b - b1) > OUTLINE_THRESH
|| abs(r - r2) > OUTLINE_THRESH
|| abs(g - g2) > OUTLINE_THRESH
|| abs(b - b2) > OUTLINE_THRESH)
|| abs(r - r2) > OUTLINE_THRESH || abs(g - g2) > OUTLINE_THRESH || abs(b - b2) > OUTLINE_THRESH)
{
api->putpixel(canvas, xx - 1, yy,
SDL_MapRGB(canvas->format, 0, 0, 0));
api->putpixel(canvas, xx, yy - 1,
SDL_MapRGB(canvas->format, 0, 0, 0));
api->putpixel(canvas, xx - 1, yy - 1,
SDL_MapRGB(canvas->format, 0, 0, 0));
api->putpixel(canvas, xx - 1, yy, SDL_MapRGB(canvas->format, 0, 0, 0));
api->putpixel(canvas, xx, yy - 1, SDL_MapRGB(canvas->format, 0, 0, 0));
api->putpixel(canvas, xx - 1, yy - 1, SDL_MapRGB(canvas->format, 0, 0, 0));
}
}
}
@ -200,13 +188,24 @@ static void do_cartoon(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * can
// Affect the canvas on drag:
void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect)
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
{
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_cartoon);
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
if (ox > x)
{
int tmp = ox;
ox = x;
x = tmp;
}
if (oy > y)
{
int tmp = oy;
oy = y;
y = tmp;
}
update_rect->x = ox - 16;
update_rect->y = oy - 16;
@ -218,8 +217,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
// Affect the canvas on click:
void cartoon_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect)
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
{
cartoon_drag(api, which, canvas, last, x, y, x, y, update_rect);
}
@ -239,7 +237,8 @@ void cartoon_shutdown(magic_api * api ATTRIBUTE_UNUSED)
}
// Record the color from Tux Paint:
void cartoon_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED)
void cartoon_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
Uint8 b ATTRIBUTE_UNUSED)
{
}
@ -249,11 +248,13 @@ int cartoon_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
return 0;
}
void cartoon_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
void cartoon_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
void cartoon_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
void cartoon_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}