[gimp/gimp-2-10] app: add gimp_symmetry_get_matrix()



commit a474e695732b758464288eb8169caf72351aea6c
Author: Ell <ell_se yahoo com>
Date:   Wed May 29 04:41:10 2019 -0400

    app: add gimp_symmetry_get_matrix()
    
    ... which returns the brush transform corresponding to a given
    GimpSymmetry stroke as a GimpMatrix3, as per
    gimp_symmetry_get_transform().
    
    (cherry picked from commit cd7bcd081b06e0211299d0a1d6eff0b7b80e7e9a)

 app/core/gimpsymmetry.c | 29 +++++++++++++++++++++++++++++
 app/core/gimpsymmetry.h |  3 +++
 2 files changed, 32 insertions(+)
---
diff --git a/app/core/gimpsymmetry.c b/app/core/gimpsymmetry.c
index fc0f892970..83a442757c 100644
--- a/app/core/gimpsymmetry.c
+++ b/app/core/gimpsymmetry.c
@@ -27,6 +27,7 @@
 
 #include "libgimpbase/gimpbase.h"
 #include "libgimpconfig/gimpconfig.h"
+#include "libgimpmath/gimpmath.h"
 
 #include "core-types.h"
 
@@ -465,6 +466,34 @@ gimp_symmetry_get_transform (GimpSymmetry *sym,
                                                 reflect);
 }
 
+/**
+ * gimp_symmetry_get_matrix:
+ * @sym:     the #GimpSymmetry
+ * @stroke:  the stroke number
+ * @matrix:  output pointer to the transformation matrix
+ *
+ * Returns the transformation matrix to apply to the paint buffer for stroke
+ * number @stroke.
+ **/
+void
+gimp_symmetry_get_matrix (GimpSymmetry *sym,
+                          gint          stroke,
+                          GimpMatrix3  *matrix)
+{
+  gdouble  angle;
+  gboolean reflect;
+
+  g_return_if_fail (GIMP_IS_SYMMETRY (sym));
+  g_return_if_fail (matrix != NULL);
+
+  gimp_symmetry_get_transform (sym, stroke, &angle, &reflect);
+
+  gimp_matrix3_identity (matrix);
+  gimp_matrix3_rotate (matrix, -gimp_deg_to_rad (angle));
+  if (reflect)
+    gimp_matrix3_scale (matrix, -1.0, 1.0);
+}
+
 /*
  * gimp_symmetry_parasite_name:
  * @type: the #GimpSymmetry's #GType
diff --git a/app/core/gimpsymmetry.h b/app/core/gimpsymmetry.h
index 3d3152245f..4f62a17748 100644
--- a/app/core/gimpsymmetry.h
+++ b/app/core/gimpsymmetry.h
@@ -98,6 +98,9 @@ void           gimp_symmetry_get_transform  (GimpSymmetry       *symmetry,
                                              gint                stroke,
                                              gdouble            *angle,
                                              gboolean           *reflect);
+void           gimp_symmetry_get_matrix     (GimpSymmetry       *symmetry,
+                                             gint                stroke,
+                                             GimpMatrix3        *matrix);
 
 gchar        * gimp_symmetry_parasite_name  (GType               type);
 GimpParasite * gimp_symmetry_to_parasite    (const GimpSymmetry *symmetry);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]