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
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue