"Panels" magic tool; convert image to 2x2 repeat

Useful for making 4-panel comics; or repeat multiple times to
create a compound-eye effect.

Closes https://sourceforge.net/p/tuxpaint/feature-requests/204/
This commit is contained in:
Bill Kendrick 2021-09-04 14:28:01 -07:00
parent fed3b80359
commit 8d67915b3e
10 changed files with 93 additions and 12 deletions

View file

@ -8,7 +8,14 @@ http://www.tuxpaint.org/
$Id$
2021.September.2 (0.9.27)
2021.September.4 (0.9.27)
* New Magic Tools:
----------------
* "Panels" - Convert your picture to 4-panel-comic-style
2x2 image, repeating the original. (Repeat for "compound eye"
style effects!)
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/204/)
* Documentation updates
---------------------
* Ensured Tux Paint's built-in help ("tuxpaint --help"),

View file

@ -1,6 +1,6 @@
Creating Tux Paint Magic Tool Plugins
Copyright 2007-2018 by various contributors; see AUTHORS.txt
Copyright 2007-2021 by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/
July 5, 2007 - February 20, 2021

View file

@ -9,7 +9,7 @@ alink="#FF00FF">
<center>
<h1>Creating Tux Paint Magic Tool Plugins</h1>
<p>Copyright 2007-2018 by various contributors; see AUTHORS.txt<br/>
<p>Copyright 2007-2021 by various contributors; see AUTHORS.txt<br/>
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
<p>July 5, 2007 - February 20, 2021</p>

BIN
magic/icons/panels.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

@ -39,6 +39,7 @@
<li><a href="square_mosaic.html">Square Mosaic</a></li>
<li><a href="negative.html">Negative</a></li>
<li><a href="noise.html">Noise</a></li>
<li><a href="panels.html">Panels</a></li>
<li><a href="pattern.html">Pattern</a></li>
<li><a href="perspective.html">Perspective</a></li>
<li><a href="picasso.html">Picasso</a></li>

View file

@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<body><html><head><title>Tux Paint "Magic" Tool: Panels</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#FF0000" alink="#FF00FF">
<h1 align="center">Tux Paint "Magic" Tool: Panels</h1>
<h2 align="center">By Bill Kendrick &lt;<a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a>&gt;</h2>
<p>Shrink the image and repeat it four times in a 2-by-2 grid. Useful for creating 4-panel comics. Can also be used to create a compound-eye effect.</p>
</body></html>

View file

@ -35,6 +35,7 @@
* Square Mosaic
* Negative
* Noise
* Panels
* Pattern
* Perspective
* Picasso

View file

@ -0,0 +1,6 @@
Tux Paint "Magic" Tool: Panels
By Bill Kendrick <bill@newbreedsoftware.com>
Shrink the image and repeat it four times in a 2-by-2 grid. Useful for
creating 4-panel comics. Can also be used to create a compound-eye effect.

View file

@ -221,6 +221,10 @@ $tools = array(
'desc'=>'Add random noise and static to your picture.',
'author'=>$AUTHOR_ANDREWC),
array('name'=>'Panels',
'desc'=>'Shrink the image and repeat it four times in a 2-by-2 grid. Useful for creating 4-panel comics. Can also be used to create a compound-eye effect.',
'author'=>$AUTHOR_KENDRICK),
array('name'=>'Pattern',
'desc'=>'Draws a tiled pattern around the picture.',
'author'=>$AUTHOR_PERE,

View file

@ -8,7 +8,7 @@
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2021 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -27,7 +27,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: August 29, 2019
Last updated: September 4, 2021
$Id$
*/
@ -114,6 +114,7 @@ float top_advc_y, right_advc_y, bottom_advc_y, left_advc_y;
enum
{
TOOL_PERSPECTIVE,
TOOL_PANELS,
TOOL_ZOOM,
perspective_NUM_TOOLS
};
@ -134,28 +135,29 @@ static Mix_Chunk *perspective_snd_effect[perspective_NUM_TOOLS + 1];
const char *perspective_snd_filenames[perspective_NUM_TOOLS + 1] = {
"perspective.ogg",
"zoom_down.ogg", /* TODO: Could use a different sound */
"zoom_up.ogg",
"zoom_down.ogg",
};
const char *perspective_icon_filenames[perspective_NUM_TOOLS] = {
"perspective.png",
"panels.png",
"zoom.png",
};
const char *perspective_names[perspective_NUM_TOOLS] = {
gettext_noop("Perspective"),
gettext_noop("Panels"),
gettext_noop("Zoom"),
};
const char *perspective_descs[perspective_NUM_TOOLS] = {
gettext_noop("Click on the corners and drag where you want to stretch the picture."),
gettext_noop("Click to turn your picture into 2-by-2 panels."),
gettext_noop("Click and drag up to zoom in or drag down to zoom out the picture."),
};
Uint32 perspective_api_version(void)
@ -358,8 +360,56 @@ void perspective_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
old_h = new_h;
}
break;
case TOOL_PANELS:
{
SDL_Surface *scaled_surf;
scaled_surf = api->scale(canvas, canvas->w / 2, canvas->h / 2, 0);
/* Top left */
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = scaled_surf->w;
update_rect->h = scaled_surf->h;
SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect);
/* Top right */
update_rect->x = scaled_surf->w;
update_rect->y = 0;
update_rect->w = scaled_surf->w;
update_rect->h = scaled_surf->h;
SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect);
/* Bottom left */
update_rect->x = 0;
update_rect->y = scaled_surf->h;
update_rect->w = scaled_surf->w;
update_rect->h = scaled_surf->h;
SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect);
/* Bottom right */
update_rect->x = scaled_surf->w;
update_rect->y = scaled_surf->h;
update_rect->w = scaled_surf->w;
update_rect->h = scaled_surf->h;
SDL_BlitSurface(scaled_surf, NULL, canvas, update_rect);
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;
update_rect->h = canvas->h;
SDL_FreeSurface(scaled_surf);
api->playsound(perspective_snd_effect[which], 127, 255);
}
break;
}
if (which != TOOL_PANELS)
{
perspective_drag(api, which, canvas, last, x, y, x, y, update_rect);
}
}
@ -482,7 +532,6 @@ void perspective_preview(magic_api * api, int which ATTRIBUTE_UNUSED,
}
}
// No setup happened:
void perspective_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{
//Clean up sounds
@ -546,10 +595,14 @@ void perspective_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
SDL_FreeSurface(canvas_back);
}
int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
int perspective_modes(magic_api * api ATTRIBUTE_UNUSED, int which)
{
if (which == TOOL_PANELS) {
return (MODE_FULLSCREEN);
} else {
return (MODE_PAINT_WITH_PREVIEW);
}
}
void perspective_line(void *ptr_to_api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
SDL_Surface * snapshot ATTRIBUTE_UNUSED, int x, int y)