[gimp] Bug 785816 - show angle in degrees when drawing straight lines.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 785816 - show angle in degrees when drawing straight lines.
- Date: Tue, 15 Aug 2017 19:07:15 +0000 (UTC)
commit 78244f9cb56ff8fab5009237af65e57e4a08a168
Author: Jehan <jehan girinstud io>
Date: Tue Aug 15 20:57:50 2017 +0200
Bug 785816 - show angle in degrees when drawing straight lines.
Paint tools in straight line mode (shift click) will now display the
angle in status bar. Angle 0 is considered as the horizontal line from
left to right, and angle is measured counterclockwise from there, which
is the most common convention.
app/tools/gimppainttool.c | 45 +++++++++++++++++++++++++++++++++++++--------
1 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index fdc4127..a7b4d11 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -642,6 +642,9 @@ gimp_paint_tool_oper_update (GimpTool *tool,
gchar *status_help;
gdouble dx, dy, pixel_dist;
+ gdouble xres;
+ gdouble yres;
+ gdouble angle;
gimp_paint_core_round_line (core, paint_options,
(state & constrain_mask) != 0);
@@ -657,23 +660,49 @@ gimp_paint_tool_oper_update (GimpTool *tool,
pixel_dist = sqrt (SQR (dx) + SQR (dy));
- /* show distance in statusbar */
+ if (shell->unit == GIMP_UNIT_PIXEL)
+ xres = yres = 1.0;
+ else
+ gimp_image_get_resolution (image, &xres, &yres);
+
+ if (dx)
+ {
+ angle = gimp_rad_to_deg (atan ((dy/yres) / (dx/xres)));
+ if (dx > 0)
+ {
+ if (dy > 0)
+ angle = 360.0 - angle;
+ else if (dy < 0)
+ angle = -angle;
+ }
+ else
+ {
+ angle = 180.0 - angle;
+ }
+ }
+ else if (dy)
+ {
+ angle = dy > 0 ? 270.0 : 90.0;
+ }
+ else
+ {
+ angle = 0.0;
+ }
+
+ /* show distance and angle in statusbar */
if (shell->unit == GIMP_UNIT_PIXEL)
{
- gimp_tool_push_status (tool, display, "%.1f %s. %s",
- pixel_dist, _("pixels"), status_help);
+ gimp_tool_push_status (tool, display, "%.1f %s, %.2f\302\260. %s",
+ pixel_dist, _("pixels"), angle, status_help);
}
else
{
- gdouble xres;
- gdouble yres;
gdouble inch_dist;
gdouble unit_dist;
gint digits = 0;
gchar format_str[64];
/* The distance in unit. */
- gimp_image_get_resolution (image, &xres, &yres);
inch_dist = sqrt (SQR (dx / xres) + SQR (dy / yres));
unit_dist = gimp_unit_get_factor (shell->unit) * inch_dist;
@@ -682,11 +711,11 @@ gimp_paint_tool_oper_update (GimpTool *tool,
digits = gimp_unit_get_scaled_digits (shell->unit,
pixel_dist / inch_dist);
- g_snprintf (format_str, sizeof (format_str), "%%.%df %s. %%s",
+ g_snprintf (format_str, sizeof (format_str), "%%.%df %s, %%.2f\302\260. %%s",
digits, gimp_unit_get_symbol (shell->unit));
gimp_tool_push_status (tool, display, format_str,
- unit_dist, status_help);
+ unit_dist, angle, status_help);
}
g_free (status_help);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]