indent mosaic_shaped.c
This commit is contained in:
parent
bd18815216
commit
5e83b2408d
1 changed files with 446 additions and 424 deletions
|
|
@ -49,35 +49,31 @@
|
||||||
#define gettext_noop(String) String
|
#define gettext_noop(String) String
|
||||||
#endif
|
#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 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 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 do_mosaic_shaped_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which,
|
||||||
static void mosaic_shaped_fill(void * ptr_to_api, int which, SDL_Surface * canvas,
|
SDL_Rect * update_rect);
|
||||||
SDL_Surface * last, int x, int y);
|
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,
|
static void mosaic_shaped_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||||
SDL_Surface * last, int x, int y);
|
|
||||||
|
|
||||||
Uint32 mosaic_shaped_api_version(void);
|
Uint32 mosaic_shaped_api_version(void);
|
||||||
int mosaic_shaped_init(magic_api * api);
|
int mosaic_shaped_init(magic_api * api);
|
||||||
int mosaic_shaped_get_tool_count(magic_api * api);
|
int mosaic_shaped_get_tool_count(magic_api * api);
|
||||||
SDL_Surface * mosaic_shaped_get_icon(magic_api * api, int which);
|
SDL_Surface *mosaic_shaped_get_icon(magic_api * api, int which);
|
||||||
char * mosaic_shaped_get_name(magic_api * api, int which);
|
char *mosaic_shaped_get_name(magic_api * api, int which);
|
||||||
|
|
||||||
char * mosaic_shaped_get_description(magic_api * api, int which, int mode);
|
char *mosaic_shaped_get_description(magic_api * api, int which, int mode);
|
||||||
|
|
||||||
void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||||
SDL_Rect * update_rect);
|
|
||||||
|
|
||||||
void mosaic_shaped_click(magic_api * api, int which, int mode,
|
void mosaic_shaped_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 mosaic_shaped_release(magic_api * api, int which,
|
void mosaic_shaped_release(magic_api * api, int which,
|
||||||
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 mosaic_shaped_shutdown(magic_api * api);
|
void mosaic_shaped_shutdown(magic_api * api);
|
||||||
|
|
||||||
|
|
@ -91,10 +87,11 @@ void mosaic_shaped_switchout(magic_api * api, int which, int mode, SDL_Surface *
|
||||||
|
|
||||||
int mosaic_shaped_modes(magic_api * api, int which);
|
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 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);
|
||||||
|
|
||||||
Uint8 * mosaic_shaped_counted;
|
Uint8 *mosaic_shaped_counted;
|
||||||
Uint8 * mosaic_shaped_done;
|
Uint8 *mosaic_shaped_done;
|
||||||
Uint8 mosaic_shaped_r, mosaic_shaped_g, mosaic_shaped_b;
|
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;
|
||||||
|
|
@ -108,42 +105,37 @@ enum
|
||||||
mosaic_shaped_NUM_TOOLS
|
mosaic_shaped_NUM_TOOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
static Mix_Chunk * mosaic_shaped_snd_effect[mosaic_shaped_NUM_TOOLS];
|
static Mix_Chunk *mosaic_shaped_snd_effect[mosaic_shaped_NUM_TOOLS];
|
||||||
static SDL_Surface * canvas_shaped;
|
static SDL_Surface *canvas_shaped;
|
||||||
static SDL_Surface * canvas_back;
|
static SDL_Surface *canvas_back;
|
||||||
static SDL_Surface * mosaic_shaped_pattern;
|
static SDL_Surface *mosaic_shaped_pattern;
|
||||||
|
|
||||||
const char * mosaic_shaped_snd_filenames[mosaic_shaped_NUM_TOOLS] =
|
const char *mosaic_shaped_snd_filenames[mosaic_shaped_NUM_TOOLS] = {
|
||||||
{
|
|
||||||
"mosaic_shaped_square.ogg",
|
"mosaic_shaped_square.ogg",
|
||||||
"mosaic_shaped_hex.ogg",
|
"mosaic_shaped_hex.ogg",
|
||||||
"mosaic_shaped_irregular.ogg", /* FIXME */ /*what's problem?*/
|
"mosaic_shaped_irregular.ogg", /* FIXME *//*what's problem? */
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * mosaic_shaped_icon_filenames[mosaic_shaped_NUM_TOOLS] =
|
const char *mosaic_shaped_icon_filenames[mosaic_shaped_NUM_TOOLS] = {
|
||||||
{
|
|
||||||
"mosaic_shaped_square.png",
|
"mosaic_shaped_square.png",
|
||||||
"mosaic_shaped_hex.png",
|
"mosaic_shaped_hex.png",
|
||||||
"mosaic_shaped_irregular.png",
|
"mosaic_shaped_irregular.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * mosaic_shaped_pattern_filenames[mosaic_shaped_NUM_TOOLS] =
|
const char *mosaic_shaped_pattern_filenames[mosaic_shaped_NUM_TOOLS] = {
|
||||||
{
|
|
||||||
"mosaic_shaped_square_pattern.png",
|
"mosaic_shaped_square_pattern.png",
|
||||||
"mosaic_shaped_hex_pattern.png",
|
"mosaic_shaped_hex_pattern.png",
|
||||||
"mosaic_shaped_irregular_pattern.png",
|
"mosaic_shaped_irregular_pattern.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * mosaic_shaped_names[mosaic_shaped_NUM_TOOLS] =
|
const char *mosaic_shaped_names[mosaic_shaped_NUM_TOOLS] = {
|
||||||
{
|
|
||||||
gettext_noop("Square Mosaic"),
|
gettext_noop("Square Mosaic"),
|
||||||
gettext_noop("Hexagon Mosaic"),
|
gettext_noop("Hexagon Mosaic"),
|
||||||
gettext_noop("Irregular Mosaic"),
|
gettext_noop("Irregular Mosaic"),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * mosaic_shaped_descs[mosaic_shaped_NUM_TOOLS][2] =
|
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 to add a square mosaic to your entire picture."),
|
||||||
|
|
@ -170,6 +162,7 @@ int mosaic_shaped_init(magic_api * api)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
mosaic_shaped_pattern = NULL;
|
mosaic_shaped_pattern = NULL;
|
||||||
|
|
||||||
for (i = 0; i < mosaic_shaped_NUM_TOOLS; i++)
|
for (i = 0; i < mosaic_shaped_NUM_TOOLS; i++)
|
||||||
|
|
@ -187,21 +180,22 @@ int mosaic_shaped_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load our icons:
|
// Load our icons:
|
||||||
SDL_Surface * mosaic_shaped_get_icon(magic_api * api, int which)
|
SDL_Surface *mosaic_shaped_get_icon(magic_api * api, int which)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
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));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our names, localized:
|
// Return our names, localized:
|
||||||
char * mosaic_shaped_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
char *mosaic_shaped_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||||
{
|
{
|
||||||
return (strdup(gettext_noop(mosaic_shaped_names[which])));
|
return (strdup(gettext_noop(mosaic_shaped_names[which])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our descriptions, localized:
|
// 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])));
|
return (strdup(gettext_noop(mosaic_shaped_descs[which][mode - 1])));
|
||||||
}
|
}
|
||||||
|
|
@ -213,11 +207,13 @@ static int mosaic_shaped_grey(Uint8 r1, Uint8 g1, Uint8 b1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the effect for the full image
|
// 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)
|
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 i, j, size;
|
int i, j, size;
|
||||||
Uint32 mosaic_shaped_color;
|
Uint32 mosaic_shaped_color;
|
||||||
magic_api * api = (magic_api *) ptr;
|
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)
|
for (i = 3; i < canvas->w - 3; i += 2)
|
||||||
|
|
@ -241,7 +237,10 @@ static void do_mosaic_shaped_full(void * ptr, SDL_Surface * canvas, SDL_Surface
|
||||||
{
|
{
|
||||||
reset_counter(canvas, mosaic_shaped_counted);
|
reset_counter(canvas, mosaic_shaped_counted);
|
||||||
size = 0;
|
size = 0;
|
||||||
pixel_average = SDL_MapRGB(canvas->format, mosaic_shaped_average_r / mosaic_shaped_average_count, mosaic_shaped_average_g / mosaic_shaped_average_count, mosaic_shaped_average_b / mosaic_shaped_average_count);
|
pixel_average =
|
||||||
|
SDL_MapRGB(canvas->format, 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);
|
scan_fill(api, canvas, canvas_shaped, i, j, 0, 1, size, pixel_average);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -250,12 +249,13 @@ static void do_mosaic_shaped_full(void * ptr, SDL_Surface * canvas, SDL_Surface
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fills a tesera */
|
/* Fills a tesera */
|
||||||
static void mosaic_shaped_fill(void * ptr_to_api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
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 * last ATTRIBUTE_UNUSED, int x, int y)
|
||||||
{
|
{
|
||||||
Uint32 mosaic_shaped_color;
|
Uint32 mosaic_shaped_color;
|
||||||
int size;
|
int size;
|
||||||
magic_api * api = (magic_api *) ptr_to_api;
|
magic_api *api = (magic_api *) ptr_to_api;
|
||||||
|
|
||||||
x = clamp(0, x, canvas->w - 1);
|
x = clamp(0, x, canvas->w - 1);
|
||||||
y = clamp(0, y, canvas->h - 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);
|
||||||
|
|
@ -274,7 +274,10 @@ static void mosaic_shaped_fill(void * ptr_to_api, int which ATTRIBUTE_UNUSED, SD
|
||||||
if (mosaic_shaped_average_count > 0)
|
if (mosaic_shaped_average_count > 0)
|
||||||
{
|
{
|
||||||
size = 0;
|
size = 0;
|
||||||
pixel_average = SDL_MapRGB(canvas->format, mosaic_shaped_average_r / mosaic_shaped_average_count, mosaic_shaped_average_g / mosaic_shaped_average_count, mosaic_shaped_average_b / mosaic_shaped_average_count);
|
pixel_average =
|
||||||
|
SDL_MapRGB(canvas->format, mosaic_shaped_average_r / mosaic_shaped_average_count,
|
||||||
|
mosaic_shaped_average_g / mosaic_shaped_average_count,
|
||||||
|
mosaic_shaped_average_b / mosaic_shaped_average_count);
|
||||||
reset_counter(canvas, mosaic_shaped_counted);
|
reset_counter(canvas, mosaic_shaped_counted);
|
||||||
scan_fill(api, canvas, canvas_shaped, x, y, 0, 1, size, pixel_average);
|
scan_fill(api, canvas, canvas_shaped, x, y, 0, 1, size, pixel_average);
|
||||||
}
|
}
|
||||||
|
|
@ -282,8 +285,7 @@ static void mosaic_shaped_fill(void * ptr_to_api, int which ATTRIBUTE_UNUSED, SD
|
||||||
|
|
||||||
// Affect the canvas on drag:
|
// Affect the canvas on drag:
|
||||||
void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||||
SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
api->line(api, which, canvas, last, ox, oy, x, y, 1, mosaic_shaped_fill);
|
api->line(api, which, canvas, last, ox, oy, x, y, 1, mosaic_shaped_fill);
|
||||||
update_rect->x = min(ox, x) - mosaic_shaped_pattern->w;
|
update_rect->x = min(ox, x) - mosaic_shaped_pattern->w;
|
||||||
|
|
@ -295,8 +297,7 @@ void mosaic_shaped_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
|
|
||||||
// Affect the canvas on click:
|
// Affect the canvas on click:
|
||||||
void mosaic_shaped_click(magic_api * api, int which, int mode,
|
void mosaic_shaped_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)
|
|
||||||
{
|
{
|
||||||
if (mode == MODE_FULLSCREEN)
|
if (mode == MODE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
|
|
@ -350,24 +351,24 @@ int mosaic_shaped_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which AT
|
||||||
}
|
}
|
||||||
|
|
||||||
//Sharpen a pixel
|
//Sharpen a pixel
|
||||||
static void mosaic_shaped_sharpen_pixel(void * ptr,
|
static void mosaic_shaped_sharpen_pixel(void *ptr,
|
||||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last,
|
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last, int x, int y)
|
||||||
int x, int y)
|
|
||||||
{
|
{
|
||||||
magic_api * api = (magic_api *) ptr;
|
magic_api *api = (magic_api *) ptr;
|
||||||
Uint8 r1, g1, b1;
|
Uint8 r1, g1, b1;
|
||||||
int grey;
|
int grey;
|
||||||
int i, j;
|
int i, j;
|
||||||
double sobel_1 = 0, sobel_2 = 0;
|
double sobel_1 = 0, sobel_2 = 0;
|
||||||
double temp;
|
double temp;
|
||||||
|
|
||||||
//Sobel weighting masks
|
//Sobel weighting masks
|
||||||
const int sobel_weights_1[3][3] = { {1, 2, 1},
|
const int sobel_weights_1[3][3] = { {1, 2, 1},
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
{ -1, -2, -1}
|
{-1, -2, -1}
|
||||||
};
|
};
|
||||||
const int sobel_weights_2[3][3] = { { -1, 0, 1},
|
const int sobel_weights_2[3][3] = { {-1, 0, 1},
|
||||||
{ -2, 0, 2},
|
{-2, 0, 2},
|
||||||
{ -1, 0, 1}
|
{-1, 0, 1}
|
||||||
};
|
};
|
||||||
sobel_1 = 0;
|
sobel_1 = 0;
|
||||||
sobel_2 = 0;
|
sobel_2 = 0;
|
||||||
|
|
@ -400,8 +401,9 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
int y, x;
|
int y, x;
|
||||||
int i, j;
|
int i, j;
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
SDL_Surface * surf_aux;
|
SDL_Surface *surf_aux;
|
||||||
Uint32 amask;
|
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)
|
if (mosaic_shaped_counted == NULL)
|
||||||
|
|
@ -418,23 +420,17 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
amask = ~(canvas->format->Rmask |
|
amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||||
canvas->format->Gmask |
|
|
||||||
canvas->format->Bmask);
|
|
||||||
canvas_shaped = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
canvas_shaped = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
canvas->w,
|
canvas->w,
|
||||||
canvas->h,
|
canvas->h,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Gmask,
|
|
||||||
canvas->format->Bmask, amask);
|
|
||||||
surf_aux = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
surf_aux = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
canvas->w + 10,
|
canvas->w + 10,
|
||||||
canvas->h + 10,
|
canvas->h + 10,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Gmask,
|
|
||||||
canvas->format->Bmask, amask);
|
|
||||||
|
|
||||||
/* Generation of patterns now in the program, solves #210 */
|
/* Generation of patterns now in the program, solves #210 */
|
||||||
if (which == TOOL_SQUARE)
|
if (which == TOOL_SQUARE)
|
||||||
|
|
@ -444,30 +440,42 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
16,
|
16,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask,
|
||||||
canvas->format->Gmask,
|
canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Bmask, amask);
|
SDL_FillRect(mosaic_shaped_pattern, NULL,
|
||||||
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 */
|
/* Shape */
|
||||||
for (i = 0;i < mosaic_shaped_pattern->w; i++)
|
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,
|
||||||
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 1, i, 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, mosaic_shaped_pattern->w - 1, i,
|
||||||
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));
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
/* Shadow */
|
/* Shadow */
|
||||||
for (i = 1; i < mosaic_shaped_pattern->w - 1; i++)
|
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));
|
api->putpixel(mosaic_shaped_pattern, 1, i,
|
||||||
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));
|
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 2, i,
|
||||||
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, i, 1,
|
||||||
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
api->putpixel(mosaic_shaped_pattern, 2, 2, SDL_MapRGBA(mosaic_shaped_pattern->format, 152, 152, 152, SDL_ALPHA_OPAQUE));
|
api->putpixel(mosaic_shaped_pattern, 2, 2,
|
||||||
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));
|
api->putpixel(mosaic_shaped_pattern, 2, mosaic_shaped_pattern->h - 3,
|
||||||
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));
|
||||||
|
api->putpixel(mosaic_shaped_pattern, mosaic_shaped_pattern->w - 3, 2,
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
else if (which == TOOL_IRREGULAR)
|
else if (which == TOOL_IRREGULAR)
|
||||||
{
|
{
|
||||||
|
|
@ -476,9 +484,9 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
64,
|
64,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask,
|
||||||
canvas->format->Gmask,
|
canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Bmask, amask);
|
SDL_FillRect(mosaic_shaped_pattern, NULL,
|
||||||
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 */
|
/* 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, 8, 36, 23, 1, mosaic_shaped_paint);
|
||||||
|
|
@ -491,8 +499,8 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
api->line(api, which, mosaic_shaped_pattern, NULL, 24, 0, 27, 19, 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, 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, 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, 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, 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, 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, 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, 63, 53, 55, 45, 1, mosaic_shaped_paint);
|
||||||
|
|
@ -510,31 +518,37 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
api->line(api, which, mosaic_shaped_pattern, NULL, 61, 44, 52, 31, 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)
|
else if (which == TOOL_HEX)
|
||||||
{
|
{
|
||||||
mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
mosaic_shaped_pattern = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||||
48,
|
48,
|
||||||
28,
|
28,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask,
|
||||||
canvas->format->Gmask,
|
canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Bmask, amask);
|
SDL_FillRect(mosaic_shaped_pattern, NULL,
|
||||||
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, 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, 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, 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, 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, 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, 13, 8, 27, 1, mosaic_shaped_paint);
|
||||||
|
|
||||||
//make pattern more accurate
|
//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, 27,
|
||||||
api->putpixel(mosaic_shaped_pattern, 9 , 26, 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, 26 , 27, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
|
api->putpixel(mosaic_shaped_pattern, 9, 26,
|
||||||
api->putpixel(mosaic_shaped_pattern, 26 , 26, 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, 26 , 25, SDL_MapRGBA(mosaic_shaped_pattern->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
|
api->putpixel(mosaic_shaped_pattern, 26, 27,
|
||||||
api->putpixel(mosaic_shaped_pattern, 25 , 27, 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, 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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,7 +569,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
deform(api, surf_aux);
|
deform(api, surf_aux);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_SetAlpha(surf_aux, 0 , SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(surf_aux, 0, SDL_ALPHA_OPAQUE);
|
||||||
SDL_BlitSurface(surf_aux, NULL, canvas_shaped, NULL);
|
SDL_BlitSurface(surf_aux, NULL, canvas_shaped, NULL);
|
||||||
SDL_FreeSurface(surf_aux);
|
SDL_FreeSurface(surf_aux);
|
||||||
black = SDL_MapRGBA(canvas->format, 0, 0, 0, 0);
|
black = SDL_MapRGBA(canvas->format, 0, 0, 0, 0);
|
||||||
|
|
@ -583,9 +597,7 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
canvas->w,
|
canvas->w,
|
||||||
canvas->h,
|
canvas->h,
|
||||||
canvas->format->BitsPerPixel,
|
canvas->format->BitsPerPixel,
|
||||||
canvas->format->Rmask,
|
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, amask);
|
||||||
canvas->format->Gmask,
|
|
||||||
canvas->format->Bmask, amask);
|
|
||||||
SDL_BlitSurface(canvas, NULL, canvas_back, NULL);
|
SDL_BlitSurface(canvas, NULL, canvas_back, NULL);
|
||||||
|
|
||||||
if (which != TOOL_SQUARE) /* The pattern for square is small enouth to not need an additional shape */
|
if (which != TOOL_SQUARE) /* The pattern for square is small enouth to not need an additional shape */
|
||||||
|
|
@ -601,7 +613,8 @@ void mosaic_shaped_switchin(magic_api * api, int which, int mode ATTRIBUTE_UNUSE
|
||||||
reset_counter(canvas, mosaic_shaped_done);
|
reset_counter(canvas, mosaic_shaped_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
void mosaic_shaped_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||||
|
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(canvas_shaped);
|
SDL_FreeSurface(canvas_shaped);
|
||||||
SDL_FreeSurface(canvas_back);
|
SDL_FreeSurface(canvas_back);
|
||||||
|
|
@ -628,7 +641,8 @@ void reset_counter(SDL_Surface * canvas, Uint8 * counter)
|
||||||
|
|
||||||
int scan_fill_count;
|
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 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 leftx, rightx;
|
int leftx, rightx;
|
||||||
Uint8 r, g, b, a;
|
Uint8 r, g, b, a;
|
||||||
|
|
@ -667,6 +681,7 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, int x,
|
||||||
Uint32 shadow;
|
Uint32 shadow;
|
||||||
Uint8 shr, shg, shb, sha;
|
Uint8 shr, shg, shb, sha;
|
||||||
Uint8 cnvsr, cnvsg, cnvsb, cnvsa;
|
Uint8 cnvsr, cnvsg, cnvsb, cnvsa;
|
||||||
|
|
||||||
shadow = api->getpixel(srfc, x, y);
|
shadow = api->getpixel(srfc, x, y);
|
||||||
SDL_GetRGBA(shadow, srfc->format, &shr, &shg, &shb, &sha);
|
SDL_GetRGBA(shadow, srfc->format, &shr, &shg, &shb, &sha);
|
||||||
SDL_GetRGBA(pixel_average, srfc->format, &cnvsr, &cnvsg, &cnvsb, &cnvsa);
|
SDL_GetRGBA(pixel_average, srfc->format, &cnvsr, &cnvsg, &cnvsb, &cnvsa);
|
||||||
|
|
@ -688,13 +703,13 @@ int scan_fill(magic_api * api, SDL_Surface * canvas, SDL_Surface * srfc, int x,
|
||||||
/* Search right */
|
/* 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 ++;
|
rightx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search left */
|
/* 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 --;
|
leftx--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Top / bottom */
|
/* Top / bottom */
|
||||||
|
|
@ -745,10 +760,10 @@ void deform(magic_api * api, SDL_Surface * srfc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Paints a 2 pixel square with black and shadows around 3 more pixels */
|
/* 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,
|
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 * last ATTRIBUTE_UNUSED, int x, int y)
|
||||||
{
|
{
|
||||||
magic_api * api = (magic_api *) ptr;
|
magic_api *api = (magic_api *) ptr;
|
||||||
int radius, shadow;
|
int radius, shadow;
|
||||||
int i, j, ii, jj;
|
int i, j, ii, jj;
|
||||||
Uint8 r, g, b, a;
|
Uint8 r, g, b, a;
|
||||||
|
|
@ -764,17 +779,21 @@ static void mosaic_shaped_paint(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surf
|
||||||
{
|
{
|
||||||
/* Ensure effects on the edges reaches the opposite side if necessary */
|
/* Ensure effects on the edges reaches the opposite side if necessary */
|
||||||
ii = x + i;
|
ii = x + i;
|
||||||
if (ii < 0) ii += canvas->w;
|
if (ii < 0)
|
||||||
if (ii >= canvas->w) ii -= canvas->w;
|
ii += canvas->w;
|
||||||
|
if (ii >= canvas->w)
|
||||||
|
ii -= canvas->w;
|
||||||
jj = y + j;
|
jj = y + j;
|
||||||
if (jj < 0) jj += canvas->h;
|
if (jj < 0)
|
||||||
if (jj >= canvas->h) ii -= canvas->h;
|
jj += canvas->h;
|
||||||
|
if (jj >= canvas->h)
|
||||||
|
ii -= canvas->h;
|
||||||
|
|
||||||
/* Shadow_tone is also used as a marker, anything already painted on black must finally be black */
|
/* Shadow_tone is also used as a marker, anything already painted on black must finally be black */
|
||||||
shadow_tone = api->getpixel(canvas, ii, jj);
|
shadow_tone = api->getpixel(canvas, ii, jj);
|
||||||
|
|
||||||
// if (abs(i) <= radius && abs(j) <= radius)
|
// if (abs(i) <= radius && abs(j) <= radius)
|
||||||
if (0 <=i && i <= 1 && 0 <= j && j <= 1)
|
if (0 <= i && i <= 1 && 0 <= j && j <= 1)
|
||||||
api->putpixel(canvas, ii, jj, black);
|
api->putpixel(canvas, ii, jj, black);
|
||||||
|
|
||||||
else if (api->in_circle(i, j, radius + shadow) && shadow_tone != black)
|
else if (api->in_circle(i, j, radius + shadow) && shadow_tone != black)
|
||||||
|
|
@ -782,9 +801,12 @@ static void mosaic_shaped_paint(void * ptr, int which ATTRIBUTE_UNUSED, SDL_Surf
|
||||||
SDL_GetRGBA(shadow_tone, canvas->format, &r, &g, &b, &a);
|
SDL_GetRGBA(shadow_tone, canvas->format, &r, &g, &b, &a);
|
||||||
|
|
||||||
/* Shadows should be shadows, not black */
|
/* Shadows should be shadows, not black */
|
||||||
if (r > 10) r -= 9;
|
if (r > 10)
|
||||||
if (g > 10) g -= 9;
|
r -= 9;
|
||||||
if (b > 10) b -= 9;
|
if (g > 10)
|
||||||
|
g -= 9;
|
||||||
|
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));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue