Elevate "Fill" from Magic Tool to real Tool

Replace the somewhat-recently-added "nothing" item in the tool bar
with the "Fill" tool, which has been converted back from a Magic tool
to a regular tool.

Also, change bash "==" to sh "=" in "if [ ... ]" tests in Makefile.

Also, link to math library (via "-lm") to make sure "max()" is available to
magic tools.

Also, add missing mention of "--newcolorslast" and "--newcolorsfirst" to manpage.
This commit is contained in:
Bill Kendrick 2019-09-12 23:04:13 -07:00
parent d79173eae4
commit 2911b35a50
15 changed files with 295 additions and 304 deletions

View file

@ -1,10 +1,10 @@
# Tux Paint - A simple drawing program for children. # Tux Paint - A simple drawing program for children.
# Copyright (c) 2002-2018 # Copyright (c) 2002-2019
# Various contributors (see AUTHORS.txt) # Various contributors (see AUTHORS.txt)
# http://www.tuxpaint.org/ # http://www.tuxpaint.org/
# June 14, 2002 - December 18, 2018 # June 14, 2002 - September 12, 2019
# The version number, for release: # The version number, for release:
@ -481,7 +481,7 @@ install: install-bin install-data install-man install-doc \
@echo @echo
@echo "--------------------------------------------------------------" @echo "--------------------------------------------------------------"
@echo @echo
@if [ "x$(OS)" == "xosx" ]; then \ @if [ "x$(OS)" = "xosx" ]; then \
echo "All done! Now you can double click $(BUNDLE) to run the"; \ echo "All done! Now you can double click $(BUNDLE) to run the"; \
echo "program!!! TuxPaint.dmg has also been created for"; \ echo "program!!! TuxPaint.dmg has also been created for"; \
echo "distribution."; \ echo "distribution."; \
@ -876,7 +876,7 @@ install-dlls:
@cp `which libstdc++-6.dll` $(BIN_PREFIX) @cp `which libstdc++-6.dll` $(BIN_PREFIX)
@cp `which libfribidi-0.dll` $(BIN_PREFIX) @cp `which libfribidi-0.dll` $(BIN_PREFIX)
@cp `which libpthread-2.dll` $(BIN_PREFIX) @cp `which libpthread-2.dll` $(BIN_PREFIX)
@if [ "x$(BDIST_WIN9X)" == "x" ]; then \ @if [ "x$(BDIST_WIN9X)" = "x" ]; then \
cp `which libxml2-2.dll` $(BIN_PREFIX); \ cp `which libxml2-2.dll` $(BIN_PREFIX); \
cp `which libcairo-2.dll` $(BIN_PREFIX); \ cp `which libcairo-2.dll` $(BIN_PREFIX); \
cp `which libfontconfig-1.dll` $(BIN_PREFIX); \ cp `which libfontconfig-1.dll` $(BIN_PREFIX); \
@ -898,7 +898,7 @@ install-dlls:
cp `which bz2-1.dll` $(BIN_PREFIX); \ cp `which bz2-1.dll` $(BIN_PREFIX); \
fi fi
@strip -s $(BIN_PREFIX)/*.dll @strip -s $(BIN_PREFIX)/*.dll
@if [ "x$(BDIST_WIN9X)" == "x" ]; then \ @if [ "x$(BDIST_WIN9X)" = "x" ]; then \
echo; \ echo; \
echo "...Installing Configuration Files..."; \ echo "...Installing Configuration Files..."; \
cp -R win32/etc/ $(BIN_PREFIX); \ cp -R win32/etc/ $(BIN_PREFIX); \
@ -1021,7 +1021,7 @@ TuxPaint.dmg:
# Build the program! # Build the program!
tuxpaint: obj/tuxpaint.o obj/i18n.o obj/im.o obj/cursor.o obj/pixels.o \ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/im.o obj/cursor.o obj/pixels.o \
obj/rgblinear.o obj/playsound.o obj/fonts.o obj/parse.o \ obj/rgblinear.o obj/playsound.o obj/fonts.o obj/parse.o obj/fill.o \
obj/progressbar.o obj/dirwalk.o obj/get_fname.o obj/onscreen_keyboard.o \ obj/progressbar.o obj/dirwalk.o obj/get_fname.o obj/onscreen_keyboard.o \
$(ARCH_LIBS) $(ARCH_LIBS)
@echo @echo
@ -1037,7 +1037,7 @@ tuxpaint: obj/tuxpaint.o obj/i18n.o obj/im.o obj/cursor.o obj/pixels.o \
obj/tuxpaint.o: src/tuxpaint.c \ obj/tuxpaint.o: src/tuxpaint.c \
src/i18n.h src/im.h src/cursor.h src/pixels.h \ src/i18n.h src/im.h src/cursor.h src/pixels.h \
src/rgblinear.h src/playsound.h src/fonts.h \ src/rgblinear.h src/playsound.h src/fonts.h src/fill.h \
src/progressbar.h src/dirwalk.h src/get_fname.h \ src/progressbar.h src/dirwalk.h src/get_fname.h \
src/compiler.h src/debug.h \ src/compiler.h src/debug.h \
src/tools.h src/titles.h src/colors.h src/shapes.h \ src/tools.h src/titles.h src/colors.h src/shapes.h \
@ -1136,6 +1136,13 @@ obj/playsound.o: src/playsound.c src/playsound.h \
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \ @$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/playsound.c -o obj/playsound.o -c src/playsound.c -o obj/playsound.o
obj/fill.o: src/fill.c src/fill.h \
src/rgblinear.h src/playsound.h src/pixels.h
@echo
@echo "...Compiling flood fill tool..."
@$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
-c src/fill.c -o obj/fill.o
obj/progressbar.o: src/progressbar.c src/progressbar.h \ obj/progressbar.o: src/progressbar.c src/progressbar.h \
src/compiler.h src/debug.h src/compiler.h src/debug.h
@echo @echo
@ -1226,7 +1233,7 @@ PLUGIN_LIBS:=$($(OS)_PLUGIN_LIBS)
#MAGIC_CFLAGS:=-g3 -O2 -fvisibility=hidden -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/ #MAGIC_CFLAGS:=-g3 -O2 -fvisibility=hidden -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/
MAGIC_CFLAGS:=-g3 -O2 -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/ $(ARCH_CFLAGS) MAGIC_CFLAGS:=-g3 -O2 -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/ $(ARCH_CFLAGS)
SHARED_FLAGS:=-shared -fpic SHARED_FLAGS:=-shared -fpic -lm
MAGIC_C:=$(wildcard magic/src/*.c) MAGIC_C:=$(wildcard magic/src/*.c)
MAGIC_SO:=$(patsubst magic/src/%.c,magic/%.$(SO_TYPE),$(MAGIC_C)) MAGIC_SO:=$(patsubst magic/src/%.c,magic/%.$(SO_TYPE),$(MAGIC_C))

View file

Before

Width:  |  Height:  |  Size: 632 B

After

Width:  |  Height:  |  Size: 632 B

Before After
Before After

View file

@ -9,6 +9,12 @@ http://www.tuxpaint.org/
$Id$ $Id$
2019.Sep.12 (0.9.24) 2019.Sep.12 (0.9.24)
* New tools
---------
* Fill
Not actually a new tool, but promoted from a "Magic" tool
to a full-fledge tool in the "Tools" bar.
* Ports & Building * Ports & Building
---------------- ----------------
* Updates to build on Haiku. * Updates to build on Haiku.

View file

@ -6,7 +6,7 @@
Copyright 2002-2019 by various contributors; see AUTHORS.txt Copyright 2002-2019 by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/ http://www.tuxpaint.org/
June 14, 2002 - April 3, 2019 June 14, 2002 - September 12, 2019
---------------------------------------------------------------------- ----------------------------------------------------------------------
@ -375,6 +375,16 @@ Available Tools
left [Alt] left [Alt]
* Thai — right [Alt] * Thai — right [Alt]
----------------------------------------------------------------------
Fill
The 'Fill' tool 'flood-fills' a contiguous area of your
drawing with a solid color of your choice.
Note: Prior to Tux Paint 0.9.24, this was a "Magic" tool
(see below).
---------------------------------------------------------------------- ----------------------------------------------------------------------
Magic (Special Effects) Magic (Special Effects)

View file

@ -22,7 +22,7 @@ version
<p>June 14, 2002 - <p>June 14, 2002 -
April 3, 2019</p> September 12, 2019</p>
</center> </center>
@ -507,6 +507,17 @@ version
<hr size=1> <hr size=1>
</dd> </dd>
<dt><b>Fill</b></dt>
<dd>
<img src="../../html/images/tool_fill.png" width=48 height=48 alt="" align=right>
<p>The 'Fill' tool 'flood-fills' a contiguous area of your drawing
with a solid color of your choice.</p>
<p>Note: Prior to Tux&nbsp;Paint 0.9.24, this was a "Magic" tool (see below).</p>
<hr size=1>
</dd>
<dt><b>Magic (Special Effects)</b></dt> <dt><b>Magic (Special Effects)</b></dt>
<dd> <dd>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -5,7 +5,7 @@ individual HTML files for each of them, and an index.html that links to
them all. */ them all. */
/* Bill Kendrick <bill@newbreedsoftware.com> */ /* Bill Kendrick <bill@newbreedsoftware.com> */
/* Oct. 8, 2009 - August 30, 2018 */ /* Oct. 8, 2009 - September 12, 2019 */
/* Authors of the Magic tools: */ /* Authors of the Magic tools: */
@ -114,10 +114,6 @@ $tools = array(
'author'=>$AUTHOR_KENDRICK, 'author'=>$AUTHOR_KENDRICK,
'see'=>array('Edges', 'Silhouette')), 'see'=>array('Edges', 'Silhouette')),
array('name'=>'Fill',
'desc'=>'This floods the picture with a color. It lets you quickly fill parts of the picture, as if it were a coloring book.',
'author'=>$AUTHOR_KENDRICK),
array('name'=>'Fisheye', array('name'=>'Fisheye',
'desc'=>'Warp parts of your picture like it\'s being seen through a fisheye lens.', 'desc'=>'Warp parts of your picture like it\'s being seen through a fisheye lens.',
'author'=>$AUTHOR_ADAMR), 'author'=>$AUTHOR_ADAMR),

View file

@ -1,268 +0,0 @@
/*
fill.c
Fill Magic Tool Plugin
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
Flood fill code based on Wikipedia example:
http://www.wikipedia.org/wiki/Flood_fill/C_example
by Damian Yerrick - http://www.wikipedia.org/wiki/Damian_Yerrick
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: July 8, 2008
$Id$
*/
#include <stdio.h>
#include <string.h>
#include "tp_magic_api.h"
#include "SDL_image.h"
/* Our globals: */
static Mix_Chunk *fill_snd;
static Uint8 fill_r, fill_g, fill_b;
/* Local function prototypes: */
static int colors_close(magic_api * api, SDL_Surface * canvas, Uint32 c1, Uint32 c2);
static void do_flood_fill(magic_api * api, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr);
int fill_modes(magic_api * api, int which);
void fill_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
void fill_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
int fill_requires_colors(magic_api * api, int which);
void fill_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
void fill_shutdown(magic_api * api);
void fill_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void fill_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void fill_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
char *fill_get_description(magic_api * api, int which, int mode);
char *fill_get_name(magic_api * api, int which);
int fill_get_tool_count(magic_api * api);
SDL_Surface *fill_get_icon(magic_api * api, int which);
Uint32 fill_api_version(void);
int fill_init(magic_api * api);
// No setup required:
int fill_init(magic_api * api)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%s/sounds/magic/fill.wav", api->data_directory);
fill_snd = Mix_LoadWAV(fname);
return (1);
}
Uint32 fill_api_version(void)
{
return (TP_MAGIC_API_VERSION);
}
// We have multiple tools:
int fill_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
{
return (1);
}
// Load our icons:
SDL_Surface *fill_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%s/images/magic/fill.png", api->data_directory);
return (IMG_Load(fname));
}
// Return our names, localized:
char *fill_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return (strdup(gettext_noop("Fill")));
}
// Return our descriptions, localized:
char *fill_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
{
return (strdup(gettext_noop("Click in the picture to fill that area with color.")));
}
// Affect the canvas on drag:
void fill_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}
// Affect the canvas on click:
void fill_click(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
int x, int y, SDL_Rect * update_rect)
{
do_flood_fill(api, canvas, x, y, SDL_MapRGB(canvas->format, fill_r, fill_g, fill_b), api->getpixel(canvas, x, y));
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;
update_rect->h = canvas->h;
}
void fill_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}
void fill_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{
Mix_FreeChunk(fill_snd);
}
// Record the color from Tux Paint:
void fill_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b)
{
fill_r = r;
fill_g = g;
fill_b = b;
}
// Use colors:
int fill_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return 1;
}
static int colors_close(magic_api * api, SDL_Surface * canvas, Uint32 c1, Uint32 c2)
{
Uint8 r1, g1, b1, r2, g2, b2;
if (c1 == c2)
{
/* Get it over with quick, if possible! */
return 1;
}
else
{
double r, g, b;
SDL_GetRGB(c1, canvas->format, &r1, &g1, &b1);
SDL_GetRGB(c2, canvas->format, &r2, &g2, &b2);
// use distance in linear RGB space
r = api->sRGB_to_linear(r1) - api->sRGB_to_linear(r2);
r *= r;
g = api->sRGB_to_linear(g1) - api->sRGB_to_linear(g2);
g *= g;
b = api->sRGB_to_linear(b1) - api->sRGB_to_linear(b2);
b *= b;
// easy to confuse:
// dark grey, brown, purple
// light grey, tan
// red, orange
return r + g + b < 0.04;
}
}
static void do_flood_fill(magic_api * api, SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr)
{
int fillL, fillR, i, in_line;
static unsigned char prog_anim;
if (cur_colr == old_colr || colors_close(api, canvas, cur_colr, old_colr))
return;
fillL = x;
fillR = x;
prog_anim++;
if ((prog_anim % 4) == 0)
{
api->update_progress_bar();
api->playsound(fill_snd, (x * 255) / canvas->w, 255);
}
/* Find left side, filling along the way */
in_line = 1;
while (in_line)
{
api->putpixel(canvas, fillL, y, cur_colr);
fillL--;
in_line = (fillL < 0) ? 0 : colors_close(api, canvas, api->getpixel(canvas, fillL, y), old_colr);
}
fillL++;
/* Find right side, filling along the way */
in_line = 1;
while (in_line)
{
api->putpixel(canvas, fillR, y, cur_colr);
fillR++;
in_line = (fillR >= canvas->w) ? 0 : colors_close(api, canvas, api->getpixel(canvas, fillR, y), old_colr);
}
fillR--;
/* Search top and bottom */
for (i = fillL; i <= fillR; i++)
{
if (y > 0 && colors_close(api, canvas, api->getpixel(canvas, i, y - 1), old_colr))
do_flood_fill(api, canvas, i, y - 1, cur_colr, old_colr);
if (y < canvas->h && colors_close(api, canvas, api->getpixel(canvas, i, y + 1), old_colr))
do_flood_fill(api, canvas, i, y + 1, cur_colr, old_colr);
}
}
void fill_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
void fill_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
int fill_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return (MODE_PAINT);
}

160
src/fill.c Normal file
View file

@ -0,0 +1,160 @@
/*
fill.c
Fill tool
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
Flood fill code based on Wikipedia example:
http://www.wikipedia.org/wiki/Flood_fill/C_example
by Damian Yerrick - http://www.wikipedia.org/wiki/Damian_Yerrick
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: September 12, 2019
$Id$
*/
#include <stdio.h>
#include <string.h>
#include "fill.h"
#include "rgblinear.h"
#include "playsound.h"
#include "pixels.h"
/* Local function prototypes: */
int colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2);
int colors_close(SDL_Surface * canvas, Uint32 c1, Uint32 c2)
{
Uint8 r1, g1, b1, r2, g2, b2;
if (c1 == c2)
{
/* Get it over with quick, if possible! */
return 1;
}
else
{
double r, g, b;
SDL_GetRGB(c1, canvas->format, &r1, &g1, &b1);
SDL_GetRGB(c2, canvas->format, &r2, &g2, &b2);
// use distance in linear RGB space
r = sRGB_to_linear_table[r1] - sRGB_to_linear_table[r2];
r *= r;
g = sRGB_to_linear_table[g1] - sRGB_to_linear_table[g2];
g *= g;
b = sRGB_to_linear_table[b1] - sRGB_to_linear_table[b2];
b *= b;
// easy to confuse:
// dark grey, brown, purple
// light grey, tan
// red, orange
return r + g + b < 0.04;
}
}
void do_flood_fill(SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2)
{
int fillL, fillR, i, in_line;
static unsigned char prog_anim;
if (cur_colr == old_colr || colors_close(canvas, cur_colr, old_colr))
return;
if (y < *y1)
{
*y1 = y;
}
if (y > *y2)
{
*y2 = y;
}
fillL = x;
fillR = x;
prog_anim++;
if ((prog_anim % 4) == 0)
{
/* FIXME: api->update_progress_bar(); */
playsound(canvas, 1, SND_FILL, 1, x, SNDDIST_NEAR);
}
/* Find left side, filling along the way */
in_line = 1;
while (in_line)
{
putpixels[canvas->format->BytesPerPixel] (canvas, fillL, y, cur_colr);
fillL--;
in_line = (fillL < 0) ? 0 : colors_close(canvas, getpixels[canvas->format->BytesPerPixel] (canvas, fillL, y), old_colr);
}
if (fillL < *x1)
{
*x1 = fillL;
}
fillL++;
/* Find right side, filling along the way */
in_line = 1;
while (in_line)
{
putpixels[canvas->format->BytesPerPixel] (canvas, fillR, y, cur_colr);
fillR++;
in_line = (fillR >= canvas->w) ? 0 : colors_close(canvas, getpixels[canvas->format->BytesPerPixel] (canvas, fillR, y), old_colr);
}
if (fillR > *x2)
{
*x2 = fillR;
}
fillR--;
/* Search top and bottom */
for (i = fillL; i <= fillR; i++)
{
if (y > 0 && colors_close(canvas, getpixels[canvas->format->BytesPerPixel] (canvas, i, y - 1), old_colr))
do_flood_fill(canvas, i, y - 1, cur_colr, old_colr, x1, y1, x2, y2);
if (y < canvas->h && colors_close(canvas, getpixels[canvas->format->BytesPerPixel] (canvas, i, y + 1), old_colr))
do_flood_fill(canvas, i, y + 1, cur_colr, old_colr, x1, y1, x2, y2);
}
}

