diff --git a/app/display/gimpdisplayshell-utils.c b/app/display/gimpdisplayshell-utils.c index 912bcc8a66..b8089635c2 100644 --- a/app/display/gimpdisplayshell-utils.c +++ b/app/display/gimpdisplayshell-utils.c @@ -89,6 +89,26 @@ gimp_display_shell_constrain_line (GimpDisplayShell *shell, xres, yres); } +gdouble +gimp_display_shell_constrain_angle (GimpDisplayShell *shell, + gdouble angle, + gint n_snap_lines) +{ + gdouble x, y; + + g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), 0.0); + + x = cos (angle); + y = sin (angle); + + gimp_display_shell_constrain_line (shell, + 0.0, 0.0, + &x, &y, + n_snap_lines); + + return atan2 (y, x); +} + /** * gimp_display_shell_get_line_status: * @status: initial status text. diff --git a/app/display/gimpdisplayshell-utils.h b/app/display/gimpdisplayshell-utils.h index d397ed6a18..3eb52e383b 100644 --- a/app/display/gimpdisplayshell-utils.h +++ b/app/display/gimpdisplayshell-utils.h @@ -19,23 +19,27 @@ #define __GIMP_DISPLAY_SHELL_UTILS_H__ -void gimp_display_shell_get_constrained_line_params (GimpDisplayShell *shell, - gdouble *offset_angle, - gdouble *xres, - gdouble *yres); -void gimp_display_shell_constrain_line (GimpDisplayShell *shell, - gdouble start_x, - gdouble start_y, - gdouble *end_x, - gdouble *end_y, - gint n_snap_lines); -gchar * gimp_display_shell_get_line_status (GimpDisplayShell *shell, - const gchar *status, - const gchar *separator, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2); +void gimp_display_shell_get_constrained_line_params (GimpDisplayShell *shell, + gdouble *offset_angle, + gdouble *xres, + gdouble *yres); +void gimp_display_shell_constrain_line (GimpDisplayShell *shell, + gdouble start_x, + gdouble start_y, + gdouble *end_x, + gdouble *end_y, + gint n_snap_lines); +gdouble gimp_display_shell_constrain_angle (GimpDisplayShell *shell, + gdouble angle, + gint n_snap_lines); + +gchar * gimp_display_shell_get_line_status (GimpDisplayShell *shell, + const gchar *status, + const gchar *separator, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2); #endif /* __GIMP_DISPLAY_SHELL_UTILS_H__ */