[gimp] Paint Select tool: apply a threshold on the image mask before triggering...



commit 7d753c6f54d3482d34dd3759e340bbf4919b11cf
Author: Thomas Manni <thomas manni free fr>
Date:   Sun Jan 10 15:28:46 2021 +0100

    Paint Select tool: apply a threshold on the image mask before triggering...
    
    ...the automatic expansion to simplify mask handling in the gegl
    paint-select operation.

 app/tools/gimppaintselecttool.c | 8 +++++++-
 app/tools/gimppaintselecttool.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/app/tools/gimppaintselecttool.c b/app/tools/gimppaintselecttool.c
index a0c4d10604..9732f612dd 100644
--- a/app/tools/gimppaintselecttool.c
+++ b/app/tools/gimppaintselecttool.c
@@ -460,10 +460,12 @@ gimp_paint_select_tool_motion (GimpTool         *tool,
               if (options->mode == GIMP_PAINT_SELECT_MODE_ADD)
                 {
                   gegl_node_set (ps_tool->ps_node, "mode", 0, NULL);
+                  gegl_node_set (ps_tool->threshold_node, "value", 0.99, NULL);
                 }
               else
                 {
                   gegl_node_set (ps_tool->ps_node, "mode", 1, NULL);
+                  gegl_node_set (ps_tool->threshold_node, "value", 0.01, NULL);
                 }
 
               gegl_node_set (ps_tool->render_node, "buffer", &result, NULL);
@@ -776,6 +778,10 @@ gimp_paint_select_tool_create_graph (GimpPaintSelectTool  *ps_tool)
                               "height", (gdouble) gegl_buffer_get_height (ps_tool->drawable),
                               NULL);
 
+  ps_tool->threshold_node = gegl_node_new_child (ps_tool->graph,
+                                                 "operation", "gegl:threshold",
+                                                 NULL);
+
   if (ps_tool->drawable_off_x || ps_tool->drawable_off_y)
     {
       translate = gegl_node_new_child (ps_tool->graph,
@@ -805,7 +811,7 @@ gimp_paint_select_tool_create_graph (GimpPaintSelectTool  *ps_tool)
                                              NULL);
 
   
-  gegl_node_link (m, crop);
+  gegl_node_link_many (m, ps_tool->threshold_node, crop, NULL);
 
   if (translate)
     gegl_node_link_many (crop, translate, ps_tool->ps_node, ps_tool->render_node, NULL);
diff --git a/app/tools/gimppaintselecttool.h b/app/tools/gimppaintselecttool.h
index f7f4c19ac8..f5008aa90d 100644
--- a/app/tools/gimppaintselecttool.h
+++ b/app/tools/gimppaintselecttool.h
@@ -49,6 +49,7 @@ struct _GimpPaintSelectTool
 
   GeglNode              *graph;
   GeglNode              *ps_node;
+  GeglNode              *threshold_node;
   GeglNode              *render_node;
 
   GimpVector2            last_pos;


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