37
src/fill.h Normal file
View file

@ -0,0 +1,37 @@
/*
fill.h
Fill tool
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
Flood fill code based on Wikipedia example:
http://www.wikipedia.org/wiki/Flood_fill/C_example
by Damian Yerrick - http://www.wikipedia.org/wiki/Damian_Yerrick
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: September 12, 2019
$Id$
*/
#include "SDL.h"
void do_flood_fill(SDL_Surface * canvas, int x, int y, Uint32 cur_colr, Uint32 old_colr, int * x1, int * y1, int * x2, int * y2);

View file

@ -1,5 +1,5 @@
.\" tuxpaint.1 - 2018.09.24 .\" tuxpaint.1 - 2019.09.12
.TH TUXPAINT 1 "24 September 2018" "0.9.23c" "Tux Paint" .TH TUXPAINT 1 "12 September 2019" "0.9.24" "Tux Paint"
.SH NAME .SH NAME
tuxpaint -- "Tux Paint", a drawing program for young children. tuxpaint -- "Tux Paint", a drawing program for young children.
@ -61,6 +61,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br .br
[\-\-nolabel] [\-\-nolabel]
.br .br
[\-\-newcolorslast]
.br
[\-\-mirrorstamps] [\-\-mirrorstamps]
.br .br
[\-\-mouse-accessibility] [\-\-mouse-accessibility]
@ -187,6 +189,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br .br
[\-\-label] [\-\-label]
.br .br
[\-\-newcolorsfirst]
.br
[\-\-dontmirrorstamps] [\-\-dontmirrorstamps]
.br .br
[\-\-stampsize=default] [\-\-stampsize=default]
@ -408,6 +412,11 @@ controllable.)
Disable or enable (default) the \fILabel\fP tool, which lets you create Disable or enable (default) the \fILabel\fP tool, which lets you create
text which can be altered or moved later. text which can be altered or moved later.
.TP 8
.B \-\-newcolorslast \-\-newcolorsfirst
List solid (blank) colors at the end, or beginning (default) of the
options displayed when using the \fINew\fP tool to start a new picture.
.TP 8 .TP 8
.B \-\-mirrorstamps \-\-dontmirrorstamps .B \-\-mirrorstamps \-\-dontmirrorstamps
With \fImirrorstamps\fP set, stamps which can be mirrored will appear With \fImirrorstamps\fP set, stamps which can be mirrored will appear

