Rainbow / Smooth Rainbow: Support sizes
This commit is contained in:
parent
759880ad61
commit
a3e2f92d74
2 changed files with 33 additions and 10 deletions
|
|
@ -38,6 +38,7 @@ https://tuxpaint.org/
|
|||
+ Kaleidoscope
|
||||
+ Blur
|
||||
+ Googly Eyes
|
||||
+ Rainbow & Smooth Rainbow
|
||||
+ Ripples
|
||||
+ WIP... more!
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: February 12, 2023
|
||||
Last updated: April 19, 2023
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#define NUM_RAINBOW_COLORS 23
|
||||
|
||||
static int rainbow_radius = 16;
|
||||
|
||||
static const int rainbow_hexes[NUM_RAINBOW_COLORS][3] = {
|
||||
{255, 0, 0},
|
||||
{255, 64, 0},
|
||||
|
|
@ -68,7 +70,7 @@ static int rainbow_color, rainbow_mix;
|
|||
static Uint32 rainbow_rgb;
|
||||
static Mix_Chunk *rainbow_snd;
|
||||
|
||||
int rainbow_init(magic_api * api);
|
||||
int rainbow_init(magic_api * api, Uint32 disabled_features);
|
||||
Uint32 rainbow_api_version(void);
|
||||
int rainbow_get_tool_count(magic_api * api);
|
||||
SDL_Surface *rainbow_get_icon(magic_api * api, int which);
|
||||
|
|
@ -100,6 +102,10 @@ void rainbow_switchin(magic_api * api, int which, int mode,
|
|||
void rainbow_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
int rainbow_modes(magic_api * api, int which);
|
||||
Uint8 rainbow_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 rainbow_default_size(magic_api * api, int which, int mode);
|
||||
void rainbow_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
|
||||
|
||||
Uint32 rainbow_api_version(void)
|
||||
{
|
||||
|
|
@ -107,7 +113,7 @@ Uint32 rainbow_api_version(void)
|
|||
}
|
||||
|
||||
// Load our sfx:
|
||||
int rainbow_init(magic_api * api)
|
||||
int rainbow_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
|
|
@ -177,11 +183,11 @@ static void rainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy;
|
||||
|
||||
for (yy = y - 16; yy < y + 16; yy++)
|
||||
for (yy = y - rainbow_radius; yy < y + rainbow_radius; yy++)
|
||||
{
|
||||
for (xx = x - 16; xx < x + 16; xx++)
|
||||
for (xx = x - rainbow_radius; xx < x + rainbow_radius; xx++)
|
||||
{
|
||||
if (api->in_circle(xx - x, yy - y, 16))
|
||||
if (api->in_circle(xx - x, yy - y, rainbow_radius))
|
||||
{
|
||||
api->putpixel(canvas, xx, yy, rainbow_rgb);
|
||||
}
|
||||
|
|
@ -247,10 +253,10 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
y = tmp;
|
||||
}
|
||||
|
||||
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 - rainbow_radius;
|
||||
update_rect->y = oy - rainbow_radius;
|
||||
update_rect->w = (x + rainbow_radius) - update_rect->x;
|
||||
update_rect->h = (y + rainbow_radius) - update_rect->y;
|
||||
|
||||
api->playsound(rainbow_snd, (x * 255) / canvas->w, 255);
|
||||
}
|
||||
|
|
@ -309,3 +315,19 @@ int rainbow_modes(magic_api * api ATTRIBUTE_UNUSED,
|
|||
{
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
|
||||
|
||||
Uint8 rainbow_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
Uint8 rainbow_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
void rainbow_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
rainbow_radius = size * 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue