WIP: New Magic tool: "Rush"
Like "Zoom", but with a blur effect. (Needs icon, sound effect, documentation.)
This commit is contained in:
parent
94a2b9caf5
commit
60e90d47d9
3 changed files with 101 additions and 11 deletions
|
|
@ -6,11 +6,11 @@ Copyright (c) 2002-2021
|
|||
Various contributors (see below, and CHANGES.txt)
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
June 17, 2002 - April 29, 2022
|
||||
June 17, 2002 - May 6, 2022
|
||||
|
||||
* Design and Coding:
|
||||
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
Lead developer: Bill Kendrick <bill@newbreedsoftware.com>
|
||||
New Breed Software
|
||||
http://www.newbreedsoftware.com/
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
|
|||
http://www.tuxpaint.org/
|
||||
|
||||
|
||||
2022.May.4 (0.9.28)
|
||||
2022.May.6 (0.9.28)
|
||||
* Improvements to "Paint" and "Lines" tools:
|
||||
------------------------------------------
|
||||
* Brush spacing may now be altered within Tux Paint.
|
||||
|
|
@ -128,6 +128,9 @@ http://www.tuxpaint.org/
|
|||
you scale down (similar to "Panels", but with non-integer scaling).
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
||||
* "Rush"; similar to "Zoom", but the effect is blurred.
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
||||
* New Brushes:
|
||||
------------
|
||||
* "Dog" animated directional brush.
|
||||
|
|
|
|||
|
|
@ -7,9 +7,13 @@
|
|||
|
||||
Tux Paint - A simple drawing program for children.
|
||||
|
||||
Credits: Andrew Corcoran <akanewbie@gmail.com>
|
||||
Original Zoom & Perspective
|
||||
By Pere Pujal Carabantes
|
||||
|
||||
Copyright (c) 2002-2022 by Bill Kendrick and others; see AUTHORS.txt
|
||||
Panels, Tile mode of Zoom, and Rush
|
||||
by Bill Kendrick
|
||||
|
||||
Copyright (c) 2014-2022
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
|
|
@ -28,7 +32,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Last updated: May 4, 2022
|
||||
Last updated: May 6, 2022
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
|
@ -119,6 +123,7 @@ enum
|
|||
TOOL_PANELS,
|
||||
TOOL_TILEZOOM,
|
||||
TOOL_ZOOM,
|
||||
TOOL_RUSH,
|
||||
perspective_NUM_TOOLS
|
||||
};
|
||||
|
||||
|
|
@ -141,6 +146,7 @@ const char *perspective_snd_filenames[perspective_NUM_TOOLS + 1] = {
|
|||
"zoom_down.ogg", /* TODO: Could use a different sound */
|
||||
"zoom_up.ogg",
|
||||
"zoom_down.ogg",
|
||||
"zoom_down.ogg", /* TODO: Could use a different sound */
|
||||
};
|
||||
|
||||
const char *perspective_icon_filenames[perspective_NUM_TOOLS] = {
|
||||
|
|
@ -148,6 +154,7 @@ const char *perspective_icon_filenames[perspective_NUM_TOOLS] = {
|
|||
"panels.png",
|
||||
"tilezoom.png",
|
||||
"zoom.png",
|
||||
"zoom.png", /* FIXME */
|
||||
};
|
||||
|
||||
const char *perspective_names[perspective_NUM_TOOLS] = {
|
||||
|
|
@ -155,6 +162,7 @@ const char *perspective_names[perspective_NUM_TOOLS] = {
|
|||
gettext_noop("Panels"),
|
||||
gettext_noop("Tile Zoom"),
|
||||
gettext_noop("Zoom"),
|
||||
gettext_noop("Rush"),
|
||||
};
|
||||
|
||||
const char *perspective_descs[perspective_NUM_TOOLS] = {
|
||||
|
|
@ -165,6 +173,8 @@ const char *perspective_descs[perspective_NUM_TOOLS] = {
|
|||
gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."),
|
||||
|
||||
gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."),
|
||||
|
||||
gettext_noop("Click and drag up to rush in or drag down to rush out the picture."),
|
||||
};
|
||||
|
||||
Uint32 perspective_api_version(void)
|
||||
|
|
@ -288,11 +298,12 @@ void perspective_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
}
|
||||
break;
|
||||
case TOOL_ZOOM:
|
||||
case TOOL_RUSH:
|
||||
case TOOL_TILEZOOM:
|
||||
{
|
||||
int x_distance, y_distance;
|
||||
|
||||
if (which == TOOL_ZOOM)
|
||||
if (which == TOOL_ZOOM || which == TOOL_RUSH)
|
||||
{
|
||||
update_rect->x = update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
|
|
@ -370,6 +381,7 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
|
||||
}
|
||||
break;
|
||||
case TOOL_RUSH:
|
||||
case TOOL_ZOOM:
|
||||
case TOOL_TILEZOOM:
|
||||
{
|
||||
|
|
@ -442,14 +454,89 @@ void perspective_release(magic_api * api, int which,
|
|||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
|
||||
if (which != TOOL_TILEZOOM)
|
||||
if (which == TOOL_ZOOM || which == TOOL_PERSPECTIVE)
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
|
||||
if (which == TOOL_PERSPECTIVE)
|
||||
{
|
||||
perspective_preview(api, which, canvas, last, x, y, update_rect, 0.5);
|
||||
}
|
||||
else
|
||||
else if (which == TOOL_RUSH)
|
||||
{
|
||||
int h1, h2, w, h, hh, x, y, dx1, dy1;
|
||||
Uint8 r1, g1, b1, r2, g2, b2;
|
||||
Uint32 r, g, b;
|
||||
float pct;
|
||||
SDL_Surface *scaled_surf;
|
||||
|
||||
if (new_h == canvas->h || new_h == 0)
|
||||
{
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
return; /* Do nothing */
|
||||
}
|
||||
|
||||
if (new_h > canvas->h * 1.5)
|
||||
new_h = canvas->h * 1.5;
|
||||
|
||||
if (new_h < canvas->h)
|
||||
{
|
||||
h1 = new_h;
|
||||
h2 = canvas->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
h1 = canvas->h;
|
||||
h2 = new_h;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
|
||||
for (h = 0; h < (h2 - h1); h++)
|
||||
{
|
||||
if ((h / 2) % 10 == 0)
|
||||
api->update_progress_bar();
|
||||
|
||||
// if (new_h < canvas->h)
|
||||
hh = h2 - h;
|
||||
// else
|
||||
// hh = new_h + h;
|
||||
|
||||
w = canvas->w * hh / canvas->h;
|
||||
scaled_surf = api->scale(last, w, hh, 0);
|
||||
|
||||
dx1 = (canvas->w - scaled_surf->w) / 2;
|
||||
dy1 = (canvas->h - scaled_surf->h) / 2;
|
||||
|
||||
for (y = 0; y < scaled_surf->h; y++)
|
||||
{
|
||||
if (dy1 + y >= 0 && dy1 + y < canvas->h)
|
||||
{
|
||||
for (x = 0; x < scaled_surf->w; x++)
|
||||
{
|
||||
if (dx1 + x >= 0 && dx1 + x < canvas->w)
|
||||
{
|
||||
SDL_GetRGB(api->getpixel(scaled_surf, x, y), scaled_surf->format, &r1, &g1, &b1);
|
||||
SDL_GetRGB(api->getpixel(canvas, dx1 + x, dy1 + y), canvas->format, &r2, &g2, &b2);
|
||||
pct = (float) ((float) h / ((float) h2 - (float) h1));
|
||||
// if (new_h > canvas->h)
|
||||
// pct = 1.0 - pct;
|
||||
r = api->linear_to_sRGB((api->sRGB_to_linear(r1) * (1.0 - pct)) + (api->sRGB_to_linear(r2) * (pct)));
|
||||
g = api->linear_to_sRGB((api->sRGB_to_linear(g1) * (1.0 - pct)) + (api->sRGB_to_linear(g2) * (pct)));
|
||||
b = api->linear_to_sRGB((api->sRGB_to_linear(b1) * (1.0 - pct)) + (api->sRGB_to_linear(b2) * (pct)));
|
||||
|
||||
api->putpixel(canvas, dx1 + x, dy1 + y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
else /* ZOOM & TILEZOOM */
|
||||
{
|
||||
SDL_Surface *aux_surf;
|
||||
SDL_Surface *scaled_surf;
|
||||
|
|
@ -536,7 +623,7 @@ void perspective_preview(magic_api * api, int which,
|
|||
|
||||
if (which == TOOL_ZOOM)
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, perspective_r, perspective_g, perspective_b));
|
||||
else if (which == TOOL_TILEZOOM)
|
||||
else if (which == TOOL_TILEZOOM || which == TOOL_RUSH)
|
||||
SDL_FillRect(canvas, update_rect, SDL_MapRGB(canvas->format, 128, 128, 128));
|
||||
|
||||
ox_distance = otop_right_x - otop_left_x;
|
||||
|
|
@ -629,7 +716,7 @@ void perspective_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, U
|
|||
// Use colors:
|
||||
int perspective_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||
{
|
||||
if (which == TOOL_PANELS || which == TOOL_TILEZOOM)
|
||||
if (which == TOOL_PANELS || which == TOOL_TILEZOOM || which == TOOL_RUSH)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue