"Smooth Rainbow" magic tool (variant of "Rainbow")

Numerous people commented on Twitter that a piece of artwork
("Chromie Squiggle #7583", created in "ArtBlocks") looked like it
was made in Tux Paint.

However, the classic (2002-era) "Rainbow" tool cycled coarsely
through solid colors.  This adds a gradient.
This commit is contained in:
Bill Kendrick 2021-09-22 23:01:26 -07:00
parent 1d5dd8eb9f
commit 8b30a278c2
9 changed files with 73 additions and 10 deletions

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$
2021.September.20 (0.9.27)
2021.September.22 (0.9.27)
* New Magic Tools:
----------------
* "Opposite" -- Change parts of the picture to their complementary
@ -22,6 +22,9 @@ $Id$
style effects!)
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/204/)
* "Smooth Rainbow" - A smooth, gradient variation of the classic
"Rainbow" Magic tool.
* Magic Tool Improvements:
------------------------
* "Halftone" works much better, drawing large overlapping circles

View file

@ -58,6 +58,7 @@
<li><a href="sharpen.html">Sharpen</a></li>
<li><a href="shift.html">Shift</a></li>
<li><a href="silhouette.html">Silhouette</a></li>
<li><a href="smooth_rainbow.html">Smooth Rainbow</a></li>
<li><a href="smudge.html">Smudge</a></li>
<li><a href="snow_ball.html">Snow Ball</a></li>
<li><a href="snow_flake.html">Snow Flake</a></li>

View file

@ -6,4 +6,5 @@
<h1 align="center">Tux Paint "Magic" Tool: Rainbow</h1>
<h2 align="center">By Bill Kendrick &lt;<a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a>&gt;</h2>
<p>This is similar to the paint brush, but as you move the mouse around, it cycles through a spectrum of bright colors.</p>
<p>See also: <a href="smooth_rainbow.html">Smooth Rainbow</a> </p>
</body></html>

View file

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<body><html><head><title>Tux Paint "Magic" Tool: Smooth Rainbow</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: Smooth Rainbow</h1>
<h2 align="center">By Bill Kendrick &lt;<a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a>&gt;</h2>
<p>This is similar to Rainbow magic tool &mdash; as you move the mouse around, it cycles through a spectrum of colors &mdash; except the colors blend smoothly as you draw.</p>
<p>See also: <a href="rainbow.html">Rainbow</a> </p>
</body></html>

View file

@ -54,6 +54,7 @@
* Sharpen
* Shift
* Silhouette
* Smooth Rainbow
* Smudge
* Snow Ball
* Snow Flake

View file

@ -4,3 +4,5 @@
This is similar to the paint brush, but as you move the mouse around, it
cycles through a spectrum of bright colors.
See also: Smooth Rainbow

View file

@ -0,0 +1,9 @@
Tux Paint "Magic" Tool: Smooth Rainbow
By Bill Kendrick <bill@newbreedsoftware.com>
This is similar to Rainbow magic tool — as you move the mouse around, it
cycles through a spectrum of colors — except the colors blend smoothly as
you draw.
See also: Rainbow

View file

@ -5,7 +5,7 @@ individual HTML files for each of them, and an index.html that links to
them all. */
/* Bill Kendrick <bill@newbreedsoftware.com> */
/* Oct. 8, 2009 - September 20, 2021 */
/* Oct. 8, 2009 - September 22, 2021 */
/* Authors of the Magic tools: */
@ -271,7 +271,8 @@ $tools = array(
array('name'=>'Rainbow',
'desc'=>'This is similar to the paint brush, but as you move the mouse around, it cycles through a spectrum of bright colors.',
'author'=>$AUTHOR_KENDRICK),
'author'=>$AUTHOR_KENDRICK,
'see'=>array('Smooth Rainbow')),
array('name'=>'Real Rainbow',
'desc'=>'Draw a transparent arc that looks like a real rainbow.',
@ -304,6 +305,11 @@ $tools = array(
'author'=>$AUTHOR_ANDREWC,
'see'=>array('Edges', 'Emboss')),
array('name'=>'Smooth Rainbow',
'desc'=>'This is similar to Rainbow magic tool &mdash; as you move the mouse around, it cycles through a spectrum of colors &mdash; except the colors blend smoothly as you draw.',
'author'=>$AUTHOR_KENDRICK,
'see'=>array('Rainbow')),
array('name'=>'Smudge',
'desc'=>'This pushes the colors around under the mouse, like finger painting with wet paint.',
'author'=>$AUTHOR_ALBERT,

View file

@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: September 21, 2021
Last updated: September 22, 2021
$Id$
*/
@ -63,7 +63,9 @@ static const int rainbow_hexes[NUM_RAINBOW_COLORS][3] = {
{255, 0, 64}
};
static int rainbow_color;
#define MIX_MAX 32
static int rainbow_color, rainbow_mix;
static Uint32 rainbow_rgb;
static Mix_Chunk *rainbow_snd;
@ -105,6 +107,7 @@ int rainbow_init(magic_api * api)
rainbow_color = 0;
rainbow_mix = 0;
snprintf(fname, sizeof(fname), "%s/sounds/magic/rainbow.wav", api->data_directory);
rainbow_snd = Mix_LoadWAV(fname);
@ -115,7 +118,7 @@ int rainbow_init(magic_api * api)
// We have multiple tools:
int rainbow_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
{
return (1);
return (2);
}
// Load our icons:
@ -131,7 +134,11 @@ SDL_Surface *rainbow_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
// Return our names, localized:
char *rainbow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return (strdup(gettext_noop("Rainbow")));
if (which == 0) {
return (strdup(gettext_noop("Rainbow")));
} else {
return (strdup(gettext_noop("Smooth Rainbow")));
}
}
// Return our group:
@ -170,10 +177,33 @@ static void rainbow_linecb(void *ptr, int which ATTRIBUTE_UNUSED,
void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
{
rainbow_color = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
Uint8 r1, g1, b1, r2, g2, b2;
int rc_tmp;
if (which == 1) {
rainbow_mix += 1;
if (rainbow_mix > MIX_MAX) {
rainbow_mix = 0;
rainbow_color = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
}
} else {
rainbow_mix = 0;
rainbow_color = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
}
r1 = rainbow_hexes[rainbow_color][0];
g1 = rainbow_hexes[rainbow_color][1];
b1 = rainbow_hexes[rainbow_color][2];
rc_tmp = (rainbow_color + 1) % NUM_RAINBOW_COLORS;
r2 = rainbow_hexes[rc_tmp][0];
g2 = rainbow_hexes[rc_tmp][1];
b2 = rainbow_hexes[rc_tmp][2];
rainbow_rgb = SDL_MapRGB(canvas->format,
rainbow_hexes[rainbow_color][0],
rainbow_hexes[rainbow_color][1], rainbow_hexes[rainbow_color][2]);
((r1 * (MIX_MAX - rainbow_mix)) + (r2 * rainbow_mix)) / MIX_MAX,
((g1 * (MIX_MAX - rainbow_mix)) + (g2 * rainbow_mix)) / MIX_MAX,
((b1 * (MIX_MAX - rainbow_mix)) + (b2 * rainbow_mix)) / MIX_MAX);
api->line((void *)api, which, canvas, last, ox, oy, x, y, 1, rainbow_linecb);