Ran indent.sh to re-indent all source files
This commit is contained in:
parent
fbb46751c6
commit
5bdbc2766b
27 changed files with 1591 additions and 1273 deletions
|
|
@ -33,20 +33,21 @@
|
|||
#include "SDL_mixer.h"
|
||||
#include "SDL2_gfxPrimitives.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_WARP,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
char * warp_icons[NUM_TOOLS] = {
|
||||
"rainbow.png", // FIXME
|
||||
char *warp_icons[NUM_TOOLS] = {
|
||||
"rainbow.png", // FIXME
|
||||
};
|
||||
|
||||
char * warp_snd_fnames[NUM_TOOLS] = {
|
||||
"rainbow.ogg", // FIXME
|
||||
char *warp_snd_fnames[NUM_TOOLS] = {
|
||||
"rainbow.ogg", // FIXME
|
||||
};
|
||||
|
||||
char * warp_tool_names[NUM_TOOLS] = {
|
||||
char *warp_tool_names[NUM_TOOLS] = {
|
||||
gettext_noop("Warp"),
|
||||
};
|
||||
|
||||
|
|
@ -54,7 +55,8 @@ char * warp_tool_names[NUM_TOOLS] = {
|
|||
#define MAX_WARP_RADIUS 64
|
||||
#define WARP_MESH_RES 16
|
||||
|
||||
typedef struct warp_mesh_s {
|
||||
typedef struct warp_mesh_s
|
||||
{
|
||||
int scr_x;
|
||||
int scr_y;
|
||||
float pt_x;
|
||||
|
|
@ -66,9 +68,9 @@ typedef struct warp_mesh_s {
|
|||
static int warp_radius;
|
||||
int warp_mesh_w, warp_mesh_h;
|
||||
float warp_dx, warp_dy;
|
||||
static warp_mesh_t * * warp_mesh = NULL;
|
||||
static warp_mesh_t **warp_mesh = NULL;
|
||||
|
||||
static Mix_Chunk * warp_snd[NUM_TOOLS];
|
||||
static Mix_Chunk *warp_snd[NUM_TOOLS];
|
||||
|
||||
int warp_init(magic_api * api, Uint32 disabled_features);
|
||||
Uint32 warp_api_version(void);
|
||||
|
|
@ -80,18 +82,18 @@ char *warp_get_description(magic_api * api, int which, int mode);
|
|||
static void warp_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
|
||||
void warp_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 warp_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 warp_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 warp_shutdown(magic_api * api);
|
||||
void warp_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 warp_requires_colors(magic_api * api, int which);
|
||||
void warp_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void warp_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
|
@ -99,7 +101,7 @@ int warp_modes(magic_api * api, int which);
|
|||
Uint8 warp_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 warp_default_size(magic_api * api, int which, int mode);
|
||||
void warp_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 warp_api_version(void)
|
||||
|
|
@ -113,7 +115,8 @@ int warp_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
int i;
|
||||
char fname[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, warp_snd_fnames[i]);
|
||||
warp_snd[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
|
@ -151,12 +154,12 @@ int warp_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
|||
// Return our descriptions, localized:
|
||||
char *warp_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Warp"))); // FIXME
|
||||
return (strdup(gettext_noop("Warp"))); // FIXME
|
||||
}
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void warp_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)
|
||||
{
|
||||
int xx, yy;
|
||||
float stroke_len;
|
||||
|
|
@ -168,53 +171,55 @@ void warp_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
return;
|
||||
|
||||
stroke_len = sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y));
|
||||
warp_dx = (float) (x - ox) / stroke_len;
|
||||
warp_dy = (float) (y - oy) / stroke_len;
|
||||
warp_dx = (float)(x - ox) / stroke_len;
|
||||
warp_dy = (float)(y - oy) / stroke_len;
|
||||
|
||||
api->line(api, which, canvas, last, ox, oy, x, y, 1, warp_linecb);
|
||||
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
|
||||
for (yy = 0; yy < warp_mesh_h - 1; yy++) {
|
||||
for (xx = 0; xx < warp_mesh_w - 1; xx++) {
|
||||
for (yy = 0; yy < warp_mesh_h - 1; yy++)
|
||||
{
|
||||
for (xx = 0; xx < warp_mesh_w - 1; xx++)
|
||||
{
|
||||
/* FIXME: Just crib perspective_preview() from perspective.c? */
|
||||
/*
|
||||
Sint16 pts_x[4];
|
||||
Sint16 pts_y[4];
|
||||
Sint16 pts_x[4];
|
||||
Sint16 pts_y[4];
|
||||
|
||||
pts_x[0] = (Sint16) warp_mesh[yy][xx].pt_x;
|
||||
pts_y[0] = (Sint16) warp_mesh[yy][xx].pt_y;
|
||||
pts_x[1] = (Sint16) warp_mesh[yy][xx + 1].pt_x;
|
||||
pts_y[1] = (Sint16) warp_mesh[yy][xx + 1].pt_y;
|
||||
pts_x[2] = (Sint16) warp_mesh[yy + 1][xx].pt_x;
|
||||
pts_y[2] = (Sint16) warp_mesh[yy + 1][xx].pt_y;
|
||||
pts_x[3] = (Sint16) warp_mesh[yy + 1][xx + 1].pt_x;
|
||||
pts_y[3] = (Sint16) warp_mesh[yy + 1][xx + 1].pt_y;
|
||||
pts_x[0] = (Sint16) warp_mesh[yy][xx].pt_x;
|
||||
pts_y[0] = (Sint16) warp_mesh[yy][xx].pt_y;
|
||||
pts_x[1] = (Sint16) warp_mesh[yy][xx + 1].pt_x;
|
||||
pts_y[1] = (Sint16) warp_mesh[yy][xx + 1].pt_y;
|
||||
pts_x[2] = (Sint16) warp_mesh[yy + 1][xx].pt_x;
|
||||
pts_y[2] = (Sint16) warp_mesh[yy + 1][xx].pt_y;
|
||||
pts_x[3] = (Sint16) warp_mesh[yy + 1][xx + 1].pt_x;
|
||||
pts_y[3] = (Sint16) warp_mesh[yy + 1][xx + 1].pt_y;
|
||||
|
||||
filledPolygonColor(canvas, pts_x, pts_y, 4, api->getpixel(last, warp_mesh[yy][xx].scr_x, warp_mesh[yy][xx].scr_y));
|
||||
*/
|
||||
filledPolygonColor(canvas, pts_x, pts_y, 4, api->getpixel(last, warp_mesh[yy][xx].scr_x, warp_mesh[yy][xx].scr_y));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (ox > x) {
|
||||
int tmp;
|
||||
tmp = ox;
|
||||
ox = x;
|
||||
x = tmp;
|
||||
}
|
||||
if (oy > y) {
|
||||
int tmp;
|
||||
tmp = oy;
|
||||
oy = x;
|
||||
y = tmp;
|
||||
}
|
||||
if (ox > x) {
|
||||
int tmp;
|
||||
tmp = ox;
|
||||
ox = x;
|
||||
x = tmp;
|
||||
}
|
||||
if (oy > y) {
|
||||
int tmp;
|
||||
tmp = oy;
|
||||
oy = x;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
update_rect->x = x - warp_radius;
|
||||
update_rect->y = y - warp_radius;
|
||||
update_rect->w = warp_radius * 2;
|
||||
update_rect->h = warp_radius * 2;
|
||||
*/
|
||||
update_rect->x = x - warp_radius;
|
||||
update_rect->y = y - warp_radius;
|
||||
update_rect->w = warp_radius * 2;
|
||||
update_rect->h = warp_radius * 2;
|
||||
*/
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -224,18 +229,22 @@ void warp_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
api->playsound(warp_snd[which], (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
||||
static void warp_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y) {
|
||||
static void warp_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y)
|
||||
{
|
||||
float intensity;
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int mx, my;
|
||||
float dx, dy;
|
||||
|
||||
for (my = 0; my < warp_mesh_h; my++) {
|
||||
for (mx = 0; mx < warp_mesh_w; mx++) {
|
||||
if (api->in_circle(warp_mesh[my][mx].pt_x - x, warp_mesh[my][mx].pt_y - y, warp_radius)) {
|
||||
dx = warp_mesh[my][mx].pt_x - (float) x;
|
||||
dy = warp_mesh[my][mx].pt_y - (float) y;
|
||||
intensity = ((float) warp_radius - sqrt(dx * dx + dy * dy)) / (float) warp_radius;
|
||||
for (my = 0; my < warp_mesh_h; my++)
|
||||
{
|
||||
for (mx = 0; mx < warp_mesh_w; mx++)
|
||||
{
|
||||
if (api->in_circle(warp_mesh[my][mx].pt_x - x, warp_mesh[my][mx].pt_y - y, warp_radius))
|
||||
{
|
||||
dx = warp_mesh[my][mx].pt_x - (float)x;
|
||||
dy = warp_mesh[my][mx].pt_y - (float)y;
|
||||
intensity = ((float)warp_radius - sqrt(dx * dx + dy * dy)) / (float)warp_radius;
|
||||
|
||||
warp_mesh[my][mx].pt_x += (warp_dx * intensity);
|
||||
warp_mesh[my][mx].pt_y += (warp_dy * intensity);
|
||||
|
|
@ -247,7 +256,7 @@ static void warp_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface
|
|||
|
||||
// Affect the canvas on click:
|
||||
void warp_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 (warp_mesh == NULL)
|
||||
return;
|
||||
|
|
@ -258,10 +267,10 @@ void warp_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void warp_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -270,16 +279,17 @@ void warp_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
if (warp_snd[i] != NULL)
|
||||
Mix_FreeChunk(warp_snd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void warp_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -289,29 +299,34 @@ int warp_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
}
|
||||
|
||||
void warp_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)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
warp_mesh_w = (canvas->w / WARP_MESH_RES);
|
||||
warp_mesh_h = (canvas->h / WARP_MESH_RES);
|
||||
warp_mesh = (warp_mesh_t * *) malloc(sizeof(warp_mesh_t *) * warp_mesh_h);
|
||||
memset(warp_mesh, (int) NULL, sizeof(warp_mesh_t *) * warp_mesh_h);
|
||||
warp_mesh = (warp_mesh_t * *)malloc(sizeof(warp_mesh_t *) * warp_mesh_h);
|
||||
memset(warp_mesh, (int)NULL, sizeof(warp_mesh_t *) * warp_mesh_h);
|
||||
|
||||
if (warp_mesh == NULL) {
|
||||
if (warp_mesh == NULL)
|
||||
{
|
||||
fprintf(stderr, "warp cannot allocate warp_mesh!\n");
|
||||
return;
|
||||
}
|
||||
for (y = 0; y < warp_mesh_h; y++) {
|
||||
for (y = 0; y < warp_mesh_h; y++)
|
||||
{
|
||||
warp_mesh[y] = (warp_mesh_t *) malloc(sizeof(warp_mesh_t) * warp_mesh_w);
|
||||
if (warp_mesh[y] == NULL) {
|
||||
if (warp_mesh[y] == NULL)
|
||||
{
|
||||
fprintf(stderr, "warp cannot allocate warp_mesh!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (y = 0; y < warp_mesh_h; y++) {
|
||||
for (x = 0; x < warp_mesh_w; x++) {
|
||||
for (y = 0; y < warp_mesh_h; y++)
|
||||
{
|
||||
for (x = 0; x < warp_mesh_w; x++)
|
||||
{
|
||||
warp_mesh[y][x].scr_x = x * WARP_MESH_RES;
|
||||
warp_mesh[y][x].scr_y = y * WARP_MESH_RES;
|
||||
warp_mesh[y][x].pt_x = x * WARP_MESH_RES;
|
||||
|
|
@ -321,17 +336,21 @@ void warp_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void warp_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 y;
|
||||
|
||||
/* FIXME: Crashes! */
|
||||
return;
|
||||
|
||||
if (warp_mesh != NULL) {
|
||||
for (y = 0; y < warp_mesh_h; y++) {
|
||||
if (warp_mesh[y] != NULL) {
|
||||
printf("freeing mesh row %d\n", y); fflush(stdout);
|
||||
if (warp_mesh != NULL)
|
||||
{
|
||||
for (y = 0; y < warp_mesh_h; y++)
|
||||
{
|
||||
if (warp_mesh[y] != NULL)
|
||||
{
|
||||
printf("freeing mesh row %d\n", y);
|
||||
fflush(stdout);
|
||||
free(warp_mesh);
|
||||
warp_mesh[y] = NULL;
|
||||
}
|
||||
|
|
@ -358,8 +377,8 @@ Uint8 warp_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
|
|||
}
|
||||
|
||||
void warp_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)
|
||||
{
|
||||
warp_radius = (size * MAX_WARP_RADIUS) / NUM_WARP_SIZES;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,19 +152,20 @@ int blocks_etc_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
// Return our order
|
||||
int blocks_etc_get_order(int which)
|
||||
{
|
||||
switch (which) {
|
||||
case TOOL_BLOCKS:
|
||||
return 4;
|
||||
break;
|
||||
case TOOL_CHALK:
|
||||
return 5;
|
||||
break;
|
||||
case TOOL_DRIP:
|
||||
return 6;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
switch (which)
|
||||
{
|
||||
case TOOL_BLOCKS:
|
||||
return 4;
|
||||
break;
|
||||
case TOOL_CHALK:
|
||||
return 5;
|
||||
break;
|
||||
case TOOL_DRIP:
|
||||
return 6;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ void checkerboard_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUT
|
|||
checkerboard_b = b;
|
||||
}
|
||||
|
||||
int checkerboard_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
int checkerboard_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED,
|
||||
Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
|
|
|
|||
|
|
@ -100,9 +100,10 @@ int clone_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
if (complexity_level == MAGIC_COMPLEXITY_NOVICE) {
|
||||
if (complexity_level == MAGIC_COMPLEXITY_NOVICE)
|
||||
{
|
||||
/* Clone tool not available in "novice" mode */
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/clone_start.ogg", api->data_directory);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ char *colorsep_descrs[NUM_TOOLS] = {
|
|||
|
||||
char *colorsep_descr_anaglyph_simple =
|
||||
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!");
|
||||
("Click and drag left and right to separate your picture's red and cyan, to make anaglyphs you can view with 3D glasses!");
|
||||
|
||||
Mix_Chunk *snd_effects[NUM_TOOLS];
|
||||
int colorsep_click_x, colorsep_click_y;
|
||||
|
|
@ -62,8 +62,9 @@ int colorsep_complexity;
|
|||
/* 3D Glasses mode (except in Novice complexity setting)
|
||||
offers different variations
|
||||
(Suggested by O'Hare The Rabbit) */
|
||||
enum {
|
||||
COLORSEP_3DGLASS_VARIATION_RED_CYAN, // default; and the only option in Novice complexity
|
||||
enum
|
||||
{
|
||||
COLORSEP_3DGLASS_VARIATION_RED_CYAN, // default; and the only option in Novice complexity
|
||||
COLORSEP_3DGLASS_VARIATION_RED_BLUE,
|
||||
// COLORSEP_3DGLASS_VARIATION_ANACHROME, // dark red / dark blue
|
||||
COLORSEP_3DGLASS_VARIATION_RED_GREEN,
|
||||
|
|
@ -155,9 +156,12 @@ int colorsep_get_order(int which)
|
|||
|
||||
char *colorsep_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == COLORSEP_TOOL_3DGLASSES && colorsep_complexity == MAGIC_COMPLEXITY_NOVICE) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES && colorsep_complexity == MAGIC_COMPLEXITY_NOVICE)
|
||||
{
|
||||
return strdup(colorsep_descr_anaglyph_simple);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return strdup(gettext(colorsep_descrs[which]));
|
||||
}
|
||||
}
|
||||
|
|
@ -254,7 +258,8 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
{
|
||||
r = g = b = 128;
|
||||
|
||||
if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_CYAN) {
|
||||
if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_CYAN)
|
||||
{
|
||||
/* Split red apart from green & blue (cyan) */
|
||||
/* RR GG BB */
|
||||
/* 1 2 2 */
|
||||
|
|
@ -265,7 +270,9 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// cyan
|
||||
g = g2;
|
||||
b = b2;
|
||||
} else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_BLUE) {
|
||||
}
|
||||
else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_BLUE)
|
||||
{
|
||||
/* Split red apart blue */
|
||||
/* RR GG BB */
|
||||
/* 1 12 2 */
|
||||
|
|
@ -286,7 +293,9 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// r = r1 / 2;
|
||||
// g = (g1 + g2 + r1 + b2) / 4;
|
||||
// b = b1 / 2;
|
||||
} else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_GREEN) {
|
||||
}
|
||||
else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_RED_GREEN)
|
||||
{
|
||||
/* Split red apart green */
|
||||
/* RR GG BB */
|
||||
/* 1 2 12 */
|
||||
|
|
@ -299,7 +308,9 @@ void colorsep_apply(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// blue shared
|
||||
b = (b1 + b2) / 2;
|
||||
} else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_MAGENTA_CYAN) {
|
||||
}
|
||||
else if (colorsep_3dglass_variation == COLORSEP_3DGLASS_VARIATION_MAGENTA_CYAN)
|
||||
{
|
||||
/* Split magenta apart from cyan */
|
||||
/* RR GG BB */
|
||||
/* 1 2 12 */
|
||||
|
|
@ -394,11 +405,14 @@ void colorsep_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
|||
|
||||
Uint8 colorsep_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (which == COLORSEP_TOOL_3DGLASSES && colorsep_complexity > MAGIC_COMPLEXITY_NOVICE) {
|
||||
if (which == COLORSEP_TOOL_3DGLASSES && colorsep_complexity > MAGIC_COMPLEXITY_NOVICE)
|
||||
{
|
||||
/* 3D Glasses mode (in all complexity levels except novice)
|
||||
uses (abuses) the size option to change styles */
|
||||
return NUM_COLORSEP_3DGLASS_VARIATIONS;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* All other tools (and 3D Glasses in novice complexity)
|
||||
do not use the size option */
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
/* Use the chosen color for the non-white pixels */
|
||||
TOOL_DITHER_VIA_COLOR,
|
||||
/* Use the image's color (hue/saturation w/ low value) for the non-white pixels */
|
||||
|
|
@ -28,28 +29,30 @@ enum {
|
|||
NUM_TOOLS
|
||||
};
|
||||
|
||||
char * dither_names[NUM_TOOLS] = {
|
||||
char *dither_names[NUM_TOOLS] = {
|
||||
gettext_noop("Dither"),
|
||||
gettext_noop("Dither (Keep Color)"),
|
||||
};
|
||||
|
||||
char * dither_descr[NUM_TOOLS][2] = {
|
||||
char *dither_descr[NUM_TOOLS][2] = {
|
||||
{
|
||||
gettext_noop("Click and drag to replace parts of your image with a dithered pattern of dots in your chosen color."),
|
||||
gettext_noop("Click to replace your entire image with a dithered pattern of dots in your chosen color."),
|
||||
},
|
||||
gettext_noop("Click and drag to replace parts of your image with a dithered pattern of dots in your chosen color."),
|
||||
gettext_noop("Click to replace your entire image with a dithered pattern of dots in your chosen color."),
|
||||
},
|
||||
{
|
||||
gettext_noop("Click and drag to replace parts of your image with a dithered pattern of dots using the picture's original colors."),
|
||||
gettext_noop("Click to replace your entire image with a dithered pattern of dots using the picture's original colors."),
|
||||
},
|
||||
gettext_noop
|
||||
("Click and drag to replace parts of your image with a dithered pattern of dots using the picture's original colors."),
|
||||
gettext_noop
|
||||
("Click to replace your entire image with a dithered pattern of dots using the picture's original colors."),
|
||||
},
|
||||
};
|
||||
|
||||
char * dither_icon_filenames[NUM_TOOLS] = {
|
||||
char *dither_icon_filenames[NUM_TOOLS] = {
|
||||
"dither.png",
|
||||
"dither_keep_color.png",
|
||||
};
|
||||
|
||||
char * dither_snd_filenames[NUM_TOOLS] = {
|
||||
char *dither_snd_filenames[NUM_TOOLS] = {
|
||||
"dither.ogg",
|
||||
"dither_keep_color.ogg",
|
||||
};
|
||||
|
|
@ -63,17 +66,15 @@ Mix_Chunk *snd_effects[NUM_TOOLS];
|
|||
Uint8 dither_sizes[NUM_TOOLS];
|
||||
|
||||
Uint32 dither_white, dither_black, dither_color;
|
||||
Uint8 * dither_touched;
|
||||
float * dither_vals;
|
||||
Uint8 *dither_touched;
|
||||
float *dither_vals;
|
||||
int dither_click_mode;
|
||||
|
||||
|
||||
void dither_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void dither_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void dither_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
Uint32 dither_api_version(void);
|
||||
int dither_init(magic_api * api, Uint8 disabled_features, Uint8 complexity_level);
|
||||
|
|
@ -87,17 +88,13 @@ int dither_requires_colors(magic_api * api, int which);
|
|||
void dither_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void dither_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void dither_set_size(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
Uint8 size, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 size, SDL_Rect * update_rect);
|
||||
void dither_set_color(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void dither_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 dither_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 dither_shutdown(magic_api * api);
|
||||
Uint8 dither_default_size(magic_api * api, int which, int mode);
|
||||
Uint8 dither_accepted_sizes(magic_api * api, int which, int mode);
|
||||
|
|
@ -114,9 +111,9 @@ int dither_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8
|
|||
int i;
|
||||
char filename[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory,
|
||||
dither_snd_filenames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory, dither_snd_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(filename);
|
||||
}
|
||||
|
||||
|
|
@ -138,8 +135,7 @@ SDL_Surface *dither_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char filename[1024];
|
||||
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s",
|
||||
api->data_directory, dither_icon_filenames[which]);
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s", api->data_directory, dither_icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(filename));
|
||||
}
|
||||
|
|
@ -165,9 +161,12 @@ int dither_get_order(int which)
|
|||
|
||||
char *dither_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode)
|
||||
{
|
||||
if (mode == MODE_PAINT) {
|
||||
if (mode == MODE_PAINT)
|
||||
{
|
||||
return strdup(gettext(dither_descr[which][0]));
|
||||
} else /* if (mode == MODE_FULLSCREEN) */ {
|
||||
}
|
||||
else /* if (mode == MODE_FULLSCREEN) */
|
||||
{
|
||||
return strdup(gettext(dither_descr[which][1]));
|
||||
}
|
||||
}
|
||||
|
|
@ -225,8 +224,7 @@ void dither_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
void
|
||||
dither_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 xx, yy;
|
||||
Uint8 r, g, b;
|
||||
|
|
@ -246,7 +244,8 @@ dither_click(magic_api * api, int which, int mode,
|
|||
dither_touched[yy * canvas->w + xx] = 1;
|
||||
|
||||
SDL_GetRGB(api->getpixel(snapshot, xx, yy), snapshot->format, &r, &g, &b);
|
||||
dither_vals[yy * canvas->w + xx] = (api->sRGB_to_linear(r) + api->sRGB_to_linear(g) + api->sRGB_to_linear(b)) / 3.0;
|
||||
dither_vals[yy * canvas->w + xx] =
|
||||
(api->sRGB_to_linear(r) + api->sRGB_to_linear(g) + api->sRGB_to_linear(b)) / 3.0;
|
||||
|
||||
if (xx == 0)
|
||||
{
|
||||
|
|
@ -270,18 +269,14 @@ dither_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
dither_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
int dither_size;
|
||||
|
||||
SDL_LockSurface(snapshot);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot,
|
||||
old_x, old_y, x, y, 1,
|
||||
dither_line_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, old_x, old_y, x, y, 1, dither_line_callback);
|
||||
|
||||
SDL_UnlockSurface(canvas);
|
||||
SDL_UnlockSurface(snapshot);
|
||||
|
|
@ -317,11 +312,10 @@ dither_drag(magic_api * api, int which,
|
|||
* [ . 5 . . ]
|
||||
*/
|
||||
int dither_x_pos[6] = { 1, 2, -1, 0, 1, 0 };
|
||||
int dither_y_pos[6] = { 0, 0, 1, 1, 1, 2 };
|
||||
int dither_y_pos[6] = { 0, 0, 1, 1, 1, 2 };
|
||||
|
||||
void dither_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)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
float val, err, h, s, v;
|
||||
|
|
@ -334,7 +328,8 @@ void dither_release(magic_api * api, int which,
|
|||
if (dither_touched[y * canvas->w + x])
|
||||
{
|
||||
val = dither_vals[y * canvas->w + x];
|
||||
if (val >= 0.5) {
|
||||
if (val >= 0.5)
|
||||
{
|
||||
api->putpixel(canvas, x, y, dither_white);
|
||||
err = val - 1.0;
|
||||
}
|
||||
|
|
@ -383,14 +378,15 @@ void dither_release(magic_api * api, int which,
|
|||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
|
||||
if (dither_click_mode == MODE_PAINT) {
|
||||
if (dither_click_mode == MODE_PAINT)
|
||||
{
|
||||
api->stopsound();
|
||||
}
|
||||
}
|
||||
|
||||
void dither_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
if (r <= 240 || g <= 240 || b <= 240)
|
||||
{
|
||||
|
|
@ -404,15 +400,14 @@ void dither_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
|||
}
|
||||
|
||||
void dither_set_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
dither_sizes[which] = size * DITHER_SIZE_SCALE;
|
||||
}
|
||||
|
||||
|
||||
void dither_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
void dither_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) pointer;
|
||||
int xx, yy, dither_size;
|
||||
|
|
@ -451,7 +446,7 @@ void dither_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
|||
|
||||
|
||||
void dither_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
SDL_Surface * canvas)
|
||||
{
|
||||
if (dither_touched == NULL)
|
||||
{
|
||||
|
|
@ -459,7 +454,7 @@ void dither_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
|
|||
}
|
||||
if (dither_vals == NULL)
|
||||
{
|
||||
dither_vals = (float *) malloc(sizeof(float) * canvas->h * canvas->w);
|
||||
dither_vals = (float *)malloc(sizeof(float) * canvas->h * canvas->w);
|
||||
}
|
||||
|
||||
dither_white = SDL_MapRGB(canvas->format, 255, 255, 255);
|
||||
|
|
@ -467,6 +462,6 @@ void dither_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
|
|||
}
|
||||
|
||||
void dither_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ int foam_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8 c
|
|||
if (foam_7 == NULL || foam_5 == NULL || foam_3 == NULL || foam_1 == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot scale %s\n", fname);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
|
|
|
|||
|
|
@ -163,21 +163,25 @@ int fretwork_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uin
|
|||
fretwork_four_back = IMG_Load(fretwork_images[2]);
|
||||
fretwork_corner_back = IMG_Load(fretwork_images[3]);
|
||||
|
||||
if (fretwork_one == NULL || fretwork_one_back == NULL) {
|
||||
if (fretwork_one == NULL || fretwork_one_back == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[0]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (fretwork_three == NULL || fretwork_three_back == NULL) {
|
||||
if (fretwork_three == NULL || fretwork_three_back == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[1]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (fretwork_four == NULL || fretwork_four_back == NULL) {
|
||||
if (fretwork_four == NULL || fretwork_four_back == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[2]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (fretwork_corner == NULL || fretwork_corner_back == NULL) {
|
||||
if (fretwork_corner == NULL || fretwork_corner_back == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[3]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
img_w = fretwork_one->w;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ static int **glasstile_hit;
|
|||
static int glasstile_hit_xsize;
|
||||
static int glasstile_hit_ysize;
|
||||
|
||||
int glasstile_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED /* FIXME */, Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
int glasstile_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED /* FIXME */ ,
|
||||
Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const char *descs[NUM_TOOLS][2] = {
|
|||
{
|
||||
gettext_noop("Click and drag to turn your drawing into a newspaper."),
|
||||
gettext_noop("Click to turn your drawing into a newspaper."),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Mix_Chunk *snd_effect[NUM_TOOLS];
|
||||
|
|
|
|||
|
|
@ -171,7 +171,8 @@ Uint32 mosaic_shaped_api_version(void)
|
|||
}
|
||||
|
||||
//Load sounds
|
||||
int mosaic_shaped_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
int mosaic_shaped_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED,
|
||||
Uint8 complexity_level ATTRIBUTE_UNUSED)
|
||||
{
|
||||
int i;
|
||||
char fname[1024];
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,32 +19,34 @@
|
|||
#include "SDL_image.h"
|
||||
#include "SDL_mixer.h"
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_POLYFILL,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
char * polyfill_names[NUM_TOOLS] = {
|
||||
char *polyfill_names[NUM_TOOLS] = {
|
||||
gettext_noop("Filled Polygon"),
|
||||
};
|
||||
|
||||
char * polyfill_descr[NUM_TOOLS] = {
|
||||
gettext_noop("Click multiple times in your picture to create a filled polygon. You may drag control points to alter the shape. Click the first point to complete the shape."),
|
||||
char *polyfill_descr[NUM_TOOLS] = {
|
||||
gettext_noop
|
||||
("Click multiple times in your picture to create a filled polygon. You may drag control points to alter the shape. Click the first point to complete the shape."),
|
||||
};
|
||||
|
||||
char * polyfill_icon_filenames[NUM_TOOLS] = {
|
||||
char *polyfill_icon_filenames[NUM_TOOLS] = {
|
||||
"polyfill.png",
|
||||
};
|
||||
|
||||
char * polyfill_snd_filenames[NUM_TOOLS] = {
|
||||
"dither.ogg", // FIXME
|
||||
char *polyfill_snd_filenames[NUM_TOOLS] = {
|
||||
"dither.ogg", // FIXME
|
||||
};
|
||||
|
||||
#define SNAP_SIZE 16
|
||||
|
||||
#define MAX_PTS 17
|
||||
|
||||
SDL_Surface * polyfill_snapshot = NULL;
|
||||
SDL_Surface *polyfill_snapshot = NULL;
|
||||
int polyfill_pt_x[MAX_PTS];
|
||||
int polyfill_pt_y[MAX_PTS];
|
||||
int polyfill_num_pts = 0;
|
||||
|
|
@ -58,11 +60,9 @@ Uint32 polyfill_color, polyfill_color_red, polyfill_color_green;
|
|||
|
||||
|
||||
void polyfill_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void polyfill_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void polyfill_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handles);
|
||||
void polyfill_draw_final(magic_api * api, SDL_Surface * canvas);
|
||||
|
|
@ -78,9 +78,9 @@ int polyfill_init(magic_api * api, Uint8 disabled_features, Uint8 complexity_lev
|
|||
int i;
|
||||
char filename[1024];
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory,
|
||||
polyfill_snd_filenames[i]);
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory, polyfill_snd_filenames[i]);
|
||||
snd_effects[i] = Mix_LoadWAV(filename);
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +97,7 @@ SDL_Surface *polyfill_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char filename[1024];
|
||||
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s",
|
||||
api->data_directory, polyfill_icon_filenames[which]);
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s", api->data_directory, polyfill_icon_filenames[which]);
|
||||
|
||||
return (IMG_Load(filename));
|
||||
}
|
||||
|
|
@ -118,7 +117,7 @@ int polyfill_get_group(magic_api * api, int which)
|
|||
|
||||
int polyfill_get_order(int which)
|
||||
{
|
||||
return 610 + which; // FIXME
|
||||
return 610 + which; // FIXME
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -164,7 +163,8 @@ void polyfill_shutdown(magic_api * api)
|
|||
}
|
||||
}
|
||||
|
||||
if (polyfill_snapshot != NULL) {
|
||||
if (polyfill_snapshot != NULL)
|
||||
{
|
||||
SDL_FreeSurface(polyfill_snapshot);
|
||||
polyfill_snapshot = NULL;
|
||||
}
|
||||
|
|
@ -172,8 +172,7 @@ void polyfill_shutdown(magic_api * api)
|
|||
|
||||
void
|
||||
polyfill_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 i;
|
||||
|
||||
|
|
@ -183,21 +182,24 @@ polyfill_click(magic_api * api, int which, int mode,
|
|||
|
||||
/* See if we're clicking a pre-existing point, to edit it? */
|
||||
polyfill_editing = MAX_PTS;
|
||||
for (i = 0; i < polyfill_num_pts && polyfill_editing == MAX_PTS; i++) {
|
||||
if (abs(x - polyfill_pt_x[i]) <= SNAP_SIZE &&
|
||||
abs(y - polyfill_pt_y[i]) <= SNAP_SIZE) {
|
||||
for (i = 0; i < polyfill_num_pts && polyfill_editing == MAX_PTS; i++)
|
||||
{
|
||||
if (abs(x - polyfill_pt_x[i]) <= SNAP_SIZE && abs(y - polyfill_pt_y[i]) <= SNAP_SIZE)
|
||||
{
|
||||
polyfill_editing = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (polyfill_editing != MAX_PTS) {
|
||||
if (polyfill_editing != MAX_PTS)
|
||||
{
|
||||
printf("Clicked %d to edit it\n", polyfill_editing);
|
||||
polyfill_draw_preview(api, canvas, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Trying to add a new point? */
|
||||
if (polyfill_num_pts < MAX_PTS) {
|
||||
if (polyfill_num_pts < MAX_PTS)
|
||||
{
|
||||
printf("Adding new point %d\n", polyfill_num_pts);
|
||||
|
||||
polyfill_pt_x[polyfill_num_pts] = x;
|
||||
|
|
@ -207,7 +209,9 @@ polyfill_click(magic_api * api, int which, int mode,
|
|||
|
||||
/* Add the new point */
|
||||
polyfill_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Out of points! */
|
||||
printf("Out of space for new points!\n");
|
||||
}
|
||||
|
|
@ -216,9 +220,7 @@ polyfill_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
polyfill_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
polyfill_dragged = 1;
|
||||
|
||||
|
|
@ -236,7 +238,8 @@ polyfill_drag(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
}
|
||||
|
||||
void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handles) {
|
||||
void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handles)
|
||||
{
|
||||
int i, xx, yy, max;
|
||||
SDL_Rect dest;
|
||||
|
||||
|
|
@ -245,24 +248,28 @@ void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handl
|
|||
|
||||
SDL_BlitSurface(polyfill_snapshot, NULL, canvas, NULL);
|
||||
|
||||
for (i = 0; i < polyfill_num_pts - 1; i++) {
|
||||
api->line((void *) api, 0 /* which */, canvas, NULL /* snapshot */,
|
||||
for (i = 0; i < polyfill_num_pts - 1; i++)
|
||||
{
|
||||
api->line((void *)api, 0 /* which */ , canvas, NULL /* snapshot */ ,
|
||||
polyfill_pt_x[i], polyfill_pt_y[i],
|
||||
polyfill_pt_x[i + 1], polyfill_pt_y[i + 1],
|
||||
1,
|
||||
polyfill_line_callback);
|
||||
polyfill_pt_x[i + 1], polyfill_pt_y[i + 1], 1, polyfill_line_callback);
|
||||
}
|
||||
|
||||
if (show_handles) {
|
||||
for (i = 1; i < polyfill_num_pts - 1; i++) {
|
||||
for (yy = -4; yy <= 4; yy++) {
|
||||
for (xx = -4; xx <= 4; xx++) {
|
||||
if (show_handles)
|
||||
{
|
||||
for (i = 1; i < polyfill_num_pts - 1; i++)
|
||||
{
|
||||
for (yy = -4; yy <= 4; yy++)
|
||||
{
|
||||
for (xx = -4; xx <= 4; xx++)
|
||||
{
|
||||
api->xorpixel(canvas, polyfill_pt_x[i] + xx, polyfill_pt_y[i] + yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (polyfill_num_pts > 0) {
|
||||
if (polyfill_num_pts > 0)
|
||||
{
|
||||
dest.x = polyfill_pt_x[0] - SNAP_SIZE;
|
||||
dest.y = polyfill_pt_y[0] - SNAP_SIZE;
|
||||
dest.w = SNAP_SIZE * 2;
|
||||
|
|
@ -270,7 +277,8 @@ void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handl
|
|||
SDL_FillRect(canvas, &dest, polyfill_color_green);
|
||||
}
|
||||
|
||||
if (polyfill_num_pts > 1) {
|
||||
if (polyfill_num_pts > 1)
|
||||
{
|
||||
dest.x = polyfill_pt_x[polyfill_num_pts - 1] - SNAP_SIZE;
|
||||
dest.y = polyfill_pt_y[polyfill_num_pts - 1] - SNAP_SIZE;
|
||||
dest.w = SNAP_SIZE * 2;
|
||||
|
|
@ -284,8 +292,7 @@ void polyfill_draw_preview(magic_api * api, SDL_Surface * canvas, int show_handl
|
|||
|
||||
void
|
||||
polyfill_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 i;
|
||||
|
||||
|
|
@ -300,7 +307,8 @@ polyfill_release(magic_api * api, int which,
|
|||
/* If they simply clicked the first point (without
|
||||
drawing to move it), and there are enough points, consider
|
||||
it a final placement of a new point! */
|
||||
if (polyfill_editing == 0 && polyfill_dragged == 0 && polyfill_num_pts > 2 && polyfill_num_pts < MAX_PTS) {
|
||||
if (polyfill_editing == 0 && polyfill_dragged == 0 && polyfill_num_pts > 2 && polyfill_num_pts < MAX_PTS)
|
||||
{
|
||||
printf("Clicked first point to end polygon!\n");
|
||||
polyfill_pt_x[polyfill_num_pts] = polyfill_pt_x[0];
|
||||
polyfill_pt_y[polyfill_num_pts] = polyfill_pt_y[0];
|
||||
|
|
@ -310,22 +318,23 @@ polyfill_release(magic_api * api, int which,
|
|||
|
||||
/* Moved (or placed) the final spot at the beginning? */
|
||||
if (polyfill_num_pts > 2 &&
|
||||
(
|
||||
(polyfill_editing == polyfill_num_pts - 1 &&
|
||||
((polyfill_editing == polyfill_num_pts - 1 &&
|
||||
abs(x - polyfill_pt_x[0]) <= SNAP_SIZE &&
|
||||
abs(y - polyfill_pt_y[0]) <= SNAP_SIZE) ||
|
||||
(polyfill_editing == 0 &&
|
||||
abs(x - polyfill_pt_x[polyfill_num_pts - 1]) <= SNAP_SIZE &&
|
||||
abs(y - polyfill_pt_y[polyfill_num_pts - 1]) <= SNAP_SIZE)
|
||||
)
|
||||
) {
|
||||
abs(y - polyfill_pt_y[polyfill_num_pts - 1]) <= SNAP_SIZE)))
|
||||
{
|
||||
printf("Ending the polygon!\n");
|
||||
|
||||
/* Snap the points */
|
||||
if (polyfill_editing == 0) {
|
||||
if (polyfill_editing == 0)
|
||||
{
|
||||
polyfill_pt_x[0] = polyfill_pt_x[polyfill_num_pts - 1];
|
||||
polyfill_pt_y[0] = polyfill_pt_y[polyfill_num_pts - 1];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
polyfill_pt_x[polyfill_num_pts - 1] = polyfill_pt_x[0];
|
||||
polyfill_pt_y[polyfill_num_pts - 1] = polyfill_pt_y[0];
|
||||
}
|
||||
|
|
@ -337,26 +346,34 @@ polyfill_release(magic_api * api, int which,
|
|||
|
||||
/* Update snapshot ahead of next polygon */
|
||||
SDL_BlitSurface(canvas, NULL, polyfill_snapshot, NULL);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Did not move (or place) the final spot at the beginning */
|
||||
|
||||
/* Did we stick to points together? We can merge them */
|
||||
if (polyfill_num_pts > 2) {
|
||||
if (polyfill_num_pts > 2)
|
||||
{
|
||||
int to_merge = MAX_PTS;
|
||||
|
||||
for (i = polyfill_editing - 1; i < polyfill_editing + 1; i++) {
|
||||
if (i >= 0 && i < polyfill_num_pts - 1) {
|
||||
for (i = polyfill_editing - 1; i < polyfill_editing + 1; i++)
|
||||
{
|
||||
if (i >= 0 && i < polyfill_num_pts - 1)
|
||||
{
|
||||
if (abs(polyfill_pt_x[i] - polyfill_pt_x[i + 1]) <= SNAP_SIZE &&
|
||||
abs(polyfill_pt_y[i] - polyfill_pt_y[i + 1]) <= SNAP_SIZE) {
|
||||
abs(polyfill_pt_y[i] - polyfill_pt_y[i + 1]) <= SNAP_SIZE)
|
||||
{
|
||||
printf("%d & %d can be merged\n", i, i + 1);
|
||||
to_merge = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (to_merge != MAX_PTS) {
|
||||
if (to_merge != MAX_PTS)
|
||||
{
|
||||
printf("Merging %d with %d\n", to_merge, to_merge + 1);
|
||||
for (i = to_merge; i < polyfill_num_pts - 1; i++) {
|
||||
for (i = to_merge; i < polyfill_num_pts - 1; i++)
|
||||
{
|
||||
polyfill_pt_x[i] = polyfill_pt_x[i + 1];
|
||||
polyfill_pt_y[i] = polyfill_pt_y[i + 1];
|
||||
}
|
||||
|
|
@ -373,22 +390,24 @@ polyfill_release(magic_api * api, int which,
|
|||
update_rect->h = canvas->h;
|
||||
}
|
||||
|
||||
void polyfill_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect)
|
||||
void polyfill_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 r, Uint8 g,
|
||||
Uint8 b, SDL_Rect * update_rect)
|
||||
{
|
||||
polyfill_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||
|
||||
if (polyfill_active) {
|
||||
if (polyfill_active)
|
||||
{
|
||||
polyfill_draw_preview(api, canvas, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void polyfill_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 size, SDL_Rect * update_rect)
|
||||
void polyfill_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 size,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void polyfill_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
void polyfill_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
SDL_Rect dest;
|
||||
|
||||
|
|
@ -403,33 +422,34 @@ void polyfill_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
|
||||
void polyfill_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas)
|
||||
void polyfill_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
|
||||
{
|
||||
polyfill_color_red = SDL_MapRGB(canvas->format, 255, 0, 0);
|
||||
polyfill_color_green = SDL_MapRGB(canvas->format, 0, 255, 0);
|
||||
|
||||
if (polyfill_snapshot == NULL) {
|
||||
if (polyfill_snapshot == NULL)
|
||||
{
|
||||
polyfill_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 (polyfill_snapshot != NULL) {
|
||||
if (polyfill_snapshot != NULL)
|
||||
{
|
||||
SDL_BlitSurface(canvas, NULL, polyfill_snapshot, NULL);
|
||||
}
|
||||
|
||||
polyfill_active = 1;
|
||||
}
|
||||
|
||||
void polyfill_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas)
|
||||
void polyfill_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
|
||||
{
|
||||
polyfill_num_pts = 0;
|
||||
polyfill_editing = MAX_PTS;
|
||||
polyfill_active = 0;
|
||||
|
||||
if (polyfill_snapshot != NULL) {
|
||||
if (polyfill_snapshot != NULL)
|
||||
{
|
||||
SDL_BlitSurface(polyfill_snapshot, NULL, canvas, NULL);
|
||||
}
|
||||
}
|
||||
|
|
@ -437,7 +457,8 @@ void polyfill_switchout(magic_api * api, int which, int mode,
|
|||
/* Based on public-domain code by Darel Rex Finley, 2007
|
||||
https://alienryderflex.com/polygon_fill/
|
||||
*/
|
||||
void polyfill_draw_final(magic_api * api, SDL_Surface * canvas) {
|
||||
void polyfill_draw_final(magic_api * api, SDL_Surface * canvas)
|
||||
{
|
||||
int i, j, ymin, ymax, y, nodes, swap;
|
||||
int nodeX[256];
|
||||
SDL_Rect rect;
|
||||
|
|
@ -446,30 +467,32 @@ void polyfill_draw_final(magic_api * api, SDL_Surface * canvas) {
|
|||
|
||||
ymin = canvas->w;
|
||||
ymax = 0;
|
||||
for (i = 0; i < polyfill_num_pts; i++) {
|
||||
if (polyfill_pt_y[i] < ymin) {
|
||||
for (i = 0; i < polyfill_num_pts; i++)
|
||||
{
|
||||
if (polyfill_pt_y[i] < ymin)
|
||||
{
|
||||
ymin = polyfill_pt_y[i];
|
||||
}
|
||||
if (polyfill_pt_y[i] > ymax) {
|
||||
if (polyfill_pt_y[i] > ymax)
|
||||
{
|
||||
ymax = polyfill_pt_y[i];
|
||||
}
|
||||
}
|
||||
printf("ymin %d -> ymax %d\n", ymin, ymax);
|
||||
|
||||
for (y = ymin; y <= ymax; y++) {
|
||||
for (y = ymin; y <= ymax; y++)
|
||||
{
|
||||
nodes = 0;
|
||||
j = polyfill_num_pts - 2;
|
||||
|
||||
for (i = 0; i < polyfill_num_pts - 1; i++) {
|
||||
if ((polyfill_pt_y[i] < y && polyfill_pt_y[j] >= y) ||
|
||||
(polyfill_pt_y[j] < y && polyfill_pt_y[i] >= y)) {
|
||||
for (i = 0; i < polyfill_num_pts - 1; i++)
|
||||
{
|
||||
if ((polyfill_pt_y[i] < y && polyfill_pt_y[j] >= y) || (polyfill_pt_y[j] < y && polyfill_pt_y[i] >= y))
|
||||
{
|
||||
nodeX[nodes++] = (int)
|
||||
(
|
||||
(double) polyfill_pt_x[i] +
|
||||
(double) (y - polyfill_pt_y[i]) /
|
||||
(double) (polyfill_pt_y[j] - polyfill_pt_y[i]) *
|
||||
(double) (polyfill_pt_x[j] - polyfill_pt_x[i])
|
||||
);
|
||||
((double)polyfill_pt_x[i] +
|
||||
(double)(y - polyfill_pt_y[i]) /
|
||||
(double)(polyfill_pt_y[j] - polyfill_pt_y[i]) * (double)(polyfill_pt_x[j] - polyfill_pt_x[i]));
|
||||
}
|
||||
|
||||
j = i;
|
||||
|
|
@ -477,24 +500,30 @@ void polyfill_draw_final(magic_api * api, SDL_Surface * canvas) {
|
|||
|
||||
// Sort the nodes, via a simple “Bubble” sort.
|
||||
i = 0;
|
||||
while (i < nodes - 1) {
|
||||
if (nodeX[i] > nodeX[i+1]) {
|
||||
while (i < nodes - 1)
|
||||
{
|
||||
if (nodeX[i] > nodeX[i + 1])
|
||||
{
|
||||
swap = nodeX[i];
|
||||
nodeX[i] = nodeX[i + 1];
|
||||
nodeX[i + 1] = swap;
|
||||
if (i)
|
||||
i--;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Fill the pixels between node pairs.
|
||||
for (i = 0; i < nodes; i += 2) {
|
||||
for (i = 0; i < nodes; i += 2)
|
||||
{
|
||||
if (nodeX[i] >= canvas->w)
|
||||
break;
|
||||
|
||||
if (nodeX[i + 1] > 0) {
|
||||
if (nodeX[i + 1] > 0)
|
||||
{
|
||||
if (nodeX[i] < 0)
|
||||
nodeX[i] = 0;
|
||||
if (nodeX[i + 1] > canvas->w - 1)
|
||||
|
|
|
|||
|
|
@ -123,21 +123,25 @@ int rails_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8
|
|||
rails_four = IMG_Load(rails_images[2]);
|
||||
rails_corner = IMG_Load(rails_images[3]);
|
||||
|
||||
if (rails_one == NULL) {
|
||||
if (rails_one == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[0]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (rails_three == NULL) {
|
||||
if (rails_three == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[1]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (rails_four == NULL) {
|
||||
if (rails_four == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[2]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
if (rails_corner == NULL) {
|
||||
if (rails_corner == NULL)
|
||||
{
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[3]);
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
img_w = rails_one->w;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
static int rainbow_radius = 16;
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_RAINBOW,
|
||||
TOOL_SMOOTH_RAINBOW,
|
||||
TOOL_RAINBOW_CYCLE,
|
||||
|
|
@ -158,7 +159,7 @@ char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNU
|
|||
{
|
||||
return (strdup(gettext_noop("Smooth Rainbow")));
|
||||
}
|
||||
else /* TOOL_RAINBOW_CYCLE */
|
||||
else /* TOOL_RAINBOW_CYCLE */
|
||||
{
|
||||
return (strdup(gettext_noop("Rainbow Cycle")));
|
||||
}
|
||||
|
|
@ -223,7 +224,7 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
rainbow_mix = 0;
|
||||
rainbow_color = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
|
||||
}
|
||||
else /* TOOL_RAINBOW_CYCLE */
|
||||
else /* TOOL_RAINBOW_CYCLE */
|
||||
{
|
||||
rainbow_mix = 0;
|
||||
}
|
||||
|
|
@ -273,7 +274,8 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
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)
|
||||
{
|
||||
if (which == TOOL_RAINBOW_CYCLE) {
|
||||
if (which == TOOL_RAINBOW_CYCLE)
|
||||
{
|
||||
rainbow_color = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,18 +58,18 @@ char *ribbon_get_description(magic_api * api, int which, int mode);
|
|||
static void ribbon_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
|
||||
void ribbon_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 ribbon_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 ribbon_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 ribbon_shutdown(magic_api * api);
|
||||
void ribbon_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 ribbon_requires_colors(magic_api * api, int which);
|
||||
void ribbon_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void ribbon_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
|
@ -77,7 +77,7 @@ int ribbon_modes(magic_api * api, int which);
|
|||
Uint8 ribbon_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 ribbon_default_size(magic_api * api, int which, int mode);
|
||||
void ribbon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 ribbon_api_version(void)
|
||||
|
|
@ -139,12 +139,12 @@ char *ribbon_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBU
|
|||
// Do the effect:
|
||||
|
||||
static void ribbon_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 i;
|
||||
|
||||
for (i = - ribbon_radius; i < ribbon_radius; i++)
|
||||
for (i = -ribbon_radius; i < ribbon_radius; i++)
|
||||
{
|
||||
api->putpixel(canvas, x + i, y + i, ribbon_segment_color);
|
||||
api->putpixel(canvas, x + i, y + i + 1, ribbon_segment_color);
|
||||
|
|
@ -154,7 +154,7 @@ static void ribbon_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void ribbon_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)
|
||||
{
|
||||
int pt, pt2, first_click;
|
||||
Uint8 r, g, b;
|
||||
|
|
@ -175,7 +175,8 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
angle = 0.0;
|
||||
|
||||
if (!first_click) {
|
||||
if (!first_click)
|
||||
{
|
||||
double x_angle;
|
||||
|
||||
if (sqrt((x - ox) * (x - ox) + (y - oy) * (y - oy)) > 16)
|
||||
|
|
@ -188,7 +189,8 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
pt = ribbon_tail;
|
||||
do {
|
||||
do
|
||||
{
|
||||
int brt;
|
||||
|
||||
pt2 = ((pt + 1) % ribbon_max_length);
|
||||
|
|
@ -212,7 +214,8 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
ribbon_segment_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, ribbon_linecb);
|
||||
pt = pt2;
|
||||
} while (((pt + 1) % ribbon_max_length) != ribbon_head);
|
||||
}
|
||||
while (((pt + 1) % ribbon_max_length) != ribbon_head);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
|
|
@ -223,17 +226,17 @@ void ribbon_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void ribbon_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)
|
||||
{
|
||||
ribbon_head = ribbon_tail = ribbon_old_angle = 0;
|
||||
ribbon_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
||||
void ribbon_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -246,9 +249,8 @@ void ribbon_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
// Record the color from Tux Paint:
|
||||
void ribbon_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)
|
||||
{
|
||||
ribbon_r = r;
|
||||
ribbon_g = g;
|
||||
|
|
@ -262,12 +264,12 @@ int ribbon_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
|||
}
|
||||
|
||||
void ribbon_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 ribbon_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -288,8 +290,8 @@ Uint8 ribbon_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
|
|||
}
|
||||
|
||||
void ribbon_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)
|
||||
{
|
||||
ribbon_max_length = (size * MAX_LENGTH) / NUM_LENGTH_OPTIONS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ int shift_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED
|
|||
// Return our order
|
||||
int shift_get_order(int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 200;
|
||||
return 200;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
|
|
|
|||
|
|
@ -39,32 +39,33 @@
|
|||
#include "SDL_mixer.h"
|
||||
#include <math.h>
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TOOL_SMOOTH,
|
||||
TOOL_SQUIGGLES,
|
||||
TOOL_LOOPS,
|
||||
NUM_TOOLS
|
||||
};
|
||||
|
||||
char * smooth_icon_fnames[NUM_TOOLS] = {
|
||||
char *smooth_icon_fnames[NUM_TOOLS] = {
|
||||
"smooth.png",
|
||||
"squiggles.png",
|
||||
"loops.png",
|
||||
};
|
||||
|
||||
char * smooth_snd_fnames[NUM_TOOLS] = {
|
||||
char *smooth_snd_fnames[NUM_TOOLS] = {
|
||||
"smooth.ogg",
|
||||
"squiggles.ogg",
|
||||
"loops.ogg",
|
||||
};
|
||||
|
||||
char * smooth_names[NUM_TOOLS] = {
|
||||
char *smooth_names[NUM_TOOLS] = {
|
||||
gettext_noop("Smooth"),
|
||||
gettext_noop("Squiggles"),
|
||||
gettext_noop("Loops"),
|
||||
};
|
||||
|
||||
char * smooth_descrs[NUM_TOOLS] = {
|
||||
char *smooth_descrs[NUM_TOOLS] = {
|
||||
gettext_noop("Click and drag the mouse around to draw in freehand; it will be smoothed when you let go."),
|
||||
gettext_noop("Click and drag the mouse around to draw squiggles."),
|
||||
gettext_noop("Click and drag the mouse around to draw loop-the-loops."),
|
||||
|
|
@ -107,14 +108,14 @@ static void smooth_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surfac
|
|||
static void smooth_squiggle_linecb(void *ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y);
|
||||
void smooth_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 smooth_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 smooth_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 smooth_shutdown(magic_api * api);
|
||||
void smooth_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 smooth_requires_colors(magic_api * api, int which);
|
||||
void smooth_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void smooth_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
|
|
@ -122,7 +123,7 @@ int smooth_modes(magic_api * api, int which);
|
|||
Uint8 smooth_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 smooth_default_size(magic_api * api, int which, int mode);
|
||||
void smooth_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
|
||||
|
||||
|
|
@ -131,7 +132,8 @@ int smooth_init(magic_api * api, Uint8 disabled_features ATTRIBUTE_UNUSED, Uint8
|
|||
char fname[1024];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/%s", api->data_directory, smooth_snd_fnames[i]);
|
||||
smooth_snds[i] = Mix_LoadWAV(fname);
|
||||
}
|
||||
|
|
@ -178,20 +180,19 @@ int smooth_get_order(int which)
|
|||
}
|
||||
|
||||
// Return our description, localized:
|
||||
char *smooth_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which, int mode ATTRIBUTE_UNUSED)
|
||||
char *smooth_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext(smooth_descrs[which])));
|
||||
}
|
||||
|
||||
|
||||
static void smooth_linecb(void *ptr, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
static void smooth_linecb(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
SDL_Rect dest;
|
||||
|
||||
if (which == TOOL_SMOOTH) {
|
||||
if (which == TOOL_SMOOTH)
|
||||
{
|
||||
/* FIXME */
|
||||
dest.x = x;
|
||||
dest.y = y;
|
||||
|
|
@ -199,7 +200,9 @@ static void smooth_linecb(void *ptr, int which,
|
|||
dest.h = smooth_size;
|
||||
|
||||
SDL_FillRect(canvas, &dest, smooth_color);
|
||||
} else if (which == TOOL_LOOPS) {
|
||||
}
|
||||
else if (which == TOOL_LOOPS)
|
||||
{
|
||||
/* FIXME */
|
||||
dest.x = x;
|
||||
dest.y = y;
|
||||
|
|
@ -207,7 +210,9 @@ static void smooth_linecb(void *ptr, int which,
|
|||
dest.h = 2;
|
||||
|
||||
SDL_FillRect(canvas, &dest, smooth_color);
|
||||
} else if (which == TOOL_SQUIGGLES) {
|
||||
}
|
||||
else if (which == TOOL_SQUIGGLES)
|
||||
{
|
||||
api->putpixel(canvas, x, y, smooth_color);
|
||||
}
|
||||
}
|
||||
|
|
@ -223,19 +228,26 @@ static void smooth_squiggle_linecb(void *ptr, int which,
|
|||
xx2 = x + (cos(smooth_squiggle_angle * M_PI / 180.0) * smooth_squiggle_rad);
|
||||
yy2 = y - (sin(smooth_squiggle_angle * M_PI / 180.0) * smooth_squiggle_rad);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
xx1 = xx2;
|
||||
yy1 = yy2;
|
||||
|
||||
if (which == TOOL_LOOPS) {
|
||||
if (which == TOOL_LOOPS)
|
||||
{
|
||||
smooth_squiggle_angle += 5;
|
||||
smooth_squiggle_rad = LOOP_RAD_CALC;
|
||||
} else if (which == TOOL_SQUIGGLES) {
|
||||
}
|
||||
else if (which == TOOL_SQUIGGLES)
|
||||
{
|
||||
smooth_squiggle_angle += (rand() % 5) + 5;
|
||||
smooth_squiggle_rad += ((rand() % 3 * smooth_size) - smooth_size);
|
||||
if (smooth_squiggle_rad < 5) {
|
||||
if (smooth_squiggle_rad < 5)
|
||||
{
|
||||
smooth_squiggle_rad += 5;
|
||||
} else if (smooth_squiggle_rad >= 15 * smooth_size) {
|
||||
}
|
||||
else if (smooth_squiggle_rad >= 15 * smooth_size)
|
||||
{
|
||||
smooth_squiggle_rad -= ((rand() % 10) + 10);
|
||||
}
|
||||
}
|
||||
|
|
@ -246,35 +258,42 @@ static void smooth_squiggle_linecb(void *ptr, int which,
|
|||
api->line((void *)api, which, canvas, last, xx1, yy1, xx2, yy2, 1, smooth_linecb);
|
||||
}
|
||||
|
||||
if (smooth_squiggle_angle >= 360) {
|
||||
if (smooth_squiggle_angle >= 360)
|
||||
{
|
||||
smooth_squiggle_angle -= 360;
|
||||
}
|
||||
}
|
||||
|
||||
void smooth_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 * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (which == TOOL_SMOOTH) {
|
||||
if (num_input_points >= MAX_CTRL_POINTS) {
|
||||
if (which == TOOL_SMOOTH)
|
||||
{
|
||||
if (num_input_points >= MAX_CTRL_POINTS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
smooth_capture = (smooth_capture + 1) % 4;
|
||||
|
||||
if (smooth_capture == 1) {
|
||||
if (smooth_capture == 1)
|
||||
{
|
||||
num_input_points++;
|
||||
smooth_control_points[num_input_points].x = x;
|
||||
smooth_control_points[num_input_points].y = y;
|
||||
}
|
||||
}
|
||||
|
||||
if (which == TOOL_SMOOTH) {
|
||||
if (which == TOOL_SMOOTH)
|
||||
{
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, smooth_linecb);
|
||||
} else if (which == TOOL_SQUIGGLES || which == TOOL_LOOPS) {
|
||||
}
|
||||
else if (which == TOOL_SQUIGGLES || which == TOOL_LOOPS)
|
||||
{
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, smooth_squiggle_linecb);
|
||||
}
|
||||
|
||||
if (which == TOOL_SMOOTH) {
|
||||
if (which == TOOL_SMOOTH)
|
||||
{
|
||||
if (ox > x)
|
||||
{
|
||||
int tmp = ox;
|
||||
|
|
@ -295,13 +314,17 @@ void smooth_drag(magic_api * api, int which,
|
|||
update_rect->y = oy - 16;
|
||||
update_rect->w = (x + 16) - update_rect->x;
|
||||
update_rect->h = (y + 16) - update_rect->y;
|
||||
} else if (which == TOOL_LOOPS) {
|
||||
}
|
||||
else if (which == TOOL_LOOPS)
|
||||
{
|
||||
// FIXME
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
} else if (which == TOOL_SQUIGGLES) {
|
||||
}
|
||||
else if (which == TOOL_SQUIGGLES)
|
||||
{
|
||||
// FIXME
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
|
|
@ -314,19 +337,21 @@ void smooth_drag(magic_api * api, int which,
|
|||
|
||||
void smooth_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)
|
||||
{
|
||||
num_input_points = 0;
|
||||
smooth_control_points[num_input_points].x = x;
|
||||
smooth_control_points[num_input_points].y = y;
|
||||
|
||||
smooth_capture = 0;
|
||||
if (which == TOOL_SQUIGGLES) {
|
||||
if (which == TOOL_SQUIGGLES)
|
||||
{
|
||||
smooth_squiggle_angle = 0;
|
||||
smooth_squiggle_rad = 0;
|
||||
smooth_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
} else if (which == TOOL_LOOPS) {
|
||||
}
|
||||
else if (which == TOOL_LOOPS)
|
||||
{
|
||||
smooth_squiggle_angle = 0;
|
||||
smooth_squiggle_rad = LOOP_RAD_CALC;
|
||||
smooth_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
|
|
@ -335,16 +360,16 @@ void smooth_click(magic_api * api,
|
|||
|
||||
|
||||
void smooth_release(magic_api * api,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
if (which == TOOL_SMOOTH) {
|
||||
if (which == TOOL_SMOOTH)
|
||||
{
|
||||
Point2D *curve;
|
||||
int p, i, n_points;
|
||||
|
||||
for (p = 0; p < 4; p++) {
|
||||
for (p = 0; p < 4; p++)
|
||||
{
|
||||
num_input_points++;
|
||||
smooth_control_points[num_input_points].x = x;
|
||||
smooth_control_points[num_input_points].y = y;
|
||||
|
|
@ -352,22 +377,21 @@ void smooth_release(magic_api * api,
|
|||
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
|
||||
for (p = 0; p < num_input_points - 3; p += 3) {
|
||||
for (p = 0; p < num_input_points - 3; p += 3)
|
||||
{
|
||||
n_points = smooth_dist(smooth_control_points[p + 0].x,
|
||||
smooth_control_points[p + 0].y,
|
||||
smooth_control_points[p + 1].x,
|
||||
smooth_control_points[p + 1].y) +
|
||||
smooth_dist(smooth_control_points[p + 1].x,
|
||||
smooth_control_points[p + 1].y,
|
||||
smooth_control_points[p + 2].x,
|
||||
smooth_control_points[p + 2].y) +
|
||||
smooth_dist(smooth_control_points[p + 2].x,
|
||||
smooth_control_points[p + 2].y,
|
||||
smooth_control_points[p + 3].x,
|
||||
smooth_control_points[p + 3].y);
|
||||
smooth_dist(smooth_control_points[p + 1].x,
|
||||
smooth_control_points[p + 1].y,
|
||||
smooth_control_points[p + 2].x,
|
||||
smooth_control_points[p + 2].y) +
|
||||
smooth_dist(smooth_control_points[p + 2].x,
|
||||
smooth_control_points[p + 2].y, smooth_control_points[p + 3].x, smooth_control_points[p + 3].y);
|
||||
|
||||
if (n_points == 0)
|
||||
continue; // No-op; not any points to plot
|
||||
continue; // No-op; not any points to plot
|
||||
|
||||
|
||||
curve = (Point2D *) malloc(sizeof(Point2D) * n_points);
|
||||
|
|
@ -376,7 +400,8 @@ void smooth_release(magic_api * api,
|
|||
|
||||
for (i = 0; i < n_points - 1; i++)
|
||||
{
|
||||
api->line((void *)api, which, canvas, last, curve[i].x, curve[i].y, curve[i + 1].x, curve[i + 1].y, 1, smooth_linecb);
|
||||
api->line((void *)api, which, canvas, last, curve[i].x, curve[i].y, curve[i + 1].x, curve[i + 1].y, 1,
|
||||
smooth_linecb);
|
||||
}
|
||||
|
||||
free(curve);
|
||||
|
|
@ -397,16 +422,17 @@ void smooth_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_TOOLS; i++) {
|
||||
for (i = 0; i < NUM_TOOLS; i++)
|
||||
{
|
||||
if (smooth_snds[i] != NULL)
|
||||
Mix_FreeChunk(smooth_snds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void smooth_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
smooth_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||
}
|
||||
|
|
@ -487,12 +513,12 @@ static float smooth_dist(float x1, float y1, float x2, float y2)
|
|||
}
|
||||
|
||||
void smooth_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 smooth_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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -513,8 +539,8 @@ Uint8 smooth_default_size(magic_api * api ATTRIBUTE_UNUSED, int which, int mode
|
|||
}
|
||||
|
||||
void smooth_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)
|
||||
{
|
||||
smooth_size = size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,9 +126,9 @@ int smudge_get_group(magic_api * api ATTRIBUTE_UNUSED, int which)
|
|||
int smudge_get_order(int which)
|
||||
{
|
||||
if (which == 0)
|
||||
return 3; /* within MAGIC_TYPE_DISTORTS */
|
||||
return 3; /* within MAGIC_TYPE_DISTORTS */
|
||||
else
|
||||
return 2500; /* within MAGIC_TYPE_PAINTING */
|
||||
return 2500; /* within MAGIC_TYPE_PAINTING */
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
|
|
|
|||
|
|
@ -29,11 +29,9 @@ Uint8 specular_size = 32;
|
|||
|
||||
|
||||
void specular_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect);
|
||||
|
||||
void specular_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void specular_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
|
||||
|
||||
Uint32 specular_api_version(void)
|
||||
|
|
@ -46,8 +44,7 @@ int specular_init(magic_api * api, Uint8 disabled_features, Uint8 complexity_lev
|
|||
int i;
|
||||
char filename[1024];
|
||||
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory,
|
||||
"reflection.ogg"); // FIXME
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory, "reflection.ogg"); // FIXME
|
||||
snd_effect = Mix_LoadWAV(filename);
|
||||
|
||||
return (1);
|
||||
|
|
@ -63,8 +60,7 @@ SDL_Surface *specular_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char filename[1024];
|
||||
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s",
|
||||
api->data_directory, "reflection.png"); // FIXME
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s", api->data_directory, "reflection.png"); // FIXME
|
||||
|
||||
return (IMG_Load(filename));
|
||||
}
|
||||
|
|
@ -90,7 +86,9 @@ int specular_get_order(int which)
|
|||
|
||||
char *specular_get_description(magic_api * api, int which, int mode)
|
||||
{
|
||||
return strdup(gettext("Click and drag on the bottom half of your picture to draw a specular reflection — like a puddle, pond, or lake — that mirrors the top half of your picture."));
|
||||
return
|
||||
strdup(gettext
|
||||
("Click and drag on the bottom half of your picture to draw a specular reflection — like a puddle, pond, or lake — that mirrors the top half of your picture."));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -120,7 +118,8 @@ Uint8 specular_default_size(magic_api * api, int which, int mode)
|
|||
|
||||
void specular_shutdown(magic_api * api)
|
||||
{
|
||||
if (snd_effect != NULL) {
|
||||
if (snd_effect != NULL)
|
||||
{
|
||||
Mix_FreeChunk(snd_effect);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,8 +127,7 @@ void specular_shutdown(magic_api * api)
|
|||
|
||||
void
|
||||
specular_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)
|
||||
{
|
||||
specular_drag(api, which, canvas, snapshot, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -137,16 +135,12 @@ specular_click(magic_api * api, int which, int mode,
|
|||
|
||||
void
|
||||
specular_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int old_x, int old_y, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
SDL_LockSurface(snapshot);
|
||||
SDL_LockSurface(canvas);
|
||||
|
||||
api->line((void *) api, which, canvas, snapshot,
|
||||
old_x, old_y, x, y, 1,
|
||||
specular_line_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, old_x, old_y, x, y, 1, specular_line_callback);
|
||||
|
||||
SDL_UnlockSurface(canvas);
|
||||
SDL_UnlockSurface(snapshot);
|
||||
|
|
@ -176,23 +170,23 @@ specular_drag(magic_api * api, int which,
|
|||
|
||||
void
|
||||
specular_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 specular_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect)
|
||||
void specular_set_color(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 r, Uint8 g,
|
||||
Uint8 b, SDL_Rect * update_rect)
|
||||
{
|
||||
}
|
||||
|
||||
void specular_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 size, SDL_Rect * update_rect)
|
||||
void specular_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot, Uint8 size,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
specular_size = size * 16;
|
||||
}
|
||||
|
||||
|
||||
void specular_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y)
|
||||
void specular_line_callback(void *pointer, int which, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) pointer;
|
||||
int xx, yy, ysrc;
|
||||
|
|
@ -220,12 +214,10 @@ void specular_line_callback(void *pointer, int which, SDL_Surface * canvas,
|
|||
}
|
||||
}
|
||||
|
||||
void specular_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas)
|
||||
void specular_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
|
||||
{
|
||||
}
|
||||
|
||||
void specular_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas)
|
||||
void specular_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ char *swirl_names[NUM_SWIRL_TOOLS] = {
|
|||
};
|
||||
|
||||
int swirls_orders[NUM_SWIRL_TOOLS] = {
|
||||
200, /* within MAGIC_TYPE_DISTORTS */
|
||||
201, /* within MAGIC_TYPE_DISTORTS */
|
||||
1800, /* within MAGIC_TYPE_PAINTING */
|
||||
200, /* within MAGIC_TYPE_DISTORTS */
|
||||
201, /* within MAGIC_TYPE_DISTORTS */
|
||||
1800, /* within MAGIC_TYPE_PAINTING */
|
||||
};
|
||||
|
||||
char *swirl_descriptions[NUM_SWIRL_TOOLS][2] = {
|
||||
|
|
|
|||
|
|
@ -38,31 +38,31 @@ enum
|
|||
Uint8 tp_offers_sizes = 1;
|
||||
|
||||
int num_tools[2] = {
|
||||
6, /* when sizes not available */
|
||||
2, /* when sizes available */
|
||||
6, /* when sizes not available */
|
||||
2, /* when sizes available */
|
||||
};
|
||||
|
||||
int * which_to_tool;
|
||||
int *which_to_tool;
|
||||
|
||||
int which_to_tool_per_size_availability[2][6] = {
|
||||
/* when sizes not available */
|
||||
{
|
||||
TOOL_EPITROCHOID_NOSIZES_1,
|
||||
TOOL_EPITROCHOID_NOSIZES_2,
|
||||
TOOL_EPITROCHOID_NOSIZES_3,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_1,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_2,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_3,
|
||||
},
|
||||
TOOL_EPITROCHOID_NOSIZES_1,
|
||||
TOOL_EPITROCHOID_NOSIZES_2,
|
||||
TOOL_EPITROCHOID_NOSIZES_3,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_1,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_2,
|
||||
TOOL_HYPOTROCHOID_NOSIZES_3,
|
||||
},
|
||||
/* when sizes available */
|
||||
{
|
||||
TOOL_EPITROCHOID_SIZES,
|
||||
TOOL_HYPOTROCHOID_SIZES,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
},
|
||||
TOOL_EPITROCHOID_SIZES,
|
||||
TOOL_HYPOTROCHOID_SIZES,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
},
|
||||
};
|
||||
|
||||
#define SIZE_WELLINSIDE 0.33
|
||||
|
|
@ -79,26 +79,27 @@ float trochoids_sizes_per_size_setting[NUM_SIZES] = {
|
|||
SIZE_OUTSIDE,
|
||||
SIZE_WELLOUTSIDE,
|
||||
};
|
||||
|
||||
/* Default to "SIZE_EDGE" */
|
||||
#define DEFAULT_SIZE 3
|
||||
|
||||
float trochoids_sizes_per_tool[NUM_TOOLS] = {
|
||||
0, // N/A; size controls available
|
||||
0, // N/A; size controls available
|
||||
SIZE_INSIDE,
|
||||
SIZE_EDGE,
|
||||
SIZE_WELLOUTSIDE,
|
||||
0, // N/A; size controls available
|
||||
0, // N/A; size controls available
|
||||
SIZE_INSIDE,
|
||||
SIZE_EDGE,
|
||||
SIZE_WELLOUTSIDE,
|
||||
};
|
||||
|
||||
const char *icon_filenames[NUM_TOOLS] = {
|
||||
"epitrochoid_edge.png", /* use "edge" variation when sizes are available */
|
||||
"epitrochoid_edge.png", /* use "edge" variation when sizes are available */
|
||||
"epitrochoid_inside.png",
|
||||
"epitrochoid_edge.png",
|
||||
"epitrochoid_outside.png",
|
||||
"hypotrochoid_edge.png", /* use "edge" variation when sizes are available */
|
||||
"hypotrochoid_edge.png", /* use "edge" variation when sizes are available */
|
||||
"hypotrochoid_inside.png",
|
||||
"hypotrochoid_edge.png",
|
||||
"hypotrochoid_outside.png",
|
||||
|
|
@ -119,20 +120,29 @@ const char *tool_names[NUM_TOOLS] = {
|
|||
|
||||
const char *tool_descriptions[NUM_TOOLS] = {
|
||||
/* Epitrochoids */
|
||||
gettext_noop("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Use the size option to change where the pen is."),
|
||||
gettext_noop("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is within the rolling circle."),
|
||||
gettext_noop("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is on the edge of the rolling circle."),
|
||||
gettext_noop("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is outside the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Use the size option to change where the pen is."),
|
||||
gettext_noop
|
||||
("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is within the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is on the edge of the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing an epitrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling outside of it. Then pen is outside the rolling circle."),
|
||||
/* Hypotrochoids */
|
||||
gettext_noop("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Use the size option to change where the pen is."),
|
||||
gettext_noop("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is within the rolling circle."),
|
||||
gettext_noop("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is on the edge of the rolling circle."),
|
||||
gettext_noop("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is outside the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Use the size option to change where the pen is."),
|
||||
gettext_noop
|
||||
("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is within the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is on the edge of the rolling circle."),
|
||||
gettext_noop
|
||||
("Click to start drawing a hypotrochoid. Drag left/right to change the size of the fixed circle, and up/down to change the size of the circle rolling inside it. Then pen is outside the rolling circle."),
|
||||
};
|
||||
|
||||
|
||||
/* Sound effects (same for everyone) */
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SND_DRAG,
|
||||
SND_RELEASE_EPITROCHOID,
|
||||
SND_RELEASE_HYPOTROCHOID,
|
||||
|
|
@ -167,33 +177,23 @@ Uint8 trochoids_accepted_sizes(magic_api * api, int which, int mode);
|
|||
Uint8 trochoids_default_size(magic_api * api, int which, int mode);
|
||||
void trochoids_shutdown(magic_api * api);
|
||||
void trochoids_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 trochoids_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int old_x, int old_y, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void trochoids_work(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int x, int y, SDL_Rect * update_rect, int guides);
|
||||
int old_x, int old_y, int x, int y, SDL_Rect * update_rect);
|
||||
void trochoids_work(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect, int guides);
|
||||
void trochoids_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 trochoids_sound(magic_api * api, int snd_idx, int x, int y);
|
||||
void trochoids_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * snapshot, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
void trochoids_set_size(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
Uint8 size, SDL_Rect * update_rect);
|
||||
void trochoids_line_callback(void *pointer, int tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void trochoids_xorline_callback(void *pointer, int tool, SDL_Surface * canvas,
|
||||
SDL_Surface * snapshot, int x, int y);
|
||||
void trochoids_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void trochoids_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void trochoids_line_callback(void *pointer, int tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void trochoids_xorline_callback(void *pointer, int tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||
void trochoids_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void trochoids_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int calc_lcm(int a, int b);
|
||||
|
||||
|
||||
|
|
@ -208,13 +208,17 @@ int trochoids_init(magic_api * api, Uint8 disabled_features, Uint8 complexity_le
|
|||
int i;
|
||||
char filename[1024];
|
||||
|
||||
for (i = 0; i < NUM_SNDS; i++) {
|
||||
for (i = 0; i < NUM_SNDS; i++)
|
||||
{
|
||||
sound_effects[i] = NULL;
|
||||
}
|
||||
|
||||
if (disabled_features & MAGIC_FEATURE_SIZE) {
|
||||
if (disabled_features & MAGIC_FEATURE_SIZE)
|
||||
{
|
||||
tp_offers_sizes = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tp_offers_sizes = 1;
|
||||
}
|
||||
|
||||
|
|
@ -222,8 +226,7 @@ int trochoids_init(magic_api * api, Uint8 disabled_features, Uint8 complexity_le
|
|||
|
||||
for (i = 0; i < NUM_SNDS; i++)
|
||||
{
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory,
|
||||
sound_filenames[i]);
|
||||
snprintf(filename, sizeof(filename), "%ssounds/magic/%s", api->data_directory, sound_filenames[i]);
|
||||
sound_effects[i] = Mix_LoadWAV(filename);
|
||||
}
|
||||
|
||||
|
|
@ -241,8 +244,7 @@ SDL_Surface *trochoids_get_icon(magic_api * api, int which)
|
|||
{
|
||||
char filename[1024];
|
||||
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s",
|
||||
api->data_directory, icon_filenames[which_to_tool[which]]);
|
||||
snprintf(filename, sizeof(filename), "%simages/magic/%s", api->data_directory, icon_filenames[which_to_tool[which]]);
|
||||
|
||||
return (IMG_Load(filename));
|
||||
}
|
||||
|
|
@ -289,8 +291,7 @@ Uint8 trochoids_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRI
|
|||
}
|
||||
|
||||
|
||||
Uint8 trochoids_default_size(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
Uint8 trochoids_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return DEFAULT_SIZE;
|
||||
}
|
||||
|
|
@ -300,8 +301,10 @@ void trochoids_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_SNDS; i++) {
|
||||
if (sound_effects[i] != NULL) {
|
||||
for (i = 0; i < NUM_SNDS; i++)
|
||||
{
|
||||
if (sound_effects[i] != NULL)
|
||||
{
|
||||
Mix_FreeChunk(sound_effects[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -309,8 +312,7 @@ void trochoids_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
|
||||
|
||||
void trochoids_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)
|
||||
{
|
||||
trochoids_x = x;
|
||||
trochoids_y = y;
|
||||
|
|
@ -322,8 +324,7 @@ void trochoids_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
/* Affect the canvas on drag: */
|
||||
void trochoids_drag(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int old_x ATTRIBUTE_UNUSED, int old_y ATTRIBUTE_UNUSED,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
int old_x ATTRIBUTE_UNUSED, int old_y ATTRIBUTE_UNUSED, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
dragged = 1;
|
||||
trochoids_work(api, which, canvas, snapshot, x, y, update_rect, 1);
|
||||
|
|
@ -331,8 +332,8 @@ void trochoids_drag(magic_api * api, int which,
|
|||
}
|
||||
|
||||
void trochoids_work(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
||||
int x, int y, SDL_Rect * update_rect, int guides) {
|
||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect, int guides)
|
||||
{
|
||||
int R, r, d, LCM;
|
||||
int px, py, px2, py2;
|
||||
float a, r_ratio, size;
|
||||
|
|
@ -342,7 +343,8 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
/* Drag left/right to change radius of stator (fixed circle) */
|
||||
R = abs(trochoids_x - x);
|
||||
if (R < 20) {
|
||||
if (R < 20)
|
||||
{
|
||||
R = 20;
|
||||
}
|
||||
|
||||
|
|
@ -350,7 +352,8 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
/* Drag down to increase radius of rotator (rolling circle) */
|
||||
r = abs(y - trochoids_y);
|
||||
if (r < 10) {
|
||||
if (r < 10)
|
||||
{
|
||||
r = 10;
|
||||
}
|
||||
|
||||
|
|
@ -358,25 +361,31 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
if (which == TOOL_HYPOTROCHOID_SIZES ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_1 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_3) {
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3)
|
||||
{
|
||||
/* Hypotrochoid */
|
||||
if (R == r) {
|
||||
if (R == r)
|
||||
{
|
||||
r += 10;
|
||||
}
|
||||
|
||||
r_ratio = (float) (R - r) / (float) r;
|
||||
} else {
|
||||
r_ratio = (float)(R - r) / (float)r;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Epitrochoid */
|
||||
r_ratio = (float) (R + r) / (float) r;
|
||||
r_ratio = (float)(R + r) / (float)r;
|
||||
}
|
||||
|
||||
/* Size option (or use of alternate tools, if --nomagicsizes)
|
||||
determines the distance from the center of the rotator
|
||||
that the pen draws */
|
||||
if (tp_offers_sizes) {
|
||||
if (tp_offers_sizes)
|
||||
{
|
||||
size = trochoids_sizes_per_size_setting[trochoids_size];
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
size = trochoids_sizes_per_tool[which];
|
||||
}
|
||||
d = r * size;
|
||||
|
|
@ -394,19 +403,22 @@ void trochoids_work(magic_api * api, int which,
|
|||
/* Draw the lines */
|
||||
LCM = calc_lcm(r, R);
|
||||
|
||||
for (a = 0; a < 360.0 * (float) (LCM / R); a++) {
|
||||
for (a = 0; a < 360.0 * (float)(LCM / R); a++)
|
||||
{
|
||||
float a2 = (a + 1);
|
||||
|
||||
if (which == TOOL_HYPOTROCHOID_SIZES ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_1 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_3) {
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3)
|
||||
{
|
||||
/* Hypotrochoid */
|
||||
px = trochoids_x + (((R - r) * deg_cos(a)) + (d * deg_cos(r_ratio * a)));
|
||||
py = trochoids_y + (((R - r) * deg_sin(a)) - (d * deg_sin(r_ratio * a)));
|
||||
px2 = trochoids_x + (((R - r) * deg_cos((a2))) + (d * deg_cos(r_ratio * a2)));
|
||||
py2 = trochoids_y + (((R - r) * deg_sin((a2))) - (d * deg_sin(r_ratio * a2)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Epitrochoid */
|
||||
px = trochoids_x + (((R + r) * deg_cos(a)) - (d * deg_cos(r_ratio * a)));
|
||||
py = trochoids_y + (((R + r) * deg_sin(a)) - (d * deg_sin(r_ratio * a)));
|
||||
|
|
@ -414,25 +426,29 @@ void trochoids_work(magic_api * api, int which,
|
|||
py2 = trochoids_y + (((R + r) * deg_sin((a2))) - (d * deg_sin(r_ratio * a2)));
|
||||
}
|
||||
|
||||
api->line((void *)api, which, canvas, snapshot, px, py, px2, py2, (20 * (guides && (a >= 360.0))) + 1, trochoids_line_callback);
|
||||
api->line((void *)api, which, canvas, snapshot, px, py, px2, py2, (20 * (guides && (a >= 360.0))) + 1,
|
||||
trochoids_line_callback);
|
||||
}
|
||||
|
||||
if (guides) {
|
||||
if (guides)
|
||||
{
|
||||
int guide_spacing;
|
||||
|
||||
/* When still dragging (before release), draw some "guides",
|
||||
showing the mechanism that would be used to generate the pattern */
|
||||
rotator_anim_a = (int) (atan2(y - trochoids_y, x - trochoids_x) / M_PI * 180.0);
|
||||
rotator_anim_a = (int)(atan2(y - trochoids_y, x - trochoids_x) / M_PI * 180.0);
|
||||
|
||||
/* Stator (fixed circle) */
|
||||
guide_spacing = 360 / R;
|
||||
if (guide_spacing < 2) {
|
||||
if (guide_spacing < 2)
|
||||
{
|
||||
guide_spacing = 2;
|
||||
}
|
||||
|
||||
for (a = 0; a < 360; a = a + guide_spacing) {
|
||||
px = (int) ((float) trochoids_x + ((float) R * deg_cos(a)));
|
||||
py = (int) ((float) trochoids_y - ((float) R * deg_sin(a)));
|
||||
for (a = 0; a < 360; a = a + guide_spacing)
|
||||
{
|
||||
px = (int)((float)trochoids_x + ((float)R * deg_cos(a)));
|
||||
py = (int)((float)trochoids_y - ((float)R * deg_sin(a)));
|
||||
api->putpixel(canvas, px, py, 0);
|
||||
api->putpixel(canvas, px + 1, py, 0xff);
|
||||
api->putpixel(canvas, px, py + 1, 0);
|
||||
|
|
@ -441,22 +457,26 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
/* Rotator (rolling circle) */
|
||||
guide_spacing = 360 / r;
|
||||
if (guide_spacing < 2) {
|
||||
if (guide_spacing < 2)
|
||||
{
|
||||
guide_spacing = 2;
|
||||
}
|
||||
|
||||
for (a = 0; a < 360; a = a + guide_spacing) {
|
||||
for (a = 0; a < 360; a = a + guide_spacing)
|
||||
{
|
||||
if (which == TOOL_HYPOTROCHOID_SIZES ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_1 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_3) {
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3)
|
||||
{
|
||||
/* Hypotrochoid */
|
||||
px = (int) ((float) trochoids_x + ((R - r) * deg_cos(rotator_anim_a)) + ((float) -r * deg_cos(a)));
|
||||
py = (int) ((float) trochoids_y + ((R - r) * deg_sin(rotator_anim_a)) - ((float) -r * deg_sin(a)));
|
||||
} else {
|
||||
px = (int)((float)trochoids_x + ((R - r) * deg_cos(rotator_anim_a)) + ((float)-r * deg_cos(a)));
|
||||
py = (int)((float)trochoids_y + ((R - r) * deg_sin(rotator_anim_a)) - ((float)-r * deg_sin(a)));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Epitrochoid */
|
||||
px = (int) ((float) trochoids_x + ((R + r) * deg_cos(rotator_anim_a)) + ((float) r * deg_cos(a)));
|
||||
py = (int) ((float) trochoids_y + ((R + r) * deg_sin(rotator_anim_a)) - ((float) r * deg_sin(a)));
|
||||
px = (int)((float)trochoids_x + ((R + r) * deg_cos(rotator_anim_a)) + ((float)r * deg_cos(a)));
|
||||
py = (int)((float)trochoids_y + ((R + r) * deg_sin(rotator_anim_a)) - ((float)r * deg_sin(a)));
|
||||
}
|
||||
api->xorpixel(canvas, px, py);
|
||||
api->xorpixel(canvas, px + 1, py);
|
||||
|
|
@ -468,15 +488,17 @@ void trochoids_work(magic_api * api, int which,
|
|||
/* Pen */
|
||||
if (which == TOOL_HYPOTROCHOID_SIZES ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_1 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 ||
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_3) {
|
||||
which == TOOL_HYPOTROCHOID_NOSIZES_2 || which == TOOL_HYPOTROCHOID_NOSIZES_3)
|
||||
{
|
||||
/* Hypotrochoid */
|
||||
px = trochoids_x + (((R - r) * deg_cos(rotator_anim_a)) + (d * deg_cos(360 - rotator_anim_a)));
|
||||
py = trochoids_y + (((R - r) * deg_sin(rotator_anim_a)) - (d * deg_sin(360 - rotator_anim_a)));
|
||||
|
||||
px2 = trochoids_x + (((R - r) * deg_cos(rotator_anim_a)));
|
||||
py2 = trochoids_y + (((R - r) * deg_sin(rotator_anim_a)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Epitrochoid */
|
||||
px = trochoids_x + (((R + r) * deg_cos(rotator_anim_a)) - (d * deg_cos(360 - rotator_anim_a)));
|
||||
py = trochoids_y + (((R + r) * deg_sin(rotator_anim_a)) - (d * deg_sin(360 - rotator_anim_a)));
|
||||
|
|
@ -487,8 +509,10 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
api->line((void *)api, which, canvas, snapshot, px, py, px2, py2, 2, trochoids_line_callback);
|
||||
|
||||
for (yy = -2; yy <= 2; yy++) {
|
||||
for (xx = -2; xx <= 2; xx++) {
|
||||
for (yy = -2; yy <= 2; yy++)
|
||||
{
|
||||
for (xx = -2; xx <= 2; xx++)
|
||||
{
|
||||
api->putpixel(canvas, px + xx, py + yy, trochoids_color);
|
||||
}
|
||||
}
|
||||
|
|
@ -497,8 +521,7 @@ void trochoids_work(magic_api * api, int which,
|
|||
|
||||
|
||||
void trochoids_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 tool, snd_idx;
|
||||
|
||||
|
|
@ -511,11 +534,12 @@ void trochoids_release(magic_api * api, int which,
|
|||
/* Pick which sound to play & play it */
|
||||
tool = which_to_tool[which];
|
||||
if (tool == TOOL_EPITROCHOID_SIZES ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_1 ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_2 ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_3) {
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_1 || tool == TOOL_EPITROCHOID_NOSIZES_2 || tool == TOOL_EPITROCHOID_NOSIZES_3)
|
||||
{
|
||||
snd_idx = SND_RELEASE_EPITROCHOID;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
snd_idx = SND_RELEASE_HYPOTROCHOID;
|
||||
}
|
||||
trochoids_sound(api, snd_idx, x, y);
|
||||
|
|
@ -525,14 +549,16 @@ void trochoids_release(magic_api * api, int which,
|
|||
ignore the (x,y) we received; we want the
|
||||
'default' offset to get a reasonably pleasant
|
||||
shape -- for users who tried clicking w/o dragging */
|
||||
if (dragged == 0) {
|
||||
if (dragged == 0)
|
||||
{
|
||||
if (tool == TOOL_EPITROCHOID_SIZES ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_1 ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_2 ||
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_3) {
|
||||
tool == TOOL_EPITROCHOID_NOSIZES_1 || tool == TOOL_EPITROCHOID_NOSIZES_2 || tool == TOOL_EPITROCHOID_NOSIZES_3)
|
||||
{
|
||||
x = trochoids_x + 50;
|
||||
y = trochoids_y + 20;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
x = trochoids_x + 70;
|
||||
y = trochoids_y + 30;
|
||||
}
|
||||
|
|
@ -546,19 +572,24 @@ void trochoids_release(magic_api * api, int which,
|
|||
/* Play a sound; volume and panning will be based
|
||||
on the size and position of the shape being generated
|
||||
by the user's UI interaction */
|
||||
void trochoids_sound(magic_api * api, int snd_idx, int x, int y) {
|
||||
void trochoids_sound(magic_api * api, int snd_idx, int x, int y)
|
||||
{
|
||||
int R, vol, pan;
|
||||
|
||||
/* Volume based on the radii of the stator (fixed circle)
|
||||
and the rotator (rolling circle), combined; larger = louder */
|
||||
R = abs(trochoids_x - x) + abs(trochoids_y - y);
|
||||
if (R < 20) {
|
||||
if (R < 20)
|
||||
{
|
||||
R = 20;
|
||||
} else if (R > api->canvas_w) {
|
||||
}
|
||||
else if (R > api->canvas_w)
|
||||
{
|
||||
R = api->canvas_w;
|
||||
}
|
||||
vol = (255 * R * 2) / api->canvas_w;
|
||||
if (vol > 255) {
|
||||
if (vol > 255)
|
||||
{
|
||||
vol = 255;
|
||||
}
|
||||
|
||||
|
|
@ -569,26 +600,24 @@ void trochoids_sound(magic_api * api, int snd_idx, int x, int y) {
|
|||
|
||||
|
||||
void trochoids_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * snapshot ATTRIBUTE_UNUSED,
|
||||
Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
trochoids_color = SDL_MapRGB(canvas->format, r, g, b);
|
||||
}
|
||||
|
||||
|
||||
void trochoids_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)
|
||||
{
|
||||
trochoids_size = (size - 1); /* array index is 0-based, but Tux Paint returns between 1...{accepted sizes} */
|
||||
trochoids_size = (size - 1); /* array index is 0-based, but Tux Paint returns between 1...{accepted sizes} */
|
||||
}
|
||||
|
||||
|
||||
void trochoids_line_callback(void *pointer ATTRIBUTE_UNUSED, int 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 *) pointer;
|
||||
|
||||
|
|
@ -596,8 +625,7 @@ void trochoids_line_callback(void *pointer ATTRIBUTE_UNUSED, int tool ATTRIBUTE_
|
|||
}
|
||||
|
||||
void trochoids_xorline_callback(void *pointer ATTRIBUTE_UNUSED, int 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 *) pointer;
|
||||
|
||||
|
|
@ -608,25 +636,30 @@ void trochoids_xorline_callback(void *pointer ATTRIBUTE_UNUSED, int tool ATTRIBU
|
|||
}
|
||||
|
||||
void trochoids_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void trochoids_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int calc_lcm(int a, int b) {
|
||||
int calc_lcm(int a, int b)
|
||||
{
|
||||
int max;
|
||||
|
||||
if (a > b) {
|
||||
if (a > b)
|
||||
{
|
||||
max = a;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
max = b;
|
||||
}
|
||||
|
||||
while ((max % a) != 0 || (max % b) != 0) {
|
||||
while ((max % a) != 0 || (max % b) != 0)
|
||||
{
|
||||
max++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue