Adding "indent.sh" to re-indent code; ran it!!!
This commit is contained in:
parent
16336cc854
commit
18f9cad6fe
98 changed files with 5798 additions and 9001 deletions
|
|
@ -26,15 +26,11 @@
|
|||
// #define DEBUG_ANGLE
|
||||
|
||||
Mix_Chunk *snd_effect = NULL;
|
||||
SDL_Surface * rivulet_img_brush_add = NULL,
|
||||
* rivulet_img_brush_alpha = NULL,
|
||||
* rivulet_img_brush_sub = NULL,
|
||||
* rivulet_img_angles = NULL;
|
||||
SDL_Surface * rivulet_snapshot = NULL;
|
||||
SDL_Surface *rivulet_img_brush_add = NULL,
|
||||
*rivulet_img_brush_alpha = NULL, *rivulet_img_brush_sub = NULL, *rivulet_img_angles = NULL;
|
||||
SDL_Surface *rivulet_snapshot = NULL;
|
||||
int riv_x, riv_y;
|
||||
Uint8 * riv_radii = NULL,
|
||||
* riv_alpha = NULL,
|
||||
* riv_angles = NULL;
|
||||
Uint8 *riv_radii = NULL, *riv_alpha = NULL, *riv_angles = NULL;
|
||||
|
||||
Uint32 rivulet_api_version(void);
|
||||
int rivulet_init(magic_api * api);
|
||||
|
|
@ -47,22 +43,16 @@ int rivulet_requires_colors(magic_api * api, int which);
|
|||
int rivulet_modes(magic_api * api, int which);
|
||||
void rivulet_shutdown(magic_api * api);
|
||||
void rivulet_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void rivulet_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void rivulet_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void rivulet_line_callback_drag(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void rivulet_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void rivulet_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void rivulet_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rivulet_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void rivulet_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rivulet_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void zero_riv_arrays(SDL_Surface * canvas);
|
||||
|
||||
|
||||
|
|
@ -82,8 +72,7 @@ int rivulet_init(magic_api * api)
|
|||
|
||||
/* Load our images */
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-add.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-add.png", api->data_directory);
|
||||
rivulet_img_brush_add = IMG_Load(fname);
|
||||
if (rivulet_img_brush_add == NULL)
|
||||
{
|
||||
|
|
@ -91,8 +80,7 @@ int rivulet_init(magic_api * api)
|
|||
return 0;
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-alpha.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-alpha.png", api->data_directory);
|
||||
rivulet_img_brush_alpha = IMG_Load(fname);
|
||||
if (rivulet_img_brush_alpha == NULL)
|
||||
{
|
||||
|
|
@ -100,8 +88,7 @@ int rivulet_init(magic_api * api)
|
|||
return 0;
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-sub.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-brush-sub.png", api->data_directory);
|
||||
rivulet_img_brush_sub = IMG_Load(fname);
|
||||
if (rivulet_img_brush_sub == NULL)
|
||||
{
|
||||
|
|
@ -109,8 +96,7 @@ int rivulet_init(magic_api * api)
|
|||
return 0;
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-angles.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet-angles.png", api->data_directory);
|
||||
rivulet_img_angles = IMG_Load(fname);
|
||||
if (rivulet_img_angles == NULL)
|
||||
{
|
||||
|
|
@ -131,39 +117,32 @@ SDL_Surface *rivulet_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rivulet.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *rivulet_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *rivulet_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext("Rivulet"));
|
||||
}
|
||||
|
||||
int rivulet_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rivulet_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
char *rivulet_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *rivulet_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return(gettext("Click and drag downward to add water rivulets to your drawing"));
|
||||
return (gettext("Click and drag downward to add water rivulets to your drawing"));
|
||||
}
|
||||
|
||||
int rivulet_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rivulet_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rivulet_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rivulet_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
@ -198,8 +177,7 @@ void rivulet_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
rivulet_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
riv_x = x;
|
||||
riv_y = y - 1;
|
||||
|
|
@ -208,10 +186,10 @@ rivulet_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
return;
|
||||
|
||||
if (snd_effect != NULL)
|
||||
{
|
||||
api->stopsound();
|
||||
api->playsound(snd_effect, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
{
|
||||
api->stopsound();
|
||||
api->playsound(snd_effect, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
rivulet_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -219,8 +197,8 @@ rivulet_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
void
|
||||
rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int old_riv_x, old_riv_y;
|
||||
|
||||
|
|
@ -243,8 +221,7 @@ rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
|||
riv_x = x;
|
||||
riv_y = y;
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, old_riv_x, old_riv_y, riv_x, riv_y, 1,
|
||||
rivulet_line_callback_drag);
|
||||
api->line((void *)api, which, canvas, snapshot, old_riv_x, old_riv_y, riv_x, riv_y, 1, rivulet_line_callback_drag);
|
||||
|
||||
/* FIXME */
|
||||
update_rect->x = 0;
|
||||
|
|
@ -254,11 +231,8 @@ rivulet_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y, /* ignored and reused in a for-loop */
|
||||
SDL_Rect * update_rect)
|
||||
void rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y, /* ignored and reused in a for-loop */
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
int src_x, src_y, idx;
|
||||
double radius, angle_deg, angle_rad;
|
||||
|
|
@ -294,12 +268,13 @@ rivulet_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, v, 64, 64));
|
||||
#else
|
||||
|
||||
radius = ((double) riv_radii[idx]);
|
||||
radius = ((double)riv_radii[idx]);
|
||||
alpha = riv_alpha[idx] / 2;
|
||||
|
||||
if (radius != 0.0) {
|
||||
if (radius != 0.0)
|
||||
{
|
||||
/* Angle is stored as 0-255 (so 256 would be 360 degrees) */
|
||||
angle_deg = ((((double) riv_angles[idx]) / 256.0) * 360.0);
|
||||
angle_deg = ((((double)riv_angles[idx]) / 256.0) * 360.0);
|
||||
|
||||
angle_rad = (angle_deg * M_PI) / 180.0;
|
||||
|
||||
|
|
@ -343,11 +318,9 @@ void rivulet_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api * api;
|
||||
magic_api *api;
|
||||
SDL_Rect dest;
|
||||
int w, h, half_w, half_h, idx;
|
||||
int src_x, src_y, dest_x, dest_y;
|
||||
|
|
@ -374,19 +347,23 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
|
||||
/* Adjust the displacement maps */
|
||||
for (src_y = 0; src_y <= h; src_y++) {
|
||||
for (src_y = 0; src_y <= h; src_y++)
|
||||
{
|
||||
dest_y = (y - half_h) + src_y;
|
||||
if (dest_y >= 0 && dest_y < canvas->h) {
|
||||
for (src_x = 0; src_x < w; src_x++) {
|
||||
if (dest_y >= 0 && dest_y < canvas->h)
|
||||
{
|
||||
for (src_x = 0; src_x < w; src_x++)
|
||||
{
|
||||
dest_x = (x - half_w) + src_x;
|
||||
if (dest_x >= 0 && dest_x < canvas->w) {
|
||||
if (dest_x >= 0 && dest_x < canvas->w)
|
||||
{
|
||||
idx = (dest_y * canvas->w) + dest_x;
|
||||
|
||||
/* Add alpha */
|
||||
pix = api->getpixel(rivulet_img_brush_alpha, src_x, src_y);
|
||||
SDL_GetRGB(pix, rivulet_img_brush_alpha->format, &intensity, &tmp, &tmp);
|
||||
|
||||
alpha = ((int) riv_alpha[idx] + (int) (intensity));
|
||||
alpha = ((int)riv_alpha[idx] + (int)(intensity));
|
||||
if (alpha > 255)
|
||||
alpha = 255;
|
||||
riv_alpha[idx] = (Uint8) alpha;
|
||||
|
|
@ -394,17 +371,17 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
/* Apply radius brush to radius displacement map */
|
||||
if (alpha > 0)
|
||||
{
|
||||
pix = api->getpixel(rivulet_img_brush_add, src_x, src_y);
|
||||
SDL_GetRGB(pix, rivulet_img_brush_add->format, &intensity, &tmp, &tmp);
|
||||
{
|
||||
pix = api->getpixel(rivulet_img_brush_add, src_x, src_y);
|
||||
SDL_GetRGB(pix, rivulet_img_brush_add->format, &intensity, &tmp, &tmp);
|
||||
|
||||
radius = ((int) riv_radii[idx] + (int) intensity - 128);
|
||||
if (radius < 0)
|
||||
radius = 0;
|
||||
if (radius > 255)
|
||||
radius = 255;
|
||||
riv_radii[idx] = radius;
|
||||
}
|
||||
radius = ((int)riv_radii[idx] + (int)intensity - 128);
|
||||
if (radius < 0)
|
||||
radius = 0;
|
||||
if (radius > 255)
|
||||
radius = 255;
|
||||
riv_radii[idx] = radius;
|
||||
}
|
||||
|
||||
|
||||
/* Apply angle brush to angle displacement map */
|
||||
|
|
@ -419,58 +396,54 @@ void rivulet_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void rivulet_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
if (riv_radii == NULL)
|
||||
{
|
||||
riv_radii = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_radii == NULL)
|
||||
{
|
||||
riv_radii = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_radii == NULL)
|
||||
{
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_radii!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
riv_alpha = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_alpha == NULL)
|
||||
{
|
||||
free(riv_radii);
|
||||
riv_radii = NULL;
|
||||
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_alpha!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
riv_angles = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_angles == NULL)
|
||||
{
|
||||
free(riv_radii);
|
||||
riv_radii = NULL;
|
||||
|
||||
free(riv_alpha);
|
||||
riv_alpha = NULL;
|
||||
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_angles!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_radii!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
riv_alpha = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_alpha == NULL)
|
||||
{
|
||||
free(riv_radii);
|
||||
riv_radii = NULL;
|
||||
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_alpha!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
riv_angles = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (riv_angles == NULL)
|
||||
{
|
||||
free(riv_radii);
|
||||
riv_radii = NULL;
|
||||
|
||||
free(riv_alpha);
|
||||
riv_alpha = NULL;
|
||||
|
||||
fprintf(stderr, "rivulet: Cannot malloc() riv_angles!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
zero_riv_arrays(canvas);
|
||||
|
||||
if (rivulet_snapshot == NULL)
|
||||
rivulet_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
if (rivulet_snapshot != NULL)
|
||||
SDL_BlitSurface(canvas, NULL, rivulet_snapshot, NULL);
|
||||
}
|
||||
|
||||
void rivulet_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
zero_riv_arrays(canvas);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ const int alien_groups[alien_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *alien_descs[alien_NUM_TOOLS][2] = {
|
||||
{gettext_noop
|
||||
("Click and drag the mouse to change the colors in parts of your picture."),
|
||||
{gettext_noop("Click and drag the mouse to change the colors in parts of your picture."),
|
||||
gettext_noop("Click to change the colors in your entire picture."),},
|
||||
};
|
||||
|
||||
|
|
@ -86,12 +85,10 @@ char *alien_get_name(magic_api * api, int which);
|
|||
int alien_get_group(magic_api * api, int which);
|
||||
char *alien_get_description(magic_api * api, int which, int mode);
|
||||
void alien_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);
|
||||
Mix_Chunk *magic_loadsound(char *file);
|
||||
void alien_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 alien_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void alien_shutdown(magic_api * api);
|
||||
|
|
@ -101,12 +98,9 @@ int alien_requires_colors(magic_api * api, int which);
|
|||
Uint8 alien_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 alien_default_size(magic_api * api, int which, int mode);
|
||||
void alien_set_size(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
Uint8 size, SDL_Rect * update_rect);
|
||||
void alien_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void alien_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void alien_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void alien_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int alien_modes(magic_api * api, int which);
|
||||
|
||||
|
||||
|
|
@ -125,8 +119,7 @@ int alien_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < alien_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
alien_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, alien_snd_filenames[i]);
|
||||
alien_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -142,8 +135,7 @@ SDL_Surface *alien_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
alien_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, alien_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -159,16 +151,14 @@ int alien_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *alien_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *alien_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(alien_descs[which][mode - 1])));
|
||||
}
|
||||
|
||||
//Do the effect for one pixel
|
||||
static void do_alien_pixel(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;
|
||||
|
||||
|
|
@ -176,25 +166,21 @@ static void do_alien_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1],
|
||||
&temp[2]);
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
//EP temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255);
|
||||
temp2[k] = clamp(0.0,
|
||||
127.5 * (1.0 +
|
||||
sin(((temp[k] / 127.5 -
|
||||
1.0) * alien_FREQUENCY[k] +
|
||||
alien_ANGLE[k] / 180.0) * M_PI)), 255.0);
|
||||
1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)), 255.0);
|
||||
}
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
|
||||
}
|
||||
|
||||
// Do the effect for the full image
|
||||
static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which)
|
||||
static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
|
@ -208,8 +194,7 @@ static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
|||
}
|
||||
|
||||
//do the effect for the brush
|
||||
static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -218,8 +203,7 @@ static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
for (xx = x - alien_RADIUS; xx < x + alien_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, alien_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, alien_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_alien_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
|
|
@ -229,12 +213,10 @@ static void do_alien_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void alien_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_alien_brush);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_alien_brush);
|
||||
|
||||
api->playsound(alien_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -275,8 +257,7 @@ Mix_Chunk *magic_loadsound(char *file)
|
|||
|
||||
// Affect the canvas on click:
|
||||
void alien_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_PAINT)
|
||||
alien_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -296,8 +277,7 @@ void alien_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -317,14 +297,15 @@ void alien_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void alien_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void alien_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int alien_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int alien_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -340,20 +321,19 @@ Uint8 alien_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
}
|
||||
|
||||
void alien_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED) {
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
alien_RADIUS = size * 4;
|
||||
}
|
||||
|
||||
void alien_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void alien_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,24 +65,20 @@ int blind_get_group(magic_api * api, int which);
|
|||
char *blind_get_description(magic_api * api, int which, int mode);
|
||||
int blind_requires_colors(magic_api * api, int which);
|
||||
void blind_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void blind_shutdown(magic_api * api);
|
||||
void blind_paint_blind(void *ptr_to_api, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void blind_paint_blind(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void blind_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void blind_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blind_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blind_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void blind_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int blind_modes(magic_api * api, int which);
|
||||
Uint8 blind_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 blind_default_size(magic_api * api, int which, int mode);
|
||||
void blind_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void blind_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
|
|
@ -91,8 +87,9 @@ Uint32 blind_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void blind_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 blind_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)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
blind_r = r;
|
||||
|
|
@ -104,8 +101,7 @@ int blind_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/blind.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/blind.ogg", api->data_directory);
|
||||
blind_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -120,35 +116,29 @@ SDL_Surface *blind_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/blind.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/blind.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *blind_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *blind_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Blind"));
|
||||
}
|
||||
|
||||
int blind_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int blind_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_DECORATIONS;
|
||||
}
|
||||
|
||||
char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click towards the edge of your picture to pull window blinds over it. Move perpendicularly to open or close the blinds."));
|
||||
}
|
||||
|
||||
int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -157,8 +147,7 @@ void blind_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -170,15 +159,13 @@ void blind_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
// Interactivity functions
|
||||
|
||||
void blind_paint_blind(void *ptr_to_api, int which_tool ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr_to_api;
|
||||
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, (blind_r + blind_light) / 2,
|
||||
(blind_g + blind_light) / 2,
|
||||
(blind_b + blind_light) / 2));
|
||||
(blind_g + blind_light) / 2, (blind_b + blind_light) / 2));
|
||||
}
|
||||
|
||||
/* void blind_do_blind(void * ptr_to_api, int which_tool,
|
||||
|
|
@ -192,8 +179,7 @@ void blind_paint_blind(void *ptr_to_api, int which_tool ATTRIBUTE_UNUSED,
|
|||
|
||||
*/
|
||||
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int opaque;
|
||||
|
||||
|
|
@ -209,14 +195,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
blind_light = 255;
|
||||
for (j = i; j > i - opaque / 2; j--)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind);
|
||||
blind_light -= 20;
|
||||
}
|
||||
for (j = i - opaque / 2; j > i - opaque; j--)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind);
|
||||
blind_light += 20;
|
||||
}
|
||||
}
|
||||
|
|
@ -234,14 +218,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
blind_light = 255;
|
||||
for (j = i; j < i + opaque / 2; j++)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind);
|
||||
blind_light -= 20;
|
||||
}
|
||||
for (j = i + opaque / 2; j < i + opaque; j++)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, 0, j, canvas->w, j, 1, blind_paint_blind);
|
||||
blind_light += 20;
|
||||
}
|
||||
}
|
||||
|
|
@ -260,14 +242,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
blind_light = 255;
|
||||
for (j = i; j < i + opaque / 2; j++)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind);
|
||||
blind_light -= 20;
|
||||
}
|
||||
for (j = i + opaque / 2; j < i + opaque; j++)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind);
|
||||
blind_light += 20;
|
||||
}
|
||||
}
|
||||
|
|
@ -286,14 +266,12 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
blind_light = 255;
|
||||
for (j = i; j > i - opaque / 2; j--)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind);
|
||||
blind_light -= 20;
|
||||
}
|
||||
for (j = i - opaque / 2; j > i - opaque; j--)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1,
|
||||
blind_paint_blind);
|
||||
api->line(api, which, canvas, snapshot, j, 0, j, canvas->h, 1, blind_paint_blind);
|
||||
blind_light += 20;
|
||||
}
|
||||
}
|
||||
|
|
@ -308,8 +286,7 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void blind_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)
|
||||
{
|
||||
if (y < canvas->h / 2)
|
||||
|
||||
|
|
@ -335,15 +312,13 @@ void blind_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void blind_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void blind_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -363,6 +338,8 @@ Uint8 blind_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void blind_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 blind_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,30 +59,24 @@ SDL_Surface *blocks_etc_get_icon(magic_api * api, int which);
|
|||
char *blocks_etc_get_name(magic_api * api, int which);
|
||||
int blocks_etc_get_group(magic_api * api, int which);
|
||||
char *blocks_etc_get_description(magic_api * api, int which, int mode);
|
||||
static void blocks_etc_linecb(void *ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y);
|
||||
static void blocks_etc_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void blocks_etc_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 blocks_etc_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 blocks_etc_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 blocks_etc_shutdown(magic_api * api);
|
||||
void blocks_etc_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int blocks_etc_requires_colors(magic_api * api, int which);
|
||||
void blocks_etc_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blocks_etc_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blocks_etc_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void blocks_etc_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int blocks_etc_modes(magic_api * api, int which);
|
||||
Uint8 blocks_etc_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 blocks_etc_default_size(magic_api * api, int which, int mode);
|
||||
void blocks_etc_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void blocks_etc_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -90,16 +84,13 @@ int blocks_etc_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/blocks.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/blocks.wav", api->data_directory);
|
||||
snd_effect[0] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/chalk.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/chalk.wav", api->data_directory);
|
||||
snd_effect[1] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/drip.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/drip.wav", api->data_directory);
|
||||
snd_effect[2] = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -124,18 +115,15 @@ SDL_Surface *blocks_etc_get_icon(magic_api * api, int which)
|
|||
|
||||
if (which == TOOL_BLOCKS)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/blocks.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/blocks.png", api->data_directory);
|
||||
}
|
||||
else if (which == TOOL_CHALK)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/chalk.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/chalk.png", api->data_directory);
|
||||
}
|
||||
else if (which == TOOL_DRIP)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/drip.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/drip.png", api->data_directory);
|
||||
}
|
||||
|
||||
return (IMG_Load(fname));
|
||||
|
|
@ -155,52 +143,41 @@ char *blocks_etc_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (all the same):
|
||||
int blocks_etc_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int blocks_etc_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode)
|
||||
char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
if (which == TOOL_BLOCKS)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to make the picture blocky.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to make the picture blocky.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop("Click to make the entire picture blocky.")));
|
||||
return (strdup(gettext_noop("Click to make the entire picture blocky.")));
|
||||
}
|
||||
}
|
||||
else if (which == TOOL_CHALK)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to turn the picture into a chalk drawing.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to turn the picture into a chalk drawing.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click to turn the entire picture into a chalk drawing.")));
|
||||
return (strdup(gettext_noop("Click to turn the entire picture into a chalk drawing.")));
|
||||
}
|
||||
}
|
||||
else if (which == TOOL_DRIP)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to make the picture drip.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to make the picture drip.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -213,9 +190,7 @@ char *blocks_etc_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
// Do the effect:
|
||||
|
||||
static void blocks_etc_linecb(void *ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y)
|
||||
static void blocks_etc_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy;
|
||||
|
|
@ -233,11 +208,9 @@ static void blocks_etc_linecb(void *ptr, int which,
|
|||
|
||||
if (!api->touched(x, y))
|
||||
{
|
||||
for (yy = y - (EFFECT_REZ * 2); yy < y + (EFFECT_REZ * 2);
|
||||
yy = yy + EFFECT_REZ)
|
||||
for (yy = y - (EFFECT_REZ * 2); yy < y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ)
|
||||
{
|
||||
for (xx = x - (EFFECT_REZ * 2); xx < x + (EFFECT_REZ * 2);
|
||||
xx = xx + EFFECT_REZ)
|
||||
for (xx = x - (EFFECT_REZ * 2); xx < x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ)
|
||||
{
|
||||
Uint32 pix[(EFFECT_REZ * EFFECT_REZ)];
|
||||
Uint32 p_or = 0;
|
||||
|
|
@ -271,12 +244,9 @@ static void blocks_etc_linecb(void *ptr, int which,
|
|||
g_sum += api->sRGB_to_linear(g);
|
||||
b_sum += api->sRGB_to_linear(b);
|
||||
}
|
||||
r =
|
||||
api->linear_to_sRGB(r_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
g =
|
||||
api->linear_to_sRGB(g_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
b =
|
||||
api->linear_to_sRGB(b_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
r = api->linear_to_sRGB(r_sum / (float)(EFFECT_REZ * EFFECT_REZ));
|
||||
g = api->linear_to_sRGB(g_sum / (float)(EFFECT_REZ * EFFECT_REZ));
|
||||
b = api->linear_to_sRGB(b_sum / (float)(EFFECT_REZ * EFFECT_REZ));
|
||||
}
|
||||
|
||||
/* Draw block: */
|
||||
|
|
@ -293,20 +263,16 @@ static void blocks_etc_linecb(void *ptr, int which,
|
|||
}
|
||||
else if (which == TOOL_CHALK)
|
||||
{
|
||||
for (yy = y - (EFFECT_REZ * 2); yy <= y + (EFFECT_REZ * 2);
|
||||
yy = yy + EFFECT_REZ)
|
||||
for (yy = y - (EFFECT_REZ * 2); yy <= y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ)
|
||||
{
|
||||
for (xx = x - (EFFECT_REZ * 2); xx <= x + (EFFECT_REZ * 2);
|
||||
xx = xx + EFFECT_REZ)
|
||||
for (xx = x - (EFFECT_REZ * 2); xx <= x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ)
|
||||
{
|
||||
dest.x = xx + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2));
|
||||
dest.y = yy + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2));
|
||||
dest.w = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2);
|
||||
dest.h = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2);
|
||||
|
||||
colr =
|
||||
api->getpixel(last, clamp(0, xx, canvas->w - 1),
|
||||
clamp(0, yy, canvas->h - 1));
|
||||
colr = api->getpixel(last, clamp(0, xx, canvas->w - 1), clamp(0, yy, canvas->h - 1));
|
||||
SDL_FillRect(canvas, &dest, colr);
|
||||
}
|
||||
}
|
||||
|
|
@ -335,11 +301,9 @@ static void blocks_etc_linecb(void *ptr, int which,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void blocks_etc_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,
|
||||
blocks_etc_linecb);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, blocks_etc_linecb);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -366,8 +330,7 @@ void blocks_etc_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void blocks_etc_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_PAINT)
|
||||
{
|
||||
|
|
@ -393,6 +356,7 @@ void blocks_etc_click(magic_api * api, int which, int mode,
|
|||
{
|
||||
/* Drip (works from bottom-to-top) */
|
||||
int p = (canvas->h - 1) % 10;
|
||||
|
||||
for (y = canvas->h - 1; y >= 0; y -= EFFECT_REZ)
|
||||
{
|
||||
if ((y + p) % 10 == 0)
|
||||
|
|
@ -416,11 +380,10 @@ void blocks_etc_click(magic_api * api, int which, int mode,
|
|||
|
||||
// Affect the canvas on release:
|
||||
void blocks_etc_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 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -435,29 +398,26 @@ void blocks_etc_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void blocks_etc_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void blocks_etc_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int blocks_etc_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int blocks_etc_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void blocks_etc_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void blocks_etc_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -480,7 +440,9 @@ Uint8 blocks_etc_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB
|
|||
return 2;
|
||||
}
|
||||
|
||||
void blocks_etc_set_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void blocks_etc_set_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == TOOL_BLOCKS)
|
||||
EFFECT_REZ = size * 4;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ float sample_weights[NUM_SAMPLE_WEIGHTS] = {
|
|||
0.0449, 0.0627, 0.0752, 0.0842, 0.0904, 0.0940, 0.0952, 0.0940, 0.0904, 0.0842, 0.0752, 0.0627, 0.0449
|
||||
};
|
||||
|
||||
Mix_Chunk * snd_effects = NULL;
|
||||
Uint8 * bloom_mask = NULL;
|
||||
Mix_Chunk *snd_effects = NULL;
|
||||
Uint8 *bloom_mask = NULL;
|
||||
int bloom_scale;
|
||||
|
||||
Uint32 bloom_api_version(void);
|
||||
|
|
@ -52,30 +52,23 @@ int bloom_requires_colors(magic_api * api, int which);
|
|||
int bloom_modes(magic_api * api, int which);
|
||||
void bloom_shutdown(magic_api * api);
|
||||
void bloom_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void bloom_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void bloom_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void bloom_line_callback_drag(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void bloom_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void bloom_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void bloom_apply_effect(magic_api * api,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot);
|
||||
void bloom_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void bloom_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void bloom_apply_effect(magic_api * api, SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void bloom_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void bloom_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
float luminance(float r, float g, float b);
|
||||
float change_luminance(float c_in, float l_in, float l_out);
|
||||
Uint8 bloom_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 bloom_default_size(magic_api * api, int which, int mode);
|
||||
void bloom_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void bloom_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 bloom_api_version(void)
|
||||
|
|
@ -87,8 +80,7 @@ int bloom_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/bloom.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/bloom.ogg", api->data_directory);
|
||||
snd_effects = Mix_LoadWAV(fname);
|
||||
|
||||
bloom_scale = sqrt(2 * (BLOOM_PAINT_RADIUS * BLOOM_PAINT_RADIUS));
|
||||
|
|
@ -105,54 +97,53 @@ SDL_Surface *bloom_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/bloom.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/bloom.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *bloom_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *bloom_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext("Bloom"));
|
||||
}
|
||||
|
||||
int bloom_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED)
|
||||
int bloom_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
char *bloom_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *bloom_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT) {
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
return strdup(gettext("Click and drag to apply a glowing \"bloom\" effect to parts of your image."));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return strdup(gettext("Click to apply a glowing \"bloom\" effect to your entire image."));
|
||||
}
|
||||
}
|
||||
|
||||
int bloom_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int bloom_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0; /* TODO: Maybe some day? */
|
||||
return 0; /* TODO: Maybe some day? */
|
||||
}
|
||||
|
||||
int bloom_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED)
|
||||
int bloom_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
void bloom_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (snd_effects != NULL) {
|
||||
if (snd_effects != NULL)
|
||||
{
|
||||
Mix_FreeChunk(snd_effects);
|
||||
snd_effects = NULL;
|
||||
}
|
||||
|
||||
if (bloom_mask != NULL) {
|
||||
if (bloom_mask != NULL)
|
||||
{
|
||||
free(bloom_mask);
|
||||
bloom_mask = NULL;
|
||||
}
|
||||
|
|
@ -160,8 +151,7 @@ void bloom_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
bloom_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (bloom_mask == NULL)
|
||||
return;
|
||||
|
|
@ -169,11 +159,15 @@ bloom_click(magic_api * api, int which, int mode,
|
|||
if (snd_effects != NULL)
|
||||
api->stopsound();
|
||||
|
||||
if (mode == MODE_PAINT) {
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
memset(bloom_mask, 0, (canvas->w * canvas->h));
|
||||
bloom_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
} else {
|
||||
if (snd_effects != NULL) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snd_effects != NULL)
|
||||
{
|
||||
api->playsound(snd_effects, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
|
|
@ -190,12 +184,12 @@ bloom_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
bloom_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (bloom_mask == NULL)
|
||||
return;
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */,
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */ ,
|
||||
bloom_line_callback_drag);
|
||||
|
||||
/* FIXME: Would be good to only update the area around the line (ox,oy)->(x,y) (+/- the maxium radius of the effect) */
|
||||
|
|
@ -207,10 +201,9 @@ bloom_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Sur
|
|||
|
||||
|
||||
void bloom_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect) {
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
if (bloom_mask == NULL)
|
||||
return;
|
||||
|
||||
|
|
@ -225,9 +218,8 @@ void bloom_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
update_rect->h = canvas->h;
|
||||
}
|
||||
|
||||
void bloom_apply_effect(magic_api * api,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot) {
|
||||
void bloom_apply_effect(magic_api * api, SDL_Surface * canvas, SDL_Surface * snapshot)
|
||||
{
|
||||
int sample, offset, offset_flip, x, y, xx, yy;
|
||||
Uint8 r, g, b;
|
||||
float rf, gf, bf, mask_weight, lum;
|
||||
|
|
@ -236,19 +228,24 @@ void bloom_apply_effect(magic_api * api,
|
|||
|
||||
SDL_BlitSurface(snapshot, NULL, canvas, NULL);
|
||||
|
||||
for (y = 0; y < canvas->h; y++) {
|
||||
if (y % 10 == 0) {
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
if (y % 10 == 0)
|
||||
{
|
||||
api->update_progress_bar();
|
||||
}
|
||||
|
||||
for (x = 0; x < canvas->w; x++) {
|
||||
if (bloom_mask[y * canvas->w + x] > 0) {
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
if (bloom_mask[y * canvas->w + x] > 0)
|
||||
{
|
||||
sums[0] = 0.0;
|
||||
sums[1] = 0.0;
|
||||
sums[2] = 0.0;
|
||||
|
||||
/* (Pull from snapshot) */
|
||||
for (sample = 0; sample < NUM_SAMPLE_WEIGHTS; sample++) {
|
||||
for (sample = 0; sample < NUM_SAMPLE_WEIGHTS; sample++)
|
||||
{
|
||||
/* Horizontal samples */
|
||||
color = api->getpixel(snapshot, x - ((NUM_SAMPLE_WEIGHTS - 1) / 2) + sample, y);
|
||||
SDL_GetRGB(color, snapshot->format, &r, &g, &b);
|
||||
|
|
@ -265,29 +262,34 @@ void bloom_apply_effect(magic_api * api,
|
|||
}
|
||||
|
||||
/* (Blend an "X" shape, additively, onto target canvas) */
|
||||
for (offset = -BLOOM_SPIKE_LENGTH; offset <= BLOOM_SPIKE_LENGTH; offset++) {
|
||||
for (offset_flip = -1; offset <= 1; offset += 2) {
|
||||
for (offset = -BLOOM_SPIKE_LENGTH; offset <= BLOOM_SPIKE_LENGTH; offset++)
|
||||
{
|
||||
for (offset_flip = -1; offset <= 1; offset += 2)
|
||||
{
|
||||
xx = x + offset;
|
||||
yy = y + (offset * offset_flip);
|
||||
|
||||
if (xx >= 0 && xx < canvas->w && yy >= 0 && yy < canvas->h) {
|
||||
if (xx >= 0 && xx < canvas->w && yy >= 0 && yy < canvas->h)
|
||||
{
|
||||
color = api->getpixel(snapshot, xx, yy);
|
||||
SDL_GetRGB(color, snapshot->format, &r, &g, &b);
|
||||
|
||||
mask_weight = (float) (bloom_mask[(yy) * canvas->w + xx] / 255.0);
|
||||
mask_weight = (float)(bloom_mask[(yy) * canvas->w + xx] / 255.0);
|
||||
mask_weight *= BLOOM_WEIGHT_CONST;
|
||||
mask_weight *= ((BLOOM_SPIKE_LENGTH + 1) - (abs(offset)) / BLOOM_SPIKE_LENGTH);
|
||||
|
||||
rf = (((float) r) + (sums[0] * mask_weight)) / 255.0;
|
||||
gf = (((float) g) + (sums[1] * mask_weight)) / 255.0;
|
||||
bf = (((float) b) + (sums[2] * mask_weight)) / 255.0;
|
||||
rf = (((float)r) + (sums[0] * mask_weight)) / 255.0;
|
||||
gf = (((float)g) + (sums[1] * mask_weight)) / 255.0;
|
||||
bf = (((float)b) + (sums[2] * mask_weight)) / 255.0;
|
||||
|
||||
/* Reinhard Tonemap (Luminence) */
|
||||
lum = luminance(rf, gf, bf);
|
||||
|
||||
if (lum > 0.0) {
|
||||
if (lum > 0.0)
|
||||
{
|
||||
float numerator = lum * (1.0f + lum);
|
||||
float l_new = numerator / (1.0f + lum);
|
||||
|
||||
rf = change_luminance(rf, lum, l_new);
|
||||
gf = change_luminance(gf, lum, l_new);
|
||||
bf = change_luminance(bf, lum, l_new);
|
||||
|
|
@ -316,19 +318,17 @@ void bloom_apply_effect(magic_api * api,
|
|||
|
||||
|
||||
void bloom_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* TODO: Maybe some day? */
|
||||
}
|
||||
|
||||
|
||||
void bloom_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
int xrad, yrad, xx, yy, chg, n;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -336,18 +336,24 @@ void bloom_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
if (snd_effects != NULL)
|
||||
api->playsound(snd_effects, (x * 255) / canvas->w, 255);
|
||||
|
||||
for (yrad = -BLOOM_PAINT_RADIUS; yrad < BLOOM_PAINT_RADIUS; yrad++) {
|
||||
for (yrad = -BLOOM_PAINT_RADIUS; yrad < BLOOM_PAINT_RADIUS; yrad++)
|
||||
{
|
||||
yy = y + yrad;
|
||||
if (yy >= 0 && yy < canvas->h) {
|
||||
for (xrad = -BLOOM_PAINT_RADIUS; xrad < BLOOM_PAINT_RADIUS; xrad++) {
|
||||
if (yy >= 0 && yy < canvas->h)
|
||||
{
|
||||
for (xrad = -BLOOM_PAINT_RADIUS; xrad < BLOOM_PAINT_RADIUS; xrad++)
|
||||
{
|
||||
xx = x + xrad;
|
||||
if (xx >= 0 && xx < canvas->w) {
|
||||
if (api->in_circle(xrad, yrad, BLOOM_PAINT_RADIUS)) {
|
||||
if (xx >= 0 && xx < canvas->w)
|
||||
{
|
||||
if (api->in_circle(xrad, yrad, BLOOM_PAINT_RADIUS))
|
||||
{
|
||||
/* Add to the bloom mask */
|
||||
n = (int) bloom_mask[yy * canvas->w + xx];
|
||||
n = (int)bloom_mask[yy * canvas->w + xx];
|
||||
chg = sqrt(bloom_scale - sqrt((xrad * xrad) + (yrad * yrad)));
|
||||
n += chg;
|
||||
if (n > 255) {
|
||||
if (n > 255)
|
||||
{
|
||||
n = 255;
|
||||
}
|
||||
bloom_mask[yy * canvas->w + xx] = (Uint8) n;
|
||||
|
|
@ -363,29 +369,29 @@ void bloom_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
|
||||
void bloom_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, int mode,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED, int mode, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (bloom_mask == NULL)
|
||||
bloom_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas-> w * canvas->h);
|
||||
bloom_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
|
||||
if (mode == MODE_FULLSCREEN)
|
||||
bloom_set_size(api, which, mode, NULL, NULL, bloom_default_size(api, which, mode), NULL);
|
||||
}
|
||||
|
||||
void bloom_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
float luminance(float r, float g, float b) {
|
||||
float luminance(float r, float g, float b)
|
||||
{
|
||||
return (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
||||
}
|
||||
|
||||
float change_luminance(float c_in, float l_in, float l_out) {
|
||||
return c_in * (l_out / l_in);
|
||||
float change_luminance(float c_in, float l_in, float l_out)
|
||||
{
|
||||
return c_in * (l_out / l_in);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -402,7 +408,9 @@ Uint8 bloom_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 2;
|
||||
}
|
||||
|
||||
void bloom_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void bloom_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
BLOOM_PAINT_RADIUS = size * 12;
|
||||
BLOOM_SPIKE_LENGTH = sqrt(BLOOM_PAINT_RADIUS + 1);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,7 @@ char *blur_get_name(magic_api * api, int which);
|
|||
int blur_get_group(magic_api * api, int which);
|
||||
char *blur_get_description(magic_api * api, int which, int mode);
|
||||
void blur_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 blur_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void blur_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -60,10 +59,8 @@ void blur_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
|||
int blur_requires_colors(magic_api * api, int which);
|
||||
Uint8 blur_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 blur_default_size(magic_api * api, int which, int mode);
|
||||
void blur_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blur_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void blur_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void blur_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int blur_modes(magic_api * api, int which);
|
||||
|
||||
enum
|
||||
|
|
@ -110,8 +107,7 @@ int blur_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < blur_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
blur_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, blur_snd_filenames[i]);
|
||||
blur_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -127,8 +123,7 @@ SDL_Surface *blur_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
blur_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, blur_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -145,16 +140,13 @@ int blur_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *blur_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *blur_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(blur_descs[which][mode - 1])));
|
||||
}
|
||||
|
||||
//Do the effect for one pixel
|
||||
static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x,
|
||||
int y)
|
||||
static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int i, j, k;
|
||||
|
|
@ -179,8 +171,7 @@ static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
for (j = -2; j < 3; j++)
|
||||
{
|
||||
//Add the pixels around the current one wieghted
|
||||
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0],
|
||||
&temp[1], &temp[2]);
|
||||
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], &temp[1], &temp[2]);
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
blurValue[k] += temp[k] * weight[i + 2][j + 2];
|
||||
|
|
@ -191,14 +182,11 @@ static void do_blur_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
blurValue[k] /= 273;
|
||||
}
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, blurValue[0], blurValue[1],
|
||||
blurValue[2]));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], blurValue[2]));
|
||||
}
|
||||
|
||||
// Do the effect for the full image
|
||||
static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which)
|
||||
static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int x, y;
|
||||
|
|
@ -218,8 +206,7 @@ static void do_blur_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
|||
}
|
||||
|
||||
//do the effect for the brush
|
||||
static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -228,8 +215,7 @@ static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
for (xx = x - blur_RADIUS; xx < x + blur_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, blur_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, blur_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_blur_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
|
|
@ -239,12 +225,10 @@ static void do_blur_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void blur_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_blur_brush);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_blur_brush);
|
||||
|
||||
api->playsound(blur_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -271,8 +255,7 @@ void blur_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void blur_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_PAINT)
|
||||
blur_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -292,8 +275,7 @@ void blur_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 y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -314,45 +296,46 @@ void blur_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void blur_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Record the size from Tux Paint:
|
||||
void blur_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 sz, SDL_Rect * update_rect ATTRIBUTE_UNUSED) {
|
||||
Uint8 sz, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
blur_RADIUS = sz * 4;
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int blur_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int blur_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Uint8 blur_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) {
|
||||
Uint8 blur_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return 8;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Uint8 blur_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) {
|
||||
Uint8 blur_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
void blur_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void blur_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ static int brick_size = TOOL_LARGEBRICKS;
|
|||
|
||||
/* Local function prototype: */
|
||||
|
||||
static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y,
|
||||
int w, int h);
|
||||
static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, int w, int h);
|
||||
int bricks_init(magic_api * api, Uint32 disabled_features);
|
||||
Uint32 bricks_api_version(void);
|
||||
int bricks_get_tool_count(magic_api * api);
|
||||
|
|
@ -65,8 +64,7 @@ char *bricks_get_name(magic_api * api, int which);
|
|||
int bricks_get_group(magic_api * api, int which);
|
||||
char *bricks_get_description(magic_api * api, int which, int mode);
|
||||
void bricks_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 bricks_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void bricks_release(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); //An empty function. Is there a purpose to this? Ask moderator.
|
||||
|
|
@ -74,22 +72,20 @@ void bricks_shutdown(magic_api * api);
|
|||
void bricks_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int bricks_requires_colors(magic_api * api, int which);
|
||||
void bricks_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void bricks_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void bricks_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void bricks_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int bricks_modes(magic_api * api, int which);
|
||||
Uint8 bricks_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 bricks_default_size(magic_api * api, int which, int mode);
|
||||
void bricks_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void bricks_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// No setup required:
|
||||
int bricks_init(magic_api * api, Uint32 disabled_features)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/brick.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/brick.wav", api->data_directory);
|
||||
brick_snd = Mix_LoadWAV(fname);
|
||||
|
||||
if (disabled_features & MAGIC_FEATURE_SIZE)
|
||||
|
|
@ -121,21 +117,18 @@ SDL_Surface *bricks_get_icon(magic_api * api, int which)
|
|||
|
||||
if (which == TOOL_LARGEBRICKS)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/largebrick.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/largebrick.png", api->data_directory);
|
||||
}
|
||||
else if (which == TOOL_SMALLBRICKS)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/smallbrick.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/smallbrick.png", api->data_directory);
|
||||
}
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
/* Both are named "Bricks", at the moment: */
|
||||
|
||||
|
|
@ -143,22 +136,23 @@ char *bricks_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int bricks_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int bricks_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (brick_two_tools) {
|
||||
if (brick_two_tools)
|
||||
{
|
||||
if (which == TOOL_LARGEBRICKS)
|
||||
return (strdup(gettext_noop("Click and drag to draw large bricks.")));
|
||||
else if (which == TOOL_SMALLBRICKS)
|
||||
return (strdup(gettext_noop("Click and drag to draw small bricks.")));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return (strdup(gettext_noop("Click and drag to draw bricks.")));
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +161,7 @@ char *bricks_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
|
||||
// Do the effect:
|
||||
|
||||
static void do_bricks(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
static void do_bricks(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -215,8 +208,7 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
mybrick = map + brick_x + 1 + (brick_y + 1) * x_count;
|
||||
|
||||
if ((unsigned) x < (unsigned) canvas->w
|
||||
&& (unsigned) y < (unsigned) canvas->h && !*mybrick)
|
||||
if ((unsigned)x < (unsigned)canvas->w && (unsigned)y < (unsigned)canvas->h && !*mybrick)
|
||||
{
|
||||
int my_x = brick_x * nominal_width;
|
||||
int my_w = specified_width;
|
||||
|
|
@ -237,8 +229,7 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas,
|
|||
my_x -= nominal_width;
|
||||
my_w = specified_length;
|
||||
}
|
||||
do_brick(api, canvas, my_x, brick_y * nominal_height, my_w,
|
||||
specified_height);
|
||||
do_brick(api, canvas, my_x, brick_y * nominal_height, my_w, specified_height);
|
||||
|
||||
|
||||
// FIXME:
|
||||
|
|
@ -258,10 +249,9 @@ static void do_bricks(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void bricks_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_bricks);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_bricks);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -290,8 +280,7 @@ void bricks_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void bricks_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)
|
||||
{
|
||||
bricks_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -300,8 +289,7 @@ void bricks_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -313,8 +301,9 @@ void bricks_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void bricks_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 bricks_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)
|
||||
{
|
||||
bricks_r = r;
|
||||
bricks_g = g;
|
||||
|
|
@ -322,29 +311,21 @@ void bricks_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int bricks_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int bricks_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y,
|
||||
int w, int h)
|
||||
static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y, int w, int h)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
// brick color: 127,76,73
|
||||
double ran_r = rand() / (double) RAND_MAX;
|
||||
double ran_g = rand() / (double) RAND_MAX;
|
||||
double base_r =
|
||||
api->sRGB_to_linear(bricks_r) * 1.5 + api->sRGB_to_linear(127) * 5.0 +
|
||||
ran_r;
|
||||
double base_g =
|
||||
api->sRGB_to_linear(bricks_g) * 1.5 + api->sRGB_to_linear(76) * 5.0 +
|
||||
ran_g;
|
||||
double base_b =
|
||||
api->sRGB_to_linear(bricks_b) * 1.5 + api->sRGB_to_linear(73) * 5.0 +
|
||||
(ran_r + ran_g * 2.0) / 3.0;
|
||||
double ran_r = rand() / (double)RAND_MAX;
|
||||
double ran_g = rand() / (double)RAND_MAX;
|
||||
double base_r = api->sRGB_to_linear(bricks_r) * 1.5 + api->sRGB_to_linear(127) * 5.0 + ran_r;
|
||||
double base_g = api->sRGB_to_linear(bricks_g) * 1.5 + api->sRGB_to_linear(76) * 5.0 + ran_g;
|
||||
double base_b = api->sRGB_to_linear(bricks_b) * 1.5 + api->sRGB_to_linear(73) * 5.0 + (ran_r + ran_g * 2.0) / 3.0;
|
||||
|
||||
Uint8 r = api->linear_to_sRGB(base_r / 7.5);
|
||||
Uint8 g = api->linear_to_sRGB(base_g / 7.5);
|
||||
|
|
@ -365,14 +346,12 @@ static void do_brick(magic_api * api, SDL_Surface * canvas, int x, int y,
|
|||
}
|
||||
|
||||
void bricks_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void bricks_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -392,10 +371,16 @@ Uint8 bricks_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 2;
|
||||
}
|
||||
|
||||
void bricks_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED) {
|
||||
if (size == 1) {
|
||||
void bricks_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (size == 1)
|
||||
{
|
||||
brick_size = TOOL_SMALLBRICKS;
|
||||
} else { // 2
|
||||
}
|
||||
else
|
||||
{ // 2
|
||||
brick_size = TOOL_LARGEBRICKS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ static SDL_Surface *calligraphy_brush, *calligraphy_colored_brush;
|
|||
|
||||
/* Local Function Prototypes */
|
||||
static Point2D calligraphy_PointOnCubicBezier(Point2D * cp, float t);
|
||||
static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve);
|
||||
static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve);
|
||||
static float calligraphy_dist(float x1, float y1, float x2, float y2);
|
||||
int calligraphy_init(magic_api * api, Uint32 disabled_features);
|
||||
Uint32 calligraphy_api_version(void);
|
||||
|
|
@ -60,26 +59,22 @@ char *calligraphy_get_name(magic_api * api, int which);
|
|||
int calligraphy_get_group(magic_api * api, int which);
|
||||
char *calligraphy_get_description(magic_api * api, int which, int mode);
|
||||
void calligraphy_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 calligraphy_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 calligraphy_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void calligraphy_shutdown(magic_api * api);
|
||||
void calligraphy_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int calligraphy_requires_colors(magic_api * api, int which);
|
||||
void calligraphy_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void calligraphy_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void calligraphy_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void calligraphy_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int calligraphy_modes(magic_api * api, int which);
|
||||
Uint8 calligraphy_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 calligraphy_default_size(magic_api * api, int which, int mode);
|
||||
void calligraphy_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void calligraphy_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -87,13 +82,11 @@ int calligraphy_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/calligraphy.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/calligraphy.ogg", api->data_directory);
|
||||
|
||||
calligraphy_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/calligraphy_brush.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/calligraphy_brush.png", api->data_directory);
|
||||
|
||||
calligraphy_brush = IMG_Load(fname);
|
||||
calligraphy_colored_brush = NULL;
|
||||
|
|
@ -127,40 +120,33 @@ SDL_Surface *calligraphy_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/calligraphy.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/calligraphy.png", api->data_directory);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our name, localized:
|
||||
char *calligraphy_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *calligraphy_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Calligraphy")));
|
||||
}
|
||||
|
||||
// Return our group
|
||||
int calligraphy_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int calligraphy_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our description, localized:
|
||||
char *calligraphy_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to draw in calligraphy.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to draw in calligraphy.")));
|
||||
}
|
||||
|
||||
|
||||
void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
Point2D *curve;
|
||||
int i, n_points, thick, new_thick;
|
||||
|
|
@ -200,9 +186,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
calligraphy_control_points[2].x,
|
||||
calligraphy_control_points[2].y) +
|
||||
calligraphy_dist(calligraphy_control_points[2].x,
|
||||
calligraphy_control_points[2].y,
|
||||
calligraphy_control_points[3].x,
|
||||
calligraphy_control_points[3].y);
|
||||
calligraphy_control_points[2].y, calligraphy_control_points[3].x, calligraphy_control_points[3].y);
|
||||
|
||||
if (n_points == 0)
|
||||
return; // No-op; not any points to plot
|
||||
|
|
@ -216,8 +200,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
for (i = 0; i < n_points - 1; i++)
|
||||
{
|
||||
thick =
|
||||
((new_thick * i) + (calligraphy_old_thick * (n_points - i))) / n_points;
|
||||
thick = ((new_thick * i) + (calligraphy_old_thick * (n_points - i))) / n_points;
|
||||
|
||||
|
||||
/* The new way, using an antialiased brush bitmap */
|
||||
|
|
@ -286,8 +269,7 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
void calligraphy_click(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
calligraphy_old_thick = 8;
|
||||
calligraphy_last_time = 0;
|
||||
|
|
@ -307,8 +289,7 @@ void calligraphy_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +306,8 @@ void calligraphy_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// We don't use colors
|
||||
void calligraphy_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int x, y;
|
||||
Uint8 a;
|
||||
|
|
@ -341,9 +323,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf
|
|||
if (calligraphy_colored_brush != NULL)
|
||||
SDL_FreeSurface(calligraphy_colored_brush);
|
||||
|
||||
amask =
|
||||
~(calligraphy_brush->format->Rmask | calligraphy_brush->format->
|
||||
Gmask | calligraphy_brush->format->Bmask);
|
||||
amask = ~(calligraphy_brush->format->Rmask | calligraphy_brush->format->Gmask | calligraphy_brush->format->Bmask);
|
||||
|
||||
calligraphy_colored_brush =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
|
|
@ -351,8 +331,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf
|
|||
calligraphy_brush->h,
|
||||
calligraphy_brush->format->BitsPerPixel,
|
||||
calligraphy_brush->format->Rmask,
|
||||
calligraphy_brush->format->Gmask,
|
||||
calligraphy_brush->format->Bmask, amask);
|
||||
calligraphy_brush->format->Gmask, calligraphy_brush->format->Bmask, amask);
|
||||
|
||||
if (calligraphy_colored_brush == NULL)
|
||||
return; // FIXME: Error!
|
||||
|
|
@ -365,13 +344,10 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf
|
|||
{
|
||||
for (x = 0; x < calligraphy_brush->w; x++)
|
||||
{
|
||||
SDL_GetRGBA(api->getpixel(calligraphy_brush, x, y),
|
||||
calligraphy_brush->format, &r, &g, &b, &a);
|
||||
SDL_GetRGBA(api->getpixel(calligraphy_brush, x, y), calligraphy_brush->format, &r, &g, &b, &a);
|
||||
|
||||
api->putpixel(calligraphy_colored_brush, x, y,
|
||||
SDL_MapRGBA(calligraphy_colored_brush->format,
|
||||
calligraphy_r, calligraphy_g, calligraphy_b,
|
||||
a));
|
||||
SDL_MapRGBA(calligraphy_colored_brush->format, calligraphy_r, calligraphy_g, calligraphy_b, a));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -380,8 +356,7 @@ void calligraphy_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf
|
|||
}
|
||||
|
||||
// We don't use colors
|
||||
int calligraphy_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int calligraphy_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -436,8 +411,7 @@ static Point2D calligraphy_PointOnCubicBezier(Point2D * cp, float t)
|
|||
<sizeof(Point2D) numberOfPoints>
|
||||
*/
|
||||
|
||||
static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve)
|
||||
static void calligraphy_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve)
|
||||
{
|
||||
float dt;
|
||||
int i;
|
||||
|
|
@ -458,27 +432,23 @@ static float calligraphy_dist(float x1, float y1, float x2, float y2)
|
|||
}
|
||||
|
||||
void calligraphy_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void calligraphy_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int calligraphy_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int calligraphy_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
||||
|
||||
Uint8 calligraphy_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 calligraphy_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -488,6 +458,8 @@ Uint8 calligraphy_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
void calligraphy_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 calligraphy_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,31 +51,26 @@ SDL_Surface *cartoon_get_icon(magic_api * api, int which);
|
|||
char *cartoon_get_name(magic_api * api, int which);
|
||||
int cartoon_get_group(magic_api * api, int which);
|
||||
char *cartoon_get_description(magic_api * api, int which, int mode);
|
||||
void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx,
|
||||
int yy);
|
||||
void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx, int yy);
|
||||
void cartoon_apply_outline(magic_api * api, int xx, int yy);
|
||||
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);
|
||||
void cartoon_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void cartoon_shutdown(magic_api * api);
|
||||
void cartoon_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int cartoon_requires_colors(magic_api * api, int which);
|
||||
void cartoon_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void cartoon_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void cartoon_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void cartoon_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int cartoon_modes(magic_api * api, int which);
|
||||
Uint8 cartoon_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 cartoon_default_size(magic_api * api, int which, int mode);
|
||||
void cartoon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void cartoon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
// No setup required:
|
||||
|
|
@ -83,8 +78,7 @@ int cartoon_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/cartoon.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/cartoon.wav", api->data_directory);
|
||||
cartoon_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -106,41 +100,33 @@ SDL_Surface *cartoon_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/cartoon.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/cartoon.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *cartoon_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *cartoon_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Cartoon")));
|
||||
}
|
||||
|
||||
// Return our groups
|
||||
int cartoon_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int cartoon_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *cartoon_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *cartoon_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
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.")));
|
||||
}
|
||||
else
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click to turn the entire picture into a cartoon.")));
|
||||
return (strdup(gettext_noop("Click to turn the entire picture into a cartoon.")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,8 +154,7 @@ void cartoon_apply_colors(magic_api * api, SDL_Surface * surf, int xx, int yy)
|
|||
sat = floor(sat * 4) / 4;
|
||||
|
||||
api->hsvtorgb(hue, sat, val, &r, &g, &b);
|
||||
api->putpixel(result_surf, xx, yy,
|
||||
SDL_MapRGB(result_surf->format, r, g, b));
|
||||
api->putpixel(result_surf, xx, yy, SDL_MapRGB(result_surf->format, r, g, b));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -178,34 +163,26 @@ void cartoon_apply_outline(magic_api * api, int xx, int yy)
|
|||
Uint8 r, g, b;
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx, yy), result_surf->format, &r, &g,
|
||||
&b);
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy), result_surf->format, &r1,
|
||||
&g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy + 1), result_surf->format,
|
||||
&r2, &g2, &b2);
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx, yy), result_surf->format, &r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy), result_surf->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(result_surf, xx + 1, yy + 1), result_surf->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(result_surf, xx - 1, yy,
|
||||
SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
api->putpixel(result_surf, xx, yy - 1,
|
||||
SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
api->putpixel(result_surf, xx - 1, yy - 1,
|
||||
SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
api->putpixel(result_surf, xx - 1, yy, SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
api->putpixel(result_surf, xx, yy - 1, SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
api->putpixel(result_surf, xx - 1, yy - 1, SDL_MapRGB(result_surf->format, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void do_cartoon(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 xx, yy;
|
||||
|
|
@ -224,8 +201,7 @@ static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// 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)
|
||||
{
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -242,7 +218,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
y = tmp;
|
||||
}
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_cartoon);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_cartoon);
|
||||
|
||||
update_rect->x = ox - cartoon_radius;
|
||||
update_rect->y = oy - cartoon_radius;
|
||||
|
|
@ -254,8 +230,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,
|
||||
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)
|
||||
{
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
|
|
@ -303,8 +278,7 @@ void cartoon_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -316,46 +290,41 @@ void cartoon_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void cartoon_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void cartoon_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int cartoon_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int cartoon_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cartoon_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
Uint32 amask;
|
||||
|
||||
amask =
|
||||
~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
|
||||
result_surf = 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);
|
||||
}
|
||||
|
||||
void cartoon_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (result_surf != NULL)
|
||||
SDL_FreeSurface(result_surf);
|
||||
}
|
||||
|
||||
int cartoon_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int cartoon_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
|
@ -374,7 +343,9 @@ Uint8 cartoon_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 4;
|
||||
}
|
||||
|
||||
void cartoon_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void cartoon_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
cartoon_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,26 +49,24 @@ int checkerboard_get_group(magic_api * api, int which);
|
|||
char *checkerboard_get_description(magic_api * api, int which, int mode);
|
||||
int checkerboard_requires_colors(magic_api * api, int which);
|
||||
void checkerboard_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void checkerboard_shutdown(magic_api * api);
|
||||
void checkerboard_paint_checkerboard(void *ptr_to_api, int which_tool,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void checkerboard_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void checkerboard_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
void checkerboard_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void checkerboard_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void checkerboard_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void checkerboard_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int checkerboard_modes(magic_api * api, int which);
|
||||
Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
void checkerboard_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);
|
||||
Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED);
|
||||
void checkerboard_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);
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
|
|
@ -77,8 +75,9 @@ Uint32 checkerboard_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void checkerboard_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 checkerboard_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)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
checkerboard_r = r;
|
||||
|
|
@ -90,8 +89,7 @@ int checkerboard_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/checkerboard.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/checkerboard.ogg", api->data_directory);
|
||||
checkerboard_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -102,40 +100,32 @@ int checkerboard_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
|||
return 1;
|
||||
}
|
||||
|
||||
SDL_Surface *checkerboard_get_icon(magic_api * api,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
SDL_Surface *checkerboard_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/checkerboard.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/checkerboard.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *checkerboard_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *checkerboard_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Checkerboard"));
|
||||
}
|
||||
|
||||
int checkerboard_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int checkerboard_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_DECORATIONS;
|
||||
}
|
||||
|
||||
char *checkerboard_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click and drag to fill the canvas with a checkerboard pattern."));
|
||||
return strdup(gettext_noop("Click and drag to fill the canvas with a checkerboard pattern."));
|
||||
}
|
||||
|
||||
int checkerboard_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int checkerboard_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -144,8 +134,7 @@ void checkerboard_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -158,8 +147,7 @@ void checkerboard_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int sz, xx, yy;
|
||||
Uint8 draw_start, draw_row, draw_cell;
|
||||
|
|
@ -168,13 +156,9 @@ void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
SDL_BlitSurface(snapshot, NULL, canvas, NULL);
|
||||
|
||||
sz =
|
||||
max(10,
|
||||
max(abs(x - checkerboard_start_x), abs(y - checkerboard_start_y)));
|
||||
sz = max(10, max(abs(x - checkerboard_start_x), abs(y - checkerboard_start_y)));
|
||||
|
||||
colr =
|
||||
SDL_MapRGB(canvas->format, checkerboard_r, checkerboard_g,
|
||||
checkerboard_b);
|
||||
colr = SDL_MapRGB(canvas->format, checkerboard_r, checkerboard_g, checkerboard_b);
|
||||
|
||||
draw_start = 1;
|
||||
if (x < checkerboard_start_x)
|
||||
|
|
@ -267,8 +251,7 @@ void checkerboard_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
void checkerboard_click(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
checkerboard_start_x = x;
|
||||
checkerboard_start_y = y;
|
||||
|
|
@ -276,26 +259,23 @@ void checkerboard_click(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void checkerboard_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void checkerboard_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)
|
||||
{
|
||||
}
|
||||
|
||||
int checkerboard_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int checkerboard_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
||||
Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 checkerboard_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -305,6 +285,8 @@ Uint8 checkerboard_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTR
|
|||
return 0;
|
||||
}
|
||||
|
||||
void checkerboard_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 checkerboard_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,11 +73,9 @@ char *clone_get_name(magic_api * api, int which);
|
|||
int clone_get_group(magic_api * api, int which);
|
||||
char *clone_get_description(magic_api * api, int which, int mode);
|
||||
void clone_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 clone_doit(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect, int crosshairs);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs);
|
||||
void clone_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void clone_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -86,29 +84,25 @@ void clone_shutdown(magic_api * api);
|
|||
void clone_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int clone_requires_colors(magic_api * api, int which);
|
||||
void clone_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void clone_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void clone_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void clone_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int clone_modes(magic_api * api, int which);
|
||||
void clone_crosshairs(magic_api * api, SDL_Surface * canvas, int x, int y);
|
||||
void done_cloning(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Rect * update_rect);
|
||||
void done_cloning(magic_api * api, SDL_Surface * canvas, SDL_Rect * update_rect);
|
||||
Uint8 clone_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 clone_default_size(magic_api * api, int which, int mode);
|
||||
void clone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void clone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// No setup required:
|
||||
int clone_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/clone_start.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/clone_start.ogg", api->data_directory);
|
||||
clone_start_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/clone.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/clone.ogg", api->data_directory);
|
||||
clone_snd = Mix_LoadWAV(fname);
|
||||
|
||||
clone_state = CLONE_READY_TO_START;
|
||||
|
|
@ -133,30 +127,25 @@ SDL_Surface *clone_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/clone.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/clone.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *clone_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *clone_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Clone")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int clone_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int clone_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
|
|
@ -167,8 +156,7 @@ char *clone_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
// Do the effect:
|
||||
|
||||
static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int yy, dx;
|
||||
|
|
@ -206,8 +194,7 @@ static void do_clone(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void clone_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
/* Step 3 - Actively cloning (moving the mouse) */
|
||||
|
||||
|
|
@ -221,8 +208,7 @@ void clone_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void clone_doit(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect, int crosshairs)
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs)
|
||||
{
|
||||
if (clone_state != CLONE_CLONING)
|
||||
return;
|
||||
|
|
@ -230,7 +216,7 @@ void clone_doit(magic_api * api, int which, SDL_Surface * canvas,
|
|||
clone_drag_start_x = ox;
|
||||
clone_drag_start_y = oy;
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_clone);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_clone);
|
||||
|
||||
/* Move source position relative to mouse motion */
|
||||
clone_src_x += (x - ox);
|
||||
|
|
@ -275,8 +261,7 @@ void clone_doit(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void clone_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)
|
||||
{
|
||||
if (clone_state == CLONE_READY_TO_START)
|
||||
{
|
||||
|
|
@ -306,8 +291,7 @@ void clone_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
void clone_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
if (clone_state == CLONE_STARTING)
|
||||
{
|
||||
|
|
@ -321,8 +305,7 @@ void clone_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
}
|
||||
|
||||
void done_cloning(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Rect * update_rect)
|
||||
void done_cloning(magic_api * api, SDL_Surface * canvas, SDL_Rect * update_rect)
|
||||
{
|
||||
/* Done cloning! */
|
||||
|
||||
|
|
@ -361,32 +344,30 @@ void clone_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
Mix_FreeChunk(clone_start_snd);
|
||||
}
|
||||
|
||||
void clone_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void clone_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int clone_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int clone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clone_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
clone_last =
|
||||
SDL_CreateRGBSurface(0, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
clone_state = CLONE_READY_TO_START;
|
||||
}
|
||||
|
||||
void clone_switchout(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
void clone_switchout(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
SDL_Rect update_rect; /* Needed to satisfy done_cloning() :-( */
|
||||
|
||||
|
|
@ -402,15 +383,19 @@ int clone_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
|
||||
Uint8 clone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) {
|
||||
Uint8 clone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
Uint8 clone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) {
|
||||
Uint8 clone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
void clone_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void clone_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
clone_radius = size * 8;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,33 +15,35 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
COLORSEP_TOOL_3DGLASSES,
|
||||
COLORSEP_TOOL_COLORSEP,
|
||||
COLORSEP_TOOL_DOUBLEVISION,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
static char * colorsep_snd_filenames[NUM_TOOLS] = {
|
||||
static char *colorsep_snd_filenames[NUM_TOOLS] = {
|
||||
"3dglasses.ogg",
|
||||
"colorsep.ogg",
|
||||
"doublevision.ogg",
|
||||
};
|
||||
|
||||
static char * colorsep_icon_filenames[NUM_TOOLS] = {
|
||||
static char *colorsep_icon_filenames[NUM_TOOLS] = {
|
||||
"3dglasses.png",
|
||||
"colorsep.png",
|
||||
"doublevision.png"
|
||||
};
|
||||
|
||||
char * colorsep_names[NUM_TOOLS] = {
|
||||
char *colorsep_names[NUM_TOOLS] = {
|
||||
gettext_noop("3D Glasses"),
|
||||
gettext_noop("Color Sep."),
|
||||
gettext_noop("Double Vision"),
|
||||
};
|
||||
|
||||
char * colorsep_descrs[NUM_TOOLS] = {
|
||||
gettext_noop("Click and drag left and right to separate your picture's red and cyan, to make anaglyphs you can view with 3D glasses!"),
|
||||
char *colorsep_descrs[NUM_TOOLS] = {
|
||||
gettext_noop
|
||||
("Click and drag left and right to separate your picture's red and cyan, to make anaglyphs you can view with 3D glasses!"),
|
||||
gettext_noop("Click and drag to separate your picture's colors."),
|
||||
gettext_noop("Click and drag to simulate double vision."),
|
||||
};
|
||||
|
|
@ -61,25 +63,22 @@ int colorsep_requires_colors(magic_api * api, int which);
|
|||
int colorsep_modes(magic_api * api, int which);
|
||||
void colorsep_shutdown(magic_api * api);
|
||||
void colorsep_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void colorsep_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void colorsep_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int offset_x, int offset_y, int preview);
|
||||
void colorsep_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void colorsep_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void colorsep_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void colorsep_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void colorsep_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
Uint8 colorsep_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 colorsep_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
void colorsep_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 colorsep_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);
|
||||
|
||||
|
||||
Uint32 colorsep_api_version(void)
|
||||
|
|
@ -92,9 +91,9 @@ int colorsep_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s",
|
||||
api->data_directory, colorsep_snd_filenames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, colorsep_snd_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -111,32 +110,27 @@ SDL_Surface *colorsep_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, colorsep_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, colorsep_icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *colorsep_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
char *colorsep_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return strdup(gettext(colorsep_names[which]));
|
||||
}
|
||||
|
||||
int colorsep_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
char *colorsep_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode ATTRIBUTE_UNUSED)
|
||||
char *colorsep_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext(colorsep_descrs[which]));
|
||||
}
|
||||
|
||||
int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == COLORSEP_TOOL_COLORSEP)
|
||||
return 1;
|
||||
|
|
@ -144,8 +138,7 @@ int colorsep_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int colorsep_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int colorsep_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
@ -154,7 +147,8 @@ void colorsep_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
if (snd_effects[i] != NULL)
|
||||
Mix_FreeChunk(snd_effects[i]);
|
||||
}
|
||||
|
|
@ -162,8 +156,7 @@ void colorsep_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
colorsep_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->stopsound();
|
||||
|
||||
|
|
@ -183,9 +176,12 @@ colorsep_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
int offset_x, offset_y;
|
||||
|
||||
offset_x = colorsep_click_x - x;
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
offset_y = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
offset_y = colorsep_click_y - y;
|
||||
}
|
||||
|
||||
|
|
@ -206,41 +202,54 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
Uint8 r1, g1, b1, r2, g2, b2, r, g, b;
|
||||
SDL_Rect dest;
|
||||
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
step = 3;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
step = 1;
|
||||
}
|
||||
|
||||
for (yy = 0; yy < canvas->h; yy = yy + step) {
|
||||
for (xx = 0; xx < canvas->w; xx = xx + step) {
|
||||
for (yy = 0; yy < canvas->h; yy = yy + step)
|
||||
{
|
||||
for (xx = 0; xx < canvas->w; xx = xx + step)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(snapshot, xx + offset_x / 2, yy + offset_y / 2), snapshot->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(snapshot, xx - offset_x / 2, yy - offset_y / 2), snapshot->format, &r2, &g2, &b2);
|
||||
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
/* Split red aparet from green & blue (cyan) */
|
||||
r = r1;
|
||||
g = g2;
|
||||
b = b2;
|
||||
} else if (which == COLORSEP_TOOL_COLORSEP) {
|
||||
r = (Uint8) ((float) r1 * colorsep_r_pct) + ((float) r2 * (1.0 - colorsep_r_pct));
|
||||
g = (Uint8) ((float) g1 * colorsep_g_pct) + ((float) g2 * (1.0 - colorsep_g_pct));
|
||||
b = (Uint8) ((float) b1 * colorsep_b_pct) + ((float) b2 * (1.0 - colorsep_b_pct));
|
||||
} else { /* which == COLORSEP_TOOL_DOUBLEVISION */
|
||||
}
|
||||
else if (which == COLORSEP_TOOL_COLORSEP)
|
||||
{
|
||||
r = (Uint8) ((float)r1 * colorsep_r_pct) + ((float)r2 * (1.0 - colorsep_r_pct));
|
||||
g = (Uint8) ((float)g1 * colorsep_g_pct) + ((float)g2 * (1.0 - colorsep_g_pct));
|
||||
b = (Uint8) ((float)b1 * colorsep_b_pct) + ((float)b2 * (1.0 - colorsep_b_pct));
|
||||
}
|
||||
else
|
||||
{ /* which == COLORSEP_TOOL_DOUBLEVISION */
|
||||
/* 50/50 for all colors */
|
||||
r = (Uint8) ((float) r1 * 0.5) + ((float) r2 * 0.5);
|
||||
g = (Uint8) ((float) g1 * 0.5) + ((float) g2 * 0.5);
|
||||
b = (Uint8) ((float) b1 * 0.5) + ((float) b2 * 0.5);
|
||||
r = (Uint8) ((float)r1 * 0.5) + ((float)r2 * 0.5);
|
||||
g = (Uint8) ((float)g1 * 0.5) + ((float)g2 * 0.5);
|
||||
b = (Uint8) ((float)b1 * 0.5) + ((float)b2 * 0.5);
|
||||
}
|
||||
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
dest.x = xx;
|
||||
dest.y = yy;
|
||||
dest.w = step;
|
||||
dest.h = step;
|
||||
|
||||
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, r, g, b));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
|
|
@ -249,17 +258,17 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void colorsep_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot,
|
||||
int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int offset_x, offset_y;
|
||||
|
||||
offset_x = colorsep_click_x - x;
|
||||
if (which == COLORSEP_TOOL_3DGLASSES) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES)
|
||||
{
|
||||
offset_y = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
offset_y = colorsep_click_y - y;
|
||||
}
|
||||
colorsep_apply(api, which, canvas, snapshot, offset_x, offset_y, 0);
|
||||
|
|
@ -272,16 +281,16 @@ void colorsep_release(magic_api * api, int which,
|
|||
|
||||
|
||||
void colorsep_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)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
colorsep_r_pct = (float) r / 255.0;
|
||||
colorsep_g_pct = (float) g / 255.0;
|
||||
colorsep_b_pct = (float) b / 255.0;
|
||||
colorsep_r_pct = (float)r / 255.0;
|
||||
colorsep_g_pct = (float)g / 255.0;
|
||||
colorsep_b_pct = (float)b / 255.0;
|
||||
|
||||
if (colorsep_r_pct == colorsep_g_pct && colorsep_r_pct == colorsep_b_pct) {
|
||||
if (colorsep_r_pct == colorsep_g_pct && colorsep_r_pct == colorsep_b_pct)
|
||||
{
|
||||
colorsep_r_pct = 1.0;
|
||||
colorsep_g_pct = 0.0;
|
||||
colorsep_b_pct = 0.0;
|
||||
|
|
@ -290,15 +299,12 @@ void colorsep_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
|
||||
|
||||
void colorsep_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void colorsep_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -313,6 +319,8 @@ Uint8 colorsep_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
}
|
||||
|
||||
|
||||
void colorsep_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 colorsep_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle
|
||||
static int CONFETTI_BRUSH_SIZE = 8; //radius of each confetti circle
|
||||
|
||||
#define CONFETTI_QUANTITY 3 //how many circles will be created every click?
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
@ -36,37 +37,34 @@ int confetti_get_group(magic_api * api, int which);
|
|||
char *confetti_get_description(magic_api * api, int which, int mode);
|
||||
int confetti_requires_colors(magic_api * api, int which);
|
||||
void confetti_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void confetti_shutdown(magic_api * api);
|
||||
inline char confetti_get_greater(const char what1, const char what2);
|
||||
inline char confetti_get_lesser(const char what1, const char what2);
|
||||
Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas);
|
||||
void confetti_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void confetti_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void confetti_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void confetti_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void confetti_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int confetti_modes(magic_api * api, int which);
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
Uint8 confetti_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 confetti_default_size(magic_api * api, int which, int mode);
|
||||
void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void confetti_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 confetti_api_version(void)
|
||||
{
|
||||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void confetti_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 confetti_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)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
confetti_colors.r = r;
|
||||
|
|
@ -78,8 +76,7 @@ int confetti_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/confetti.ogg", api->data_directory);
|
||||
confetti_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -94,33 +91,27 @@ SDL_Surface *confetti_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/confetti.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/confetti.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *confetti_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Confetti"));
|
||||
}
|
||||
|
||||
int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *confetti_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Click to throw confetti!"));
|
||||
}
|
||||
|
||||
int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -129,8 +120,7 @@ void confetti_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -183,27 +173,23 @@ Uint32 confetti_get_new_color(void *ptr, SDL_Surface * canvas) //this function
|
|||
|
||||
|
||||
static void confetti_circle(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 xx, yy;
|
||||
Uint32 color = confetti_get_new_color(api, canvas);
|
||||
|
||||
for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2;
|
||||
yy++)
|
||||
for (yy = y - CONFETTI_BRUSH_SIZE / 2; yy < y + CONFETTI_BRUSH_SIZE / 2; yy++)
|
||||
|
||||
for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2;
|
||||
xx++)
|
||||
for (xx = x - CONFETTI_BRUSH_SIZE / 2; xx < x + CONFETTI_BRUSH_SIZE / 2; xx++)
|
||||
|
||||
if (api->in_circle(xx - x, yy - y, CONFETTI_BRUSH_SIZE / 2))
|
||||
api->putpixel(canvas, xx, yy, color);
|
||||
}
|
||||
|
||||
void confetti_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)
|
||||
{
|
||||
unsigned char i;
|
||||
char min_x = 0, max_x = 0, min_y = 0, max_y = 0;
|
||||
|
|
@ -212,8 +198,8 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
for (i = 0; i < CONFETTI_QUANTITY; i++)
|
||||
{
|
||||
srand((dx + dy) / 2 + time(0)); //to get a unique seed even if dx and dy aren't defined
|
||||
dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50>
|
||||
dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position
|
||||
dx = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //generate a value between <-50; +50>
|
||||
dy = (rand() % CONFETTI_BRUSH_SIZE * 12) - (CONFETTI_BRUSH_SIZE * 6); //to spread confetti around the cursor position
|
||||
|
||||
if (!i)
|
||||
{
|
||||
|
|
@ -227,7 +213,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
min_y = confetti_get_lesser(min_y, dy);
|
||||
max_y = confetti_get_greater(max_y, dy);
|
||||
}
|
||||
confetti_circle((void *) api, which, canvas, last, x + dx, y + dy);
|
||||
confetti_circle((void *)api, which, canvas, last, x + dx, y + dy);
|
||||
}
|
||||
|
||||
update_rect->x = x + min_x - CONFETTI_BRUSH_SIZE / 2;
|
||||
|
|
@ -239,8 +225,7 @@ void confetti_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int temp;
|
||||
|
||||
|
|
@ -261,19 +246,16 @@ void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void confetti_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void confetti_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int confetti_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int confetti_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -289,7 +271,9 @@ Uint8 confetti_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 2;
|
||||
}
|
||||
|
||||
void confetti_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 confetti_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)
|
||||
{
|
||||
CONFETTI_BRUSH_SIZE = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,31 +65,25 @@ int distortion_requires_colors(magic_api * api, int which);
|
|||
void distortion_shutdown(magic_api * api);
|
||||
|
||||
void distortion_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void distortion_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void distortion_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void distortion_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void distortion_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void distortion_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void distortion_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int distortion_modes(magic_api * api, int which);
|
||||
|
||||
void distortion_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
static void distortion_line_callback(void *ptr, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
static void distortion_line_callback(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
Uint8 distortion_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 distortion_default_size(magic_api * api, int which, int mode);
|
||||
void distortion_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void distortion_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
/* Setup Functions: */
|
||||
|
|
@ -107,8 +101,7 @@ int distortion_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/distortion.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/distortion.ogg", api->data_directory);
|
||||
|
||||
// Try to load the file!
|
||||
|
||||
|
|
@ -132,8 +125,7 @@ SDL_Surface *distortion_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/distortion.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/distortion.png", api->data_directory);
|
||||
|
||||
|
||||
// Try to load the image, and return the results to Tux Paint:
|
||||
|
|
@ -144,8 +136,7 @@ SDL_Surface *distortion_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
|
||||
// Report our "Magic" tool names
|
||||
|
||||
char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Distortion")));
|
||||
}
|
||||
|
|
@ -153,8 +144,7 @@ char *distortion_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
// Report our "Magic" tool groups
|
||||
|
||||
int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
|
@ -163,18 +153,14 @@ int distortion_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
|||
// Report our "Magic" tool descriptions
|
||||
|
||||
char *distortion_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode 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.")));
|
||||
}
|
||||
|
||||
// Report whether we accept colors
|
||||
|
||||
int distortion_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int distortion_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -194,8 +180,7 @@ void distortion_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
// Affect the canvas on click:
|
||||
|
||||
void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
distortion_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -204,11 +189,9 @@ void distortion_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
// Affect the canvas on drag:
|
||||
|
||||
void distortion_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1,
|
||||
distortion_line_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, distortion_line_callback);
|
||||
|
||||
|
||||
if (ox > x)
|
||||
|
|
@ -244,14 +227,15 @@ void distortion_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -259,8 +243,7 @@ void distortion_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
// Our "callback" function
|
||||
|
||||
static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy;
|
||||
|
|
@ -276,29 +259,23 @@ static void distortion_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
if (api->in_circle(xx, yy, distortion_radius))
|
||||
{
|
||||
api->putpixel(canvas, x + xx, y + yy,
|
||||
api->getpixel(snapshot, x + xx / 2, y + yy));
|
||||
api->putpixel(canvas, x + xx, 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)
|
||||
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)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int distortion_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int distortion_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -314,7 +291,9 @@ Uint8 distortion_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB
|
|||
return 2;
|
||||
}
|
||||
|
||||
void distortion_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void distortion_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
distortion_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,29 +47,25 @@ int emboss_get_group(magic_api * api, int which);
|
|||
char *emboss_get_description(magic_api * api, int which, int mode);
|
||||
|
||||
void emboss_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 emboss_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 emboss_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 emboss_shutdown(magic_api * api);
|
||||
void emboss_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int emboss_requires_colors(magic_api * api, int which);
|
||||
void emboss_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void emboss_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void emboss_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void emboss_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int emboss_modes(magic_api * api, int which);
|
||||
Uint8 emboss_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 emboss_default_size(magic_api * api, int which, int mode);
|
||||
void emboss_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void emboss_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 emboss_api_version(void)
|
||||
|
|
@ -83,8 +79,7 @@ int emboss_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/emboss.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/emboss.ogg", api->data_directory);
|
||||
emboss_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -101,34 +96,28 @@ SDL_Surface *emboss_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/emboss.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/emboss.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *emboss_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *emboss_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Emboss")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int emboss_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int emboss_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to emboss the picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to emboss the picture.")));
|
||||
else
|
||||
return (strdup(gettext_noop("Click to emboss the entire picture.")));
|
||||
}
|
||||
|
|
@ -136,8 +125,7 @@ char *emboss_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
// Do the effect (single pixel; used by do_emboss() (painted circle)
|
||||
// and emboss_click() when in fullscreen mode):
|
||||
static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y,
|
||||
SDL_Surface * canvas)
|
||||
static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y, SDL_Surface * canvas)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
|
|
@ -168,8 +156,7 @@ static void emboss_pixel(void *ptr, SDL_Surface * last, int x, int y,
|
|||
|
||||
|
||||
// Do the effect (a circle around a touch point):
|
||||
static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
static void do_emboss(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;
|
||||
|
|
@ -191,10 +178,9 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void emboss_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_emboss);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_emboss);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -221,8 +207,7 @@ void emboss_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void emboss_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_PAINT)
|
||||
{
|
||||
|
|
@ -255,8 +240,7 @@ void emboss_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -268,27 +252,26 @@ void emboss_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void emboss_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void emboss_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int emboss_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int emboss_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void emboss_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void emboss_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +294,9 @@ Uint8 emboss_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 4;
|
||||
}
|
||||
|
||||
void emboss_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void emboss_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
emboss_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ enum
|
|||
NUM_TOOLS
|
||||
};
|
||||
|
||||
char * tool_names[NUM_TOOLS] = {
|
||||
char *tool_names[NUM_TOOLS] = {
|
||||
gettext_noop("Lighten"),
|
||||
gettext_noop("Darken"),
|
||||
gettext_noop("Desaturate"),
|
||||
|
|
@ -52,34 +52,31 @@ char * tool_names[NUM_TOOLS] = {
|
|||
gettext_noop("Keep Color"),
|
||||
};
|
||||
|
||||
char * tool_descriptions[NUM_TOOLS][2] = {
|
||||
char *tool_descriptions[NUM_TOOLS][2] = {
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to lighten parts of your picture."),
|
||||
gettext_noop("Click to lighten your entire picture.")
|
||||
},
|
||||
gettext_noop("Click to lighten your entire picture.")},
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to darken parts of your picture."),
|
||||
gettext_noop("Click to darken your entire picture.")
|
||||
},
|
||||
gettext_noop("Click to darken your entire picture.")},
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to desaturate parts of your picture."),
|
||||
gettext_noop("Click to desaturate your entire picture.")
|
||||
},
|
||||
gettext_noop("Click to desaturate your entire picture.")},
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to saturate parts of your picture."),
|
||||
gettext_noop("Click to saturate your entire picture.")
|
||||
},
|
||||
gettext_noop("Click to saturate your entire picture.")},
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to entirely desaturate parts of your picture that match the chosen color."),
|
||||
gettext_noop("Click to entirely desaturate the parts of your picture that match the chosen color."),
|
||||
},
|
||||
},
|
||||
{
|
||||
gettext_noop("Click and drag the mouse to entirely desaturate parts of your picture that don't match the chosen color."),
|
||||
gettext_noop
|
||||
("Click and drag the mouse to entirely desaturate parts of your picture that don't match the chosen color."),
|
||||
gettext_noop("Click to entirely desaturate the parts of your picture that don't match the chosen color."),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
char * sfx_filenames[NUM_TOOLS] = {
|
||||
char *sfx_filenames[NUM_TOOLS] = {
|
||||
"fade.wav",
|
||||
"darken.wav",
|
||||
"desaturate.ogg",
|
||||
|
|
@ -88,7 +85,7 @@ char * sfx_filenames[NUM_TOOLS] = {
|
|||
"keep_color.ogg",
|
||||
};
|
||||
|
||||
char * icon_filenames[NUM_TOOLS] = {
|
||||
char *icon_filenames[NUM_TOOLS] = {
|
||||
"fade.png",
|
||||
"darken.png",
|
||||
"desaturate.png",
|
||||
|
|
@ -117,31 +114,25 @@ SDL_Surface *fade_darken_get_icon(magic_api * api, int which);
|
|||
int fade_darken_get_group(magic_api * api, int which);
|
||||
char *fade_darken_get_name(magic_api * api, int which);
|
||||
char *fade_darken_get_description(magic_api * api, int which, int mode);
|
||||
static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void fade_darken_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 fade_darken_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 fade_darken_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void fade_darken_shutdown(magic_api * api);
|
||||
void fade_darken_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int fade_darken_requires_colors(magic_api * api, int which);
|
||||
void fade_darken_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void fade_darken_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void fade_darken_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void fade_darken_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int fade_darken_modes(magic_api * api, int which);
|
||||
Uint8 fade_darken_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 fade_darken_default_size(magic_api * api, int which, int mode);
|
||||
void fade_darken_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void fade_darken_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
int fade_darken_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
|
|
@ -149,9 +140,9 @@ int fade_darken_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s",
|
||||
api->data_directory, sfx_filenames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, sfx_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +165,7 @@ SDL_Surface *fade_darken_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -187,21 +177,18 @@ char *fade_darken_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (all the same):
|
||||
int fade_darken_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fade_darken_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
// Return our description, localized:
|
||||
char *fade_darken_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *fade_darken_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return strdup(gettext(tool_descriptions[which][mode - 1]));
|
||||
}
|
||||
|
||||
static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -226,25 +213,36 @@ static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
api->rgbtohsv(r, g, b, &h, &s, &v);
|
||||
|
||||
if (which == TOOL_DESATURATE) {
|
||||
if (which == TOOL_DESATURATE)
|
||||
{
|
||||
s = (s * SAT_DESAT_RATIO_NUM) / SAT_DESAT_RATIO_DENOM;
|
||||
} else if (which == TOOL_SATURATE) {
|
||||
if (s > 0.1) { /* don't saturate things w/o undefined color! */
|
||||
}
|
||||
else if (which == TOOL_SATURATE)
|
||||
{
|
||||
if (s > 0.1)
|
||||
{ /* don't saturate things w/o undefined color! */
|
||||
s = (s * SAT_DESAT_RATIO_DENOM) / SAT_DESAT_RATIO_NUM;
|
||||
if (s > 1.0) {
|
||||
if (s > 1.0)
|
||||
{
|
||||
s = 1.0;
|
||||
}
|
||||
}
|
||||
} else if (which == TOOL_REMOVE) {
|
||||
}
|
||||
else if (which == TOOL_REMOVE)
|
||||
{
|
||||
if (fabs(h - chosen_h) <= KEEP_REMOVE_HUE_THRESH
|
||||
/* && fabs(s - chosen_s) <= KEEP_REMOVE_VALUE_THRESH */
|
||||
) {
|
||||
/* && fabs(s - chosen_s) <= KEEP_REMOVE_VALUE_THRESH */
|
||||
)
|
||||
{
|
||||
s = 0.0;
|
||||
}
|
||||
} else if (which == TOOL_KEEP) {
|
||||
}
|
||||
else if (which == TOOL_KEEP)
|
||||
{
|
||||
if (fabs(h - chosen_h) > KEEP_REMOVE_HUE_THRESH
|
||||
/* || fabs(s - chosen_s) > KEEP_REMOVE_VALUE_THRESH */
|
||||
) {
|
||||
/* || fabs(s - chosen_s) > KEEP_REMOVE_VALUE_THRESH */
|
||||
)
|
||||
{
|
||||
s = 0.0;
|
||||
}
|
||||
}
|
||||
|
|
@ -257,8 +255,7 @@ static void do_fade_darken(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
// Callback that does the fade_darken color effect on a circle centered around x,y
|
||||
static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -277,14 +274,12 @@ static void do_fade_darken_paint(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Ask Tux Paint to call our 'do_fade_darken_paint()' callback over a line
|
||||
void fade_darken_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)
|
||||
{
|
||||
SDL_LockSurface(last);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1,
|
||||
do_fade_darken_paint);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_fade_darken_paint);
|
||||
|
||||
SDL_UnlockSurface(canvas);
|
||||
SDL_UnlockSurface(last);
|
||||
|
|
@ -315,8 +310,7 @@ void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// Ask Tux Paint to call our 'do_fade_darken_paint()' callback at a single point,
|
||||
// or 'do_fade_darken()' on the entire image
|
||||
void fade_darken_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_PAINT)
|
||||
fade_darken_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -342,8 +336,7 @@ void fade_darken_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +351,8 @@ void fade_darken_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
void fade_darken_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
float tmp;
|
||||
|
||||
|
|
@ -366,8 +360,7 @@ void fade_darken_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surf
|
|||
}
|
||||
|
||||
// We don't use colors
|
||||
int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == TOOL_REMOVE || which == TOOL_KEEP)
|
||||
return 1;
|
||||
|
|
@ -376,27 +369,23 @@ int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void fade_darken_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void fade_darken_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int fade_darken_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fade_darken_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
|
||||
Uint8 fade_darken_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 fade_darken_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return 8;
|
||||
|
|
@ -409,7 +398,9 @@ Uint8 fade_darken_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
return 4;
|
||||
}
|
||||
|
||||
void fade_darken_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void fade_darken_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fade_darken_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,39 +49,36 @@ int fisheye_get_group(magic_api * api, int which);
|
|||
char *fisheye_get_description(magic_api * api, int which, int mode);
|
||||
int fisheye_requires_colors(magic_api * api, int which);
|
||||
void fisheye_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void fisheye_shutdown(magic_api * api);
|
||||
void fisheye_draw(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
void fisheye_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void fisheye_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
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_switchin(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);
|
||||
Uint8 fisheye_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 fisheye_default_size(magic_api * api, int which, int mode);
|
||||
void fisheye_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void fisheye_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
Uint32 fisheye_api_version(void)
|
||||
{
|
||||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void fisheye_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void fisheye_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -89,8 +86,7 @@ int fisheye_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fisheye.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fisheye.ogg", api->data_directory);
|
||||
fisheye_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -105,35 +101,27 @@ SDL_Surface *fisheye_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fisheye.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fisheye.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *fisheye_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Fisheye"));
|
||||
}
|
||||
|
||||
int fisheye_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fisheye_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
char *fisheye_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
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."));
|
||||
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)
|
||||
int fisheye_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -142,8 +130,7 @@ void fisheye_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -172,13 +159,11 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
|||
|
||||
oryg =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius, fisheye_radius, 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_SWSURFACE, fisheye_radius, fisheye_radius, 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 - (fisheye_radius / 2);
|
||||
rect.y = y - (fisheye_radius / 2);
|
||||
|
|
@ -191,8 +176,7 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
|||
{
|
||||
temp_src =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, 1, fisheye_radius, 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
|
||||
//left side first
|
||||
|
|
@ -205,10 +189,9 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
|||
temp_dest =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, 1, fisheye_radius + 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, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src
|
||||
temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src
|
||||
|
||||
temp_rect.x = 0;
|
||||
temp_rect.y = i;
|
||||
|
|
@ -223,7 +206,7 @@ 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 //OK
|
||||
|
||||
temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src
|
||||
temp_dest = api->scale(temp_src, 1, fisheye_radius + 2 * i, 0); //temp_dest stores scaled temp_src
|
||||
|
||||
SDL_BlitSurface(temp_dest, &temp_rect, output, &rect); //let's copy it to output
|
||||
}
|
||||
|
|
@ -233,14 +216,12 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
|||
{
|
||||
temp_src =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, fisheye_radius, 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_SWSURFACE, fisheye_radius + 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
|
||||
rect.x = 0;
|
||||
|
|
@ -274,9 +255,12 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
|||
|
||||
//let's blit an area surrounded by a circle
|
||||
|
||||
for (yy = y - (fisheye_radius / 2); yy < y + (fisheye_radius / 2); yy++) {
|
||||
for (xx = x - (fisheye_radius / 2); xx < x + (fisheye_radius / 2); xx++) {
|
||||
if (api->in_circle(xx - x, yy - y, (fisheye_radius / 2))) {
|
||||
for (yy = y - (fisheye_radius / 2); yy < y + (fisheye_radius / 2); yy++)
|
||||
{
|
||||
for (xx = x - (fisheye_radius / 2); xx < x + (fisheye_radius / 2); xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, (fisheye_radius / 2)))
|
||||
{
|
||||
api->putpixel(canvas, xx, yy,
|
||||
api->getpixel(output, xx + (fisheye_radius / 2) - x, yy + (fisheye_radius / 2) - y));
|
||||
}
|
||||
|
|
@ -294,8 +278,7 @@ void fisheye_draw(void *ptr, int which ATTRIBUTE_UNUSED, 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_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
|
||||
api->line(api, which, canvas, snapshot, ox, oy, x, y, 1, fisheye_draw);
|
||||
|
|
@ -306,30 +289,26 @@ void fisheye_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void fisheye_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)
|
||||
{
|
||||
last_x = -fisheye_radius; /* A value that will be beyond any clicked position */
|
||||
last_x = -fisheye_radius; /* A value that will be beyond any clicked position */
|
||||
last_y = -fisheye_radius;
|
||||
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)
|
||||
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)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int fisheye_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fisheye_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -337,15 +316,17 @@ int fisheye_modes(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
Uint8 fisheye_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 5; // FIXME
|
||||
return 5; // FIXME
|
||||
}
|
||||
|
||||
Uint8 fisheye_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 2; // FIXME
|
||||
return 2; // FIXME
|
||||
}
|
||||
|
||||
void fisheye_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void fisheye_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fisheye_radius = size * 40;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ static int flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y;
|
|||
static int flower_side_first;
|
||||
static int flower_side_decided;
|
||||
static SDL_Surface *flower_base_full = NULL, *flower_leaf_full = NULL, *flower_petals_full = NULL;
|
||||
static SDL_Surface *flower_base = NULL, *flower_leaf = NULL, *flower_petals = NULL,
|
||||
*flower_petals_colorized = NULL;
|
||||
static SDL_Surface *flower_base = NULL, *flower_leaf = NULL, *flower_petals = NULL, *flower_petals_colorized = NULL;
|
||||
|
||||
/* Local function prototypes: */
|
||||
|
||||
|
|
@ -70,11 +69,9 @@ typedef struct
|
|||
} Point2D;
|
||||
|
||||
static void flower_drawbase(magic_api * api, SDL_Surface * canvas);
|
||||
static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x,
|
||||
int y);
|
||||
static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, int y);
|
||||
static Point2D flower_PointOnCubicBezier(Point2D * cp, float t);
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve);
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve);
|
||||
Uint32 flower_api_version(void);
|
||||
int flower_init(magic_api * api, Uint32 disabled_features);
|
||||
int flower_get_tool_count(magic_api * api);
|
||||
|
|
@ -82,37 +79,31 @@ SDL_Surface *flower_get_icon(magic_api * api, int which);
|
|||
char *flower_get_name(magic_api * api, int which);
|
||||
int flower_get_group(magic_api * api, int which);
|
||||
char *flower_get_description(magic_api * api, int which, int mode);
|
||||
static void flower_predrag(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y);
|
||||
static void flower_predrag(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y);
|
||||
void flower_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 flower_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void flower_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x,
|
||||
int y);
|
||||
static void flower_drawflower(magic_api * api, SDL_Surface * canvas, int x, int y);
|
||||
static void flower_drawbase(magic_api * api, SDL_Surface * canvas);
|
||||
static void flower_drawstalk(magic_api * api, SDL_Surface * canvas,
|
||||
int top_x, int top_y, int minx, int maxx,
|
||||
int bottom_x, int bottom_y, int final);
|
||||
int top_x, int top_y, int minx, int maxx, int bottom_x, int bottom_y, int final);
|
||||
void flower_shutdown(magic_api * api);
|
||||
void flower_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int flower_requires_colors(magic_api * api, int which);
|
||||
static Point2D flower_PointOnCubicBezier(Point2D * cp, float t);
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve);
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve);
|
||||
static void flower_colorize_petals(magic_api * api);
|
||||
void flower_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void flower_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void flower_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void flower_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int flower_modes(magic_api * api, int which);
|
||||
Uint8 flower_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 flower_default_size(magic_api * api, int which, int mode);
|
||||
void flower_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void flower_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -126,58 +117,59 @@ Uint32 flower_api_version(void)
|
|||
int flower_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
SDL_Surface * tmp_surf;
|
||||
SDL_Surface *tmp_surf;
|
||||
int h;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flower_click.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flower_click.ogg", api->data_directory);
|
||||
flower_click_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flower_release.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flower_release.ogg", api->data_directory);
|
||||
flower_release_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_base.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_base.png", api->data_directory);
|
||||
tmp_surf = IMG_Load(fname);
|
||||
if (tmp_surf == NULL) {
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
h = tmp_surf->h * MAX_WIDTH / tmp_surf->w;
|
||||
flower_base_full = api->scale(tmp_surf, MAX_WIDTH, h, 1);
|
||||
if (flower_base_full == NULL) {
|
||||
if (flower_base_full == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_leaf.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_leaf.png", api->data_directory);
|
||||
tmp_surf = IMG_Load(fname);
|
||||
if (tmp_surf == NULL) {
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
/* N.B.: Leaf is 1/2 as wide as base & petals */
|
||||
h = tmp_surf->h * (MAX_WIDTH / 2) / tmp_surf->w;
|
||||
flower_leaf_full = api->scale(tmp_surf, MAX_WIDTH / 2, h, 1);
|
||||
if (flower_leaf_full == NULL) {
|
||||
if (flower_leaf_full == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_petals.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower_petals.png", api->data_directory);
|
||||
tmp_surf = IMG_Load(fname);
|
||||
if (tmp_surf == NULL) {
|
||||
if (tmp_surf == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
h = tmp_surf->h * MAX_WIDTH / tmp_surf->w;
|
||||
flower_petals_full = api->scale(tmp_surf, MAX_WIDTH, h, 1);
|
||||
if (flower_petals_full == NULL) {
|
||||
if (flower_petals_full == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale %s", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
flower_cur_size = DEFAULT_SIZE;
|
||||
|
|
@ -197,41 +189,33 @@ SDL_Surface *flower_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flower.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *flower_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *flower_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Flower")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int flower_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int flower_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *flower_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *flower_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to draw a flower stalk. Let go to finish the flower.")));
|
||||
return (strdup(gettext_noop("Click and drag to draw a flower stalk. Let go to finish the flower.")));
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
static void flower_predrag(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox,
|
||||
int oy, int x, int y)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y)
|
||||
{
|
||||
if (x < flower_min_x)
|
||||
flower_min_x = x;
|
||||
|
|
@ -265,8 +249,7 @@ static void flower_predrag(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
flower_predrag(api, canvas, last, ox, oy, x, y);
|
||||
|
||||
|
|
@ -279,8 +262,7 @@ void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
/* Draw the base and the stalk (low-quality) for now: */
|
||||
|
||||
flower_drawstalk(api, canvas,
|
||||
x, y, flower_min_x, flower_max_x, flower_bottom_x,
|
||||
flower_bottom_y, !(api->button_down()));
|
||||
x, y, flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y, !(api->button_down()));
|
||||
|
||||
flower_drawbase(api, canvas);
|
||||
|
||||
|
|
@ -292,8 +274,7 @@ void flower_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void flower_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)
|
||||
{
|
||||
flower_min_x = x;
|
||||
flower_max_x = x;
|
||||
|
|
@ -310,8 +291,7 @@ void flower_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on release:
|
||||
void flower_release(magic_api * api, int which 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)
|
||||
{
|
||||
/* Don't let flower be too low compared to base: */
|
||||
|
||||
|
|
@ -331,8 +311,7 @@ void flower_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
/* Draw high-quality stalk, and flower: */
|
||||
|
||||
flower_drawstalk(api, canvas, x, y, flower_min_x, flower_max_x,
|
||||
flower_bottom_x, flower_bottom_y, 1);
|
||||
flower_drawstalk(api, canvas, x, y, flower_min_x, flower_max_x, flower_bottom_x, flower_bottom_y, 1);
|
||||
|
||||
flower_drawflower(api, canvas, x, y);
|
||||
|
||||
|
|
@ -348,12 +327,11 @@ void flower_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
|
||||
static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, int x, int y)
|
||||
static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas, int x, int y)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
if (flower_petals_colorized == NULL) // Abort!
|
||||
if (flower_petals_colorized == NULL) // Abort!
|
||||
return;
|
||||
|
||||
dest.x = x - (flower_petals_colorized->w / 2);
|
||||
|
|
@ -362,12 +340,11 @@ static void flower_drawflower(magic_api * api ATTRIBUTE_UNUSED,
|
|||
SDL_BlitSurface(flower_petals_colorized, NULL, canvas, &dest);
|
||||
}
|
||||
|
||||
static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
if (flower_base == NULL) // Abort!
|
||||
if (flower_base == NULL) // Abort!
|
||||
return;
|
||||
|
||||
dest.x = flower_bottom_x - (flower_base->w / 2);
|
||||
|
|
@ -378,8 +355,7 @@ static void flower_drawbase(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
static void flower_drawstalk(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, int top_x, int top_y,
|
||||
int minx, int maxx, int bottom_x, int bottom_y,
|
||||
int final)
|
||||
int minx, int maxx, int bottom_x, int bottom_y, int final)
|
||||
{
|
||||
Point2D control_points[4];
|
||||
Point2D *curve;
|
||||
|
|
@ -389,7 +365,7 @@ static void flower_drawstalk(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int xx, yy, side;
|
||||
|
||||
|
||||
if (flower_leaf == NULL) // Abort!
|
||||
if (flower_leaf == NULL) // Abort!
|
||||
return;
|
||||
|
||||
/* Compute a nice bezier curve for the stalk, based on the
|
||||
|
|
@ -585,7 +561,8 @@ void flower_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void flower_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
flower_r = r;
|
||||
flower_g = g;
|
||||
|
|
@ -595,8 +572,7 @@ void flower_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int flower_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int flower_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -651,8 +627,7 @@ static Point2D flower_PointOnCubicBezier(Point2D * cp, float t)
|
|||
<sizeof(Point2D) numberOfPoints>
|
||||
*/
|
||||
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve)
|
||||
static void flower_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve)
|
||||
{
|
||||
float dt;
|
||||
int i;
|
||||
|
|
@ -673,14 +648,12 @@ static void flower_colorize_petals(magic_api * api)
|
|||
if (flower_petals_colorized != NULL)
|
||||
SDL_FreeSurface(flower_petals_colorized);
|
||||
|
||||
if (flower_petals == NULL) // Abort!
|
||||
if (flower_petals == NULL) // Abort!
|
||||
return;
|
||||
|
||||
/* Create a surface to render into: */
|
||||
|
||||
amask =
|
||||
~(flower_petals->format->Rmask | flower_petals->format->
|
||||
Gmask | flower_petals->format->Bmask);
|
||||
amask = ~(flower_petals->format->Rmask | flower_petals->format->Gmask | flower_petals->format->Bmask);
|
||||
|
||||
flower_petals_colorized =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
|
|
@ -688,8 +661,7 @@ static void flower_colorize_petals(magic_api * api)
|
|||
flower_petals->h,
|
||||
flower_petals->format->BitsPerPixel,
|
||||
flower_petals->format->Rmask,
|
||||
flower_petals->format->Gmask,
|
||||
flower_petals->format->Bmask, amask);
|
||||
flower_petals->format->Gmask, flower_petals->format->Bmask, amask);
|
||||
|
||||
/* Render the new petals: */
|
||||
|
||||
|
|
@ -700,19 +672,14 @@ static void flower_colorize_petals(magic_api * api)
|
|||
{
|
||||
for (x = 0; x < flower_petals->w; x++)
|
||||
{
|
||||
SDL_GetRGBA(api->getpixel(flower_petals, x, y), flower_petals->format,
|
||||
&r, &g, &b, &a);
|
||||
SDL_GetRGBA(api->getpixel(flower_petals, x, y), flower_petals->format, &r, &g, &b, &a);
|
||||
|
||||
api->putpixel(flower_petals_colorized, x, y,
|
||||
SDL_MapRGBA(flower_petals_colorized->format, flower_r,
|
||||
flower_g, flower_b, a));
|
||||
SDL_MapRGBA(flower_petals_colorized->format, flower_r, flower_g, flower_b, a));
|
||||
|
||||
if (api->in_circle
|
||||
((x - flower_petals->w / 2), (y - flower_petals->h / 2), (flower_petals->w / 4)))
|
||||
if (api->in_circle((x - flower_petals->w / 2), (y - flower_petals->h / 2), (flower_petals->w / 4)))
|
||||
{
|
||||
api->putpixel(flower_petals_colorized, x, y,
|
||||
SDL_MapRGBA(flower_petals_colorized->format, 0xFF, 0xFF,
|
||||
0x00, a));
|
||||
api->putpixel(flower_petals_colorized, x, y, SDL_MapRGBA(flower_petals_colorized->format, 0xFF, 0xFF, 0x00, a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -722,14 +689,12 @@ static void flower_colorize_petals(magic_api * api)
|
|||
}
|
||||
|
||||
void flower_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void flower_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -748,7 +713,9 @@ Uint8 flower_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
||||
void flower_set_size(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void flower_set_size(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int scale, width, height;
|
||||
|
||||
|
|
|
|||
104
magic/src/foam.c
104
magic/src/foam.c
|
|
@ -45,23 +45,17 @@ Uint32 foam_api_version(void);
|
|||
int foam_init(magic_api * api, Uint32 disabled_features);
|
||||
char *foam_get_description(magic_api * api, int which, int mode);
|
||||
void foam_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void foam_release_worker(SDL_Surface * canvas, SDL_Surface * last, SDL_Rect * update_rect);
|
||||
void foam_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 foam_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface *foam_get_icon(magic_api * api, int which);
|
||||
char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED);
|
||||
int foam_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED);
|
||||
void foam_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void foam_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED);
|
||||
int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED);
|
||||
void foam_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void foam_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void foam_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void foam_shutdown(magic_api * api);
|
||||
|
|
@ -70,7 +64,8 @@ int foam_modes(magic_api * api, int which);
|
|||
int foam_requires_colors(magic_api * api, int which);
|
||||
Uint8 foam_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 foam_default_size(magic_api * api, int which, int mode);
|
||||
void foam_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void foam_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
#define FOAM_PROP 8
|
||||
#define FOAM_RADIUS 3
|
||||
|
|
@ -87,26 +82,16 @@ int foam_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
char fname[1024];
|
||||
SDL_Surface *foam_data;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/foam.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/foam.ogg", api->data_directory);
|
||||
foam_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/foam_data.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/foam_data.png", api->data_directory);
|
||||
foam_data = IMG_Load(fname);
|
||||
|
||||
foam_7 =
|
||||
api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 4) / 4, 1);
|
||||
foam_5 =
|
||||
api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 3) / 4, 1);
|
||||
foam_3 =
|
||||
api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 2) / 4, 1);
|
||||
foam_1 =
|
||||
api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4,
|
||||
((api->canvas_h / FOAM_PROP) * 1) / 4, 1);
|
||||
foam_7 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 4) / 4, ((api->canvas_h / FOAM_PROP) * 4) / 4, 1);
|
||||
foam_5 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 3) / 4, ((api->canvas_h / FOAM_PROP) * 3) / 4, 1);
|
||||
foam_3 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 2) / 4, ((api->canvas_h / FOAM_PROP) * 2) / 4, 1);
|
||||
foam_1 = api->scale(foam_data, ((api->canvas_w / FOAM_PROP) * 1) / 4, ((api->canvas_h / FOAM_PROP) * 1) / 4, 1);
|
||||
|
||||
SDL_FreeSurface(foam_data);
|
||||
|
||||
|
|
@ -124,41 +109,33 @@ SDL_Surface *foam_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/foam.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/foam.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *foam_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Foam")));
|
||||
}
|
||||
|
||||
// Return our groups
|
||||
int foam_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int foam_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *foam_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *foam_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 cover an area with foamy bubbles.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to cover an area with foamy bubbles.")));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
|
||||
static void do_foam(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy, nx, ny;
|
||||
|
|
@ -185,10 +162,9 @@ static void do_foam(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void foam_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_foam);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_foam);
|
||||
|
||||
foam_release_worker(canvas, last, update_rect);
|
||||
// foam_release(api, which, canvas, last, x, y, update_rect);
|
||||
|
|
@ -220,8 +196,7 @@ void foam_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// Affect the canvas on click:
|
||||
void foam_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x ATTRIBUTE_UNUSED,
|
||||
int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -230,8 +205,8 @@ void foam_click(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
|||
foam_mask_w = canvas->w / FOAM_PROP;
|
||||
foam_mask_h = canvas->h / FOAM_PROP;
|
||||
|
||||
foam_mask = (int *) malloc(sizeof(int) * (foam_mask_w * foam_mask_h));
|
||||
foam_mask_tmp = (int *) malloc(sizeof(int) * (foam_mask_w * foam_mask_h));
|
||||
foam_mask = (int *)malloc(sizeof(int) * (foam_mask_w * foam_mask_h));
|
||||
foam_mask_tmp = (int *)malloc(sizeof(int) * (foam_mask_w * foam_mask_h));
|
||||
}
|
||||
|
||||
for (i = 0; i < foam_mask_w * foam_mask_h; i++)
|
||||
|
|
@ -265,14 +240,13 @@ static int foam_mask_test(int r, int x, int y)
|
|||
// Affect the canvas on release:
|
||||
void foam_release(magic_api * api ATTRIBUTE_UNUSED ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x ATTRIBUTE_UNUSED,
|
||||
int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
api->stopsound();
|
||||
foam_release_worker(canvas, last, update_rect);
|
||||
}
|
||||
|
||||
void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * update_rect)
|
||||
void foam_release_worker(SDL_Surface * canvas, SDL_Surface * last, SDL_Rect * update_rect)
|
||||
{
|
||||
int xx, yy;
|
||||
int changes, max_iters;
|
||||
|
|
@ -282,8 +256,7 @@ void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * upd
|
|||
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
|
||||
memcpy(foam_mask_tmp, foam_mask,
|
||||
(sizeof(int) * (foam_mask_w * foam_mask_h)));
|
||||
memcpy(foam_mask_tmp, foam_mask, (sizeof(int) * (foam_mask_w * foam_mask_h)));
|
||||
|
||||
|
||||
max_iters = 2;
|
||||
|
|
@ -441,8 +414,7 @@ void foam_release_worker(SDL_Surface * canvas, SDL_Surface* last, SDL_Rect * upd
|
|||
}
|
||||
}
|
||||
|
||||
memcpy(foam_mask, foam_mask_tmp,
|
||||
(sizeof(int) * (foam_mask_w * foam_mask_h)));
|
||||
memcpy(foam_mask, foam_mask_tmp, (sizeof(int) * (foam_mask_w * foam_mask_h)));
|
||||
|
||||
|
||||
update_rect->x = 0;
|
||||
|
|
@ -472,7 +444,8 @@ void foam_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void foam_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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
foam_r = r;
|
||||
foam_g = g;
|
||||
|
|
@ -480,21 +453,18 @@ void foam_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int foam_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int foam_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0; /* FIXME: Would be nice to tint the bubbles */
|
||||
}
|
||||
|
||||
void foam_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void foam_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -514,6 +484,8 @@ Uint8 foam_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 0;
|
||||
}
|
||||
|
||||
void foam_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 foam_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
230
magic/src/fold.c
230
magic/src/fold.c
|
|
@ -30,21 +30,15 @@ SDL_Surface *fold_surface_src, *fold_surface_dst;
|
|||
|
||||
|
||||
void fold_draw(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
static void fold_erase(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
static void fold_erase(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void translate_coords(SDL_Surface * canvas, int angle);
|
||||
SDL_Surface *rotate(magic_api * api, SDL_Surface * canvas, int angle);
|
||||
void fold_draw(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
static void fold_print_line(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void fold_print_dark_line(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b,
|
||||
int rotation);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
static void fold_print_line(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void fold_print_dark_line(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, int rotation);
|
||||
Uint32 fold_api_version(void);
|
||||
void fold_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
|
|
@ -56,30 +50,25 @@ int fold_get_group(magic_api * api, int which);
|
|||
char *fold_get_description(magic_api * api, int which, int mode);
|
||||
int fold_requires_colors(magic_api * api, int which);
|
||||
void fold_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void fold_shutdown(magic_api * api);
|
||||
void fold_click(magic_api * ptr, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void fold_preview(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
int fold_modes(magic_api * api, int which);
|
||||
|
||||
// Housekeeping functions
|
||||
|
||||
void fold_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void fold_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void fold_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
inline Uint8 fold_what_corner(int x, int y, SDL_Surface * canvas);
|
||||
void fold_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void fold_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
Uint8 fold_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 fold_default_size(magic_api * api, int which, int mode);
|
||||
void fold_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void fold_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 fold_api_version(void)
|
||||
{
|
||||
|
|
@ -87,7 +76,8 @@ Uint32 fold_api_version(void)
|
|||
}
|
||||
|
||||
void fold_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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
fold_r = r;
|
||||
|
|
@ -99,8 +89,7 @@ int fold_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fold.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fold.wav", api->data_directory);
|
||||
fold_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -111,48 +100,37 @@ int fold_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
|||
return 1;
|
||||
}
|
||||
|
||||
SDL_Surface *fold_get_icon(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
SDL_Surface *fold_get_icon(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fold.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fold.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *fold_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *fold_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (gettext_noop("Fold"));
|
||||
}
|
||||
|
||||
int fold_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fold_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *fold_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *fold_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Choose a background color and click to turn the corner of the page over."));
|
||||
return strdup(gettext_noop("Choose a background color and click to turn the corner of the page over."));
|
||||
}
|
||||
|
||||
int fold_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fold_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
} //selected color will be a "backpage" color
|
||||
|
||||
|
||||
static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * temp, int x,
|
||||
int y)
|
||||
static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * temp, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
Uint8 r, g, b, a;
|
||||
|
|
@ -162,14 +140,11 @@ static void fold_shadow(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
max(r - 160 + fold_shadow_value * 4,
|
||||
0),
|
||||
max(g - 160 + fold_shadow_value * 4,
|
||||
0),
|
||||
max(b - 160 + fold_shadow_value * 4,
|
||||
0), a));
|
||||
0), max(b - 160 + fold_shadow_value * 4, 0), a));
|
||||
}
|
||||
|
||||
void fold_draw(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
float right_step_x, right_step_y, left_step_x, left_step_y;
|
||||
float dist_x, dist_y;
|
||||
|
|
@ -180,17 +155,16 @@ void fold_draw(magic_api * api, int which,
|
|||
temp =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
SDL_BlitSurface(canvas, 0, temp, 0);
|
||||
|
||||
right_step_x = (float) (x - left_arm_x) / (float) (left_arm_x - fold_ox);
|
||||
right_step_y = (float) (y - left_arm_y) / (float) (left_arm_x - fold_ox);
|
||||
left_step_x = (float) (x - right_arm_x) / (float) (right_arm_y - fold_oy);
|
||||
left_step_y = (float) (y - right_arm_y) / (float) (right_arm_y - fold_oy);
|
||||
right_step_x = (float)(x - left_arm_x) / (float)(left_arm_x - fold_ox);
|
||||
right_step_y = (float)(y - left_arm_y) / (float)(left_arm_x - fold_ox);
|
||||
left_step_x = (float)(x - right_arm_x) / (float)(right_arm_y - fold_oy);
|
||||
left_step_y = (float)(y - right_arm_y) / (float)(right_arm_y - fold_oy);
|
||||
|
||||
left_y = (float) right_arm_y / left_arm_x * (left_arm_x - canvas->w);
|
||||
right_x = (float) left_arm_x / right_arm_y * (right_arm_y - canvas->h);
|
||||
left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w);
|
||||
right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h);
|
||||
|
||||
for (w = 0; w < canvas->w; w += 0.5)
|
||||
{
|
||||
|
|
@ -198,8 +172,7 @@ void fold_draw(magic_api * api, int which,
|
|||
{
|
||||
dist_x = right_step_x * w + left_step_x * h;
|
||||
dist_y = right_step_y * w + left_step_y * h;
|
||||
api->putpixel(canvas, x - dist_x, y - dist_y,
|
||||
api->getpixel(temp, w, h));
|
||||
api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,71 +181,58 @@ void fold_draw(magic_api * api, int which,
|
|||
if (left_arm_x > canvas->w)
|
||||
{
|
||||
for (h = 0; h <= right_arm_y; h++)
|
||||
api->line((void *) api, which, canvas, snapshot, canvas->w, left_y - h,
|
||||
-1, right_arm_y - h, 1, fold_erase);
|
||||
api->line((void *)api, which, canvas, snapshot, canvas->w, left_y - h, -1, right_arm_y - h, 1, fold_erase);
|
||||
}
|
||||
else if (right_arm_y > canvas->h)
|
||||
{
|
||||
for (w = 0; w <= left_arm_x; w++)
|
||||
api->line((void *) api, which, canvas, snapshot, left_arm_x - w, 0,
|
||||
right_x - w, canvas->h + 1, 1, fold_erase);
|
||||
api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, right_x - w, canvas->h + 1, 1, fold_erase);
|
||||
}
|
||||
else
|
||||
for (w = 0; w <= min(left_arm_x, right_arm_y); w++) // The -1 values are because api->line
|
||||
api->line((void *) api, which, canvas, snapshot, left_arm_x - w, 0, -1,
|
||||
right_arm_y - w, 1, fold_erase);
|
||||
api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, -1, right_arm_y - w, 1, fold_erase);
|
||||
|
||||
SDL_BlitSurface(canvas, 0, temp, 0);
|
||||
|
||||
// Shadows
|
||||
if (left_arm_x > canvas->w)
|
||||
{
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40;
|
||||
fold_shadow_value += 1)
|
||||
api->line((void *) api, which, canvas, temp, canvas->w,
|
||||
left_y - fold_shadow_value, 0,
|
||||
right_arm_y - fold_shadow_value, 1, fold_shadow);
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1)
|
||||
api->line((void *)api, which, canvas, temp, canvas->w,
|
||||
left_y - fold_shadow_value, 0, right_arm_y - fold_shadow_value, 1, fold_shadow);
|
||||
|
||||
}
|
||||
else if (right_arm_y > canvas->h)
|
||||
{
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40;
|
||||
fold_shadow_value += 1)
|
||||
api->line((void *) api, which, canvas, temp,
|
||||
left_arm_x - fold_shadow_value, 0,
|
||||
right_x - fold_shadow_value, canvas->h, 1, fold_shadow);
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1)
|
||||
api->line((void *)api, which, canvas, temp,
|
||||
left_arm_x - fold_shadow_value, 0, right_x - fold_shadow_value, canvas->h, 1, fold_shadow);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40;
|
||||
fold_shadow_value += 1)
|
||||
api->line((void *) api, which, canvas, temp,
|
||||
left_arm_x - fold_shadow_value, 0, 0,
|
||||
right_arm_y - fold_shadow_value, 1, fold_shadow);
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1)
|
||||
api->line((void *)api, which, canvas, temp,
|
||||
left_arm_x - fold_shadow_value, 0, 0, right_arm_y - fold_shadow_value, 1, fold_shadow);
|
||||
|
||||
SDL_BlitSurface(canvas, 0, temp, 0);
|
||||
|
||||
for (fold_shadow_value = 0; fold_shadow_value < 40; fold_shadow_value += 1)
|
||||
{
|
||||
if (fold_shadow_value * left_step_x > x
|
||||
|| fold_shadow_value * right_step_y > y)
|
||||
if (fold_shadow_value * left_step_x > x || fold_shadow_value * right_step_y > y)
|
||||
break;
|
||||
|
||||
dist_x = fold_shadow_value * (right_step_x + left_step_x);
|
||||
dist_y = fold_shadow_value * (right_step_y + left_step_y);
|
||||
api->line((void *) api, which, canvas, temp,
|
||||
api->line((void *)api, which, canvas, temp,
|
||||
left_arm_x + fold_shadow_value * right_step_x,
|
||||
fold_shadow_value * right_step_y,
|
||||
fold_shadow_value * left_step_x,
|
||||
right_arm_y + fold_shadow_value * left_step_y, 1, fold_shadow);
|
||||
fold_shadow_value * left_step_x, right_arm_y + fold_shadow_value * left_step_y, 1, fold_shadow);
|
||||
}
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, x, y, right_arm_x,
|
||||
right_arm_y, 1, fold_print_line);
|
||||
api->line((void *) api, which, canvas, snapshot, x, y, left_arm_x,
|
||||
left_arm_y, 1, fold_print_line);
|
||||
api->line((void *) api, which, canvas, snapshot, left_arm_x, left_arm_y,
|
||||
api->line((void *)api, which, canvas, snapshot, x, y, right_arm_x, right_arm_y, 1, fold_print_line);
|
||||
api->line((void *)api, which, canvas, snapshot, x, y, left_arm_x, left_arm_y, 1, fold_print_line);
|
||||
api->line((void *)api, which, canvas, snapshot, left_arm_x, left_arm_y,
|
||||
right_arm_x, right_arm_y, 1, fold_print_dark_line);
|
||||
|
||||
}
|
||||
|
|
@ -287,14 +247,12 @@ SDL_Surface *rotate(magic_api * api, SDL_Surface * canvas, int angle)
|
|||
temp =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
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);
|
||||
else
|
||||
temp =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->h, canvas->w,
|
||||
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);
|
||||
|
||||
switch (angle)
|
||||
{
|
||||
|
|
@ -361,8 +319,7 @@ void translate_coords(SDL_Surface * canvas, int angle)
|
|||
}
|
||||
}
|
||||
|
||||
void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b,
|
||||
int rotation)
|
||||
void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b, int rotation)
|
||||
{
|
||||
switch (rotation)
|
||||
{
|
||||
|
|
@ -382,8 +339,7 @@ void translate_xy(SDL_Surface * canvas, int x, int y, int *a, int *b,
|
|||
}
|
||||
|
||||
void fold_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int a, b;
|
||||
SDL_Surface *temp, *temp2;
|
||||
|
|
@ -467,8 +423,7 @@ inline Uint8 fold_what_corner(int x, int y, SDL_Surface * canvas)
|
|||
|
||||
|
||||
static void fold_print_line(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x,
|
||||
int y)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -476,9 +431,7 @@ static void fold_print_line(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
static void fold_print_dark_line(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;
|
||||
|
||||
|
|
@ -486,18 +439,15 @@ static void fold_print_dark_line(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
static void fold_erase(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;
|
||||
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, fold_r, fold_g, fold_b));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, fold_r, fold_g, fold_b));
|
||||
}
|
||||
|
||||
void fold_click(magic_api * ptr, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -527,8 +477,7 @@ void fold_click(magic_api * ptr, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
void fold_preview(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int middle_point_x;
|
||||
int middle_point_y;
|
||||
|
|
@ -543,67 +492,49 @@ void fold_preview(magic_api * api, int which, SDL_Surface * canvas,
|
|||
switch (corner)
|
||||
{
|
||||
case 1: //Right Upper
|
||||
right_arm_x =
|
||||
fold_ox - (fold_ox - middle_point_x) -
|
||||
middle_point_y * middle_point_y / (fold_ox - middle_point_x);
|
||||
right_arm_x = fold_ox - (fold_ox - middle_point_x) - middle_point_y * middle_point_y / (fold_ox - middle_point_x);
|
||||
right_arm_y = fold_oy;
|
||||
|
||||
left_arm_x = fold_ox;
|
||||
left_arm_y =
|
||||
fold_oy - (fold_oy - middle_point_y) - (fold_ox -
|
||||
middle_point_x) * (fold_ox -
|
||||
middle_point_x)
|
||||
/ (fold_oy - middle_point_y);
|
||||
middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y);
|
||||
break;
|
||||
|
||||
case 2: //LU
|
||||
right_arm_x = fold_ox;
|
||||
right_arm_y =
|
||||
middle_point_y + middle_point_x * middle_point_x / middle_point_y;
|
||||
right_arm_y = middle_point_y + middle_point_x * middle_point_x / middle_point_y;
|
||||
|
||||
left_arm_x =
|
||||
middle_point_x + middle_point_y * middle_point_y / middle_point_x;
|
||||
left_arm_x = middle_point_x + middle_point_y * middle_point_y / middle_point_x;
|
||||
left_arm_y = fold_oy;
|
||||
break;
|
||||
|
||||
case 3: //LL
|
||||
right_arm_x =
|
||||
middle_point_x + (fold_oy - middle_point_y) * (fold_oy -
|
||||
middle_point_y) /
|
||||
middle_point_x;
|
||||
right_arm_x = middle_point_x + (fold_oy - middle_point_y) * (fold_oy - middle_point_y) / middle_point_x;
|
||||
right_arm_y = fold_oy;
|
||||
|
||||
left_arm_x = fold_ox;
|
||||
left_arm_y =
|
||||
fold_oy - (fold_oy - middle_point_y) - (fold_ox -
|
||||
middle_point_x) * (fold_ox -
|
||||
middle_point_x)
|
||||
/ (fold_oy - middle_point_y);
|
||||
middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y);
|
||||
break;
|
||||
|
||||
case 4: //RL
|
||||
right_arm_x = fold_ox;
|
||||
right_arm_y =
|
||||
fold_oy - (fold_oy - middle_point_y) - (fold_ox -
|
||||
middle_point_x) * (fold_ox -
|
||||
middle_point_x)
|
||||
/ (fold_oy - middle_point_y);
|
||||
middle_point_x) * (fold_ox - middle_point_x) / (fold_oy - middle_point_y);
|
||||
|
||||
left_arm_x =
|
||||
fold_ox - (fold_ox - middle_point_x) - (fold_oy -
|
||||
middle_point_y) * (fold_oy -
|
||||
middle_point_y)
|
||||
/ (fold_ox - middle_point_x);
|
||||
middle_point_y) * (fold_oy - middle_point_y) / (fold_ox - middle_point_x);
|
||||
left_arm_y = fold_oy;
|
||||
break;
|
||||
}
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, x, y, right_arm_x,
|
||||
right_arm_y, 1, fold_print_line);
|
||||
api->line((void *) api, which, canvas, snapshot, x, y, left_arm_x,
|
||||
left_arm_y, 1, fold_print_line);
|
||||
api->line((void *) api, which, canvas, snapshot, left_arm_x, left_arm_y,
|
||||
right_arm_x, right_arm_y, 1, fold_print_line);
|
||||
api->line((void *)api, which, canvas, snapshot, x, y, right_arm_x, right_arm_y, 1, fold_print_line);
|
||||
api->line((void *)api, which, canvas, snapshot, x, y, left_arm_x, left_arm_y, 1, fold_print_line);
|
||||
api->line((void *)api, which, canvas, snapshot, left_arm_x, left_arm_y, right_arm_x, right_arm_y, 1, fold_print_line);
|
||||
|
||||
update_rect->x = update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
|
|
@ -611,8 +542,7 @@ void fold_preview(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void fold_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
// Avoid division by zero when calculating the preview
|
||||
x = clamp(2, x, canvas->w - 2);
|
||||
|
|
@ -621,14 +551,12 @@ void fold_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void fold_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void fold_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -648,6 +576,8 @@ Uint8 fold_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 0;
|
||||
}
|
||||
|
||||
void fold_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 fold_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ static unsigned int fretwork_update_rectangle_width; //the width of the updat
|
|||
static unsigned int fretwork_update_rectangle_height; //the height of the update_rectangle
|
||||
static SDL_Rect modification_rect;
|
||||
static SDL_Surface *canvas_backup;
|
||||
static SDL_Surface *fretwork_one_back, *fretwork_three_back,
|
||||
*fretwork_four_back, *fretwork_corner_back;
|
||||
static SDL_Surface *fretwork_one_back, *fretwork_three_back, *fretwork_four_back, *fretwork_corner_back;
|
||||
|
||||
|
||||
// Housekeeping functions
|
||||
|
|
@ -59,8 +58,7 @@ Uint32 fretwork_api_version(void);
|
|||
int fretwork_modes(magic_api * api, int which);
|
||||
void fretwork_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
static void fretwork_colorize(magic_api * api, SDL_Surface * dest,
|
||||
SDL_Surface * src);
|
||||
static void fretwork_colorize(magic_api * api, SDL_Surface * dest, SDL_Surface * src);
|
||||
int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED);
|
||||
int fretwork_get_tool_count(magic_api * api);
|
||||
SDL_Surface *fretwork_get_icon(magic_api * api, int which);
|
||||
|
|
@ -69,32 +67,26 @@ int fretwork_get_group(magic_api * api, int which);
|
|||
char *fretwork_get_description(magic_api * api, int which, int mode);
|
||||
int fretwork_requires_colors(magic_api * api, int which);
|
||||
void fretwork_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void fretwork_shutdown(magic_api * api);
|
||||
void fretwork_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void fretwork_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void fretwork_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void fretwork_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
|
||||
#define POINT_TYPE typeof(((SDL_Rect *)NULL)->x)
|
||||
inline void fretwork_extract_coords_from_segment(unsigned int segment,
|
||||
POINT_TYPE * x,
|
||||
POINT_TYPE * y);
|
||||
inline void fretwork_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y);
|
||||
void fretwork_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
void fretwork_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
inline unsigned int fretwork_get_segment(int x, int y);
|
||||
Uint8 fretwork_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 fretwork_default_size(magic_api * api, int which, int mode);
|
||||
void fretwork_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void fretwork_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
SDL_Surface *fretwork_one, *fretwork_three, *fretwork_four, *fretwork_corner;
|
||||
|
|
@ -104,14 +96,14 @@ Uint32 fretwork_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
int fretwork_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fretwork_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
void fretwork_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fretwork_r = r;
|
||||
fretwork_g = g;
|
||||
|
|
@ -123,8 +115,7 @@ void fretwork_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface
|
|||
}
|
||||
|
||||
/* Adapted from flower.c */
|
||||
static void fretwork_colorize(magic_api * api, SDL_Surface * dest,
|
||||
SDL_Surface * src)
|
||||
static void fretwork_colorize(magic_api * api, SDL_Surface * dest, SDL_Surface * src)
|
||||
{
|
||||
int x, y;
|
||||
Uint8 r, g, b, a;
|
||||
|
|
@ -138,9 +129,7 @@ static void fretwork_colorize(magic_api * api, SDL_Surface * dest,
|
|||
{
|
||||
SDL_GetRGBA(api->getpixel(src, x, y), src->format, &r, &g, &b, &a);
|
||||
|
||||
api->putpixel(dest, x, y,
|
||||
SDL_MapRGBA(dest->format, fretwork_r, fretwork_g,
|
||||
fretwork_b, a));
|
||||
api->putpixel(dest, x, y, SDL_MapRGBA(dest->format, fretwork_r, fretwork_g, fretwork_b, a));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,19 +143,15 @@ int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
char fname[1024];
|
||||
Uint8 i; //is always < 4, so Uint8 seems to be a good idea
|
||||
|
||||
fretwork_images = (char **) malloc(sizeof(char *) * 4);
|
||||
fretwork_images = (char **)malloc(sizeof(char *) * 4);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
fretwork_images[i] = (char *) malloc(sizeof(char) * 1024);
|
||||
fretwork_images[i] = (char *)malloc(sizeof(char) * 1024);
|
||||
|
||||
snprintf(fretwork_images[0], 1024 * sizeof(char),
|
||||
"%simages/magic/fretwork_one.png", api->data_directory);
|
||||
snprintf(fretwork_images[1], 1024 * sizeof(char),
|
||||
"%simages/magic/fretwork_three.png", api->data_directory);
|
||||
snprintf(fretwork_images[2], 1024 * sizeof(char),
|
||||
"%simages/magic/fretwork_four.png", api->data_directory);
|
||||
snprintf(fretwork_images[3], 1024 * sizeof(char),
|
||||
"%simages/magic/fretwork_corner.png", api->data_directory);
|
||||
snprintf(fretwork_images[0], 1024 * sizeof(char), "%simages/magic/fretwork_one.png", api->data_directory);
|
||||
snprintf(fretwork_images[1], 1024 * sizeof(char), "%simages/magic/fretwork_three.png", api->data_directory);
|
||||
snprintf(fretwork_images[2], 1024 * sizeof(char), "%simages/magic/fretwork_four.png", api->data_directory);
|
||||
snprintf(fretwork_images[3], 1024 * sizeof(char), "%simages/magic/fretwork_corner.png", api->data_directory);
|
||||
|
||||
fretwork_one = IMG_Load(fretwork_images[0]);
|
||||
fretwork_three = IMG_Load(fretwork_images[1]);
|
||||
|
|
@ -180,8 +165,7 @@ int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
img_w = fretwork_one->w;
|
||||
img_h = fretwork_one->h;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fretwork.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/fretwork.ogg", api->data_directory);
|
||||
fretwork_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -196,38 +180,30 @@ SDL_Surface *fretwork_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fretwork.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/fretwork.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
int fretwork_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fretwork_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
char *fretwork_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *fretwork_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Fretwork"));
|
||||
}
|
||||
|
||||
char *fretwork_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *fretwork_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return
|
||||
strdup(gettext_noop("Click and drag to draw repetitive patterns."));
|
||||
return strdup(gettext_noop("Click and drag to draw repetitive patterns."));
|
||||
else
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click to surround your picture with repetitive patterns."));
|
||||
return strdup(gettext_noop("Click to surround your picture with repetitive patterns."));
|
||||
}
|
||||
|
||||
int fretwork_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int fretwork_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -236,8 +212,7 @@ void fretwork_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -266,16 +241,14 @@ void fretwork_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void fretwork_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
{
|
||||
//we've to compute the quantity of segments in each direction
|
||||
|
||||
canvas_backup =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
SDL_BlitSurface(canvas, NULL, canvas_backup, NULL);
|
||||
fretwork_segments_x = fretwork_math_ceil(canvas->w, img_w);
|
||||
|
|
@ -287,8 +260,7 @@ void fretwork_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
void fretwork_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
{
|
||||
free(fretwork_status_of_segments);
|
||||
fretwork_status_of_segments = NULL;
|
||||
|
|
@ -301,7 +273,7 @@ inline int fretwork_math_ceil(int x, int y)
|
|||
{
|
||||
int temp;
|
||||
|
||||
temp = (int) x / y;
|
||||
temp = (int)x / y;
|
||||
if (x % y)
|
||||
return temp + 1;
|
||||
else
|
||||
|
|
@ -320,12 +292,10 @@ inline unsigned int fretwork_get_segment(int x, int y)
|
|||
return (yy - 1) * fretwork_segments_x + xx;
|
||||
}
|
||||
|
||||
inline void fretwork_extract_coords_from_segment(unsigned int segment,
|
||||
POINT_TYPE * x,
|
||||
POINT_TYPE * y)
|
||||
inline void fretwork_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y)
|
||||
{
|
||||
*x = ((segment % fretwork_segments_x) - 1) * img_w; //useful to set update_rect as small as possible
|
||||
*y = (int) (segment / fretwork_segments_x) * img_h;
|
||||
*y = (int)(segment / fretwork_segments_x) * img_h;
|
||||
}
|
||||
|
||||
/* static void fretwork_flip(void * ptr, SDL_Surface * dest, SDL_Surface * src) */
|
||||
|
|
@ -339,20 +309,17 @@ inline void fretwork_extract_coords_from_segment(unsigned int segment,
|
|||
/* api->putpixel(dest, x, y, api->getpixel(src, x, src->h-y)); */
|
||||
/* } */
|
||||
|
||||
static void fretwork_flip_flop(void *ptr, SDL_Surface * dest,
|
||||
SDL_Surface * src)
|
||||
static void fretwork_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
POINT_TYPE x, y;
|
||||
|
||||
for (x = 0; x < dest->w; x++)
|
||||
for (y = 0; y < dest->h; y++)
|
||||
api->putpixel(dest, dest->w - 1 - x, dest->h - 1 - y,
|
||||
api->getpixel(src, x, y));
|
||||
api->putpixel(dest, dest->w - 1 - x, dest->h - 1 - y, api->getpixel(src, x, y));
|
||||
}
|
||||
|
||||
static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src,
|
||||
_Bool direction)
|
||||
static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, _Bool direction)
|
||||
//src and dest must have same size
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -375,8 +342,7 @@ static void fretwork_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src,
|
|||
|
||||
|
||||
void fretwork_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int left_x, right_x, top_y, bottom_y;
|
||||
|
||||
|
|
@ -388,29 +354,26 @@ void fretwork_click(magic_api * api, int which, int mode,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (fretwork_full_runs <=
|
||||
min(fretwork_segments_x, fretwork_segments_y) / 2)
|
||||
if (fretwork_full_runs <= min(fretwork_segments_x, fretwork_segments_y) / 2)
|
||||
{
|
||||
left_x = img_w * fretwork_full_runs;
|
||||
right_x = img_w * fretwork_segments_x - img_w * fretwork_full_runs;
|
||||
top_y = img_h * fretwork_full_runs;
|
||||
bottom_y =
|
||||
img_h * fretwork_segments_y - img_h * (fretwork_full_runs - 1);
|
||||
bottom_y = img_h * fretwork_segments_y - img_h * (fretwork_full_runs - 1);
|
||||
|
||||
//left line
|
||||
api->line((void *) api, which, canvas, snapshot, left_x, top_y, left_x,
|
||||
api->line((void *)api, which, canvas, snapshot, left_x, top_y, left_x,
|
||||
bottom_y, img_w / 2, fretwork_draw_wrapper);
|
||||
|
||||
//top line
|
||||
api->line((void *) api, which, canvas, snapshot, left_x, top_y, right_x,
|
||||
top_y, img_w / 2, fretwork_draw_wrapper);
|
||||
api->line((void *)api, which, canvas, snapshot, left_x, top_y, right_x, top_y, img_w / 2, fretwork_draw_wrapper);
|
||||
|
||||
//bottom line
|
||||
api->line((void *) api, which, canvas, snapshot, left_x, bottom_y,
|
||||
api->line((void *)api, which, canvas, snapshot, left_x, bottom_y,
|
||||
right_x, bottom_y, img_w / 2, fretwork_draw_wrapper);
|
||||
|
||||
//right line
|
||||
api->line((void *) api, which, canvas, snapshot, right_x, top_y,
|
||||
api->line((void *)api, which, canvas, snapshot, right_x, top_y,
|
||||
right_x, bottom_y, img_w / 2, fretwork_draw_wrapper);
|
||||
|
||||
fretwork_full_runs += 1;
|
||||
|
|
@ -427,8 +390,7 @@ static Uint8 fretwork_select_image(Uint16 segment)
|
|||
int take_up, take_down;
|
||||
int val_up, val_down, val_left, val_right;
|
||||
int from_top = 0, from_bottom = 0, from_left = 0, from_right = 0;
|
||||
int from_top_right = 0, from_top_left = 0, from_bottom_right =
|
||||
0, from_bottom_left = 0;
|
||||
int from_top_right = 0, from_top_left = 0, from_bottom_right = 0, from_bottom_left = 0;
|
||||
int TOP = 0, BOTTOM = 0, LEFT = 0, RIGHT = 0;
|
||||
|
||||
//Checking from were we come...
|
||||
|
|
@ -445,26 +407,22 @@ static Uint8 fretwork_select_image(Uint16 segment)
|
|||
|
||||
// Very very few cases will reach this, segments are joining by the corner
|
||||
// We need to add a new segment to join by side, adding clockwise
|
||||
else if (segment ==
|
||||
fretwork_segment_modified_last + fretwork_segments_x + 1)
|
||||
else if (segment == fretwork_segment_modified_last + fretwork_segments_x + 1)
|
||||
{
|
||||
from_top_left = 1;
|
||||
fretwork_segment_to_add = segment - fretwork_segments_x;
|
||||
}
|
||||
else if (segment ==
|
||||
fretwork_segment_modified_last + fretwork_segments_x - 1)
|
||||
else if (segment == fretwork_segment_modified_last + fretwork_segments_x - 1)
|
||||
{
|
||||
from_top_right = 1;
|
||||
fretwork_segment_to_add = segment + 1;
|
||||
}
|
||||
else if (segment ==
|
||||
fretwork_segment_modified_last - fretwork_segments_x - 1)
|
||||
else if (segment == fretwork_segment_modified_last - fretwork_segments_x - 1)
|
||||
{
|
||||
from_bottom_right = 1;
|
||||
fretwork_segment_to_add = segment + fretwork_segments_x;
|
||||
}
|
||||
else if (segment ==
|
||||
fretwork_segment_modified_last - fretwork_segments_x + 1)
|
||||
else if (segment == fretwork_segment_modified_last - fretwork_segments_x + 1)
|
||||
{
|
||||
from_bottom_left = 1;
|
||||
fretwork_segment_to_add = segment - 1;
|
||||
|
|
@ -478,7 +436,7 @@ static Uint8 fretwork_select_image(Uint16 segment)
|
|||
val_up = fretwork_status_of_segments[take_up];
|
||||
|
||||
take_down = segment + fretwork_segments_x;
|
||||
if (take_down > (signed) (fretwork_segments_x * fretwork_segments_y))
|
||||
if (take_down > (signed)(fretwork_segments_x * fretwork_segments_y))
|
||||
val_down = SEG_NONE;
|
||||
else
|
||||
val_down = fretwork_status_of_segments[take_down];
|
||||
|
|
@ -536,8 +494,7 @@ static Uint8 fretwork_select_image(Uint16 segment)
|
|||
|
||||
static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x,
|
||||
int y ATTRIBUTE_UNUSED, unsigned int segment)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y ATTRIBUTE_UNUSED, unsigned int segment)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
SDL_Surface *result, *temp;
|
||||
|
|
@ -547,8 +504,7 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
use_temp = 0;
|
||||
if ((segment < 1) | (segment > fretwork_segments_x * fretwork_segments_y))
|
||||
return;
|
||||
fretwork_extract_coords_from_segment(segment, &modification_rect.x,
|
||||
&modification_rect.y);
|
||||
fretwork_extract_coords_from_segment(segment, &modification_rect.x, &modification_rect.y);
|
||||
modification_rect.h = img_w;
|
||||
modification_rect.w = img_h;
|
||||
|
||||
|
|
@ -563,17 +519,13 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
SDL_CreateRGBSurface(SDL_SWSURFACE, img_w, img_h,
|
||||
fretwork_one->format->BitsPerPixel,
|
||||
fretwork_one->format->Rmask,
|
||||
fretwork_one->format->Gmask,
|
||||
fretwork_one->format->Bmask,
|
||||
fretwork_one->format->Amask);
|
||||
fretwork_one->format->Gmask, fretwork_one->format->Bmask, fretwork_one->format->Amask);
|
||||
|
||||
temp =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, img_w, img_h,
|
||||
fretwork_one->format->BitsPerPixel,
|
||||
fretwork_one->format->Rmask,
|
||||
fretwork_one->format->Gmask,
|
||||
fretwork_one->format->Bmask,
|
||||
fretwork_one->format->Amask);
|
||||
fretwork_one->format->Gmask, fretwork_one->format->Bmask, fretwork_one->format->Amask);
|
||||
|
||||
SDL_BlitSurface(canvas_backup, &modification_rect, result, NULL);
|
||||
|
||||
|
|
@ -645,32 +597,25 @@ static void fretwork_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
|
||||
static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
fretwork_segment_modified = fretwork_get_segment(x, y);
|
||||
|
||||
fretwork_draw((void *) ptr, which, canvas, last, x, y,
|
||||
fretwork_segment_modified);
|
||||
fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified);
|
||||
|
||||
if (fretwork_segment_modified_last > 0)
|
||||
|
||||
{
|
||||
fretwork_draw((void *) ptr, which, canvas, last, x, y,
|
||||
fretwork_segment_modified_last);
|
||||
fretwork_extract_coords_from_segment(fretwork_segment_start_rectangle,
|
||||
&modification_rect.x,
|
||||
&modification_rect.y);
|
||||
fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified_last);
|
||||
fretwork_extract_coords_from_segment(fretwork_segment_start_rectangle, &modification_rect.x, &modification_rect.y);
|
||||
modification_rect.w = fretwork_update_rectangle_width * img_w;
|
||||
modification_rect.h = fretwork_update_rectangle_height * img_h;
|
||||
}
|
||||
|
||||
if (fretwork_segment_to_add > 0)
|
||||
{
|
||||
fretwork_draw((void *) ptr, which, canvas, last, x, y,
|
||||
fretwork_segment_to_add);
|
||||
fretwork_draw((void *) ptr, which, canvas, last, x, y,
|
||||
fretwork_segment_modified_last);
|
||||
fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_to_add);
|
||||
fretwork_draw((void *)ptr, which, canvas, last, x, y, fretwork_segment_modified_last);
|
||||
fretwork_segment_to_add = 0;
|
||||
}
|
||||
|
||||
|
|
@ -678,17 +623,14 @@ static void fretwork_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void fretwork_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int ox,
|
||||
int oy, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int start_x, end_x, start_y, end_y, segment_start, segment_end, w, h;
|
||||
|
||||
if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w)
|
||||
&& (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0)
|
||||
&& ((signed) ox > 0) && ((signed) oy > 0))
|
||||
&& (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0))
|
||||
{
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, img_w / 2,
|
||||
fretwork_draw_wrapper);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, fretwork_draw_wrapper);
|
||||
// This should be improved, maybe passed to fretwork_draw()
|
||||
start_x = min(ox, x);
|
||||
end_x = max(ox, x);
|
||||
|
|
@ -698,9 +640,9 @@ void fretwork_drag(magic_api * api, int which,
|
|||
segment_end = fretwork_get_segment(end_x + img_w, end_y + img_h);
|
||||
|
||||
x = ((segment_start % fretwork_segments_x) - 1) * img_w;
|
||||
y = (int) (segment_start / fretwork_segments_x) * img_h;
|
||||
y = (int)(segment_start / fretwork_segments_x) * img_h;
|
||||
w = ((segment_end % fretwork_segments_x) - 1) * img_w - x + img_w;
|
||||
h = (int) (segment_end / fretwork_segments_x) * img_h - y + img_h;
|
||||
h = (int)(segment_end / fretwork_segments_x) * img_h - y + img_h;
|
||||
|
||||
update_rect->x = x;
|
||||
update_rect->y = y;
|
||||
|
|
@ -719,6 +661,8 @@ Uint8 fretwork_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 0;
|
||||
}
|
||||
|
||||
void fretwork_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 fretwork_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,29 +48,24 @@ SDL_Surface *glasstile_get_icon(magic_api * api, int which);
|
|||
char *glasstile_get_name(magic_api * api, int which);
|
||||
int glasstile_get_group(magic_api * api, int which);
|
||||
char *glasstile_get_description(magic_api * api, int which, int mode);
|
||||
static void do_glasstile(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_glasstile(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void glasstile_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 glasstile_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 glasstile_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void glasstile_shutdown(magic_api * api);
|
||||
void glasstile_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int glasstile_requires_colors(magic_api * api, int which);
|
||||
void glasstile_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void glasstile_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void glasstile_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void glasstile_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int glasstile_modes(magic_api * api, int which);
|
||||
Uint8 glasstile_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 glasstile_default_size(magic_api * api, int which, int mode);
|
||||
void glasstile_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void glasstile_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 glasstile_api_version(void)
|
||||
|
|
@ -87,8 +82,7 @@ int glasstile_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/glasstile.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/glasstile.ogg", api->data_directory);
|
||||
glasstile_snd = Mix_LoadWAV(fname);
|
||||
|
||||
glasstile_hit = NULL;
|
||||
|
|
@ -108,45 +102,35 @@ SDL_Surface *glasstile_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/glasstile.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/glasstile.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *glasstile_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *glasstile_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Glass Tile")));
|
||||
}
|
||||
|
||||
// Return our groups
|
||||
int glasstile_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int glasstile_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *glasstile_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *glasstile_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to put glass tile over your picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to put glass tile over your picture.")));
|
||||
else
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click to cover your entire picture in glass tiles.")));
|
||||
return (strdup(gettext_noop("Click to cover your entire picture in glass tiles.")));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
|
||||
static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x,
|
||||
int y)
|
||||
static void do_glasstile(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, xl, xr, yt, yb;
|
||||
|
|
@ -180,14 +164,10 @@ static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
for (xx = -GT_SIZE; xx < GT_SIZE; xx = xx + 2)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r1, &g1,
|
||||
&b1);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy), last->format, &r2,
|
||||
&g2, &b2);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy + 1), last->format, &r3,
|
||||
&g3, &b3);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy + 1), last->format,
|
||||
&r4, &g4, &b4);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy), last->format, &r2, &g2, &b2);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy + 1), last->format, &r3, &g3, &b3);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx + 1, y + yy + 1), last->format, &r4, &g4, &b4);
|
||||
|
||||
r = (r1 + r2 + r3 + r4) >> 2;
|
||||
g = (g1 + g2 + g3 + g4) >> 2;
|
||||
|
|
@ -233,10 +213,9 @@ static void do_glasstile(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void glasstile_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_glasstile);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_glasstile);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -269,8 +248,7 @@ void glasstile_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void glasstile_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)
|
||||
{
|
||||
int xx, yy;
|
||||
|
||||
|
|
@ -279,10 +257,10 @@ void glasstile_click(magic_api * api, int which, int mode,
|
|||
glasstile_hit_ysize = (canvas->h / GT_SIZE) + 1;
|
||||
glasstile_hit_xsize = (canvas->w / GT_SIZE) + 1;
|
||||
|
||||
glasstile_hit = (int * *) malloc(sizeof(int *) * glasstile_hit_ysize);
|
||||
glasstile_hit = (int * *)malloc(sizeof(int *) * glasstile_hit_ysize);
|
||||
|
||||
for (yy = 0; yy < glasstile_hit_ysize; yy++)
|
||||
glasstile_hit[yy] = (int *) malloc(sizeof(int) * glasstile_hit_xsize);
|
||||
glasstile_hit[yy] = (int *)malloc(sizeof(int) * glasstile_hit_xsize);
|
||||
}
|
||||
|
||||
for (yy = 0; yy < glasstile_hit_ysize; yy++)
|
||||
|
|
@ -311,8 +289,7 @@ void glasstile_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -336,33 +313,30 @@ void glasstile_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void glasstile_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void glasstile_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int glasstile_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int glasstile_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void glasstile_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void glasstile_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int glasstile_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int glasstile_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
|
@ -379,6 +353,8 @@ Uint8 glasstile_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU
|
|||
return 0;
|
||||
}
|
||||
|
||||
void glasstile_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 glasstile_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,12 +19,14 @@
|
|||
|
||||
#define NUM_SIZES 2
|
||||
int sizes[NUM_SIZES] = { 100, 50 };
|
||||
char * googlyeyes_descr[NUM_SIZES] = {
|
||||
|
||||
char *googlyeyes_descr[NUM_SIZES] = {
|
||||
gettext_noop("Click to place a large googly eye, then drag and release to make it look that direction."),
|
||||
gettext_noop("Click to place a small googly eye, then drag and release to make it look that direction."),
|
||||
};
|
||||
char * img_filenames[NUM_SIZES] = {
|
||||
"googlyeyes.png", // Also used with magic sizes
|
||||
|
||||
char *img_filenames[NUM_SIZES] = {
|
||||
"googlyeyes.png", // Also used with magic sizes
|
||||
"googlyeyes-sm.png"
|
||||
};
|
||||
|
||||
|
|
@ -34,9 +36,9 @@ int googlyeyes_limited = 0;
|
|||
int googlyeyes_sizes;
|
||||
int googlyeyes_size;
|
||||
Mix_Chunk *snd_effect = NULL;
|
||||
SDL_Surface * * googlyeyes_img_bkgd = NULL;
|
||||
SDL_Surface * * googlyeyes_img_pupil = NULL;
|
||||
SDL_Surface * * googlyeyes_img_reflection = NULL;
|
||||
SDL_Surface **googlyeyes_img_bkgd = NULL;
|
||||
SDL_Surface **googlyeyes_img_pupil = NULL;
|
||||
SDL_Surface **googlyeyes_img_reflection = NULL;
|
||||
int eye_x, eye_y;
|
||||
|
||||
Uint32 googlyeyes_api_version(void);
|
||||
|
|
@ -48,27 +50,22 @@ int googlyeyes_get_group(magic_api * api, int which);
|
|||
char *googlyeyes_get_description(magic_api * api, int which, int mode);
|
||||
int googlyeyes_requires_colors(magic_api * api, int which);
|
||||
int googlyeyes_modes(magic_api * api, int which);
|
||||
Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 googlyeyes_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
void googlyeyes_shutdown(magic_api * api);
|
||||
void googlyeyes_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void googlyeyes_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void googlyeyes_set_size(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
Uint8 sz, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * last, Uint8 sz, SDL_Rect * update_rect);
|
||||
void googlyeyes_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void googlyeyes_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void googlyeyes_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void googlyeyes_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void googlyeyes_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void googlyeyes_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
||||
|
||||
Uint32 googlyeyes_api_version(void)
|
||||
|
|
@ -84,30 +81,32 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features)
|
|||
googlyeyes_limited = (disabled_features & MAGIC_FEATURE_SIZE);
|
||||
|
||||
/* Load sound effect */
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/googlyeyes.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/googlyeyes.ogg", api->data_directory);
|
||||
snd_effect = Mix_LoadWAV(fname);
|
||||
|
||||
/* Init the images */
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
googlyeyes_sizes = NUM_SIZES;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
googlyeyes_sizes = NUM_SCALEABLE_SIZES;
|
||||
}
|
||||
|
||||
googlyeyes_img_bkgd = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
googlyeyes_img_pupil = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
googlyeyes_img_reflection = (SDL_Surface * *) malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
googlyeyes_img_bkgd = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
googlyeyes_img_pupil = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
googlyeyes_img_reflection = (SDL_Surface * *)malloc(sizeof(SDL_Surface *) * googlyeyes_sizes);
|
||||
|
||||
for (i = 0; i < googlyeyes_sizes; i++) {
|
||||
for (i = 0; i < googlyeyes_sizes; i++)
|
||||
{
|
||||
googlyeyes_img_bkgd[i] = NULL;
|
||||
googlyeyes_img_pupil[i] = NULL;
|
||||
googlyeyes_img_reflection[i] = NULL;
|
||||
}
|
||||
|
||||
/* Load the base images (100% scale) */
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-bkgd.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-bkgd.png", api->data_directory);
|
||||
googlyeyes_img_bkgd[0] = IMG_Load(fname);
|
||||
if (googlyeyes_img_bkgd[0] == NULL)
|
||||
{
|
||||
|
|
@ -115,8 +114,7 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features)
|
|||
return 0;
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-pupil.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-pupil.png", api->data_directory);
|
||||
googlyeyes_img_pupil[0] = IMG_Load(fname);
|
||||
if (googlyeyes_img_pupil[0] == NULL)
|
||||
{
|
||||
|
|
@ -124,8 +122,7 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features)
|
|||
return 0;
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-reflection.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/googly-eyes-reflection.png", api->data_directory);
|
||||
googlyeyes_img_reflection[0] = IMG_Load(fname);
|
||||
if (googlyeyes_img_reflection[0] == NULL)
|
||||
{
|
||||
|
|
@ -134,43 +131,47 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features)
|
|||
}
|
||||
|
||||
/* Create the scaled versions */
|
||||
for (i = 1; i < googlyeyes_sizes; i++) {
|
||||
for (i = 1; i < googlyeyes_sizes; i++)
|
||||
{
|
||||
int size;
|
||||
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
size = sizes[i];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size = (100 * (googlyeyes_sizes - i)) / googlyeyes_sizes;
|
||||
}
|
||||
|
||||
googlyeyes_img_bkgd[i] = api->scale(googlyeyes_img_bkgd[0],
|
||||
(googlyeyes_img_bkgd[0]->w * size) / 100,
|
||||
(googlyeyes_img_bkgd[0]->h * size) / 100,
|
||||
1);
|
||||
(googlyeyes_img_bkgd[0]->h * size) / 100, 1);
|
||||
|
||||
if (googlyeyes_img_bkgd[i] == NULL) {
|
||||
if (googlyeyes_img_bkgd[i] == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale bkgd to %d%%", size);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
googlyeyes_img_pupil[i] = api->scale(googlyeyes_img_pupil[0],
|
||||
(googlyeyes_img_pupil[0]->w * size) / 100,
|
||||
(googlyeyes_img_pupil[0]->h * size) / 100,
|
||||
1);
|
||||
(googlyeyes_img_pupil[0]->w * size) / 100,
|
||||
(googlyeyes_img_pupil[0]->h * size) / 100, 1);
|
||||
|
||||
if (googlyeyes_img_pupil[i] == NULL) {
|
||||
if (googlyeyes_img_pupil[i] == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale pupil to %d%%", size);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
googlyeyes_img_reflection[i] = api->scale(googlyeyes_img_reflection[0],
|
||||
(googlyeyes_img_reflection[0]->w * size) / 100,
|
||||
(googlyeyes_img_reflection[0]->h * size) / 100,
|
||||
1);
|
||||
(googlyeyes_img_reflection[0]->w * size) / 100,
|
||||
(googlyeyes_img_reflection[0]->h * size) / 100, 1);
|
||||
|
||||
if (googlyeyes_img_reflection[i] == NULL) {
|
||||
if (googlyeyes_img_reflection[i] == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale reflection to %d%%", size);
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,9 +180,12 @@ int googlyeyes_init(magic_api * api, Uint32 disabled_features)
|
|||
|
||||
int googlyeyes_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
return (NUM_SIZES);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -191,52 +195,52 @@ SDL_Surface *googlyeyes_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, img_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, img_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *googlyeyes_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *googlyeyes_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext("Googly Eyes"));
|
||||
}
|
||||
|
||||
int googlyeyes_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int googlyeyes_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
char *googlyeyes_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
return strdup(gettext(googlyeyes_descr[which]));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return strdup(gettext_noop("Click to place a googly eye, then drag and release to make it look that direction."));
|
||||
}
|
||||
}
|
||||
|
||||
int googlyeyes_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int googlyeyes_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int googlyeyes_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int googlyeyes_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
||||
Uint8 googlyeyes_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return NUM_SCALEABLE_SIZES;
|
||||
}
|
||||
}
|
||||
|
|
@ -253,7 +257,8 @@ void googlyeyes_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
if (snd_effect != NULL)
|
||||
Mix_FreeChunk(snd_effect);
|
||||
|
||||
for (i = 0; i < googlyeyes_sizes; i++) {
|
||||
for (i = 0; i < googlyeyes_sizes; i++)
|
||||
{
|
||||
if (googlyeyes_img_bkgd[i] != NULL)
|
||||
SDL_FreeSurface(googlyeyes_img_bkgd[i]);
|
||||
|
||||
|
|
@ -272,17 +277,19 @@ void googlyeyes_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
googlyeyes_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int img;
|
||||
|
||||
eye_x = x;
|
||||
eye_y = y;
|
||||
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
img = which;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
img = googlyeyes_size - 1;
|
||||
}
|
||||
|
||||
|
|
@ -300,16 +307,19 @@ googlyeyes_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
void
|
||||
googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
int max_radius;
|
||||
int img;
|
||||
|
||||
if (googlyeyes_limited) {
|
||||
if (googlyeyes_limited)
|
||||
{
|
||||
img = which;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
img = googlyeyes_size - 1;
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +337,8 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva
|
|||
|
||||
/* 2. Draw the pupil */
|
||||
max_radius = ((googlyeyes_img_bkgd[img]->w - googlyeyes_img_pupil[img]->w) / 2);
|
||||
if (sqrt(((x - eye_x) * (x - eye_x)) + ((y - eye_y) * (y - eye_y))) > max_radius) {
|
||||
if (sqrt(((x - eye_x) * (x - eye_x)) + ((y - eye_y) * (y - eye_y))) > max_radius)
|
||||
{
|
||||
/* If drag position would place pupil outside the circular bounds
|
||||
* of the background, put it on the edge, "looking towards" (pointing at)
|
||||
* the mouse. */
|
||||
|
|
@ -335,8 +346,8 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva
|
|||
* https://github.com/freedesktop/xorg-xeyes/blob/master/Eyes.c) */
|
||||
double dx, dy, angle;
|
||||
|
||||
dx = (double) (x - eye_x);
|
||||
dy = (double) (y - eye_y);
|
||||
dx = (double)(x - eye_x);
|
||||
dy = (double)(y - eye_y);
|
||||
angle = atan2(dy, dx);
|
||||
|
||||
x = eye_x + (cos(angle) * max_radius);
|
||||
|
|
@ -360,15 +371,16 @@ googlyeyes_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canva
|
|||
|
||||
void
|
||||
googlyeyes_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void googlyeyes_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void googlyeyes_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -381,14 +393,11 @@ void googlyeyes_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
}
|
||||
|
||||
void googlyeyes_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void googlyeyes_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ char *grass_get_name(magic_api * api, int which);
|
|||
int grass_get_group(magic_api * api, int which);
|
||||
char *grass_get_description(magic_api * api, int which, int mode);
|
||||
void grass_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 grass_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void grass_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -59,29 +58,25 @@ void grass_shutdown(magic_api * api);
|
|||
void grass_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int grass_requires_colors(magic_api * api, int which);
|
||||
static void do_grass(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_grass(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static int log2int(int x);
|
||||
void grass_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void grass_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void grass_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void grass_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int grass_modes(magic_api * api, int which);
|
||||
Uint8 grass_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 grass_default_size(magic_api * api, int which, int mode);
|
||||
void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// No setup required:
|
||||
int grass_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav", api->data_directory);
|
||||
grass_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png", api->data_directory);
|
||||
img_grass = IMG_Load(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -105,43 +100,35 @@ SDL_Surface *grass_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Grass")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int grass_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int grass_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to draw grass. Don’t forget the dirt!")));
|
||||
return (strdup(gettext_noop("Click and drag to draw grass. Don’t forget the dirt!")));
|
||||
}
|
||||
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void grass_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, 4, do_grass);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 4, do_grass);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -168,8 +155,7 @@ void grass_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void grass_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)
|
||||
{
|
||||
grass_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -178,8 +164,7 @@ void grass_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +176,9 @@ void grass_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void grass_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 grass_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)
|
||||
{
|
||||
grass_r = r;
|
||||
grass_g = g;
|
||||
|
|
@ -200,15 +186,13 @@ void grass_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void do_grass(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 xx, yy;
|
||||
|
|
@ -221,12 +205,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
if (!api->button_down())
|
||||
bucket = 0;
|
||||
bucket += (3.5 + (rand() / (double) RAND_MAX)) * 7.0;
|
||||
bucket += (3.5 + (rand() / (double)RAND_MAX)) * 7.0;
|
||||
while (bucket >= 0)
|
||||
{
|
||||
int rank =
|
||||
log2int(((double) y / canvas->h) *
|
||||
(0.99 + (rand() / (double) RAND_MAX)) * 64);
|
||||
int rank = log2int(((double)y / canvas->h) * (0.99 + (rand() / (double)RAND_MAX)) * 64);
|
||||
int ah = 1 << rank;
|
||||
|
||||
bucket -= ah;
|
||||
|
|
@ -236,12 +218,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
src.h = ah;
|
||||
|
||||
dest.x = x - 32;
|
||||
dest.y = y - 30 + (int) ((rand() / (double) RAND_MAX) * 30);
|
||||
dest.y = y - 30 + (int)((rand() / (double)RAND_MAX) * 30);
|
||||
|
||||
tmp_red =
|
||||
api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double) RAND_MAX);
|
||||
tmp_green =
|
||||
api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double) RAND_MAX);
|
||||
tmp_red = api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double)RAND_MAX);
|
||||
tmp_green = api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double)RAND_MAX);
|
||||
tmp_blue = api->sRGB_to_linear(grass_b) * 2.0 + api->sRGB_to_linear(17);
|
||||
|
||||
for (yy = 0; yy < ah; yy++)
|
||||
|
|
@ -250,8 +230,7 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
double rd, gd, bd;
|
||||
|
||||
SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y),
|
||||
img_grass->format, &r, &g, &b, &a);
|
||||
SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y), img_grass->format, &r, &g, &b, &a);
|
||||
|
||||
rd = api->sRGB_to_linear(r) * 8.0 + tmp_red;
|
||||
rd = rd * (a / 255.0) / 11.0;
|
||||
|
|
@ -260,21 +239,13 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
bd = api->sRGB_to_linear(b) * 8.0 + tmp_blue;
|
||||
bd = bd * (a / 255.0) / 11.0;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y),
|
||||
canvas->format, &r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y), canvas->format, &r, &g, &b);
|
||||
|
||||
r =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) +
|
||||
rd);
|
||||
g =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) +
|
||||
gd);
|
||||
b =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) +
|
||||
bd);
|
||||
r = api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) + rd);
|
||||
g = api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) + gd);
|
||||
b = api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) + bd);
|
||||
|
||||
api->putpixel(canvas, xx + dest.x, yy + dest.y,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
api->putpixel(canvas, xx + dest.x, yy + dest.y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -297,14 +268,12 @@ static int log2int(int x)
|
|||
}
|
||||
|
||||
void grass_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void grass_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -325,6 +294,8 @@ Uint8 grass_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void grass_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 grass_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,8 @@ static SDL_Surface *canvas_backup, *square;
|
|||
/* Function Prototypes: */
|
||||
|
||||
void halftone_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void halftone_line_callback(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void halftone_line_callback(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
Uint32 halftone_api_version(void);
|
||||
int halftone_init(magic_api * api, Uint32 disabled_features);
|
||||
int halftone_get_tool_count(magic_api * api);
|
||||
|
|
@ -74,21 +72,18 @@ int halftone_requires_colors(magic_api * api, int which);
|
|||
int halftone_modes(magic_api * api, int which);
|
||||
void halftone_shutdown(magic_api * api);
|
||||
void halftone_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void halftone_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void halftone_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void halftone_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void halftone_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void halftone_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void halftone_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[]);
|
||||
Uint8 halftone_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 halftone_default_size(magic_api * api, int which, int mode);
|
||||
void halftone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void halftone_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -107,8 +102,7 @@ int halftone_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, snd_filenames[i]);
|
||||
|
||||
snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
|
@ -126,8 +120,7 @@ SDL_Surface *halftone_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -148,8 +141,7 @@ int halftone_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return groups[which];
|
||||
}
|
||||
|
||||
char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
const char *our_desc_english;
|
||||
const char *our_desc_localized;
|
||||
|
|
@ -160,14 +152,12 @@ char *halftone_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
return (strdup(our_desc_localized));
|
||||
}
|
||||
|
||||
int halftone_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int halftone_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int halftone_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int halftone_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
|
@ -189,8 +179,7 @@ void halftone_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
void halftone_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int full_x, full_y;
|
||||
|
||||
|
|
@ -216,11 +205,9 @@ void halftone_click(magic_api * api, int which, int mode,
|
|||
}
|
||||
|
||||
void halftone_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 4,
|
||||
halftone_line_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 4, halftone_line_callback);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -278,21 +265,20 @@ void halftone_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
void halftone_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void halftone_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x,
|
||||
int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
Uint8 r, g, b, or, og, ob;
|
||||
Uint32 total_r, total_g, total_b;
|
||||
|
|
@ -323,8 +309,7 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
for (yyy = -(GRID_SIZE / 2); yyy < (GRID_SIZE / 2); yyy++)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(canvas_backup, x + xxx, y + yyy),
|
||||
canvas_backup->format, &r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(canvas_backup, x + xxx, y + yyy), canvas_backup->format, &r, &g, &b);
|
||||
total_r += r;
|
||||
total_g += g;
|
||||
total_b += b;
|
||||
|
|
@ -367,12 +352,10 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
/* Additively blend with whatever we have in the
|
||||
'square' buffer (which starts as white)
|
||||
(since the target is RGB, we use `min()`) */
|
||||
SDL_GetRGB(api->getpixel(square, sqx, sqy), square->format, &or,
|
||||
&og, &ob);
|
||||
SDL_GetRGB(api->getpixel(square, sqx, sqy), square->format, &or, &og, &ob);
|
||||
pixel =
|
||||
SDL_MapRGB(square->format, min((Uint8) (r * 2.0), or),
|
||||
min((Uint8) (g * 2.0), og), min((Uint8) (b * 2.0),
|
||||
ob));
|
||||
min((Uint8) (g * 2.0), og), min((Uint8) (b * 2.0), ob));
|
||||
api->putpixel(square, sqx, sqy, pixel);
|
||||
}
|
||||
}
|
||||
|
|
@ -388,16 +371,14 @@ void halftone_line_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
SDL_BlitSurface(square, NULL, canvas, &dest);
|
||||
}
|
||||
|
||||
void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
if (canvas_backup == NULL)
|
||||
{
|
||||
canvas_backup =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, api->canvas_w, api->canvas_h,
|
||||
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);
|
||||
}
|
||||
|
||||
if (square == NULL)
|
||||
|
|
@ -405,16 +386,14 @@ void halftone_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
square =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, GRID_SIZE, GRID_SIZE,
|
||||
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);
|
||||
}
|
||||
|
||||
SDL_BlitSurface(canvas, NULL, canvas_backup, NULL);
|
||||
}
|
||||
|
||||
void halftone_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -436,9 +415,9 @@ void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[])
|
|||
}
|
||||
else
|
||||
{
|
||||
c = 1.0 - (((float) r) / 255.0);
|
||||
m = 1.0 - (((float) g) / 255.0);
|
||||
y = 1.0 - (((float) b) / 255.0);
|
||||
c = 1.0 - (((float)r) / 255.0);
|
||||
m = 1.0 - (((float)g) / 255.0);
|
||||
y = 1.0 - (((float)b) / 255.0);
|
||||
|
||||
mincmy = min(c, min(m, y));
|
||||
c = (c - mincmy) / (1.0 - mincmy);
|
||||
|
|
@ -456,14 +435,16 @@ void halftone_rgb2cmyk(Uint8 r, Uint8 g, Uint8 b, float cmyk[])
|
|||
|
||||
Uint8 halftone_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0; // No size support at this time
|
||||
return 0; // No size support at this time
|
||||
}
|
||||
|
||||
Uint8 halftone_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0; // No size support at this time
|
||||
return 0; // No size support at this time
|
||||
}
|
||||
|
||||
void halftone_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 halftone_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,32 +16,33 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
KAL_LENS_4,
|
||||
KAL_LENS_6,
|
||||
KAL_LENS_8,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
static char * kaleidox_snd_fnames[NUM_TOOLS] = {
|
||||
static char *kaleidox_snd_fnames[NUM_TOOLS] = {
|
||||
"kaleido-4.ogg",
|
||||
"kaleido-6.ogg",
|
||||
"kaleido-8.ogg",
|
||||
};
|
||||
|
||||
static char * kaleidox_icon_fnames[NUM_TOOLS] = {
|
||||
static char *kaleidox_icon_fnames[NUM_TOOLS] = {
|
||||
"kaleido-4.png",
|
||||
"kaleido-6.png",
|
||||
"kaleido-8.png",
|
||||
};
|
||||
|
||||
char * kaleidox_names[NUM_TOOLS] = {
|
||||
char *kaleidox_names[NUM_TOOLS] = {
|
||||
gettext_noop("Kaleido-4"),
|
||||
gettext_noop("Kaleido-6"),
|
||||
gettext_noop("Kaleido-8"),
|
||||
};
|
||||
|
||||
char * kaleidox_descrs[NUM_TOOLS] = {
|
||||
char *kaleidox_descrs[NUM_TOOLS] = {
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
gettext_noop("Click and drag around your picture to look through it with a kaleidoscope!"),
|
||||
|
|
@ -60,26 +61,21 @@ int kaleidox_requires_colors(magic_api * api, int which);
|
|||
int kaleidox_modes(magic_api * api, int which);
|
||||
void kaleidox_shutdown(magic_api * api);
|
||||
void kaleidox_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void kaleidox_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void kaleidox_render(magic_api *, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y, int preview);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void kaleidox_render(magic_api *, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, int preview);
|
||||
void kaleidox_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void kaleidox_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void kaleidox_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void kaleidox_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void kaleidox_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int mirror(int n, int max, int flip);
|
||||
Uint8 kaleidox_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 kaleidox_default_size(magic_api * api, int which, int mode);
|
||||
void kaleidox_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void kaleidox_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 kaleidox_api_version(void)
|
||||
|
|
@ -92,9 +88,9 @@ int kaleidox_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s",
|
||||
api->data_directory, kaleidox_snd_fnames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, kaleidox_snd_fnames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -111,38 +107,32 @@ SDL_Surface *kaleidox_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, kaleidox_icon_fnames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, kaleidox_icon_fnames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *kaleidox_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
char *kaleidox_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return strdup(gettext(kaleidox_names[which]));
|
||||
}
|
||||
|
||||
int kaleidox_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *kaleidox_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode ATTRIBUTE_UNUSED)
|
||||
char *kaleidox_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext(kaleidox_descrs[which]));
|
||||
}
|
||||
|
||||
int kaleidox_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kaleidox_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kaleidox_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT_WITH_PREVIEW;
|
||||
}
|
||||
|
|
@ -151,7 +141,8 @@ void kaleidox_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
if (snd_effects[i] != NULL)
|
||||
Mix_FreeChunk(snd_effects[i]);
|
||||
}
|
||||
|
|
@ -159,8 +150,7 @@ void kaleidox_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
kaleidox_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->stopsound();
|
||||
|
||||
|
|
@ -170,23 +160,28 @@ kaleidox_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
#define linear(start, end, dist, full) (start + (((end - start) * dist) / full))
|
||||
#define length(x1, y1, x2, y2) sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2))
|
||||
|
||||
int mirror(int n, int max, int flip) {
|
||||
int mirror(int n, int max, int flip)
|
||||
{
|
||||
int adjusted;
|
||||
|
||||
if (flip)
|
||||
n = max - n;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
adjusted = 0;
|
||||
if (n < 0) {
|
||||
if (n < 0)
|
||||
{
|
||||
n = -n;
|
||||
adjusted = 1;
|
||||
}
|
||||
if (n >= max) {
|
||||
if (n >= max)
|
||||
{
|
||||
n = (max - 1) - (n - max);
|
||||
adjusted = 1;
|
||||
}
|
||||
} while (adjusted);
|
||||
}
|
||||
while (adjusted);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
@ -196,7 +191,8 @@ kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (snd_effects[which] != NULL) {
|
||||
if (snd_effects[which] != NULL)
|
||||
{
|
||||
api->playsound(snd_effects[which], 128, 255);
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +205,7 @@ kaleidox_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y, int preview)
|
||||
SDL_Surface * snapshot, int x, int y, int preview)
|
||||
{
|
||||
int off_x, off_y, sides, max_radius;
|
||||
float angle, angle_offset;
|
||||
|
|
@ -221,15 +217,22 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
off_x = (canvas->w / 2) - x * 2;
|
||||
off_y = (canvas->h / 2) - y * 2;
|
||||
max_radius = max(canvas->w, canvas->h); /* FIXME: Better calculation should be used! */
|
||||
max_radius = max(canvas->w, canvas->h); /* FIXME: Better calculation should be used! */
|
||||
|
||||
if (which == KAL_LENS_4) {
|
||||
if (which == KAL_LENS_4)
|
||||
{
|
||||
sides = 4;
|
||||
} else if (which == KAL_LENS_6) {
|
||||
}
|
||||
else if (which == KAL_LENS_6)
|
||||
{
|
||||
sides = 6;
|
||||
} else if (which == KAL_LENS_8) {
|
||||
}
|
||||
else if (which == KAL_LENS_8)
|
||||
{
|
||||
sides = 8;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -237,12 +240,14 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
angle_offset = angle / 2;
|
||||
|
||||
/* Go around each side */
|
||||
for (s = 0; s < sides; s++) {
|
||||
a1 = (angle * (float) s) + angle_offset;
|
||||
a2 = (angle * (float) (s + 1)) + angle_offset;
|
||||
for (s = 0; s < sides; s++)
|
||||
{
|
||||
a1 = (angle * (float)s) + angle_offset;
|
||||
a2 = (angle * (float)(s + 1)) + angle_offset;
|
||||
|
||||
/* From the center outward... */
|
||||
for (r = 0; r < max_radius; r = r + (preview ? 4 : 1)) {
|
||||
for (r = 0; r < max_radius; r = r + (preview ? 4 : 1))
|
||||
{
|
||||
dx = (canvas->w / 2) + cos(a1) * r;
|
||||
dy = (canvas->h / 2) - sin(a1) * r;
|
||||
|
||||
|
|
@ -252,13 +257,15 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
len = length(dx, dy, dx2, dy2);
|
||||
|
||||
/* Scan rows of the source, and draw along each triangle */
|
||||
if (len != 0) {
|
||||
xxm = ((len > 0 ? 1 : -1 ) * (preview ? 4 : 1));
|
||||
if (len != 0)
|
||||
{
|
||||
xxm = ((len > 0 ? 1 : -1) * (preview ? 4 : 1));
|
||||
|
||||
push = (canvas->w - abs(len)) / 2;
|
||||
xx = 0;
|
||||
done = 0;
|
||||
do {
|
||||
do
|
||||
{
|
||||
src_x = (canvas->w / 2) + off_x + xx + push;
|
||||
src_x = mirror(src_x, canvas->w, (s % 2));
|
||||
|
||||
|
|
@ -268,20 +275,25 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
colr = api->getpixel(snapshot, src_x, src_y);
|
||||
dest.x = linear(dx, dx2, xx, len);
|
||||
dest.y = linear(dy, dy2, xx, len);
|
||||
if (preview) {
|
||||
if (preview)
|
||||
{
|
||||
dest.w = 6;
|
||||
dest.h = 6;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
dest.w = 2;
|
||||
dest.h = 2;
|
||||
}
|
||||
SDL_FillRect(canvas, &dest, colr);
|
||||
|
||||
xx = xx + xxm;
|
||||
if ((xxm > 0 && xx > len) || (xxm < 0 && xx < len)) {
|
||||
if ((xxm > 0 && xx > len) || (xxm < 0 && xx < len))
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
} while (!done);
|
||||
}
|
||||
while (!done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -289,10 +301,7 @@ void kaleidox_render(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void kaleidox_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot,
|
||||
int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
kaleidox_render(api, which, canvas, snapshot, x, y, 0);
|
||||
|
||||
|
|
@ -306,24 +315,21 @@ void kaleidox_release(magic_api * api, int which,
|
|||
|
||||
|
||||
void kaleidox_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void kaleidox_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void kaleidox_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -340,6 +346,8 @@ Uint8 kaleidox_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 0;
|
||||
}
|
||||
|
||||
void kaleidox_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 kaleidox_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,17 +70,13 @@ SDL_Surface *kalidescope_get_icon(magic_api * api, int which);
|
|||
char *kalidescope_get_name(magic_api * api, int which);
|
||||
int kalidescope_get_group(magic_api * api, int which);
|
||||
char *kalidescope_get_description(magic_api * api, int which, int mode);
|
||||
static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void kalidescope_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 kalidescope_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 kalidescope_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void kalidescope_shutdown(magic_api * api);
|
||||
int kalidescope_requires_colors(magic_api * api, int which);
|
||||
Uint8 kalidescope_accepted_sizes(magic_api * api, int which, int mode);
|
||||
|
|
@ -88,12 +84,9 @@ Uint8 kalidescope_default_size(magic_api * api, int which, int mode);
|
|||
void kalidescope_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void kalidescope_set_size(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
Uint8 sz, SDL_Rect * update_rect);
|
||||
void kalidescope_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void kalidescope_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, Uint8 sz, SDL_Rect * update_rect);
|
||||
void kalidescope_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void kalidescope_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int kalidescope_modes(magic_api * api, int which);
|
||||
|
||||
Uint32 kalidescope_api_version(void)
|
||||
|
|
@ -105,8 +98,7 @@ int kalidescope_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/kaleidoscope.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/kaleidoscope.ogg", api->data_directory);
|
||||
kalidescope_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -122,8 +114,7 @@ SDL_Surface *kalidescope_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
kal_icon_names[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, kal_icon_names[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -154,16 +145,14 @@ char *kalidescope_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (all the same):
|
||||
int kalidescope_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kalidescope_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PATTERN_PAINTING;
|
||||
}
|
||||
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == KAL_LR)
|
||||
{
|
||||
|
|
@ -179,21 +168,15 @@ char *kalidescope_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
}
|
||||
else if (which == KAL_PATTERN)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to draw a pattern across the picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to draw a pattern across the picture.")));
|
||||
}
|
||||
else if (which == KAL_TILES)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to draw a pattern that is symmetric across the picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to draw a pattern that is symmetric across the picture.")));
|
||||
}
|
||||
else
|
||||
{ /* KAL_BOTH */
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to draw with symmetric brushes (a kaleidoscope).")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to draw with symmetric brushes (a kaleidoscope).")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,8 +190,7 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas,
|
|||
int i, j;
|
||||
Uint32 colr;
|
||||
|
||||
colr =
|
||||
SDL_MapRGB(canvas->format, kalidescope_r, kalidescope_g, kalidescope_b);
|
||||
colr = SDL_MapRGB(canvas->format, kalidescope_r, kalidescope_g, kalidescope_b);
|
||||
|
||||
for (yy = -kalidescope_sz; yy < kalidescope_sz; yy++)
|
||||
{
|
||||
|
|
@ -224,8 +206,7 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
if (which == KAL_BOTH)
|
||||
{
|
||||
api->putpixel(canvas, canvas->w - 1 - x + xx,
|
||||
canvas->h - 1 - y + yy, colr);
|
||||
api->putpixel(canvas, canvas->w - 1 - x + xx, canvas->h - 1 - y + yy, colr);
|
||||
}
|
||||
}
|
||||
if (which == KAL_UD || which == KAL_BOTH)
|
||||
|
|
@ -237,11 +218,9 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas,
|
|||
for (i = 0; i <= canvas->w; i += square_size)
|
||||
for (j = 0; j <= canvas->h; j += square_size)
|
||||
{
|
||||
api->putpixel(canvas, i + xx + x % square_size,
|
||||
j + yy + y % square_size, colr);
|
||||
api->putpixel(canvas, i + xx + x % square_size, j + yy + y % square_size, colr);
|
||||
if (which == KAL_TILES)
|
||||
api->putpixel(canvas, i + yy + y % square_size,
|
||||
j + xx + x % square_size, colr);
|
||||
api->putpixel(canvas, i + yy + y % square_size, j + xx + x % square_size, colr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -251,11 +230,9 @@ static void do_kalidescope(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void kalidescope_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_kalidescope);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_kalidescope);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -267,8 +244,7 @@ void kalidescope_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void kalidescope_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)
|
||||
{
|
||||
kalidescope_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -277,8 +253,7 @@ void kalidescope_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
void kalidescope_release(magic_api * api, 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)
|
||||
{
|
||||
api->stopsound();
|
||||
}
|
||||
|
|
@ -291,15 +266,15 @@ void kalidescope_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int kalidescope_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kalidescope_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void kalidescope_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 kalidescope_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)
|
||||
{
|
||||
kalidescope_r = r;
|
||||
kalidescope_g = g;
|
||||
|
|
@ -313,8 +288,7 @@ Uint8 kalidescope_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED,
|
|||
return KAL_MAX_SIZE;
|
||||
}
|
||||
|
||||
Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return KAL_DEF_SIZE;
|
||||
}
|
||||
|
|
@ -329,21 +303,16 @@ void kalidescope_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
|
||||
|
||||
void kalidescope_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void kalidescope_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int kalidescope_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int kalidescope_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,9 @@ SDL_Surface *light_get_icon(magic_api * api, int which);
|
|||
char *light_get_name(magic_api * api, int which);
|
||||
int light_get_group(magic_api * api, int which);
|
||||
char *light_get_description(magic_api * api, int which, int mode);
|
||||
static void do_light(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_light(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void light_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 light_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void light_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -63,14 +61,13 @@ void light_shutdown(magic_api * api);
|
|||
void light_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int light_requires_colors(magic_api * api, int which);
|
||||
void light_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void light_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void light_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void light_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int light_modes(magic_api * api, int which);
|
||||
Uint8 light_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 light_default_size(magic_api * api, int which, int mode);
|
||||
void light_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void light_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 light_api_version(void)
|
||||
|
|
@ -84,12 +81,10 @@ int light_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/light1.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/light1.ogg", api->data_directory);
|
||||
light1_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/light2.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/light2.ogg", api->data_directory);
|
||||
light2_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -106,41 +101,33 @@ SDL_Surface *light_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/light.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/light.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *light_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *light_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Light")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int light_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int light_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *light_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *light_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to draw a beam of light on your picture.")));
|
||||
return (strdup(gettext_noop("Click and drag to draw a beam of light on your picture.")));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
|
||||
static void do_light(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 xx, yy;
|
||||
|
|
@ -159,11 +146,11 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
SDL_GetRGB(pix, canvas->format, &r, &g, &b);
|
||||
|
||||
adj = (((float) light_radius - 0.01) - sqrt(abs(xx * yy))) / (16.0 * (float) light_radius);
|
||||
adj = (((float)light_radius - 0.01) - sqrt(abs(xx * yy))) / (16.0 * (float)light_radius);
|
||||
|
||||
api->rgbtohsv(r, g, b, &h, &s, &v);
|
||||
|
||||
v = min((float) 1.0, v + adj);
|
||||
v = min((float)1.0, v + adj);
|
||||
|
||||
if (light_h == -1 && h == -1)
|
||||
{
|
||||
|
|
@ -192,8 +179,7 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
api->hsvtorgb(new_h, new_s, new_v, &r, &g, &b);
|
||||
|
||||
api->putpixel(canvas, x + xx, y + yy,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -201,10 +187,9 @@ static void do_light(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void light_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_light);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_light);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -231,8 +216,7 @@ void light_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void light_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)
|
||||
{
|
||||
light_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -240,8 +224,7 @@ void light_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
// Affect the canvas on release:
|
||||
void light_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
int x, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
api->playsound(light2_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
|
@ -257,27 +240,25 @@ void light_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void light_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
api->rgbtohsv(r, g, b, &light_h, &light_s, &light_v);
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int light_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int light_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void light_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void light_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +278,9 @@ Uint8 light_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 2;
|
||||
}
|
||||
|
||||
void light_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void light_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
light_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,28 +31,22 @@ int lightning_requires_colors(magic_api * api, int which);
|
|||
int lightning_modes(magic_api * api, int which);
|
||||
void lightning_shutdown(magic_api * api);
|
||||
void lightning_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void lightning_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void lightning_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void lightning_line_callback_drag(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void lightning_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void lightning_draw_bolt(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, float sx, float sy,
|
||||
float angle, float len, int thickness);
|
||||
SDL_Surface * snapshot, float sx, float sy, float angle, float len, int thickness);
|
||||
void lightning_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void lightning_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void lightning_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void lightning_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void lightning_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
Uint8 lightning_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 lightning_default_size(magic_api * api, int which, int mode);
|
||||
void lightning_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void lightning_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 lightning_api_version(void)
|
||||
|
|
@ -64,8 +58,7 @@ int lightning_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/lightning.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/lightning.ogg", api->data_directory);
|
||||
snd_effect = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -81,41 +74,32 @@ SDL_Surface *lightning_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/lightning.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/lightning.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *lightning_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *lightning_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext("Lightning"));
|
||||
}
|
||||
|
||||
int lightning_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int lightning_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
char *lightning_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *lightning_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext
|
||||
("Click, drag, and release to draw a lightning bolt between two points."));
|
||||
return strdup(gettext("Click, drag, and release to draw a lightning bolt between two points."));
|
||||
}
|
||||
|
||||
int lightning_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int lightning_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lightning_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int lightning_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
@ -129,8 +113,7 @@ void lightning_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
lightning_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
sx = x;
|
||||
sy = y;
|
||||
|
|
@ -154,15 +137,13 @@ lightning_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
SDL_BlitSurface(snapshot, update_rect, canvas, update_rect);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, sx, sy, x, y, 1,
|
||||
lightning_line_callback_drag);
|
||||
api->line((void *)api, which, canvas, snapshot, sx, sy, x, y, 1, lightning_line_callback_drag);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
lightning_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
float a, b, len, angle;
|
||||
int thickness;
|
||||
|
|
@ -194,8 +175,7 @@ lightning_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
#ifdef DEBUG
|
||||
printf
|
||||
("(%d,%d)->(%d,%d) => a = %.2f, b = %.2f, c (len) = %.2f; angle = %.2f degrees\n",
|
||||
sx, sy, x, y, a, b, len, angle);
|
||||
("(%d,%d)->(%d,%d) => a = %.2f, b = %.2f, c (len) = %.2f; angle = %.2f degrees\n", sx, sy, x, y, a, b, len, angle);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
|
@ -203,13 +183,11 @@ lightning_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
if (thickness < 4)
|
||||
thickness = 4;
|
||||
|
||||
lightning_draw_bolt((void *) api, canvas, snapshot, (float) sx, (float) sy,
|
||||
angle, len, thickness);
|
||||
lightning_draw_bolt((void *)api, canvas, snapshot, (float)sx, (float)sy, angle, len, thickness);
|
||||
}
|
||||
|
||||
void lightning_draw_bolt(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, float sx, float sy,
|
||||
float angle, float len, int thickness)
|
||||
SDL_Surface * snapshot, float sx, float sy, float angle, float len, int thickness)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
float i;
|
||||
|
|
@ -232,7 +210,7 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas,
|
|||
x = x + cos(angle * M_PI / 180.0);
|
||||
y = y + sin(angle * M_PI / 180.0);
|
||||
|
||||
angle = angle + ((float) (rand() % 15) - 7.5);
|
||||
angle = angle + ((float)(rand() % 15) - 7.5);
|
||||
if (angle < orig_angle - 10.0)
|
||||
angle = orig_angle - 10.0;
|
||||
else if (angle > orig_angle + 10.0)
|
||||
|
|
@ -249,8 +227,7 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas,
|
|||
light_h = lightning_h;
|
||||
light_s = lightning_s;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, x + xx, y + yy), canvas->format,
|
||||
&r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(canvas, x + xx, y + yy), canvas->format, &r, &g, &b);
|
||||
api->rgbtohsv(r, g, b, &h, &s, &v);
|
||||
|
||||
adj = 1.0 - (sqrt((xx * xx) + (yy * yy)) / t);
|
||||
|
|
@ -275,46 +252,41 @@ void lightning_draw_bolt(void *ptr, SDL_Surface * canvas,
|
|||
|
||||
api->hsvtorgb(new_h, new_s, new_v, &r, &g, &b);
|
||||
|
||||
api->putpixel(canvas, x + xx, y + yy,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (((rand() % 50) == 0 || (int) i == (int) (len / 2)) && thickness > 1
|
||||
&& len >= 4)
|
||||
if (((rand() % 50) == 0 || (int)i == (int)(len / 2)) && thickness > 1 && len >= 4)
|
||||
{
|
||||
float new_angle;
|
||||
|
||||
if ((rand() % 10) == 0)
|
||||
{
|
||||
new_angle = angle + ((float) (rand() % 180) - 90.0);
|
||||
new_angle = angle + ((float)(rand() % 180) - 90.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_angle = angle + ((float) (rand() % 90) - 45.0);
|
||||
new_angle = angle + ((float)(rand() % 90) - 45.0);
|
||||
}
|
||||
|
||||
lightning_draw_bolt((void *) api, canvas, snapshot, x, y,
|
||||
new_angle,
|
||||
((len / 8) + (rand() % (int) (len / 4))),
|
||||
thickness - 1);
|
||||
lightning_draw_bolt((void *)api, canvas, snapshot, x, y,
|
||||
new_angle, ((len / 8) + (rand() % (int)(len / 4))), thickness - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lightning_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
api->rgbtohsv(r, g, b, &lightning_h, &lightning_s, &lightning_v);
|
||||
}
|
||||
|
||||
|
||||
void lightning_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -322,15 +294,12 @@ void lightning_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void lightning_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void lightning_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -344,6 +313,8 @@ Uint8 lightning_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU
|
|||
return 0;
|
||||
}
|
||||
|
||||
void lightning_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 lightning_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
304
magic/src/maze.c
304
magic/src/maze.c
|
|
@ -28,15 +28,16 @@
|
|||
int xm[4] = { 0, 0, -1, 1 };
|
||||
int ym[4] = { -1, 1, 0, 0 };
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int x, y;
|
||||
} maze_start_t;
|
||||
|
||||
Mix_Chunk *snd_effect = NULL;
|
||||
Uint8 * maze_mask = NULL, * new_maze_mask = NULL, * maze_array = NULL;
|
||||
Uint32 * maze_color;
|
||||
maze_start_t * maze_starts;
|
||||
SDL_Surface * maze_snapshot = NULL;
|
||||
Uint8 *maze_mask = NULL, *new_maze_mask = NULL, *maze_array = NULL;
|
||||
Uint32 *maze_color;
|
||||
maze_start_t *maze_starts;
|
||||
SDL_Surface *maze_snapshot = NULL;
|
||||
Uint8 maze_r, maze_g, maze_b;
|
||||
int maze_start_x, maze_start_y;
|
||||
int num_maze_starts = 0, maze_starts_size = 0;
|
||||
|
|
@ -52,23 +53,17 @@ int maze_requires_colors(magic_api * api, int which);
|
|||
int maze_modes(magic_api * api, int which);
|
||||
void maze_shutdown(magic_api * api);
|
||||
void maze_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void maze_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void maze_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void maze_line_callback_drag(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void maze_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void maze_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void maze_render(magic_api * api, SDL_Surface * canvas);
|
||||
void maze_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void maze_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void maze_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void maze_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void zero_maze_arrays(SDL_Surface * canvas);
|
||||
void draw_hall(SDL_Surface * canvas, int x, int y);
|
||||
void maze_add_start(void);
|
||||
|
|
@ -76,7 +71,8 @@ int check_arrays(void);
|
|||
void maze_collapse_contiguous(SDL_Surface * canvas);
|
||||
Uint8 maze_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 maze_default_size(magic_api * api, int which, int mode);
|
||||
void maze_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void maze_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 maze_api_version(void)
|
||||
|
|
@ -88,8 +84,7 @@ int maze_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/maze.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/maze.ogg", api->data_directory);
|
||||
snd_effect = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -105,42 +100,35 @@ SDL_Surface *maze_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/maze.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/maze.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *maze_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *maze_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext("Maze"));
|
||||
}
|
||||
|
||||
int maze_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int maze_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
char *maze_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode)
|
||||
char *maze_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return(gettext("Click and drag to paint a maze on your picture."));
|
||||
return (gettext("Click and drag to paint a maze on your picture."));
|
||||
else
|
||||
return(gettext("Click to turn your entire picture into a maze."));
|
||||
return (gettext("Click to turn your entire picture into a maze."));
|
||||
}
|
||||
|
||||
int maze_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int maze_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int maze_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int maze_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT | MODE_FULLSCREEN;
|
||||
}
|
||||
|
|
@ -164,18 +152,19 @@ void maze_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
/* FIXME */
|
||||
int check_arrays(void) {
|
||||
int check_arrays(void)
|
||||
{
|
||||
if (maze_array == NULL || maze_mask == NULL || new_maze_mask == NULL ||
|
||||
maze_color == NULL || maze_snapshot == NULL || maze_starts == NULL) {
|
||||
return(0);
|
||||
maze_color == NULL || maze_snapshot == NULL || maze_starts == NULL)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
return(1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
maze_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (!check_arrays())
|
||||
return;
|
||||
|
|
@ -186,9 +175,12 @@ maze_click(magic_api * api, int which, int mode,
|
|||
maze_start_x = floor(x / MAZE_BLOCK_SIZE) * MAZE_BLOCK_SIZE + (MAZE_BLOCK_SIZE / 2);
|
||||
maze_start_y = floor(y / MAZE_BLOCK_SIZE) * MAZE_BLOCK_SIZE + (MAZE_BLOCK_SIZE / 2);
|
||||
|
||||
if (mode == MODE_PAINT) {
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
maze_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Uint32 color;
|
||||
|
||||
maze_add_start();
|
||||
|
|
@ -216,14 +208,13 @@ maze_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
maze_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (!check_arrays())
|
||||
return;
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1,
|
||||
maze_line_callback_drag);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, maze_line_callback_drag);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -234,8 +225,8 @@ maze_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
|||
|
||||
void maze_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect) {
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
if (snd_effect != NULL)
|
||||
api->stopsound();
|
||||
|
||||
|
|
@ -266,27 +257,34 @@ void maze_render(magic_api * api, SDL_Surface * canvas)
|
|||
|
||||
/* Reset everything we've drawn [back to] wall: */
|
||||
memset(maze_array, MAZE_HALL, (canvas->w * canvas->h));
|
||||
for (y = 0; y < canvas->h; y++) {
|
||||
for (x = 0; x < canvas->w; x++) {
|
||||
if (maze_mask[y * canvas->w + x]) {
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
if (maze_mask[y * canvas->w + x])
|
||||
{
|
||||
maze_array[y * canvas->w + x] = MAZE_WALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Render a maze! */
|
||||
for (s = 0; s < num_maze_starts; s++) {
|
||||
for (s = 0; s < num_maze_starts; s++)
|
||||
{
|
||||
x = maze_starts[s].x;
|
||||
y = maze_starts[s].y;
|
||||
|
||||
/* Render from here, ONLY if it's still non-contiguous to anything: */
|
||||
if (maze_mask[y * canvas->w + x] == s + 1) {
|
||||
if (maze_mask[y * canvas->w + x] == s + 1)
|
||||
{
|
||||
maze_array[y * canvas->w + x] = MAZE_START;
|
||||
|
||||
state = STATE_PICKDIR;
|
||||
iter = 0;
|
||||
do {
|
||||
if (state == STATE_PICKDIR) {
|
||||
do
|
||||
{
|
||||
if (state == STATE_PICKDIR)
|
||||
{
|
||||
dir = (rand() % 4);
|
||||
old_dir = dir;
|
||||
}
|
||||
|
|
@ -296,7 +294,8 @@ void maze_render(magic_api * api, SDL_Surface * canvas)
|
|||
nx = x + (xm[dir] * MAZE_BLOCK_SIZE * 2);
|
||||
ny = y + (ym[dir] * MAZE_BLOCK_SIZE * 2);
|
||||
|
||||
if (nx >= 0 && nx < canvas->w && ny >= 0 && ny < canvas->h && maze_array[ny * canvas->w + nx] == MAZE_WALL) {
|
||||
if (nx >= 0 && nx < canvas->w && ny >= 0 && ny < canvas->h && maze_array[ny * canvas->w + nx] == MAZE_WALL)
|
||||
{
|
||||
draw_hall(canvas, nx, ny);
|
||||
maze_array[ny * canvas->w + nx] = dir + 1;
|
||||
|
||||
|
|
@ -310,18 +309,21 @@ void maze_render(magic_api * api, SDL_Surface * canvas)
|
|||
state = STATE_PICKDIR;
|
||||
}
|
||||
|
||||
if (state == STATE_DONE) {
|
||||
if (state == STATE_DONE)
|
||||
{
|
||||
dir = (dir + 1) % 4;
|
||||
|
||||
if (dir != old_dir)
|
||||
state = STATE_KEEPGOING;
|
||||
}
|
||||
|
||||
if (state == STATE_DONE) {
|
||||
if (state == STATE_DONE)
|
||||
{
|
||||
dir = maze_array[y * canvas->w + x];
|
||||
draw_hall(canvas, x, y);
|
||||
|
||||
if (dir != MAZE_START) {
|
||||
if (dir != MAZE_START)
|
||||
{
|
||||
x = x - (xm[dir - 1] * MAZE_BLOCK_SIZE * 2);
|
||||
y = y - (ym[dir - 1] * MAZE_BLOCK_SIZE * 2);
|
||||
|
||||
|
|
@ -335,11 +337,16 @@ void maze_render(magic_api * api, SDL_Surface * canvas)
|
|||
}
|
||||
|
||||
/* Draw the maze onto the canvas */
|
||||
for (y = 0; y < canvas->h; y++) {
|
||||
for (x = 0; x < canvas->w; x++) {
|
||||
if (maze_array[y * canvas->w + x] == MAZE_WALL) {
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
if (maze_array[y * canvas->w + x] == MAZE_WALL)
|
||||
{
|
||||
api->putpixel(canvas, x, y, maze_color[y * canvas->w + x]);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, x, y, api->getpixel(maze_snapshot, x, y));
|
||||
}
|
||||
}
|
||||
|
|
@ -348,7 +355,8 @@ void maze_render(magic_api * api, SDL_Surface * canvas)
|
|||
|
||||
|
||||
void maze_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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
maze_r = r;
|
||||
maze_g = g;
|
||||
|
|
@ -357,9 +365,7 @@ void maze_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED
|
|||
|
||||
|
||||
void maze_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy, idx;
|
||||
|
|
@ -373,12 +379,17 @@ void maze_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
x = floor(x / (MAZE_BLOCK_SIZE * 3)) * (MAZE_BLOCK_SIZE * 3);
|
||||
y = floor(y / (MAZE_BLOCK_SIZE * 3)) * (MAZE_BLOCK_SIZE * 3);
|
||||
|
||||
for (yy = -MAZE_PAINT_RADIUS; yy < MAZE_PAINT_RADIUS; yy++) {
|
||||
if (y + yy > 0 && y + yy < canvas->h) {
|
||||
for (xx = -MAZE_PAINT_RADIUS; xx < MAZE_PAINT_RADIUS; xx++) {
|
||||
if (x + xx > 0 && x + xx < canvas->w) {
|
||||
for (yy = -MAZE_PAINT_RADIUS; yy < MAZE_PAINT_RADIUS; yy++)
|
||||
{
|
||||
if (y + yy > 0 && y + yy < canvas->h)
|
||||
{
|
||||
for (xx = -MAZE_PAINT_RADIUS; xx < MAZE_PAINT_RADIUS; xx++)
|
||||
{
|
||||
if (x + xx > 0 && x + xx < canvas->w)
|
||||
{
|
||||
idx = (y + yy) * canvas->w + (x + xx);
|
||||
if (maze_mask[idx] == 0) {
|
||||
if (maze_mask[idx] == 0)
|
||||
{
|
||||
maze_mask[idx] = num_maze_starts + 1;
|
||||
}
|
||||
maze_color[idx] = color;
|
||||
|
|
@ -390,80 +401,77 @@ void maze_line_callback_drag(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void maze_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
if (maze_array == NULL)
|
||||
{
|
||||
maze_array = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (maze_array == NULL)
|
||||
{
|
||||
maze_array = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (maze_array == NULL)
|
||||
{
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_array!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_array!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (maze_mask == NULL)
|
||||
{
|
||||
maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (maze_mask == NULL)
|
||||
{
|
||||
maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (maze_mask == NULL)
|
||||
{
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_mask!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_mask!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_maze_mask == NULL)
|
||||
{
|
||||
new_maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (new_maze_mask == NULL)
|
||||
{
|
||||
new_maze_mask = (Uint8 *) malloc(sizeof(Uint8) * canvas->w * canvas->h);
|
||||
if (new_maze_mask == NULL)
|
||||
{
|
||||
fprintf(stderr, "new_maze: Cannot malloc() maze_mask!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "new_maze: Cannot malloc() maze_mask!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (maze_color == NULL)
|
||||
{
|
||||
maze_color = (Uint32 *) malloc(sizeof(Uint32) * canvas->w * canvas->h);
|
||||
if (maze_color == NULL)
|
||||
{
|
||||
maze_color = (Uint32 *) malloc(sizeof(Uint32) * canvas->w * canvas->h);
|
||||
if (maze_color == NULL)
|
||||
{
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_color!\n");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_color!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (maze_starts == NULL)
|
||||
{
|
||||
int w, h;
|
||||
w = ceil(canvas->w / MAZE_BLOCK_SIZE);
|
||||
h = ceil(canvas->h / MAZE_BLOCK_SIZE);
|
||||
maze_starts_size = (w * h);
|
||||
{
|
||||
int w, h;
|
||||
|
||||
maze_starts = (maze_start_t *) malloc(sizeof(maze_start_t) * maze_starts_size);
|
||||
if (maze_starts == NULL)
|
||||
{
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_starts!\n");
|
||||
return;
|
||||
}
|
||||
w = ceil(canvas->w / MAZE_BLOCK_SIZE);
|
||||
h = ceil(canvas->h / MAZE_BLOCK_SIZE);
|
||||
maze_starts_size = (w * h);
|
||||
|
||||
maze_starts = (maze_start_t *) malloc(sizeof(maze_start_t) * maze_starts_size);
|
||||
if (maze_starts == NULL)
|
||||
{
|
||||
fprintf(stderr, "maze: Cannot malloc() maze_starts!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
zero_maze_arrays(canvas);
|
||||
|
||||
if (maze_snapshot == NULL)
|
||||
maze_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
if (maze_snapshot != NULL)
|
||||
SDL_BlitSurface(canvas, NULL, maze_snapshot, NULL);
|
||||
}
|
||||
|
||||
void maze_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
zero_maze_arrays(canvas);
|
||||
}
|
||||
|
|
@ -485,13 +493,18 @@ void zero_maze_arrays(SDL_Surface * canvas)
|
|||
memset(maze_color, 0, (sizeof(Uint32) * (canvas->w * canvas->h)));
|
||||
}
|
||||
|
||||
void draw_hall(SDL_Surface * canvas, int x, int y) {
|
||||
void draw_hall(SDL_Surface * canvas, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
|
||||
for (yy = -MAZE_BLOCK_SIZE / 2; yy < MAZE_BLOCK_SIZE / 2; yy++) {
|
||||
if (y + yy >= 0 && y + yy < canvas->h) {
|
||||
for (xx = -MAZE_BLOCK_SIZE / 2; xx < MAZE_BLOCK_SIZE / 2; xx++) {
|
||||
if (x + xx >= 0 && x + xx < canvas->w) {
|
||||
for (yy = -MAZE_BLOCK_SIZE / 2; yy < MAZE_BLOCK_SIZE / 2; yy++)
|
||||
{
|
||||
if (y + yy >= 0 && y + yy < canvas->h)
|
||||
{
|
||||
for (xx = -MAZE_BLOCK_SIZE / 2; xx < MAZE_BLOCK_SIZE / 2; xx++)
|
||||
{
|
||||
if (x + xx >= 0 && x + xx < canvas->w)
|
||||
{
|
||||
maze_array[(y + yy) * canvas->w + (x + xx)] = MAZE_HALL;
|
||||
}
|
||||
}
|
||||
|
|
@ -499,42 +512,59 @@ void draw_hall(SDL_Surface * canvas, int x, int y) {
|
|||
}
|
||||
}
|
||||
|
||||
void maze_add_start(void) {
|
||||
void maze_add_start(void)
|
||||
{
|
||||
maze_starts[num_maze_starts].x = maze_start_x;
|
||||
maze_starts[num_maze_starts].y = maze_start_y;
|
||||
|
||||
num_maze_starts++;
|
||||
}
|
||||
|
||||
void maze_collapse_contiguous(SDL_Surface * canvas) {
|
||||
void maze_collapse_contiguous(SDL_Surface * canvas)
|
||||
{
|
||||
int i, x, y, touching, idx;
|
||||
|
||||
for (i = num_maze_starts; i > 0; i--) {
|
||||
for (i = num_maze_starts; i > 0; i--)
|
||||
{
|
||||
touching = -1;
|
||||
for (y = 1; y < canvas->h - 1 && touching == -1; y++) {
|
||||
for (x = 1; x < canvas->w - 1 && touching == -1; x++) {
|
||||
for (y = 1; y < canvas->h - 1 && touching == -1; y++)
|
||||
{
|
||||
for (x = 1; x < canvas->w - 1 && touching == -1; x++)
|
||||
{
|
||||
idx = (y * canvas->w + x);
|
||||
if (maze_mask[idx] == i + 1) {
|
||||
if (maze_mask[idx - 1] != 0 && maze_mask[idx - 1] != i + 1) {
|
||||
if (maze_mask[idx] == i + 1)
|
||||
{
|
||||
if (maze_mask[idx - 1] != 0 && maze_mask[idx - 1] != i + 1)
|
||||
{
|
||||
touching = maze_mask[idx - 1];
|
||||
} else if (maze_mask[idx + 1] != 0 && maze_mask[idx + 1] != i + 1) {
|
||||
}
|
||||
else if (maze_mask[idx + 1] != 0 && maze_mask[idx + 1] != i + 1)
|
||||
{
|
||||
touching = maze_mask[idx + 1];
|
||||
} else if (maze_mask[idx - canvas->w] != 0 && maze_mask[idx - canvas->w] != i + 1) {
|
||||
}
|
||||
else if (maze_mask[idx - canvas->w] != 0 && maze_mask[idx - canvas->w] != i + 1)
|
||||
{
|
||||
touching = maze_mask[idx - canvas->w];
|
||||
} else if (maze_mask[idx + canvas->w] != 0 && maze_mask[idx + canvas->w] != i + 1) {
|
||||
}
|
||||
else if (maze_mask[idx + canvas->w] != 0 && maze_mask[idx + canvas->w] != i + 1)
|
||||
{
|
||||
touching = maze_mask[idx + canvas->w];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (touching != -1) {
|
||||
if (touching != -1)
|
||||
{
|
||||
/* Touching someone else; turn all of our area
|
||||
into that area */
|
||||
for (y = 1; y < canvas->h; y++) {
|
||||
for (x = 1; x < canvas->w; x++) {
|
||||
for (y = 1; y < canvas->h; y++)
|
||||
{
|
||||
for (x = 1; x < canvas->w; x++)
|
||||
{
|
||||
idx = (y * canvas->w + x);
|
||||
if (maze_mask[idx] == i + 1) {
|
||||
if (maze_mask[idx] == i + 1)
|
||||
{
|
||||
maze_mask[idx] = touching;
|
||||
}
|
||||
}
|
||||
|
|
@ -553,6 +583,8 @@ Uint8 maze_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 0;
|
||||
}
|
||||
|
||||
void maze_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 maze_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,29 +45,24 @@ SDL_Surface *metalpaint_get_icon(magic_api * api, int which);
|
|||
char *metalpaint_get_name(magic_api * api, int which);
|
||||
int metalpaint_get_group(magic_api * api, int which);
|
||||
char *metalpaint_get_description(magic_api * api, int which, int mode);
|
||||
static void do_metalpaint(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_metalpaint(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void metalpaint_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 metalpaint_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 metalpaint_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void metalpaint_shutdown(magic_api * api);
|
||||
void metalpaint_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int metalpaint_requires_colors(magic_api * api, int which);
|
||||
void metalpaint_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void metalpaint_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void metalpaint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void metalpaint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int metalpaint_modes(magic_api * api, int which);
|
||||
Uint8 metalpaint_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 metalpaint_default_size(magic_api * api, int which, int mode);
|
||||
void metalpaint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void metalpaint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 metalpaint_api_version(void)
|
||||
|
|
@ -81,8 +76,7 @@ int metalpaint_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/metalpaint.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/metalpaint.wav", api->data_directory);
|
||||
metalpaint_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -99,34 +93,28 @@ SDL_Surface *metalpaint_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/metalpaint.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/metalpaint.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *metalpaint_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *metalpaint_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Metal Paint")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int metalpaint_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int metalpaint_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *metalpaint_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse to paint with a metallic color.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse to paint with a metallic color.")));
|
||||
}
|
||||
|
||||
#define METALPAINT_CYCLE 32
|
||||
|
|
@ -143,8 +131,7 @@ static int metalpaint_gradient[METALPAINT_CYCLE] = {
|
|||
// Do the effect:
|
||||
|
||||
static void do_metalpaint(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 xx, yy;
|
||||
|
|
@ -161,19 +148,16 @@ static void do_metalpaint(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
g = (metalpaint_g * n) / 255;
|
||||
b = (metalpaint_b * n) / 255;
|
||||
|
||||
api->putpixel(canvas, x + xx, y + yy,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void metalpaint_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_metalpaint);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_metalpaint);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -200,8 +184,7 @@ void metalpaint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void metalpaint_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)
|
||||
{
|
||||
metalpaint_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -211,8 +194,7 @@ void metalpaint_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -224,8 +206,9 @@ void metalpaint_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void metalpaint_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 metalpaint_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)
|
||||
{
|
||||
metalpaint_r = min(255, r + 64);
|
||||
metalpaint_g = min(255, g + 64);
|
||||
|
|
@ -233,28 +216,22 @@ void metalpaint_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int metalpaint_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int metalpaint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void metalpaint_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void metalpaint_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int metalpaint_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int metalpaint_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -270,7 +247,9 @@ Uint8 metalpaint_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB
|
|||
return 2;
|
||||
}
|
||||
|
||||
void metalpaint_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void metalpaint_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
metalpaint_size = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,9 @@ SDL_Surface *mirror_flip_get_icon(magic_api *, int);
|
|||
char *mirror_flip_get_name(magic_api *, int);
|
||||
int mirror_flip_get_group(magic_api *, int);
|
||||
char *mirror_flip_get_description(magic_api *, int, int);
|
||||
void mirror_flip_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int,
|
||||
int, int, int, SDL_Rect *);
|
||||
void mirror_flip_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int,
|
||||
int, int, int, SDL_Rect *);
|
||||
void mirror_flip_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *,
|
||||
int, int, SDL_Rect *);
|
||||
void mirror_flip_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
|
||||
void mirror_flip_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
|
||||
void mirror_flip_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
|
||||
void mirror_flip_shutdown(magic_api *);
|
||||
void mirror_flip_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
|
|
@ -66,19 +63,18 @@ void mirror_flip_switchout(magic_api *, int, int, SDL_Surface *);
|
|||
int mirror_flip_modes(magic_api *, int);
|
||||
Uint8 mirror_flip_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 mirror_flip_default_size(magic_api * api, int which, int mode);
|
||||
void mirror_flip_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void mirror_flip_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// No setup required:
|
||||
int mirror_flip_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/mirror.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/mirror.wav", api->data_directory);
|
||||
snd_effects[TOOL_MIRROR] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flip.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/flip.wav", api->data_directory);
|
||||
snd_effects[TOOL_FLIP] = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -102,13 +98,11 @@ SDL_Surface *mirror_flip_get_icon(magic_api * api, int which)
|
|||
|
||||
if (which == TOOL_MIRROR)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/mirror.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/mirror.png", api->data_directory);
|
||||
}
|
||||
else if (which == TOOL_FLIP)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flip.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/flip.png", api->data_directory);
|
||||
}
|
||||
|
||||
return (IMG_Load(fname));
|
||||
|
|
@ -126,15 +120,13 @@ char *mirror_flip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (the same):
|
||||
int mirror_flip_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int mirror_flip_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == TOOL_MIRROR)
|
||||
return (strdup(gettext_noop("Click to make a mirror image.")));
|
||||
|
|
@ -150,8 +142,7 @@ void mirror_flip_drag(magic_api * api ATTRIBUTE_UNUSED,
|
|||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int ox ATTRIBUTE_UNUSED, int oy 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)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
|
@ -161,8 +152,7 @@ void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int ox ATTRIBUTE_UNUSED, int oy 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)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
|
@ -170,8 +160,7 @@ void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
// Affect the canvas on click:
|
||||
void mirror_flip_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
int xx, yy;
|
||||
SDL_Rect src, dest;
|
||||
|
|
@ -229,40 +218,37 @@ void mirror_flip_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// We don't use colors:
|
||||
void mirror_flip_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void mirror_flip_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// We don't use colors:
|
||||
int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mirror_flip_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void mirror_flip_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
|
||||
Uint8 mirror_flip_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 mirror_flip_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -272,6 +258,8 @@ Uint8 mirror_flip_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
void mirror_flip_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 mirror_flip_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,9 @@
|
|||
#define gettext_noop(String) String
|
||||
#endif
|
||||
|
||||
static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas,
|
||||
int noise_AMOUNT, int x, int y);
|
||||
static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, int noise_AMOUNT, int x, int y);
|
||||
static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void reset_mosaic_blured(SDL_Surface * canvas);
|
||||
|
||||
/* Prototypes */
|
||||
|
|
@ -61,12 +58,9 @@ char *mosaic_get_name(magic_api *, int);
|
|||
int mosaic_get_group(magic_api *, int);
|
||||
char *mosaic_get_description(magic_api *, int, int);
|
||||
void mosaic_paint(void *, int, SDL_Surface *, SDL_Surface *, int, int);
|
||||
void mosaic_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int,
|
||||
int, int, SDL_Rect *);
|
||||
void mosaic_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int,
|
||||
int, SDL_Rect *);
|
||||
void mosaic_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int,
|
||||
SDL_Rect *);
|
||||
void mosaic_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
|
||||
void mosaic_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
|
||||
void mosaic_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
|
||||
void mosaic_shutdown(magic_api *);
|
||||
void mosaic_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
|
|
@ -76,7 +70,8 @@ void mosaic_switchout(magic_api *, int, int, SDL_Surface *);
|
|||
int mosaic_modes(magic_api *, int);
|
||||
Uint8 mosaic_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 mosaic_default_size(magic_api * api, int which, int mode);
|
||||
void mosaic_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void mosaic_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
static const int mosaic_AMOUNT = 300;
|
||||
|
|
@ -112,8 +107,7 @@ const int mosaic_groups[mosaic_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *mosaic_descs[mosaic_NUM_TOOLS][2] = {
|
||||
{gettext_noop
|
||||
("Click and drag the mouse to add a mosaic effect to parts of your picture."),
|
||||
{gettext_noop("Click and drag the mouse to add a mosaic effect to parts of your picture."),
|
||||
gettext_noop("Click to add a mosaic effect to your entire picture."),},
|
||||
};
|
||||
|
||||
|
|
@ -131,8 +125,7 @@ int mosaic_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < mosaic_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
mosaic_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, mosaic_snd_filenames[i]);
|
||||
mosaic_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -149,8 +142,7 @@ SDL_Surface *mosaic_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
mosaic_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, mosaic_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +159,7 @@ int mosaic_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *mosaic_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *mosaic_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(mosaic_descs[which][mode - 1])));
|
||||
}
|
||||
|
|
@ -181,21 +172,18 @@ static int mosaic_grey(Uint8 r1, Uint8 g1, Uint8 b1)
|
|||
|
||||
// Do the effect for the full image
|
||||
static void do_mosaic_full(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
int x, y;
|
||||
|
||||
Uint32 amask =
|
||||
~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
Uint32 amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
SDL_Surface *mosaic_temp = SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
canvas->w,
|
||||
canvas->h,
|
||||
canvas->format->
|
||||
BitsPerPixel,
|
||||
canvas->format->BitsPerPixel,
|
||||
canvas->format->Rmask,
|
||||
canvas->format->Gmask,
|
||||
canvas->format->Bmask,
|
||||
|
|
@ -229,21 +217,17 @@ static void do_mosaic_full(void *ptr, SDL_Surface * canvas,
|
|||
/* Paint the brush, noise is yet done at switchin,
|
||||
blurs 2 pixels around the brush in order to get sharpen well done.*/
|
||||
void mosaic_paint(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)
|
||||
{
|
||||
int i, j, pix_row_pos;
|
||||
|
||||
magic_api *api = (magic_api *) ptr_to_api;
|
||||
|
||||
for (j = max(0, y - mosaic_RADIUS - 2);
|
||||
j < min(canvas->h, y + mosaic_RADIUS + 2); j++)
|
||||
for (j = max(0, y - mosaic_RADIUS - 2); j < min(canvas->h, y + mosaic_RADIUS + 2); j++)
|
||||
{
|
||||
pix_row_pos = j * canvas->w;
|
||||
for (i = max(0, x - mosaic_RADIUS - 2);
|
||||
i < min(canvas->w, x + mosaic_RADIUS + 2); i++)
|
||||
if (!mosaic_blured[pix_row_pos + i]
|
||||
&& api->in_circle(i - x, j - y, mosaic_RADIUS + 2))
|
||||
for (i = max(0, x - mosaic_RADIUS - 2); i < min(canvas->w, x + mosaic_RADIUS + 2); i++)
|
||||
if (!mosaic_blured[pix_row_pos + i] && api->in_circle(i - x, j - y, mosaic_RADIUS + 2))
|
||||
{
|
||||
mosaic_blur_pixel(api, canvas_blur, canvas_noise, i, j);
|
||||
mosaic_blured[pix_row_pos + i] = 1; /* Track what are yet blured */
|
||||
|
|
@ -262,8 +246,7 @@ void mosaic_paint(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void mosaic_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_paint);
|
||||
|
||||
|
|
@ -277,8 +260,7 @@ void mosaic_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void mosaic_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)
|
||||
|
|
@ -302,8 +284,7 @@ void mosaic_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -323,21 +304,21 @@ void mosaic_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void mosaic_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void mosaic_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int mosaic_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int mosaic_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Add noise to a pixel
|
||||
static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas,
|
||||
int noise_AMOUNT, int x, int y)
|
||||
static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas, int noise_AMOUNT, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -345,21 +326,16 @@ static void mosaic_noise_pixel(void *ptr, SDL_Surface * canvas,
|
|||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1],
|
||||
&temp[2]);
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
temp2[k] =
|
||||
clamp(0.0, (int) temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0,
|
||||
255.0);
|
||||
temp2[k] = clamp(0.0, (int)temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, 255.0);
|
||||
}
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
}
|
||||
|
||||
//Blur a pixel
|
||||
static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int i, j, k;
|
||||
|
|
@ -384,8 +360,7 @@ static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas,
|
|||
for (j = -2; j < 3; j++)
|
||||
{
|
||||
//Add the pixels around the current one wieghted
|
||||
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0],
|
||||
&temp[1], &temp[2]);
|
||||
SDL_GetRGB(api->getpixel(last, x + i, y + j), last->format, &temp[0], &temp[1], &temp[2]);
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
blurValue[k] += temp[k] * weight[i + 2][j + 2];
|
||||
|
|
@ -396,14 +371,11 @@ static void mosaic_blur_pixel(void *ptr, SDL_Surface * canvas,
|
|||
{
|
||||
blurValue[k] /= 273;
|
||||
}
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, blurValue[0], blurValue[1],
|
||||
blurValue[2]));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, blurValue[0], blurValue[1], blurValue[2]));
|
||||
}
|
||||
|
||||
//Sharpen a pixel
|
||||
static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -431,8 +403,7 @@ static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas,
|
|||
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_grey(r1, g1, b1);
|
||||
sobel_1 += grey * sobel_weights_1[i + 1][j + 1];
|
||||
sobel_2 += grey * sobel_weights_2[i + 1][j + 1];
|
||||
|
|
@ -451,8 +422,7 @@ static void mosaic_sharpen_pixel(void *ptr, SDL_Surface * canvas,
|
|||
|
||||
}
|
||||
|
||||
void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
int y, x;
|
||||
Uint32 amask;
|
||||
|
|
@ -464,16 +434,13 @@ void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
exit(1);
|
||||
}
|
||||
|
||||
amask =
|
||||
~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
|
||||
canvas_noise = 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);
|
||||
|
||||
SDL_BlitSurface(canvas, NULL, canvas_noise, NULL);
|
||||
|
||||
|
|
@ -489,23 +456,18 @@ void mosaic_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
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_sharp = 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);
|
||||
reset_mosaic_blured(canvas);
|
||||
}
|
||||
|
||||
void mosaic_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
SDL_FreeSurface(canvas_noise);
|
||||
SDL_FreeSurface(canvas_blur);
|
||||
|
|
@ -542,8 +504,9 @@ Uint8 mosaic_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 4;
|
||||
}
|
||||
|
||||
void mosaic_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void mosaic_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
mosaic_RADIUS = size * 4;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,30 +42,25 @@ SDL_Surface *negative_get_icon(magic_api * api, int which);
|
|||
char *negative_get_name(magic_api * api, int which);
|
||||
int negative_get_group(magic_api * api, int which);
|
||||
char *negative_get_description(magic_api * api, int which, int mode);
|
||||
static void do_negative(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_negative(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void negative_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 negative_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 negative_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void negative_shutdown(magic_api * api);
|
||||
void negative_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int negative_requires_colors(magic_api * api, int which);
|
||||
void negative_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void negative_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void negative_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void negative_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int negative_modes(magic_api * api, int which);
|
||||
Uint8 negative_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 negative_default_size(magic_api * api, int which, int mode);
|
||||
void negative_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void negative_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
@ -86,14 +81,11 @@ const char *negative_names[negative_NUM_TOOLS] = {
|
|||
|
||||
const char *negative_descs[negative_NUM_TOOLS][2] = {
|
||||
{
|
||||
gettext_noop
|
||||
("Click and drag the mouse around to make your painting negative."),
|
||||
gettext_noop("Click and drag the mouse around to make your painting negative."),
|
||||
gettext_noop("Click to turn your painting into its negative.")},
|
||||
{
|
||||
gettext_noop
|
||||
("Click and drag the mouse around to change colors to their opposites -- their complementary colors."),
|
||||
gettext_noop
|
||||
("Click to turn all colors in your painting into their opposites -- their complementary colors.")},
|
||||
gettext_noop("Click and drag the mouse around to change colors to their opposites -- their complementary colors."),
|
||||
gettext_noop("Click to turn all colors in your painting into their opposites -- their complementary colors.")},
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -101,8 +93,7 @@ int negative_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/negative.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/negative.wav", api->data_directory);
|
||||
|
||||
negative_snd = Mix_LoadWAV(fname);
|
||||
|
||||
|
|
@ -124,8 +115,7 @@ SDL_Surface *negative_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
negative_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, negative_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -136,15 +126,13 @@ char *negative_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int negative_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int negative_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
// Return our description, localized:
|
||||
char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
int mode_idx;
|
||||
|
||||
|
|
@ -164,8 +152,7 @@ char *negative_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
return (strdup(gettext_noop(negative_descs[which][mode_idx])));
|
||||
}
|
||||
|
||||
static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 * new_r, Uint8 * new_g, Uint8 * new_b)
|
||||
static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b, Uint8 * new_r, Uint8 * new_g, Uint8 * new_b)
|
||||
{
|
||||
float h, s, v, new_h;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -189,8 +176,7 @@ static void negative_calc(void *ptr, int which, Uint8 r, Uint8 g, Uint8 b,
|
|||
}
|
||||
|
||||
// Callback that does the negative color effect on a circle centered around x,y
|
||||
static void do_negative(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_negative(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
Uint8 r, g, b, new_r, new_g, new_b;
|
||||
|
|
@ -204,8 +190,7 @@ static void do_negative(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b);
|
||||
negative_calc(api, which, r, g, b, &new_r, &new_g, &new_b);
|
||||
api->putpixel(canvas, xx, yy,
|
||||
SDL_MapRGB(canvas->format, new_r, new_g, new_b));
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, new_r, new_g, new_b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -213,13 +198,12 @@ static void do_negative(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Ask Tux Paint to call our 'do_negative()' callback over a line
|
||||
void negative_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)
|
||||
{
|
||||
SDL_LockSurface(last);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_negative);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_negative);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -250,8 +234,7 @@ void negative_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Ask Tux Paint to call our 'do_negative()' callback at a single point
|
||||
void negative_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_PAINT)
|
||||
negative_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -266,8 +249,7 @@ void negative_click(magic_api * api, int which, int mode,
|
|||
{
|
||||
SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b);
|
||||
negative_calc(api, which, r, g, b, &new_r, &new_g, &new_b);
|
||||
api->putpixel(canvas, xx, yy,
|
||||
SDL_MapRGB(canvas->format, new_r, new_g, new_b));
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, new_r, new_g, new_b));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,8 +267,7 @@ void negative_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -298,38 +279,37 @@ void negative_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// We don't use colors
|
||||
void negative_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void negative_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// We don't use colors
|
||||
int negative_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int negative_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void negative_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void negative_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int negative_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int negative_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
|
||||
Uint8 negative_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode) {
|
||||
Uint8 negative_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return 8;
|
||||
else
|
||||
|
|
@ -341,7 +321,9 @@ Uint8 negative_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
return 4;
|
||||
}
|
||||
|
||||
void negative_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void negative_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
negative_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,7 @@ const int noise_groups[noise_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *noise_descs[noise_NUM_TOOLS][2] = {
|
||||
{gettext_noop
|
||||
("Click and drag the mouse to add noise to parts of your picture."),
|
||||
{gettext_noop("Click and drag the mouse to add noise to parts of your picture."),
|
||||
gettext_noop("Click to add noise to your entire picture."),},
|
||||
};
|
||||
|
||||
|
|
@ -81,15 +80,11 @@ SDL_Surface *noise_get_icon(magic_api * api, int which);
|
|||
char *noise_get_name(magic_api * api, int which);
|
||||
int noise_get_group(magic_api * api, int which);
|
||||
char *noise_get_description(magic_api * api, int which, int mode);
|
||||
static void do_noise_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which);
|
||||
static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_noise_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which);
|
||||
static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void noise_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 noise_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void noise_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -98,15 +93,14 @@ void noise_shutdown(magic_api * api);
|
|||
void noise_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int noise_requires_colors(magic_api * api, int which);
|
||||
void noise_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void noise_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void noise_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void noise_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int noise_modes(magic_api * api, int which);
|
||||
int noise_get_tool_count(magic_api * api ATTRIBUTE_UNUSED);
|
||||
Uint8 noise_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 noise_default_size(magic_api * api, int which, int mode);
|
||||
void noise_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void noise_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 noise_api_version(void)
|
||||
|
|
@ -124,8 +118,7 @@ int noise_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < noise_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
noise_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, noise_snd_filenames[i]);
|
||||
noise_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -141,8 +134,7 @@ SDL_Surface *noise_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
noise_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, noise_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -159,16 +151,14 @@ int noise_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *noise_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *noise_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(noise_descs[which][mode - 1])));
|
||||
}
|
||||
|
||||
//Do the effect for one pixel
|
||||
static void do_noise_pixel(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;
|
||||
|
||||
|
|
@ -176,22 +166,17 @@ static void do_noise_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
double temp2[3];
|
||||
int k;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1],
|
||||
&temp[2]);
|
||||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
|
||||
for (k = 0; k < 3; k++)
|
||||
{
|
||||
temp2[k] =
|
||||
clamp(0.0, (int) temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0,
|
||||
255.0);
|
||||
temp2[k] = clamp(0.0, (int)temp[k] - (rand() % noise_AMOUNT) + noise_AMOUNT / 2.0, 255.0);
|
||||
}
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
|
||||
|
||||
}
|
||||
|
||||
// Do the effect for the full image
|
||||
static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which)
|
||||
static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
|
@ -205,8 +190,7 @@ static void do_noise_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
|||
}
|
||||
|
||||
//do the effect for the brush
|
||||
static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -215,8 +199,7 @@ static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
for (xx = x - noise_RADIUS; xx < x + noise_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, noise_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, noise_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_noise_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
|
|
@ -226,12 +209,10 @@ static void do_noise_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void noise_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_noise_brush);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_noise_brush);
|
||||
|
||||
api->playsound(noise_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -258,8 +239,7 @@ void noise_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void noise_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_PAINT)
|
||||
noise_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -279,8 +259,7 @@ void noise_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -300,27 +279,26 @@ void noise_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void noise_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void noise_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int noise_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int noise_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void noise_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void noise_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +321,9 @@ Uint8 noise_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 4;
|
||||
}
|
||||
|
||||
void noise_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void noise_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
noise_RADIUS = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@
|
|||
|
||||
static void perspective_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect,
|
||||
float step);
|
||||
int x, int y, SDL_Rect * update_rect, float step);
|
||||
Uint32 perspective_api_version(void);
|
||||
int perspective_init(magic_api * api, Uint32 disabled_features);
|
||||
int perspective_get_tool_count(magic_api * api);
|
||||
|
|
@ -63,16 +62,13 @@ int perspective_get_group(magic_api * api, int which);
|
|||
char *perspective_get_description(magic_api * api, int which, int mode);
|
||||
|
||||
void perspective_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 perspective_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 perspective_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 perspective_shutdown(magic_api * api);
|
||||
|
||||
|
|
@ -81,24 +77,21 @@ void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
int perspective_requires_colors(magic_api * api, int which);
|
||||
|
||||
void perspective_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void perspective_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
||||
void perspective_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void perspective_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
||||
int perspective_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);
|
||||
|
||||
void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
Uint8 perspective_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 perspective_default_size(magic_api * api, int which, int mode);
|
||||
void perspective_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void perspective_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -115,8 +108,7 @@ int click_x, click_y;
|
|||
int latest_x, latest_y;
|
||||
int new_w, new_h, old_h, sound_h;
|
||||
|
||||
int perspective_average_r, perspective_average_g, perspective_average_b,
|
||||
perspective_average_count;
|
||||
int perspective_average_r, perspective_average_g, perspective_average_b, perspective_average_count;
|
||||
Uint32 pixel_average, black, white;
|
||||
|
||||
int otop_left_x, otop_left_y, otop_right_x, otop_right_y;
|
||||
|
|
@ -178,19 +170,15 @@ const char *perspective_names[perspective_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *perspective_descs[perspective_NUM_TOOLS] = {
|
||||
gettext_noop
|
||||
("Click on the corners and drag where you want to stretch the picture."),
|
||||
gettext_noop("Click on the corners and drag where you want to stretch the picture."),
|
||||
|
||||
gettext_noop("Click to turn your picture into 2-by-2 panels."),
|
||||
|
||||
gettext_noop
|
||||
("Click and drag up to zoom in the picture. Drag down to zoom out and tile the picture."),
|
||||
gettext_noop("Click and drag up to zoom in the picture. Drag down to zoom out and tile the picture."),
|
||||
|
||||
gettext_noop
|
||||
("Click and drag up to zoom in or drag down to zoom out the picture."),
|
||||
gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."),
|
||||
|
||||
gettext_noop
|
||||
("Click and drag up to rush in or drag down to rush out the picture."),
|
||||
gettext_noop("Click and drag up to rush in or drag down to rush out the picture."),
|
||||
};
|
||||
|
||||
Uint32 perspective_api_version(void)
|
||||
|
|
@ -206,8 +194,7 @@ int perspective_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i <= perspective_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
perspective_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, perspective_snd_filenames[i]);
|
||||
perspective_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -223,8 +210,7 @@ SDL_Surface *perspective_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
perspective_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, perspective_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -235,15 +221,13 @@ char *perspective_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (the same):
|
||||
int perspective_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int perspective_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop(perspective_descs[which])));
|
||||
}
|
||||
|
|
@ -252,8 +236,7 @@ char *perspective_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
// Affect the canvas on drag:
|
||||
void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (canvas_back == NULL)
|
||||
return;
|
||||
|
|
@ -302,8 +285,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
/* Draw a square and the current shape relative to it as a visual reference */
|
||||
/* square */
|
||||
api->line(api, which, canvas, last, otop_left_x, otop_left_y,
|
||||
otop_right_x, otop_right_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, otop_left_x, otop_left_y, otop_right_x, otop_right_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, otop_left_x, otop_left_y,
|
||||
obottom_left_x, obottom_left_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, obottom_left_x, obottom_left_y,
|
||||
|
|
@ -312,10 +294,8 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
otop_right_x, otop_right_y, 1, perspective_line);
|
||||
|
||||
/* shape */
|
||||
api->line(api, which, canvas, last, top_left_x, top_left_y, top_right_x,
|
||||
top_right_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, top_left_x, top_left_y,
|
||||
bottom_left_x, bottom_left_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, top_left_x, top_left_y, top_right_x, top_right_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, top_left_x, top_left_y, bottom_left_x, bottom_left_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, bottom_left_x, bottom_left_y,
|
||||
bottom_right_x, bottom_right_y, 1, perspective_line);
|
||||
api->line(api, which, canvas, last, bottom_right_x, bottom_right_y,
|
||||
|
|
@ -324,8 +304,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
|
||||
api->playsound(perspective_snd_effect[which], (x * 255) / canvas->w,
|
||||
255);
|
||||
api->playsound(perspective_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
}
|
||||
break;
|
||||
case TOOL_ZOOM:
|
||||
|
|
@ -340,9 +319,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
|
||||
SDL_FillRect(canvas, update_rect,
|
||||
SDL_MapRGB(canvas->format, perspective_r, perspective_g,
|
||||
perspective_b));
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
}
|
||||
|
||||
new_h = max(1, old_h + click_y - y);
|
||||
|
|
@ -381,8 +358,7 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void perspective_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)
|
||||
{
|
||||
click_x = x;
|
||||
click_y = y;
|
||||
|
|
@ -482,8 +458,7 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on release:
|
||||
void perspective_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)
|
||||
{
|
||||
if (canvas_back == NULL)
|
||||
return;
|
||||
|
|
@ -496,9 +471,7 @@ void perspective_release(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
|
||||
if (which == TOOL_ZOOM || which == TOOL_PERSPECTIVE)
|
||||
SDL_FillRect(canvas, update_rect,
|
||||
SDL_MapRGB(canvas->format, perspective_r, perspective_g,
|
||||
perspective_b));
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
|
||||
if (which == TOOL_PERSPECTIVE)
|
||||
{
|
||||
|
|
@ -508,7 +481,7 @@ void perspective_release(magic_api * api, int which,
|
|||
{
|
||||
int h1, h2, w, h, hh, dx1, dy1;
|
||||
SDL_Surface *scaled_surf;
|
||||
SDL_Surface * aux1;
|
||||
SDL_Surface *aux1;
|
||||
|
||||
if (new_h == canvas->h || new_h == 0)
|
||||
{
|
||||
|
|
@ -536,9 +509,10 @@ void perspective_release(magic_api * api, int which,
|
|||
|
||||
aux1 = api->scale(last, last->w, last->h, 0);
|
||||
for (h = 0; h < h2 - h1; h++)
|
||||
{
|
||||
if (h % 10 == 0)
|
||||
{
|
||||
if (h % 10 == 0) {
|
||||
api->update_progress_bar();
|
||||
api->update_progress_bar();
|
||||
}
|
||||
hh = h2 - h;
|
||||
w = canvas->w * hh / canvas->h;
|
||||
|
|
@ -546,67 +520,68 @@ void perspective_release(magic_api * api, int which,
|
|||
dx1 = (canvas->w - scaled_surf->w) / 2;
|
||||
dy1 = (canvas->h - scaled_surf->h) / 2;
|
||||
SDL_Rect rrr;
|
||||
|
||||
rrr.x = dx1;
|
||||
rrr.y = dy1;
|
||||
rrr.w = dx1 + scaled_surf->w;
|
||||
rrr.h = dy1 + scaled_surf->h;
|
||||
SDL_SetSurfaceBlendMode( scaled_surf, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetSurfaceAlphaMod(scaled_surf,24);
|
||||
SDL_SetSurfaceBlendMode(scaled_surf, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetSurfaceAlphaMod(scaled_surf, 24);
|
||||
SDL_BlitSurface(scaled_surf, NULL, aux1, &rrr);
|
||||
SDL_FreeSurface(scaled_surf);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_BlitSurface(aux1, NULL, canvas, NULL);
|
||||
SDL_FreeSurface(aux1);
|
||||
/*
|
||||
for (h = 0; h < (h2 - h1); h++)
|
||||
{
|
||||
if ((h / 2) % 10 == 0)
|
||||
api->update_progress_bar();
|
||||
for (h = 0; h < (h2 - h1); h++)
|
||||
{
|
||||
if ((h / 2) % 10 == 0)
|
||||
api->update_progress_bar();
|
||||
|
||||
// if (new_h < canvas->h)
|
||||
hh = h2 - h;
|
||||
// else
|
||||
// hh = new_h + h;
|
||||
// if (new_h < canvas->h)
|
||||
hh = h2 - h;
|
||||
// else
|
||||
// hh = new_h + h;
|
||||
|
||||
w = canvas->w * hh / canvas->h;
|
||||
scaled_surf = api->scale(last, w, hh, 0);
|
||||
w = canvas->w * hh / canvas->h;
|
||||
scaled_surf = api->scale(last, w, hh, 0);
|
||||
|
||||
dx1 = (canvas->w - scaled_surf->w) / 2;
|
||||
dy1 = (canvas->h - scaled_surf->h) / 2;
|
||||
dx1 = (canvas->w - scaled_surf->w) / 2;
|
||||
dy1 = (canvas->h - scaled_surf->h) / 2;
|
||||
|
||||
for (y = 0; y < scaled_surf->h; y++)
|
||||
{
|
||||
if (dy1 + y >= 0 && dy1 + y < canvas->h)
|
||||
{
|
||||
for (x = 0; x < scaled_surf->w; x++)
|
||||
{
|
||||
if (dx1 + x >= 0 && dx1 + x < canvas->w)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(scaled_surf, x, y),
|
||||
scaled_surf->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(canvas, dx1 + x, dy1 + y),
|
||||
canvas->format, &r2, &g2, &b2);
|
||||
pct = (float) ((float) h / ((float) h2 - (float) h1));
|
||||
// if (new_h > canvas->h)
|
||||
// pct = 1.0 - pct;
|
||||
r =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(r1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(r2) * (pct)));
|
||||
g =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(g1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(g2) * (pct)));
|
||||
b =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(b1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(b2) * (pct)));
|
||||
for (y = 0; y < scaled_surf->h; y++)
|
||||
{
|
||||
if (dy1 + y >= 0 && dy1 + y < canvas->h)
|
||||
{
|
||||
for (x = 0; x < scaled_surf->w; x++)
|
||||
{
|
||||
if (dx1 + x >= 0 && dx1 + x < canvas->w)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(scaled_surf, x, y),
|
||||
scaled_surf->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(canvas, dx1 + x, dy1 + y),
|
||||
canvas->format, &r2, &g2, &b2);
|
||||
pct = (float) ((float) h / ((float) h2 - (float) h1));
|
||||
// if (new_h > canvas->h)
|
||||
// pct = 1.0 - pct;
|
||||
r =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(r1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(r2) * (pct)));
|
||||
g =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(g1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(g2) * (pct)));
|
||||
b =
|
||||
api->linear_to_sRGB((api->sRGB_to_linear(b1) * (1.0 - pct)) +
|
||||
(api->sRGB_to_linear(b2) * (pct)));
|
||||
|
||||
api->putpixel(canvas, dx1 + x, dy1 + y,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
api->putpixel(canvas, dx1 + x, dy1 + y,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -623,9 +598,7 @@ void perspective_release(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
|
||||
if (which == TOOL_ZOOM)
|
||||
SDL_FillRect(canvas, update_rect,
|
||||
SDL_MapRGB(canvas->format, perspective_r, perspective_g,
|
||||
perspective_b));
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
|
||||
|
||||
if (new_h < canvas->h)
|
||||
|
|
@ -670,9 +643,7 @@ void perspective_release(magic_api * api, int which,
|
|||
aux_w,
|
||||
aux_h,
|
||||
canvas->format->BitsPerPixel,
|
||||
canvas->format->Rmask,
|
||||
canvas->format->Gmask,
|
||||
canvas->format->Bmask, 0);
|
||||
canvas->format->Rmask, canvas->format->Gmask, canvas->format->Bmask, 0);
|
||||
|
||||
SDL_BlitSurface(canvas_back, update_rect, aux_surf, NULL);
|
||||
scaled_surf = api->scale(aux_surf, canvas->w, canvas->h, 0);
|
||||
|
|
@ -691,8 +662,7 @@ void perspective_release(magic_api * api, int which,
|
|||
void perspective_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect, float step)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect, float step)
|
||||
{
|
||||
float i, j;
|
||||
float ax, ay, bx, by, dx, dy;
|
||||
|
|
@ -708,47 +678,42 @@ void perspective_preview(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
|
||||
if (which == TOOL_ZOOM)
|
||||
SDL_FillRect(canvas, update_rect,
|
||||
SDL_MapRGB(canvas->format, perspective_r, perspective_g,
|
||||
perspective_b));
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
else if (which == TOOL_TILEZOOM || which == TOOL_RUSH)
|
||||
SDL_FillRect(canvas, update_rect,
|
||||
SDL_MapRGB(canvas->format, 128, 128, 128));
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, 128, 128, 128));
|
||||
|
||||
ox_distance = otop_right_x - otop_left_x;
|
||||
oy_distance = obottom_left_y - otop_left_y;
|
||||
|
||||
top_advc_x = (float) (top_right_x - top_left_x) / ox_distance;
|
||||
top_advc_y = (float) (top_right_y - top_left_y) / ox_distance;
|
||||
top_advc_x = (float)(top_right_x - top_left_x) / ox_distance;
|
||||
top_advc_y = (float)(top_right_y - top_left_y) / ox_distance;
|
||||
|
||||
left_advc_x = (float) (bottom_left_x - top_left_x) / oy_distance;
|
||||
left_advc_y = (float) (bottom_left_y - top_left_y) / oy_distance;
|
||||
left_advc_x = (float)(bottom_left_x - top_left_x) / oy_distance;
|
||||
left_advc_y = (float)(bottom_left_y - top_left_y) / oy_distance;
|
||||
|
||||
|
||||
right_advc_x = (float) (bottom_right_x - top_right_x) / oy_distance;
|
||||
right_advc_y = (float) (bottom_right_y - top_right_y) / oy_distance;
|
||||
right_advc_x = (float)(bottom_right_x - top_right_x) / oy_distance;
|
||||
right_advc_y = (float)(bottom_right_y - top_right_y) / oy_distance;
|
||||
|
||||
bottom_advc_x = (float) (bottom_right_x - bottom_left_x) / ox_distance;
|
||||
bottom_advc_y = (float) (bottom_right_y - bottom_left_y) / ox_distance;
|
||||
bottom_advc_x = (float)(bottom_right_x - bottom_left_x) / ox_distance;
|
||||
bottom_advc_y = (float)(bottom_right_y - bottom_left_y) / ox_distance;
|
||||
|
||||
center_ofset_x = (otop_left_x - top_left_x) * 2;
|
||||
center_ofset_y = (otop_left_y - top_left_y) * 2;
|
||||
|
||||
for (i = 0; i < canvas->w; i += step)
|
||||
{
|
||||
ax = (float) top_advc_x *i;
|
||||
ay = (float) top_advc_y *i;
|
||||
bx = (float) bottom_advc_x *i + (bottom_left_x - top_left_x) * 2;
|
||||
by = (float) bottom_advc_y *i + (bottom_left_y - top_left_y) * 2;
|
||||
ax = (float)top_advc_x *i;
|
||||
ay = (float)top_advc_y *i;
|
||||
bx = (float)bottom_advc_x *i + (bottom_left_x - top_left_x) * 2;
|
||||
by = (float)bottom_advc_y *i + (bottom_left_y - top_left_y) * 2;
|
||||
|
||||
for (j = 0; j < canvas->h; j += step)
|
||||
{
|
||||
dx = (float) (bx - ax) / canvas->h * j;
|
||||
dy = (float) (by - ay) / canvas->h * j;
|
||||
dx = (float)(bx - ax) / canvas->h * j;
|
||||
dy = (float)(by - ay) / canvas->h * j;
|
||||
|
||||
api->putpixel(canvas, ax + dx - center_ofset_x,
|
||||
ay + dy - center_ofset_y, api->getpixel(canvas_back, i,
|
||||
j));
|
||||
api->putpixel(canvas, ax + dx - center_ofset_x, ay + dy - center_ofset_y, api->getpixel(canvas_back, i, j));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -800,7 +765,8 @@ void perspective_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
void perspective_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect)
|
||||
{
|
||||
if (r != perspective_r || g != perspective_g || b != perspective_b) {
|
||||
if (r != perspective_r || g != perspective_g || b != perspective_b)
|
||||
{
|
||||
perspective_r = r;
|
||||
perspective_g = g;
|
||||
perspective_b = b;
|
||||
|
|
@ -818,8 +784,7 @@ int perspective_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
Uint32 amask;
|
||||
|
||||
|
|
@ -829,29 +794,26 @@ void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
|||
top_left_x = otop_left_x = bottom_left_x = obottom_left_x = canvas->w / 4;
|
||||
top_left_y = otop_left_y = top_right_y = otop_right_y = canvas->h / 4;
|
||||
|
||||
top_right_x = otop_right_x = bottom_right_x = obottom_right_x =
|
||||
canvas->w - otop_left_x;
|
||||
top_right_x = otop_right_x = bottom_right_x = obottom_right_x = canvas->w - otop_left_x;
|
||||
|
||||
bottom_left_y = obottom_left_y = bottom_right_y = obottom_right_y =
|
||||
canvas->h - otop_left_y;
|
||||
bottom_left_y = obottom_left_y = bottom_right_y = obottom_right_y = canvas->h - otop_left_y;
|
||||
|
||||
black = SDL_MapRGBA(canvas->format, 0, 0, 0, 0);
|
||||
white = SDL_MapRGBA(canvas->format, 255, 255, 255, 0);
|
||||
|
||||
amask =
|
||||
~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
amask = ~(canvas->format->Rmask | canvas->format->Gmask | canvas->format->Bmask);
|
||||
|
||||
if (canvas_back == NULL) {
|
||||
if (canvas_back == NULL)
|
||||
{
|
||||
canvas_back = 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);
|
||||
}
|
||||
|
||||
if (canvas_back == NULL) {
|
||||
if (canvas_back == NULL)
|
||||
{
|
||||
fprintf(stderr, "perspective cannot create background canvas!\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -860,11 +822,10 @@ void perspective_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void perspective_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (canvas_back != NULL) {
|
||||
if (canvas_back != NULL)
|
||||
{
|
||||
SDL_FreeSurface(canvas_back);
|
||||
canvas_back = NULL;
|
||||
}
|
||||
|
|
@ -883,8 +844,7 @@ int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
void perspective_line(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr_to_api;
|
||||
|
||||
|
|
@ -898,7 +858,8 @@ void perspective_line(void *ptr_to_api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
|
||||
Uint8 perspective_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 perspective_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -908,6 +869,8 @@ Uint8 perspective_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
void perspective_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 perspective_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ char *pixels_get_name(magic_api * api, int which);
|
|||
int pixels_get_group(magic_api * api, int which);
|
||||
char *pixels_get_description(magic_api * api, int which, int mode);
|
||||
void pixels_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 pixels_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void pixels_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -68,14 +67,13 @@ void pixels_shutdown(magic_api * api);
|
|||
void pixels_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int pixels_requires_colors(magic_api * api, int which);
|
||||
void pixels_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void pixels_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void pixels_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void pixels_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int pixels_modes(magic_api * api, int which);
|
||||
Uint8 pixels_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 pixels_default_size(magic_api * api, int which, int mode);
|
||||
void pixels_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void pixels_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
// No setup required:
|
||||
|
|
@ -83,8 +81,7 @@ int pixels_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/pixels.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/pixels.ogg", api->data_directory);
|
||||
pixel_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -106,30 +103,25 @@ SDL_Surface *pixels_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/pixels.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/pixels.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *pixels_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *pixels_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Pixels")));
|
||||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int pixels_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int pixels_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Click and drag to draw large pixels.")));
|
||||
|
||||
|
|
@ -139,8 +131,7 @@ char *pixels_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
|||
// Do the effect:
|
||||
|
||||
static void do_pixels(void *ptr ATTRIBUTE_UNUSED, 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)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
|
|
@ -149,16 +140,14 @@ static void do_pixels(void *ptr ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
|||
dest.w = pixel_size;
|
||||
dest.h = pixel_size;
|
||||
|
||||
SDL_FillRect(canvas, &dest,
|
||||
SDL_MapRGB(canvas->format, pixels_r, pixels_g, pixels_b));
|
||||
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, pixels_r, pixels_g, pixels_b));
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void pixels_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_pixels);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_pixels);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -190,8 +179,7 @@ void pixels_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void pixels_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)
|
||||
{
|
||||
pixels_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -199,8 +187,7 @@ void pixels_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
void pixels_release(magic_api * api, 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)
|
||||
{
|
||||
api->stopsound();
|
||||
}
|
||||
|
|
@ -213,8 +200,9 @@ void pixels_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void pixels_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 pixels_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)
|
||||
{
|
||||
pixels_r = r;
|
||||
pixels_g = g;
|
||||
|
|
@ -222,21 +210,18 @@ void pixels_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int pixels_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int pixels_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void pixels_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void pixels_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +241,9 @@ Uint8 pixels_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 1;
|
||||
}
|
||||
|
||||
void pixels_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void pixels_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int canv_area_scale;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,30 +57,25 @@ char *puzzle_get_name(magic_api * api, int which);
|
|||
int puzzle_get_group(magic_api * api, int which);
|
||||
char *puzzle_get_description(magic_api * api, int which, int mode);
|
||||
void puzzle_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 puzzle_shutdown(magic_api * api);
|
||||
void puzzle_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int puzzle_requires_colors(magic_api * api, int which);
|
||||
void puzzle_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void puzzle_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void puzzle_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void puzzle_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int puzzle_modes(magic_api * api, int which);
|
||||
static void puzzle_draw(void *ptr, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
static void puzzle_draw(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void puzzle_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 puzzle_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);
|
||||
int gcd(int a, int b);
|
||||
Uint8 puzzle_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 puzzle_default_size(magic_api * api, int which, int mode);
|
||||
void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 puzzle_api_version(void)
|
||||
{
|
||||
|
|
@ -91,8 +86,7 @@ int puzzle_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/puzzle.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/puzzle.wav", api->data_directory);
|
||||
puzzle_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return 1;
|
||||
|
|
@ -107,32 +101,26 @@ SDL_Surface *puzzle_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/puzzle.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/puzzle.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *puzzle_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *puzzle_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Puzzle")));
|
||||
}
|
||||
|
||||
int puzzle_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int puzzle_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
|
||||
char *puzzle_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *puzzle_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click the part of your picture where would you like a puzzle."));
|
||||
return strdup(gettext_noop("Click the part of your picture where would you like a puzzle."));
|
||||
return strdup(gettext_noop("Click to make a puzzle in fullscreen mode."));
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +128,7 @@ void puzzle_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -151,13 +138,14 @@ void puzzle_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
Mix_FreeChunk(puzzle_snd);
|
||||
}
|
||||
|
||||
void puzzle_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void puzzle_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int puzzle_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int puzzle_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -170,22 +158,19 @@ int gcd(int a, int b) //greatest common divisor
|
|||
}
|
||||
|
||||
void puzzle_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
puzzle_gcd = RATIO * gcd(canvas->w, canvas->h);
|
||||
rects_w = (unsigned int) canvas->w / puzzle_gcd;
|
||||
rects_h = (unsigned int) canvas->h / puzzle_gcd;
|
||||
rects_w = (unsigned int)canvas->w / puzzle_gcd;
|
||||
rects_h = (unsigned int)canvas->h / puzzle_gcd;
|
||||
canvas_backup =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
}
|
||||
|
||||
void puzzle_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
SDL_FreeSurface(canvas_backup);
|
||||
canvas_backup = NULL;
|
||||
|
|
@ -197,8 +182,7 @@ int puzzle_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
static void puzzle_draw(void *ptr, int which_tool ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
|
||||
|
||||
|
|
@ -258,20 +242,14 @@ static void puzzle_draw(void *ptr, int which_tool ATTRIBUTE_UNUSED,
|
|||
|
||||
void puzzle_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2,
|
||||
y - puzzle_gcd / 2);
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y - puzzle_gcd / 2);
|
||||
|
||||
puzzle_draw(api, which, canvas, last, x - 1.5 * puzzle_gcd / 2,
|
||||
y - puzzle_gcd / 2);
|
||||
puzzle_draw(api, which, canvas, last, x + 0.5 * puzzle_gcd,
|
||||
y - puzzle_gcd / 2);
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2,
|
||||
y - 1.5 * puzzle_gcd);
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2,
|
||||
y + 0.5 * puzzle_gcd);
|
||||
puzzle_draw(api, which, canvas, last, x - 1.5 * puzzle_gcd / 2, y - puzzle_gcd / 2);
|
||||
puzzle_draw(api, which, canvas, last, x + 0.5 * puzzle_gcd, y - puzzle_gcd / 2);
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y - 1.5 * puzzle_gcd);
|
||||
puzzle_draw(api, which, canvas, last, x - puzzle_gcd / 2, y + 0.5 * puzzle_gcd);
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -280,8 +258,7 @@ void puzzle_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void puzzle_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)
|
||||
{
|
||||
puzzle_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -297,9 +274,9 @@ Uint8 puzzle_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 4;
|
||||
}
|
||||
|
||||
void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void puzzle_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
RATIO = size + 1;
|
||||
puzzle_switchin(api, which, mode, canvas);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,37 +60,30 @@ int rails_get_group(magic_api * api, int which);
|
|||
char *rails_get_description(magic_api * api, int which, int mode);
|
||||
int rails_requires_colors(magic_api * api, int which);
|
||||
void rails_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void rails_shutdown(magic_api * api);
|
||||
void rails_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rails_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rails_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rails_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
inline unsigned int rails_get_segment(int x, int y);
|
||||
|
||||
#define POINT_TYPE typeof(((SDL_Rect *)NULL)->x)
|
||||
inline void rails_extract_coords_from_segment(unsigned int segment,
|
||||
POINT_TYPE * x, POINT_TYPE * y);
|
||||
inline void rails_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y);
|
||||
static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src);
|
||||
static void rails_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src);
|
||||
static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src,
|
||||
unsigned int direction);
|
||||
static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, unsigned int direction);
|
||||
void rails_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
static Uint8 rails_select_image(Uint16 segment);
|
||||
static void rails_draw(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
unsigned int segment);
|
||||
SDL_Surface * last, int x, int y, unsigned int segment);
|
||||
|
||||
static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void rails_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
Uint8 rails_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rails_default_size(magic_api * api, int which, int mode);
|
||||
void rails_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void rails_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 rails_api_version(void)
|
||||
{
|
||||
|
|
@ -102,8 +95,10 @@ int rails_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
return (MODE_PAINT);
|
||||
}
|
||||
|
||||
void rails_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rails_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -112,19 +107,15 @@ int rails_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
char fname[1024];
|
||||
Uint8 i; //is always < 3, so Uint8 seems to be a good idea
|
||||
|
||||
rails_images = (char **) malloc(sizeof(char *) * 4);
|
||||
rails_images = (char **)malloc(sizeof(char *) * 4);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
rails_images[i] = (char *) malloc(sizeof(char) * 1024);
|
||||
rails_images[i] = (char *)malloc(sizeof(char) * 1024);
|
||||
|
||||
snprintf(rails_images[0], 1024 * sizeof(char),
|
||||
"%simages/magic/rails_one.png", api->data_directory);
|
||||
snprintf(rails_images[1], 1024 * sizeof(char),
|
||||
"%simages/magic/rails_three.png", api->data_directory);
|
||||
snprintf(rails_images[2], 1024 * sizeof(char),
|
||||
"%simages/magic/rails_four.png", api->data_directory);
|
||||
snprintf(rails_images[3], 1024 * sizeof(char),
|
||||
"%simages/magic/rails_corner.png", api->data_directory);
|
||||
snprintf(rails_images[0], 1024 * sizeof(char), "%simages/magic/rails_one.png", api->data_directory);
|
||||
snprintf(rails_images[1], 1024 * sizeof(char), "%simages/magic/rails_three.png", api->data_directory);
|
||||
snprintf(rails_images[2], 1024 * sizeof(char), "%simages/magic/rails_four.png", api->data_directory);
|
||||
snprintf(rails_images[3], 1024 * sizeof(char), "%simages/magic/rails_corner.png", api->data_directory);
|
||||
|
||||
rails_one = IMG_Load(rails_images[0]);
|
||||
rails_three = IMG_Load(rails_images[1]);
|
||||
|
|
@ -134,8 +125,7 @@ int rails_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
img_w = rails_one->w;
|
||||
img_h = rails_one->h;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/rails.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/rails.wav", api->data_directory);
|
||||
rails_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -150,35 +140,27 @@ SDL_Surface *rails_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rails.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rails.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *rails_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *rails_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Rails"));
|
||||
}
|
||||
|
||||
int rails_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rails_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
char *rails_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *rails_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click and drag to draw train track rails on your picture."));
|
||||
return strdup(gettext_noop("Click and drag to draw train track rails on your picture."));
|
||||
}
|
||||
|
||||
int rails_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rails_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -187,8 +169,7 @@ void rails_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -212,28 +193,24 @@ void rails_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
void rails_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
//we've to compute the quantity of segments in each direction
|
||||
|
||||
canvas_backup =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
SDL_BlitSurface(canvas, NULL, canvas_backup, NULL);
|
||||
rails_segments_x = rails_math_ceil(canvas->w, img_w);
|
||||
rails_segments_y = rails_math_ceil(canvas->h, img_h);
|
||||
//status_of_segments[0] will not be used, we write in rails_status_of_segments[1 to segments_x*segments_y]
|
||||
rails_status_of_segments =
|
||||
(Uint8 *) calloc(rails_segments_x * rails_segments_y + 1, sizeof(Uint8));
|
||||
rails_status_of_segments = (Uint8 *) calloc(rails_segments_x * rails_segments_y + 1, sizeof(Uint8));
|
||||
}
|
||||
|
||||
void rails_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (rails_status_of_segments != NULL)
|
||||
{
|
||||
|
|
@ -248,7 +225,7 @@ inline int rails_math_ceil(int x, int y)
|
|||
{
|
||||
int temp;
|
||||
|
||||
temp = (int) x / y;
|
||||
temp = (int)x / y;
|
||||
|
||||
if (x % y)
|
||||
return temp + 1;
|
||||
|
|
@ -269,11 +246,10 @@ inline unsigned int rails_get_segment(int x, int y)
|
|||
|
||||
}
|
||||
|
||||
inline void rails_extract_coords_from_segment(unsigned int segment,
|
||||
POINT_TYPE * x, POINT_TYPE * y)
|
||||
inline void rails_extract_coords_from_segment(unsigned int segment, POINT_TYPE * x, POINT_TYPE * y)
|
||||
{ //extracts the coords of the beginning and the segment
|
||||
*x = ((segment % rails_segments_x) - 1) * img_w; //useful to set update_rect as small as possible
|
||||
*y = (int) (segment / rails_segments_x) * img_h;
|
||||
*y = (int)(segment / rails_segments_x) * img_h;
|
||||
}
|
||||
|
||||
static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src)
|
||||
|
|
@ -296,8 +272,7 @@ static void rails_flip_flop(void *ptr, SDL_Surface * dest, SDL_Surface * src)
|
|||
api->putpixel(dest, x, y, api->getpixel(src, y, x));
|
||||
}
|
||||
|
||||
static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src,
|
||||
unsigned int direction)
|
||||
static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src, unsigned int direction)
|
||||
//src and dest must have same size
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -319,8 +294,7 @@ static void rails_rotate(void *ptr, SDL_Surface * dest, SDL_Surface * src,
|
|||
}
|
||||
|
||||
void rails_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
rails_segment_modified_last = 0;
|
||||
rails_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
|
|
@ -331,8 +305,7 @@ static Uint8 rails_select_image(Uint16 segment)
|
|||
int take_up, take_down;
|
||||
int val_up, val_down, val_left, val_right;
|
||||
int from_top = 0, from_bottom = 0, from_left = 0, from_right = 0;
|
||||
int from_top_right = 0, from_top_left = 0, from_bottom_right =
|
||||
0, from_bottom_left = 0;
|
||||
int from_top_right = 0, from_top_left = 0, from_bottom_right = 0, from_bottom_left = 0;
|
||||
int TOP = 0, BOTTOM = 0, LEFT = 0, RIGHT = 0;
|
||||
|
||||
//Checking from were we come...
|
||||
|
|
@ -387,7 +360,7 @@ static Uint8 rails_select_image(Uint16 segment)
|
|||
val_up = rails_status_of_segments[take_up];
|
||||
|
||||
take_down = segment + rails_segments_x;
|
||||
if (take_down > (signed) (rails_segments_x * rails_segments_y))
|
||||
if (take_down > (signed)(rails_segments_x * rails_segments_y))
|
||||
val_down = SEG_NONE;
|
||||
else
|
||||
val_down = rails_status_of_segments[take_down];
|
||||
|
|
@ -446,8 +419,7 @@ static Uint8 rails_select_image(Uint16 segment)
|
|||
|
||||
static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
ATTRIBUTE_UNUSED SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x,
|
||||
int y ATTRIBUTE_UNUSED, unsigned int segment)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y ATTRIBUTE_UNUSED, unsigned int segment)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
SDL_Surface *result, *temp;
|
||||
|
|
@ -458,8 +430,7 @@ static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
if (segment > rails_segments_x * rails_segments_y)
|
||||
return;
|
||||
//modification_rect.x and modification_rect.y are set by function
|
||||
rails_extract_coords_from_segment(segment, &modification_rect.x,
|
||||
&modification_rect.y);
|
||||
rails_extract_coords_from_segment(segment, &modification_rect.x, &modification_rect.y);
|
||||
modification_rect.h = img_w;
|
||||
modification_rect.w = img_h;
|
||||
|
||||
|
|
@ -553,8 +524,7 @@ static void rails_draw(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
api->playsound(rails_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
rails_segment_modified = rails_get_segment(x, y);
|
||||
|
||||
|
|
@ -563,18 +533,15 @@ static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
|||
return;
|
||||
if (rails_segment_modified > 0)
|
||||
{
|
||||
rails_draw((void *) ptr, which, canvas, last, x, y,
|
||||
rails_segment_modified);
|
||||
rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified);
|
||||
}
|
||||
if (rails_segment_modified_last > 0)
|
||||
rails_draw((void *) ptr, which, canvas, last, x, y,
|
||||
rails_segment_modified_last);
|
||||
rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified_last);
|
||||
|
||||
if (rails_segment_to_add > 0)
|
||||
{
|
||||
rails_draw((void *) ptr, which, canvas, last, x, y, rails_segment_to_add);
|
||||
rails_draw((void *) ptr, which, canvas, last, x, y,
|
||||
rails_segment_modified_last);
|
||||
rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_to_add);
|
||||
rails_draw((void *)ptr, which, canvas, last, x, y, rails_segment_modified_last);
|
||||
rails_segment_to_add = 0;
|
||||
}
|
||||
if (rails_segment_modified > 0)
|
||||
|
|
@ -582,18 +549,15 @@ static void rails_draw_wrapper(void *ptr, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void rails_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int start_x, end_x, start_y, end_y, segment_start, segment_end, w, h;
|
||||
|
||||
// avoiding to write out of the canvas
|
||||
if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w)
|
||||
&& (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0)
|
||||
&& ((signed) ox > 0) && ((signed) oy > 0))
|
||||
&& (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0))
|
||||
{
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, img_w / 2,
|
||||
rails_draw_wrapper);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, img_w / 2, rails_draw_wrapper);
|
||||
|
||||
start_x = min(ox, x);
|
||||
end_x = max(ox, x);
|
||||
|
|
@ -604,9 +568,9 @@ void rails_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
segment_end = rails_get_segment(end_x + img_w, end_y + img_h);
|
||||
|
||||
x = ((segment_start % rails_segments_x) - 1) * img_w;
|
||||
y = (int) (segment_start / rails_segments_x) * img_h;
|
||||
y = (int)(segment_start / rails_segments_x) * img_h;
|
||||
w = ((segment_end % rails_segments_x) - 1) * img_w - x + img_w;
|
||||
h = (int) (segment_end / rails_segments_x) * img_h - y + img_h;
|
||||
h = (int)(segment_end / rails_segments_x) * img_h - y + img_h;
|
||||
|
||||
update_rect->x = x;
|
||||
update_rect->y = y;
|
||||
|
|
@ -627,6 +591,8 @@ Uint8 rails_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void rails_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 rails_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@
|
|||
#define gettext_noop(String) String
|
||||
#endif
|
||||
|
||||
void rain_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int,
|
||||
SDL_Rect *);
|
||||
void rain_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
|
||||
|
||||
static int rain_SIZE = 30;
|
||||
static int rain_AMOUNT = 200;
|
||||
|
|
@ -84,13 +83,10 @@ SDL_Surface *rain_get_icon(magic_api * api, int which);
|
|||
char *rain_get_name(magic_api * api, int which);
|
||||
int rain_get_group(magic_api * api, int which);
|
||||
char *rain_get_description(magic_api * api, int which, int mode);
|
||||
static void do_rain_drop(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void rain_linecb(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_rain_drop(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void rain_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 rain_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void rain_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -99,14 +95,13 @@ void rain_shutdown(magic_api * api);
|
|||
void rain_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int rain_requires_colors(magic_api * api, int which);
|
||||
void rain_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rain_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rain_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rain_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int rain_modes(magic_api * api, int which);
|
||||
Uint8 rain_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rain_default_size(magic_api * api, int which, int mode);
|
||||
void rain_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void rain_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 rain_api_version(void)
|
||||
|
|
@ -117,7 +112,7 @@ Uint32 rain_api_version(void)
|
|||
//Checks if a a pixel is inside a raindrop shape centered on the origin
|
||||
static int rain_inRainShape(double x, double y, double r)
|
||||
{
|
||||
if (sqrt(x * x + y * y) < (r * pow(cos(atan2(x, y)), (float) (rain_SIZE / 3.0))))
|
||||
if (sqrt(x * x + y * y) < (r * pow(cos(atan2(x, y)), (float)(rain_SIZE / 3.0))))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -133,8 +128,7 @@ int rain_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
//Load sounds
|
||||
for (i = 0; i < rain_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
rain_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, rain_snd_filenames[i]);
|
||||
rain_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -151,8 +145,7 @@ SDL_Surface *rain_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
rain_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, rain_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -169,16 +162,14 @@ int rain_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *rain_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *rain_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(rain_descs[which][mode - 1])));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_rain_drop(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;
|
||||
|
||||
|
|
@ -195,17 +186,14 @@ static void do_rain_drop(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
//api->hsvtorgb(h, s, rain_weights[(yy-y)*((rain_SIZE*2) -1)+(xx-x)], &r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(canvas, xx, yy), canvas->format, &r, &g, &b);
|
||||
api->putpixel(canvas, xx, yy,
|
||||
SDL_MapRGB(canvas->format, clamp(0, r - 50, 255),
|
||||
clamp(0, g - 50, 255), clamp(0, b + 200,
|
||||
255)));
|
||||
SDL_MapRGB(canvas->format, clamp(0, r - 50, 255), clamp(0, g - 50, 255), clamp(0, b + 200, 255)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void rain_linecb(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void rain_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
SDL_Rect rect;
|
||||
|
|
@ -213,17 +201,15 @@ static void rain_linecb(void *ptr, int which, SDL_Surface * canvas,
|
|||
if (rand() % 10 == 0)
|
||||
{
|
||||
rain_click(api, which, MODE_PAINT, canvas, last,
|
||||
x + (rand() % rain_SIZE * 2) - rain_SIZE,
|
||||
y + (rand() % rain_SIZE * 2) - rain_SIZE, &rect);
|
||||
x + (rand() % rain_SIZE * 2) - rain_SIZE, y + (rand() % rain_SIZE * 2) - rain_SIZE, &rect);
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void rain_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, rain_linecb);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, rain_linecb);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -248,8 +234,7 @@ void rain_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void rain_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_PAINT)
|
||||
|
|
@ -270,8 +255,7 @@ void rain_click(magic_api * api, int which, int mode,
|
|||
|
||||
for (i = 0; i < rain_AMOUNT; i++)
|
||||
{
|
||||
do_rain_drop(api, which, canvas, last, rand() % canvas->w,
|
||||
rand() % canvas->h);
|
||||
do_rain_drop(api, which, canvas, last, rand() % canvas->w, rand() % canvas->h);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
|
|
@ -288,8 +272,7 @@ void rain_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 y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -310,27 +293,25 @@ void rain_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void rain_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int rain_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rain_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void rain_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void rain_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +332,9 @@ Uint8 rain_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 2;
|
||||
}
|
||||
|
||||
void rain_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rain_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
rain_SIZE = size * 15;
|
||||
rain_AMOUNT = 400 / size;
|
||||
|
|
|
|||
|
|
@ -77,34 +77,29 @@ SDL_Surface *rainbow_get_icon(magic_api * api, int which);
|
|||
char *rainbow_get_name(magic_api * api, int which);
|
||||
int rainbow_get_group(magic_api * api, int which);
|
||||
char *rainbow_get_description(magic_api * api, int which, int mode);
|
||||
static void rainbow_linecb(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void rainbow_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
|
||||
void rainbow_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 rainbow_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 rainbow_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 rainbow_shutdown(magic_api * api);
|
||||
void rainbow_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int rainbow_requires_colors(magic_api * api, int which);
|
||||
void rainbow_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rainbow_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rainbow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rainbow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int rainbow_modes(magic_api * api, int which);
|
||||
Uint8 rainbow_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rainbow_default_size(magic_api * api, int which, int mode);
|
||||
void rainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void rainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 rainbow_api_version(void)
|
||||
|
|
@ -121,8 +116,7 @@ int rainbow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
rainbow_color = 0;
|
||||
rainbow_mix = 0;
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/rainbow.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/rainbow.wav", api->data_directory);
|
||||
rainbow_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -139,15 +133,13 @@ SDL_Surface *rainbow_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rainbow.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == 0)
|
||||
{
|
||||
|
|
@ -160,16 +152,13 @@ char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
// Return our group:
|
||||
int rainbow_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("You can draw in rainbow colors!")));
|
||||
}
|
||||
|
|
@ -177,8 +166,7 @@ char *rainbow_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
|||
// Do the effect:
|
||||
|
||||
static void rainbow_linecb(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 xx, yy;
|
||||
|
|
@ -197,8 +185,7 @@ static void rainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void rainbow_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)
|
||||
{
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
int rc_tmp;
|
||||
|
|
@ -232,11 +219,9 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
(r2 * rainbow_mix)) / MIX_MAX,
|
||||
((g1 * (MIX_MAX - rainbow_mix)) +
|
||||
(g2 * rainbow_mix)) / MIX_MAX,
|
||||
((b1 * (MIX_MAX - rainbow_mix)) +
|
||||
(b2 * rainbow_mix)) / MIX_MAX);
|
||||
((b1 * (MIX_MAX - rainbow_mix)) + (b2 * rainbow_mix)) / MIX_MAX);
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1,
|
||||
rainbow_linecb);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, rainbow_linecb);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -263,8 +248,7 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void rainbow_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)
|
||||
{
|
||||
rainbow_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -273,8 +257,7 @@ void rainbow_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -286,32 +269,30 @@ void rainbow_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void rainbow_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rainbow_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int rainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rainbow_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void rainbow_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int rainbow_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rainbow_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -327,7 +308,9 @@ Uint8 rainbow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 4;
|
||||
}
|
||||
|
||||
void rainbow_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rainbow_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
rainbow_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,12 @@ Mix_Chunk *realrainbow_snd;
|
|||
int realrainbow_x1, realrainbow_y1, realrainbow_x2, realrainbow_y2;
|
||||
SDL_Rect realrainbow_rect;
|
||||
SDL_Surface *realrainbow_colors[2];
|
||||
Uint8 realrainbow_blendr, realrainbow_blendg, realrainbow_blendb,
|
||||
realrainbow_blenda;
|
||||
Uint8 realrainbow_blendr, realrainbow_blendg, realrainbow_blendb, realrainbow_blenda;
|
||||
|
||||
|
||||
void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x1, int y1, int x2, int y2,
|
||||
int fulldraw, SDL_Rect * update_rect);
|
||||
static void realrainbow_linecb(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
SDL_Surface * last, int x1, int y1, int x2, int y2, int fulldraw, SDL_Rect * update_rect);
|
||||
static void realrainbow_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
Uint32 realrainbow_api_version(void);
|
||||
int realrainbow_init(magic_api * api, Uint32 disabled_features);
|
||||
int realrainbow_get_tool_count(magic_api * api);
|
||||
|
|
@ -47,21 +44,17 @@ void realrainbow_shutdown(magic_api * api);
|
|||
void realrainbow_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void realrainbow_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 realrainbow_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 realrainbow_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void realrainbow_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void realrainbow_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void realrainbow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void realrainbow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
Uint8 realrainbow_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 realrainbow_default_size(magic_api * api, int which, int mode);
|
||||
void realrainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void realrainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 realrainbow_api_version(void)
|
||||
|
|
@ -73,21 +66,17 @@ int realrainbow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-colors.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-colors.png", api->data_directory);
|
||||
realrainbow_colors[0] = IMG_Load(fname);
|
||||
if (realrainbow_colors[0] == NULL)
|
||||
return (0);
|
||||
|
||||
snprintf(fname, sizeof(fname),
|
||||
"%simages/magic/realrainbow-roygbiv-colors.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv-colors.png", api->data_directory);
|
||||
realrainbow_colors[1] = IMG_Load(fname);
|
||||
if (realrainbow_colors[1] == NULL)
|
||||
return (0);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/realrainbow.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/realrainbow.ogg", api->data_directory);
|
||||
realrainbow_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -103,11 +92,9 @@ SDL_Surface *realrainbow_get_icon(magic_api * api, int which)
|
|||
char fname[1024];
|
||||
|
||||
if (which == 0)
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow.png", api->data_directory);
|
||||
else
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/realrainbow-roygbiv.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -120,29 +107,25 @@ char *realrainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return (strdup(gettext_noop("ROYGBIV Rainbow")));
|
||||
}
|
||||
|
||||
int realrainbow_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int realrainbow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
char *realrainbow_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click where you want your rainbow to start, drag to where you want it to end, and then let go to draw a rainbow.")));
|
||||
}
|
||||
|
||||
int realrainbow_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int realrainbow_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT_WITH_PREVIEW);
|
||||
}
|
||||
|
||||
int realrainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int realrainbow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -157,16 +140,17 @@ void realrainbow_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
Mix_FreeChunk(realrainbow_snd);
|
||||
}
|
||||
|
||||
void realrainbow_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void realrainbow_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void realrainbow_click(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
realrainbow_x1 = x;
|
||||
realrainbow_y1 = y;
|
||||
|
|
@ -179,8 +163,7 @@ void realrainbow_click(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
void realrainbow_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int rx1, ry1, rx2, ry2;
|
||||
SDL_Rect rect;
|
||||
|
|
@ -217,8 +200,7 @@ void realrainbow_drag(magic_api * api, int which,
|
|||
}
|
||||
|
||||
void realrainbow_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)
|
||||
{
|
||||
int rx1, ry1, rx2, ry2;
|
||||
SDL_Rect rect;
|
||||
|
|
@ -257,23 +239,18 @@ void realrainbow_release(magic_api * api, int which,
|
|||
}
|
||||
|
||||
void realrainbow_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void realrainbow_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x1, int y1, int x2, int y2,
|
||||
int fulldraw, SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int x1, int y1, int x2, int y2, int fulldraw, SDL_Rect * update_rect)
|
||||
{
|
||||
int lowx, lowy, hix, hiy, xm, ym, xc, yc, r, a1, atan2_a, atan2_b;
|
||||
int a, oa, ox, oy, nx, ny, step, thick, rr, done;
|
||||
|
|
@ -320,7 +297,7 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas,
|
|||
if (hix == lowx)
|
||||
return;
|
||||
|
||||
slope = (float) (hiy - lowy) / (float) (hix - lowx);
|
||||
slope = (float)(hiy - lowy) / (float)(hix - lowx);
|
||||
|
||||
yc = lowy;
|
||||
xc = slope * (ym - yc) + xm;
|
||||
|
|
@ -364,20 +341,16 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas,
|
|||
nx = (rr * cos(a * M_PI / 180.0)) + xc;
|
||||
ny = (rr * sin(a * M_PI / 180.0)) + yc;
|
||||
|
||||
colorindex =
|
||||
realrainbow_colors[which]->h - 1 -
|
||||
(((rr - r + (thick / 2)) * realrainbow_colors[which]->h) / thick);
|
||||
colorindex = realrainbow_colors[which]->h - 1 - (((rr - r + (thick / 2)) * realrainbow_colors[which]->h) / thick);
|
||||
|
||||
SDL_GetRGBA(api->getpixel(realrainbow_colors[which], 0, colorindex),
|
||||
realrainbow_colors[which]->format, &realrainbow_blendr,
|
||||
&realrainbow_blendg, &realrainbow_blendb,
|
||||
&realrainbow_blenda);
|
||||
&realrainbow_blendg, &realrainbow_blendb, &realrainbow_blenda);
|
||||
|
||||
if (!fulldraw)
|
||||
realrainbow_blenda = 255;
|
||||
|
||||
api->line((void *) api, 0, canvas, last, ox, oy, nx, ny, 1,
|
||||
realrainbow_linecb);
|
||||
api->line((void *)api, 0, canvas, last, ox, oy, nx, ny, 1, realrainbow_linecb);
|
||||
}
|
||||
|
||||
oa = a;
|
||||
|
|
@ -396,8 +369,7 @@ void realrainbow_arc(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
static void realrainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
Uint8 origr, origg, origb;
|
||||
|
|
@ -405,21 +377,16 @@ static void realrainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
SDL_GetRGB(api->getpixel(last, x, y), last->format, &origr, &origg, &origb);
|
||||
|
||||
newr =
|
||||
((realrainbow_blendr * realrainbow_blenda) / 255) +
|
||||
((origr * (255 - realrainbow_blenda)) / 255);
|
||||
newg =
|
||||
((realrainbow_blendg * realrainbow_blenda) / 255) +
|
||||
((origg * (255 - realrainbow_blenda)) / 255);
|
||||
newb =
|
||||
((realrainbow_blendb * realrainbow_blenda) / 255) +
|
||||
((origb * (255 - realrainbow_blenda)) / 255);
|
||||
newr = ((realrainbow_blendr * realrainbow_blenda) / 255) + ((origr * (255 - realrainbow_blenda)) / 255);
|
||||
newg = ((realrainbow_blendg * realrainbow_blenda) / 255) + ((origg * (255 - realrainbow_blenda)) / 255);
|
||||
newb = ((realrainbow_blendb * realrainbow_blenda) / 255) + ((origb * (255 - realrainbow_blenda)) / 255);
|
||||
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, newr, newg, newb));
|
||||
}
|
||||
|
||||
|
||||
Uint8 realrainbow_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 realrainbow_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -429,6 +396,8 @@ Uint8 realrainbow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
return 0;
|
||||
}
|
||||
|
||||
void realrainbow_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 realrainbow_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,28 +59,24 @@ char *reflection_get_name(magic_api * api, int which);
|
|||
int reflection_get_group(magic_api * api, int which);
|
||||
char *reflection_get_description(magic_api * api, int which, int mode);
|
||||
void reflection_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 do_reflection(magic_api * api, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect, int show_origin);
|
||||
void reflection_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 reflection_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void reflection_shutdown(magic_api * api);
|
||||
void reflection_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int reflection_requires_colors(magic_api * api, int which);
|
||||
void reflection_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void reflection_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void reflection_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void reflection_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int reflection_modes(magic_api * api, int which);
|
||||
Uint8 reflection_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 reflection_default_size(magic_api * api, int which, int mode);
|
||||
void reflection_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void reflection_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -88,8 +84,7 @@ int reflection_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg", api->data_directory);
|
||||
reflection_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -114,38 +109,31 @@ SDL_Surface *reflection_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Reflection")));
|
||||
}
|
||||
|
||||
int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *reflection_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to add a reflection to your picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to add a reflection to your picture.")));
|
||||
}
|
||||
|
||||
void reflection_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
do_reflection(api, canvas, last, x, y, update_rect, 1);
|
||||
}
|
||||
|
||||
void do_reflection(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect,
|
||||
int show_origin)
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect, int show_origin)
|
||||
{
|
||||
float scale;
|
||||
int xx, yy;
|
||||
|
|
@ -200,7 +188,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
/* Starting from `reflection_y1` and moving down,
|
||||
we'll copy from `reflection_y1` and moving up */
|
||||
|
||||
scale = (float) reflection_y1 / (float) y;
|
||||
scale = (float)reflection_y1 / (float)y;
|
||||
|
||||
for (yy = reflection_y1; yy < canvas->h; yy++)
|
||||
{
|
||||
|
|
@ -232,7 +220,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
/* Starting from `reflection_y1` and moving up,
|
||||
we'll copy from `reflection_y1` and moving down */
|
||||
|
||||
scale = ((float) reflection_y1 / (float) y);
|
||||
scale = ((float)reflection_y1 / (float)y);
|
||||
|
||||
for (yy = reflection_y1; yy >= 0; yy--)
|
||||
{
|
||||
|
|
@ -264,7 +252,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
/* Starting from `reflection_x1` and moving right,
|
||||
we'll copy from `reflection_x1` and moving left */
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
scale = (float)reflection_x1 / (float)x;
|
||||
|
||||
for (xx = reflection_x1; xx < canvas->w; xx++)
|
||||
{
|
||||
|
|
@ -296,7 +284,7 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
/* Starting from `reflection_x1` and left up,
|
||||
we'll copy from `reflection_x1` and right down */
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
scale = (float)reflection_x1 / (float)x;
|
||||
|
||||
for (xx = reflection_x1; xx >= 0; xx--)
|
||||
{
|
||||
|
|
@ -336,24 +324,20 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
}
|
||||
else
|
||||
{
|
||||
for (yy = reflection_y1 - REFLECTION_XOR_SIZE;
|
||||
yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++)
|
||||
for (yy = reflection_y1 - REFLECTION_XOR_SIZE; yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++)
|
||||
{
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, reflection_x1, yy);
|
||||
else
|
||||
api->putpixel(canvas, reflection_x1, yy,
|
||||
api->getpixel(last, reflection_x1, yy));
|
||||
api->putpixel(canvas, reflection_x1, yy, api->getpixel(last, reflection_x1, yy));
|
||||
}
|
||||
|
||||
for (xx = reflection_x1 - REFLECTION_XOR_SIZE;
|
||||
xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++)
|
||||
for (xx = reflection_x1 - REFLECTION_XOR_SIZE; xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++)
|
||||
{
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, xx, reflection_y1);
|
||||
else
|
||||
api->putpixel(canvas, xx, reflection_y1,
|
||||
api->getpixel(last, xx, reflection_y1));
|
||||
api->putpixel(canvas, xx, reflection_y1, api->getpixel(last, xx, reflection_y1));
|
||||
}
|
||||
|
||||
update_rect->x -= REFLECTION_XOR_SIZE;
|
||||
|
|
@ -362,13 +346,11 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
update_rect->h += (REFLECTION_XOR_SIZE * 2);
|
||||
}
|
||||
|
||||
api->playsound(reflection_snd, (x * 255) / canvas->w,
|
||||
(y * 255) / canvas->h);
|
||||
api->playsound(reflection_snd, (x * 255) / canvas->w, (y * 255) / canvas->h);
|
||||
}
|
||||
|
||||
void reflection_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)
|
||||
{
|
||||
if (x <= 0)
|
||||
x = 1;
|
||||
|
|
@ -388,8 +370,7 @@ void reflection_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void reflection_release(magic_api * api, int which 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)
|
||||
{
|
||||
do_reflection(api, canvas, last, x, y, update_rect, 0);
|
||||
}
|
||||
|
|
@ -400,34 +381,31 @@ void reflection_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
Mix_FreeChunk(reflection_snd);
|
||||
}
|
||||
|
||||
void reflection_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void reflection_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void reflection_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
reflection_x1 = canvas->w / 2;
|
||||
reflection_y1 = canvas->h / 2;
|
||||
}
|
||||
|
||||
void reflection_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int reflection_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int reflection_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
@ -443,6 +421,8 @@ Uint8 reflection_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB
|
|||
return 0;
|
||||
}
|
||||
|
||||
void reflection_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 reflection_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,27 +49,23 @@ char *ripples_get_name(magic_api * api, int which);
|
|||
int ripples_get_group(magic_api * api, int which);
|
||||
char *ripples_get_description(magic_api * api, int which, int mode);
|
||||
void ripples_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
static void ripples_linecb(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
static void ripples_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void ripples_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void ripples_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void ripples_shutdown(magic_api * api);
|
||||
void ripples_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int ripples_requires_colors(magic_api * api, int which);
|
||||
void ripples_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void ripples_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void ripples_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void ripples_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int ripples_modes(magic_api * api, int which);
|
||||
Uint8 ripples_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 ripples_default_size(magic_api * api, int which, int mode);
|
||||
void ripples_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void ripples_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 ripples_api_version(void)
|
||||
|
|
@ -85,8 +81,7 @@ int ripples_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/ripples.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/ripples.ogg", api->data_directory);
|
||||
ripples_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -103,33 +98,27 @@ SDL_Surface *ripples_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/ripples.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/ripples.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *ripples_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *ripples_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Ripples")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int ripples_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int ripples_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *ripples_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *ripples_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop("Click to make ripples appear over your picture.")));
|
||||
return (strdup(gettext_noop("Click to make ripples appear over your picture.")));
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
|
|
@ -138,14 +127,12 @@ void ripples_drag(magic_api * api ATTRIBUTE_UNUSED,
|
|||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int ox ATTRIBUTE_UNUSED, int oy 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)
|
||||
{
|
||||
}
|
||||
|
||||
static void ripples_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x,
|
||||
int y)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
Uint8 r, g, b;
|
||||
|
|
@ -163,8 +150,7 @@ static void ripples_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void ripples_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)
|
||||
{
|
||||
float fli;
|
||||
int ox, oy, nx, ny, d;
|
||||
|
|
@ -183,18 +169,17 @@ void ripples_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
ripples_brite = (ripples_z * 20 * deg_sin(d + 45)) / ((fli / 4) + 1);
|
||||
|
||||
api->line((void *) api, which, canvas, last, ox, oy, nx, ny, 1,
|
||||
ripples_linecb);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, nx, ny, 1, ripples_linecb);
|
||||
|
||||
ox = nx;
|
||||
oy = ny;
|
||||
}
|
||||
}
|
||||
|
||||
update_rect->x = x - (int) ripples_radius;
|
||||
update_rect->y = y - (int) ripples_radius;
|
||||
update_rect->w = ((int) ripples_radius) * 2;
|
||||
update_rect->h = ((int) ripples_radius) * 2;
|
||||
update_rect->x = x - (int)ripples_radius;
|
||||
update_rect->y = y - (int)ripples_radius;
|
||||
update_rect->w = ((int)ripples_radius) * 2;
|
||||
update_rect->h = ((int)ripples_radius) * 2;
|
||||
|
||||
api->playsound(ripples_snd, (x * 255) / api->canvas_w, 255);
|
||||
}
|
||||
|
|
@ -204,8 +189,7 @@ void ripples_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -217,38 +201,37 @@ void ripples_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void ripples_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void ripples_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int ripples_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int ripples_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ripples_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void ripples_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int ripples_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int ripples_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_ONECLICK);
|
||||
}
|
||||
|
||||
|
||||
Uint8 ripples_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED) {
|
||||
Uint8 ripples_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +240,9 @@ Uint8 ripples_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 5;
|
||||
}
|
||||
|
||||
void ripples_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void ripples_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
ripples_radius = ((float) size) * 20.0;
|
||||
ripples_radius = ((float)size) * 20.0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "SDL_mixer.h"
|
||||
#include <math.h> //for sin, cos, ...
|
||||
|
||||
static int ROSETTE_R = 8; //circle's diameter
|
||||
static int ROSETTE_R = 8; //circle's diameter
|
||||
|
||||
static int xmid, ymid;
|
||||
|
||||
|
|
@ -62,28 +62,22 @@ int rosette_get_group(magic_api * api, int which);
|
|||
char *rosette_get_description(magic_api * api, int which, int mode);
|
||||
int rosette_requires_colors(magic_api * api, int which);
|
||||
void rosette_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void rosette_shutdown(magic_api * api);
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void rosette_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void rosette_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void rosette_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void rosette_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void rosette_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void rosette_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int rosette_modes(magic_api * api, int which);
|
||||
void rosette_circle(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void rosette_circle(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
Uint8 rosette_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rosette_default_size(magic_api * api, int which, int mode);
|
||||
void rosette_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void rosette_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 rosette_api_version(void)
|
||||
|
|
@ -91,8 +85,9 @@ Uint32 rosette_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void rosette_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 rosette_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)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
rosette_colors.r = r;
|
||||
|
|
@ -104,8 +99,7 @@ int rosette_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/picasso.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/picasso.ogg", api->data_directory);
|
||||
rosette_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -121,11 +115,9 @@ SDL_Surface *rosette_get_icon(magic_api * api, int which)
|
|||
char fname[1024];
|
||||
|
||||
if (!which)
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rosette.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/rosette.png", api->data_directory);
|
||||
else
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/picasso.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/picasso.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -138,14 +130,12 @@ char *rosette_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return strdup(gettext_noop("Picasso"));
|
||||
}
|
||||
|
||||
int rosette_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rosette_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PATTERN_PAINTING;
|
||||
}
|
||||
|
||||
char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (!which)
|
||||
return strdup(gettext_noop("Click and start drawing your rosette.")); //just k'scope with 3 bits?
|
||||
|
|
@ -153,8 +143,7 @@ char *rosette_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
return strdup(gettext_noop("You can draw just like Picasso!")); //what is this actually doing?
|
||||
}
|
||||
|
||||
int rosette_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rosette_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -163,8 +152,7 @@ void rosette_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +164,7 @@ void rosette_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
// Interactivity functions
|
||||
|
||||
void rosette_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -186,14 +173,11 @@ void rosette_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
for (yy = y - ROSETTE_R; yy < y + ROSETTE_R; yy++)
|
||||
for (xx = x - ROSETTE_R; xx < x + ROSETTE_R; xx++)
|
||||
if (api->in_circle(xx - x, yy - y, ROSETTE_R / 2))
|
||||
api->putpixel(canvas, xx, yy,
|
||||
SDL_MapRGB(canvas->format, rosette_colors.r,
|
||||
rosette_colors.g, rosette_colors.b));
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, rosette_colors.r, rosette_colors.g, rosette_colors.b));
|
||||
|
||||
}
|
||||
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
void rosette_draw(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -201,18 +185,18 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
double xx, yy; //distance to the center of the image
|
||||
int x1, y1, x2, y2;
|
||||
|
||||
xx = (double) (xmid - x);
|
||||
yy = (double) (y - ymid);
|
||||
xx = (double)(xmid - x);
|
||||
yy = (double)(y - ymid);
|
||||
|
||||
if (which == 0)
|
||||
{
|
||||
angle = 2 * M_PI / 3; //an angle between brushes
|
||||
|
||||
x1 = (int) (xx * cos(angle) - yy * sin(angle));
|
||||
y1 = (int) (xx * sin(angle) + yy * cos(angle));
|
||||
x1 = (int)(xx * cos(angle) - yy * sin(angle));
|
||||
y1 = (int)(xx * sin(angle) + yy * cos(angle));
|
||||
|
||||
x2 = (int) (xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int) (xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
x2 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int)(xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -230,11 +214,11 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
if ((y == ymid) && (xx < 0))
|
||||
angle = M_PI;
|
||||
|
||||
x1 = (int) (xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y1 = (int) (xx * sin(2 * angle) - yy * cos(angle));
|
||||
x1 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y1 = (int)(xx * sin(2 * angle) - yy * cos(angle));
|
||||
|
||||
x2 = (int) (xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int) (xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
x2 = (int)(xx * cos(2 * angle) - yy * sin(2 * angle));
|
||||
y2 = (int)(xx * sin(2 * angle) + yy * cos(2 * angle));
|
||||
}
|
||||
|
||||
rosette_circle(api, which, canvas, snapshot, x, y);
|
||||
|
|
@ -243,11 +227,9 @@ void rosette_draw(void *ptr, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void rosette_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1,
|
||||
rosette_draw);
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1, rosette_draw);
|
||||
api->playsound(rosette_snd, (x * 255) / canvas->w, 255);
|
||||
|
||||
update_rect->x = update_rect->y = 0;
|
||||
|
|
@ -256,29 +238,25 @@ void rosette_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void rosette_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)
|
||||
{
|
||||
rosette_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
||||
void rosette_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
xmid = canvas->w / 2;
|
||||
ymid = canvas->h / 2;
|
||||
}
|
||||
|
||||
void rosette_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int rosette_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int rosette_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -294,7 +272,9 @@ Uint8 rosette_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 1;
|
||||
}
|
||||
|
||||
void rosette_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void rosette_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
ROSETTE_R = (size + 2) * 2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,12 @@ const char *sharpen_names[sharpen_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *sharpen_descs[sharpen_NUM_TOOLS][2] = {
|
||||
{gettext_noop
|
||||
("Click and drag the mouse to trace edges in parts of your picture."),
|
||||
{gettext_noop("Click and drag the mouse to trace edges in parts of your picture."),
|
||||
gettext_noop("Click to trace edges in your entire picture."),},
|
||||
{gettext_noop("Click and drag the mouse to sharpen parts of your picture."),
|
||||
gettext_noop("Click to sharpen the entire picture."),},
|
||||
{gettext_noop
|
||||
("Click and drag the mouse to create a black and white silhouette."),
|
||||
gettext_noop
|
||||
("Click to create a black and white silhouette of your entire picture.")},
|
||||
{gettext_noop("Click and drag the mouse to create a black and white silhouette."),
|
||||
gettext_noop("Click to create a black and white silhouette of your entire picture.")},
|
||||
};
|
||||
|
||||
Uint32 sharpen_api_version(void);
|
||||
|
|
@ -97,34 +94,28 @@ char *sharpen_get_name(magic_api * api, int which);
|
|||
int sharpen_get_group(magic_api * api, int which);
|
||||
char *sharpen_get_description(magic_api * api, int which, int mode);
|
||||
static int sharpen_grey(Uint8 r1, Uint8 g1, Uint8 b1);
|
||||
static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_sharpen_full(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int which);
|
||||
static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_sharpen_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which);
|
||||
static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void sharpen_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 sharpen_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void sharpen_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 sharpen_shutdown(magic_api * api);
|
||||
void sharpen_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int sharpen_requires_colors(magic_api * api, int which);
|
||||
void sharpen_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void sharpen_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void sharpen_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void sharpen_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int sharpen_modes(magic_api * api, int which);
|
||||
Uint8 sharpen_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 sharpen_default_size(magic_api * api, int which, int mode);
|
||||
void sharpen_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void sharpen_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -143,8 +134,7 @@ int sharpen_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < sharpen_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
sharpen_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, sharpen_snd_filenames[i]);
|
||||
sharpen_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +152,7 @@ SDL_Surface *sharpen_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
sharpen_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, sharpen_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -174,15 +163,13 @@ char *sharpen_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (all the same):
|
||||
int sharpen_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int sharpen_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *sharpen_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *sharpen_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(sharpen_descs[which][mode - 1])));
|
||||
}
|
||||
|
|
@ -194,8 +181,7 @@ static int sharpen_grey(Uint8 r1, Uint8 g1, Uint8 b1)
|
|||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -222,8 +208,7 @@ static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas,
|
|||
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 = sharpen_grey(r1, g1, b1);
|
||||
sobel_1 += grey * sobel_weights_1[i + 1][j + 1];
|
||||
sobel_2 += grey * sobel_weights_2[i + 1][j + 1];
|
||||
|
|
@ -253,14 +238,12 @@ static void do_sharpen_pixel(void *ptr, int which, SDL_Surface * canvas,
|
|||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format,
|
||||
clamp(0.0, r1 + SHARPEN * temp, 255.0),
|
||||
clamp(0.0, g1 + SHARPEN * temp, 255.0),
|
||||
clamp(0.0, b1 + SHARPEN * temp, 255.0)));
|
||||
clamp(0.0, g1 + SHARPEN * temp, 255.0), clamp(0.0, b1 + SHARPEN * temp, 255.0)));
|
||||
}
|
||||
}
|
||||
|
||||
// Do the effect for the full image
|
||||
static void do_sharpen_full(void *ptr, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int which)
|
||||
static void do_sharpen_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -281,8 +264,7 @@ static void do_sharpen_full(void *ptr, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
//do the effect for the brush
|
||||
static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -291,8 +273,7 @@ static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
for (xx = x - sharpen_RADIUS; xx < x + sharpen_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, sharpen_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, sharpen_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_sharpen_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
|
|
@ -302,12 +283,10 @@ static void do_sharpen_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void sharpen_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_sharpen_brush);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_sharpen_brush);
|
||||
|
||||
api->playsound(sharpen_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -334,8 +313,7 @@ void sharpen_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void sharpen_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_PAINT)
|
||||
sharpen_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -355,8 +333,7 @@ void sharpen_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -376,32 +353,30 @@ void sharpen_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void sharpen_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void sharpen_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int sharpen_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int sharpen_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sharpen_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void sharpen_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int sharpen_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int sharpen_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_FULLSCREEN | MODE_PAINT);
|
||||
}
|
||||
|
|
@ -421,7 +396,9 @@ Uint8 sharpen_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 4;
|
||||
}
|
||||
|
||||
void sharpen_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void sharpen_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
sharpen_RADIUS = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ static Mix_Chunk *shift_snd;
|
|||
/* Local function prototypes: */
|
||||
|
||||
static void shift_doit(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect, int crosshairs);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect, int crosshairs);
|
||||
Uint32 shift_api_version(void);
|
||||
int shift_init(magic_api * api, Uint32 disabled_features);
|
||||
int shift_get_tool_count(magic_api * api);
|
||||
|
|
@ -53,8 +52,7 @@ char *shift_get_name(magic_api * api, int which);
|
|||
int shift_get_group(magic_api * api, int which);
|
||||
char *shift_get_description(magic_api * api, int which, int mode);
|
||||
void shift_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 shift_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void shift_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -64,15 +62,14 @@ void shift_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
|||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int shift_requires_colors(magic_api * api, int which);
|
||||
|
||||
void shift_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void shift_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void shift_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void shift_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int shift_modes(magic_api * api, int which);
|
||||
|
||||
Uint8 shift_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 shift_default_size(magic_api * api, int which, int mode);
|
||||
void shift_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void shift_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -87,8 +84,7 @@ int shift_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/shift.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/shift.ogg", api->data_directory);
|
||||
shift_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -101,46 +97,37 @@ int shift_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Load our icons:
|
||||
SDL_Surface *shift_get_icon(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
SDL_Surface *shift_get_icon(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/shift.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/shift.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *shift_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *shift_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Shift")));
|
||||
}
|
||||
|
||||
// Return our group
|
||||
int shift_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int shift_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *shift_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *shift_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to shift your picture around on the canvas.")));
|
||||
return (strdup(gettext_noop("Click and drag to shift your picture around on the canvas.")));
|
||||
}
|
||||
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void shift_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)
|
||||
{
|
||||
if (ox == x && oy == y)
|
||||
return; /* No-op */
|
||||
|
|
@ -151,8 +138,7 @@ void shift_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
static void shift_doit(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect, int crosshairs)
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect, int crosshairs)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
int dx, dy;
|
||||
|
|
@ -313,8 +299,7 @@ static void shift_doit(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void shift_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)
|
||||
{
|
||||
shift_x = x;
|
||||
shift_y = y;
|
||||
|
|
@ -324,8 +309,7 @@ void shift_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on release:
|
||||
void shift_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)
|
||||
{
|
||||
shift_doit(api, which, canvas, last, x, y, x, y, update_rect, 0);
|
||||
api->stopsound();
|
||||
|
|
@ -340,27 +324,26 @@ void shift_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void shift_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void shift_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int shift_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int shift_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void shift_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void shift_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -380,6 +363,8 @@ Uint8 shift_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void shift_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 shift_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,9 @@ SDL_Surface *smudge_get_icon(magic_api * api, int which);
|
|||
char *smudge_get_name(magic_api * api, int which);
|
||||
int smudge_get_group(magic_api * api, int which);
|
||||
char *smudge_get_description(magic_api * api, int which, int mode);
|
||||
static void do_smudge(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_smudge(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void smudge_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 smudge_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void smudge_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -61,23 +59,21 @@ void smudge_shutdown(magic_api * api);
|
|||
void smudge_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int smudge_requires_colors(magic_api * api, int which);
|
||||
void smudge_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void smudge_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void smudge_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void smudge_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int smudge_modes(magic_api * api, int which);
|
||||
int smudge_get_tool_count(magic_api * api);
|
||||
Uint8 smudge_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 smudge_default_size(magic_api * api, int which, int mode);
|
||||
void smudge_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void smudge_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
int smudge_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/smudge.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/smudge.wav", api->data_directory);
|
||||
smudge_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -100,11 +96,9 @@ SDL_Surface *smudge_get_icon(magic_api * api, int which)
|
|||
char fname[1024];
|
||||
|
||||
if (which == 0)
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/smudge.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/smudge.png", api->data_directory);
|
||||
else /* if (which == 1) */
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/wetpaint.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/wetpaint.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -128,23 +122,17 @@ int smudge_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *smudge_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *smudge_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == 0)
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to smudge the picture.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to smudge the picture.")));
|
||||
else /* if (which == 1) */
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to draw with wet, smudgy paint.")));
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to draw with wet, smudgy paint.")));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
|
||||
static void do_smudge(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_smudge(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
static double state[256][256][3];
|
||||
|
|
@ -160,8 +148,7 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas,
|
|||
for (xx = -(smudge_radius / 2); xx < (smudge_radius / 2); xx++)
|
||||
if (api->in_circle(xx, yy, (smudge_radius / 2)))
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r,
|
||||
&g, &b);
|
||||
SDL_GetRGB(api->getpixel(last, x + xx, y + yy), last->format, &r, &g, &b);
|
||||
strength = (abs(xx * yy) / (smudge_radius / 2)) + 1;
|
||||
api->putpixel(canvas, x + xx, y + yy, SDL_MapRGB(canvas->format,
|
||||
(smudge_r +
|
||||
|
|
@ -169,10 +156,7 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas,
|
|||
(strength + 1),
|
||||
(smudge_g +
|
||||
g * strength) /
|
||||
(strength + 1),
|
||||
(smudge_b +
|
||||
b * strength) /
|
||||
(strength + 1)));
|
||||
(strength + 1), (smudge_b + b * strength) / (strength + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,37 +166,31 @@ static void do_smudge(void *ptr, int which, SDL_Surface * canvas,
|
|||
int ix = i % (smudge_radius * 2);
|
||||
int radius_check;
|
||||
|
||||
radius_check = (smudge_radius * 75) / 10; /* For 16 radius, we'll use 120 */
|
||||
radius_check = (smudge_radius * 75) / 10; /* For 16 radius, we'll use 120 */
|
||||
|
||||
// is it not on the circle of radius sqrt(radius_check) at location (smudge_radius,smudge_radius)?
|
||||
if ((ix - smudge_radius) * (ix - smudge_radius) + (iy - smudge_radius) * (iy - smudge_radius) > radius_check)
|
||||
continue;
|
||||
// it is on the circle, so grab it
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius), last->format,
|
||||
&r, &g, &b);
|
||||
state[ix][iy][0] =
|
||||
rate * state[ix][iy][0] + (1.0 - rate) * api->sRGB_to_linear(r);
|
||||
state[ix][iy][1] =
|
||||
rate * state[ix][iy][1] + (1.0 - rate) * api->sRGB_to_linear(g);
|
||||
state[ix][iy][2] =
|
||||
rate * state[ix][iy][2] + (1.0 - rate) * api->sRGB_to_linear(b);
|
||||
SDL_GetRGB(api->getpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius), last->format, &r, &g, &b);
|
||||
state[ix][iy][0] = rate * state[ix][iy][0] + (1.0 - rate) * api->sRGB_to_linear(r);
|
||||
state[ix][iy][1] = rate * state[ix][iy][1] + (1.0 - rate) * api->sRGB_to_linear(g);
|
||||
state[ix][iy][2] = rate * state[ix][iy][2] + (1.0 - rate) * api->sRGB_to_linear(b);
|
||||
|
||||
// opacity 100% --> new data not blended w/ existing data
|
||||
api->putpixel(canvas, x + ix - smudge_radius, y + iy - smudge_radius,
|
||||
SDL_MapRGB(canvas->format,
|
||||
api->linear_to_sRGB(state[ix][iy][0]),
|
||||
api->linear_to_sRGB(state[ix][iy][1]),
|
||||
api->linear_to_sRGB(state[ix][iy][2])));
|
||||
api->linear_to_sRGB(state[ix][iy][1]), api->linear_to_sRGB(state[ix][iy][2])));
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void smudge_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_smudge);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_smudge);
|
||||
|
||||
api->playsound(smudge_snd, (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -239,8 +217,7 @@ void smudge_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void smudge_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)
|
||||
{
|
||||
smudge_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -250,8 +227,7 @@ void smudge_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -263,8 +239,9 @@ void smudge_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void smudge_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 smudge_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)
|
||||
{
|
||||
smudge_r = r;
|
||||
smudge_g = g;
|
||||
|
|
@ -272,8 +249,7 @@ void smudge_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == 0)
|
||||
return 0;
|
||||
|
|
@ -282,14 +258,12 @@ int smudge_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void smudge_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void smudge_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +284,9 @@ Uint8 smudge_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 4;
|
||||
}
|
||||
|
||||
void smudge_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void smudge_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
smudge_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,29 +89,25 @@ SDL_Surface *snow_get_icon(magic_api * api, int which);
|
|||
char *snow_get_name(magic_api * api, int which);
|
||||
int snow_get_group(magic_api * api, int which);
|
||||
char *snow_get_description(magic_api * api, int which);
|
||||
static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which, int snowAmount);
|
||||
static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which, int snowAmount);
|
||||
void snow_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 snow_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void snow_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 snow_shutdown(magic_api * api);
|
||||
void snow_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int snow_requires_colors(magic_api * api, int which);
|
||||
void snow_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void snow_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void snow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void snow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int snow_modes(magic_api * api, int which);
|
||||
Uint8 snow_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 snow_default_size(magic_api * api, int which, int mode);
|
||||
void snow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void snow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 snow_api_version(void)
|
||||
|
|
@ -128,16 +124,14 @@ int snow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
srand(time(0));
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake4.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake4.png", api->data_directory);
|
||||
snow_flake1 = IMG_Load(fname);
|
||||
if (snow_flake1 == NULL)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake5.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/Snow_flake5.png", api->data_directory);
|
||||
snow_flake2 = IMG_Load(fname);
|
||||
if (snow_flake2 == NULL)
|
||||
{
|
||||
|
|
@ -146,8 +140,7 @@ int snow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
|
||||
for (i = 0; i < snow_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
snow_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, snow_snd_filenames[i]);
|
||||
snow_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -163,8 +156,7 @@ SDL_Surface *snow_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
snow_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, snow_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -174,8 +166,7 @@ char *snow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return (strdup(gettext_noop(snow_names[which])));
|
||||
}
|
||||
|
||||
int snow_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int snow_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_DECORATIONS; /* Because we affect the whole image, and not just around the mouse */
|
||||
}
|
||||
|
|
@ -187,8 +178,7 @@ char *snow_get_description(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which, int snowAmount)
|
||||
static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which, int snowAmount)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -208,10 +198,8 @@ static void do_snow(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
|||
{
|
||||
if (api->in_circle(x, y, snow_RADIUS))
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(last, centre_x + x, centre_y + y),
|
||||
last->format, &r, &g, &b);
|
||||
api->putpixel(canvas, centre_x + x, centre_y + y,
|
||||
SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
SDL_GetRGB(api->getpixel(last, centre_x + x, centre_y + y), last->format, &r, &g, &b);
|
||||
api->putpixel(canvas, centre_x + x, centre_y + y, SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -237,8 +225,7 @@ void snow_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
|||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x ATTRIBUTE_UNUSED,
|
||||
int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
|
@ -246,8 +233,7 @@ void snow_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
|||
// Affect the canvas on click:
|
||||
void snow_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||
{
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -263,8 +249,7 @@ void snow_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 y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -293,26 +278,24 @@ void snow_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void snow_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int snow_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int snow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void snow_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void snow_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -333,6 +316,8 @@ Uint8 snow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 0;
|
||||
}
|
||||
|
||||
void snow_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 snow_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,25 +60,21 @@ int stretch_get_group(magic_api * api, int which);
|
|||
char *stretch_get_description(magic_api * api, int which, int mode);
|
||||
int stretch_requires_colors(magic_api * api, int which);
|
||||
void stretch_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void stretch_shutdown(magic_api * api);
|
||||
void stretch_paint_stretch(void *ptr_to_api, int which_tool,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int x, int y);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void stretch_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void stretch_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void stretch_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void stretch_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void stretch_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void stretch_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int stretch_modes(magic_api * api, int which);
|
||||
Uint8 stretch_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 stretch_default_size(magic_api * api, int which, int mode);
|
||||
void stretch_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void stretch_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// Housekeeping functions
|
||||
Uint32 stretch_api_version(void)
|
||||
|
|
@ -86,8 +82,10 @@ Uint32 stretch_api_version(void)
|
|||
return (TP_MAGIC_API_VERSION);
|
||||
}
|
||||
|
||||
void stretch_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void stretch_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +93,7 @@ int stretch_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/stretch.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/stretch.ogg", api->data_directory);
|
||||
stretch_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -111,35 +108,27 @@ SDL_Surface *stretch_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/stretch.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/stretch.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *stretch_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *stretch_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return strdup(gettext_noop("Stretch"));
|
||||
}
|
||||
|
||||
int stretch_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int stretch_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *stretch_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *stretch_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click and drag to stretch part of your picture vertically or horizontally."));
|
||||
return strdup(gettext_noop("Click and drag to stretch part of your picture vertically or horizontally."));
|
||||
}
|
||||
|
||||
int stretch_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int stretch_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -148,8 +137,7 @@ void stretch_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +150,7 @@ void stretch_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
SDL_Rect src, dest;
|
||||
float xx, yy;
|
||||
|
|
@ -177,9 +164,8 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
if (y != stretch_start_y)
|
||||
{
|
||||
divisor1 = (float) y / (float) stretch_start_y;
|
||||
divisor2 =
|
||||
(float) (canvas->h - y) / (float) (canvas->h - stretch_start_y);
|
||||
divisor1 = (float)y / (float)stretch_start_y;
|
||||
divisor2 = (float)(canvas->h - y) / (float)(canvas->h - stretch_start_y);
|
||||
|
||||
for (yy = 0; yy < y; yy++)
|
||||
{
|
||||
|
|
@ -220,9 +206,8 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
if (x != stretch_start_x)
|
||||
{
|
||||
divisor1 = (float) x / (float) stretch_start_x;
|
||||
divisor2 =
|
||||
(float) (canvas->w - x) / (float) (canvas->w - stretch_start_x);
|
||||
divisor1 = (float)x / (float)stretch_start_x;
|
||||
divisor2 = (float)(canvas->w - x) / (float)(canvas->w - stretch_start_x);
|
||||
|
||||
for (xx = 0; xx < x; xx++)
|
||||
{
|
||||
|
|
@ -267,8 +252,7 @@ void stretch_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void stretch_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)
|
||||
{
|
||||
if (y < canvas->h / 2)
|
||||
{
|
||||
|
|
@ -296,21 +280,18 @@ void stretch_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void stretch_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void stretch_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int stretch_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int stretch_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -326,6 +307,8 @@ Uint8 stretch_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 0;
|
||||
}
|
||||
|
||||
void stretch_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 stretch_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
unsigned int img_w, img_h;
|
||||
static Uint8 string_r, string_g, string_b;
|
||||
static int string_ox, string_oy;
|
||||
static int string_vertex_x, string_vertex_y, string_vertex_done,
|
||||
string_vertex_distance;
|
||||
static int string_vertex_x, string_vertex_y, string_vertex_done, string_vertex_distance;
|
||||
static SDL_Surface *canvas_backup;
|
||||
enum string_tools
|
||||
{
|
||||
|
|
@ -25,24 +24,18 @@ Mix_Chunk *string_snd[STRING_NUMTOOLS];
|
|||
|
||||
// Custom function declarations
|
||||
|
||||
void string_callback(void *ptr, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void string_callback_xor(void *ptr, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void string_callback(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void string_callback_xor(void *ptr, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void string_draw_triangle(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void string_draw_angle(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void string_draw_triangle_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void string_draw_angle_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void scale_xcoord(int *xcoord);
|
||||
void scale_ycoord(int *ycoord);
|
||||
void scale_coords(int *ox, int *oy, int *x, int *y);
|
||||
|
|
@ -56,8 +49,7 @@ void compute_middle(int start_point, int end_point, int vertex, int *middle);
|
|||
// Prototypes for required functions
|
||||
|
||||
void string_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 string_api_version(void);
|
||||
|
|
@ -71,20 +63,18 @@ int string_get_group(magic_api * api, int which);
|
|||
char *string_get_description(magic_api * api, int which, int mode);
|
||||
int string_requires_colors(magic_api * api, int which);
|
||||
void string_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
int string_init(magic_api * api, Uint32 disabled_features);
|
||||
void string_shutdown(magic_api * api);
|
||||
void string_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void string_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void string_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void string_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot);
|
||||
void string_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
Uint8 string_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
Uint8 string_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED);
|
||||
void string_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 string_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);
|
||||
|
||||
// Required functions
|
||||
|
||||
|
|
@ -101,8 +91,9 @@ int string_modes(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
return (MODE_PAINT_WITH_PREVIEW);
|
||||
}
|
||||
|
||||
void string_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 string_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)
|
||||
{
|
||||
string_r = r;
|
||||
string_g = g;
|
||||
|
|
@ -123,17 +114,13 @@ SDL_Surface *string_get_icon(magic_api * api, int which)
|
|||
switch (which)
|
||||
{
|
||||
case STRING_TOOL_FULL_BY_OFFSET:
|
||||
snprintf(fname, sizeof(fname),
|
||||
"%simages/magic/string_art_full_by_offset.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/string_art_full_by_offset.png", api->data_directory);
|
||||
break;
|
||||
case STRING_TOOL_TRIANGLE:
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/string_art_triangles.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/string_art_triangles.png", api->data_directory);
|
||||
break;
|
||||
case STRING_TOOL_ANGLE:
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/string_art_angles.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/string_art_angles.png", api->data_directory);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -141,8 +128,7 @@ SDL_Surface *string_get_icon(magic_api * api, int which)
|
|||
}
|
||||
|
||||
|
||||
char *string_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *string_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
|
|
@ -157,14 +143,12 @@ char *string_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
}
|
||||
|
||||
int string_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int string_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
switch (which)
|
||||
{
|
||||
|
|
@ -174,30 +158,25 @@ char *string_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
("Click and drag to draw string art. Drag top-bottom to draw less or more lines, left or right to make a bigger hole."));
|
||||
break;
|
||||
case STRING_TOOL_TRIANGLE:
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click and drag to draw arrows made of string art."));
|
||||
return strdup(gettext_noop("Click and drag to draw arrows made of string art."));
|
||||
break;
|
||||
default:
|
||||
return strdup(gettext_noop("Draw string art arrows with free angles."));
|
||||
}
|
||||
}
|
||||
|
||||
int string_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int string_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void string_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int dx, dy;
|
||||
|
||||
if (which == STRING_TOOL_TRIANGLE)
|
||||
string_draw_triangle((void *) api, which, canvas, snapshot, string_ox,
|
||||
string_oy, x, y, update_rect);
|
||||
string_draw_triangle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect);
|
||||
if (which == STRING_TOOL_ANGLE)
|
||||
{
|
||||
if (!string_vertex_done) // maybe we face small children, draw square angles aligned to the drag
|
||||
|
|
@ -207,8 +186,7 @@ void string_release(magic_api * api, int which,
|
|||
y = y + dx;
|
||||
x = x - dy;
|
||||
}
|
||||
string_draw_angle((void *) api, which, canvas, snapshot, string_ox,
|
||||
string_oy, x, y, update_rect);
|
||||
string_draw_angle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,16 +194,13 @@ int string_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string.ogg", api->data_directory);
|
||||
string_snd[STRING_TOOL_FULL_BY_OFFSET] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string2.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string2.ogg", api->data_directory);
|
||||
string_snd[STRING_TOOL_TRIANGLE] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string3.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/string3.ogg", api->data_directory);
|
||||
string_snd[STRING_TOOL_ANGLE] = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -248,20 +223,17 @@ void string_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void string_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
{
|
||||
canvas_backup =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
}
|
||||
|
||||
void string_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED)
|
||||
{
|
||||
SDL_FreeSurface(canvas_backup);
|
||||
canvas_backup = NULL;
|
||||
|
|
@ -271,19 +243,15 @@ void string_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
|
||||
void string_callback(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGBA(canvas->format, string_r, string_g, string_b,
|
||||
255));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGBA(canvas->format, string_r, string_g, string_b, 255));
|
||||
}
|
||||
|
||||
void string_callback_xor(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
|
|
@ -292,8 +260,7 @@ void string_callback_xor(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
|
||||
void string_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
SDL_BlitSurface(canvas, NULL, canvas_backup, NULL);
|
||||
|
||||
|
|
@ -306,9 +273,7 @@ void string_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface *
|
||||
snapshot ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int u;
|
||||
|
|
@ -318,16 +283,16 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
// int n=y/5;
|
||||
int **a;
|
||||
float step_w, step_h, aux;
|
||||
int side = (int) (y / 3);
|
||||
int side = (int)(y / 3);
|
||||
|
||||
SDL_BlitSurface(snapshot, 0, canvas, 0);
|
||||
|
||||
if (side < 3)
|
||||
side = 3;
|
||||
|
||||
o = (int) (side * 4 * x / canvas->w);
|
||||
step_w = canvas->w / (float) side;
|
||||
step_h = canvas->h / (float) side;
|
||||
o = (int)(side * 4 * x / canvas->w);
|
||||
step_w = canvas->w / (float)side;
|
||||
step_h = canvas->h / (float)side;
|
||||
|
||||
a = malloc(sizeof(int *) * side * 4 * 2);
|
||||
|
||||
|
|
@ -337,22 +302,22 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
if (i < side)
|
||||
{
|
||||
a[i][0] = 0;
|
||||
aux = step_h * (float) i;
|
||||
a[i][1] = (int) aux;
|
||||
aux = step_h * (float)i;
|
||||
a[i][1] = (int)aux;
|
||||
}
|
||||
else if (i < (side * 2))
|
||||
{
|
||||
a[i][0] = (int) ((float) (i % side) * step_w);
|
||||
a[i][0] = (int)((float)(i % side) * step_w);
|
||||
a[i][1] = canvas->h;
|
||||
}
|
||||
else if (i < (int) (side * 3))
|
||||
else if (i < (int)(side * 3))
|
||||
{
|
||||
a[i][0] = canvas->w;
|
||||
a[i][1] = (int) (canvas->h - (float) ((i % side) * step_h));
|
||||
a[i][1] = (int)(canvas->h - (float)((i % side) * step_h));
|
||||
}
|
||||
else if (i < (int) (side * 4))
|
||||
else if (i < (int)(side * 4))
|
||||
{
|
||||
a[i][0] = (int) (canvas->w - ((float) ((i % side) * step_w)));
|
||||
a[i][0] = (int)(canvas->w - ((float)((i % side) * step_w)));
|
||||
a[i][1] = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -361,8 +326,7 @@ static void string_draw_full_by_offset(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
for (i = 0; i < side * 4; i++)
|
||||
{
|
||||
u = (i + o) % (side * 4);
|
||||
api->line((void *) api, which, canvas, snapshot, a[i][0], a[i][1],
|
||||
a[u][0], a[u][1], 1, string_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, a[i][0], a[i][1], a[u][0], a[u][1], 1, string_callback);
|
||||
}
|
||||
|
||||
for (i = 0; i < side * 4; i++)
|
||||
|
|
@ -403,18 +367,13 @@ void scale_coords(int *ox, int *oy, int *x, int *y)
|
|||
|
||||
void compute_middle(int start_point, int end_point, int vertex, int *middle)
|
||||
{
|
||||
*middle =
|
||||
min(start_point,
|
||||
end_point) + (max(start_point, end_point) - min(start_point,
|
||||
end_point)) / 2;
|
||||
*middle =
|
||||
min(*middle, vertex) + (max(*middle, vertex) - min(*middle, vertex)) / 2;
|
||||
*middle = min(start_point, end_point) + (max(start_point, end_point) - min(start_point, end_point)) / 2;
|
||||
*middle = min(*middle, vertex) + (max(*middle, vertex) - min(*middle, vertex)) / 2;
|
||||
}
|
||||
|
||||
void string_draw_triangle_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int middle_x, middle_y;
|
||||
|
||||
|
|
@ -429,21 +388,15 @@ void string_draw_triangle_preview(magic_api * api, int which,
|
|||
compute_middle(x, string_ox, string_ox, &middle_x);
|
||||
compute_middle(y, string_oy, string_oy, &middle_y);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, string_ox, string_oy,
|
||||
string_ox, y, 1, string_callback_xor);
|
||||
api->line((void *) api, which, canvas, snapshot, string_ox, string_oy, x,
|
||||
string_oy, 1, string_callback_xor);
|
||||
api->line((void *) api, which, canvas, snapshot, middle_x, middle_y, x,
|
||||
string_oy, 1, string_callback_xor);
|
||||
api->line((void *) api, which, canvas, snapshot, string_ox, y, middle_x,
|
||||
middle_y, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, string_ox, y, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, x, string_oy, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, middle_x, middle_y, x, string_oy, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, string_ox, y, middle_x, middle_y, 1, string_callback_xor);
|
||||
}
|
||||
|
||||
void string_draw_angle_preview(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int ox ATTRIBUTE_UNUSED,
|
||||
int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int middle_x, middle_y;
|
||||
int dx, dy;
|
||||
|
|
@ -454,7 +407,7 @@ void string_draw_angle_preview(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
SDL_BlitSurface(canvas_backup, update_rect, canvas, update_rect);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, string_ox, string_oy,
|
||||
api->line((void *)api, which, canvas, snapshot, string_ox, string_oy,
|
||||
string_vertex_x, string_vertex_y, 1, string_callback_xor);
|
||||
if (!string_vertex_done)
|
||||
{
|
||||
|
|
@ -469,22 +422,17 @@ void string_draw_angle_preview(magic_api * api, int which,
|
|||
compute_middle(string_ox, x, string_vertex_x, &middle_x);
|
||||
compute_middle(string_oy, y, string_vertex_y, &middle_y);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, string_vertex_x,
|
||||
string_vertex_y, x, y, 1, string_callback_xor);
|
||||
api->line((void *) api, which, canvas, snapshot, string_ox, string_oy,
|
||||
middle_x, middle_y, 1, string_callback_xor);
|
||||
api->line((void *) api, which, canvas, snapshot, x, y, middle_x, middle_y,
|
||||
1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, string_vertex_x, string_vertex_y, x, y, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, string_ox, string_oy, middle_x, middle_y, 1, string_callback_xor);
|
||||
api->line((void *)api, which, canvas, snapshot, x, y, middle_x, middle_y, 1, string_callback_xor);
|
||||
}
|
||||
|
||||
void string_draw_angle(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
float first_arm_step_x, first_arm_step_y, second_arm_step_x,
|
||||
second_arm_step_y;
|
||||
float first_arm_step_x, first_arm_step_y, second_arm_step_x, second_arm_step_y;
|
||||
int i;
|
||||
int max_wh, steps;
|
||||
int max_separation = 10;
|
||||
|
|
@ -498,29 +446,26 @@ void string_draw_angle(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
max_wh =
|
||||
max(max(max(string_ox, string_vertex_x), x) -
|
||||
min(min(string_vertex_x, x), string_ox),
|
||||
max(max(string_oy, string_vertex_y), y) - min(min(string_vertex_y, y),
|
||||
string_oy));
|
||||
max(max(string_oy, string_vertex_y), y) - min(min(string_vertex_y, y), string_oy));
|
||||
|
||||
steps = max_wh / max_separation;
|
||||
first_arm_step_x = (float) (string_ox - string_vertex_x) / (float) steps;
|
||||
first_arm_step_y = (float) (string_oy - string_vertex_y) / (float) steps;
|
||||
second_arm_step_x = (float) (string_vertex_x - x) / (float) steps;
|
||||
second_arm_step_y = (float) (string_vertex_y - y) / (float) steps;
|
||||
first_arm_step_x = (float)(string_ox - string_vertex_x) / (float)steps;
|
||||
first_arm_step_y = (float)(string_oy - string_vertex_y) / (float)steps;
|
||||
second_arm_step_x = (float)(string_vertex_x - x) / (float)steps;
|
||||
second_arm_step_y = (float)(string_vertex_y - y) / (float)steps;
|
||||
|
||||
for (i = 0; i <= steps; i++)
|
||||
{
|
||||
api->line((void *) api, 0, canvas, snapshot,
|
||||
api->line((void *)api, 0, canvas, snapshot,
|
||||
string_ox - first_arm_step_x * i,
|
||||
string_oy - first_arm_step_y * i,
|
||||
string_vertex_x - second_arm_step_x * i,
|
||||
string_vertex_y - second_arm_step_y * i, 1, string_callback);
|
||||
string_vertex_x - second_arm_step_x * i, string_vertex_y - second_arm_step_y * i, 1, string_callback);
|
||||
}
|
||||
}
|
||||
|
||||
void string_draw_triangle(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
SDL_BlitSurface(canvas_backup, 0, canvas, 0);
|
||||
scale_coords(&ox, &oy, &x, &y);
|
||||
|
|
@ -531,8 +476,7 @@ void string_draw_triangle(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
string_oy = y;
|
||||
y = string_vertex_y;
|
||||
|
||||
string_draw_angle((void *) api, which, canvas, snapshot, string_ox,
|
||||
string_oy, x, y, update_rect);
|
||||
string_draw_angle((void *)api, which, canvas, snapshot, string_ox, string_oy, x, y, update_rect);
|
||||
}
|
||||
|
||||
void string_draw_wrapper(magic_api * api, int which,
|
||||
|
|
@ -540,14 +484,11 @@ void string_draw_wrapper(magic_api * api, int which,
|
|||
int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (which == STRING_TOOL_FULL_BY_OFFSET)
|
||||
string_draw_full_by_offset((void *) api, which, canvas, snapshot, x, y,
|
||||
update_rect);
|
||||
string_draw_full_by_offset((void *)api, which, canvas, snapshot, x, y, update_rect);
|
||||
else if (which == STRING_TOOL_TRIANGLE)
|
||||
string_draw_triangle_preview((void *) api, which, canvas, snapshot, ox,
|
||||
oy, x, y, update_rect);
|
||||
string_draw_triangle_preview((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect);
|
||||
else if (which == STRING_TOOL_ANGLE)
|
||||
string_draw_angle_preview((void *) api, which, canvas, snapshot, ox, oy,
|
||||
x, y, update_rect);
|
||||
string_draw_angle_preview((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect);
|
||||
}
|
||||
|
||||
void string_set_vertex(int x, int y)
|
||||
|
|
@ -569,16 +510,13 @@ void string_set_vertex(int x, int y)
|
|||
}
|
||||
|
||||
void string_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if ((x < canvas->w) && (y < canvas->h) && (ox < canvas->w)
|
||||
&& (oy < canvas->h) && ((signed) x > 0) && ((signed) y > 0)
|
||||
&& ((signed) ox > 0) && ((signed) oy > 0))
|
||||
&& (oy < canvas->h) && ((signed)x > 0) && ((signed)y > 0) && ((signed)ox > 0) && ((signed)oy > 0))
|
||||
{
|
||||
string_set_vertex(x, y);
|
||||
string_draw_wrapper((void *) api, which, canvas, snapshot, ox, oy, x, y,
|
||||
update_rect);
|
||||
string_draw_wrapper((void *)api, which, canvas, snapshot, ox, oy, x, y, update_rect);
|
||||
api->playsound(string_snd[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
}
|
||||
|
|
@ -596,6 +534,8 @@ Uint8 string_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 0;
|
||||
}
|
||||
|
||||
void string_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 string_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,41 +19,39 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SWIRL_TOOL_CIRCLES,
|
||||
SWIRL_TOOL_RAYS,
|
||||
SWIRL_TOOL_FUR,
|
||||
NUM_SWIRL_TOOLS
|
||||
};
|
||||
|
||||
char * swirl_names[NUM_SWIRL_TOOLS] = {
|
||||
char *swirl_names[NUM_SWIRL_TOOLS] = {
|
||||
gettext_noop("Circles"),
|
||||
gettext_noop("Rays"),
|
||||
gettext_noop("Fur")
|
||||
};
|
||||
|
||||
char * swirl_descriptions[NUM_SWIRL_TOOLS][2] = {
|
||||
char *swirl_descriptions[NUM_SWIRL_TOOLS][2] = {
|
||||
{
|
||||
gettext_noop("Click and drag to transform parts of your picture to circular brushstrokes."),
|
||||
gettext_noop("Click to turn your entire picture into circular brushstrokes.")
|
||||
},
|
||||
gettext_noop("Click to turn your entire picture into circular brushstrokes.")},
|
||||
{
|
||||
gettext_noop("Click and drag to transform parts of your picture to brushstroke rays."),
|
||||
gettext_noop("Click to turn your entire picture into brushstroke rays.")
|
||||
},
|
||||
gettext_noop("Click to turn your entire picture into brushstroke rays.")},
|
||||
{
|
||||
gettext_noop("Click and drag to add fur to your picture."),
|
||||
""
|
||||
},
|
||||
""},
|
||||
};
|
||||
|
||||
char * swirl_icon_filenames[NUM_SWIRL_TOOLS] = {
|
||||
char *swirl_icon_filenames[NUM_SWIRL_TOOLS] = {
|
||||
"swirls_circles.png",
|
||||
"swirls_rays.png",
|
||||
"swirls_fur.png"
|
||||
};
|
||||
|
||||
char * swirl_sfx_filenames[NUM_SWIRL_TOOLS] = {
|
||||
char *swirl_sfx_filenames[NUM_SWIRL_TOOLS] = {
|
||||
"swirls_circles.ogg",
|
||||
"swirls_rays.ogg",
|
||||
"swirls_fur.ogg"
|
||||
|
|
@ -78,7 +76,7 @@ int SWIRLS_STROKE_LENGTH[NUM_SWIRL_TOOLS] = {
|
|||
};
|
||||
|
||||
Mix_Chunk *snd_effects[NUM_SWIRL_TOOLS];
|
||||
SDL_Surface * swirls_snapshot = NULL;
|
||||
SDL_Surface *swirls_snapshot = NULL;
|
||||
int swirls_start_x, swirls_start_y;
|
||||
Uint32 swirl_stroke_color;
|
||||
Uint8 swirl_fur_color_r, swirl_fur_color_g, swirl_fur_color_b;
|
||||
|
|
@ -94,31 +92,24 @@ int swirls_requires_colors(magic_api * api, int which);
|
|||
int swirls_modes(magic_api * api, int which);
|
||||
void swirls_shutdown(magic_api * api);
|
||||
void swirls_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x,
|
||||
int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void swirls_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void swirls_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void swirls_line_callback_drag(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void swirls_line_callback_drag(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y);
|
||||
void swirls_line_callback_draw_stroke(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y);
|
||||
void swirls_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void swirls_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void swirls_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void swirls_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void swirls_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
double get_angle(int x, int y, int target_x, int target_y);
|
||||
Uint8 swirls_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 swirls_default_size(magic_api * api, int which, int mode);
|
||||
void swirls_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void swirls_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 swirls_api_version(void)
|
||||
|
|
@ -131,9 +122,9 @@ int swirls_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_SWIRL_TOOLS; i++) {
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s",
|
||||
api->data_directory, swirl_sfx_filenames[i]);
|
||||
for (i = 0; i < NUM_SWIRL_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, swirl_sfx_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -150,50 +141,53 @@ SDL_Surface *swirls_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s",
|
||||
api->data_directory, swirl_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, swirl_icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *swirls_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
char *swirls_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return strdup(gettext(swirl_names[which]));
|
||||
}
|
||||
|
||||
int swirls_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int swirls_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
}
|
||||
|
||||
char *swirls_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode)
|
||||
char *swirls_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return strdup(gettext(swirl_descriptions[which][mode - 1]));
|
||||
}
|
||||
|
||||
int swirls_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which)
|
||||
int swirls_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int swirls_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int swirls_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,7 +196,8 @@ void swirls_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_SWIRL_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_SWIRL_TOOLS; i++)
|
||||
{
|
||||
if (snd_effects[i] != NULL)
|
||||
Mix_FreeChunk(snd_effects[i]);
|
||||
}
|
||||
|
|
@ -210,8 +205,7 @@ void swirls_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
swirls_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (snd_effects[which] != NULL)
|
||||
api->stopsound();
|
||||
|
|
@ -219,16 +213,23 @@ swirls_click(magic_api * api, int which, int mode,
|
|||
swirls_start_x = x;
|
||||
swirls_start_y = y;
|
||||
|
||||
if (mode == MODE_PAINT) {
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
swirls_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
} else {
|
||||
if (snd_effects[which] != NULL) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (snd_effects[which] != NULL)
|
||||
{
|
||||
api->playsound(snd_effects[which], (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
for (x = 0; x < canvas->w; x++) {
|
||||
for (y = 0; y < canvas->h; y++) {
|
||||
if (rand() % 100 == 0) {
|
||||
for (x = 0; x < canvas->w; x++)
|
||||
{
|
||||
for (y = 0; y < canvas->h; y++)
|
||||
{
|
||||
if (rand() % 100 == 0)
|
||||
{
|
||||
swirls_draw_stroke(api, which, canvas, x, y);
|
||||
}
|
||||
}
|
||||
|
|
@ -244,14 +245,15 @@ swirls_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
swirls_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
swirls_start_x = x;
|
||||
swirls_start_y = y;
|
||||
}
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */,
|
||||
api->line((void *)api, which, canvas, snapshot, ox, oy, x, y, 1 /* FIXME: Consider fewer iterations? */ ,
|
||||
swirls_line_callback_drag);
|
||||
|
||||
/* FIXME: Would be good to only update the area around the line (ox,oy)->(x,y) (+/- the maxium radius of the effect) */
|
||||
|
|
@ -263,10 +265,10 @@ swirls_drag(magic_api * api ATTRIBUTE_UNUSED, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void swirls_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED) {
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (snd_effects[which] != NULL && which != SWIRL_TOOL_FUR)
|
||||
api->stopsound();
|
||||
}
|
||||
|
|
@ -275,8 +277,7 @@ void swirls_release(magic_api * api, int which,
|
|||
void swirls_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)
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
swirl_fur_color_r = r;
|
||||
swirl_fur_color_g = g;
|
||||
|
|
@ -285,9 +286,7 @@ void swirls_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
|
||||
|
||||
void swirls_line_callback_drag(void *ptr, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
int i, ang_deg, radius, nx, ny;
|
||||
double ang_rad;
|
||||
|
|
@ -296,19 +295,21 @@ void swirls_line_callback_drag(void *ptr, int which,
|
|||
if (snd_effects[which] != NULL)
|
||||
api->playsound(snd_effects[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
for (i = 0; i < SWIRLS_NUM_STROKES_PER_DRAG_LINE[which]; i++) {
|
||||
for (i = 0; i < SWIRLS_NUM_STROKES_PER_DRAG_LINE[which]; i++)
|
||||
{
|
||||
ang_deg = (rand() % 360);
|
||||
ang_rad = (ang_deg * M_PI) / 180.0;
|
||||
radius = (rand() % (SWIRLS_DRAG_LINE_STROKE_RADIUS[which] * 2)) - SWIRLS_DRAG_LINE_STROKE_RADIUS[which];
|
||||
|
||||
nx = x + (int) (cos(ang_rad) * radius);
|
||||
ny = y + (int) (sin(ang_rad) * radius);
|
||||
nx = x + (int)(cos(ang_rad) * radius);
|
||||
ny = y + (int)(sin(ang_rad) * radius);
|
||||
|
||||
swirls_draw_stroke(api, which, canvas, nx, ny);
|
||||
}
|
||||
}
|
||||
|
||||
void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y) {
|
||||
void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x, int y)
|
||||
{
|
||||
int x1, y1, x2, y2, len;
|
||||
double a;
|
||||
Uint8 r, g, b;
|
||||
|
|
@ -317,66 +318,85 @@ void swirls_draw_stroke(magic_api * api, int which, SDL_Surface * canvas, int x,
|
|||
len = SWIRLS_STROKE_LENGTH[which];
|
||||
|
||||
a = get_angle(x, y, swirls_start_x, swirls_start_y);
|
||||
if (which == SWIRL_TOOL_CIRCLES) {
|
||||
if (which == SWIRL_TOOL_CIRCLES)
|
||||
{
|
||||
a = a + (M_PI / 2.0);
|
||||
}
|
||||
|
||||
x1 = x - cos(a) * len;
|
||||
y1 = y - sin(a) * len;
|
||||
|
||||
|
||||
x2 = x + cos(a) * len;
|
||||
y2 = y + sin(a) * len;
|
||||
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
r = swirl_fur_color_r;
|
||||
g = swirl_fur_color_g;
|
||||
b = swirl_fur_color_b;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
swirl_stroke_color = api->getpixel(swirls_snapshot, x, y);
|
||||
SDL_GetRGB(swirl_stroke_color, canvas->format, &r, &g, &b);
|
||||
}
|
||||
|
||||
api->rgbtohsv(r, g, b, &h, &s, &v);
|
||||
h = h + (((rand() % 7) - 3) / 10.0);
|
||||
if (s > 0.00) {
|
||||
if (s > 0.00)
|
||||
{
|
||||
s = s + (((rand() % 3) - 1) / 10.0);
|
||||
}
|
||||
v = v + (((rand() % 3) - 1) / 10.0);
|
||||
if (h < 0.0) {
|
||||
h = h - 360.0;
|
||||
} else if (h >= 360.0) {
|
||||
if (h < 0.0)
|
||||
{
|
||||
h = h - 360.0;
|
||||
}
|
||||
if (s < 0.0) {
|
||||
else if (h >= 360.0)
|
||||
{
|
||||
h = h - 360.0;
|
||||
}
|
||||
if (s < 0.0)
|
||||
{
|
||||
s = 0.0;
|
||||
} else if (s > 1.0) {
|
||||
}
|
||||
else if (s > 1.0)
|
||||
{
|
||||
s = 1.0;
|
||||
}
|
||||
if (v < 0.0) {
|
||||
if (v < 0.0)
|
||||
{
|
||||
v = 0.0;
|
||||
} else if (v > 1.0) {
|
||||
}
|
||||
else if (v > 1.0)
|
||||
{
|
||||
v = 1.0;
|
||||
}
|
||||
api->hsvtorgb(h, s, v, &r, &g, &b);
|
||||
swirl_stroke_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||
|
||||
api->line((void *) api, which, canvas, NULL /* N/A */,
|
||||
api->line((void *)api, which, canvas, NULL /* N/A */ ,
|
||||
x1, y1, x2, y2, 1, swirls_line_callback_draw_stroke);
|
||||
}
|
||||
|
||||
|
||||
void swirls_line_callback_draw_stroke(void *ptr, int which,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y) {
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
||||
if (which == SWIRL_TOOL_FUR) {
|
||||
if (which == SWIRL_TOOL_FUR)
|
||||
{
|
||||
api->putpixel(canvas, x, y, swirl_stroke_color);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int xx, yy;
|
||||
for (yy = -1; yy <= 1; yy++) {
|
||||
for (xx = -1; xx <= 1; xx++) {
|
||||
|
||||
for (yy = -1; yy <= 1; yy++)
|
||||
{
|
||||
for (xx = -1; xx <= 1; xx++)
|
||||
{
|
||||
api->putpixel(canvas, x + xx, y + yy, swirl_stroke_color);
|
||||
}
|
||||
}
|
||||
|
|
@ -385,28 +405,25 @@ void swirls_line_callback_draw_stroke(void *ptr, int which,
|
|||
|
||||
|
||||
void swirls_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
if (swirls_snapshot == NULL)
|
||||
swirls_snapshot = SDL_CreateRGBSurface(SDL_SWSURFACE, canvas->w, canvas->h,
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask,
|
||||
canvas->format->Amask);
|
||||
canvas->format->BitsPerPixel, canvas->format->Rmask,
|
||||
canvas->format->Gmask, canvas->format->Bmask, canvas->format->Amask);
|
||||
|
||||
if (swirls_snapshot != NULL)
|
||||
SDL_BlitSurface(canvas, NULL, swirls_snapshot, NULL);
|
||||
}
|
||||
|
||||
void swirls_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
double get_angle(int x, int y, int target_x, int target_y) {
|
||||
return atan2((double) (y - target_y), (double) (x - target_x));
|
||||
double get_angle(int x, int y, int target_x, int target_y)
|
||||
{
|
||||
return atan2((double)(y - target_y), (double)(x - target_x));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -423,6 +440,8 @@ Uint8 swirls_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
return 0;
|
||||
}
|
||||
|
||||
void swirls_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 swirls_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,13 +75,10 @@ const char *tint_names[tint_NUM_TOOLS] = {
|
|||
};
|
||||
|
||||
const char *tint_descs[tint_NUM_TOOLS][2] = {
|
||||
{gettext_noop
|
||||
("Click and drag the mouse around to change the color of parts of your picture."),
|
||||
{gettext_noop("Click and drag the mouse around to change the color of parts of your picture."),
|
||||
gettext_noop("Click to change the color of your entire picture."),},
|
||||
{gettext_noop
|
||||
("Click and drag the mouse around to turn parts of your picture into white and a color you choose."),
|
||||
gettext_noop
|
||||
("Click to turn your entire picture into white and a color you choose.")}
|
||||
{gettext_noop("Click and drag the mouse around to turn parts of your picture into white and a color you choose."),
|
||||
gettext_noop("Click to turn your entire picture into white and a color you choose.")}
|
||||
};
|
||||
|
||||
int tint_init(magic_api * api, Uint32 disabled_features);
|
||||
|
|
@ -92,15 +89,11 @@ char *tint_get_name(magic_api * api, int which);
|
|||
int tint_get_group(magic_api * api, int which);
|
||||
char *tint_get_description(magic_api * api, int which, int mode);
|
||||
static int tint_grey(Uint8 r1, Uint8 g1, Uint8 b1);
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which);
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which);
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void tint_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 tint_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tint_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -109,14 +102,13 @@ void tint_shutdown(magic_api * api);
|
|||
void tint_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int tint_requires_colors(magic_api * api, int which);
|
||||
void tint_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void tint_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int tint_modes(magic_api * api, int which);
|
||||
Uint8 tint_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 tint_default_size(magic_api * api, int which, int mode);
|
||||
void tint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void tint_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 tint_api_version(void)
|
||||
|
|
@ -126,13 +118,13 @@ Uint32 tint_api_version(void)
|
|||
|
||||
//Load sounds
|
||||
int tint_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{int i;
|
||||
{
|
||||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < tint_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
tint_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, tint_snd_filenames[i]);
|
||||
tint_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
return (1);
|
||||
|
|
@ -148,8 +140,7 @@ SDL_Surface *tint_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
tint_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, tint_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -160,15 +151,13 @@ char *tint_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int tint_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tint_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *tint_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode)
|
||||
char *tint_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
return (strdup(gettext_noop(tint_descs[which][mode - 1])));
|
||||
}
|
||||
|
|
@ -179,8 +168,7 @@ static int tint_grey(Uint8 r1, Uint8 g1, Uint8 b1)
|
|||
return 0.3 * r1 + .59 * g1 + 0.11 * b1;
|
||||
}
|
||||
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -204,21 +192,18 @@ static void do_tint_pixel(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
if (greyValue < thresholdValue)
|
||||
{
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, x, y,
|
||||
SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int which)
|
||||
static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
|
@ -231,8 +216,7 @@ static void do_tint_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last,
|
|||
}
|
||||
}
|
||||
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y)
|
||||
static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
int xx, yy;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
|
|
@ -241,8 +225,7 @@ static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
for (xx = x - tint_RADIUS; xx < x + tint_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, tint_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, tint_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
do_tint_pixel(api, which, canvas, last, xx, yy);
|
||||
}
|
||||
|
|
@ -252,12 +235,10 @@ static void do_tint_brush(void *ptr, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void tint_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_tint_brush);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_tint_brush);
|
||||
|
||||
api->playsound(tint_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -284,8 +265,7 @@ void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void tint_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_PAINT)
|
||||
tint_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -305,8 +285,7 @@ void tint_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 y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +306,8 @@ void tint_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void tint_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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tint_r = r;
|
||||
tint_g = g;
|
||||
|
|
@ -335,14 +315,12 @@ void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int tint_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
|
||||
int x, y;
|
||||
|
|
@ -370,8 +348,7 @@ void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void tint_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -394,8 +371,9 @@ Uint8 tint_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
return 4;
|
||||
}
|
||||
|
||||
void tint_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void tint_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tint_RADIUS = size * 4;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,30 +83,25 @@ SDL_Surface *toothpaste_get_icon(magic_api * api, int which);
|
|||
char *toothpaste_get_name(magic_api * api, int which);
|
||||
int toothpaste_get_group(magic_api * api, int which);
|
||||
char *toothpaste_get_description(magic_api * api, int which, int mode);
|
||||
static void do_toothpaste(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_toothpaste(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
void toothpaste_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 toothpaste_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 toothpaste_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void toothpaste_shutdown(magic_api * api);
|
||||
void toothpaste_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int toothpaste_requires_colors(magic_api * api, int which);
|
||||
void toothpaste_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void toothpaste_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void toothpaste_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void toothpaste_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int toothpaste_modes(magic_api * api, int which);
|
||||
int toothpaste_setup_weights(magic_api * api);
|
||||
Uint8 toothpaste_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 toothpaste_default_size(magic_api * api, int which, int mode);
|
||||
void toothpaste_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void toothpaste_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 toothpaste_api_version(void)
|
||||
|
|
@ -123,8 +118,7 @@ int toothpaste_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
//Load sounds
|
||||
for (i = 0; i < toothpaste_NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory,
|
||||
toothpaste_snd_filenames[i]);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, toothpaste_snd_filenames[i]);
|
||||
toothpaste_snd_effect[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
||||
|
|
@ -137,13 +131,12 @@ int toothpaste_setup_weights(magic_api * api)
|
|||
|
||||
//Set up weights
|
||||
pi = acos(0.0) * 2;
|
||||
if (toothpaste_weights != NULL) {
|
||||
if (toothpaste_weights != NULL)
|
||||
{
|
||||
free(toothpaste_weights);
|
||||
}
|
||||
|
||||
toothpaste_weights =
|
||||
(double *) malloc(toothpaste_RADIUS * 2 * toothpaste_RADIUS * 2 *
|
||||
sizeof(double));
|
||||
toothpaste_weights = (double *)malloc(toothpaste_RADIUS * 2 * toothpaste_RADIUS * 2 * sizeof(double));
|
||||
if (toothpaste_weights == NULL)
|
||||
{
|
||||
return (0);
|
||||
|
|
@ -159,7 +152,7 @@ int toothpaste_setup_weights(magic_api * api)
|
|||
toothpaste_RADIUS) * ((toothpaste_RADIUS * 2) -
|
||||
1) + (j +
|
||||
toothpaste_RADIUS)] =
|
||||
((fabs(atan2((double) (j), (double) (k)))) / pi);
|
||||
((fabs(atan2((double)(j), (double)(k)))) / pi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,8 +170,7 @@ SDL_Surface *toothpaste_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory,
|
||||
toothpaste_icon_filenames[which]);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/%s", api->data_directory, toothpaste_icon_filenames[which]);
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
|
|
@ -195,16 +187,14 @@ int toothpaste_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *toothpaste_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *toothpaste_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop(toothpaste_descs[which])));
|
||||
}
|
||||
|
||||
// Do the effect:
|
||||
static void do_toothpaste(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 xx, yy;
|
||||
|
|
@ -220,18 +210,14 @@ static void do_toothpaste(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
for (xx = x - toothpaste_RADIUS; xx < x + toothpaste_RADIUS; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, toothpaste_RADIUS)
|
||||
&& !api->touched(xx, yy))
|
||||
if (api->in_circle(xx - x, yy - y, toothpaste_RADIUS) && !api->touched(xx, yy))
|
||||
{
|
||||
|
||||
api->rgbtohsv(toothpaste_r, toothpaste_g, toothpaste_b, &h, &s, &v);
|
||||
api->hsvtorgb(h, s,
|
||||
toothpaste_weights[(yy - y +
|
||||
toothpaste_RADIUS) *
|
||||
((toothpaste_RADIUS * 2) - 1) + (xx -
|
||||
x +
|
||||
toothpaste_RADIUS)],
|
||||
&r, &g, &b);
|
||||
((toothpaste_RADIUS * 2) - 1) + (xx - x + toothpaste_RADIUS)], &r, &g, &b);
|
||||
api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, r, g, b));
|
||||
|
||||
}
|
||||
|
|
@ -242,12 +228,10 @@ static void do_toothpaste(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void toothpaste_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_toothpaste);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_toothpaste);
|
||||
|
||||
api->playsound(toothpaste_snd_effect[which], (x * 255) / canvas->w, 255);
|
||||
|
||||
|
|
@ -260,8 +244,7 @@ void toothpaste_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void toothpaste_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)
|
||||
{
|
||||
|
||||
toothpaste_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -272,8 +255,7 @@ void toothpaste_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -298,8 +280,9 @@ void toothpaste_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void toothpaste_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 toothpaste_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)
|
||||
{
|
||||
toothpaste_r = r;
|
||||
toothpaste_g = g;
|
||||
|
|
@ -307,29 +290,23 @@ void toothpaste_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int toothpaste_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int toothpaste_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void toothpaste_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void toothpaste_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int toothpaste_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int toothpaste_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
|
@ -345,7 +322,9 @@ Uint8 toothpaste_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIB
|
|||
return 2;
|
||||
}
|
||||
|
||||
void toothpaste_set_size(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void toothpaste_set_size(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
toothpaste_RADIUS = size * 5;
|
||||
toothpaste_setup_weights(api);
|
||||
|
|
|
|||
|
|
@ -63,18 +63,14 @@ typedef struct
|
|||
float x, y;
|
||||
} Point2D;
|
||||
|
||||
static void tornado_predrag(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y);
|
||||
static void tornado_predrag(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y);
|
||||
static void tornado_drawbase(magic_api * api, SDL_Surface * canvas);
|
||||
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int top_x, int top_y,
|
||||
int minx, int maxx, int bottom_x, int bottom_y,
|
||||
int final);
|
||||
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x,
|
||||
int y);
|
||||
int minx, int maxx, int bottom_x, int bottom_y, int final);
|
||||
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y);
|
||||
static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t);
|
||||
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve);
|
||||
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve);
|
||||
static void tornado_colorize_cloud(magic_api * api);
|
||||
static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas);
|
||||
Uint32 tornado_api_version(void);
|
||||
|
|
@ -85,26 +81,23 @@ char *tornado_get_name(magic_api * api, int which);
|
|||
int tornado_get_group(magic_api * api, int which);
|
||||
char *tornado_get_description(magic_api * api, int which, int mode);
|
||||
void tornado_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 tornado_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tornado_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void tornado_shutdown(magic_api * api);
|
||||
void tornado_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int tornado_requires_colors(magic_api * api, int which);
|
||||
void tornado_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void tornado_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void tornado_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void tornado_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int tornado_modes(magic_api * api, int which);
|
||||
Uint8 tornado_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 tornado_default_size(magic_api * api, int which, int mode);
|
||||
void tornado_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void tornado_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -125,16 +118,13 @@ int tornado_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
tornado_click_snd = Mix_LoadWAV(fname);
|
||||
*/
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg", api->data_directory);
|
||||
tornado_release_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png", api->data_directory);
|
||||
tornado_base = IMG_Load(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png", api->data_directory);
|
||||
tornado_cloud = IMG_Load(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -151,41 +141,33 @@ SDL_Surface *tornado_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tornado.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Tornado")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_ARTISTIC;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to draw a tornado funnel on your picture.")));
|
||||
return (strdup(gettext_noop("Click and drag to draw a tornado funnel on your picture.")));
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox,
|
||||
int oy, int x, int y)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y)
|
||||
{
|
||||
if (x < tornado_min_x)
|
||||
tornado_min_x = x;
|
||||
|
|
@ -219,8 +201,7 @@ static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int ox, int oy,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
tornado_predrag(api, canvas, last, ox, oy, x, y);
|
||||
|
||||
|
|
@ -233,8 +214,7 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
/* Draw the base and the stalk (low-quality) for now: */
|
||||
|
||||
tornado_drawstalk(api, canvas, last,
|
||||
x, y, tornado_min_x, tornado_max_x, tornado_bottom_x,
|
||||
tornado_bottom_y, !(api->button_down()));
|
||||
x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, !(api->button_down()));
|
||||
|
||||
tornado_drawbase(api, canvas);
|
||||
|
||||
|
|
@ -246,8 +226,7 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void tornado_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)
|
||||
{
|
||||
tornado_min_x = x;
|
||||
tornado_max_x = x;
|
||||
|
|
@ -266,8 +245,7 @@ void tornado_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on release:
|
||||
void tornado_release(magic_api * api, int which 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)
|
||||
{
|
||||
/* Don't let tornado be too low compared to base: */
|
||||
|
||||
|
|
@ -287,8 +265,7 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
/* Draw high-quality stalk, and tornado: */
|
||||
|
||||
tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x,
|
||||
tornado_bottom_x, tornado_bottom_y, 1);
|
||||
tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, 1);
|
||||
|
||||
tornado_drawtornado(api, canvas, x, y);
|
||||
|
||||
|
|
@ -304,8 +281,7 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
|
||||
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x,
|
||||
int y)
|
||||
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y)
|
||||
{
|
||||
SDL_Surface *aux_surf;
|
||||
SDL_Rect dest;
|
||||
|
|
@ -318,8 +294,7 @@ static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x,
|
|||
SDL_FreeSurface(aux_surf);
|
||||
}
|
||||
|
||||
static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
|
|
@ -332,19 +307,17 @@ static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED,
|
|||
static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas)
|
||||
{
|
||||
Uint8 r, g, b, a;
|
||||
float f = (float) rand() * 255 / RAND_MAX;
|
||||
float f = (float)rand() * 255 / RAND_MAX;
|
||||
|
||||
SDL_GetRGBA(pixel, canvas->format, &r, &g, &b, &a);
|
||||
return (SDL_MapRGBA(canvas->format,
|
||||
(tornado_r + r + (Uint8) f * 2) / 4,
|
||||
(tornado_g + g + (Uint8) f * 2) / 4,
|
||||
(tornado_b + b + (Uint8) f * 2) / 4, a));
|
||||
(tornado_g + g + (Uint8) f * 2) / 4, (tornado_b + b + (Uint8) f * 2) / 4, a));
|
||||
}
|
||||
|
||||
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int top_x, int top_y,
|
||||
int minx, int maxx, int bottom_x, int bottom_y,
|
||||
int final)
|
||||
int minx, int maxx, int bottom_x, int bottom_y, int final)
|
||||
{
|
||||
Point2D control_points[4];
|
||||
Point2D *curve;
|
||||
|
|
@ -426,34 +399,23 @@ static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas,
|
|||
/* The body of the tornado: 3x 1y rotation + some random particles */
|
||||
for (p = dest.x; p < dest.x + dest.w; p++)
|
||||
{
|
||||
if ((float) rand() * 100 / RAND_MAX > 10)
|
||||
if ((float)rand() * 100 / RAND_MAX > 10)
|
||||
{
|
||||
api->putpixel(canvas, p, dest.y,
|
||||
api->getpixel(last,
|
||||
dest.x + (p - dest.x + rotation) % dest.w,
|
||||
dest.y));
|
||||
api->putpixel(canvas, p, dest.y, api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y));
|
||||
}
|
||||
else
|
||||
{
|
||||
api->putpixel(canvas, p, dest.y,
|
||||
tornado_mess(api->getpixel(last,
|
||||
dest.x + (p - dest.x +
|
||||
rotation) % dest.w,
|
||||
dest.y), canvas));
|
||||
tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y), canvas));
|
||||
}
|
||||
}
|
||||
|
||||
/* Some random particles flying around the tornado */
|
||||
for (p = dest.x - dest.w * 20 / 100;
|
||||
p < dest.x + dest.w + dest.w * 20 / 100; p++)
|
||||
for (p = dest.x - dest.w * 20 / 100; p < dest.x + dest.w + dest.w * 20 / 100; p++)
|
||||
{
|
||||
if ((float) rand() * 100 / RAND_MAX < 5
|
||||
&& ((p < dest.x) || (p > dest.w)))
|
||||
if ((float)rand() * 100 / RAND_MAX < 5 && ((p < dest.x) || (p > dest.w)))
|
||||
api->putpixel(canvas, p, dest.y,
|
||||
tornado_mess(api->getpixel(last,
|
||||
dest.x + (p - dest.x +
|
||||
rotation) % dest.w,
|
||||
dest.y), canvas));
|
||||
tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y), canvas));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -480,7 +442,8 @@ void tornado_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void tornado_set_color(magic_api * api, 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)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tornado_r = r;
|
||||
tornado_g = g;
|
||||
|
|
@ -490,8 +453,7 @@ void tornado_set_color(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -546,8 +508,7 @@ static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t)
|
|||
<sizeof(Point2D) numberOfPoints>
|
||||
*/
|
||||
|
||||
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints,
|
||||
Point2D * curve)
|
||||
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve)
|
||||
{
|
||||
float dt;
|
||||
int i;
|
||||
|
|
@ -570,9 +531,7 @@ static void tornado_colorize_cloud(magic_api * api)
|
|||
|
||||
/* Create a surface to render into: */
|
||||
|
||||
amask =
|
||||
~(tornado_cloud->format->Rmask | tornado_cloud->format->
|
||||
Gmask | tornado_cloud->format->Bmask);
|
||||
amask = ~(tornado_cloud->format->Rmask | tornado_cloud->format->Gmask | tornado_cloud->format->Bmask);
|
||||
|
||||
tornado_cloud_colorized =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE,
|
||||
|
|
@ -580,8 +539,7 @@ static void tornado_colorize_cloud(magic_api * api)
|
|||
tornado_cloud->h,
|
||||
tornado_cloud->format->BitsPerPixel,
|
||||
tornado_cloud->format->Rmask,
|
||||
tornado_cloud->format->Gmask,
|
||||
tornado_cloud->format->Bmask, amask);
|
||||
tornado_cloud->format->Gmask, tornado_cloud->format->Bmask, amask);
|
||||
|
||||
/* Render the new cloud: */
|
||||
|
||||
|
|
@ -592,14 +550,11 @@ static void tornado_colorize_cloud(magic_api * api)
|
|||
{
|
||||
for (x = 0; x < tornado_cloud->w; x++)
|
||||
{
|
||||
SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format,
|
||||
&r, &g, &b, &a);
|
||||
SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format, &r, &g, &b, &a);
|
||||
|
||||
api->putpixel(tornado_cloud_colorized, x, y,
|
||||
SDL_MapRGBA(tornado_cloud_colorized->format,
|
||||
(tornado_r + r * 2) / 3,
|
||||
(tornado_g + g * 2) / 3,
|
||||
(tornado_b + b * 2) / 3, a));
|
||||
(tornado_r + r * 2) / 3, (tornado_g + g * 2) / 3, (tornado_b + b * 2) / 3, a));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -608,20 +563,17 @@ static void tornado_colorize_cloud(magic_api * api)
|
|||
}
|
||||
|
||||
void tornado_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void tornado_switchout(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
api->stopsound();
|
||||
}
|
||||
|
||||
int tornado_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tornado_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (MODE_PAINT_WITH_PREVIEW);
|
||||
}
|
||||
|
|
@ -637,6 +589,8 @@ Uint8 tornado_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tornado_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 tornado_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
static int tv_radius = 16;
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TV_TOOL_TV_CLASSIC,
|
||||
TV_TOOL_TV_BRIGHT,
|
||||
NUM_TV_TOOLS
|
||||
|
|
@ -55,16 +56,12 @@ int tv_get_group(magic_api * api, int which);
|
|||
char *tv_get_description(magic_api * api, int which, int mode);
|
||||
int tv_requires_colors(magic_api * api, int which);
|
||||
void tv_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||
void tv_shutdown(magic_api * api);
|
||||
void tv_paint_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void tv_do_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void tv_paint_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void tv_do_tv(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void tv_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void tv_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void tv_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
|
@ -72,7 +69,8 @@ void tv_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
|||
int tv_modes(magic_api * api, int which);
|
||||
Uint8 tv_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 tv_default_size(magic_api * api, int which, int mode);
|
||||
void tv_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void tv_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
// Housekeeping functions
|
||||
|
|
@ -83,7 +81,8 @@ Uint32 tv_api_version(void)
|
|||
}
|
||||
|
||||
void tv_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
//get the colors from API and store it in structure
|
||||
}
|
||||
|
|
@ -92,8 +91,7 @@ int tv_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/tv.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/tv.ogg", api->data_directory);
|
||||
tv_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -108,8 +106,7 @@ SDL_Surface *tv_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tv.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/tv.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
|
@ -127,21 +124,15 @@ int tv_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
return MAGIC_TYPE_DISTORTS;
|
||||
}
|
||||
|
||||
char *tv_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *tv_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click and drag to make parts of your picture look like they are on television."));
|
||||
return strdup(gettext_noop("Click and drag to make parts of your picture look like they are on television."));
|
||||
else
|
||||
return
|
||||
strdup(gettext_noop
|
||||
("Click to make your picture look like it's on television."));
|
||||
return strdup(gettext_noop("Click to make your picture look like it's on television."));
|
||||
}
|
||||
|
||||
int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -149,8 +140,7 @@ int tv_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
|||
void tv_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -162,8 +152,7 @@ void tv_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
// Interactivity functions
|
||||
|
||||
void tv_do_tv(void *ptr_to_api, int which_tool,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr_to_api;
|
||||
int r, g, b, i;
|
||||
|
|
@ -178,11 +167,14 @@ void tv_do_tv(void *ptr_to_api, int which_tool,
|
|||
the original "TV" effect as a stylistic way to darken parts of their
|
||||
picture, so we offer two tools (brighter, and classic).
|
||||
-bjk 2023.04.22 */
|
||||
if (which_tool == TV_TOOL_TV_BRIGHT) {
|
||||
if (which_tool == TV_TOOL_TV_BRIGHT)
|
||||
{
|
||||
r = r8 * 2;
|
||||
g = g8 * 2;
|
||||
b = b8 * 2;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
r = r8;
|
||||
g = g8;
|
||||
b = b8;
|
||||
|
|
@ -220,8 +212,7 @@ void tv_do_tv(void *ptr_to_api, int which_tool,
|
|||
}
|
||||
|
||||
void tv_paint_tv(void *ptr_to_api, int which_tool,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
int i, j;
|
||||
magic_api *api = (magic_api *) ptr_to_api;
|
||||
|
|
@ -241,8 +232,7 @@ void tv_paint_tv(void *ptr_to_api, int which_tool,
|
|||
}
|
||||
|
||||
void tv_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line(api, which, canvas, snapshot, ox, oy, x, y, 1, tv_paint_tv);
|
||||
|
||||
|
|
@ -254,8 +244,7 @@ void tv_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void tv_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)
|
||||
{
|
||||
|
|
@ -279,15 +268,13 @@ void tv_click(magic_api * api, int which, int mode,
|
|||
}
|
||||
|
||||
void tv_switchin(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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void tv_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -311,7 +298,9 @@ Uint8 tv_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
return 4;
|
||||
}
|
||||
|
||||
void tv_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, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void tv_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,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tv_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ char *waves_get_name(magic_api * api, int which);
|
|||
int waves_get_group(magic_api * api, int which);
|
||||
char *waves_get_description(magic_api * api, int which, int mode);
|
||||
void waves_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 waves_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void waves_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -58,14 +57,13 @@ void waves_shutdown(magic_api * api);
|
|||
void waves_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int waves_requires_colors(magic_api * api, int which);
|
||||
void waves_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void waves_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void waves_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void waves_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int waves_modes(magic_api * api, int which);
|
||||
Uint8 waves_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 waves_default_size(magic_api * api, int which, int mode);
|
||||
void waves_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void waves_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
Uint32 waves_api_version(void)
|
||||
{
|
||||
|
|
@ -78,12 +76,10 @@ int waves_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/waves.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/waves.ogg", api->data_directory);
|
||||
waves_snd[0] = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/wavelet.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/wavelet.ogg", api->data_directory);
|
||||
waves_snd[1] = Mix_LoadWAV(fname);
|
||||
|
||||
|
||||
|
|
@ -102,18 +98,15 @@ SDL_Surface *waves_get_icon(magic_api * api, int which)
|
|||
char fname[1024];
|
||||
|
||||
if (!which)
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/waves.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/waves.png", api->data_directory);
|
||||
else
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/wavelet.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/wavelet.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our group (both the same):
|
||||
int waves_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int waves_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
|
@ -128,8 +121,7 @@ char *waves_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (!which)
|
||||
return (strdup
|
||||
|
|
@ -143,8 +135,7 @@ char *waves_get_description(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
|
||||
void waves_drag(magic_api * api ATTRIBUTE_UNUSED, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int xx, yy;
|
||||
SDL_Rect src, dest;
|
||||
|
|
@ -202,8 +193,7 @@ void waves_drag(magic_api * api ATTRIBUTE_UNUSED, int which,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void waves_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)
|
||||
{
|
||||
waves_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
api->playsound(waves_snd[which], 128, 255);
|
||||
|
|
@ -214,8 +204,7 @@ void waves_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -229,27 +218,26 @@ void waves_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void waves_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void waves_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
// Use colors:
|
||||
int waves_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int waves_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void waves_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void waves_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -269,6 +257,8 @@ Uint8 waves_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void waves_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 waves_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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,28 +44,25 @@ int xor_get_group(magic_api * api, int which);
|
|||
char *xor_get_description(magic_api * api, int which, int mode);
|
||||
|
||||
void xor_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 xor_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 xor_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 xor_shutdown(magic_api * api);
|
||||
void xor_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int xor_requires_colors(magic_api * api, int which);
|
||||
void xor_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void xor_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void xor_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int xor_modes(magic_api * api, int which);
|
||||
Uint8 xor_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 xor_default_size(magic_api * api, int which, int mode);
|
||||
void xor_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void xor_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 xor_api_version(void)
|
||||
|
|
@ -77,8 +74,7 @@ int xor_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/xor.ogg",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/xor.ogg", api->data_directory);
|
||||
xor_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -93,38 +89,31 @@ SDL_Surface *xor_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/xor.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/xor.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *xor_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *xor_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Xor Colors")));
|
||||
}
|
||||
|
||||
int xor_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int xor_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_COLOR_FILTERS;
|
||||
}
|
||||
|
||||
char *xor_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode)
|
||||
char *xor_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
return (strdup(gettext_noop("Click and drag to draw a XOR effect")));
|
||||
else
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click to draw a XOR effect on the whole picture")));
|
||||
return (strdup(gettext_noop("Click to draw a XOR effect on the whole picture")));
|
||||
}
|
||||
|
||||
static void do_xor(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;
|
||||
Uint8 r, g, b, xor;
|
||||
|
|
@ -134,17 +123,16 @@ static void do_xor(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r, &g, &b);
|
||||
api->rgbtohsv(r, g, b, &hue, &sat, &val);
|
||||
if (sat == 0)
|
||||
xor = (2 * (int) hue + (x ^ y)) % 360;
|
||||
xor = (2 * (int)hue + (x ^ y)) % 360;
|
||||
else
|
||||
xor = ((int) hue + (x ^ y)) % 360;
|
||||
xor = ((int)hue + (x ^ y)) % 360;
|
||||
api->hsvtorgb(xor, 1, 1, &r, &g, &b);
|
||||
pixel = SDL_MapRGB(canvas->format, r, g, b);
|
||||
api->putpixel(canvas, x, y, pixel);
|
||||
}
|
||||
|
||||
static void do_xor_circle(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 xx, yy;
|
||||
|
|
@ -163,11 +151,9 @@ static void do_xor_circle(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void xor_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, 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_xor_circle);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, do_xor_circle);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -193,8 +179,7 @@ void xor_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
void xor_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (mode == MODE_PAINT)
|
||||
xor_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -217,8 +202,7 @@ void xor_click(magic_api * api, int which, int mode,
|
|||
void xor_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 y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -229,25 +213,23 @@ void xor_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
void xor_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int xor_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int xor_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void xor_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void xor_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -270,7 +252,9 @@ Uint8 xor_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNU
|
|||
return 4;
|
||||
}
|
||||
|
||||
void xor_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 xor_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)
|
||||
{
|
||||
xor_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue