Cartoon: Support sizes

Also add forgotten new func prototypes to bloom.c
This commit is contained in:
Bill Kendrick 2023-04-22 11:03:57 -07:00
parent f5a340a152
commit 5120d07dd3
3 changed files with 33 additions and 10 deletions

View file

@ -38,6 +38,7 @@ https://tuxpaint.org/
+ Bloom
+ Blur
+ Bricks
+ Cartoon
+ Clone
+ Confetti
+ Foam

View file

@ -73,6 +73,9 @@ void bloom_switchout(magic_api * api, int which, int mode,
SDL_Surface * canvas);
float luminance(float r, float g, float b);
float change_luminance(float c_in, float l_in, float l_out);
Uint8 bloom_accepted_sizes(magic_api * api, int which, int mode);
Uint8 bloom_default_size(magic_api * api, int which, int mode);
void bloom_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
Uint32 bloom_api_version(void)

View file

@ -39,11 +39,12 @@
static Mix_Chunk *cartoon_snd;
SDL_Surface *result_surf;
static int cartoon_radius = 16;
#define OUTLINE_THRESH 48
/* Local function prototypes: */
int cartoon_init(magic_api * api);
int cartoon_init(magic_api * api, Uint32 disabled_features);
Uint32 cartoon_api_version(void);
int cartoon_get_tool_count(magic_api * api);
SDL_Surface *cartoon_get_icon(magic_api * api, int which);
@ -72,11 +73,13 @@ void cartoon_switchin(magic_api * api, int which, int mode,
void cartoon_switchout(magic_api * api, int which, int mode,
SDL_Surface * canvas);
int cartoon_modes(magic_api * api, int which);
Uint8 cartoon_accepted_sizes(magic_api * api, int which, int mode);
Uint8 cartoon_default_size(magic_api * api, int which, int mode);
void cartoon_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
// No setup required:
int cartoon_init(magic_api * api)
int cartoon_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
{
char fname[1024];
@ -207,11 +210,11 @@ static void do_cartoon(void *ptr, int which ATTRIBUTE_UNUSED,
magic_api *api = (magic_api *) ptr;
int xx, yy;
for (yy = y - 16; yy < y + 16; yy = yy + 1)
for (yy = y - cartoon_radius; yy < y + cartoon_radius; yy = yy + 1)
{
for (xx = x - 16; xx < x + 16; xx = xx + 1)
for (xx = x - cartoon_radius; xx < x + cartoon_radius; xx = xx + 1)
{
if (api->in_circle(xx - x, yy - y, 16))
if (api->in_circle(xx - x, yy - y, cartoon_radius))
{
api->putpixel(canvas, xx, yy, api->getpixel(result_surf, xx, yy));
}
@ -241,10 +244,10 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas,
api->line((void *) api, which, canvas, last, ox, oy, x, y, 1, do_cartoon);
update_rect->x = ox - 16;
update_rect->y = oy - 16;
update_rect->w = (x + 16) - update_rect->x;
update_rect->h = (y + 16) - update_rect->y;
update_rect->x = ox - cartoon_radius;
update_rect->y = oy - cartoon_radius;
update_rect->w = (x + cartoon_radius) - update_rect->x;
update_rect->h = (y + cartoon_radius) - update_rect->y;
api->playsound(cartoon_snd, (x * 255) / canvas->w, 255);
}
@ -356,3 +359,19 @@ int cartoon_modes(magic_api * api ATTRIBUTE_UNUSED,
{
return (MODE_PAINT | MODE_FULLSCREEN);
}
Uint8 cartoon_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return 8;
}
Uint8 cartoon_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return 4;
}
void cartoon_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
cartoon_radius = size * 4;
}