View file

@ -4,7 +4,7 @@
For Tux Paint For Tux Paint
List of sound effects. List of sound effects.
Copyright (c) 2002-2007 by Bill Kendrick and others Copyright (c) 2002-2019 by Bill Kendrick and others
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 15, 2002 - July 5, 2007 June 15, 2002 - September 12, 2019
$Id$ $Id$
*/ */
@ -67,6 +67,7 @@ enum
SND_TUXOK, /* "Ok" */ SND_TUXOK, /* "Ok" */
SND_THICK, SND_THICK,
SND_THIN, SND_THIN,
SND_FILL,
NUM_SOUNDS NUM_SOUNDS
}; };
@ -107,7 +108,8 @@ static const char *sound_fnames[NUM_SOUNDS] = {
DATA_PREFIX "sounds/youcannot.wav", DATA_PREFIX "sounds/youcannot.wav",
DATA_PREFIX "sounds/tuxok.wav", DATA_PREFIX "sounds/tuxok.wav",
DATA_PREFIX "sounds/thick.wav", DATA_PREFIX "sounds/thick.wav",
DATA_PREFIX "sounds/thin.wav" DATA_PREFIX "sounds/thin.wav",
DATA_PREFIX "sounds/fill.wav"
}; };
#endif #endif

View file

