Adding "indent.sh" to re-indent code; ran it!!!

This commit is contained in:
Bill Kendrick 2023-04-23 23:26:00 -07:00
parent 16336cc854
commit 18f9cad6fe
98 changed files with 5798 additions and 9001 deletions

View file

@ -48,20 +48,14 @@
#define gettext_noop(String) String
#endif
static void mosaic_shaped_sharpen_pixel(void *ptr, SDL_Surface * canvas,
SDL_Surface * last, int x, int y);
static void mosaic_shaped_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
static void reset_counter(SDL_Surface * canvas, Uint8 * counter);
static void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y,
int size, Uint32 color);
static void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, int size, Uint32 color);
static void deform(magic_api * api, SDL_Surface * srfc);
static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas,
SDL_Surface * last, int which,
SDL_Rect * update_rect);
static void mosaic_shaped_fill(void *ptr_to_api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y);
static void mosaic_shaped_paint(void *ptr, int which, SDL_Surface * canvas,
SDL_Surface * last, int x, int y);
SDL_Surface * last, int which, SDL_Rect * update_rect);
static void mosaic_shaped_fill(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
static void mosaic_shaped_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
Uint32 mosaic_shaped_api_version(void);
int mosaic_shaped_init(magic_api * api, Uint32 disabled_features);
@ -73,16 +67,13 @@ int mosaic_shaped_get_group(magic_api * api, int which);
char *mosaic_shaped_get_description(magic_api * api, int which, int mode);
void mosaic_shaped_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 mosaic_shaped_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 mosaic_shaped_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 mosaic_shaped_shutdown(magic_api * api);
@ -91,28 +82,25 @@ void mosaic_shaped_set_color(magic_api * api, int which, SDL_Surface * canvas,
int mosaic_shaped_requires_colors(magic_api * api, int which);
void mosaic_shaped_switchin(magic_api * api, int which, int mode,
SDL_Surface * canvas);
void mosaic_shaped_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void mosaic_shaped_switchout(magic_api * api, int which, int mode,
SDL_Surface * canvas);
void mosaic_shaped_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
int mosaic_shaped_modes(magic_api * api, int which);
int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
int x, int y, int fill_edge, int fill_tile, int size,
Uint32 color);
int x, int y, int fill_edge, int fill_tile, int size, Uint32 color);
Uint8 mosaic_shaped_accepted_sizes(magic_api * api, int which, int mode);
Uint8 mosaic_shaped_default_size(magic_api * api, int which, int mode);
void mosaic_shaped_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
void mosaic_shaped_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
SDL_Rect * update_rect);
Uint8 *mosaic_shaped_counted;
Uint8 *mosaic_shaped_done;
Uint8 mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b;
int mosaic_shaped_average_r, mosaic_shaped_average_g, mosaic_shaped_average_b,
mosaic_shaped_average_count;
int mosaic_shaped_average_r, mosaic_shaped_average_g, mosaic_shaped_average_b, mosaic_shaped_average_count;
Uint32 pixel_average, black, white;
enum
@ -155,20 +143,17 @@ const char *mosaic_shaped_names[mosaic_shaped_NUM_TOOLS] = {
const char *mosaic_shaped_descs[mosaic_shaped_NUM_TOOLS][2] = {
{
gettext_noop
("Click and drag the mouse to add a square mosaic to parts of your picture."),
gettext_noop("Click and drag the mouse to add a square mosaic to parts of your picture."),
gettext_noop("Click to add a square mosaic to your entire picture."),
},
{
gettext_noop
("Click and drag the mouse to add a hexagonal mosaic to parts of your picture."),
gettext_noop("Click and drag the mouse to add a hexagonal mosaic to parts of your picture."),
gettext_noop("Click to add a hexagonal mosaic to your entire picture."),
},
{
gettext_noop
("Click and drag the mouse to add an irregular mosaic to parts of your picture."),
gettext_noop("Click and drag the mouse to add an irregular mosaic to parts of your picture."),
gettext_noop("Click to add an irregular mosaic to your entire picture."),
},
};
@ -188,8 +173,7 @@ int mosaic_shaped_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSE
for (i = 0; i < mosaic_shaped_NUM_TOOLS; i++)
{
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
mosaic_shaped_snd_filenames[i]);
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, mosaic_shaped_snd_filenames[i]);
mosaic_shaped_snd_effect[i] = Mix_LoadWAV(fname);
}
@ -206,8 +190,7 @@ SDL_Surface *mosaic_shaped_get_icon(magic_api * api, int which)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
mosaic_shaped_icon_filenames[which]);
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, mosaic_shaped_icon_filenames[which]);
return (IMG_Load(fname));
}
@ -218,15 +201,13 @@ char *mosaic_shaped_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
}
// Return our groups (all the same!)
int mosaic_shaped_get_group(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
int mosaic_shaped_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return MAGIC_TYPE_DISTORTS;
}
// Return our descriptions, localized:
char *mosaic_shaped_get_description(magic_api * api ATTRIBUTE_UNUSED,
int which, int mode)
char *mosaic_shaped_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
{
return (strdup(gettext_noop(mosaic_shaped_descs[which][mode - 1])));
}
@ -240,16 +221,13 @@ static int mosaic_shaped_grey(Uint8 r1, Uint8 g1, Uint8 b1)
// Do the effect for the full image
static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas,
SDL_Surface * last ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED,
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
int which ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
int i, j, size;
Uint32 mosaic_shaped_color;
magic_api *api = (magic_api *) ptr;
mosaic_shaped_color =
SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g,
mosaic_shaped_b, 0);
mosaic_shaped_color = SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b, 0);
for (i = 3; i < canvas->w - 3; i += 2)
{
@ -266,8 +244,7 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas,
mosaic_shaped_average_g = 0;
mosaic_shaped_average_b = 0;
mosaic_shaped_average_count = 0;
scan_fill(api, canvas, canvas_shaped, i, j, 1, 0, 1,
mosaic_shaped_color);
scan_fill(api, canvas, canvas_shaped, i, j, 1, 0, 1, mosaic_shaped_color);
if (mosaic_shaped_average_count > 0)
{
@ -278,11 +255,8 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas,
mosaic_shaped_average_r /
mosaic_shaped_average_count,
mosaic_shaped_average_g /
mosaic_shaped_average_count,
mosaic_shaped_average_b /
mosaic_shaped_average_count);
scan_fill(api, canvas, canvas_shaped, i, j, 0, 1, size,
pixel_average);
mosaic_shaped_average_count, mosaic_shaped_average_b / mosaic_shaped_average_count);
scan_fill(api, canvas, canvas_shaped, i, j, 0, 1, size, pixel_average);
}
}
}
@ -291,9 +265,7 @@ static void do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas,
/* Fills a tesera */
static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas,
SDL_Surface * last ATTRIBUTE_UNUSED, int x,
int y)
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
{
Uint32 mosaic_shaped_color;
int size;
@ -301,9 +273,7 @@ static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
x = clamp(0, x, canvas->w - 1);
y = clamp(0, y, canvas->h - 1);
mosaic_shaped_color =
SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g,
mosaic_shaped_b, 0);
mosaic_shaped_color = SDL_MapRGBA(canvas->format, mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b, 0);
mosaic_shaped_average_r = 0;
mosaic_shaped_average_g = 0;
mosaic_shaped_average_b = 0;
@ -331,8 +301,7 @@ static void mosaic_shaped_fill(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
// Affect the canvas on drag:
void mosaic_shaped_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(api, which, canvas, last, ox, oy, x, y, 1, mosaic_shaped_fill);
update_rect->x = min(ox, x) - mosaic_shaped_pattern->w;
@ -344,8 +313,7 @@ void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
// Affect the canvas on click:
void mosaic_shaped_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)
{
if (mode == MODE_FULLSCREEN)
{
@ -367,8 +335,7 @@ void mosaic_shaped_release(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED,
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}
@ -388,8 +355,9 @@ void mosaic_shaped_shutdown(magic_api * api ATTRIBUTE_UNUSED)
}
// Record the color from Tux Paint:
void mosaic_shaped_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
void mosaic_shaped_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r,
Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
mosaic_shaped_r = r;
mosaic_shaped_g = g;
@ -397,16 +365,14 @@ void mosaic_shaped_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU
}
// Use colors:
int mosaic_shaped_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
int mosaic_shaped_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return 1;
}
//Sharpen a pixel
static void mosaic_shaped_sharpen_pixel(void *ptr,
SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last, int x, int y)
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last, int x, int y)
{
magic_api *api = (magic_api *) ptr;
Uint8 r1, g1, b1;
@ -432,8 +398,7 @@ static void mosaic_shaped_sharpen_pixel(void *ptr,
for (j = -1; j < 2; j++)
{
//No need to check if inside canvas, getpixel does it for us.
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1,
&b1);
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &r1, &g1, &b1);
grey = mosaic_shaped_grey(r1, g1, b1);
sobel_1 += grey * sobel_weights_1[i + 1][j + 1];
sobel_2 += grey * sobel_weights_2[i + 1][j + 1];
@ -445,15 +410,13 @@ static void mosaic_shaped_sharpen_pixel(void *ptr,
if (temp > 25)
{
api->putpixel(canvas_shaped, x, y,
SDL_MapRGBA(canvas_shaped->format, 0, 0, 0, 0));
api->putpixel(canvas_shaped, x, y, SDL_MapRGBA(canvas_shaped->format, 0, 0, 0, 0));
}
}
void mosaic_shaped_switchin(magic_api * api, int which,
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
{
int y, x;
int i, j;
@ -461,8 +424,7 @@ void mosaic_shaped_switchin(magic_api * api, int which,
SDL_Surface *surf_aux, *tmp, *tmp2;
Uint32 amask;
mosaic_shaped_counted =
(Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h));
mosaic_shaped_counted = (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h));
if (mosaic_shaped_counted == NULL)
{
@ -470,8 +432,7 @@ void mosaic_shaped_switchin(magic_api * api, int which,
exit(1);
}
mosaic_shaped_done =
(Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h));
mosaic_shaped_done = (Uint8 *) malloc(sizeof(Uint8) * (canvas->w * canvas->h));
if (mosaic_shaped_done == NULL)
{
@ -479,15 +440,13 @@ void mosaic_shaped_switchin(magic_api * api, int which,
exit(1);
}
amask =
~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
tmp = SDL_CreateRGBSurface(SDL_SWSURFACE,
canvas->w,
canvas->h,
canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask,
canvas->format->Bmask, amask);
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
canvas_shaped = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_RGB888, 0);
SDL_FreeSurface(tmp);
@ -495,8 +454,7 @@ void mosaic_shaped_switchin(magic_api * api, int which,
canvas->w + 10,
canvas->h + 10,
canvas->format->BitsPerPixel,
canvas->format->Rmask, canvas->format->Gmask,
canvas->format->Bmask, amask);
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
surf_aux = SDL_ConvertSurfaceFormat(tmp2, SDL_PIXELFORMAT_RGB888, 0);
SDL_FreeSurface(tmp2);
@ -509,58 +467,41 @@ void mosaic_shaped_switchin(magic_api * api, int which,
16,
canvas->format->BitsPerPixel,
canvas->format->Rmask,
canvas->format->Gmask,
canvas->format->Bmask,
amask);
canvas->format->Gmask, canvas->format->Bmask, amask);
SDL_FillRect(mosaic_shaped_pattern, NULL,
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
/* Shape */
for (i = 0; i < mosaic_shaped_pattern->w; i++)
{
api->putpixel(mosaic_shaped_pattern, 0, i,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 0, i, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 1, i,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, i, 0,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, i, 0, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 1,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
}
/* Shadow */
for (i = 1; i < mosaic_shaped_pattern->w - 1; i++)
{
api->putpixel(mosaic_shaped_pattern, 1, i,
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 2, i,
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, i, 1,
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, i, mosaic_shaped_pattern->w - 2,
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 128, 128, 128, SDL_ALPHA_OPAQUE));
}
api->putpixel(mosaic_shaped_pattern, 2, 2,
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 2, mosaic_shaped_pattern->h - 3,
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 3, 2,
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 3,
mosaic_shaped_pattern->h - 3,
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE));
}
else if (which == TOOL_IRREGULAR)
{
@ -569,68 +510,38 @@ void mosaic_shaped_switchin(magic_api * api, int which,
64,
canvas->format->BitsPerPixel,
canvas->format->Rmask,
canvas->format->Gmask,
canvas->format->Bmask,
amask);
canvas->format->Gmask, canvas->format->Bmask, amask);
SDL_FillRect(mosaic_shaped_pattern, NULL,
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
/* Start/end of lines taken from the original mosaic_shaped_irregular_pattern.png */
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 8, 36, 23, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 43, 36, 23, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 26, 28, 53, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 54, 10, 63, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 55, 0, 36, 23, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 43, 28, 53, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 24, 63, 28, 53, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 8, 50, 6, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 4, 10, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 25, 7, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 0, 26, 12, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 28, 53, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 56, 58, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 53, 55, 45, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 55, 63, 59, 49, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 63, 20, 45, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 26, 40, 18, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 4, 30, 14, 14, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 18, 33, 21, 17, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 23, 48, 29, 27, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 37, 50, 36, 23, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 44, 13, 37, 3, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 59, 24, 55, 7, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 49, 47, 54, 23, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 36, 35, 51, 37, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 8, 36, 23, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 43, 36, 23, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 26, 28, 53, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 54, 10, 63, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 55, 0, 36, 23, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 43, 28, 53, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 24, 63, 28, 53, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 8, 50, 6, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 4, 10, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 0, 25, 7, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 0, 26, 12, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 28, 53, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 41, 63, 56, 58, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 53, 55, 45, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 55, 63, 59, 49, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 10, 63, 20, 45, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 63, 26, 40, 18, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 4, 30, 14, 14, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 18, 33, 21, 17, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 23, 48, 29, 27, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 37, 50, 36, 23, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 44, 13, 37, 3, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 59, 24, 55, 7, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 49, 47, 54, 23, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 36, 35, 51, 37, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 1, mosaic_shaped_paint);
}
else if (which == TOOL_HEX)
@ -640,45 +551,24 @@ void mosaic_shaped_switchin(magic_api * api, int which,
28,
canvas->format->BitsPerPixel,
canvas->format->Rmask,
canvas->format->Gmask,
canvas->format->Bmask,
amask);
canvas->format->Gmask, canvas->format->Bmask, amask);
SDL_FillRect(mosaic_shaped_pattern, NULL,
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255,
SDL_ALPHA_OPAQUE));
SDL_MapRGBA(mosaic_shaped_pattern->format, 255, 255, 255, SDL_ALPHA_OPAQUE));
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 16, 8, 0, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 8, 0, 26, 0, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 26, 0, 32, 14, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 26, 27, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 47, 14, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 13, 8, 27, 1,
mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 16, 8, 0, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 8, 0, 26, 0, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 26, 0, 32, 14, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 26, 27, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 32, 14, 47, 14, 1, mosaic_shaped_paint);
api->line(api, which, mosaic_shaped_pattern, NULL, 0, 13, 8, 27, 1, mosaic_shaped_paint);
//make pattern more accurate
api->putpixel(mosaic_shaped_pattern, 9, 27,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 9, 26,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 27,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 26,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 25,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 25, 27,
SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0,
SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 9, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 9, 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 26, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 26, 25, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
api->putpixel(mosaic_shaped_pattern, 25, 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
}
@ -728,9 +618,7 @@ void mosaic_shaped_switchin(magic_api * api, int which,
canvas->w,
canvas->h,
canvas->format->BitsPerPixel,
canvas->format->Rmask,
canvas->format->Gmask,
canvas->format->Bmask, amask);
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
SDL_BlitSurface(canvas, NULL, canvas_back, NULL);
if (which != TOOL_SQUARE) /* The pattern for square is small enouth to not need an additional shape */
@ -748,8 +636,7 @@ void mosaic_shaped_switchin(magic_api * api, int which,
void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
SDL_FreeSurface(canvas_shaped);
SDL_FreeSurface(canvas_back);
@ -757,8 +644,7 @@ void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED,
free(mosaic_shaped_counted);
}
int mosaic_shaped_modes(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
int mosaic_shaped_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return (MODE_PAINT | MODE_FULLSCREEN);
}
@ -778,8 +664,7 @@ void reset_counter(SDL_Surface * canvas, Uint8 * counter)
int scan_fill_count;
int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
int x, int y, int fill_edge, int fill_tile, int size,
Uint32 color)
int x, int y, int fill_edge, int fill_tile, int size, Uint32 color)
{
int leftx, rightx;
Uint8 r, g, b, a;
@ -829,8 +714,7 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
}
else
{
SDL_GetRGBA(api->getpixel(canvas_back, x, y), canvas_back->format, &r, &g,
&b, &a);
SDL_GetRGBA(api->getpixel(canvas_back, x, y), canvas_back->format, &r, &g, &b, &a);
mosaic_shaped_average_r += r;
mosaic_shaped_average_g += g;
mosaic_shaped_average_b += b;
@ -839,17 +723,13 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
}
/* Search right */
while (scan_fill
(api, canvas, srfc, rightx, y, fill_edge, fill_tile, size, color)
&& (rightx < canvas->w))
while (scan_fill(api, canvas, srfc, rightx, y, fill_edge, fill_tile, size, color) && (rightx < canvas->w))
{
rightx++;
}
/* Search left */
while (scan_fill
(api, canvas, srfc, leftx, y, fill_edge, fill_tile, size, color)
&& (leftx >= 0))
while (scan_fill(api, canvas, srfc, leftx, y, fill_edge, fill_tile, size, color) && (leftx >= 0))
{
leftx--;
}
@ -859,14 +739,12 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
{
if (y > 0)
{
scan_fill(api, canvas, srfc, i, y - 1, fill_edge, fill_tile, size,
color);
scan_fill(api, canvas, srfc, i, y - 1, fill_edge, fill_tile, size, color);
}
if (y + 1 < canvas->w)
{
scan_fill(api, canvas, srfc, i, y + 1, fill_edge, fill_tile, size,
color);
scan_fill(api, canvas, srfc, i, y + 1, fill_edge, fill_tile, size, color);
}
}
@ -875,8 +753,7 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc,
}
void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y,
int size, Uint32 color)
void fill_square(magic_api * api, SDL_Surface * canvas, int x, int y, int size, Uint32 color)
{
int i, j;
@ -894,23 +771,19 @@ void deform(magic_api * api, SDL_Surface * srfc)
for (j = 0; j < srfc->h; j++)
for (i = 0; i < srfc->w; i++)
{
api->putpixel(srfc, i, j,
api->getpixel(srfc, i + sin(j * M_PI / 90) * 10 + 10, j));
api->putpixel(srfc, i, j, api->getpixel(srfc, i + sin(j * M_PI / 90) * 10 + 10, j));
}
for (i = 0; i < srfc->w; i++)
for (j = 0; j < srfc->h; j++)
{
api->putpixel(srfc, i, j,
api->getpixel(srfc, i, j + sin(i * M_PI / 90) * 10 + 10));
api->putpixel(srfc, i, j, api->getpixel(srfc, i, j + sin(i * M_PI / 90) * 10 + 10));
}
}
/* Paints a 2 pixel square with black and shadows around 3 more pixels */
static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas,
SDL_Surface * last ATTRIBUTE_UNUSED, int x,
int y)
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
{
magic_api *api = (magic_api *) ptr;
int radius, shadow;
@ -957,8 +830,7 @@ static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED,
if (b > 10)
b -= 9;
api->putpixel(canvas, ii, jj,
SDL_MapRGBA(canvas->format, r, g, b, SDL_ALPHA_OPAQUE));
api->putpixel(canvas, ii, jj, SDL_MapRGBA(canvas->format, r, g, b, SDL_ALPHA_OPAQUE));
}
@ -966,16 +838,20 @@ static void mosaic_shaped_paint(void *ptr, int which ATTRIBUTE_UNUSED,
}
Uint8 mosaic_shaped_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
Uint8 mosaic_shaped_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{
return 0;
}
Uint8 mosaic_shaped_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
Uint8 mosaic_shaped_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{
return 0;
}
void mosaic_shaped_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
void mosaic_shaped_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}