[gimp/alxsa-stroke-translate-api: 2/2] pdb: Use floating point offset in stroke_translate




commit b317eceda92939b3949d499077836cfb999aad73
Author: Alx Sa <cmyk student gmail com>
Date:   Fri Oct 7 01:40:26 2022 +0000

    pdb: Use floating point offset in stroke_translate
    
    Update gimp_vectors_stroke_translate () to accept
    floating point values for offset parameters
    like gimp_stroke_translate () does.

 app/pdb/vectors-cmds.c    | 28 ++++++++++++++--------------
 libgimp/gimpvectors_pdb.c |  8 ++++----
 libgimp/gimpvectors_pdb.h |  4 ++--
 pdb/groups/vectors.pdb    |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/app/pdb/vectors-cmds.c b/app/pdb/vectors-cmds.c
index f9dd6a63c4..c4950c2cfc 100644
--- a/app/pdb/vectors-cmds.c
+++ b/app/pdb/vectors-cmds.c
@@ -429,13 +429,13 @@ vectors_stroke_translate_invoker (GimpProcedure         *procedure,
   gboolean success = TRUE;
   GimpVectors *vectors;
   gint stroke_id;
-  gint off_x;
-  gint off_y;
+  gdouble off_x;
+  gdouble off_y;
 
   vectors = g_value_get_object (gimp_value_array_index (args, 0));
   stroke_id = g_value_get_int (gimp_value_array_index (args, 1));
-  off_x = g_value_get_int (gimp_value_array_index (args, 2));
-  off_y = g_value_get_int (gimp_value_array_index (args, 3));
+  off_x = g_value_get_double (gimp_value_array_index (args, 2));
+  off_y = g_value_get_double (gimp_value_array_index (args, 3));
 
   if (success)
     {
@@ -1692,17 +1692,17 @@ register_vectors_procs (GimpPDB *pdb)
                                                  G_MININT32, G_MAXINT32, 0,
                                                  GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
-                               g_param_spec_int ("off-x",
-                                                 "off x",
-                                                 "Offset in x direction",
-                                                 G_MININT32, G_MAXINT32, 0,
-                                                 GIMP_PARAM_READWRITE));
+                               g_param_spec_double ("off-x",
+                                                    "off x",
+                                                    "Offset in x direction",
+                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+                                                    GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
-                               g_param_spec_int ("off-y",
-                                                 "off y",
-                                                 "Offset in y direction",
-                                                 G_MININT32, G_MAXINT32, 0,
-                                                 GIMP_PARAM_READWRITE));
+                               g_param_spec_double ("off-y",
+                                                    "off y",
+                                                    "Offset in y direction",
+                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
+                                                    GIMP_PARAM_READWRITE));
   gimp_pdb_register_procedure (pdb, procedure);
   g_object_unref (procedure);
 
diff --git a/libgimp/gimpvectors_pdb.c b/libgimp/gimpvectors_pdb.c
index 0d8b6f85af..5ea35a2b06 100644
--- a/libgimp/gimpvectors_pdb.c
+++ b/libgimp/gimpvectors_pdb.c
@@ -444,8 +444,8 @@ gimp_vectors_stroke_reverse (GimpVectors *vectors,
 gboolean
 gimp_vectors_stroke_translate (GimpVectors *vectors,
                                gint         stroke_id,
-                               gint         off_x,
-                               gint         off_y)
+                               gdouble      off_x,
+                               gdouble      off_y)
 {
   GimpValueArray *args;
   GimpValueArray *return_vals;
@@ -454,8 +454,8 @@ gimp_vectors_stroke_translate (GimpVectors *vectors,
   args = gimp_value_array_new_from_types (NULL,
                                           GIMP_TYPE_VECTORS, vectors,
                                           G_TYPE_INT, stroke_id,
-                                          G_TYPE_INT, off_x,
-                                          G_TYPE_INT, off_y,
+                                          G_TYPE_DOUBLE, off_x,
+                                          G_TYPE_DOUBLE, off_y,
                                           G_TYPE_NONE);
 
   return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
diff --git a/libgimp/gimpvectors_pdb.h b/libgimp/gimpvectors_pdb.h
index a8424e95f0..a48a77a35e 100644
--- a/libgimp/gimpvectors_pdb.h
+++ b/libgimp/gimpvectors_pdb.h
@@ -58,8 +58,8 @@ gboolean              gimp_vectors_stroke_reverse            (GimpVectors
                                                               gint                     stroke_id);
 gboolean              gimp_vectors_stroke_translate          (GimpVectors             *vectors,
                                                               gint                     stroke_id,
-                                                              gint                     off_x,
-                                                              gint                     off_y);
+                                                              gdouble                  off_x,
+                                                              gdouble                  off_y);
 gboolean              gimp_vectors_stroke_scale              (GimpVectors             *vectors,
                                                               gint                     stroke_id,
                                                               gdouble                  scale_x,
diff --git a/pdb/groups/vectors.pdb b/pdb/groups/vectors.pdb
index 73c394567d..759cd26597 100644
--- a/pdb/groups/vectors.pdb
+++ b/pdb/groups/vectors.pdb
@@ -392,9 +392,9 @@ HELP
          desc => 'The vectors object' },
        { name => 'stroke_id', type => 'int32',
          desc => 'The stroke ID' },
-       { name => "off_x", type => 'int32',
+       { name => "off_x", type => 'float',
           desc => "Offset in x direction" },
-       { name => "off_y", type => 'int32',
+       { name => "off_y", type => 'float',
           desc => "Offset in y direction" }
     );
 
@@ -1333,7 +1333,7 @@ CODE
 @procs = qw(vectors_new
            vectors_new_from_text_layer
             vectors_copy
-            vectors_get_strokes 
+            vectors_get_strokes
             vectors_stroke_get_length
             vectors_stroke_get_point_at_dist
             vectors_remove_stroke


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