Added smudge tool

This commit is contained in:
Jacob1 2012-03-14 19:06:37 -04:00
parent 0212099041
commit afbe8cf38e
3 changed files with 27 additions and 2 deletions

View File

@ -101,12 +101,14 @@ static menu_wall colorlist[] =
#define DECO_DRAW 0
#define DECO_LIGHTEN 1
#define DECO_DARKEN 2
#define DECO_SMUDGE 3
static menu_wall toollist[] =
{
{PIXPACK(0xFF0000), "Draw"},
{PIXPACK(0xDDDDDD), "Lighten"},
{PIXPACK(0x111111), "Darken"},
{PIXPACK(0x00FF00), "Smudge"},
};
struct ui_edit

View File

@ -2917,7 +2917,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c
}
void create_decoration(int x, int y, int r, int g, int b, int click, int tool)
{
int rp, tr,tg,tb;
int rp, tr = 0, tg = 0, tb = 0;
rp = pmap[y][x];
if (!rp)
return;
@ -2946,6 +2946,27 @@ void create_decoration(int x, int y, int r, int g, int b, int click, int tool)
tb = (parts[rp>>8].dcolour)&0xFF;
parts[rp>>8].dcolour = ((parts[rp>>8].dcolour&0xFF000000)|(clamp_flt(tr-(tr)*0.02, 0,255)<<16)|(clamp_flt(tg-(tg)*0.02, 0,255)<<8)|clamp_flt(tb-(tb)*0.02, 0,255));
}
else if (tool == DECO_SMUDGE)
{
int rx, ry, num = 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
{
if ((pmap[y+ry][x+rx]&0xFF) && parts[pmap[y+ry][x+rx]>>8].dcolour)
{
num++;
tr += (parts[pmap[y+ry][x+rx]>>8].dcolour>>16)&0xFF;
tg += (parts[pmap[y+ry][x+rx]>>8].dcolour>>8)&0xFF;
tb += (parts[pmap[y+ry][x+rx]>>8].dcolour)&0xFF;
}
}
if (num == 0)
return;
tr = (int)((float)tr/num+.5);
tg = (int)((float)tg/num+.5);
tb = (int)((float)tb/num+.5);
parts[rp>>8].dcolour = ((255<<24)|(tr<<16)|(tg<<8)|tb);
}
}
void line_decorations(int x1, int y1, int x2, int y2, int rx, int ry, int r, int g, int b, int click, int tool)
{

View File

@ -2537,7 +2537,7 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
float overflow = fwidth-(XRES-BARSIZE), location = ((float)XRES-BARSIZE)/((float)(mx-(XRES-BARSIZE)));
xoff = (int)(overflow / location);
}
for (n = 0; n<3; n++)
for (n = 0; n<4; n++)
{
for (a=1; a<15; a++)
{
@ -2547,6 +2547,8 @@ int color_menu_ui(pixel *vid_buf, int i, int *cr, int *cg, int *cb, int b, int b
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour)-10*a, PIXG(toollist[n].colour)-10*a, PIXB(toollist[n].colour)-10*a);
else if (n == DECO_DARKEN)
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour)+10*a, PIXG(toollist[n].colour)+10*a, PIXB(toollist[n].colour)+10*a);
else if (n == DECO_SMUDGE)
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(PIXR(toollist[n].colour), PIXG(toollist[n].colour)-5*c, PIXB(toollist[n].colour)+5*c);
else if (n == DECO_DRAW)
vid_buf[(XRES+BARSIZE)*(y+a)+((x-xoff)+c)] = PIXRGB(*cr,*cg,*cb);
else