Showing aspect ratio of shapes when stretching them
...in the Tux tips area
This commit is contained in:
parent
9f5769855b
commit
16e7cb1f59
3 changed files with 50 additions and 18 deletions
|
|
@ -31,6 +31,8 @@ http://www.tuxpaint.org/
|
|||
------------------------------
|
||||
* Added hexagon (6-sided polygon) and heptagon (7-sided) shapes.
|
||||
|
||||
* Showing aspect ratio of shapes when stretching them.
|
||||
|
||||
* Using floats more, allowing for proper heptagon support, as
|
||||
well as a non-skewed starting angle for octagons (22.5 degrees).
|
||||
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
(See COPYING.txt)
|
||||
|
||||
Copyright (c) 2002-2021 by Bill Kendrick
|
||||
Copyright (c) 2002-2022 by Bill Kendrick
|
||||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
June 14, 2002 - October 25, 2021
|
||||
June 14, 2002 - January 21, 2022
|
||||
$Id$
|
||||
*/
|
||||
|
||||
|
|
@ -164,10 +164,11 @@ const char *const tool_tips[NUM_TOOLS] = {
|
|||
|
||||
// Instruction while using Line tool (after click, before release)
|
||||
#define TIP_LINE_START gettext_noop("Let go of the button to complete the line.")
|
||||
#define TIP_LINE_MOVING gettext_noop("Let go of the button to complete the line. (Your line's angle is %.0f degrees.)")
|
||||
#define TIP_LINE_MOVING gettext_noop("Let go of the button to complete the line. (Your line’s angle is %.0f degrees.)")
|
||||
|
||||
// Instruction while using Shape tool (after first click, before release)
|
||||
#define TIP_SHAPE_START gettext_noop("Hold the button to stretch the shape.")
|
||||
#define TIP_SHAPE_STRETCHING_UNLOCKED gettext_noop("Hold the button to stretch the shape. (It has an aspect ratio of \"%.2g:1\".)")
|
||||
|
||||
// Instruction while finishing Shape tool (after release, during rotation step before second click)
|
||||
#define TIP_SHAPE_NEXT gettext_noop("Move the mouse to rotate the shape. Click to draw it.")
|
||||
|
|
|
|||
|
|
@ -2363,7 +2363,7 @@ static void mainloop(void)
|
|||
|
||||
float angle;
|
||||
char angle_tool_text[256]; // FIXME Consider malloc'ing
|
||||
|
||||
char stretch_tool_text[256]; // FIXME Consider malloc'ing
|
||||
|
||||
num_things = num_brushes;
|
||||
thing_scroll = &brush_scroll;
|
||||
|
|
@ -6009,25 +6009,54 @@ static void mainloop(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (cur_tool == TOOL_SHAPES && shape_tool_mode == SHAPE_TOOL_MODE_ROTATE)
|
||||
else if (cur_tool == TOOL_SHAPES)
|
||||
{
|
||||
int deg;
|
||||
if (shape_tool_mode == SHAPE_TOOL_MODE_STRETCH && !shape_locked[cur_shape])
|
||||
{
|
||||
float aspect;
|
||||
int w, h;
|
||||
|
||||
deg = shape_rotation(shape_start_x, shape_start_y, old_x, old_y);
|
||||
do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0);
|
||||
w = abs(shape_start_x - new_x);
|
||||
h = abs(shape_start_y - new_y);
|
||||
|
||||
deg = shape_rotation(shape_start_x, shape_start_y, new_x, new_y);
|
||||
do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0);
|
||||
|
||||
deg = -deg;
|
||||
if (deg < 0)
|
||||
deg += 360;
|
||||
if (w < 2 || h < 2)
|
||||
aspect = 0;
|
||||
else if (w > h)
|
||||
aspect = (float) w / (float) h;
|
||||
else
|
||||
aspect = (float) h / (float) w;
|
||||
|
||||
snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_SHAPE_ROTATING), deg);
|
||||
draw_tux_text(TUX_BORED, angle_tool_text, 1);
|
||||
|
||||
/* FIXME: Do something less intensive! */
|
||||
SDL_Flip(screen);
|
||||
if (aspect == 0 || aspect >= 100)
|
||||
{
|
||||
draw_tux_text(TUX_BORED, TIP_SHAPE_START, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(stretch_tool_text, sizeof(stretch_tool_text), gettext(TIP_SHAPE_STRETCHING_UNLOCKED), aspect);
|
||||
draw_tux_text(TUX_BORED, stretch_tool_text, 1);
|
||||
}
|
||||
}
|
||||
else if (shape_tool_mode == SHAPE_TOOL_MODE_ROTATE)
|
||||
{
|
||||
int deg;
|
||||
|
||||
deg = shape_rotation(shape_start_x, shape_start_y, old_x, old_y);
|
||||
do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0);
|
||||
|
||||
deg = shape_rotation(shape_start_x, shape_start_y, new_x, new_y);
|
||||
do_shape(shape_start_x, shape_start_y, shape_current_x, shape_current_y, deg, 0);
|
||||
|
||||
deg = -deg;
|
||||
if (deg < 0)
|
||||
deg += 360;
|
||||
|
||||
snprintf(angle_tool_text, sizeof(angle_tool_text), gettext(TIP_SHAPE_ROTATING), deg);
|
||||
draw_tux_text(TUX_BORED, angle_tool_text, 1);
|
||||
|
||||
/* FIXME: Do something less intensive! */
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
}
|
||||
|
||||
old_x = new_x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue