Blocks & Chalk can now affect entire image at once
This commit is contained in:
parent
832d812c4a
commit
3fad8fc75b
2 changed files with 44 additions and 26 deletions
|
|
@ -8,7 +8,7 @@ http://www.tuxpaint.org/
|
|||
|
||||
$Id$
|
||||
|
||||
2021.October.26 (0.9.27)
|
||||
2021.October.27 (0.9.27)
|
||||
* New Magic Tools:
|
||||
----------------
|
||||
* "Lightning" - Draws a bolt of lightning striking between
|
||||
|
|
@ -41,7 +41,8 @@ $Id$
|
|||
* "TV" now breaks pixels into red/green/blue components,
|
||||
rather than merely adding a 'scanline' effect.
|
||||
|
||||
* "Halftone" and "Emboss" can now affect the entire image at once.
|
||||
* "Blocks", "Chalk", "Emboss", and "Halftone" can all now affect
|
||||
the entire image at once.
|
||||
|
||||
* Other Improvements:
|
||||
-------------------
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: September 20, 2021
|
||||
Last updated: October 27, 2021
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
|
@ -43,6 +43,8 @@ enum
|
|||
NUM_TOOLS
|
||||
};
|
||||
|
||||
#define EFFECT_REZ 4
|
||||
|
||||
|
||||
/* Our globals: */
|
||||
|
||||
|
|
@ -170,19 +172,19 @@ static void blocks_chalk_drip_linecb(void *ptr, int which, SDL_Surface * canvas,
|
|||
{
|
||||
/* Put x/y on exact grid points: */
|
||||
|
||||
x = (x / 4) * 4;
|
||||
y = (y / 4) * 4;
|
||||
x = (x / EFFECT_REZ) * EFFECT_REZ;
|
||||
y = (y / EFFECT_REZ) * EFFECT_REZ;
|
||||
|
||||
if (!api->touched(x, y))
|
||||
{
|
||||
for (yy = y - 8; yy < y + 8; yy = yy + 4)
|
||||
for (yy = y - (EFFECT_REZ * 2); yy < y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ)
|
||||
{
|
||||
for (xx = x - 8; xx < x + 8; xx = xx + 4)
|
||||
for (xx = x - (EFFECT_REZ * 2); xx < x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ)
|
||||
{
|
||||
Uint32 pix[16];
|
||||
Uint32 pix[(EFFECT_REZ * EFFECT_REZ)];
|
||||
Uint32 p_or = 0;
|
||||
Uint32 p_and = ~0;
|
||||
unsigned i = 16;
|
||||
unsigned i = (EFFECT_REZ * EFFECT_REZ);
|
||||
|
||||
while (i--)
|
||||
{
|
||||
|
|
@ -203,7 +205,7 @@ static void blocks_chalk_drip_linecb(void *ptr, int which, SDL_Surface * canvas,
|
|||
double g_sum = 0.0;
|
||||
double b_sum = 0.0;
|
||||
|
||||
i = 16;
|
||||
i = (EFFECT_REZ * EFFECT_REZ);
|
||||
while (i--)
|
||||
{
|
||||
SDL_GetRGB(pix[i], last->format, &r, &g, &b);
|
||||
|
|
@ -211,17 +213,17 @@ static void blocks_chalk_drip_linecb(void *ptr, int which, SDL_Surface * canvas,
|
|||
g_sum += api->sRGB_to_linear(g);
|
||||
b_sum += api->sRGB_to_linear(b);
|
||||
}
|
||||
r = api->linear_to_sRGB(r_sum / 16.0);
|
||||
g = api->linear_to_sRGB(g_sum / 16.0);
|
||||
b = api->linear_to_sRGB(b_sum / 16.0);
|
||||
r = api->linear_to_sRGB(r_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
g = api->linear_to_sRGB(g_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
b = api->linear_to_sRGB(b_sum / (float) (EFFECT_REZ * EFFECT_REZ));
|
||||
}
|
||||
|
||||
/* Draw block: */
|
||||
|
||||
dest.x = xx;
|
||||
dest.y = yy;
|
||||
dest.w = 4;
|
||||
dest.h = 4;
|
||||
dest.w = EFFECT_REZ;
|
||||
dest.h = EFFECT_REZ;
|
||||
|
||||
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
|
|
@ -230,15 +232,14 @@ static void blocks_chalk_drip_linecb(void *ptr, int which, SDL_Surface * canvas,
|
|||
}
|
||||
else if (which == TOOL_CHALK)
|
||||
{
|
||||
|
||||
for (yy = y - 8; yy <= y + 8; yy = yy + 4)
|
||||
for (yy = y - (EFFECT_REZ * 2); yy <= y + (EFFECT_REZ * 2); yy = yy + EFFECT_REZ)
|
||||
{
|
||||
for (xx = x - 8; xx <= x + 8; xx = xx + 4)
|
||||
for (xx = x - (EFFECT_REZ * 2); xx <= x + (EFFECT_REZ * 2); xx = xx + EFFECT_REZ)
|
||||
{
|
||||
dest.x = xx + ((rand() % 5) - 2);
|
||||
dest.y = yy + ((rand() % 5) - 2);
|
||||
dest.w = (rand() % 4) + 2;
|
||||
dest.h = (rand() % 4) + 2;
|
||||
dest.x = xx + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2));
|
||||
dest.y = yy + ((rand() % (EFFECT_REZ + 1)) - (EFFECT_REZ / 2));
|
||||
dest.w = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2);
|
||||
dest.h = (rand() % EFFECT_REZ) + (EFFECT_REZ / 2);
|
||||
|
||||
colr = api->getpixel(last, clamp(0, xx, canvas->w - 1), clamp(0, yy, canvas->h - 1));
|
||||
SDL_FillRect(canvas, &dest, colr);
|
||||
|
|
@ -297,10 +298,22 @@ void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
|
||||
// Affect the canvas on click:
|
||||
void blocks_chalk_drip_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
void blocks_chalk_drip_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
blocks_chalk_drip_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
if (mode == MODE_PAINT) {
|
||||
blocks_chalk_drip_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
} else /* MODE_FULLSCREEN */ {
|
||||
for (y = 0; y < canvas->h; y += EFFECT_REZ) {
|
||||
for (x = 0; x < canvas->w; x += EFFECT_REZ) {
|
||||
blocks_chalk_drip_linecb(api, which, canvas, last, x, y);
|
||||
}
|
||||
}
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
|
|
@ -342,7 +355,11 @@ void blocks_chalk_drip_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATT
|
|||
{
|
||||
}
|
||||
|
||||
int blocks_chalk_drip_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int blocks_chalk_drip_modes(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
return (MODE_PAINT); /* FIXME - Blocks and Chalk, at least, can also be turned into a full-image effect */
|
||||
if (which == TOOL_BLOCKS || TOOL_CHALK) {
|
||||
return (MODE_PAINT | MODE_FULLSCREEN);
|
||||
} else /* TOOL_DRIP */ {
|
||||
return (MODE_PAINT);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue