Fill antialiasing edges; Not perfect, but improved

Probably can still improve the ratio of
{old pixel's difference to initial color to be replaced}
to {new color being flood-filled}...
This commit is contained in:
Bill Kendrick 2021-03-08 01:36:07 -08:00
parent 866d5190bf
commit f7e9fa2870
2 changed files with 22 additions and 8 deletions

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$
2021.March.7 (0.9.26)
2021.March.8 (0.9.26)
* New Features
------------
* Larger UI buttons
@ -64,7 +64,7 @@ $Id$
* Other Improvements
------------------
* [WIP] Fill tools do a better job at filling around
* Fill tools do a better job at filling around
antialiased edges, and apply some blending.
* Reduce CPU usage by increasing delay in main loop

View file

@ -191,7 +191,7 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
}
px_colr = getpixels[last->format->BytesPerPixel] (last, fillL, y);
putpixels[canvas->format->BytesPerPixel] (canvas, fillL, y, blend(canvas, cur_colr, px_colr, (3.0 - in_line) / 3.0));
putpixels[canvas->format->BytesPerPixel] (canvas, fillL, y, blend(canvas, cur_colr, px_colr, (1.0 - in_line)));
fillL--;
px_colr = getpixels[last->format->BytesPerPixel] (last, fillL, y);
@ -206,9 +206,15 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
}
}
if (touched != NULL && fillL >= 0)
if (fillL >= 0)
{
touched[(y * canvas->w) + fillL] = (255 - ((Uint8) (in_line * 85)));
if (touched != NULL)
{
touched[(y * canvas->w) + fillL] = (255 - ((Uint8) (in_line * 85)));
}
px_colr = getpixels[last->format->BytesPerPixel] (last, fillL, y);
putpixels[canvas->format->BytesPerPixel] (canvas, fillL, y, blend(canvas, cur_colr, px_colr, (1.0 - in_line)));
}
@ -236,8 +242,10 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
if (touched != NULL) {
touched[(y * canvas->w) + fillR] = (255 - ((Uint8) (in_line * 85)));
}
px_colr = getpixels[last->format->BytesPerPixel] (last, fillR, y);
putpixels[canvas->format->BytesPerPixel] (canvas, fillR, y, blend(canvas, cur_colr, px_colr, (3.0 - in_line) / 3.0));
printf("%f\n", in_line);
putpixels[canvas->format->BytesPerPixel] (canvas, fillR, y, blend(canvas, cur_colr, px_colr, (1.0 - in_line)));
fillR++;
px_colr = getpixels[last->format->BytesPerPixel] (last, fillR, y);
@ -252,9 +260,15 @@ void simulate_flood_fill_outside_check(SDL_Surface * screen, SDL_Surface * last,
}
}
if (touched != NULL && fillR < canvas->w)
if (fillR < canvas->w)
{
touched[(y * canvas->w) + fillR] = (255 - ((Uint8) (in_line * 85)));
if (touched != NULL)
{
touched[(y * canvas->w) + fillR] = (255 - ((Uint8) (in_line * 85)));
}
px_colr = getpixels[last->format->BytesPerPixel] (last, fillR, y);
putpixels[canvas->format->BytesPerPixel] (canvas, fillR, y, blend(canvas, cur_colr, px_colr, (1.0 - in_line)));
}
if (fillR > *x2)