diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 0b6cc7352..31418a006 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -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 diff --git a/magic/magic-docs/en/html/index.html b/magic/magic-docs/en/html/index.html index 701c2fca8..0e3417fa6 100644 --- a/magic/magic-docs/en/html/index.html +++ b/magic/magic-docs/en/html/index.html @@ -58,6 +58,7 @@
  • Sharpen
  • Shift
  • Silhouette
  • +
  • Smooth Rainbow
  • Smudge
  • Snow Ball
  • Snow Flake
  • diff --git a/magic/magic-docs/en/html/rainbow.html b/magic/magic-docs/en/html/rainbow.html index d36ffe13f..9375ccf81 100644 --- a/magic/magic-docs/en/html/rainbow.html +++ b/magic/magic-docs/en/html/rainbow.html @@ -6,4 +6,5 @@

    Tux Paint "Magic" Tool: Rainbow

    By Bill Kendrick <bill@newbreedsoftware.com>

    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

    \ No newline at end of file diff --git a/magic/magic-docs/en/html/smooth_rainbow.html b/magic/magic-docs/en/html/smooth_rainbow.html new file mode 100644 index 000000000..183c50413 --- /dev/null +++ b/magic/magic-docs/en/html/smooth_rainbow.html @@ -0,0 +1,10 @@ + +Tux Paint "Magic" Tool: Smooth Rainbow + + + +

    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

    + \ No newline at end of file diff --git a/magic/magic-docs/en/index.txt b/magic/magic-docs/en/index.txt index 2bae5c024..9811204d2 100644 --- a/magic/magic-docs/en/index.txt +++ b/magic/magic-docs/en/index.txt @@ -54,6 +54,7 @@ * Sharpen * Shift * Silhouette + * Smooth Rainbow * Smudge * Snow Ball * Snow Flake diff --git a/magic/magic-docs/en/rainbow.txt b/magic/magic-docs/en/rainbow.txt index 318b509d1..a6f1cf267 100644 --- a/magic/magic-docs/en/rainbow.txt +++ b/magic/magic-docs/en/rainbow.txt @@ -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 diff --git a/magic/magic-docs/en/smooth_rainbow.txt b/magic/magic-docs/en/smooth_rainbow.txt new file mode 100644 index 000000000..f202e4289 --- /dev/null +++ b/magic/magic-docs/en/smooth_rainbow.txt @@ -0,0 +1,9 @@ + Tux Paint "Magic" Tool: Smooth Rainbow + + By Bill Kendrick + + 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 diff --git a/magic/magic-docs/src/magic-docs.php b/magic/magic-docs/src/magic-docs.php index 560f9b191..804e53293 100644 --- a/magic/magic-docs/src/magic-docs.php +++ b/magic/magic-docs/src/magic-docs.php @@ -5,7 +5,7 @@ individual HTML files for each of them, and an index.html that links to them all. */ /* Bill Kendrick */ -/* 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 — as you move the mouse around, it cycles through a spectrum of colors — 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, diff --git a/magic/src/rainbow.c b/magic/src/rainbow.c index 012270acc..66c17c4fd 100644 --- a/magic/src/rainbow.c +++ b/magic/src/rainbow.c @@ -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);