[gimp/blend-tool-fun: 6/6] foo
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/blend-tool-fun: 6/6] foo
- Date: Mon, 27 Apr 2015 04:11:08 +0000 (UTC)
commit 67a2849377045faf0be6070bc6d9f7cc2ad5c87d
Author: Michael Henning <drawoc darkrefraction com>
Date: Sun Apr 26 21:38:11 2015 -0400
foo
app/tools/gimpblendtool.c | 57 +++++++++++++++++++++++++++++++++++++++++++-
app/tools/gimpblendtool.h | 4 +++
2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 265653c..97930df 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -915,9 +915,19 @@ gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
static void
gimp_blend_tool_create_graph (GimpBlendTool *blend_tool)
{
+ GimpTool *tool = GIMP_TOOL (blend_tool);
+
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
GimpContext *context = GIMP_CONTEXT (options);
- GeglNode *graph, *output, *render;
+ GeglNode *graph, *output, *render, *shapeburst, *translate, *subtract, *divide;
+ GimpImage *image = gimp_display_get_image (tool->display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GeglBuffer *buf = NULL;
+
+ gint x, y, width, height;
+
+ if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
+ return;
/* render_node is not supposed to be recreated */
g_return_if_fail (blend_tool->graph == NULL);
@@ -931,10 +941,28 @@ gimp_blend_tool_create_graph (GimpBlendTool *blend_tool)
"operation", "gimp:blend",
NULL);
- gegl_node_link (render, output);
+ buf = gimp_drawable_blend_shapeburst_distmap (drawable, FALSE,
+ GEGL_RECTANGLE (0, 0, width, height),
+ GIMP_PROGRESS (blend_tool));
+
+ translate = gegl_node_new_child (graph, "operation", "gegl:translate",
+ "x", (gdouble) x, "y", (gdouble) y, NULL);
+
+ subtract = gegl_node_new_child (graph, "operation", "gegl:subtract", NULL);
+ divide = gegl_node_new_child (graph, "operation", "gegl:divide", NULL);
+
+ shapeburst = gegl_node_new_child (graph, "operation", "gegl:buffer-source",
+ "buffer", buf, NULL);
+
+ gegl_node_link_many (/*render*/shapeburst, translate, subtract, divide, render, output, NULL);
blend_tool->graph = graph;
blend_tool->render_node = render;
+ blend_tool->subtract_node = subtract;
+ blend_tool->divide_node = divide;
+ blend_tool->dist_buffer = buf;
+ blend_tool->dist_buffer_off_x = x;
+ blend_tool->dist_buffer_off_y = y;
gegl_node_set (render,
"context", context,
@@ -955,6 +983,31 @@ gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool)
"end_x", blend_tool->end_x - off_x,
"end_y", blend_tool->end_y - off_y,
NULL);
+
+ gfloat start, end;
+
+ gegl_buffer_get (blend_tool->dist_buffer,
+ GEGL_RECTANGLE (blend_tool->start_x - blend_tool->dist_buffer_off_x,
+ blend_tool->start_y - blend_tool->dist_buffer_off_y,
+ 1, 1),
+ 1.0, babl_format("Y float"), &start,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+
+ gegl_buffer_get (blend_tool->dist_buffer,
+ GEGL_RECTANGLE (blend_tool->end_x - blend_tool->dist_buffer_off_x,
+ blend_tool->end_y - blend_tool->dist_buffer_off_y,
+ 1, 1),
+ 1.0, babl_format("Y float"), &end,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+
+ if (start != end) {
+ gegl_node_set (blend_tool->subtract_node,
+ "value", (gdouble) start,
+ NULL);
+ gegl_node_set (blend_tool->divide_node,
+ "value", (gdouble) (end - start),
+ NULL);
+ }
}
static void
diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h
index 0362b0b..0159491 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -68,6 +68,10 @@ struct _GimpBlendTool
GeglNode *graph;
GeglNode *render_node;
+ GeglNode *subtract_node;
+ GeglNode *divide_node;
+ GeglBuffer *dist_buffer;
+ gint dist_buffer_off_x, dist_buffer_off_y;
GimpImageMap *image_map;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]