static void gimp_warp_tool_update_stroke (GimpWarpTool *wt, GeglNode *node) { GeglPath *stroke; gdouble size; gegl_node_get (node, "stroke", &stroke, "size", &size, NULL); if (stroke) { gdouble min_x; gdouble max_x; gdouble min_y; gdouble max_y; GeglRectangle bbox; gegl_path_get_bounds (stroke, &min_x, &max_x, &min_y, &max_y); g_object_unref (stroke); bbox.x = min_x - size * 0.5; bbox.y = min_y - size * 0.5; bbox.width = max_x - min_x + size; bbox.height = max_y - min_y + size; gimp_image_map_apply (wt->image_map, &bbox); } }
static void path_changed (GeglPath *path, const GeglRectangle *roi, gpointer userdata) { GeglChantO *o = GEGL_CHANT_PROPERTIES (userdata); GeglRectangle rect; gdouble x0, x1, y0, y1; gegl_path_get_bounds(o->d, &x0, &x1, &y0, &y1); rect.x = x0 - 1; rect.y = y0 - 1; rect.width = x1 - x0 + 2; rect.height = y1 - y0 + 2; gegl_operation_invalidate (userdata, &rect, TRUE); };
static gboolean paint_release (GtkWidget *widget, GdkEventButton *event) { if (event->button == 1) { gdouble x0, x1, y0, y1; GeglProcessor *processor; GeglNode *writebuf; GeglRectangle roi; gegl_path_get_bounds (vector, &x0, &x1, &y0, &y1); roi.x = x0 - LINEWIDTH; roi.y = y0 - LINEWIDTH; roi.width = x1 - x0 + LINEWIDTH * 2; roi.height = y1 - y0 + LINEWIDTH * 2; writebuf = gegl_node_new_child (gegl, "operation", "gegl:write-buffer", "buffer", buffer, NULL); gegl_node_link_many (over, writebuf, NULL); processor = gegl_node_new_processor (writebuf, &roi); while (gegl_processor_work (processor, NULL)) ; gegl_processor_destroy (processor); g_object_unref (writebuf); gegl_node_link_many (top, out, NULL); g_object_unref (over); g_object_unref (stroke); over = NULL; stroke = NULL; pen_down = FALSE; return TRUE; } return FALSE; }
static GeglRectangle get_bounding_box (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglRectangle defined = { 0, 0, 512, 512 }; GeglRectangle *in_rect; gdouble x0, x1, y0, y1; in_rect = gegl_operation_source_get_bounding_box (operation, "input"); gegl_path_get_bounds (o->d, &x0, &x1, &y0, &y1); defined.x = x0; defined.y = y0; defined.width = x1 - x0; defined.height = y1 - y0; if (in_rect) { gegl_rectangle_bounding_box (&defined, &defined, in_rect); } return defined; }
static void gimp_warp_tool_update_stroke (GimpWarpTool *wt, GeglNode *node) { GeglPath *stroke; gdouble size; gegl_node_get (node, "stroke", &stroke, "size", &size, NULL); if (stroke) { gdouble min_x; gdouble max_x; gdouble min_y; gdouble max_y; GeglRectangle bbox; gegl_path_get_bounds (stroke, &min_x, &max_x, &min_y, &max_y); g_object_unref (stroke); bbox.x = min_x - size * 0.5; bbox.y = min_y - size * 0.5; bbox.width = max_x - min_x + size; bbox.height = max_y - min_y + size; #ifdef WARP_DEBUG g_printerr ("update stroke: (%d,%d), %dx%d\n", bbox.x, bbox.y, bbox.width, bbox.height); #endif gimp_drawable_filter_apply (wt->filter, &bbox); } }