From e98daa5a626d89dbb537bed516cc255f2a435734 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sat, 1 Jul 2023 01:21:10 -0700 Subject: [PATCH] Fill -> Linear Gradient: Show angle while dragging When using the Linear Gradient fill tool, the angle of the gradient is now is shown (in the instructions at the bottom). h/t Miyagi Andel for the idea --- docs/CHANGES.txt | 9 ++++++++- src/fill_tools.h | 4 +++- src/tools.h | 2 +- src/tuxpaint.c | 15 ++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 3c085884f..2a0d6fce4 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -6,7 +6,7 @@ Copyright (c) 2002-2023 Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ -2023.June.29 (0.9.31) +2023.July.1 (0.9.31) * New Magic Tools: ---------------- * Loops - Draw loop-the-loops. @@ -35,6 +35,13 @@ https://tuxpaint.org/ * Fuzzy round erasers Bill Kendrick + * Improvements to Fill tool: + -------------------------- + * When using the Linear Gradient fill tool, the angle of the + gradient is now is shown (in the instructions at the bottom). + Bill Kendrick + h/t Miyagi Andel for the idea + * Other Improvements: ------------------- * Saved pictures can, from the Open dialog, be copied into diff --git a/src/fill_tools.h b/src/fill_tools.h index 73efbf4e9..f21e97417 100644 --- a/src/fill_tools.h +++ b/src/fill_tools.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: March 7, 2023 + Last updated: July 1, 2023 $Id$ */ @@ -72,4 +72,6 @@ const char *const fill_img_fnames[NUM_FILLS] = { DATA_PREFIX "images/fills/gradient_shaped.png" }; +#define TIP_FILL_LINEAR_MOVING gettext_noop("Click and drag to fill an area with a linear gradient (from the chosen color to transparent). (Your gradient’s angle is %.0f degrees.)") + #endif diff --git a/src/tools.h b/src/tools.h index a43ff7e6b..ce55588d7 100644 --- a/src/tools.h +++ b/src/tools.h @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Copyright (c) 2002-2022 by Bill Kendrick + Copyright (c) 2002-2023 by Bill Kendrick bill@newbreedsoftware.com https://tuxpaint.org/ diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 0fd1db4bb..0b684b97d 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - June 21, 2023 + June 14, 2002 - July 2, 2023 */ #include "platform.h" @@ -6652,6 +6652,19 @@ static void mainloop(void) new_x, new_y, draw_color, sim_flood_touched); update_canvas(sim_flood_x1, sim_flood_y1, sim_flood_x2, sim_flood_y2); + + if (new_y != fill_y) + angle = (atan2f((new_x - fill_x), (new_y - fill_y)) * 180 / M_PI) - 90.0; + else if (new_x >= fill_x) + angle = 0.0; + else + angle = 180.0; + + if (angle < 0.0) + angle += 360.0; + + snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_FILL_LINEAR_MOVING), floor(angle)); + draw_tux_text(TUX_GREAT, angle_tool_text, 1); } else if (cur_tool == TOOL_FILL && cur_fill == FILL_BRUSH) {