@ -19,11 +19,11 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Copyright (c) 2002-2009 by Bill Kendrick Copyright (c) 2002-2019 by Bill Kendrick
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.tuxpaint.org/ http://www.tuxpaint.org/
June 14, 2002 - October 9, 2009 June 14, 2002 - September 12, 2019
$Id$ $Id$
*/ */
@ -41,7 +41,7 @@ enum
TOOL_SHAPES, TOOL_SHAPES,
TOOL_TEXT, TOOL_TEXT,
TOOL_LABEL, TOOL_LABEL,
TOOL_NA, TOOL_FILL,
TOOL_MAGIC, TOOL_MAGIC,
TOOL_UNDO, TOOL_UNDO,
TOOL_REDO, TOOL_REDO,
@ -76,8 +76,8 @@ const char *const tool_names[NUM_TOOLS] = {
// Label tool // Label tool
gettext_noop("Label"), gettext_noop("Label"),
// Reserved... // Fill tool
" ", gettext_noop("Fill"),
// "Magic" effects tools (blur, flip image, etc.) // "Magic" effects tools (blur, flip image, etc.)
gettext_noop("Magic"), gettext_noop("Magic"),
@ -132,8 +132,8 @@ const char *const tool_tips[NUM_TOOLS] = {
gettext_noop gettext_noop
("Choose a style of text. Click on your drawing and you can start typing. Press [Enter] or [Tab] to complete the text. By using the selector button and clicking an existing label, you can move it, edit it and change its text style."), ("Choose a style of text. Click on your drawing and you can start typing. Press [Enter] or [Tab] to complete the text. By using the selector button and clicking an existing label, you can move it, edit it and change its text style."),
// Reserved... // Fill tool instructions
" ", gettext_noop("Click in the picture to fill that area with color."),
// Magic tool instruction // Magic tool instruction
gettext_noop("Pick a magical effect to use on your drawing!"), gettext_noop("Pick a magical effect to use on your drawing!"),
@ -185,7 +185,7 @@ const char *const tool_img_fnames[NUM_TOOLS] = {
DATA_PREFIX "images/tools/shapes.png", DATA_PREFIX "images/tools/shapes.png",
DATA_PREFIX "images/tools/text.png", DATA_PREFIX "images/tools/text.png",
DATA_PREFIX "images/tools/label.png", DATA_PREFIX "images/tools/label.png",
DATA_PREFIX "images/ui/dead40x40.png", DATA_PREFIX "images/tools/fill.png",
DATA_PREFIX "images/tools/magic.png", DATA_PREFIX "images/tools/magic.png",
DATA_PREFIX "images/tools/undo.png", DATA_PREFIX "images/tools/undo.png",
DATA_PREFIX "images/tools/redo.png", DATA_PREFIX "images/tools/redo.png",

View file

@ -503,6 +503,8 @@ static void mtw(wchar_t * wtok, char *tok)
#include "tip_tux.h" #include "tip_tux.h"
#include "great.h" #include "great.h"
#include "fill.h"
#include "im.h" #include "im.h"
@ -3065,6 +3067,12 @@ static void mainloop(void)
draw_brushes(); draw_brushes();
draw_colors(COLORSEL_ENABLE); draw_colors(COLORSEL_ENABLE);
} }
else if (cur_tool == TOOL_FILL)
{
keybd_flag = 0;
draw_none();
draw_colors(COLORSEL_ENABLE);
}
else if (cur_tool == TOOL_SHAPES) else if (cur_tool == TOOL_SHAPES)
{ {
keybd_flag = 0; keybd_flag = 0;
@ -4376,6 +4384,24 @@ static void mainloop(void)
if (mouseaccessibility) if (mouseaccessibility)
emulate_button_pressed = !emulate_button_pressed; emulate_button_pressed = !emulate_button_pressed;
} }
else if (cur_tool == TOOL_FILL)
{
int x1, y1, x2, y2;
/* Fill */
x1 = x2 = old_x;
y1 = y2 = old_y;
do_flood_fill(canvas, old_x, old_y,
SDL_MapRGB(canvas->format,
color_hexes[cur_color][0],
color_hexes[cur_color][1],
color_hexes[cur_color][2]),
getpixels[canvas->format->BytesPerPixel] (canvas, old_x, old_y),
&x1, &y1, &x2, &y2);
update_canvas(x1, y1, x2, y2);
}
else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL) else if (cur_tool == TOOL_TEXT || cur_tool == TOOL_LABEL)
{ {
/* Text and Label Tools! */ /* Text and Label Tools! */
@ -4549,7 +4575,8 @@ static void mainloop(void)
if (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP || if (cur_tool == TOOL_BRUSH || cur_tool == TOOL_STAMP ||
cur_tool == TOOL_SHAPES || cur_tool == TOOL_LINES || cur_tool == TOOL_SHAPES || cur_tool == TOOL_LINES ||
cur_tool == TOOL_MAGIC || cur_tool == TOOL_TEXT || cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL) cur_tool == TOOL_MAGIC || cur_tool == TOOL_TEXT ||
cur_tool == TOOL_ERASER || cur_tool == TOOL_LABEL)
{ {
/* Left tools scroll */ /* Left tools scroll */
@ -5151,7 +5178,7 @@ static void mainloop(void)
do_setcursor(cursor_brush); do_setcursor(cursor_brush);
else if (cur_tool == TOOL_STAMP) else if (cur_tool == TOOL_STAMP)
do_setcursor(cursor_tiny); do_setcursor(cursor_tiny);
else if (cur_tool == TOOL_LINES) else if (cur_tool == TOOL_LINES || cur_tool == TOOL_FILL)
do_setcursor(cursor_crosshair); do_setcursor(cursor_crosshair);
else if (cur_tool == TOOL_SHAPES) else if (cur_tool == TOOL_SHAPES)
{ {
@ -5182,7 +5209,6 @@ static void mainloop(void)
do_setcursor(cursor_arrow); do_setcursor(cursor_arrow);
} }
} }
else if (cur_tool == TOOL_MAGIC) else if (cur_tool == TOOL_MAGIC)
do_setcursor(cursor_wand); do_setcursor(cursor_wand);
else if (cur_tool == TOOL_ERASER) else if (cur_tool == TOOL_ERASER)
@ -10110,11 +10136,6 @@ static void reset_avail_tools(void)
tool_avail[TOOL_LABEL] = 0; tool_avail[TOOL_LABEL] = 0;
/* TBD... */
tool_avail[TOOL_NA] = 0;
/* Disable save? */ /* Disable save? */
if (disable_save) if (disable_save)