[gimp] app: add gimp_display_shell_constrain_angle()
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_display_shell_constrain_angle()
- Date: Thu, 14 May 2020 21:52:12 +0000 (UTC)
commit 8c1a277007ec149cfb4ad091d28cb27c32353a85
Author: Ell <ell_se yahoo com>
Date: Thu May 14 23:44:50 2020 +0300
app: add gimp_display_shell_constrain_angle()
... which constrains an angle to discrete increments in screen
space, similarly to gimp_display_shell_constrain_line().
app/display/gimpdisplayshell-utils.c | 20 +++++++++++++++++++
app/display/gimpdisplayshell-utils.h | 38 ++++++++++++++++++++----------------
2 files changed, 41 insertions(+), 17 deletions(-)
---
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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]