Beispiel #1
0
static void
vectors_new_callback (GtkWidget    *dialog,
                      GimpImage    *image,
                      GimpVectors  *vectors,
                      GimpContext  *context,
                      const gchar  *vectors_name,
                      gboolean      vectors_visible,
                      gboolean      vectors_linked,
                      GimpColorTag  vectors_color_tag,
                      gboolean      vectors_lock_content,
                      gboolean      vectors_lock_position,
                      gpointer      user_data)
{
  GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);

  g_object_set (config,
                "path-new-name", vectors_name,
                NULL);

  vectors = gimp_vectors_new (image, config->vectors_new_name);
  gimp_item_set_visible (GIMP_ITEM (vectors), vectors_visible, FALSE);
  gimp_item_set_linked (GIMP_ITEM (vectors), vectors_linked, FALSE);
  gimp_item_set_color_tag (GIMP_ITEM (vectors), vectors_color_tag, FALSE);
  gimp_item_set_lock_content (GIMP_ITEM (vectors), vectors_lock_content, FALSE);
  gimp_item_set_lock_position (GIMP_ITEM (vectors), vectors_lock_position, FALSE);

  gimp_image_add_vectors (image, vectors,
                          GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
  gimp_image_flush (image);

  gtk_widget_destroy (dialog);
}
static int
vectors_init(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
{
    PyGimpImage *img;
    char *name;

    static char *kwlist[] = { "image", "name", NULL };

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     "O!s:gimp.Vectors.__init__",
                                     kwlist,
                                     &PyGimpImage_Type, &img, &name))
        return -1;

    self->ID = gimp_vectors_new(img->ID, name);

    if (self->ID < 0) {
        PyErr_Format(pygimp_error,
                     "could not create vectors '%s' on image (ID %d)",
                     name, img->ID);
        return -1;
    }

    return 0;
}
Beispiel #3
0
GimpVectors *
gimp_text_vectors_new (GimpImage *image,
                       GimpText  *text)
{
  GimpVectors    *vectors;
  GimpTextLayout *layout;
  RenderContext   context = { 0, };

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);

  vectors = gimp_vectors_new (image, NULL);

  if (text->text)
    {
      gimp_object_set_name_safe (GIMP_OBJECT (vectors), text->text);

      layout = gimp_text_layout_new (text, image);

      context.vectors = vectors;

      gimp_text_layout_render (layout,
                               (GimpTextRenderFunc) gimp_text_render_vectors,
                               &context);

      g_object_unref (layout);

      if (context.stroke)
        gimp_stroke_close (context.stroke);
    }

  return vectors;
}
Beispiel #4
0
static GimpItem *
gimp_vectors_tree_view_item_new (GimpImage *image)
{
  GimpVectors *new_vectors;

  new_vectors = gimp_vectors_new (image, _("Empty Path"));

  gimp_image_add_vectors (image, new_vectors, -1);

  return GIMP_ITEM (new_vectors);
}
static GimpItem *
gimp_vectors_tree_view_item_new (GimpImage *image)
{
  GimpVectors *new_vectors;

  new_vectors = gimp_vectors_new (image, _("Path"));

  gimp_image_add_vectors (image, new_vectors,
                          GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);

  return GIMP_ITEM (new_vectors);
}
Beispiel #6
0
void
vectors_new_last_vals_cmd_callback (GtkAction *action,
                                    gpointer   data)
{
  GimpImage   *image;
  GimpVectors *new_vectors;
  return_if_no_image (image, data);

  new_vectors = gimp_vectors_new (image,
                                  vectors_name ? vectors_name : _("New Path"));

  gimp_image_add_vectors (image, new_vectors, -1);

  gimp_image_flush (image);
}
Beispiel #7
0
void
vectors_new_last_vals_cmd_callback (GtkAction *action,
                                    gpointer   data)
{
  GimpImage        *image;
  GimpVectors      *vectors;
  GimpDialogConfig *config;
  return_if_no_image (image, data);

  config = GIMP_DIALOG_CONFIG (image->gimp->config);

  vectors = gimp_vectors_new (image, config->vectors_new_name);
  gimp_image_add_vectors (image, vectors,
                          GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
  gimp_image_flush (image);
}
Beispiel #8
0
static void
vectors_new_vectors_response (GtkWidget            *widget,
                              gint                  response_id,
                              VectorsOptionsDialog *options)
{
  if (response_id == GTK_RESPONSE_OK)
    {
      GimpVectors *new_vectors;

      if (vectors_name)
        g_free (vectors_name);

      vectors_name =
        g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));

      new_vectors = gimp_vectors_new (options->image, vectors_name);

      gimp_image_add_vectors (options->image, new_vectors, -1);

      gimp_image_flush (options->image);
    }

  gtk_widget_destroy (options->dialog);
}
static void
do_points (spline_list_array_type in_splines,
           gint32                 image_ID)
{
  gint32   vectors;
  gint32   stroke;
  gint     i, j;
  gboolean have_points = FALSE;
  spline_list_type spline_list;

  /* check if there really is something to do... */
  for (i = 0; i < SPLINE_LIST_ARRAY_LENGTH (in_splines); i++)
    {
      spline_list = SPLINE_LIST_ARRAY_ELT (in_splines, i);
      /* Ignore single points that are on their own */
      if (SPLINE_LIST_LENGTH (spline_list) < 2)
        continue;
      have_points = TRUE;
      break;
    }

  if (!have_points)
    return;

  vectors = gimp_vectors_new (image_ID, _("Selection"));

  for (j = 0; j < SPLINE_LIST_ARRAY_LENGTH (in_splines); j++)
    {
      spline_type seg;

      spline_list = SPLINE_LIST_ARRAY_ELT (in_splines, j);

      /* Ignore single points that are on their own */
      if (SPLINE_LIST_LENGTH (spline_list) < 2)
        continue;

      seg = SPLINE_LIST_ELT (spline_list, 0);
      stroke = gimp_vectors_bezier_stroke_new_moveto (vectors,
                                                      START_POINT (seg).x,
                                                      START_POINT (seg).y);

      for (i = 0; i < SPLINE_LIST_LENGTH (spline_list); i++)
        {
          seg = SPLINE_LIST_ELT (spline_list, i);

          if (SPLINE_DEGREE (seg) == LINEAR)
            gimp_vectors_bezier_stroke_lineto (vectors, stroke,
                                               END_POINT (seg).x,
                                               END_POINT (seg).y);
          else if (SPLINE_DEGREE (seg) == CUBIC)
            gimp_vectors_bezier_stroke_cubicto (vectors, stroke,
                                                CONTROL1 (seg).x,
                                                CONTROL1 (seg).y,
                                                CONTROL2 (seg).x,
                                                CONTROL2 (seg).y,
                                                END_POINT (seg).x,
                                                END_POINT (seg).y);
          else
            g_warning ("print_spline: strange degree (%d)",
                       SPLINE_DEGREE (seg));
        }

      gimp_vectors_stroke_close (vectors, stroke);

      /* transform to GIMPs coordinate system, taking the selections
       * bounding box into account  */
      gimp_vectors_stroke_scale (vectors, stroke, 1.0, -1.0);
      gimp_vectors_stroke_translate (vectors, stroke,
                                     sel_x1, sel_y1 + sel_height + 1);
    }

  gimp_image_insert_vectors (image_ID, vectors, -1, -1);
}