[gimp] Adds new blending mode 'Truncate blend'



commit ad4862c60bddd61414b7a12acd46e7b669fe02ee
Author: João S. O. Bueno <gwidion gmail com>
Date:   Thu Apr 24 12:18:26 2014 -0300

    Adds new blending mode 'Truncate blend'
    
    Bring repeat behavior on par with GEGL and Cairo,
    and sane ways of creating square or circular gradient
    shapes.

 app/core/gimpdrawable-blend.c |    9 ++++++++-
 app/pdb/edit-cmds.c           |    2 +-
 libgimpbase/gimpbaseenums.c   |    2 ++
 libgimpbase/gimpbaseenums.h   |    5 +++--
 tools/pdbgen/enums.pl         |   19 +++++++++++--------
 5 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c
index e34f4c0..d23edf3 100644
--- a/app/core/gimpdrawable-blend.c
+++ b/app/core/gimpdrawable-blend.c
@@ -724,6 +724,8 @@ gradient_render_pixel (gdouble   x,
 
   switch (rbd->repeat)
     {
+    case GIMP_REPEAT_TRUNCATE:
+      break;
     case GIMP_REPEAT_NONE:
       factor = CLAMP (factor, 0.0, 1.0);
       break;
@@ -750,7 +752,12 @@ gradient_render_pixel (gdouble   x,
 
   /* Blend the colors */
 
-  if (rbd->blend_mode == GIMP_CUSTOM_MODE)
+  if (factor < 0.0 || factor > 1.0)
+    {
+      color->r = color->g = color->b = 0;
+      color->a = GIMP_OPACITY_TRANSPARENT;
+    }
+  else if (rbd->blend_mode == GIMP_CUSTOM_MODE)
     {
 #ifdef USE_GRADIENT_CACHE
       *color = rbd->gradient_cache[(gint) (factor * (rbd->gradient_cache_size - 1))];
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index 03ac9c3..ce483c9 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -1495,7 +1495,7 @@ register_edit_procs (GimpPDB *pdb)
                                                   "repeat",
                                                   "Repeat mode",
                                                   GIMP_TYPE_REPEAT_MODE,
-                                                  GIMP_REPEAT_NONE,
+                                                  GIMP_REPEAT_TRUNCATE,
                                                   GIMP_PARAM_READWRITE));
   gimp_procedure_add_argument (procedure,
                                g_param_spec_boolean ("reverse",
diff --git a/libgimpbase/gimpbaseenums.c b/libgimpbase/gimpbaseenums.c
index 5609009..85285a6 100644
--- a/libgimpbase/gimpbaseenums.c
+++ b/libgimpbase/gimpbaseenums.c
@@ -635,6 +635,7 @@ gimp_repeat_mode_get_type (void)
 {
   static const GEnumValue values[] =
   {
+    { GIMP_REPEAT_TRUNCATE, "GIMP_REPEAT_TRUNCATE", "truncate" },
     { GIMP_REPEAT_NONE, "GIMP_REPEAT_NONE", "none" },
     { GIMP_REPEAT_SAWTOOTH, "GIMP_REPEAT_SAWTOOTH", "sawtooth" },
     { GIMP_REPEAT_TRIANGULAR, "GIMP_REPEAT_TRIANGULAR", "triangular" },
@@ -643,6 +644,7 @@ gimp_repeat_mode_get_type (void)
 
   static const GimpEnumDesc descs[] =
   {
+    { GIMP_REPEAT_TRUNCATE, NC_("repeat-mode", "Truncate blending"), NULL },
     { GIMP_REPEAT_NONE, NC_("repeat-mode", "None"), NULL },
     { GIMP_REPEAT_SAWTOOTH, NC_("repeat-mode", "Sawtooth wave"), NULL },
     { GIMP_REPEAT_TRIANGULAR, NC_("repeat-mode", "Triangular wave"), NULL },
diff --git a/libgimpbase/gimpbaseenums.h b/libgimpbase/gimpbaseenums.h
index c7115cb..bd18a60 100644
--- a/libgimpbase/gimpbaseenums.h
+++ b/libgimpbase/gimpbaseenums.h
@@ -171,7 +171,7 @@ GType gimp_foreground_extract_mode_get_type (void) G_GNUC_CONST;
 typedef enum
 {
   GIMP_FOREGROUND_EXTRACT_SIOX,
-  GIMP_FOREGROUND_EXTRACT_MATTING 
+  GIMP_FOREGROUND_EXTRACT_MATTING
 } GimpForegroundExtractMode;
 
 
@@ -259,7 +259,7 @@ typedef enum
   GIMP_INTERPOLATION_CUBIC,  /*< desc="Cubic"  >*/
   GIMP_INTERPOLATION_NOHALO, /*< desc="NoHalo" >*/
   GIMP_INTERPOLATION_LOHALO, /*< desc="LoHalo" >*/
-  GIMP_INTERPOLATION_LANCZOS = GIMP_INTERPOLATION_NOHALO /*< skip */
+  GIMP_INTERPOLATION_LANCZOS = GIMP_INTERPOLATION_NOHALO /*< skip >*/
 } GimpInterpolationType;
 
 
@@ -280,6 +280,7 @@ GType gimp_repeat_mode_get_type (void) G_GNUC_CONST;
 
 typedef enum
 {
+  GIMP_REPEAT_TRUNCATE,   /*< desc="Truncate blending" >*/
   GIMP_REPEAT_NONE,       /*< desc="None"            >*/
   GIMP_REPEAT_SAWTOOTH,   /*< desc="Sawtooth wave"   >*/
   GIMP_REPEAT_TRIANGULAR  /*< desc="Triangular wave" >*/
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index d8bff5b..1cb0d0c 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -175,16 +175,18 @@ package Gimp::CodeGen::enums;
                       GIMP_INDEXEDA_IMAGE => '5' }
        },
     GimpInterpolationType =>
-       { contig => 1,
+       { contig => 0,
          header => 'libgimpbase/gimpbaseenums.h',
          symbols => [ qw(GIMP_INTERPOLATION_NONE GIMP_INTERPOLATION_LINEAR
                          GIMP_INTERPOLATION_CUBIC GIMP_INTERPOLATION_NOHALO
-                         GIMP_INTERPOLATION_LOHALO) ],
+                         GIMP_INTERPOLATION_LOHALO
+                         GIMP_INTERPOLATION_LANCZOS) ],
          mapping => { GIMP_INTERPOLATION_NONE => '0',
                       GIMP_INTERPOLATION_LINEAR => '1',
                       GIMP_INTERPOLATION_CUBIC => '2',
                       GIMP_INTERPOLATION_NOHALO => '3',
-                      GIMP_INTERPOLATION_LOHALO => '4' }
+                      GIMP_INTERPOLATION_LOHALO => '4',
+                      GIMP_INTERPOLATION_LANCZOS => 'GIMP_INTERPOLATION_NOHALO' }
        },
     GimpPaintApplicationMode =>
        { contig => 1,
@@ -196,11 +198,12 @@ package Gimp::CodeGen::enums;
     GimpRepeatMode =>
        { contig => 1,
          header => 'libgimpbase/gimpbaseenums.h',
-         symbols => [ qw(GIMP_REPEAT_NONE GIMP_REPEAT_SAWTOOTH
-                         GIMP_REPEAT_TRIANGULAR) ],
-         mapping => { GIMP_REPEAT_NONE => '0',
-                      GIMP_REPEAT_SAWTOOTH => '1',
-                      GIMP_REPEAT_TRIANGULAR => '2' }
+         symbols => [ qw(GIMP_REPEAT_TRUNCATE GIMP_REPEAT_NONE
+                         GIMP_REPEAT_SAWTOOTH GIMP_REPEAT_TRIANGULAR) ],
+         mapping => { GIMP_REPEAT_TRUNCATE => '0',
+                      GIMP_REPEAT_NONE => '1',
+                      GIMP_REPEAT_SAWTOOTH => '2',
+                      GIMP_REPEAT_TRIANGULAR => '3' }
        },
     GimpRunMode =>
        { contig => 1,


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