Пример #1
0
static gboolean paint_press (GtkWidget      *widget,
                             GdkEventButton *event)
{
  if (event->button == 1)
    {
      vector     = gegl_path_new ();

      over       = gegl_node_new_child (gegl, "operation", "gegl:over", NULL);
      stroke     = gegl_node_new_child (gegl, "operation", "gegl:path",
                                        "d", vector,
                                        "fill-opacity", 0.0,
                                        "stroke", gegl_color_new (COLOR),
                                        "stroke-width", LINEWIDTH,
                                        "stroke-hardness", HARDNESS,
                                        NULL);
      gegl_node_link_many (top, over, out, NULL);
      gegl_node_connect_to (stroke, "output", over, "aux");
      gegl_path_append (vector, 'M', event->x, event->y);

      pen_down = TRUE;

      return TRUE;
    }
  return FALSE;
}
Пример #2
0
static void
gimp_warp_tool_button_press (GimpTool            *tool,
                             const GimpCoords    *coords,
                             guint32              time,
                             GdkModifierType      state,
                             GimpButtonPressType  press_type,
                             GimpDisplay         *display)
{
  GimpWarpTool    *wt      = GIMP_WARP_TOOL (tool);
  GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt);
  GeglNode        *new_op;
  gint             off_x, off_y;

  if (tool->display && display != tool->display)
    {
      gimp_tool_pop_status (tool, tool->display);
      gimp_warp_tool_halt (wt);
    }

  if (! tool->display)
    {
      if (! gimp_warp_tool_start (wt, display))
        return;
    }

  wt->current_stroke = gegl_path_new ();

  new_op = gegl_node_new_child (NULL,
                                "operation", "gegl:warp",
                                "behavior",  options->behavior,
                                "strength",  options->effect_strength,
                                "size",      options->effect_size,
                                "hardness",  options->effect_hardness,
                                "stroke",    wt->current_stroke,
                                NULL);

  gimp_warp_tool_add_op (wt, new_op);
  g_object_unref (new_op);

  g_signal_connect (wt->current_stroke, "changed",
                    G_CALLBACK (gimp_warp_tool_stroke_changed),
                    wt);

  gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y);

  gegl_path_append (wt->current_stroke,
                    'M', coords->x - off_x, coords->y - off_y);

  wt->stroke_timer = g_timeout_add (STROKE_PERIOD,
                                    (GSourceFunc) gimp_warp_tool_stroke_timer,
                                    wt);

  gimp_tool_control_activate (tool->control);
}