From 77e346103bb57c7fac46400294156cbb20339c7e Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Thu, 8 Oct 2009 17:17:17 +0000 Subject: [PATCH] Added "Wet Paint" tool. --- docs/CHANGES.txt | 5 ++- magic/magic-docs/html/index.html | 1 + magic/magic-docs/html/smudge.html | 2 +- magic/magic-docs/html/wetpaint.html | 12 ++++++ magic/magic-docs/index.txt | 1 + magic/magic-docs/smudge.txt | 2 +- magic/magic-docs/src/magic-docs.php | 9 ++++- magic/magic-docs/wetpaint.txt | 8 ++++ magic/src/smudge.c | 58 +++++++++++++++++++++++------ 9 files changed, 81 insertions(+), 17 deletions(-) create mode 100644 magic/magic-docs/html/wetpaint.html create mode 100644 magic/magic-docs/wetpaint.txt diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 254df9c3a..d983bca23 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -8,7 +8,7 @@ http://www.tuxpaint.org/ $Id$ -2009.October.7 (0.9.22) +2009.October.8 (0.9.22) * New Tools: ---------- * Label - A tool to add text to a drawing, which can be modified or @@ -32,6 +32,9 @@ $Id$ * ROYGBIV Rainbow - Draw a rainbow arc using solid colors of Red, Orange, Yellow, Green, Blue, Indigo and Violet. + * Wet Paint - Draws a light coat of paint, and smudges at the same time. + (Based on Smudge tool. Requested by gallery artist Angela.) + * Other Improvements: ------------------- * Starter images can be in SVG (Scalable Vector Graphics) format. diff --git a/magic/magic-docs/html/index.html b/magic/magic-docs/html/index.html index 2bd37562d..0569d687b 100644 --- a/magic/magic-docs/html/index.html +++ b/magic/magic-docs/html/index.html @@ -61,5 +61,6 @@
  • Toothpaste
  • Waves
  • Wavelets
  • +
  • Wet Paint
  • Zoom
  • \ No newline at end of file diff --git a/magic/magic-docs/html/smudge.html b/magic/magic-docs/html/smudge.html index 2d06b908b..f8efbc03c 100644 --- a/magic/magic-docs/html/smudge.html +++ b/magic/magic-docs/html/smudge.html @@ -6,5 +6,5 @@

    Tux Paint "Magic" Tool: Smudge

    By Albert Cahalan <albert@users.sf.net>

    This pushes the colors around under the mouse, like finger painting with wet paint.

    -

    See also: Blur

    +

    See also: Blur Wet Paint

    \ No newline at end of file diff --git a/magic/magic-docs/html/wetpaint.html b/magic/magic-docs/html/wetpaint.html new file mode 100644 index 000000000..d2bf4328e --- /dev/null +++ b/magic/magic-docs/html/wetpaint.html @@ -0,0 +1,12 @@ + +Tux Paint "Magic" Tool: Wet Paint + + + +

    Tux Paint "Magic" Tool: Wet Paint

    +

    By Albert Cahalan <albert@users.sf.net>
    +Bill Kendrick <bill@newbreedsoftware.com>
    +

    +

    This draws a light, smudgy coat of paint on the picture.

    +

    See also: Smudge

    + \ No newline at end of file diff --git a/magic/magic-docs/index.txt b/magic/magic-docs/index.txt index 30a62c8a9..abb9c31cc 100644 --- a/magic/magic-docs/index.txt +++ b/magic/magic-docs/index.txt @@ -57,4 +57,5 @@ * Toothpaste * Waves * Wavelets + * Wet Paint * Zoom diff --git a/magic/magic-docs/smudge.txt b/magic/magic-docs/smudge.txt index 82db428ff..ba6604cd4 100644 --- a/magic/magic-docs/smudge.txt +++ b/magic/magic-docs/smudge.txt @@ -5,4 +5,4 @@ This pushes the colors around under the mouse, like finger painting with wet paint. - See also: Blur + See also: Blur Wet Paint diff --git a/magic/magic-docs/src/magic-docs.php b/magic/magic-docs/src/magic-docs.php index 0e99a19b8..6dc29f38b 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 */ -/* 2009.08.31 */ +/* 2009.10.08 */ /* Authors of the Magic tools: */ @@ -272,7 +272,7 @@ $tools = array( array('name'=>'Smudge', 'desc'=>'This pushes the colors around under the mouse, like finger painting with wet paint.', 'author'=>$AUTHOR_ALBERT, - 'see'=>'Blur'), + 'see'=>array('Blur', 'Wet Paint')), array('name'=>'Snow Ball', 'desc'=>'Fill the picture with snowballs.', @@ -324,6 +324,11 @@ $tools = array( 'author'=>array($AUTHOR_KENDRICK, $AUTHOR_ADAMR), 'see'=>'Waves'), + array('name'=>'Wet Paint', + 'desc'=>'This draws a light, smudgy coat of paint on the picture.', + 'author'=>array($AUTHOR_ALBERT, $AUTHOR_KENDRICK), + 'see'=>'Smudge'), + array('name'=>'Zoom', 'desc'=>'Click and drag up to zoom in, or down to zoom out.', 'author'=>$AUTHOR_PERE), diff --git a/magic/magic-docs/wetpaint.txt b/magic/magic-docs/wetpaint.txt new file mode 100644 index 000000000..7f66ddb82 --- /dev/null +++ b/magic/magic-docs/wetpaint.txt @@ -0,0 +1,8 @@ + Tux Paint "Magic" Tool: Wet Paint + + By Albert Cahalan + Bill Kendrick + + This draws a light, smudgy coat of paint on the picture. + + See also: Smudge diff --git a/magic/src/smudge.c b/magic/src/smudge.c index ea56a2cde..d86016335 100644 --- a/magic/src/smudge.c +++ b/magic/src/smudge.c @@ -4,9 +4,10 @@ Magic Tool Plugin Tux Paint - A simple drawing program for children. - by Albert Cahalan - Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt - bill@newbreedsoftware.com + Smudge by Albert Cahalan + Wet Paint addition by Bill Kendrick + + Copyright (c) 2002-2009 http://www.tuxpaint.org/ This program is free software; you can redistribute it and/or modify @@ -24,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 8, 2008 + Last updated: Oconter 8, 2009 $Id$ */ @@ -37,7 +38,7 @@ /* Our globals: */ static Mix_Chunk * smudge_snd; - +static Uint8 smudge_r, smudge_g, smudge_b; // No setup required: @@ -57,7 +58,7 @@ Uint32 smudge_api_version(void) { return(TP_MAGIC_API_VERSION); } // We have multiple tools: int smudge_get_tool_count(magic_api * api) { - return(1); + return(2); } // Load our icons: @@ -65,8 +66,12 @@ SDL_Surface * smudge_get_icon(magic_api * api, int which) { char fname[1024]; - snprintf(fname, sizeof(fname), "%s/images/magic/smudge.png", - api->data_directory); + if (which == 0) + snprintf(fname, sizeof(fname), "%s/images/magic/smudge.png", + api->data_directory); + else /* if (which == 1) */ + snprintf(fname, sizeof(fname), "%s/images/magic/smudge.png", /* FIXME */ + api->data_directory); return(IMG_Load(fname)); } @@ -74,14 +79,19 @@ SDL_Surface * smudge_get_icon(magic_api * api, int which) // Return our names, localized: char * smudge_get_name(magic_api * api, int which) { - return(strdup(gettext_noop("Smudge"))); + if (which == 0) + return(strdup(gettext_noop("Smudge"))); + else /* if (which == 1) */ + return(strdup(gettext_noop("Wet Paint"))); } // Return our descriptions, localized: char * smudge_get_description(magic_api * api, int which, int mode) { - return(strdup(gettext_noop( -"Click and move the mouse around to smudge the picture."))); + if (which == 0) + return(strdup(gettext_noop("Click and move the mouse around to smudge the picture."))); + else /* if (which == 1) */ + return(strdup(gettext_noop("Click and move the mouse around to draw with wet, smudgy paint."))); } // Do the effect: @@ -94,6 +104,24 @@ static void do_smudge(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * unsigned i = 32 * 32; double rate = api->button_down() ? 0.5 : 0.0; Uint8 r, g, b; + int xx, yy, strength; + + if (which == 1) + { + /* Wet paint */ + for (yy = -8; yy < 8; yy++) + for (xx = -8; xx < 8; xx++) + if (api->in_circle(xx, yy, 8)) + { + SDL_GetRGB(api->getpixel(last, x + xx, y + yy), + last->format, &r, &g, &b); + strength = (abs(xx * yy) / 8) + 6; + api->putpixel(canvas, x + xx, y +yy, SDL_MapRGB(canvas->format, + (smudge_r + r * strength) / (strength + 1), + (smudge_g + g * strength) / (strength + 1), + (smudge_b + b * strength) / (strength + 1))); + } + } while (i--) { @@ -164,12 +192,18 @@ void smudge_shutdown(magic_api * api) // Record the color from Tux Paint: void smudge_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b) { + smudge_r = r; + smudge_g = g; + smudge_b = b; } // Use colors: int smudge_requires_colors(magic_api * api, int which) { - return 0; + if (which == 0) + return 0; + else /* if (which == 1) */ + return 1; } void smudge_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)